* { box-sizing: border-box; }
[hidden], .hide { display: none !important; }

:root {
    color-scheme: dark;
    --bg: #121212;
    --sidebar: #0c0c0c;
    --surface: #1a1a1a;
    --surface-2: #242424;
    --surface-3: #151515;
    --line: #323232;
    --line-soft: rgba(255, 255, 255, .07);
    --text: #f4f4f3;
    --soft: #d0d0cd;
    --muted: #9a9a96;
    --accent: #ff7a1a;
    --accent-2: #ffcfa6;
    --danger: #e47767;
    --warning: #e3b75d;
    --info: #78aee1;
    --violet: #b6a1e6;
    --shadow: 0 24px 70px rgba(0, 0, 0, .26);
}

html, body {
    min-height: 100vh;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
}

button, input, select, textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: var(--accent-2);
    text-decoration: none;
}

a:hover {
    color: var(--text);
}

code, pre, .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: .92em;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar {
    min-height: 100vh;
    padding: 22px 18px;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #0a0a0a;
    font-weight: 900;
    letter-spacing: .02em;
}

.brand-title {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-subtitle {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav-btn {
    width: 100%;
    min-height: 42px;
    padding: 10px 11px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-btn:hover {
    background: #171717;
    color: var(--soft);
    transform: translateX(2px);
}

.nav-btn.is-active {
    background: var(--surface-2);
    color: var(--text);
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 12px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger);
}

.status-dot.ok {
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(255, 122, 26, .12);
}

.workspace {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: 0;
}

.topbar p:last-child {
    margin: 8px 0 0;
    color: var(--muted);
    max-width: 720px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.who {
    color: var(--muted);
    font-size: 12px;
}

.eyebrow {
    margin: 0 0 6px;
    color: #afbbb1;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.page {
    display: none;
    animation: rise .22s ease both;
}

.page.is-active {
    display: block;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.metric {
    min-height: 112px;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(26, 26, 26, .9);
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.metric strong {
    display: block;
    margin-top: 10px;
    font-size: clamp(26px, 3vw, 34px);
    line-height: 1;
    font-weight: 850;
    letter-spacing: 0;
}

.overview-grid,
.metrics-layout {
    display: grid;
    grid-template-columns: minmax(360px, .9fr) minmax(420px, 1.1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.panel {
    background: rgba(26, 26, 26, .92);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: 0;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn, .button {
    min-height: 39px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 750;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: border-color .18s ease, transform .18s ease, background .18s ease;
}

.btn:hover, .button:hover {
    border-color: rgba(255, 122, 26, .55);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: .48;
    cursor: not-allowed;
    transform: none;
}

.btn.primary, .primary {
    border-color: rgba(255, 122, 26, .7);
    background: var(--accent);
    color: #0a0a0a;
}

.btn-ghost {
    background: transparent;
}

.btn-success {
    border-color: rgba(255, 122, 26, .55);
    background: rgba(255, 122, 26, .16);
    color: var(--accent-2);
}

.btn-danger {
    border-color: rgba(228, 119, 103, .45);
    background: rgba(228, 119, 103, .12);
    color: #f0a49b;
}

.btn-sm {
    min-height: 31px;
    padding: 6px 9px;
    font-size: 12px;
}

.toggle-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.run-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 14px;
}

.quick-launch {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.quick-launch__item {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-3);
}

.quick-launch__item label {
    min-width: 0;
}

.quick-launch__item input {
    max-width: 150px;
}

.quick-launch__item p {
    grid-column: 1 / -1;
    margin: 0;
}

.run-control {
    display: grid;
    gap: 10px;
    align-content: start;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-3);
}

.toggle-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 13px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-3);
}

.toggle-row strong {
    display: block;
    margin-bottom: 4px;
}

.toggle-row p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: #3a3a3a;
    border-radius: 999px;
    cursor: pointer;
    transition: background .2s;
}

.slider:before {
    position: absolute;
    content: "";
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #fff;
    transition: transform .2s;
}

input:checked + .slider {
    background: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.pill,
.status-chip,
.source-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #262626;
    color: var(--soft);
    font-size: 12px;
    font-weight: 700;
    gap: 6px;
}

.pill.ok,
.status-chip.ok {
    color: var(--accent-2);
    background: rgba(255, 122, 26, .14);
}

.pill.warn,
.status-chip.warn {
    color: var(--warning);
    background: rgba(227, 183, 93, .14);
}

.status-chip.err {
    color: var(--danger);
    background: rgba(228, 119, 103, .14);
}

.event-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #262626;
    color: var(--soft);
    font-size: 12px;
    font-weight: 700;
    gap: 6px;
    white-space: nowrap;
}

.event-pill.event-ok {
    color: var(--accent-2);
    background: rgba(255, 122, 26, .14);
}

.event-pill.event-warn {
    color: var(--warning);
    background: rgba(227, 183, 93, .14);
}

.event-pill.event-err {
    color: var(--danger);
    background: rgba(228, 119, 103, .14);
}

.billing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px 18px;
    margin: 8px 0 14px;
}

.billing-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.billing-grid input {
    padding: 8px 12px;
    background: #1c1c1c;
    color: var(--soft);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.billing-grid input[readonly] {
    background: #181818;
    color: rgba(200, 208, 212, .65);
    cursor: not-allowed;
}

.tg-admin-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 14px;
    min-height: 28px;
}

.tg-admin-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 4px 12px;
    border-radius: 999px;
    background: #262626;
    color: var(--soft);
    font-size: 13px;
    font-weight: 600;
}

