:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #102033;
    --muted: #627084;
    --line: #d8e0ea;
    --line-strong: #c4cedb;
    --accent: #1769aa;
    --accent-dark: #0f548d;
    --accent-soft: #e8f2fb;
    --brand-warm: #fb9a73;
    --brand-warm-soft: #fff1e9;
    --danger: #b42318;
    --danger-soft: #fff1ef;
    --ok: #1b7f43;
    --ok-soft: #edf8f0;
    --warn: #b7791f;
    --warn-soft: #fff7e8;
    --shadow: 0 14px 36px rgba(15, 35, 55, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at 50% 0, rgba(251, 154, 115, 0.24), rgba(251, 154, 115, 0) 310px),
        linear-gradient(180deg, #eef4f8 0, rgba(244, 246, 248, 0) 260px),
        var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    min-height: 100vh;
}

.solo-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 40px;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 40px;
}

.workspace {
    min-width: 0;
    padding: 30px 36px 44px;
}

.sidebar {
    background: #16212d;
    color: #dbe6f2;
    display: flex;
    flex-direction: column;
    gap: 26px;
    min-height: 100vh;
    padding: 22px 18px;
    position: sticky;
    top: 0;
}

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

.brand-mark {
    align-items: center;
    background: #ef2f3d;
    border-radius: 7px;
    color: #fff;
    display: inline-flex;
    font-weight: 900;
    height: 44px;
    justify-content: center;
    width: 44px;
}

.sidebar-brand strong {
    color: #fff;
    display: block;
    font-size: 15px;
    line-height: 1.1;
}

.sidebar-brand small,
.sidebar-footer small {
    color: #9fb0c3;
    display: block;
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 7px;
}

