:root {
    --navy: #042742;
    --navy-dark: #021b2f;
    --blue: #059bd8;
    --aqua: #2ec3e4;
    --indigo: #283679;
    --yellow: #f9ed2e;
    --gold: #f7d24f;
    --surface: #f7fbfd;
    --white: #ffffff;
    --ink: #111827;
    --muted: #5f7180;
    --line: #d6e7ef;
    --green: #198754;
    --green-soft: #e8f5ee;
    --amber: #ad6800;
    --amber-soft: #fff4dd;
    --red: #b42318;
    --red-soft: #ffebe9;
    --blue-soft: #eaf8fc;
    --slate-soft: #eef3f5;
    --shadow: 0 18px 50px rgba(4, 39, 66, 0.10);
}

* { box-sizing: border-box; }
html { background: var(--surface); }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% -12%, rgba(249, 237, 46, 0.24), transparent 30rem),
        radial-gradient(circle at 94% 2%, rgba(46, 195, 228, 0.12), transparent 34rem),
        var(--surface);
    font-family: Montserrat, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, input { font: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto minmax(210px, 1fr);
    align-items: center;
    gap: 24px;
    min-height: 78px;
    padding: 12px clamp(18px, 4vw, 56px);
    color: var(--white);
    background: rgba(4, 39, 66, 0.98);
    box-shadow: 0 8px 30px rgba(4, 39, 66, 0.18);
    border-bottom: 3px solid var(--blue);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;
    width: fit-content;
    color: var(--white);
    text-decoration: none;
}
.brand-logo {
    display: block;
    width: 154px;
    height: auto;
    flex: 0 0 auto;
}
.brand-separator {
    width: 1px;
    height: 38px;
    flex: 0 0 auto;
    background: rgba(255,255,255,.28);
}
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 1.04rem; font-weight: 800; }
.brand-copy small { margin-top: 2px; color: rgba(255,255,255,.72); font-size: .72rem; }
.topbar-login { grid-template-columns: 1fr; }

.primary-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 13px;
    background: rgba(255,255,255,.08);
}
.primary-nav a {
    padding: 9px 14px;
    color: rgba(255,255,255,.72);
    border-radius: 9px;
    font-size: .82rem;
    font-weight: 800;
    text-decoration: none;
    transition: color .18s ease, background .18s ease;
}
.primary-nav a:hover { color: var(--white); }
.primary-nav a.active {
    color: var(--navy);
    background: var(--yellow);
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}
.user-label { color: rgba(255,255,255,.78); font-size: .9rem; }

.page-shell {
    width: min(1460px, calc(100% - 36px));
    margin: 0 auto;
    padding: 42px 0 54px;
}

.hero-panel, .detail-hero, .page-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 28px;
}
.hero-panel h1, .detail-hero h1, .page-hero h1 {
    max-width: 840px;
    margin: 7px 0 8px;
    color: var(--navy);
    font-size: clamp(2.2rem, 5vw, 4.9rem);
    line-height: .98;
    letter-spacing: -0.055em;
}
.detail-hero h1, .page-hero h1 { font-size: clamp(2rem, 4vw, 3.8rem); }
.hero-copy, .detail-hero p, .page-hero p {
    max-width: 720px;
    margin: 0;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.65;
}

.eyebrow {
    color: var(--blue);
    font-size: .73rem;
    font-weight: 850;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.overall-status {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: min(100%, 390px);
    padding: 17px 19px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--white);
    box-shadow: var(--shadow);
}
.overall-status strong, .overall-status small { display: block; }
.overall-status strong { color: var(--navy); }
.overall-status small { margin-top: 3px; color: var(--muted); }

.status-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 0 5px currentColor;
    opacity: .9;
}
.status-healthy { color: var(--green); }
.status-degraded { color: var(--amber); }
.status-offline { color: var(--red); }
.status-paused { color: var(--muted); }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}
.summary-card {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--white);
}
.summary-card span, .summary-card small { display: block; color: var(--muted); }
.summary-card > span { font-size: .82rem; font-weight: 750; }
.summary-card strong {
    display: block;
    margin: 7px 0 4px;
    color: var(--navy);
    font-size: 1.85rem;
    line-height: 1.08;
    letter-spacing: -.035em;
}
.summary-card strong.summary-word { font-size: 1.55rem; }
.summary-card strong.summary-date { font-size: 1.45rem; }
.summary-card small {
    overflow-wrap: anywhere;
    font-size: .78rem;
    line-height: 1.45;
}