.tg-admin-chip button {
    background: transparent;
    border: 0;
    color: var(--danger);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
}

.tg-admin-add {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}

.tg-admin-add input {
    flex: 0 0 220px;
    padding: 8px 12px;
    background: #1c1c1c;
    color: var(--soft);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

select.select {
    appearance: none;
    background: #262626;
    color: var(--soft);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    padding: 6px 28px 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23c8d0d4' d='M6 8 0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 6px;
}

.kv {
    display: grid;
    grid-template-columns: minmax(150px, .38fr) minmax(0, 1fr);
    gap: 9px 14px;
    margin: 0;
}

.kv.compact {
    grid-template-columns: 130px minmax(0, 1fr);
}

.kv dt {
    color: var(--muted);
}

.kv dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.status-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-3);
}

.status-tile span {
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.status-tile strong {
    font-size: 24px;
    line-height: 1;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.queue-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: 13px;
}

.queue-table th,
.queue-table td {
    padding: 10px 11px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.queue-table th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.queue-table tr.clickable:hover {
    background: rgba(255, 122, 26, .07);
    cursor: pointer;
}

.title-cell {
    min-width: 300px;
    max-width: 540px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.num-col {
    width: 120px;
    text-align: right !important;
}

.action-col {
    width: 116px;
}

.source-pill {
    color: var(--accent-2);
    background: rgba(255, 122, 26, .13);
}

.wp-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 31px;
    padding: 6px 9px;
    border: 1px solid rgba(255, 122, 26, .45);
    border-radius: 8px;
    background: rgba(255, 122, 26, .12);
    color: var(--accent-2);
    font-size: 12px;
    font-weight: 750;
}

.filters {
    display: grid;
    grid-template-columns: 220px minmax(220px, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
}

input, select, textarea {
    width: 100%;
    min-height: 40px;
    color: var(--text);
    background: #0e0e0e;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: rgba(255, 122, 26, .74);
}

.form-row {
    display: grid;
    grid-template-columns: 140px minmax(240px, 1fr) 160px 130px 150px auto;
    gap: 10px;
    align-items: end;
    margin-top: 12px;
}

.load-panel {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-3);
}

.load-panel summary {
    cursor: pointer;
    font-weight: 750;
}

.article-head {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 22px;
    margin: 18px 0;
}

.cover-thumb {
    width: 220px;
    height: 220px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-3);
}

.article-meta h2 {
    margin: 0 0 8px;
    font-size: 26px;
    line-height: 1.18;
}

.article-meta p {
    margin: 0 0 12px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.section-title {
    margin: 22px 0 10px;
    font-size: 15px;
}

.body-preview {
    max-height: 640px;
    overflow: auto;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0e0e0e;
    color: var(--soft);
    line-height: 1.62;
}

.body-preview :is(h2, h3) {
    margin: 14px 0 8px;
    color: var(--text);
}

.body-preview p {
    margin: 8px 0;
}

.body-preview ul,
.body-preview ol {
    margin: 8px 0 8px 22px;
}

.body-preview nav.hses-toc {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-3);
    margin-bottom: 14px;
}

.body-preview nav.hses-toc ul {
    list-style: none;
    margin-left: 0;
    padding-left: 0;
}

.npa-list,
.plain-list {
    display: grid;
    gap: 10px;
    padding-left: 0;
    list-style: none;
}

.npa-list li,
.plain-list li {
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-3);
}

