/* BPI admin portal (T195): the console's A14 visual system, in its light and dark themes.
   The tokens are custom properties on :root; `.dark` on the root redefines them with the
   console's dark set, and dark is the default (T225). Since T263 they are the console's
   SocketFox colours (console/src/index.css, docs/design/brand/socketfox_brand_kit.md).
   System fonts only: the page's Content Security Policy loads nothing from elsewhere, and
   this sheet fetches nothing. */

:root {
  color-scheme: light;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --border: #dfe5ee;
  --border-strong: #7f8ca0;
  --text: #131b2e;
  --text-2: #475569;
  --text-3: #5b6779;
  --accent: #346595;
  --accent-hover: #254e7b;
  --accent-soft: #e8f1fa;
  --accent-text: #254e7b;
  --on-accent: #ffffff;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #c81e1e;
  --danger-soft: #fef2f2;
  --info: #4338ca;
  --info-soft: #eef2ff;
  --ring: rgba(52, 101, 149, 0.8);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

/* The dark theme (T225): the console's dark tokens (console/src/index.css `.dark`). */
:root.dark {
  color-scheme: dark;
  --bg: #0b1329;
  --surface: #111b33;
  --surface-2: #1e293b;
  --border: #26324a;
  --border-strong: #64738c;
  --text: #e6ebf3;
  --text-2: #a3afc2;
  --text-3: #8793a8;
  --accent: #38bdf8;
  --accent-hover: #a5dcfb;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --accent-text: #a5dcfb;
  --on-accent: #0b1329;
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #a5b4fc;
  --info-soft: rgba(165, 180, 252, 0.13);
  --ring: rgba(56, 189, 248, 0.8);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Shell: a sidebar beside the main area ---------- */
.app { display: flex; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; width: 240px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
/* The SocketFox emblem and wordmark, and the full logo above the sign-in form (T263),
   each in the theme's version. */
.brand-mark { width: 28px; height: 28px; }
.wordmark { height: 20px; width: auto; }
.auth .logo { width: 224px; align-self: center; }
.logo-dark { display: none; }
:root.dark .logo-light { display: none; }
:root.dark .logo-dark { display: block; }
.menu { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.menu a { padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; font-size: 13.5px; }
.menu a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.menu a.active { background: var(--accent-soft); color: var(--accent-text); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.sidebar-foot p { font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }

.main { flex: 1; min-width: 0; padding: 24px; }
/* Signed out: no sidebar, the main area is a centred card's width. */
.sidebar[hidden] + .main { max-width: 28rem; margin: 48px auto; }
.content, .status { max-width: 1100px; }
.content { display: flex; flex-direction: column; gap: 16px; }
.status:not(:empty) {
  margin-bottom: 16px; padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius);
}

/* Below desktop width the sidebar becomes a top bar whose menu wraps. */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { position: static; height: auto; width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .menu { flex-direction: row; flex-wrap: wrap; padding: 8px 10px; }
  .sidebar-foot { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 16px; }
  .main { padding: 16px; }
}

/* ---------- Page head ---------- */
.page-head { display: flex; flex-direction: column; gap: 6px; }
.title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--text-3); }

/* ---------- Cards ---------- */
.auth, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 20px;
}
.auth { display: flex; flex-direction: column; gap: 16px; }
.card { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.card h3 { margin-top: 4px; }
.card section { width: 100%; }
/* A card's inner section (the optimization switches) keeps its buttons at their own width. */
.card section:not(.secret) { align-items: flex-start; }
.muted { color: var(--text-2); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Forms ---------- */
form, section { display: flex; flex-direction: column; gap: 12px; }
/* A setting: its label and control, then its helper text (T196). */
.setting { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 28rem; }
.setting-check { width: auto; }
.hint { color: var(--text-2); font-size: 12.5px; font-weight: 400; line-height: 1.4; }
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 28rem; font-size: 13px; font-weight: 500; }
.check { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.field input, .field select, .secret input {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 400 14px var(--font);
}
.field input:focus, .field select:focus, .secret input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
/* A prompt (T233): wider than a field, monospaced, several lines. */
.setting-wide, .setting-wide .field { max-width: 48rem; }
.field textarea {
  width: 100%; min-height: 10rem; padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 400 13px var(--mono); line-height: 1.5; resize: vertical;
}
.field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
fieldset {
  width: 100%; margin: 0; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px;
}
legend { padding: 0 4px; font-weight: 600; font-size: 13px; }
fieldset .setting { flex: 1 1 10rem; }
fieldset .setting-check { flex: 0 0 auto; }
fieldset > .hint { flex-basis: 100%; }
/* A checkbox list: one labelled checkbox per item, in columns as wide as fit. */
.checks { flex-basis: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 8px 16px; }
.secret {
  width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px;
  background: var(--warning-soft); border: 1px solid var(--warning); border-radius: var(--radius);
}
.secret p { flex-basis: 100%; }
.secret input { flex: 1 1 16rem; width: auto; font-family: var(--mono); }

/* ---------- Buttons ---------- */
button {
  display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 12px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 500 13.5px/1 var(--font); white-space: nowrap; cursor: pointer;
}
button:hover { background: var(--surface-2); border-color: var(--border-strong); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
