:root {
    --bg: #0b111a;
    --bg-soft: #111b2a;
    --panel: #131f31;
    --panel-strong: #172740;
    --border: #2a3b55;
    --text: #e7edf7;
    --text-soft: #9baac2;
    --text-faint: #7486a1;
    --accent: #3986ff;
    --accent-hover: #2c6fd4;
    --success: #2db477;
    --warning: #e3b341;
    --danger: #d86161;
    --info: #5b9eff;
    --radius: 14px;
    --shadow: 0 20px 40px rgba(3, 7, 13, 0.45);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(1100px 600px at 12% -8%, rgba(57, 134, 255, 0.18), transparent 62%),
        radial-gradient(900px 500px at 88% 4%, rgba(57, 134, 255, 0.1), transparent 65%),
        linear-gradient(170deg, var(--bg), #070c14 72%);
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-shell {
    width: min(460px, 100%);
}

.auth-card {
    background: linear-gradient(165deg, rgba(22, 34, 54, 0.9), rgba(15, 24, 38, 0.96));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.auth-logo {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    border: 1px solid #d4dce7;
    background: #ffffff;
    object-fit: cover;
    box-shadow: 0 6px 18px rgba(20, 30, 44, 0.12);
    flex: 0 0 68px;
}

.auth-subtitle {
    margin: 0 0 14px;
    color: var(--text-soft);
    font-size: 14px;
}

a {
    color: inherit;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 28px 20px;
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(13, 21, 33, 0.95), rgba(10, 16, 25, 0.9));
    backdrop-filter: blur(8px);
}

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

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    background: linear-gradient(145deg, #3d8bff, #2f65c2);
    box-shadow: 0 10px 25px rgba(18, 52, 106, 0.45);
}

.brand-kicker {
    margin: 0 0 4px;
    font-size: 10px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.brand-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
}

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

.nav-item {
    border: 1px solid transparent;
    border-radius: 10px;
    text-decoration: none;
    padding: 10px 12px;
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.nav-item:hover {
    color: var(--text);
    border-color: rgba(83, 118, 172, 0.4);
    background: rgba(31, 47, 73, 0.45);
}

.nav-item.active {
    color: #ffffff;
    border-color: rgba(84, 140, 229, 0.9);
    background: linear-gradient(140deg, rgba(57, 134, 255, 0.36), rgba(47, 101, 194, 0.25));
}

.sidebar-footer {
    margin-top: auto;
}

.pwa-controls {
    display: grid;
    gap: 8px;
}

.pwa-hint {
    margin: 2px 2px 0;
    line-height: 1.35;
}

.main-content {
    padding: 24px;
    min-width: 0;
    transition: opacity 0.14s ease;
}

body.is-nav-loading .main-content {
    opacity: 0.78;
}

.network-banner {
    position: sticky;
    top: 0;
    z-index: 90;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(216, 97, 97, 0.45);
    color: #ffd6d6;
    background: rgba(90, 25, 25, 0.9);
    backdrop-filter: blur(6px);
    font-size: 13px;
}

.page-header,
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.page-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.page-subtitle {
    margin: 8px 0 0;
    max-width: 860px;
    color: var(--text-faint);
    line-height: 1.45;
}

.header-actions,
.head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stats-grid,
.grid-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.main-grid,
.grid-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
}

.panel,
.card {
    background: linear-gradient(165deg, rgba(22, 34, 54, 0.88), rgba(15, 24, 38, 0.95));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    min-width: 0;
}

.stat-card {
    background: linear-gradient(165deg, rgba(21, 33, 52, 0.9), rgba(14, 23, 36, 0.96));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    min-height: 128px;
    min-width: 0;
}

.stat-label {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.stat-value {
    margin: 8px 0 0;
    font-size: 34px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.stat-meta {
    margin: 10px 0 0;
    color: var(--text-soft);
    font-size: 13px;
    line-break: anywhere;
}

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

.panel-head h3,
.card-head h3,
.section-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.section-title {
    margin-top: 4px;
}

.text-link,
.link-muted {
    color: var(--text-soft);
    font-size: 13px;
    text-decoration: none;
}

.text-link:hover,
.link-muted:hover {
    color: var(--text);
}

.entity-list,
.site-list {
    display: grid;
    gap: 10px;
}

.entity-row,
.site-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #24344c;
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(12, 20, 32, 0.7);
}

.row-actions,
.site-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

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

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

.table-wrap-dashboard {
    overflow-x: hidden;
}

.table-dashboard {
    min-width: 0;
    table-layout: fixed;
}

.table-fixed {
    table-layout: fixed;
}

.table th,
.table td {
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(64, 89, 125, 0.45);
    padding: 11px 10px;
    font-size: 14px;
    line-height: 1.35;
}

.table-fixed th,
.table-fixed td {
    overflow-wrap: anywhere;
}

.table-dashboard th,
.table-dashboard td {
    overflow-wrap: normal;
    word-break: normal;
}

.table-dashboard th {
    white-space: nowrap;
}

.queue-table .col-id,
.recent-table .col-id {
    width: 74px;
}

.queue-table .col-status,
.recent-table .col-status {
    width: 176px;
}

.queue-table .col-sites {
    width: auto;
}

.recent-table .col-type {
    width: 120px;
}

.queue-table .col-start,
.recent-table .col-time {
    width: 196px;
}

.queue-table .col-result,
.recent-table .col-result {
    width: 96px;
}

.recent-table .col-action {
    width: 124px;
}

.queue-sites-cell {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-table td:nth-child(4),
.queue-table td:nth-child(5),
.recent-table td:nth-child(4),
.recent-table td:nth-child(5) {
    white-space: nowrap;
}

.recent-table td:last-child {
    text-align: right;
}

.recent-table td:last-child .btn {
    white-space: nowrap;
    min-width: 104px;
}

.table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-faint);
    font-weight: 700;
}

.table-sites .col-name {
    width: 15%;
}

.table-sites .col-url {
    width: 19%;
}

.table-sites .col-auth {
    width: 13%;
}

.table-sites .col-schedules {
    width: 24%;
}

.table-sites .col-status {
    width: 10%;
}

.table-sites .col-actions {
    width: 19%;
}

.table-sites th,
.table-sites td {
    overflow-wrap: normal;
    word-break: normal;
}

.site-schedules-cell {
    display: grid;
    gap: 6px;
    min-width: 0;
    width: 100%;
}

.site-schedules-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
    width: 100%;
}

.site-schedule-link {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: min(100%, 320px);
    min-width: 0;
    border: 1px solid #355177;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-schedule-link.is-active {
    color: #d9ecff;
    background: rgba(64, 123, 213, 0.24);
    border-color: rgba(90, 151, 241, 0.55);
}

.site-schedule-link.is-paused {
    color: #d2deef;
    background: rgba(68, 86, 116, 0.36);
    border-color: rgba(86, 108, 144, 0.55);
}

.site-schedule-link:hover {
    filter: brightness(1.1);
}

.site-schedule-more {
    display: inline-flex;
    width: fit-content;
    color: var(--text-soft);
    font-size: 12px;
    text-decoration: none;
}

.site-schedule-more:hover {
    color: var(--text);
}

.table-sites td:nth-child(6) {
    min-width: 0;
}

.table-sites td:nth-child(2) {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table-sites td:nth-child(3),
.table-sites td:nth-child(4),
.table-sites td:nth-child(5) {
    min-width: 0;
    overflow: hidden;
}

.table-sites td:nth-child(3) .badge,
.table-sites td:nth-child(5) .badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-sites td:nth-child(6) .row-actions {
    gap: 6px;
}

.table-sites td:nth-child(6) .row-actions .btn {
    min-width: 98px;
    justify-content: center;
}

.form-grid {
    display: grid;
    gap: 12px;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 2fr) minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 12px;
    margin-bottom: 14px;
    align-items: end;
}

.toolbar-field {
    margin: 0;
}

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

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

.field {
    display: grid;
    gap: 7px;
}

.field > span,
.field-label {
    color: var(--text-soft);
    font-size: 13px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    background: rgba(10, 16, 26, 0.78);
    border: 1px solid #344766;
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-faint);
    opacity: 1;
}

