/* Brahmi portal design system. Same brand tokens as the marketing site. */
:root {
  --bg: #ffffff; --bg-alt: #f7f7fb; --surface: #ffffff; --surface-2: #f3f2f8;
  --border: #e8e6f0; --border-strong: #d6d3e2; --text: #16141f; --muted: #565169; --faint: #8a8599;
  --brand: #6b46e5; --brand-hover: #5a37d1; --brand-soft: #f1edff; --brand-ink: #4b2fb8;
  --ok: #15803d; --warn: #b45309; --info: #2f5bd3; --danger: #dc2626;
  --ok-bg: #e9f8ef; --warn-bg: #fdf3e3; --info-bg: #ebf0fd; --danger-bg: #fdecec;
  --header-bg: rgba(255,255,255,.88); --code-bg: #15131f; --code-text: #e6e3f0;
  --shadow-sm: 0 1px 2px rgba(22,20,31,.05);
  --shadow: 0 1px 2px rgba(22,20,31,.04), 0 8px 24px -12px rgba(22,20,31,.12);
  --radius: 12px; --header-h: 60px; --container: 1180px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #0e0d14; --bg-alt: #13121b; --surface: #17151f; --surface-2: #211f2c;
  --border: #2a2738; --border-strong: #3a3650; --text: #eeedf4; --muted: #a9a5b8; --faint: #77738a;
  --brand: #8b6cf6; --brand-hover: #9d82f8; --brand-soft: rgba(139,108,246,.14); --brand-ink: #c4b5fd;
  --ok: #4ade80; --warn: #fbbf24; --info: #8aa8ff; --danger: #f87171;
  --ok-bg: rgba(74,222,128,.12); --warn-bg: rgba(251,191,36,.12); --info-bg: rgba(138,168,255,.12); --danger-bg: rgba(248,113,113,.12);
  --header-bg: rgba(14,13,20,.85); --code-bg: #09080e; --code-text: #e6e3f0;
  --shadow-sm: none; --shadow: 0 12px 32px -16px rgba(0,0,0,.6);
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0d14; --bg-alt: #13121b; --surface: #17151f; --surface-2: #211f2c;
  --border: #2a2738; --border-strong: #3a3650; --text: #eeedf4; --muted: #a9a5b8; --faint: #77738a;
  --brand: #8b6cf6; --brand-hover: #9d82f8; --brand-soft: rgba(139,108,246,.14); --brand-ink: #c4b5fd;
  --ok: #4ade80; --warn: #fbbf24; --info: #8aa8ff; --danger: #f87171;
  --ok-bg: rgba(74,222,128,.12); --warn-bg: rgba(251,191,36,.12); --info-bg: rgba(138,168,255,.12); --danger-bg: rgba(248,113,113,.12);
  --header-bg: rgba(14,13,20,.85); --code-bg: #09080e; --code-text: #e6e3f0;
  --shadow-sm: none; --shadow: 0 12px 32px -16px rgba(0,0,0,.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg-alt); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; } h2 { font-size: 1.15rem; font-weight: 600; } h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.skip-link { position: absolute; left: -999px; } .skip-link:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 50; height: var(--header-h); background: var(--header-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { height: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; }
.logo { display: flex; align-items: center; } .logo img { height: 28px; width: auto; }
.logo-on-dark { display: none; }
:root[data-theme="dark"] .logo-on-light { display: none; } :root[data-theme="dark"] .logo-on-dark { display: block; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 500; font-size: .93rem; display: inline-flex; align-items: center; gap: 6px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 1px solid transparent; color: var(--muted); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 1.15rem; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle .ri-sun-line { display: none; } :root[data-theme="dark"] .theme-toggle .ri-sun-line { display: inline; } :root[data-theme="dark"] .theme-toggle .ri-moon-line { display: none; }
.nav-toggle { display: none; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.user-menu > summary::-webkit-details-marker { display: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; }
.user-name { font-size: .88rem; font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; color: var(--text); font: inherit; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop .menu-label { padding: 6px 10px; font-size: .78rem; color: var(--faint); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- Layout ---- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 28px 20px 56px; flex: 1; }
main[data-fw]:not([data-fw=""]) { max-width: none; padding: 0; height: calc(100vh - var(--header-h)); display: flex; flex-direction: column; min-height: 0; }
main[data-fw]:not([data-fw=""]) .messages { margin: 0; padding: 8px 12px; }
.full-width { flex: 1; display: flex; flex-direction: column; min-height: 0; height: calc(100vh - var(--header-h)); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; } .page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin-bottom: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---- Card / stat ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px; } .card-body > :last-child { margin-bottom: 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.stat-value { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.stat-sub { color: var(--faint); font-size: .8rem; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 .92rem var(--font); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); } .btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .82rem; border-radius: 7px; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 600; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; } .table tbody tr:hover { background: var(--bg-alt); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--info-bg); color: var(--info); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); } .badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); } .badge-muted { background: var(--surface-2); color: var(--muted); }

