:root {
    --red: #E31C23;
    --red-soft: rgba(227, 28, 35, 0.12);
    --black: #111111;
    --bg: #f3f4f6;
    --card: #ffffff;
    --muted: #6b6b6b;
    --line: #ececec;
    --shadow: 0 10px 30px rgba(17, 17, 17, 0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: Outfit, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--black);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.admin-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: #111;
    color: #fff;
    padding: 22px 16px 18px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 16px;
}
.brand img {
    height: 36px;
    width: auto;
    background: #fff;
    border-radius: 9px;
    padding: 2px;
}
.brand strong { display: block; font-size: 15px; letter-spacing: -0.02em; }
.brand span { display: block; font-size: 11px; color: #9a9a9a; font-weight: 500; }
.nav-label {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #7a7a7a;
    padding: 8px 12px 6px;
    font-weight: 700;
}
.sidebar-nav { flex: 1; }
.sidebar a {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
    color: #e8e8e8;
}
.sidebar a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar a.active {
    background: var(--red);
    color: #fff;
}
.sidebar-foot {
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-foot a { color: #bbb; font-weight: 600; }
.topbar {
    background: rgba(255,255,255,0.86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar strong { font-size: 18px; letter-spacing: -0.02em; }
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f6f6f7;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px 6px 6px;
    font-size: 13px;
    font-weight: 600;
}
.user-chip i {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    display: grid;
    place-items: center;
    font-style: normal;
    font-size: 12px;
    font-weight: 800;
}
.admin-main { min-width: 0; }
.nav-toggle { display: none; }
.sidebar-backdrop { display: none; }
.content { padding: 24px 28px 56px; }
.pw-warn {
    background: #fff3cd;
    border: 1px solid #f5d78a;
    color: #7a5b00;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
}
.pw-warn a { color: var(--red); font-weight: 800; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow);
}
a.stat {
    display: block;
    color: inherit;
    text-decoration: none;
}
a.stat:hover {
    border-color: var(--red);
}
.stat span { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat b {
    display: block;
    font-size: 30px;
    color: var(--black);
    margin-top: 8px;
    letter-spacing: -0.03em;
}
.stat b em { font-style: normal; color: var(--red); }
.dash-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
.dash-charts .card h3,
.card h3 {
    margin: 0 0 6px;
    font-size: 16px;
}
.chart-wrap {
    position: relative;
    height: 260px;
}
.chart-wrap-donut { height: 280px; }
.dash-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.dash-date-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
}
.dash-date-filter label,
.dash-date-filter-action {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dash-date-filter-spacer {
    line-height: 1;
    height: 16px;
}
.dash-date-filter input[type=date],
.dash-date-filter .btn {
    height: 40px;
    margin: 0;
    box-sizing: border-box;
}
.dash-date-filter input[type=date] {
    font-weight: 600;
    min-width: 140px;
}
.dash-date-filter .select2-container {
    min-width: 140px;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: #fafafa; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
}
.btn:hover { opacity: 0.92; }
.btn-dark { background: #111; }
.btn-ghost { background: #f1f1f2; color: #111; }
.btn-ghost.is-on { background: var(--red); color: #fff; }
.btn-line {
    border: 1px solid #cfcfcf;
    background: #fff;
    color: #111;
}
.btn-line.is-on {
    border-color: #9a1217;
}
.form-row { margin-bottom: 14px; }
.color-pick {
    display: flex;
    align-items: center;
    gap: 10px;
}
.color-pick input[type=color] {
    width: 52px;
    height: 44px;
    padding: 4px;
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}
.color-pick .js-color-hex {
    flex: 1;
    font-family: ui-monospace, Consolas, monospace;
    text-transform: uppercase;
}
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=date], input[type=email], textarea, select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    font: inherit;
    background: #fafafa;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    background: #fff;
    border-color: rgba(227, 28, 35, 0.5);
    box-shadow: 0 0 0 4px var(--red-soft);
}
.note-editor.note-frame,
.note-editor.note-airframe {
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    background: #fff;
}
.note-editor .note-toolbar {
    background: #fafafa;
    border-bottom: 1px solid #ececec;
    border-radius: 12px 12px 0 0;
}
.note-editor .note-statusbar { border-radius: 0 0 12px 12px; }
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.ok { background: #e8f5e9; color: #1b5e20; }
.err { background: #ffebee; color: #b71c1c; }
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(800px 280px at 10% -10%, rgba(227, 28, 35, 0.16), transparent 50%),
        var(--bg);
    padding: 24px;
}
.login-card {
    width: min(420px, 92vw);
    background: #fff;
    padding: 32px 28px;
    border-radius: 22px;
    border: 1px solid var(--line);
    box-shadow: 0 18px 50px rgba(17, 17, 17, 0.08);
}
.login-card h1 { margin: 8px 0 4px; font-size: 24px; letter-spacing: -0.03em; }
.login-card > p { margin: 0 0 18px; color: var(--muted); }
.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.login-brand img {
    height: 40px;
    background: #fff;
    border-radius: 10px;
}
.login-card .btn { width: 100%; padding: 12px; border-radius: 12px; margin-top: 4px; }
.login-card p a { color: var(--muted); font-weight: 600; font-size: 13px; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; }
.badge-on { background: #e8f5e9; color: #1b5e20; }
.badge-off { background: #eee; color: #666; }
.badge-soon { background: #fff3e0; color: #e65100; }
.status-opt { font-weight: 500; margin: 6px 0; }
.hint-admin { color: var(--muted); font-size: 13px; line-height: 1.5; }
.drag-handle {
    cursor: grab;
    color: #bbb;
    font-weight: 800;
    letter-spacing: 2px;
    width: 36px;
    user-select: none;
}
.drag-handle:active { cursor: grabbing; }
tr.sortable-ghost { opacity: 0.45; background: #fff5f5; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.select2-container .select2-selection--single {
    height: 40px;
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    background: #fff;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
    padding-left: 12px;
    color: #111;
    font-size: 14px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px;
}
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: rgba(227, 28, 35, 0.45);
    box-shadow: 0 0 0 4px var(--red-soft);
}
.select2-dropdown {
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(0,0,0,0.08);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #e4e4e4;
    border-radius: 8px;
    padding: 6px 10px;
}
.select2-container--default .select2-results__option {
    padding: 8px 12px;
    font-size: 14px;
}
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: var(--red);
    color: #fff;
}
.notice-toast {
    position: fixed;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 95;
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(560px, calc(100% - 32px));
    background: #1aa3a1;
    color: #fff;
    border-radius: 16px;
    padding: 14px 42px 14px 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    animation: noticeIn .28s ease;
}
.notice-toast.is-err { background: #d32f2f; }
.notice-toast p { margin: 0; font-size: 14px; line-height: 1.45; font-weight: 500; }
.notice-toast p strong { font-weight: 800; margin-right: 4px; }
.notice-ico { flex-shrink: 0; }
.notice-x {
    position: absolute;
    top: 8px;
    right: 10px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
}
.notice-x:hover { opacity: 1; }
.storage-meter {
    height: 8px;
    background: #eee;
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0 16px;
}
.storage-meter span {
    display: block;
    height: 100%;
    background: #E31C23;
    border-radius: 999px;
}
.dropzone {
    position: relative;
    display: block;
    cursor: pointer;
    border: 1.5px dashed #d8d8d8;
    border-radius: 16px;
    background: #fafafa;
    padding: 22px 16px;
    text-align: center;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.dropzone:hover, .dropzone.is-drag {
    border-color: var(--red);
    background: var(--red-soft);
    box-shadow: 0 0 0 4px rgba(227, 28, 35, 0.06);
}
.dropzone.is-disabled {
    cursor: not-allowed;
    opacity: 0.55;
    pointer-events: none;
}
.dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.dropzone-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}
.dropzone-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #fff;
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(17,17,17,0.06);
}
.dropzone-title {
    font-weight: 700;
    font-size: 14px;
    margin-top: 4px;
}
.dropzone-sub, .dropzone-name {
    font-size: 12px;
    color: var(--muted);
}
.dropzone-name { font-weight: 600; color: #111; }
.dropzone.has-file .dropzone-title,
.dropzone.has-file .dropzone-sub,
.dropzone.has-file .ads-size-hints,
.dropzone.has-file .ads-size-note { display: none; }
.dropzone-preview {
    max-height: 88px;
    max-width: 160px;
    border-radius: 10px;
    object-fit: cover;
    display: block;
}
.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
}
.settings-tab {
    appearance: none;
    border: 1px solid #cfcfcf;
    background: #fff;
    color: #111;
    border-radius: 999px;
    padding: 8px 16px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.settings-tab:hover { border-color: #b8b8b8; }
.settings-tab.is-on {
    background: var(--red);
    border-color: #9a1217;
    color: #fff;
}
.settings-panel h3 { margin-top: 0; }
.posts-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 18px;
}
.posts-storage { flex: 1; max-width: 320px; }
.posts-storage-label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.posts-head .storage-meter {
    margin: 8px 0 0;
    height: 6px;
    max-width: 240px;
}
.posts-card { padding: 0; overflow-x: auto; }
.posts-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}
.posts-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.posts-tab {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #6b6b6b;
}
.posts-tab:hover { background: #f6f6f7; color: #111; }
.posts-tab.is-on {
    background: var(--red-soft);
    color: var(--red);
}
.posts-search-form { margin: 0; }
.posts-search {
    width: 220px;
    padding: 9px 12px;
    border: 1px solid #e4e4e4;
    border-radius: 10px;
    background: #fafafa;
    font: inherit;
    font-size: 13px;
}
.posts-card table { margin: 0; }
.posts-card th, .posts-card td { padding: 14px 16px; }
.posts-title { font-weight: 700; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions form { margin: 0; }
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}
.icon-btn-edit { background: #e8f1fb; color: #1d6fb8; }
.icon-btn-del { background: #fdecea; color: #c62828; }
.icon-btn:hover { opacity: 0.88; }
.icon-btn-edit.is-on { background: #1d6fb8; color: #fff; }
.badge-status-active { background: #22c55e; color: #fff; }
.badge-status-upcoming { background: #f59e0b; color: #fff; }
.badge-status-inactive { background: #9ca3af; color: #fff; }
@keyframes noticeIn {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
@media (max-width: 900px) {
    .admin-shell { grid-template-columns: 1fr; }
    .nav-toggle {
        display: inline-grid;
        place-items: center;
        width: 40px;
        height: 40px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 10px;
        background: #f1f1f2;
        color: #111;
        cursor: pointer;
        flex-shrink: 0;
    }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 50;
        width: min(280px, 86vw);
        height: 100vh;
        height: 100dvh;
        transform: translateX(-105%);
        transition: transform .22s ease;
        overflow-y: auto;
    }
    .admin-shell.nav-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(17, 17, 17, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }
    .admin-shell.nav-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
    body.nav-lock { overflow: hidden; }
    .topbar {
        padding: 12px 14px;
        gap: 10px;
    }
    .topbar-title {
        flex: 1;
        min-width: 0;
        font-size: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .chip-name { display: none; }
    .user-chip { padding: 4px; }
    .content { padding: 16px 14px 48px; }
    .stats { grid-template-columns: 1fr 1fr; }
    .stat { padding: 14px; }
    .stat b { font-size: 24px; }
    .dash-charts { grid-template-columns: 1fr; }
    .chart-wrap, .chart-wrap-donut { height: 220px; }
    .card { padding: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .ads-list-card,
    .card:has(.stack-table) { overflow-x: visible; }
    .posts-card { padding: 0; }
    table { min-width: 680px; }
    .ads-table,
    .stack-table { min-width: 0; width: 100%; }
    .table-wrap:has(.stack-table) { overflow: visible; }
    .posts-head {
        flex-direction: column;
        align-items: stretch;
    }
    .posts-storage { max-width: none; }
    .posts-head .storage-meter { max-width: none; }
    .posts-head .btn { width: 100%; }
    .posts-search-form, .posts-search { width: 100%; }
    .dash-date-filter { width: 100%; }
    .dash-date-filter input[type=date] { min-width: 0; width: 100%; }
    .settings-tabs { gap: 6px; }
    .settings-tab { padding: 8px 12px; }
}
@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr; }
    .login-card { padding: 24px 18px; }
}

.ads-card h3 { margin-bottom: 14px; }
.ads-dropzone { padding: 28px 18px; margin-bottom: 18px; }
.ads-size-hints {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}
.ads-size-hints span {
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #555;
}
.ads-size-note {
    font-size: 12px;
    color: var(--muted);
    max-width: 36em;
    line-height: 1.45;
}
.ads-fields {
    display: grid;
    grid-template-columns: 220px 1fr 1fr;
    gap: 12px;
}
.ads-fields .form-row { margin-bottom: 0; }
.card-foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}
.ads-list-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.ads-list-head h3 { margin: 0 0 4px; }
.ads-list-head .hint-admin { margin: 0; }
.ads-slot-pills { display: flex; gap: 6px; }
.ads-slot-pill {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    background: #f3f4f6;
    color: #888;
}
.ads-slot-pill.is-used { background: var(--red-soft); color: var(--red); }
.ads-table-wrap { overflow-x: auto; }
.ads-table { margin: 0; }
.ads-table th, .ads-table td { vertical-align: middle; }
.ad-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 12px;
    background: #f3f4f6;
    display: block;
}
.ad-view strong { display: block; font-size: 14px; margin-bottom: 4px; }
.ad-link {
    color: var(--red);
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    word-break: break-all;
}
.ad-muted { color: var(--muted); font-size: 13px; }
.ad-slot-label { font-weight: 700; font-size: 13px; }
.ad-warn { display: block; margin-top: 4px; font-size: 11px; font-weight: 700; color: #e65100; }
.ad-edit { display: none; }
.ad-row.is-editing .ad-view { display: none; }
.ad-row.is-editing .ad-edit { display: grid; gap: 8px; }
.ad-replace {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}
.ad-replace input { margin-top: 4px; font-size: 12px; }
.ads-empty { text-align: center; color: var(--muted); padding: 28px 12px !important; }
.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    font: inherit;
}
.switch-ui {
    width: 51px;
    height: 31px;
    border-radius: 999px;
    background: #e9e9eb;
    position: relative;
    flex-shrink: 0;
    transition: background .2s ease;
}
.switch-ui:after {
    content: "";
    position: absolute;
    width: 27px;
    height: 27px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .12);
    transition: transform .22s cubic-bezier(.22, 1, .36, 1);
}
.switch.is-on .switch-ui { background: #34c759; }
.switch.is-on .switch-ui:after { transform: translateX(20px); }
.switch-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
}
.switch.is-on .switch-label { color: #16a34a; }

.sub-flow { display: flex; flex-direction: column; gap: 8px; min-width: 168px; }
.sub-flow-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.sub-flow-btns .btn { padding: 6px 10px; font-size: 12px; }
.status-chip {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 4px 9px;
    width: max-content;
    background: #ececec;
    color: #333;
}
.status-chip.is-processing { background: #fff3cd; color: #7a5b00; }
.status-chip.is-approved { background: #d4edda; color: #1b6b32; }
.status-chip.is-rejected,
.status-chip.is-cancelled { background: #f8d7da; color: #8a1c21; }
.sub-remarks {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    max-width: 240px;
}
.dlg-back {
    position: fixed;
    inset: 0;
    background: rgba(17, 17, 17, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 80;
    padding: 20px;
}
.dlg-back.is-open { display: flex; }
.dlg-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 18px 50px rgba(0,0,0,.2);
}
.dlg-card h3 { margin: 0 0 6px; font-size: 18px; }
.sub-action-hint { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.dlg-card label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.dlg-card textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    resize: vertical;
}
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.page-head { margin: 0 0 18px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.03em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.subs-filter {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) 180px minmax(180px, 1.1fr) auto auto;
    gap: 12px;
    align-items: end;
}
.subs-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 8px 4px;
}
.kpi {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-right: 1px solid var(--line);
}
.kpi:last-child { border-right: 0; }
.kpi b {
    display: block;
    font-size: 26px;
    letter-spacing: -0.04em;
    line-height: 1.1;
}
.kpi strong { display: block; font-size: 13px; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi-ico {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.kpi-red { background: #fee2e2; color: #b91c1c; }
.kpi-amber { background: #ffedd5; color: #c2410c; }
.kpi-green { background: #dcfce7; color: #15803d; }
.kpi-rose { background: #ffe4e6; color: #e11d48; }
.card-table { padding: 8px 8px 16px; }
.table-wrap { overflow-x: auto; }
.subs-table { min-width: 980px; }
.subs-table th { white-space: nowrap; }
.cell-date { font-weight: 700; }
.cell-muted { color: var(--muted); font-size: 12px; margin-top: 2px; }
.cell-strong { font-weight: 700; }
.cat-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.status-chip.is-new { background: #fef3c7; color: #92400e; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 9px; }
.sub-flow-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.subs-pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 10px 2px;
    color: var(--muted);
    font-size: 13px;
}
.pager { display: flex; gap: 6px; }
.pager a,
.pager span {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: #fff;
}
.pager a:hover { border-color: #ccc; }
.pager .is-on { border-color: var(--red); color: var(--red); }

.form-ref {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 800;
    font-size: 13px;
    color: var(--red);
    letter-spacing: -0.02em;
}
.form-ref:hover { text-decoration: underline; }
.form-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 4px 8px;
    border-radius: 8px;
    background: #111;
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
}
.sub-view-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.sub-view-head .btn {
    margin-bottom: 12px;
}
.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.back-link:hover { color: var(--red); }
.sub-view-head h1 {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: -0.03em;
}
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 24px;
}
.detail-item label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}
.detail-item div { font-weight: 700; font-size: 15px; }
.detail-wide { grid-column: 1 / -1; }
.sub-view-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.modal { z-index: 1080; }
.modal-backdrop { z-index: 1070; }
.modal-header,
.modal-footer {
    border-color: var(--line);
}
.modal-title {
    font-weight: 700;
    letter-spacing: -0.02em;
}
.modal-footer .btn {
    min-width: 88px;
}

@media (max-width: 1100px) {
    .subs-filter { grid-template-columns: 1fr 1fr; }
    .subs-kpis { grid-template-columns: 1fr 1fr; }
    .kpi { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 900px) {
    .ads-fields { grid-template-columns: 1fr; }
    .subs-filter { grid-template-columns: 1fr; }
    .subs-kpis { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .sub-view-head { flex-direction: column; }
    .ads-table-wrap { overflow: visible; }
    .ads-table thead { display: none; }
    .ads-table,
    .ads-table tbody {
        display: block;
        width: 100%;
    }
    .ads-table tr.ad-row {
        display: grid;
        grid-template-columns: 64px 1fr;
        gap: 8px 12px;
        width: 100%;
        margin: 0 0 12px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #fff;
        box-sizing: border-box;
    }
    .ads-table tr.ad-row:last-child { margin-bottom: 0; }
    .ads-table tr.ad-row td {
        display: grid;
        grid-template-columns: 88px minmax(0, 1fr);
        align-items: center;
        gap: 8px;
        width: auto;
        padding: 8px 0 0;
        border: 0;
        min-width: 0;
    }
    .ads-table tr.ad-row td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--muted);
    }
    .ads-table tr.ad-row td:nth-child(1) {
        grid-column: 1;
        grid-row: 1 / span 2;
        display: block;
        padding: 0;
    }
    .ads-table tr.ad-row td:nth-child(1)::before { display: none; }
    .ads-table tr.ad-row td:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
        display: block;
        padding: 0;
    }
    .ads-table tr.ad-row td:nth-child(2)::before { display: none; }
    .ads-table tr.ad-row td:nth-child(n+3) {
        grid-column: 1 / -1;
        border-top: 1px solid var(--line);
        padding-top: 10px;
        margin-top: 2px;
    }
    .ads-table .ad-thumb {
        width: 64px;
        height: 64px;
    }
    .ads-table .ad-edit input,
    .ads-table .ad-edit select,
    .ads-table .ad-replace input {
        width: 100%;
        max-width: 100%;
    }
    .ads-table tr:not(.ad-row) {
        display: block;
        width: 100%;
    }
    .ads-table .ads-empty {
        display: block;
        min-width: 0 !important;
        width: 100%;
        padding: 20px 8px !important;
    }
    .stack-table thead { display: none; }
    .stack-table,
    .stack-table tbody,
    .subs-table.stack-table {
        display: block;
        width: 100%;
        min-width: 0;
    }
    .stack-table tbody tr {
        display: block;
        width: 100%;
        margin: 0 0 12px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #fff;
        box-sizing: border-box;
    }
    .stack-table tbody tr:last-child { margin-bottom: 0; }
    .stack-table tbody tr:hover { background: #fff; }
    .stack-table tbody td {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        align-items: center;
        gap: 8px;
        width: auto;
        padding: 10px 0;
        border: 0;
        border-bottom: 1px solid var(--line);
        min-width: 0;
        word-break: break-word;
    }
    .stack-table tbody td:first-child { padding-top: 0; }
    .stack-table tbody td:last-child { border-bottom: 0; padding-bottom: 0; }
    .stack-table tbody td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--muted);
    }
    .stack-table tbody td[data-label=""] {
        grid-template-columns: minmax(0, 1fr);
    }
    .stack-table tbody td[data-label=""]::before { display: none; }
    .stack-table tbody td[colspan] {
        display: block;
        border: 0;
        padding: 8px 0;
    }
    .stack-table tbody td[colspan]::before { display: none; }
    .stack-table tbody tr:has(> td[colspan]) {
        border: 0;
        padding: 8px 4px;
        background: transparent;
    }
    .stack-table input[type="text"],
    .stack-table select {
        width: 100%;
        max-width: 100%;
    }
    .stack-table .select2-container {
        width: 100% !important;
        max-width: 100%;
    }
    .stack-table img {
        max-width: 72px;
        max-height: 72px;
        width: auto;
        height: auto;
        border-radius: 10px;
    }
    .stack-table tbody td .row-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }
    .stack-table tbody td .row-actions form {
        margin: 0;
        display: inline-flex;
    }
    .stack-table tbody td .row-actions .btn {
        margin: 0;
        width: auto;
        flex: 0 0 auto;
    }
}
