/* ============ authkit console — design system (tech-feel) ============
   No external fonts (privacy-first, zero fallback risk). Monospace is a
   first-class identity element: keys, ids, prices, metrics. */
:root {
  /* light (default) — cool neutrals with a faint blue-violet bias */
  --ground: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #fafaff;
  --ink: #14161f;
  --ink-soft: #575d73;
  --ink-faint: #8b90a6;
  --line: #e7e8f2;
  --line-soft: #f0f1f7;

  /* dark sidebar rail — same in both themes, the console's signature */
  --nav: #13141d;
  --nav-elev: #1c1e2b;
  --nav-ink: #ccd0e6;
  --nav-ink-soft: #7f849e;
  --nav-line: rgba(255,255,255,.09);
  --nav-active: rgba(123,120,255,.18);

  /* accent — electric iris, spent only on primary actions + active state */
  --brand: #5b57f2;
  --brand-strong: #4b46e6;
  --brand-tint: rgba(91,87,242,.11);
  --brand-on: #ffffff;

  /* semantic state (separate from accent) */
  --ok: #128a63;      --ok-tint: rgba(18,138,99,.13);
  --warn: #b9791a;    --warn-tint: rgba(200,140,40,.15);
  --danger: #cf424b;  --danger-tint: rgba(207,66,75,.12);

  --radius: 12px; --radius-sm: 9px; --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(20,22,31,.05), 0 14px 34px -20px rgba(20,22,31,.30);
  --shadow-sm: 0 1px 2px rgba(20,22,31,.06);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --ground: #0b0c13;
    --surface: #14151f;
    --surface-2: #191b26;
    --ink: #e9eaf2;
    --ink-soft: #a3a8bf;
    --ink-faint: #6f7490;
    --line: #262835;
    --line-soft: #1d1f2a;
    --nav: #0a0b11;
    --nav-elev: #15161f;
    --nav-ink: #d6d9ea;
    --nav-ink-soft: #838aa6;
    --brand: #817eff;
    --brand-strong: #6f6cf5;
    --brand-tint: rgba(129,126,255,.16);
    --ok: #34c48d;     --ok-tint: rgba(52,196,141,.15);
    --warn: #e0a13e;   --warn-tint: rgba(224,161,62,.16);
    --danger: #f16d73; --danger-tint: rgba(241,109,115,.15);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 18px 44px -22px rgba(0,0,0,.72);
  }
}
:root[data-theme="dark"] {
  --ground: #0b0c13;
  --surface: #14151f;
  --surface-2: #191b26;
  --ink: #e9eaf2;
  --ink-soft: #a3a8bf;
  --ink-faint: #6f7490;
  --line: #262835;
  --line-soft: #1d1f2a;
  --nav: #0a0b11;
  --nav-elev: #15161f;
  --nav-ink: #d6d9ea;
  --nav-ink-soft: #838aa6;
  --brand: #817eff;
  --brand-strong: #6f6cf5;
  --brand-tint: rgba(129,126,255,.16);
  --ok: #34c48d;     --ok-tint: rgba(52,196,141,.15);
  --warn: #e0a13e;   --warn-tint: rgba(224,161,62,.16);
  --danger: #f16d73; --danger-tint: rgba(241,109,115,.15);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 18px 44px -22px rgba(0,0,0,.72);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3 { margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

/* ---------- sidebar ---------- */
.side {
  background: var(--nav);
  color: var(--nav-ink);
  border-right: 1px solid var(--nav-line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.15rem 1.25rem; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), #8f7bff);
  box-shadow: 0 6px 18px -8px var(--brand);
  color: #fff; font-weight: 800; font-family: var(--mono); font-size: .95rem;
}
.brand .name { font-weight: 700; letter-spacing: -.01em; font-size: 1.05rem; color: #fff; }
.brand .env { margin-left: auto; font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--nav-ink-soft); border: 1px solid var(--nav-line);
  padding: .18rem .4rem; border-radius: 6px; }
.nav { padding: .5rem .7rem; display: flex; flex-direction: column; gap: .12rem; overflow-y: auto; }
.nav .group { font-family: var(--mono); font-size: .62rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--nav-ink-soft); padding: .9rem .55rem .35rem; }
.nav a {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .55rem; border-radius: 8px;
  color: var(--nav-ink); font-size: .92rem; font-weight: 500; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.nav a:hover { background: var(--nav-elev); }
.nav a.active { background: var(--nav-active); color: #fff; }
.nav a .ico { width: 17px; height: 17px; opacity: .85; flex: none; }
.nav a.active .ico { opacity: 1; }
.nav a .tag { margin-left: auto; font-family: var(--mono); font-size: .66rem; color: var(--nav-ink-soft); }
.side-foot { margin-top: auto; border-top: 1px solid var(--nav-line); padding: .85rem 1rem; display: flex; align-items: center; gap: .6rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand); font-weight: 700; font-size: .82rem; }
.side-foot .who { min-width: 0; }
.side-foot .who b { display: block; font-size: .84rem; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { font-size: .72rem; color: var(--nav-ink-soft); }

/* ---------- topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 2rem; background: color-mix(in srgb, var(--ground) 82%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumb { font-family: var(--mono); font-size: .74rem; color: var(--ink-faint); letter-spacing: .02em; }
.crumb b { color: var(--ink-soft); font-weight: 600; }
.top h1 { font-size: 1.05rem; font-weight: 650; }
.top .spacer { flex: 1; }
.content { padding: 1.9rem 2rem 3rem; max-width: 1080px; width: 100%; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: .45rem; font: inherit; font-weight: 600; font-size: .88rem;
  padding: .52rem .9rem; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  transition: background .13s ease, border-color .13s ease, transform .05s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 20px -12px var(--brand); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-faint); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-sm { padding: .34rem .6rem; font-size: .8rem; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--ink-faint); }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.05rem 1.1rem; box-shadow: var(--shadow-sm); }
.stat .l { font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.stat .n { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; margin-top: .3rem; font-variant-numeric: tabular-nums; }
.stat .d { font-size: .78rem; color: var(--ink-soft); margin-top: .15rem; display: flex; align-items: center; gap: .3rem; }
.stat .d .up { color: var(--ok); font-weight: 600; }
.spark { display: block; margin-top: .5rem; width: 100%; height: 30px; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 1.4rem; overflow: hidden; }
.panel-h { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line-soft); }
.panel-h h2 { font-size: 1rem; font-weight: 650; }
.panel-h .sub { font-size: .8rem; color: var(--ink-soft); }
.panel-h .spacer { flex: 1; }
.panel-b { padding: 1.2rem; }
.panel-b.flush { padding: 0; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th { text-align: left; font-family: var(--mono); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; padding: .7rem 1.2rem; border-bottom: 1px solid var(--line-soft); }
tbody td { padding: .78rem 1.2rem; border-bottom: 1px solid var(--line-soft); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; }
.u-email { font-weight: 550; }
.u-sub { font-family: var(--mono); font-size: .74rem; color: var(--ink-faint); }

/* ---------- pills / chips ---------- */
.pill { display: inline-flex; align-items: center; gap: .32rem; font-size: .74rem; font-weight: 600;
  padding: .2rem .55rem; border-radius: 999px; letter-spacing: .01em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.ok { color: var(--ok); background: var(--ok-tint); }
.pill.warn { color: var(--warn); background: var(--warn-tint); }
.pill.danger { color: var(--danger); background: var(--danger-tint); }
.pill.muted { color: var(--ink-soft); background: var(--line-soft); }
.chip { display: inline-flex; align-items: center; gap: .3rem; font-family: var(--mono); font-size: .76rem; font-weight: 600;
  padding: .18rem .5rem; border-radius: 7px; border: 1px solid var(--line); color: var(--ink-soft); background: var(--surface-2); }
.chip.brand { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); background: var(--brand-tint); }
.chip.default { color: var(--ink); }
.chip .star { color: var(--brand); }

/* ---------- app cards (dashboard) ---------- */
.apps-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.appcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: .7rem; transition: border-color .13s ease, box-shadow .13s ease, transform .08s ease; cursor: pointer; }
.appcard:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: var(--shadow); transform: translateY(-1px); }
.appcard .top-row { display: flex; align-items: center; gap: .7rem; }
.appcard .glyph { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand); font-family: var(--mono); font-weight: 800; }
.appcard h3 { font-size: 1.02rem; font-weight: 650; }
.appcard .id { font-family: var(--mono); font-size: .72rem; color: var(--ink-faint); }
.appcard .meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.appcard .foot { display: flex; align-items: center; gap: .8rem; color: var(--ink-soft); font-size: .8rem; border-top: 1px solid var(--line-soft); padding-top: .7rem; }
.appcard-new { border-style: dashed; align-items: center; justify-content: center; text-align: center; color: var(--ink-soft); gap: .4rem; min-height: 150px; }
.appcard-new .plus { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand); font-size: 1.3rem; }