.server-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 46px;
    overflow: hidden;
    color: var(--white);
    background: var(--navy);
    border-radius: 17px;
}
.server-strip a {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    border-right: 1px solid rgba(255,255,255,.13);
    text-decoration: none;
    transition: background .18s ease;
}
.server-strip a:hover { background: rgba(255,255,255,.07); }
.server-strip a:last-child { border-right: 0; }
.server-strip span { color: rgba(255,255,255,.65); }

.systems-section { margin-top: 42px; }
.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 17px;
}
.section-heading.compact { align-items: center; }
.section-heading h2, .detail-card h2, .data-card h2, .attention-panel h2 {
    margin: 5px 0 0;
    color: var(--navy);
    font-size: 1.45rem;
    line-height: 1.15;
    letter-spacing: -.025em;
}
.section-heading > span { color: var(--muted); font-size: .86rem; text-align: right; }

.system-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 17px;
}
.system-card {
    display: flex;
    min-height: 340px;
    min-width: 0;
    flex-direction: column;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--white);
    box-shadow: 0 8px 28px rgba(0, 48, 87, 0.045);
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.system-card:hover {
    transform: translateY(-3px);
    border-color: rgba(5,155,216,.48);
    box-shadow: var(--shadow);
}
.system-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.pill {
    padding: 6px 9px;
    color: var(--navy);
    background: var(--blue-soft);
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 7px 10px;
    border-radius: 999px;
    background: currentColor;
    font-size: .72rem;
    font-weight: 850;
}
.status-badge .status-dot {
    width: 7px;
    height: 7px;
    color: var(--white);
    box-shadow: none;
}
.status-badge.status-healthy { background: var(--green-soft); }
.status-badge.status-degraded { background: var(--amber-soft); }
.status-badge.status-offline { background: var(--red-soft); }
.status-badge.status-paused { background: var(--slate-soft); }

.system-card h3 {
    margin: 22px 0 6px;
    color: var(--navy);
    font-size: 1.35rem;
    line-height: 1.18;
    letter-spacing: -.025em;
}
.system-card > p {
    min-height: 44px;
    margin: 0 0 19px;
    color: var(--muted);
    line-height: 1.5;
}
.metric-list, .detail-list { margin: 0; }
.metric-list div, .detail-list div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 15px;
    padding: 9px 0;
    border-top: 1px solid #edf1f4;
}
.metric-list dt, .detail-list dt { color: var(--muted); font-size: .78rem; }
.metric-list dd, .detail-list dd {
    min-width: 0;
    margin: 0;
    text-align: right;
    font-size: .82rem;
    font-weight: 750;
    overflow-wrap: anywhere;
}
.card-warning {
    margin-top: 15px;
    padding: 11px 12px;
    color: var(--amber);
    background: var(--amber-soft);
    border-radius: 11px;
    font-size: .76rem;
    line-height: 1.4;
}
.card-link {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 18px;
    color: var(--navy);
    font-size: .82rem;
    font-weight: 850;
}
.card-link span { font-size: 1.15rem; }

.backup-current { color: var(--green); }
.backup-running { color: var(--navy); }
.backup-stale, .backup-failed { color: var(--red); }
.backup-pending, .backup-not_configured { color: var(--amber); }
.backup-scheduled { color: var(--navy); }
.restore-not-tested { color: var(--muted); }

.read-only-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 46px;
    padding: 18px 20px;
    color: var(--navy);
    background: var(--yellow);
    border-radius: 16px;
}
.read-only-banner strong { white-space: nowrap; }
.read-only-banner span { line-height: 1.5; }

.footer {
    display: flex;
    justify-content: space-between;
    width: min(1460px, calc(100% - 36px));
    margin: 0 auto;
    padding: 0 0 28px;
    color: var(--muted);
    font-size: .76rem;
}

.login-wrap {
    display: grid;
    min-height: calc(100vh - 210px);
    place-items: center;
}
.login-card {
    width: min(100%, 500px);
    padding: clamp(26px, 5vw, 46px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--white);
    box-shadow: var(--shadow);
}
.login-brand-logo {
    display: block;
    width: min(100%, 285px);
    height: auto;
    margin: 0 0 28px;
}

