/* Trust SONAR VPN portal styles.
   Palette, typography and layout follow the network-discovery-probe dashboard
   (docs/BRANDING.md there): Trust red #bb1621, grey #53565a, navy #1f2a50,
   Networks teal #045367 / #21999b / #67c1bf, Lato. Logo artwork is used
   unmodified and always shown on white. Light background and border tints are
   derived UI surfaces, not additional brand colours. No external fonts or CDNs:
   the CSP only allows 'self'. */
@font-face { font-family: Lato; src: url('/static/Lato-Regular.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: Lato; src: url('/static/Lato-Bold.ttf') format('truetype'); font-style: normal; font-weight: 700; font-display: swap; }

:root {
  --ink: #1f2a50;          /* Trust navy: headings and primary text */
  --muted: #53565a;        /* Trust grey: secondary text */
  --faint: #69727e;
  --line: #e2e5e9;
  --line-strong: #d9dde3;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f3f5f7;
  --brand-red: #bb1621;    /* Trust red: primary actions, active navigation */
  --brand-red-dark: #94121b;
  --brand-red-text: #a1121b;
  --red-tint: #fbeef0;
  --network: #045367;      /* Networks dark teal: devices, focus */
  --network-tint: #e8f4f4;
  --teal: #21999b;
  --light-teal: #67c1bf;
  --ok: #278451;
  --ok-tint: #e7f4ec;
  --amber: #90691c;
  --amber-tint: #f8f0de;
  --navy-tint: #eceff5;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; font-size: 16px; line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
a { color: var(--brand-red-text); }
code, pre { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; color: var(--ink); }
code.wrap { word-break: break-all; }
h1 { font-size: 31px; line-height: 1.2; letter-spacing: -1.1px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
section { margin-bottom: 24px; }
small { font-size: 14px; }
.muted { color: var(--muted); }
.fine { color: var(--faint); font-size: 14px; }
.hidden, [hidden] { display: none !important; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--network); outline-offset: 3px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; background: #fff; padding: 12px; border: 2px solid var(--network); transform: translateY(-160%); }
.skip-link:focus { transform: none; }

/* Sidebar (as the probe dashboard) */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 238px; background: #fff; border-right: 1px solid var(--line);
  padding: 20px 18px 24px; display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; align-items: center; justify-content: center; padding: 12px 10px; background: #fff; }
.brand img { display: block; width: 180px; max-width: 100%; height: auto; aspect-ratio: 180 / 62; object-fit: contain; object-position: left center; }
.product { display: flex; justify-content: center; border-top: 1px solid var(--line); margin: 18px 0 22px; padding: 24px 10px 0; }
.product img { display: block; width: 180px; max-width: 100%; height: auto; }
.nav-label { font-size: 12px; letter-spacing: 1.7px; color: var(--faint); padding: 0 13px 10px; text-transform: uppercase; }
.nav-label + nav { margin-bottom: 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 5px; }
.nav { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 7px; font-size: 14px; color: var(--muted); text-decoration: none; }
.nav > span { font-size: 17px; width: 19px; line-height: 16px; text-align: center; }
.nav:hover { background: var(--bg); }
.nav[aria-current="page"] { background: var(--red-tint); color: var(--brand-red); font-weight: 700; box-shadow: inset 3px 0 var(--brand-red); }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding: 18px 10px 0; font-size: 14px; }
.sidebar-bottom .who { display: block; color: var(--ink); font-weight: 700; text-decoration: none; }
.sidebar-bottom small { display: block; color: var(--muted); margin: 2px 0 10px; font-size: 12px; }
.sidebar-bottom form { margin: 0; }
.version { float: right; color: var(--muted); font-size: 12px; }
.text-button { background: none; border: 0; padding: 5px 0; font-size: 14px; color: var(--brand-red-text); cursor: pointer; text-align: left; }

.main { margin-left: 238px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 64px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center;
  padding: 0 38px; color: var(--muted); font-size: 14px; background: var(--bg); gap: 16px;
}
.topbar b { font-weight: 700; color: var(--ink); }
.slash { margin: 0 10px; color: #a5abb3; }
.live-badge i { display: inline-block; width: 6px; height: 6px; background: var(--network); border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.content { padding: 30px 38px 24px; max-width: 1500px; width: 100%; flex: 1; }
.eyebrow { font-size: 12px; letter-spacing: 2px; color: var(--network); font-weight: 700; margin-bottom: 8px; text-transform: uppercase; }
.foot { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; padding: 0 38px 24px; max-width: 1500px; }
.crumbs { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.crumbs a { color: var(--muted); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin-bottom: 6px; }

/* Panels */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 23px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 18px 0 24px; }
.stat { display: flex; flex-direction: column; min-height: 112px; }
.stat-l { color: var(--muted); font-size: 14px; order: -1; }
.stat-n { font-size: 34px; letter-spacing: -1px; font-weight: 700; line-height: 1; margin: 14px 0 6px; }
.stat-n small { font-size: 16px; color: var(--faint); font-weight: 400; letter-spacing: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; margin-bottom: 24px; }
.two-col section { margin: 0; }
.danger-zone { border-color: #e7b8bd; }

/* Key/value lists */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.server-info { margin-top: 18px; color: var(--muted); font-size: 14px; }
.server-info summary { cursor: pointer; }
.server-info .kv { margin-top: 12px; }
details.card.server-info { margin-top: 20px; }
details.card.server-info > p { margin: 12px 0; }
.howto { margin: 4px 0 14px; font-size: 14px; }
.howto summary { cursor: pointer; font-weight: 700; margin-bottom: 10px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th { text-align: left; color: var(--muted); font-weight: 500; letter-spacing: .4px; padding: 12px 11px; background: var(--surface-2); white-space: nowrap; }
.grid td { border-bottom: 1px solid #e5e8ec; padding: 13px 11px; line-height: 1.5; vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid td small { display: block; color: var(--faint); font-size: 13px; }
.grid td:first-child a { white-space: nowrap; font-weight: 700; text-decoration: none; }
.grid .num { text-align: right; white-space: nowrap; }
.grid.compact td { padding: 8px 10px; }
.grid .empty { text-align: center; color: var(--muted); padding: 30px; }
.row-disabled td { opacity: .7; }
.row-failure { background: var(--red-tint); }

/* Badges (the probe's .pill / .tag style) */
.kind, .state {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase;
  padding: 4px 7px; border-radius: 4px; vertical-align: middle; white-space: nowrap; line-height: 1.2;
}
.kind-device { color: var(--network); background: var(--network-tint); }
.kind-user { color: var(--ink); background: var(--navy-tint); }
.state-online { color: var(--ok); background: var(--ok-tint); }
.state-offline { color: var(--muted); background: #eef0f3; }
.state-disconnected { color: var(--amber); background: var(--amber-tint); }
.state-disabled { color: var(--brand-red-text); background: var(--red-tint); }
.state::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.state-offline::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; } /* hollow: not colour alone */

/* Buttons (the probe's .primary / .secondary) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  font-size: 14px; font-weight: 400; line-height: 1.2; padding: 10px 15px; border-radius: 7px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--brand-red); border-color: var(--brand-red); color: #fff; font-weight: 700; box-shadow: 0 2px 3px #1f2a5016; }
.btn-primary:hover { background: var(--brand-red-dark); border-color: var(--brand-red-dark); }
.btn-danger { color: var(--brand-red-text); border-color: #e7b8bd; }
.btn-danger:hover { background: var(--red-tint); }
.btn-warn { color: var(--amber); border-color: #e6d3a8; }
.btn-warn:hover { background: var(--amber-tint); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.copied { color: var(--ok); border-color: var(--ok); }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 0; text-decoration: underline; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions form { margin: 0; }
section > .actions, .page-head + .actions, p + .actions { margin-bottom: 18px; }

/* Forms */
.form { max-width: 860px; }
.form fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.form legend { font-weight: 700; margin-bottom: 6px; font-size: 16px; padding: 0; }
label { display: block; font-size: 14px; font-weight: 700; margin: 0 0 15px; }
label small { display: block; font-weight: 400; color: var(--faint); margin-top: 6px; font-size: 13px; line-height: 1.5; }
input, select, textarea {
  display: block; width: 100%; margin-top: 7px; font-size: 14px; font-weight: 400; color: var(--ink);
  background: #fff; border: 1px solid #78818e; border-radius: 6px; padding: 10px 11px;
}
textarea { resize: vertical; line-height: 1.6; }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: auto; margin: 0 8px 0 0; vertical-align: middle; accent-color: var(--brand-red); }
label.radio, label.check { font-weight: 400; }
label.radio small { display: inline; margin-left: 4px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 15px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.stack label { margin-bottom: 16px; }
.inline { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.inline label { margin: 0; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type="search"], .filters select { width: auto; margin: 0; min-width: 13rem; border-color: var(--line-strong); }
.filters label.check { margin: 0; font-size: 14px; color: var(--muted); }
.otp { font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center; }

/* Notices */
.flash { padding: 14px 18px; border-radius: 8px; margin-bottom: 18px; border: 1px solid; font-size: 14px; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash-success { color: #1d6a40; background: var(--ok-tint); border-color: #b5dcc4; }
.flash-error { color: var(--brand-red-text); background: var(--red-tint); border-color: #e7b8bd; }
.flash-warn { color: #6f5114; background: var(--amber-tint); border-color: #e6d3a8; }
.flash-info { color: var(--muted); background: #edf7f7; border-color: #a9d1d3; }

/* Config display */
pre.config { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 16px; overflow-x: auto; white-space: pre; margin: 0 0 16px; font-size: 13px; color: var(--ink); }
.qr { background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--line); max-width: 100%; height: auto; }
.secret { font-size: 16px; letter-spacing: .05em; }

/* Sign-in pages (as the probe's login card) */
body.bare { min-height: 100vh; }
body.bare .content { max-width: none; padding: 0; }
.auth-card { max-width: 440px; margin: 8vh auto; padding: 40px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px #182b4510; }
.auth-card.wide { max-width: 640px; }
.auth-card h1 { font-size: 28px; margin: 22px 0 6px; letter-spacing: -.6px; }
.auth-card > p { color: var(--muted); }
.org-logo { display: block; width: 190px; max-width: 100%; height: auto; aspect-ratio: 190 / 66; object-fit: contain; object-position: left center; }
.product-logo { display: block; width: 170px; height: auto; margin: 26px 0 4px; }
.mfa-grid { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; margin: 16px 0; }
.pager { display: flex; gap: 8px; margin-top: 16px; }

@media (max-width: 1150px) {
  .sidebar { width: 202px; padding: 20px 12px; }
  .main { margin-left: 202px; }
  .topbar, .content, .foot { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 780px) {
  .sidebar { position: static; width: 100%; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { justify-content: flex-start; padding: 4px 0; }
  .brand img { width: 140px; }
  .product { justify-content: flex-start; margin: 12px 0; padding: 12px 0 0; }
  .product img { width: 150px; }
  .nav-label { display: none; }
  .sidebar nav { flex-direction: row; overflow-x: auto; gap: 4px; margin-bottom: 8px !important; }
  .nav { white-space: nowrap; padding: 9px 10px; }
  .nav[aria-current="page"] { box-shadow: inset 0 -3px var(--brand-red); }
  .sidebar-bottom { padding-top: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .sidebar-bottom small { margin: 0; }
  .version { display: none; }
  .main { margin-left: 0; }
  .topbar { height: auto; padding: 12px 16px; }
  .live-badge { display: none; }
  .content { padding: 20px 16px; }
  .foot { padding: 0 16px 20px; }
  h1 { font-size: 26px; }
  .auth-card { margin: 24px 16px; padding: 28px; }
  .mfa-grid { grid-template-columns: 1fr; justify-items: center; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .filters input[type="search"], .filters select { min-width: 0; flex: 1; }
  .two-col { grid-template-columns: 1fr; }
}
