:root {
    color-scheme: dark;
    --bg: #090a0d;
    --surface: #111319;
    --surface-2: #171a21;
    --line: #2a2e38;
    --line-soft: #20232b;
    --text: #f4f5f7;
    --muted: #9ba1ad;
    --red: #e33a45;
    --red-strong: #ff4c57;
    --red-dark: #6d1c24;
    --green: #4fce8b;
    --amber: #f0b955;
    --shadow: 0 24px 80px rgba(0, 0, 0, .44);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }

button { color: inherit; }

.hidden { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.shell { min-height: 100vh; }

.topbar {
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(18px, 4vw, 56px);
    border-bottom: 1px solid var(--line-soft);
    background: rgba(9, 10, 13, .94);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid #8e2730;
    background: #281014;
    color: var(--red-strong);
    font-weight: 900;
    border-radius: 6px;
}

.brand strong { display: block; font-size: 15px; line-height: 1; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 1.4px; }

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

.status-pill, .role-pill, .lock-state {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--muted);
    background: var(--surface);
    font-size: 12px;
    font-weight: 700;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: var(--amber); }
.status-up .status-dot { background: var(--green); box-shadow: 0 0 10px rgba(79, 206, 139, .5); }
.status-down .status-dot { background: var(--red); }
.role-pill { color: #d7dae0; text-transform: uppercase; }

main { width: 100%; }

.login-view {
    min-height: calc(100vh - 68px);
    display: grid;
    grid-template-columns: minmax(360px, 520px) minmax(360px, 1fr);
    align-items: stretch;
}

.login-panel {
    align-self: center;
    width: min(100%, 430px);
    margin: 40px auto;
    padding: clamp(28px, 5vw, 48px);
}

.section-kicker { color: var(--red-strong); font-size: 11px; font-weight: 900; letter-spacing: 1.7px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(32px, 5vw, 52px); line-height: 1.02; letter-spacing: 0; }
h2 { margin-bottom: 6px; font-size: 18px; letter-spacing: 0; }
.lead, .section-heading p, .admin-toolbar p { color: var(--muted); line-height: 1.55; }
.lead { margin-bottom: 30px; max-width: 390px; }

.role-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    margin-bottom: 22px;
    border: 1px solid var(--line);
    background: #0d0f13;
    border-radius: 6px;
}

.role-option {
    height: 38px;
    border: 0;
    border-radius: 4px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-weight: 750;
}

.role-option.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px #353945; }

label { display: block; margin-bottom: 8px; color: #c8cbd2; font-size: 12px; font-weight: 750; }

.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; }

input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0 13px;
    color: var(--text);
    background: #0d0f13;
    outline: none;
}