.field select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 42px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239baac2' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
}

.field textarea {
    resize: vertical;
    min-height: 92px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: #4c8ef3;
    box-shadow: 0 0 0 3px rgba(59, 122, 215, 0.25);
}

.field-check {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-soft);
    font-size: 14px;
}

.field-check input {
    width: 16px;
    height: 16px;
}

.field-block {
    display: grid;
    gap: 8px;
}

.checks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
}

.checks-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #2f435f;
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(11, 18, 29, 0.75);
    color: var(--text-soft);
    font-size: 14px;
}

.checks-grid input {
    width: 15px;
    height: 15px;
}

.checks-scroll {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

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

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    white-space: nowrap;
    transition: filter 0.18s ease, transform 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary {
    background: linear-gradient(140deg, var(--accent), var(--accent-hover));
    color: #ffffff;
}

.btn-secondary {
    background: rgba(43, 61, 87, 0.78);
    border-color: #46628c;
    color: var(--text);
}

.btn-ghost {
    background: rgba(11, 18, 29, 0.66);
    border-color: #30435f;
    color: var(--text-soft);
}

.btn-danger {
    background: linear-gradient(140deg, #cd5b5b, #a74848);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success {
    color: #0f2c1f;
    background: var(--success);
}

.badge-warning {
    color: #362604;
    background: var(--warning);
}

.badge-danger {
    color: #fff4f4;
    background: var(--danger);
}

.badge-info {
    color: #08203d;
    background: var(--info);
}

.badge-muted {
    color: #d2dbeb;
    background: rgba(75, 96, 125, 0.62);
}

.badge-clickable {
    border: 0;
    cursor: pointer;
    transition: filter 0.18s ease, transform 0.18s ease;
}

.badge-clickable:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.badge-clickable:active {
    transform: translateY(0);
}

.alert {
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 11px 14px;
    font-size: 14px;
    margin-bottom: 14px;
}

.alert-success {
    background: rgba(45, 180, 119, 0.17);
    border-color: rgba(45, 180, 119, 0.45);
    color: #b8f0d6;
}

.alert-error {
    background: rgba(216, 97, 97, 0.16);
    border-color: rgba(216, 97, 97, 0.4);
    color: #ffd2d2;
}

.alert-info {
    background: rgba(91, 158, 255, 0.16);
    border-color: rgba(91, 158, 255, 0.4);
    color: #d9e9ff;
}

body.modal-open {
    overflow: hidden;
}

.app-confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: grid;
    place-items: center;
    padding: 18px;
}

.app-confirm-modal[hidden] {
    display: none;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: grid;
    place-items: center;
    padding: 18px;
}

.app-modal[hidden] {
    display: none;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 13, 0.68);
    backdrop-filter: blur(2px);
}