/* ---------- key box (shown once) ---------- */
.keywarn { display: flex; gap: .6rem; align-items: flex-start; background: var(--warn-tint); border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  border-radius: var(--radius-sm); padding: .7rem .85rem; font-size: .82rem; color: color-mix(in srgb, var(--warn) 78%, var(--ink)); margin-bottom: 1rem; }
.keyrow { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.keyrow .kl { font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); width: 92px; flex: none; }
.keyfield { flex: 1; display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.keyfield code { flex: 1; padding: .5rem .7rem; font-family: var(--mono); font-size: .82rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy { border: 0; border-left: 1px solid var(--line); background: transparent; padding: .5rem .7rem; cursor: pointer; color: var(--ink-soft); font: inherit; font-size: .78rem; font-weight: 600; }
.copy:hover { color: var(--brand); background: var(--brand-tint); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea { font: inherit; padding: .58rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field textarea { resize: vertical; }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }

/* ---------- danger zone ---------- */
.danger-zone { border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); border-radius: var(--radius); padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1rem; }
.danger-zone .t b { display: block; font-weight: 650; }
.danger-zone .t span { font-size: .84rem; color: var(--ink-soft); }
.danger-zone .spacer { flex: 1; }

/* ---------- search ---------- */
.search { display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .65rem; width: 260px; }
.search input { border: 0; background: transparent; font: inherit; color: var(--ink); flex: 1; outline: none; }
.search .ico { color: var(--ink-faint); }

.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.plan-banner { display: flex; align-items: center; gap: .9rem; background: linear-gradient(120deg, var(--brand-tint), transparent 70%); border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: 1.5rem; }
.plan-banner .cap { font-family: var(--mono); font-size: .8rem; color: var(--ink-soft); }
.plan-banner .cap b { color: var(--ink); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .side .nav, .side .side-foot { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .apps-grid { grid-template-columns: 1fr; }
  .content { padding: 1.4rem; }
  .top { padding: .8rem 1.4rem; }
}
@media (prefers-reduced-motion: reduce) { .view.active { animation: none; } .appcard:hover { transform: none; } }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* auth pages */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.auth-card .logo { display: flex; align-items: center; gap: .55rem; margin-bottom: 1.3rem; }
.auth-card .logo .mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(140deg, var(--brand), #8f7bff); color: #fff; font-weight: 800; font-family: var(--mono); }
.auth-card h1 { font-size: 1.35rem; margin-bottom: .3rem; }
.auth-card .lede { color: var(--ink-soft); font-size: .92rem; margin-bottom: 1.4rem; }
.auth-foot { margin-top: 1.2rem; text-align: center; font-size: .88rem; color: var(--ink-soft); }
.auth-foot a { color: var(--brand); font-weight: 600; }
.alert { border-radius: var(--radius-sm); padding: .7rem .85rem; font-size: .88rem; margin-bottom: 1rem; }
.alert-error { background: var(--danger-tint); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-ok { background: var(--ok-tint); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.btn-block { width: 100%; justify-content: center; }