.login-card h1 {
    margin: 8px 0 12px;
    color: var(--navy);
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1;
    letter-spacing: -.05em;
}
.login-card > p { color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 16px; margin-top: 26px; }
.login-form label { color: var(--navy); font-size: .82rem; font-weight: 800; }
.login-form input {
    width: 100%;
    margin-top: 7px;
    padding: 14px 15px;
    border: 1px solid #cbd6de;
    border-radius: 12px;
    outline: none;
}
.login-form input:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 4px rgba(5,155,216,.14);
}

.button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 850;
    text-decoration: none;
}
.button-primary { color: var(--navy); background: var(--yellow); }
.button-ghost { color: var(--white); background: rgba(255,255,255,.11); }
.button-small { min-height: 37px; padding: 8px 12px; font-size: .78rem; }
.button-full { width: 100%; }

.notice {
    margin: 18px 0;
    padding: 14px 16px;
    border-radius: 13px;
    line-height: 1.5;
}
.notice-critical { color: var(--red); background: var(--red-soft); }
.notice-warning { color: var(--amber); background: var(--amber-soft); }
.notice-info { color: var(--navy); background: var(--blue-soft); }

.back-link {
    display: inline-block;
    margin-bottom: 26px;
    color: var(--navy);
    font-size: .84rem;
    font-weight: 850;
    text-decoration: none;
}
.detail-grid {
    display: grid;
    grid-template-columns: 1.05fr 1.35fr .8fr;
    gap: 17px;
    margin: 20px 0;
}
.server-detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.detail-card, .data-card, .attention-panel {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 19px;
    background: var(--white);
}
.wide-card { margin-top: 17px; }
.detail-list { margin-top: 16px; }
.detail-list div { align-items: flex-start; }
.detail-list dd { max-width: 62%; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.probe-table { margin-top: 10px; }
.probe-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 90px;
    align-items: center;
    gap: 20px;
    padding: 15px 0;
    border-top: 1px solid #edf1f4;
}
.probe-row strong, .probe-row small { display: block; }
.probe-row strong { color: var(--navy); }
.probe-row small { margin-top: 4px; color: var(--muted); }

.warning-list { margin: 15px 0 0; padding-left: 20px; color: var(--amber); }
.warning-list li { margin: 8px 0; }

.empty-state {
    margin-top: 14px;
    padding: 22px;
    color: var(--muted);
    background: #f4f9fb;
    border-radius: 13px;
    text-align: center;
}
.log-list { margin-top: 13px; }
.log-item { border-top: 1px solid #edf1f4; }
.log-item summary {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px 2px;
    cursor: pointer;
    list-style: none;
}
.log-item summary::-webkit-details-marker { display: none; }
.log-item summary small { color: var(--muted); }
.log-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
}
.log-success .log-indicator { background: var(--green); }
.log-warning .log-indicator { background: var(--amber); }
.log-critical .log-indicator { background: var(--red); }
.log-item pre {
    overflow-x: auto;
    margin: 0 0 14px 22px;
    padding: 14px;
    color: #d9e7f1;
    background: var(--navy-dark);
    border-radius: 11px;
    font-size: .74rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.break-word { overflow-wrap: anywhere; }

.attention-panel { margin-bottom: 38px; }
.alert-list { margin-top: 10px; }
.alert-row {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 14px 2px;
    border-top: 1px solid #edf1f4;
    text-decoration: none;
}
.alert-row strong, .alert-row small { display: block; }
.alert-row strong { color: var(--navy); }
.alert-row small { margin-top: 4px; color: var(--muted); line-height: 1.45; }
.alert-dot, .mini-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.alert-critical { color: var(--red); }
.alert-warning { color: var(--amber); }
.alert-arrow { color: var(--navy); font-size: 1.1rem; }

.connection-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin: 15px 0 36px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: var(--line);
}
.connection-item {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
    padding: 17px 18px;
    background: var(--white);
}
.connection-item .status-dot { width: 8px; height: 8px; box-shadow: 0 0 0 4px currentColor; }
.connection-item strong, .connection-item small { display: block; }
.connection-item strong { color: var(--navy); font-size: .86rem; }
.connection-item small { margin-top: 3px; color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }

