/* InkVPN Controller — dark operations console
   Tokens ------------------------------------------------------------------ */
:root {
  --bg: #0B1120;
  --bg-2: #0F172A;
  --panel: #131C2E;
  --card: #1B2336;
  --card-2: #212B41;
  --line: #273247;
  --line-2: #334155;
  --text: #F8FAFC;
  --text-2: #CBD5E1;
  --muted: #94A3B8;
  --muted-2: #64748B;
  --ok: #22C55E;
  --ok-dim: rgba(34,197,94,.14);
  --warn: #F59E0B;
  --warn-dim: rgba(245,158,11,.14);
  --bad: #EF4444;
  --bad-dim: rgba(239,68,68,.14);
  --info: #38BDF8;
  --info-dim: rgba(56,189,248,.14);
  --accent: #22C55E;
  --accent-ink: #052E16;
  --violet: #A78BFA;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --r-xs: 6px;
  --sans: "Fira Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 1px 0 rgba(255,255,255,.04) inset, 0 24px 60px -20px rgba(0,0,0,.75);
  --ease: cubic-bezier(.2,.8,.2,1);
  --sidebar-w: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(34,197,94,.08), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(56,189,248,.06), transparent 60%), var(--bg);
  color: var(--text); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: rgba(34,197,94,.35); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 14px; height: 14px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* Layout ------------------------------------------------------------------ */
.app { min-height: 100%; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--bg-2) 0, var(--bg) var(--sidebar-w), transparent var(--sidebar-w)); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg)); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #14532D, #052E16); display: grid; place-items: center; box-shadow: var(--shadow); }
.brand-mark svg { width: 20px; height: 20px; stroke: var(--ok); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand b { display: block; font-weight: 600; letter-spacing: .01em; }
.brand span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); color: var(--text-2);
  min-height: 40px; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav a.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.nav a.active svg { color: var(--ok); }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.side-foot .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.main { padding: 22px 28px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-dim); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--ok-dim);} 50% { box-shadow: 0 0 0 6px transparent; } }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: min(280px, 85vw); transform: translateX(-100%); transition: transform .2s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 39; }
  .main { padding: 16px; }
  .btn.menu-btn { display: inline-flex; }
}
.btn.menu-btn { display: none; }
@media (max-width: 960px) { .btn.menu-btn { display: inline-flex; } }