.app-modal-dialog {
    position: relative;
    width: min(640px, 100%);
    max-height: min(78vh, 720px);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: linear-gradient(165deg, rgba(22, 34, 54, 0.95), rgba(15, 24, 38, 0.98));
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.app-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid rgba(64, 89, 125, 0.45);
}

.app-modal-head h3 {
    margin: 0;
    font-size: 17px;
}

.app-modal-meta {
    margin: 6px 0 0;
    color: var(--text-faint);
    font-size: 13px;
}

.app-modal-body {
    padding: 10px 14px 14px;
    overflow: auto;
}

.app-modal-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

.app-modal-list li {
    border: 1px solid #2b3f5a;
    border-radius: 10px;
    background: rgba(10, 16, 26, 0.72);
    color: var(--text-soft);
    padding: 9px 11px;
    line-height: 1.35;
    word-break: break-word;
}

.app-confirm-dialog {
    width: min(520px, 100%);
}

.app-confirm-message {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.45;
    white-space: pre-line;
}

.app-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 14px 14px;
}

.hint {
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1.4;
}

.empty {
    margin: 2px 0;
    color: var(--text-faint);
}

.mono {
    margin: 2px 0 0;
    font-family: "JetBrains Mono", Menlo, Consolas, monospace;
    color: var(--text-soft);
    font-size: 12px;
    line-break: anywhere;
}

.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrap input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 0;
    cursor: pointer;
    z-index: 2;
}

.password-toggle:hover {
    color: #c8d8f0;
    background: transparent;
}

.eye-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.default-auth-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid #2f4566;
    border-radius: 12px;
    background: rgba(11, 18, 29, 0.68);
}

.default-auth-card[hidden] {
    display: none;
}

.default-auth-card .section-title {
    margin: 0;
}