.backup-table-card { padding: 0; overflow: hidden; }
.backup-table-card .section-heading { padding: 22px 22px 5px; }
.responsive-table { overflow-x: auto; }
.backup-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.backup-table th {
    padding: 13px 16px;
    color: var(--muted);
    background: #f4f9fb;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: .72rem;
    font-weight: 850;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .045em;
}
.backup-table th:nth-child(1) { width: 20%; }
.backup-table th:nth-child(2) { width: 20%; }
.backup-table th:nth-child(3) { width: 10%; }
.backup-table th:nth-child(4) { width: 18%; }
.backup-table th:nth-child(5) { width: 14%; }
.backup-table th:nth-child(6) { width: 18%; }
.backup-table td {
    padding: 17px 16px;
    border-bottom: 1px solid #edf1f4;
    vertical-align: top;
    font-size: .82rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.backup-table tbody tr:last-child td { border-bottom: 0; }
.backup-table td small, .table-system-link small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: .74rem;
}
.table-system-link { color: var(--navy); text-decoration: none; }
.table-system-link:hover strong { text-decoration: underline; }
.table-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 800;
}
.mini-dot { flex: 0 0 auto; width: 7px; height: 7px; }

.healthy-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 19px;
    background: var(--white);
}
.healthy-panel strong, .healthy-panel small { display: block; }
.healthy-panel strong { color: var(--navy); }
.healthy-panel small { margin-top: 4px; color: var(--muted); }

@media (max-width: 1180px) {
    .topbar { grid-template-columns: 1fr auto; }
    .primary-nav { grid-row: 2; grid-column: 1 / -1; justify-self: center; }
    .summary-grid, .connection-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .system-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid .detail-card:last-child { grid-column: 1 / -1; }
    .server-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .backup-table, .backup-table tbody, .backup-table tr, .backup-table td { display: block; width: 100%; }
    .backup-table thead { display: none; }
    .backup-table tr { padding: 10px 16px; border-bottom: 1px solid var(--line); }
    .backup-table tbody tr:last-child { border-bottom: 0; }
    .backup-table td {
        display: grid;
        grid-template-columns: minmax(120px, 42%) minmax(0, 1fr);
        gap: 14px;
        padding: 10px 0;
        border-bottom: 1px solid #edf1f4;
    }
    .backup-table td:last-child { border-bottom: 0; }
    .backup-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .72rem;
        font-weight: 800;
    }
}

@media (max-width: 720px) {
    .topbar {
        grid-template-columns: 1fr auto;
        gap: 10px 14px;
        min-height: 68px;
        padding: 10px 16px;
    }
    .brand-copy small, .user-label { display: none; }
    .brand-logo { width: 124px; }
    .brand-separator { height: 31px; }
    .topbar-actions { justify-self: end; }
    .primary-nav {
        grid-row: 2;
        grid-column: 1 / -1;
        width: 100%;
        justify-content: stretch;
    }
    .primary-nav a { flex: 1; text-align: center; padding: 9px 8px; }
    .page-shell { width: min(100% - 24px, 1460px); padding-top: 27px; }
    .hero-panel, .detail-hero, .page-hero { align-items: flex-start; flex-direction: column; }
    .overall-status { width: 100%; min-width: 0; }
    .summary-grid, .system-grid, .detail-grid, .server-detail-grid, .connection-strip { grid-template-columns: 1fr; }
    .detail-grid .detail-card:last-child { grid-column: auto; }
    .server-strip { grid-template-columns: repeat(2, 1fr); }
    .server-strip a:nth-child(2) { border-right: 0; }
    .server-strip a:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.13); }
    .system-card { min-height: 0; }
    .section-heading { align-items: flex-start; }
    .read-only-banner { align-items: flex-start; flex-direction: column; gap: 7px; }
    .read-only-banner strong { white-space: normal; }
    .footer { align-items: flex-start; flex-direction: column; gap: 6px; }
    .probe-row { grid-template-columns: minmax(0, 1fr) auto; }
    .probe-row > span:last-child { grid-column: 1 / -1; color: var(--muted); }
}

@media (max-width: 480px) {
    .brand-logo { width: 98px; }
    .brand-copy strong { font-size: .82rem; }
    .brand-separator { height: 27px; }
    .button-small { padding: 8px 10px; }
    .hero-panel h1, .detail-hero h1, .page-hero h1 { font-size: 2.45rem; }
    .summary-card, .detail-card, .data-card, .attention-panel { padding: 18px; }
    .backup-table-card { padding: 0; }
    .backup-table td { grid-template-columns: 1fr; gap: 5px; }
    .system-card-top { align-items: flex-start; }
    .status-badge { font-size: .68rem; }
}
