/* Sentinel VPN admin panel.
   Plain CSS in a separate file, not inline: the control server sends a strict
   CSP with no unsafe-inline, so an inline <style> block would be blocked. That
   is deliberate - the CSP is worth more than the convenience.

   The same rule shapes the JavaScript: no inline handlers, no innerHTML. A
   panel that renders operator- and node-supplied strings is the obvious place
   for an injected script to land, and the CSP is the backstop rather than the
   only defence. */

:root {
  --bg: #0a0d13;
  --surface: #12171f;
  --surface-2: #1a202b;
  --surface-3: #212836;
  --border: #262d3a;
  --border-soft: #1e2531;
  --text: #e6e9ef;
  --muted: #8b94a7;
  --accent: #4f8cff;
  --accent-dim: #2a4a86;
  --ok: #35c88a;
  --warn: #e0a458;
  --bad: #e5615e;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 232px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.accent { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.spacer { flex: 1; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 19px; }
h2 { font-size: 15px; }
h3 { font-size: 15px; }

/* ---- login ---- */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  /* A quiet wash of the brand colour, so the sign-in page is not a black box. */
  background:
    radial-gradient(760px 420px at 50% -10%, rgba(79, 140, 255, .16), transparent 70%),
    var(--bg);
}

.login-card {
  width: min(380px, calc(100vw - 3rem));
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 2rem;
  text-align: center;
}

.login-mark { width: 60px; height: 60px; margin: 0 auto .25rem; object-fit: contain; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 0 0 .75rem; }
.login-card label { text-align: left; font-size: 12.5px; color: var(--muted); margin-top: .35rem; }
.login-card button { margin-top: 1rem; }

/* ---- shell ---- */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.1rem .75rem;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 .4rem;
  font-weight: 600;
  font-size: 15px;
}

.brand-mark { width: 30px; height: 30px; object-fit: contain; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.tab {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .55rem .7rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.tab:hover { background: var(--surface-2); color: var(--text); }

.tab[aria-current="true"] {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 500;
}

.tab-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  flex: none;
}

.tab[aria-current="true"] .tab-dot { background: var(--accent); opacity: 1; }

.sidebar-foot { margin-top: auto; padding: 0 .5rem; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 13, 19, .8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

.account { display: flex; align-items: center; gap: .6rem; padding-left: .75rem; border-left: 1px solid var(--border); }
.who { display: flex; flex-direction: column; line-height: 1.25; }

main { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* Each view lays its own children out.
   `main` only spaces the sections apart from each other, and a section is a
   single flex item — so without this the toolbar, the create form and the table
   inside one view sat flush against each other with no space at all. */
.view { display: flex; flex-direction: column; gap: 1.25rem; }

/* ---- cards, panels ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

/* ---- stats ---- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.stat .value { font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: 12.5px; margin-top: .15rem; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: .35rem; }

/* ---- toolbar ---- */

.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

.search { min-width: 220px; }

/* ---- forms ---- */

input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .5rem .65rem;
  font: inherit;
  font-size: 13.5px;
  width: 100%;
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form { display: flex; flex-direction: column; gap: 1rem; }
.form .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .85rem; }
.form label { display: flex; flex-direction: column; gap: .3rem; font-size: 12.5px; color: var(--muted); }
/* Not `.form .actions`: the token dialog has an action row too and is not a
   form, so a form-scoped rule left its buttons touching. */
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.switches {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: .75rem .9rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  margin: 0;
}

.switch { flex-direction: row !important; align-items: center; gap: .45rem !important; color: var(--text) !important; }
.switch input, .show-revoked input { width: auto; }

/* ---- buttons ---- */

button {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: .5rem .9rem;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

button:disabled { opacity: .5; cursor: not-allowed; }

.primary { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: #3f7bee; }

.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.ghost:hover:not(:disabled) { background: var(--surface-2); }

.danger { background: transparent; border-color: rgba(229, 97, 94, .45); color: var(--bad); }
.danger:hover:not(:disabled) { background: rgba(229, 97, 94, .12); }

button.small { padding: .35rem .7rem; font-size: 12.5px; }

/* ---- tables ---- */

.wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 600;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: .7rem 1rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

td .row-actions { display: flex; gap: .4rem; justify-content: flex-end; }

/* ---- pills ---- */

.pill {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.pill.active, .pill.online, .pill.success {
  background: rgba(53, 200, 138, .12); color: var(--ok); border-color: rgba(53, 200, 138, .25);
}
.pill.pending, .pill.draining, .pill.expired {
  background: rgba(224, 164, 88, .12); color: var(--warn); border-color: rgba(224, 164, 88, .25);
}
.pill.revoked, .pill.offline, .pill.disabled, .pill.failure {
  background: rgba(229, 97, 94, .12); color: var(--bad); border-color: rgba(229, 97, 94, .25);
}

.dot-live {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); margin-right: .4rem;
}
.dot-idle { background: var(--border); }

/* ---- node cards ---- */

.nodes { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1rem; }

.node-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.node-head { display: flex; align-items: center; gap: .6rem; }
.node-head .name { font-weight: 600; }

.node-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .9rem; }
.node-meta div { display: flex; justify-content: space-between; gap: .5rem; font-size: 12.5px; }
.node-meta .k { color: var(--muted); }

.meters { display: flex; flex-direction: column; gap: .5rem; }
.meter-row { display: grid; grid-template-columns: 62px 1fr 42px; align-items: center; gap: .6rem; font-size: 12px; }
.meter-row .k { color: var(--muted); }
.meter-row .v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter > span.warn { background: var(--warn); }
.meter > span.bad { background: var(--bad); }

/* ---- health rows (overview) ---- */

.health-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1.1rem; border-bottom: 1px solid var(--border-soft);
}
.health-row:last-child { border-bottom: 0; }
.health-row .name { font-weight: 500; }
.health-row .meter { flex: 1; max-width: 160px; }

/* ---- activity ---- */

.activity-row {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .6rem 1.1rem; border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.activity-row:last-child { border-bottom: 0; }
.activity-row .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.activity-row .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- misc ---- */

.empty { padding: 2.25rem 1rem; text-align: center; color: var(--muted); }
.error { color: var(--bad); font-size: 13px; margin: 0; }

.pager { display: flex; align-items: center; gap: .75rem; justify-content: center; }

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(4, 6, 10, .72);
  display: grid; place-items: center; padding: 1.5rem;
}

.dialog { width: min(560px, 100%); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .75rem; }

.token {
  display: block; word-break: break-all;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .75rem;
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 12.5px;
}

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem 1rem;
  box-shadow: var(--shadow); z-index: 30; font-size: 13px;
}
.toast.bad { border-color: rgba(229, 97, 94, .5); color: var(--bad); }

/* ---- narrow screens ---- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 1rem; overflow-x: auto; }
  .nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  .split { grid-template-columns: 1fr; }
  main { padding: 1rem; }
  .topbar { padding: .85rem 1rem; }
}