input:focus { border-color: #9e3039; box-shadow: 0 0 0 3px rgba(227, 58, 69, .12); }

.button, .icon-button {
    border: 1px solid var(--line);
    border-radius: 5px;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
    font-weight: 780;
}

.button:active, .icon-button:active { transform: translateY(1px); }
.button:disabled, .icon-button:disabled { opacity: .45; cursor: not-allowed; }
.button { min-height: 38px; padding: 0 14px; }
.button-full { width: 100%; min-height: 44px; }
.button-primary { border-color: #b62d37; background: var(--red); color: white; }
.button-primary:hover { background: var(--red-strong); }
.button-secondary { background: var(--surface-2); }
.button-secondary:hover, .button-quiet:hover { border-color: #4a4f5b; background: #20232b; }
.button-danger { color: #ffb0b6; border-color: #6f2830; background: #321318; }
.button-danger:hover { background: #44171e; }
.button-quiet { background: transparent; color: var(--muted); }
.button-small { min-height: 30px; padding: 0 9px; font-size: 11px; }
.icon-button { min-width: 62px; padding: 0 10px; background: var(--surface-2); color: var(--muted); }

.form-message { min-height: 20px; margin: 12px 0 0; color: #ff8e96; font-size: 12px; }
.lock-notice { margin-top: 18px; padding: 12px 14px; border-left: 3px solid var(--amber); background: #211b10; color: #f2d69c; font-size: 12px; }

.signal-panel {
    position: relative;
    overflow: hidden;
    border-left: 1px solid var(--line-soft);
    background: #0d0e12;
}

.signal-grid {
    position: absolute;
    inset: 0;
    opacity: .48;
    background-image: linear-gradient(rgba(227, 58, 69, .09) 1px, transparent 1px), linear-gradient(90deg, rgba(227, 58, 69, .09) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom right, transparent 0%, black 48%, transparent 100%);
}

.signal-content { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.signal-content p { color: #6f747e; font-size: 11px; text-transform: uppercase; letter-spacing: 1.6px; }
.signal-ring {
    width: 210px;
    height: 210px;
    margin: 0 auto 24px;
    display: grid;
    place-items: center;
    border: 1px solid #4c1d22;
    border-radius: 50%;
    box-shadow: 0 0 0 34px rgba(227, 58, 69, .025), 0 0 0 68px rgba(227, 58, 69, .018);
}
.signal-ring::before, .signal-ring::after { content: ""; position: absolute; width: 148px; height: 1px; background: #5e2228; }
.signal-ring::after { transform: rotate(90deg); }
.signal-ring span { color: #f06770; font-size: 36px; font-weight: 950; letter-spacing: 4px; }

.panel-view { width: min(1440px, 100%); margin: 0 auto; padding: 42px clamp(18px, 4vw, 56px) 72px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 28px; }
.page-heading h1 { margin: 6px 0 8px; font-size: clamp(30px, 4vw, 46px); }
.page-heading p { margin: 0; color: var(--muted); }
.lock-state { color: #f0d39b; border-color: #59451f; background: #201a10; }
.lock-state.unlocked { color: #a7eac7; border-color: #225c40; background: #10261c; }

.metric-band {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin-bottom: 38px;
}
.metric { min-height: 94px; padding: 22px 24px; border-right: 1px solid var(--line); }
.metric:first-child { padding-left: 0; }
.metric:last-child { border-right: 0; }
.metric span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.metric strong { font-size: 18px; }

.content-section { display: grid; gap: 30px; }
.admin-toolbar, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.admin-toolbar { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.admin-toolbar p, .section-heading p { margin: 0; font-size: 13px; }
.command-row { display: flex; flex-wrap: wrap; gap: 8px; }
.table-section { padding-top: 4px; }
.section-heading.compact { margin-bottom: 14px; }

.search-field { width: min(320px, 100%); margin: 0; }
.search-field input { height: 38px; }

.table-wrap { position: relative; overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { color: #7f8590; font-size: 10px; text-transform: uppercase; font-weight: 850; }
td { color: #d7d9de; font-size: 12px; }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; text-align: right; }
.session-role { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; font-size: 10px; font-weight: 850; }
.session-role.admin { color: #ff9fa6; border-color: #6d2830; background: #2c1317; }
.session-role.guest { color: #a9d6f5; border-color: #2f5068; background: #111f29; }
.current-label { color: var(--green); margin-left: 7px; font-size: 10px; font-weight: 800; }
.client-cell { max-width: 350px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.row-actions { display: inline-flex; justify-content: flex-end; gap: 6px; }
.empty-state { padding: 24px 0; color: var(--muted); font-size: 13px; }

.detail-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-list div { padding: 22px; border-right: 1px solid var(--line); }
.detail-list div:first-child { padding-left: 0; }
.detail-list div:last-child { border-right: 0; }
.detail-list dt { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.detail-list dd { margin: 8px 0 0; font-weight: 750; }
.text-success { color: var(--green); }

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 50;
    max-width: min(390px, calc(100vw - 44px));
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--green);
    border-radius: 5px;
    background: #14171d;
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 12px;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: var(--red); }

@media (max-width: 900px) {
    .login-view { grid-template-columns: 1fr; }
    .signal-panel { display: none; }
    .metric-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric:nth-child(2) { border-right: 0; }
    .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .metric:nth-child(3) { padding-left: 0; }
    .admin-toolbar, .section-heading { align-items: flex-start; flex-direction: column; }
    .search-field { width: 100%; }
}

@media (max-width: 600px) {
    .topbar { height: 62px; }
    .status-pill { display: none; }
    .login-view { min-height: calc(100vh - 62px); }
    .login-panel { padding: 30px 20px; }
    .panel-view { padding-top: 28px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .metric { min-height: 82px; padding: 17px 13px; }
    .metric strong { font-size: 15px; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list div, .detail-list div:first-child { padding: 17px 0; border-right: 0; border-bottom: 1px solid var(--line-soft); }
    .detail-list div:last-child { border-bottom: 0; }
    .command-row, .command-row .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