.default-auth-value-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.default-auth-value-input {
    font-family: "JetBrains Mono", Menlo, Consolas, monospace;
}

.default-auth-copy-btn {
    min-width: 108px;
    white-space: nowrap;
}

#customAuthFields {
    display: none;
}

#customAuthFields.show {
    display: grid;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1320px) {
    .table-sites {
        min-width: 980px;
    }
}

@media (max-width: 1280px) {
    .stats-grid,
    .grid-stats {
        grid-template-columns: 1fr;
    }

    .main-grid,
    .grid-main {
        grid-template-columns: 1fr;
    }

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

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

@media (max-width: 640px) {
    .default-auth-value-row {
        flex-direction: column;
    }
}

@media (max-width: 1240px) {
    .table-wrap-stable {
        overflow-x: visible;
        min-height: 0 !important;
    }

    .table-sites {
        display: block;
        min-width: 0;
        table-layout: auto;
        width: 100%;
    }

    .table-sites thead {
        display: none;
    }

    .table-sites tbody {
        display: grid;
        gap: 10px;
        width: 100%;
    }

    .table-sites tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        border: 1px solid rgba(64, 89, 125, 0.45);
        border-radius: 12px;
        background: rgba(12, 20, 32, 0.72);
        padding: 10px 12px;
    }

    .table-sites td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        border-bottom: 1px solid rgba(64, 89, 125, 0.35);
        padding: 8px 0;
        min-width: 0;
    }

    .table-sites td::before {
        content: attr(data-label);
        flex: 0 0 102px;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-faint);
    }

    .table-sites td[colspan] {
        display: block;
        border-bottom: 0;
        padding: 10px 0 0;
    }

    .table-sites td[colspan]::before {
        display: none;
    }

    .table-sites td:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .table-sites td:nth-child(2) {
        overflow-wrap: anywhere;
    }

    .table-sites td:nth-child(6) {
        display: block;
    }

    .table-sites td:nth-child(6)::before {
        display: block;
        margin-bottom: 8px;
    }

    .table-sites td:nth-child(6) .row-actions {
        justify-content: flex-start;
    }

    .site-schedules-cell {
        justify-items: end;
        text-align: right;
    }

    .site-schedules-list {
        justify-content: flex-end;
    }
}

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

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        gap: 14px;
    }

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

    .main-content {
        padding: 16px;
        min-width: 0;
    }

    .table-wrap-dashboard {
        overflow-x: auto;
    }

    .table-wrap-dashboard .table-dashboard {
        min-width: 640px;
    }

    .table-wrap-stable {
        overflow-x: visible;
        min-height: 0 !important;
    }

    .table-sites {
        display: block;
        min-width: 0;
        table-layout: auto;
        width: 100%;
    }

    .table-sites thead {
        display: none;
    }

    .table-sites tbody {
        display: grid;
        gap: 10px;
        width: 100%;
    }

    .table-sites tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        border: 1px solid rgba(64, 89, 125, 0.45);
        border-radius: 12px;
        background: rgba(12, 20, 32, 0.72);
        padding: 10px 12px;
    }

    .table-sites td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        border-bottom: 1px solid rgba(64, 89, 125, 0.35);
        padding: 8px 0;
        min-width: 0;
    }

    .table-sites td::before {
        content: attr(data-label);
        flex: 0 0 102px;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-faint);
    }

    .table-sites td[colspan] {
        display: block;
        border-bottom: 0;
        padding: 10px 0 0;
    }

    .table-sites td[colspan]::before {
        display: none;
    }

    .table-sites td:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .table-sites td:nth-child(2) {
        overflow-wrap: anywhere;
    }

    .table-sites td:nth-child(6) {
        display: block;
    }

    .table-sites td:nth-child(6)::before {
        display: block;
        margin-bottom: 8px;
    }

    .table-sites td:nth-child(6) .row-actions {
        justify-content: flex-start;
    }

    .site-schedules-cell {
        justify-items: end;
        text-align: right;
    }

    .site-schedules-list {
        justify-content: flex-end;
    }
}

