:root {
  color-scheme: dark;
  --bg: #07111e;
  --surface: #0d1a2a;
  --surface-2: #122238;
  --line: #233a55;
  --text: #edf6ff;
  --muted: #91a6bd;
  --cyan: #33d4ff;
  --green: #39e58c;
  --red: #ff6470;
  --amber: #ffc857;
  --shadow: 0 24px 70px rgba(0, 0, 0, .35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 78% -20%, #10375b 0, transparent 34%), var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.muted { color: var(--muted); margin: .35rem 0 0; line-height: 1.55; }
.compact { font-size: .82rem; }
.eyebrow { color: var(--cyan); font-size: .72rem; font-weight: 800; letter-spacing: .16em; margin: 0 0 .55rem; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: min(100%, 430px); padding: 2.25rem; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(145deg, rgba(18,34,56,.96), rgba(9,20,34,.98)); box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-size: 2rem; letter-spacing: -.035em; }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 1.5rem; border: 1px solid rgba(51,212,255,.6); border-radius: 16px; background: linear-gradient(135deg, rgba(51,212,255,.22), rgba(57,229,140,.08)); color: var(--cyan); font-weight: 900; box-shadow: inset 0 0 28px rgba(51,212,255,.09); }
.brand-mark.small { width: 42px; height: 42px; margin: 0; border-radius: 12px; }
.stack-form { display: grid; gap: 1rem; margin-top: 1.7rem; }
label { display: grid; gap: .5rem; color: #c7d7e8; font-size: .9rem; font-weight: 650; }
input { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #071421; color: var(--text); padding: .78rem .9rem; outline: none; }
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(51,212,255,.12); }
.primary-button, .secondary-button, .danger-button, .ghost-button, .icon-button { border: 0; border-radius: 10px; padding: .72rem 1rem; font-weight: 800; }
.primary-button { background: var(--cyan); color: #02131c; }
.primary-button:hover { background: #67e0ff; }
.secondary-button { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.danger-button { background: var(--red); color: #210309; }
.ghost-button { background: transparent; color: var(--muted); padding: .4rem; }
.icon-button { width: 38px; height: 38px; padding: 0; background: var(--surface-2); color: var(--text); font-size: 1.5rem; }
.private-note { margin: 1.35rem 0 0; color: var(--muted); font-size: .78rem; text-align: center; }
.form-error { min-height: 1.2rem; margin: 0; color: var(--red); font-size: .84rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.25rem; border-right: 1px solid var(--line); background: rgba(7,17,30,.88); backdrop-filter: blur(18px); }
.sidebar-brand { display: flex; align-items: center; gap: .8rem; padding: .3rem .2rem 1.6rem; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { margin-top: .2rem; color: var(--muted); font-size: .75rem; }
nav { display: grid; gap: .45rem; }
.nav-item { padding: .8rem .9rem; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; font-weight: 750; }
.nav-item:hover, .nav-item.active { border-color: var(--line); background: var(--surface); color: var(--text); }
.nav-item.active { box-shadow: inset 3px 0 var(--cyan); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 1rem .4rem 0; border-top: 1px solid var(--line); }
.content { min-width: 0; padding: 2rem clamp(1rem, 3vw, 3.2rem) 3rem; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.topbar h1 { margin: 0; font-size: clamp(1.65rem, 2.5vw, 2.35rem); letter-spacing: -.04em; }
.topbar-actions { display: flex; align-items: center; gap: .65rem; }
.compact-button { white-space: nowrap; }
.status-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .85rem; margin-bottom: .95rem; }
.status-card { min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; padding: 1.15rem; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, rgba(18,34,56,.86), rgba(11,25,42,.9)); }
.status-card.accent { border-color: rgba(51,212,255,.45); box-shadow: inset 0 0 45px rgba(51,212,255,.05); }
.status-card strong { font-size: 1.65rem; letter-spacing: -.035em; }
.card-label, .card-meta { color: var(--muted); font-size: .8rem; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: rgba(13,26,42,.9); box-shadow: 0 16px 44px rgba(0,0,0,.18); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.25rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.search-field { width: min(320px, 42%); }
.search-field input { padding: .65rem .8rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .92rem 1.25rem; border-bottom: 1px solid rgba(35,58,85,.72); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: .9rem; }
tbody tr:hover { background: rgba(51,212,255,.025); }
.align-right { text-align: right; }
.client-name { display: block; font-weight: 800; }
.client-ip { display: block; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; margin-top: .18rem; }
.status-pill { display: inline-flex; align-items: center; gap: .45rem; border-radius: 999px; padding: .35rem .65rem; font-size: .76rem; font-weight: 850; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.on { color: var(--green); background: rgba(57,229,140,.09); }
.status-pill.off { color: var(--amber); background: rgba(255,200,87,.09); }
.row-actions { display: flex; justify-content: flex-end; gap: .45rem; }
.toggle-button, .delete-button { border: 1px solid var(--line); border-radius: 9px; padding: .48rem .7rem; background: var(--surface-2); color: var(--text); font-size: .78rem; font-weight: 800; }
.toggle-button.turn-off { color: var(--amber); }
.toggle-button.turn-on { color: var(--green); }
.delete-button { color: var(--red); }
.toggle-button:disabled, .delete-button:disabled, button:disabled { opacity: .55; cursor: wait; }
.empty-state { padding: 3rem 1.25rem; color: var(--muted); text-align: center; }
.empty-state.error { color: var(--red); }
.audit-list { display: grid; }
.audit-item { display: grid; grid-template-columns: 170px 150px minmax(0,1fr); gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.audit-time, .audit-actor { color: var(--muted); font-size: .8rem; }
.audit-action { font-weight: 800; }
.proxy-status-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
.proxy-panel { margin-bottom: .95rem; }
.secret-box { display: flex; align-items: center; gap: .65rem; padding: .8rem; border: 1px solid var(--line); border-radius: 11px; background: #071421; }
.secret-box code { min-width: 0; flex: 1; overflow-wrap: anywhere; color: var(--green); font-size: 1rem; }

dialog { width: min(92vw, 470px); border: 1px solid var(--line); border-radius: 17px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(1,8,15,.78); backdrop-filter: blur(4px); }
.dialog-form { display: grid; gap: 1rem; padding: 1.35rem; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h2, .compact-dialog h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: .4rem; }
.check-row { display: flex; align-items: center; gap: .65rem; }
.check-row input { width: 18px; height: 18px; }
.toast { position: fixed; z-index: 20; right: 1rem; top: 1rem; max-width: min(92vw,420px); padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 11px; background: #102238; color: var(--text); box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,100,112,.55); color: #ffd6d9; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { padding: 0; }
  .sidebar nav { display: flex; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0 0 0 1rem; border: 0; }
  .status-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .proxy-status-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 680px) {
  .sidebar { padding: .8rem 1rem; }
  .sidebar-brand span, .sidebar nav, .sidebar-foot > span { display: none; }
  .content { padding: 1.1rem .8rem 2rem; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .topbar-actions .muted { width: 100%; }
  .topbar-actions button { flex: 1; }
  .status-grid { gap: .6rem; }
  .proxy-status-grid { grid-template-columns: 1fr; }
  .status-card { min-height: 112px; padding: .9rem; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
  th, td { padding: .85rem .8rem; }
  .row-actions { flex-direction: column; }
  .audit-item { grid-template-columns: 1fr; gap: .3rem; }
}
