:root {
    color-scheme: dark;
    --bg: #060912;
    --panel: #0d1421;
    --panel-2: #111c2c;
    --line: #22334a;
    --text: #eafbf6;
    --muted: #8da5aa;
    --mint: #35f0bd;
    --cyan: #53d6ff;
    --danger: #ff6680;
    --warning: #ffc857;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 78% 4%, rgba(31, 176, 160, .12), transparent 28rem),
        linear-gradient(rgba(53, 240, 189, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(53, 240, 189, .025) 1px, transparent 1px),
        var(--bg);
    background-size: auto, 32px 32px, 32px 32px, auto;
    color: var(--text);
}
a { color: var(--cyan); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
code { display: block; margin-top: .3rem; color: #8bd8d1; font-size: .72rem; }
.inline-code { display: inline; margin: 0; }
small { display: block; margin-top: .24rem; color: var(--muted); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .25rem; font-size: clamp(1.45rem, 2.5vw, 2rem); }
h2 { margin-bottom: 1rem; font-size: 1.04rem; letter-spacing: .02em; }

.app-shell { display: grid; grid-template-columns: 245px minmax(0, 1fr); min-height: 100vh; }
.app-shell--guest { display: grid; place-items: center; padding: 1rem; }
.app-shell--guest .main { width: min(100%, 460px); padding: 0; }
.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1.4rem;
    border-right: 1px solid var(--line);
    background: rgba(8, 13, 23, .94);
    backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: .8rem; color: var(--text); font-weight: 800; letter-spacing: .12em; line-height: 1.1; }
.brand__mark {
    display: grid;
    place-items: center;
    width: 42px;
    aspect-ratio: 1;
    border: 1px solid var(--mint);
    border-radius: 12px 3px 12px 3px;
    box-shadow: inset 0 0 18px rgba(53, 240, 189, .16), 0 0 16px rgba(53, 240, 189, .12);
    color: var(--mint);
    font-size: 1.35rem;
}
.nav { display: grid; gap: .35rem; margin: 2rem 0; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .75rem .85rem; border: 1px solid transparent; border-radius: 9px; color: var(--muted); }
.nav a:hover, .nav a.active { border-color: #274b4c; background: rgba(53, 240, 189, .07); color: var(--mint); }
.nav__dot { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.nav a.active .nav__dot { background: currentColor; box-shadow: 0 0 9px currentColor; }
.logout { margin-top: auto; }
.main { min-width: 0; padding: 1.6rem clamp(1rem, 3vw, 3rem); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.eyebrow { margin-bottom: .35rem; color: var(--mint); font-size: .68rem; font-weight: 800; letter-spacing: .16em; }
.identity { display: flex; align-items: center; gap: .8rem; padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(13, 20, 33, .8); }
.identity strong { color: var(--mint); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat, .card {
    border: 1px solid var(--line);
    border-radius: 13px;
    background: linear-gradient(145deg, rgba(17, 28, 44, .92), rgba(10, 16, 27, .92));
    box-shadow: 0 14px 44px rgba(0, 0, 0, .18);
}
.stat { padding: 1rem; }
.stat span { display: block; color: var(--muted); font-size: .76rem; }
.stat strong { display: block; margin-top: .4rem; color: var(--mint); font-size: 1.55rem; }
.card { padding: 1.15rem; margin-bottom: 1rem; overflow: hidden; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.card-grid .card { margin-bottom: 0; }
.muted, .empty { color: var(--muted); }

.stack { display: grid; gap: .65rem; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: .75rem; align-items: end; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
.form-grid--2 { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
label { display: grid; gap: .35rem; color: #b9cfce; font-size: .78rem; }
input, select, textarea {
    width: 100%;
    min-width: 0;
    padding: .68rem .72rem;
    border: 1px solid #2a4253;
    border-radius: 8px;
    outline: none;
    background: #080e19;
    color: var(--text);
}
textarea { min-height: 82px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(53, 240, 189, .08); }
.checkbox { display: flex; align-items: center; gap: .5rem; min-height: 42px; }
.checkbox input { width: auto; }
.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: .35rem;
    min-height: 40px;
    padding: .62rem .85rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111b2a;
    cursor: pointer;
    font-weight: 750;
}
.button:hover { filter: brightness(1.12); }
.button--primary { border-color: #3ee2b9; background: var(--mint); color: #04120e; }
.button--danger { border-color: #673243; background: rgba(255, 102, 128, .1); color: #ff91a4; }
.button--ghost { width: 100%; background: transparent; color: var(--muted); }
.button--small { min-height: 34px; padding: .45rem .65rem; font-size: .78rem; }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .75rem; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { padding: .78rem .7rem; border-bottom: 1px solid rgba(34, 51, 74, .75); text-align: left; vertical-align: top; }
th { color: #8eb1b1; font-size: .68rem; letter-spacing: .07em; text-transform: uppercase; }
tbody tr:hover { background: rgba(53, 240, 189, .025); }
.status { display: inline-block; padding: .28rem .5rem; border-radius: 999px; border: 1px solid currentColor; font-size: .69rem; }
.status--online, .status--active { color: var(--mint); }
.status--offline, .status--unregistered { color: var(--warning); }
.status--expired, .status--suspended, .status--traffic_exhausted { color: var(--danger); }
.money-plus { color: var(--mint); font-weight: 800; }
.money-minus { color: var(--danger); font-weight: 800; }

.flash { margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid; border-radius: 9px; transition: opacity .25s, transform .25s; }
.flash--success { border-color: #266b59; background: rgba(53, 240, 189, .07); color: var(--mint); }
.flash--error { border-color: #70364a; background: rgba(255, 102, 128, .07); color: #ff9caf; }
.flash.is-hiding { opacity: 0; transform: translateY(-5px); }
.login-card { padding: 1.6rem; border: 1px solid #254451; border-radius: 16px; background: rgba(10, 16, 27, .95); box-shadow: 0 30px 100px rgba(0, 0, 0, .42); }
.login-card__brand { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.login-card .button { margin-top: .55rem; width: 100%; }
.footer { padding: 1.5rem 0 .5rem; color: #536b72; font-size: .72rem; text-align: center; }
.details { margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--line); }
details > summary { color: var(--cyan); cursor: pointer; font-size: .8rem; }
.progress { height: 8px; margin-top: .55rem; overflow: hidden; border-radius: 999px; background: #07101a; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--cyan)); }
.metric-row { display: flex; flex-wrap: wrap; gap: .75rem 1.2rem; color: var(--muted); font-size: .78rem; }
.metric-row strong { color: var(--text); }
.command-box { overflow-x: auto; padding: 1rem; border: 1px solid #315b58; border-radius: 10px; background: #050a10; white-space: pre-wrap; word-break: break-all; }
.command-box code { margin: 0; color: var(--mint); font-size: .78rem; }
.notice { margin: 1rem 0; padding: .85rem 1rem; border-left: 3px solid var(--warning); background: rgba(255, 200, 87, .06); color: #e8d8ab; }
.steps { display: grid; gap: .45rem; padding-left: 1.3rem; color: #b9cfce; }
.control-hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.health-cluster { display: flex; align-items: center; gap: .7rem; min-width: 180px; }
.health-orb { width: 15px; height: 15px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 18px currentColor; }
.health-orb--online { color: var(--mint); background: var(--mint); }
.health-orb--expired, .health-orb--traffic_exhausted { color: var(--danger); background: var(--danger); }
.signal-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.signal-card { min-width: 0; padding: .9rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(11, 18, 30, .88); }
.signal-card > span, .signal-card small { display: block; color: var(--muted); font-size: .72rem; }
.signal-card strong { display: block; margin: .35rem 0; color: var(--mint); font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; }
.signal-card .signal-card__small { font-size: .82rem; white-space: nowrap; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2 { margin-bottom: 0; }
.switch { display: flex; grid-auto-flow: column; align-items: center; gap: .5rem; }
.switch input { width: auto; }
.button--wide { width: 100%; margin-top: .9rem; }
.alert-panel { display: flex; flex-wrap: wrap; gap: .45rem 1rem; margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid; border-radius: 10px; }
.alert-panel--danger { border-color: #74354a; background: rgba(255, 102, 128, .08); color: #ff9caf; }
.command-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.command-tile { width: 100%; min-height: 82px; padding: .85rem; border: 1px solid #2d4c58; border-radius: 11px; background: #0a1220; color: var(--text); text-align: left; cursor: pointer; }
.command-tile:hover { border-color: var(--mint); background: rgba(53, 240, 189, .055); }
.command-tile span, .command-tile small { display: block; }
.command-tile span { font-weight: 800; }
.probe { display: inline-block; padding: .22rem .45rem; border: 1px solid currentColor; border-radius: 999px; font-size: .68rem; }
.probe--ok { color: var(--mint); }
.probe--degraded { color: var(--warning); }
.probe--blocked, .probe--failed { color: var(--danger); }
.probe--unsupported { color: var(--muted); }
.telemetry-list { display: grid; gap: .55rem; margin: 0; }
.telemetry-list > div { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .5rem; border-bottom: 1px solid rgba(34, 51, 74, .65); }
.telemetry-list dt { color: var(--muted); }
.telemetry-list dd { margin: 0; color: var(--text); text-align: right; }
.timeline-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid rgba(34, 51, 74, .65); }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); }
.timeline-item--warning .timeline-dot { background: var(--warning); }
.timeline-item--critical .timeline-dot { background: var(--danger); }
.endpoint-row { padding: .8rem 0; border-bottom: 1px solid rgba(34, 51, 74, .75); }
.endpoint-row > summary { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }

@media (max-width: 1000px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid, .form-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .signal-grid, .command-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 1rem; }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 1rem 0; }
    .logout { margin: 0; }
    .topbar { align-items: flex-start; }
    .identity { flex-direction: column; align-items: flex-end; gap: .15rem; }
    .card-grid, .form-grid, .form-grid--3, .form-grid--2 { grid-template-columns: 1fr; }
    .control-hero, .section-heading { align-items: flex-start; flex-direction: column; }
    .signal-grid, .command-grid { grid-template-columns: 1fr; }
}
