:root {
  --primary: #1D5EF1;
  --primary-ink: #ffffff;
  --navy: #0F172A;
  --page: #F8FAFC;
  --card: #ffffff;
  --ink: #0F172A;
  --ink-2: #475569;
  --line: #E2E8F0;
  --danger: #DC4C3E;
  --danger-soft: #FDECEA;
  --success: #0E9F8E;
  --success-soft: #E3F6F3;
  --warning: #B7791F;
  --warning-soft: #FEF5E7;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }

label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], select, textarea {
  width: 100%; height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { height: auto; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 94, 241, .15); }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; background: #F1F5F9; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(.95); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.alert { border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 13px; }
.alert-error { background: var(--danger-soft); color: #8B2A20; }
.alert-ok { background: var(--success-soft); color: #0B5E55; }
.alert-warn { background: var(--warning-soft); color: #7A4F12; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Console */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: var(--navy); color: #CBD5E1; padding: 18px 12px; flex-shrink: 0; }
.sidebar .logo { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 10px 18px; }
.sidebar .group { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #64748B; padding: 14px 10px 6px; }
.sidebar a { display: block; color: #CBD5E1; padding: 7px 10px; border-radius: 8px; }
.sidebar a:hover, .sidebar a.active { background: rgba(29, 94, 241, .25); color: #fff; text-decoration: none; }
.main { flex: 1; min-width: 0; padding: 24px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #EEF2F7; color: var(--ink-2); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-ACTIVE, .chip-DELIVERED { background: var(--success-soft); color: var(--success); }
.chip-SUSPENDED, .chip-FAILED, .chip-DISABLED { background: var(--danger-soft); color: var(--danger); }
.chip-PENDING, .chip-INVITED, .chip-PREVIOUS, .chip-PROVISIONING { background: var(--warning-soft); color: var(--warning); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 16px; }
.inline { display: inline; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
@media (max-width: 840px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 12px; }
  .sidebar .logo { width: 100%; padding-bottom: 6px; }
  .sidebar .group { display: none; }
  .main { padding: 16px; }
}

/* Public pages (sign-in, reset, invite): Kili's auth layout, no card, large title, tall controls */
.auth { position: relative; min-height: 100svh; display: flex; flex-direction: column; align-items: center; padding: 40px 20px; background: var(--page); }
.auth > div { width: 100%; max-width: 360px; margin: auto 0; }
.auth-card { background: transparent; border: 0; padding: 0; }
.auth .brand { display: block; margin-bottom: 20px; }
.auth .brand img { height: 36px; max-width: 180px; object-fit: contain; }
.auth .wordmark { color: var(--primary); font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.auth h1 { font-size: 40px; line-height: 1.1; letter-spacing: -.02em; font-weight: 600; margin: 0 0 10px; }
.auth h1 + .muted, .auth .lede { font-size: 13px; line-height: 1.55; margin: 0 0 36px; max-width: 34ch; }
.auth label { text-transform: none; letter-spacing: .01em; font-size: 12px; color: var(--ink); margin: 16px 0 8px; }
.auth input[type=text], .auth input[type=email], .auth input[type=password] { height: 48px; padding: 0 14px; font-size: 14px; border-radius: 8px; background: var(--card); }
.auth input::placeholder { color: #94A3B8; }
.auth .pw { position: relative; }
.auth .pw input { padding-right: 46px; }
.auth .pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; color: var(--ink-2); cursor: pointer; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.auth .pw-toggle:hover { color: var(--ink); }
.auth .btn { height: 48px; border-radius: 999px; font-weight: 500; font-size: 14px; }
.auth .btn-block { margin-top: 28px; }
.auth form:has(:invalid) .btn-primary { opacity: .4; cursor: not-allowed; }
.auth .links { margin-top: 32px; text-align: center; font-size: 12px; color: var(--ink-2); }
.auth .links a { color: var(--ink-2); display: block; margin-top: 6px; }
.auth .links a:hover { color: var(--ink); }
.auth .alert { margin: 0 0 16px; }
.footer-note { text-align: center; margin-top: 40px; color: #94A3B8; font-size: 11px; }
.theme-toggle { position: absolute; top: 20px; right: 20px; width: 36px; height: 36px; border-radius: 999px; border: 0; background: none; color: var(--ink-2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.theme-toggle:hover { background: rgba(148, 163, 184, .15); color: var(--ink); }
.theme-toggle .sun, :root[data-theme=dark] .theme-toggle .moon { display: none; }
:root[data-theme=dark] .theme-toggle .sun { display: block; }

/* Dark theme (public pages and console share the tokens) */
:root[data-theme=dark] { --page: #0B1120; --card: #111827; --ink: #E2E8F0; --ink-2: #94A3B8; --line: #1F2937; --danger-soft: #3B1A17; --success-soft: #0F2E2A; --warning-soft: #33260F; }
:root[data-theme=dark] .alert-error { color: #F4B4AC; }
:root[data-theme=dark] .alert-ok { color: #9DE3D9; }
:root[data-theme=dark] .alert-warn { color: #F2CF95; }
:root[data-theme=dark] .btn:not(.btn-primary) { background: var(--card); color: var(--ink); }