/* Cards & grid ------------------------------------------------------------ */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1200px) { .two, .three { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card.pad-0 { padding: 0; }
.card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; }
.card h3 .right { margin-left: auto; font-weight: 500; text-transform: none; letter-spacing: 0; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; overflow-wrap: anywhere; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi .trend { font-size: 12px; color: var(--muted); }
.kpi.ok .value { color: var(--ok); } .kpi.bad .value { color: var(--bad); } .kpi.warn .value { color: var(--warn); }

/* Server card ------------------------------------------------------------- */
.srv { display: flex; flex-direction: column; gap: 12px; padding: 16px; position: relative; transition: border-color .15s var(--ease), transform .15s var(--ease); }
.srv:hover { border-color: var(--line-2); }
.srv .head { display: flex; align-items: center; gap: 10px; }
.srv .flag { font-size: 24px; line-height: 1; width: 32px; text-align: center; }
.srv .name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.srv .ip { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.srv .status { margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; line-height: 1.4; white-space: nowrap; border: 1px solid transparent; }
.pill .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-dim); border-color: rgba(34,197,94,.25); }
.pill.bad { color: var(--bad); background: var(--bad-dim); border-color: rgba(239,68,68,.25); }
.pill.warn { color: var(--warn); background: var(--warn-dim); border-color: rgba(245,158,11,.25); }
.pill.info { color: var(--info); background: var(--info-dim); border-color: rgba(56,189,248,.25); }
.pill.neutral { color: var(--muted); background: rgba(148,163,184,.1); border-color: var(--line-2); }
.pill.ok .d { box-shadow: 0 0 0 3px var(--ok-dim); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--bad); color: #fff; }
.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.meter { display: flex; flex-direction: column; gap: 5px; }
.meter .row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.meter .row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .5s var(--ease), background-color .3s; }
.bar > i.warn { background: var(--warn); } .bar > i.bad { background: var(--bad); }
.netrow { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.netrow b { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.svcs { display: flex; gap: 6px; flex-wrap: wrap; }
.svc { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: var(--r-xs); background: rgba(255,255,255,.04); font-family: var(--mono); font-size: 11.5px; color: var(--text-2); border: 1px solid var(--line); }
.svc .d { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); } .svc.off .d { background: var(--bad); } .svc.off { color: var(--muted); }
.srv .foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.srv.offline { border-color: rgba(239,68,68,.35); background: linear-gradient(180deg, rgba(239,68,68,.05), transparent 40%), var(--card); }
.srv .spark { position: absolute; right: 16px; top: 44px; opacity: .6; }
.srv .alert-strip { display: flex; gap: 6px; flex-wrap: wrap; }

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--card-2); color: var(--text); font-weight: 500; font-size: 13px;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease), opacity .15s; white-space: nowrap;
}
.btn:hover { background: #283553; border-color: #3E4C66; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #34D46B; }
.btn.danger { color: #FCA5A5; border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.08); }
.btn.danger:hover { background: rgba(239,68,68,.16); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: rgba(255,255,255,.05); color: var(--text); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: var(--r-xs); }
.btn.icon { padding: 0; width: 36px; justify-content: center; }
.btn.icon.sm { width: 30px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 500; min-height: 28px; }
.seg button.active { background: var(--card-2); color: var(--text); box-shadow: var(--shadow); }

/* Forms ------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--muted-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:focus { outline: none; border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-dim); }
.input.mono { font-family: var(--mono); font-size: 13px; }
textarea.input { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 40px; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--line-2); transition: background-color .15s var(--ease); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s var(--ease); }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check input:checked + .switch { background: var(--ok); } .check input:checked + .switch::after { transform: translateX(18px); }
.check input:focus-visible + .switch { outline: 2px solid var(--info); outline-offset: 2px; }

/* Tables ------------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255,255,255,.02); }
.table .r { text-align: right; }
.table td.r .btn-row { flex-wrap: nowrap; }
.table-wrap { overflow-x: auto; }
.dragging { opacity: .4; }

/* Logs -------------------------------------------------------------------- */
.log { background: #070C18; border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; color: #C7D2E1; white-space: pre-wrap; word-break: break-word; max-height: 520px; overflow: auto; }
.log .ok { color: var(--ok); } .log .warn { color: var(--warn); } .log .bad { color: var(--bad); } .log .step { color: var(--info); font-weight: 500; }

/* Journal ----------------------------------------------------------------- */
.feed { display: flex; flex-direction: column; }
.feed .item { display: grid; grid-template-columns: 8px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.feed .item:last-child { border-bottom: 0; }
.feed .d { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--muted-2); }
.feed .d.ok { background: var(--ok); } .feed .d.error, .feed .d.crit, .feed .d.failed { background: var(--bad); } .feed .d.warn, .feed .d.partial { background: var(--warn); } .feed .d.running { background: var(--info); animation: pulse 1.5s infinite; }
.feed .t { font-size: 13px; }
.feed .t b { font-weight: 500; }
.feed .m { color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-word; }
.feed .ts { font-family: var(--mono); font-size: 11.5px; color: var(--muted-2); white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }

/* Charts ------------------------------------------------------------------ */
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: rgba(255,255,255,.05); }
.chart .area { fill: url(#g-ok); } .chart .line { fill: none; stroke: var(--ok); stroke-width: 1.5; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* Login ------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; padding: 28px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px; }
.login .brand { padding: 0 0 6px; }
.login h2 { margin: 0; font-size: 18px; font-weight: 600; }
.login .err { color: #FCA5A5; font-size: 13px; background: var(--bad-dim); border: 1px solid rgba(239,68,68,.3); padding: 8px 10px; border-radius: var(--r-sm); }

/* Toasts & modal ---------------------------------------------------------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, 90vw); }
.toast { padding: 10px 14px; border-radius: var(--r-md); background: var(--card-2); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; animation: rise .2s var(--ease); }
.toast.ok { border-color: rgba(34,197,94,.4); } .toast.bad { border-color: rgba(239,68,68,.5); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.modal-scrim { position: fixed; inset: 0; background: rgba(2,6,23,.7); backdrop-filter: blur(4px); z-index: 90; display: grid; place-items: center; padding: 16px; animation: fade .15s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 560px; background: var(--card); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: 92vh; overflow: auto; }
.modal.wide { max-width: 900px; }
.modal h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }
.gauge { display: flex; align-items: center; gap: 14px; }
.gauge svg { width: 64px; height: 64px; flex: none; }
.gauge .v { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.gauge .l { font-size: 12px; color: var(--muted); }
.code { display: flex; align-items: center; gap: 8px; background: #070C18; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px; font-family: var(--mono); font-size: 12.5px; overflow: auto; }
.code code { flex: 1; white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 10px 12px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 40px; white-space: nowrap; }
.tabs button.active { color: var(--text); border-color: var(--ok); }
.skeleton { background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 50%, var(--card) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r-sm); min-height: 80px; }
@keyframes sk { to { background-position: -200% 0; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.step-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.step-list .s { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.step-list .s svg { color: var(--ok); }