.sidebar-nav a {
    align-items: center;
    border-radius: 7px;
    color: #dbe6f2;
    display: flex;
    gap: 11px;
    min-height: 42px;
    padding: 0 12px;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav a.active {
    background: #303b48;
    color: #fff;
}

.nav-icon {
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    color: #c8d4e3;
    display: inline-flex;
    font-size: 11px;
    font-weight: 900;
    height: 24px;
    justify-content: center;
    width: 28px;
}

.sidebar-nav a.active .nav-icon {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
    padding-top: 16px;
}

.sidebar-footer span {
    color: #fff;
    display: block;
    font-weight: 800;
}

.app-shell .main-nav {
    display: none;
}

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

.topbar h1 {
    margin: 0 0 4px;
}

.topbar p {
    color: var(--muted);
    margin: 0;
    max-width: 760px;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.main-nav {
    align-items: center;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 18px;
    padding: 4px;
    width: fit-content;
    box-shadow: 0 6px 18px rgba(15, 35, 55, 0.05);
}

.main-nav a {
    align-items: center;
    border-radius: 6px;
    color: #344256;
    display: inline-flex;
    font-weight: 750;
    min-height: 36px;
    padding: 0 14px;
    text-decoration: none;
}

.main-nav a:hover {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.main-nav a.active {
    background: var(--accent);
    color: #fff;
}

h1,
h2 {
    line-height: 1.2;
}

h1 {
    font-size: 34px;
}

h2 {
    font-size: 19px;
    margin: 0 0 10px;
}

p {
    margin: 0 0 14px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.metric-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15, 35, 55, 0.04);
    display: grid;
    gap: 4px;
    min-height: 84px;
    padding: 15px 16px;
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.metric-card strong {
    color: var(--text);
    font-size: 28px;
    line-height: 1;
}

.metric-card.danger-metric strong {
    color: var(--danger);
}

.metric-card.danger-metric {
    border-top-color: var(--danger);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 35, 55, 0.05);
    margin-bottom: 16px;
    padding: 20px;
}

.auth.panel {
    margin-left: auto;
    margin-right: auto;
    max-width: 440px;
}

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

.stack {
    display: grid;
    gap: 12px;
}

.test-form {
    margin-top: 10px;
}

.cron-status {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    margin-top: 14px;
    padding: 12px 13px;
}

.cron-status.fresh {
    background: var(--ok-soft);
    border-color: #a9d8b5;
}

.cron-status.stale {
    background: var(--warn-soft);
    border-color: #f0c36f;
}

.cron-status span,
.cron-status small {
    color: var(--muted);
}

.tabs {
    align-items: center;
    background: #edf2f7;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 12px 0 18px;
    max-width: 100%;
    padding: 4px;
    width: fit-content;
}

.tabs .tab {
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 750;
    min-height: 34px;
    padding: 0 13px;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tabs .tab:hover {
    background: #fff;
}

.tabs .tab-count {
    background: #d8e2ec;
    border-radius: 999px;
    color: #526173;
    font-size: 12px;
    font-weight: 750;
    min-width: 22px;
    padding: 3px 7px;
    text-align: center;
}

.tabs .tab.active {
    background: var(--accent);
    box-shadow: 0 7px 14px rgba(23, 105, 170, 0.2);
    color: #fff;
}

.tabs .tab.active .tab-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.table-tools {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin: 0 0 14px;
}

.search-field {
    min-width: min(340px, 100%);
}

.search-summary {
    color: var(--muted);
    font-size: 14px;
    font-weight: 750;
    min-height: 24px;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    font-weight: 700;
    gap: 6px;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 42px;
    padding: 10px 12px;
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
    width: 100%;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.14);
    outline: none;
}

.row-input {
    min-height: 38px;
    min-width: 150px;
    padding: 8px 10px;
}

.project-input {
    min-width: 190px;
}

button,
.button {
    align-items: center;
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: 750 14px/1 system-ui, sans-serif;
    justify-content: center;
    min-height: 40px;
    padding: 0 15px;
    text-decoration: none;
    transition: background 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

button:hover,
.button:hover {
    background: var(--accent-dark);
    box-shadow: 0 8px 18px rgba(23, 105, 170, 0.18);
}

button:active,
.button:active {
    transform: translateY(1px);
}

.ghost {
    background: #e7eef5;
    color: var(--text);
}

.ghost:hover {
    background: #dce7f0;
    box-shadow: none;
}

.danger {
    background: var(--danger);
}

.danger:hover {
    background: #971b12;
    box-shadow: 0 8px 18px rgba(180, 35, 24, 0.16);
}

.domain-link {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

.domain-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.alert {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.alert.success {
    background: var(--ok-soft);
    border-color: #a9d8b5;
    color: var(--ok);
}

.alert.error,
.warning {
    background: var(--warn-soft);
    border-color: #f0c36f;
}

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

.table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    min-width: 820px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 13px 12px;
    text-align: left;
    vertical-align: middle;
}

tbody tr:hover {
    background: var(--panel-soft);
}

tbody tr:last-child td {
    border-bottom: 0;
}

th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.sort-button {
    background: transparent;
    box-shadow: none;
    color: var(--muted);
    font: inherit;
    font-weight: 800;
    justify-content: flex-start;
    min-height: auto;
    padding: 0;
    text-align: left;
}

.sort-button:hover {
    background: transparent;
    box-shadow: none;
    color: var(--text);
}

.sort-button::after {
    content: "";
    display: inline-block;
    margin-left: 6px;
    opacity: 0.55;
}

.sort-button.active.asc::after {
    content: "↑";
}

.sort-button.active.desc::after {
    content: "↓";
}

.right {
    text-align: right;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
}

.row-actions button {
    min-width: 104px;
    width: 104px;
}

.right form + form {
    margin-top: 6px;
}

.count-badge {
    border-radius: 999px;
    display: inline-flex;
    font-weight: 800;
    justify-content: center;
    min-width: 28px;
    padding: 3px 8px;
}

.count-badge.good {
    background: var(--ok-soft);
    color: var(--ok);
}

.count-badge.bad {
    background: var(--danger-soft);
    color: var(--danger);
}

.history-table {
    min-width: 760px;
}

.nowrap {
    white-space: nowrap;
}

.cards {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.more-results {
    margin-top: 14px;
}

.more-results summary {
    align-items: center;
    background: #e7eef5;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font-weight: 750;
    min-height: 40px;
    padding: 0 14px;
}

.more-results summary::marker {
    content: "";
}

.more-results[open] summary {
    margin-bottom: 14px;
}

.more-results[open] summary span {
    display: none;
}

.more-results[open] summary::after {
    content: "Скрыть";
    font-size: 14px;
}

.status {
    background: #fff;
    border: 1px solid var(--line);
    border-left: 5px solid var(--muted);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    padding: 14px;
}

.status.ok {
    border-left-color: var(--ok);
}

.status.warning {
    border-left-color: var(--warn);
}

.status.expired,
.status.error {
    border-left-color: var(--danger);
}

.eyebrow {
    color: var(--muted);
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.detail-header {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
}

.detail-header h2 {
    font-size: 28px;
}

.detail-kpis {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    min-width: min(500px, 100%);
}

.detail-kpis div {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.detail-kpis span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
}

.detail-kpis strong {
    display: block;
    font-size: 17px;
    overflow-wrap: anywhere;
}

.detail-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-wide {
    grid-column: 1 / -1;
}

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

.section-head h2,
.section-head p {
    margin-bottom: 4px;
}

.inline-form {
    flex: 0 0 auto;
}

.detail-list {
    display: grid;
    gap: 10px 18px;
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
    margin: 0;
}

.detail-list dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.detail-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.detail-list small {
    display: block;
    margin-top: 4px;
}

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill-list span {
    background: #edf2f7;
    border-radius: 999px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 750;
    padding: 4px 9px;
}

.detail-form {
    display: grid;
    gap: 14px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.form-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.delete-panel {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 18px;
}

code {
    background: #edf2f7;
    border-radius: 4px;
    padding: 2px 5px;
}

@media (max-width: 920px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .shell {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .solo-shell {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .workspace {
        padding: 18px 10px 30px;
    }

    .sidebar {
        min-height: auto;
        padding: 14px 10px;
        position: static;
    }

    .sidebar-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sidebar-footer {
        display: none;
    }

    .topbar,
    .grid,
    .detail-header,
    .detail-grid,
    .form-grid,
    .section-head {
        display: grid;
        grid-template-columns: 1fr;
    }

    .topbar {
        gap: 12px;
    }

    h1 {
        font-size: 30px;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .main-nav,
    .tabs {
        width: 100%;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .detail-kpis {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .detail-list {
        grid-template-columns: 1fr;
    }
}
