/* svoVPN panel — vanilla CSS, no build step, weak-VPS friendly. Dark admin theme
   distinct from the public placeholder cover. Accessible: visible focus rings,
   semantic colors with sufficient contrast, respects reduced motion. */
:root {
  --bg: #0e131b;
  --bg-2: #151c28;
  --panel: #1a2331;
  --line: rgba(255, 255, 255, 0.10);
  --ink: #e7edf5;
  --muted: #92a0b5;
  --blue: #3d82f6;
  --blue-deep: #1b4ba8;
  --green: #37c26b;
  --amber: #e0a53b;
  --red: #e2564d;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win — .login/.app set an explicit `display`
   (grid/flex) which otherwise overrides the UA `[hidden]{display:none}` rule and
   leaves both views stacked (login never disappears after a successful sign-in). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}

/* --- login --- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, rgba(61,130,246,0.14), transparent 30rem), var(--bg);
}
.login-card {
  width: min(360px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: 0.5px; }
.login-sub { margin: 0 0 16px; color: var(--muted); }
.login-card label { font-size: 12px; color: var(--muted); margin-top: 8px; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* --- buttons --- */
.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--ink);
  background: var(--bg-2);
}
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-deep); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-small { padding: 5px 9px; font-size: 12px; }

.error { color: var(--red); margin: 8px 0 0; font-size: 13px; }

/* --- app shell --- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 58px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 700; font-size: 18px; }
.brand-tag { color: var(--muted); font-weight: 400; font-size: 13px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 6px;
  font: inherit;
}
.tab[aria-selected="true"] { color: var(--ink); background: var(--panel); }
.tab:hover { color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.whoami { color: var(--muted); font-size: 13px; }

.banner {
  padding: 10px 20px;
  background: rgba(224,165,59,0.14);
  border-bottom: 1px solid var(--line);
  color: var(--amber);
}
.banner.error { background: rgba(226,86,77,0.16); color: var(--red); }
.banner.ok { background: rgba(55,194,107,0.14); color: var(--green); }

.panel { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 17px; }

/* --- tables --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.grid { width: 100%; border-collapse: collapse; min-width: 720px; }
.grid th, .grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.grid th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.grid tbody tr:hover { background: var(--bg-2); }
.grid td.num { font-variant-numeric: tabular-nums; }
.row-revoked td { opacity: 0.5; }

.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); margin-right: 3px; }
.pill-up { color: var(--green); }
.pill-down { color: var(--red); }
.tag-revoked { color: var(--red); border-color: var(--red); }

.desc-input { min-width: 140px; }

/* --- cards (health/metrics) --- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.card .kv { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.card .kv b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-up { background: var(--green); }
.dot-down { background: var(--red); }

/* mini bar sparkline */
.spark { display: flex; align-items: flex-end; gap: 1px; height: 30px; margin-top: 8px; }
.spark span { flex: 1; background: var(--blue); min-height: 1px; border-radius: 1px 1px 0 0; }

/* --- logs --- */
.logs-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 12px; }
.logs-controls label { font-size: 12px; color: var(--muted); display: block; }
.logs-controls select, .logs-controls input { width: auto; }
.logs {
  background: #0a0e14;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  max-height: 60vh;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- dialog --- */
.dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); max-width: 440px; padding: 22px; }
.dialog::backdrop { background: rgba(0,0,0,0.55); }
.dialog h3 { margin: 0 0 10px; }
.dialog p { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
#confirm-ack-wrap { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--red); }
#confirm-ack-wrap input { width: auto; }

.head-actions { display: flex; gap: 8px; }
.dialog label { display: block; font-size: 12px; color: var(--muted); margin-top: 10px; }
.fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 12px 0 4px; padding: 8px 12px; }
.fieldset legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
.fieldset label { display: flex; align-items: center; gap: 8px; color: var(--ink); margin-top: 4px; }
.fieldset input { width: auto; }
.dialog-status { color: var(--muted); font-size: 13px; margin: 12px 0 0; min-height: 1.2em; }

.empty { color: var(--muted); padding: 18px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