.trace-table {
    min-width: 900px;
}

.bars {
    display: grid;
    gap: 8px;
}

.bar-row {
    display: grid;
    grid-template-columns: 210px minmax(160px, 1fr) 80px;
    gap: 12px;
    align-items: center;
    font-size: 13px;
}

.bar-label {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.bar {
    height: 16px;
    overflow: hidden;
    border-radius: 999px;
    background: #282828;
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
}

.bar-value {
    text-align: right;
    font-weight: 800;
}

.timeline {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 240px;
    padding: 10px 0 4px;
    overflow-x: auto;
}

.tl-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 48px;
}

.tl-bar {
    width: 28px;
    height: 160px;
    background: #282828;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column-reverse;
}

.tl-published { background: var(--accent); }
.tl-failed { background: var(--warning); }
.tl-date { margin-top: 6px; color: var(--muted); font-size: 11px; }
.tl-num { margin-top: 2px; color: var(--soft); font-size: 12px; }

.cfg-area {
    min-height: 210px;
    margin-bottom: 10px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.55;
}

.cfg-area.tall {
    min-height: 410px;
}

#toast-box {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(20px);
    max-width: min(520px, 84vw);
    padding: 12px 18px;
    border-radius: 8px;
    background: #1f2937;
    color: #f8fafc;
    border: 1px solid rgba(255, 122, 26, .5);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    z-index: 200;
}

#toast-box.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#toast-box.toast-err {
    border-color: rgba(228, 119, 103, .6);
    background: #3b1d1b;
}

@media (max-width: 1080px) {
    body { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        min-height: auto;
        padding: 16px;
    }
    .nav {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .nav-btn {
        justify-content: center;
    }
    .sidebar-foot {
        display: none;
    }
    .workspace {
        padding: 20px;
    }
    .overview-grid,
    .metrics-layout,
    .topbar,
    .article-head {
        grid-template-columns: 1fr;
        display: grid;
    }
    .cover-thumb {
        width: min(100%, 260px);
        height: auto;
        aspect-ratio: 1;
    }
    .form-row,
    .filters,
    .run-grid,
    .quick-launch,
    .quick-launch__item {
        grid-template-columns: 1fr;
    }
}

/* === Соцсети === */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}
.toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.soc-platform {
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    padding: 14px;
    margin-top: 12px;
    background: var(--surface-3);
}
.soc-platform-head,
.soc-platform-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.soc-platform-foot {
    margin-top: 8px;
    margin-bottom: 0;
}
.soc-platform textarea {
    width: 100%;
    min-height: 110px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}
.btn.small {
    padding: 4px 10px;
    font-size: 12px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 13px;
}
.data-table th,
.data-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}
.data-table th {
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
}
.badge.ok { background: rgba(255, 122, 26, 0.18); border-color: rgba(255, 122, 26, 0.4); color: #ff7a1a; }
.badge.warn { background: rgba(255, 167, 38, 0.18); border-color: rgba(255, 167, 38, 0.4); color: #ffa726; }
.badge.err { background: rgba(255, 70, 70, 0.18); border-color: rgba(255, 70, 70, 0.4); color: #ff6e6e; }

@media (max-width: 640px) {
    .workspace { padding: 16px; }
    .topbar h1 { font-size: 26px; }
    .nav { grid-template-columns: 1fr 1fr; }
    .panel { padding: 14px; }
    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
    .metric strong {
        font-size: 26px;
    }
    .kv {
        grid-template-columns: 1fr;
    }
    .bar-row {
        grid-template-columns: 1fr;
    }
}