/* ---- Empty ---- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty i { font-size: 2rem; color: var(--faint); display: block; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ---- Forms ---- */
.form .field { margin-bottom: 16px; }
.form label { display: block; font-weight: 500; font-size: .88rem; margin-bottom: 6px; }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=number], .form input[type=search], .form select, .form textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; }
.form textarea { font-family: var(--mono); font-size: .85rem; min-height: 110px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.help { color: var(--faint); font-size: .8rem; margin-top: 4px; } .help ul { margin: 4px 0 0; padding-left: 18px; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--danger); font-size: .84rem; }
.form-error { background: var(--danger-bg); color: var(--danger); border-radius: 9px; padding: 10px 14px; margin-bottom: 16px; font-size: .9rem; }
.form-error .errorlist { margin: 0; }

/* ---- Code block ---- */
.code-block { position: relative; background: var(--code-bg); color: var(--code-text); border-radius: 10px; padding: 12px 52px 12px 14px; font-family: var(--mono); font-size: .84rem; overflow-x: auto; white-space: pre; border: 1px solid var(--border); }
.code-block .copy-btn { position: absolute; top: 6px; right: 6px; background: rgba(255,255,255,.08); color: var(--code-text); border: 0; border-radius: 6px; width: 30px; height: 30px; cursor: pointer; font-size: 1rem; }
.code-block .copy-btn:hover { background: rgba(255,255,255,.18); }

/* ---- Meter ---- */
.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }
.meter-warn .meter-fill, .meter.meter-warn .meter-fill { background: var(--warn); }
.meter-danger .meter-fill, .meter.meter-danger .meter-fill { background: var(--danger); }

/* ---- Messages ---- */
.messages { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.message { padding: 11px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--info-bg); color: var(--text); display: flex; gap: 10px; align-items: flex-start; }
.message i { margin-top: 2px; color: var(--info); }
.message.success { background: var(--ok-bg); } .message.success i { color: var(--ok); }
.message.warning { background: var(--warn-bg); } .message.warning i { color: var(--warn); }
.message.error { background: var(--danger-bg); } .message.error i { color: var(--danger); }

/* ---- Host cards / key-value ---- */
.host-card h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; } .dot.on { background: var(--ok); }

/* ---- Auth ---- */
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .logo { justify-content: center; margin-bottom: 24px; } .auth-card .logo img { height: 34px; }
.auth-card .card-body { padding: 28px; }
.auth-card h1 { font-size: 1.35rem; text-align: center; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--muted); font-size: .9rem; }
.auth-top { position: absolute; top: 12px; right: 12px; }

/* ---- Responsive ---- */
@media (max-width: 960px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .nav { display: none; position: absolute; top: var(--header-h); left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; padding: 8px 12px 12px; box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .topbar-inner { gap: 8px; } .topbar-right { margin-left: auto; } .user-name { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container { padding: 20px 16px 40px; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
}
@media (min-width: 761px) and (max-width: 960px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