@media (max-width: 740px) {
    .page-header,
    .page-head {
        flex-direction: column;
    }

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

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        grid-template-columns: none;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .sidebar {
        padding: 12px;
    }

    .brand {
        padding: 0;
        gap: 10px;
    }

    .brand-title {
        font-size: 18px;
    }

    .brand-kicker {
        font-size: 9px;
    }

    .page-title {
        font-size: 24px;
    }

    .panel,
    .card,
    .stat-card {
        padding: 12px;
    }

    .header-actions,
    .head-actions {
        width: 100%;
    }

    .header-actions .btn,
    .head-actions .btn {
        flex: 1 1 auto;
        min-width: 0;
    }

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

    .app-confirm-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .table-sites td {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .table-sites td::before {
        flex: 0 0 auto;
    }

    .site-schedules-cell {
        justify-items: start;
        text-align: left;
    }

    .site-schedules-list {
        justify-content: flex-start;
    }

    .table-sites td:nth-child(6) .row-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .table-sites td:nth-child(6) .row-actions .btn,
    .table-sites td:nth-child(6) .row-actions form,
    .table-sites td:nth-child(6) .row-actions form .btn {
        width: 100%;
        min-width: 0;
    }
}

/* --- Autopost-inspired redesign (light platform skin) --- */
:root {
    --bg: #e8ecf1;
    --bg-soft: #f2f5f9;
    --panel: #ffffff;
    --panel-strong: #f5f8fc;
    --border: #ccd4df;
    --text: #11141a;
    --text-soft: #667083;
    --text-faint: #7a8799;
    --accent: #1a2b45;
    --accent-hover: #101f35;
    --success: #1f6a37;
    --warning: #8a5d0a;
    --danger: #8a1f2c;
    --info: #25426c;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(17, 20, 26, 0.08), 0 12px 28px rgba(17, 20, 26, 0.07);
}

html,
body {
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0.01em;
    color: var(--text);
    background:
        radial-gradient(circle at 85% -10%, rgba(31, 47, 74, 0.14), transparent 45%),
        radial-gradient(circle at -5% 10%, rgba(126, 140, 168, 0.18), transparent 40%),
        linear-gradient(180deg, #f2f5f9 0%, var(--bg) 100%);
}

a {
    color: var(--accent);
}

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

.shell.backup-shell {
    width: min(1500px, calc(100% - 48px));
    margin: 0 auto;
    padding: clamp(18px, 3vw, 34px) 0 clamp(24px, 3vw, 40px);
}

.app-shell {
    display: block;
    min-height: 0;
}

.backup-head.app-head {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding: clamp(20px, 3vw, 30px);
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(145deg, #ffffff 0%, #f2f6fb 100%);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.backup-head.app-head::after {
    content: "";
    position: absolute;
    inset: auto -40px -38px auto;
    width: 210px;
    height: 110px;
    transform: rotate(-14deg);
    background: linear-gradient(90deg, rgba(26, 43, 69, 0.14), rgba(26, 43, 69, 0));
    pointer-events: none;
}

.backup-head .eyebrow {
    margin: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: var(--text-soft);
}

.backup-head h1 {
    margin: 8px 0 6px;
    font-size: clamp(34px, 4vw, 48px);
    line-height: 1;
    letter-spacing: -0.03em;
    font-weight: 800;
}

.backup-head .lead {
    max-width: 66ch;
    margin: 0;
    color: #495365;
    font-size: 14px;
}

.app-head-tools {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}

.top-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 10px;
    padding: 8px;
    border: 1px solid #ccd4df;
    border-radius: 14px;
    background: #f4f7fb;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0 0 16px;
}

.top-nav .nav-btn,
.top-nav .nav-item {
    display: inline-flex;
    flex: 1 1 0;
    min-width: 168px;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid #aeb8c8;
    border-radius: 10px;
    background: #ffffff;
    color: #1f2836;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    text-decoration: none;
    transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease;
}

.top-nav .nav-btn:active:not(:disabled),
.top-nav .nav-item:active {
    transform: translateY(1px);
}

.top-nav .nav-btn:hover:not(:disabled):not(.active),
.top-nav .nav-item:hover:not(:disabled):not(.active) {
    border-color: #8e9bb0;
}

.top-nav .nav-btn.active,
.top-nav .nav-item.active {
    border-color: #101f35;
    background: #1a2b45;
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.top-nav .nav-btn.active:hover:not(:disabled),
.top-nav .nav-item.active:hover:not(:disabled),
.top-nav .nav-btn.active:focus-visible,
.top-nav .nav-item.active:focus-visible {
    border-color: #101f35;
    background: #1a2b45;
    color: #ffffff;
}

.top-nav .nav-btn:focus-visible,
.top-nav .nav-item:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 43, 69, 0.2);
}

.top-nav::-webkit-scrollbar {
    height: 8px;
}

.top-nav::-webkit-scrollbar-thumb {
    background: #ccd6e6;
    border-radius: 999px;
}

.main-content {
    padding: 0;
    min-width: 0;
}

body.is-nav-loading .main-content {
    opacity: 0.82;
}

.network-banner {
    position: sticky;
    top: 0;
    z-index: 90;
    padding: 10px 16px;
    border-bottom: 1px solid #d7a1ab;
    color: #6e1f2c;
    background: rgba(252, 238, 241, 0.95);
    backdrop-filter: blur(6px);
    font-size: 13px;
}

.page-title {
    color: #0f1825;
    margin: 0;
    font-size: clamp(28px, 3.3vw, 36px);
    line-height: 1.05;
    letter-spacing: -0.02em;
    font-weight: 800;
}

.page-subtitle {
    color: #586578;
    font-size: 14px;
    line-height: 1.45;
}

.panel,
.card,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-card {
    min-height: 118px;
}

.stat-value {
    font-size: clamp(28px, 3vw, 36px);
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-meta {
    color: #59677b;
}

.panel-head h3,
.card-head h3,
.section-title {
    color: #1a2638;
    font-size: 18px;
    line-height: 1.25;
    letter-spacing: -0.01em;
    font-weight: 700;
}

.text-link,
.link-muted {
    color: #4f5f75;
}

.text-link:hover,
.link-muted:hover {
    color: #16273f;
}

.table th,
.table td {
    border-bottom: 1px solid #dde4ee;
    color: #172233;
    font-size: 13px;
    line-height: 1.35;
}

.table th {
    color: #6b7b92;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.table tr:hover td {
    background: #f7fafe;
}

.field > span,
.field-label,
.field-check {
    color: #5f6e83;
    font-size: 13px;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

.field > span,
.field-label {
    font-weight: 700;
}

.field input,
.field select,
.field textarea,
.default-auth-value-input {
    background-color: #f8fbff;
    border: 1px solid #cfd7e4;
    color: #131a24;
}

input::placeholder,
textarea::placeholder {
    color: #8d9bb0;
}

select,
.field select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 44px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6L8 10L12 6' stroke='%235D6A80' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
}

select::-ms-expand {
    display: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.default-auth-value-input:focus {
    border-color: #1a2b45;
    box-shadow: 0 0 0 3px rgba(26, 43, 69, 0.18);
    background-color: #ffffff;
}

.btn {
    border-radius: 10px;
}

.btn-primary {
    background: #1a2b45;
    border-color: #1a2b45;
    color: #ffffff;
}

.btn-primary:hover {
    background: #16253b;
    border-color: #16253b;
}

.btn-secondary {
    background: #e7edf7;
    border-color: #c4d0e0;
    color: #22314a;
}

.btn-secondary:hover {
    background: #dde6f3;
    border-color: #b8c7db;
}

.btn-ghost {
    background: #f7fafd;
    border-color: #cfd8e5;
    color: #3d4e66;
}

.btn-danger {
    background: #fceef1;
    border-color: #e8b3bd;
    color: #7d2230;
}

.btn-info {
    background: #e7edf7;
    border-color: #bfd0ea;
    color: #23406d;
}

.badge {
    border-width: 1px;
    border-style: solid;
}

.badge-success {
    background: #ebf7ef;
    border-color: #b7dfc4;
    color: #1f6a37;
}

.badge-danger {
    background: #fceef1;
    border-color: #e8b3bd;
    color: #8a1f2c;
}

.badge-warning {
    background: #fff4dc;
    border-color: #f1ddaa;
    color: #8a5d0a;
}

.badge-info {
    background: #e7edf7;
    border-color: #bfd0ea;
    color: #23406d;
}

.badge-muted {
    background: #edf2f8;
    border-color: #d3dbe7;
    color: #5e6b7f;
}

.site-schedule-link.is-active {
    color: #23406d;
    background: #e9f1ff;
    border-color: #b9ccec;
}

.site-schedule-link.is-paused {
    color: #5c6980;
    background: #edf2f8;
    border-color: #d3dbe7;
}

.site-schedule-more {
    color: #4f5f75;
}

.table-sites tr {
    background: #ffffff;
}

.checks-grid label {
    background: #f8fbff;
    border-color: #d2dbe8;
    color: #4d5e75;
}

.default-auth-card {
    background: linear-gradient(180deg, #ffffff 0%, #f5f8fc 100%);
    border: 1px solid #ccd4df;
}

.default-auth-card .section-title {
    color: #1a2638;
}

.default-auth-card .hint {
    color: #5e6d83;
}

.checks-scroll::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

.checks-scroll::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
    background: #c9d3e2;
    border-radius: 999px;
    border: 2px solid #eef3f9;
}

.checks-scroll::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
    background: #eef3f9;
    border-radius: 999px;
}

.alert {
    border-radius: 11px;
    border: 1px solid #cfd7e4;
    background: #f7fafd;
    color: #2d3d55;
}

.alert-success {
    border-color: #b7dfc4;
    background: #ebf7ef;
    color: #1f6a37;
}

.alert-error {
    border-color: #e8b3bd;
    background: #fceef1;
    color: #8a1f2c;
}

.alert-info {
    border-color: #bfd0ea;
    background: #e7edf7;
    color: #23406d;
}

.app-modal-backdrop {
    background: rgba(10, 18, 29, 0.42);
}

.app-modal-dialog {
    border: 1px solid var(--border);
    background: #ffffff;
    box-shadow: 0 24px 40px rgba(12, 20, 33, 0.18);
}

.app-modal-head h3 {
    color: #1a2638;
}

.app-modal-body {
    color: #4e5f76;
}

.auth-page {
    background:
        radial-gradient(circle at 85% -10%, rgba(31, 47, 74, 0.14), transparent 45%),
        radial-gradient(circle at -5% 10%, rgba(126, 140, 168, 0.18), transparent 40%),
        linear-gradient(180deg, #f2f5f9 0%, var(--bg) 100%);
}

.auth-card {
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.auth-subtitle {
    color: #5c6a7d;
}

/* Ensure anchor-buttons keep button colors on hover/focus (do not inherit link hover color). */
a.btn,
a.btn:hover,
a.btn:active,
a.btn:focus-visible {
    text-decoration: none;
}

.btn-primary,
a.btn-primary {
    color: #ffffff;
}

.btn-primary:hover,
a.btn-primary:hover,
.btn-primary:focus-visible,
a.btn-primary:focus-visible {
    color: #ffffff;
}

.btn-secondary,
a.btn-secondary {
    color: #22314a;
}

.btn-secondary:hover,
a.btn-secondary:hover,
.btn-secondary:focus-visible,
a.btn-secondary:focus-visible {
    color: #22314a;
}

.btn-ghost,
a.btn-ghost {
    color: #3d4e66;
}

.btn-ghost:hover,
a.btn-ghost:hover,
.btn-ghost:focus-visible,
a.btn-ghost:focus-visible {
    color: #3d4e66;
}

.btn-danger,
a.btn-danger {
    color: #7d2230;
}

.btn-danger:hover,
a.btn-danger:hover,
.btn-danger:focus-visible,
a.btn-danger:focus-visible {
    color: #7d2230;
}

@media (max-width: 1060px) {
    .shell.backup-shell {
        width: min(1500px, calc(100% - 24px));
        padding-top: 14px;
    }

    .backup-head.app-head {
        padding: 16px;
        border-radius: 14px;
    }

    .backup-head h1 {
        font-size: clamp(32px, 8vw, 40px);
    }

    .top-nav {
        gap: 8px;
    }
}

@media (max-width: 760px) {
    .backup-head.app-head {
        flex-direction: column;
        gap: 14px;
    }

    .backup-head .eyebrow {
        font-size: 10px;
    }

    .backup-head h1 {
        font-size: 30px;
    }

    .backup-head .lead {
        font-size: 13px;
    }

    .top-nav .nav-btn,
    .top-nav .nav-item {
        min-height: 38px;
        padding: 0 12px;
        font-size: 13px;
    }

    .toolbar-actions {
        justify-content: stretch;
    }
}
