/* SetPoint design (same look as SetPoint Light): top bar, grouped sidebar, cards, striped tables. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #f8fafc; --surface: #ffffff; --surface-2: #f1f5f9; --text: #0f172a; --muted: #64748b; --border: #e2e8f0;
  --primary: #1e2a4a; --primary-text: #ffffff; --nav-active: #e2e8f0; --focus: #3b5bdb;
  --ok: #15803d; --ok-bg: #f0fdf4; --ok-border: #bbf7d0;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-border: #fde68a;
  --bad: #b91c1c; --bad-bg: #fef2f2; --bad-border: #fecaca;
  --neutral: #94a3b8; --brand-yellow: #facc15; --shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827; --surface: #1e293b; --surface-2: #273449; --text: #f1f5f9; --muted: #94a3b8; --border: #334155;
    --primary: #f1f5f9; --primary-text: #0f172a; --nav-active: #273449; --focus: #93b4ff;
    --ok: #4ade80; --ok-bg: rgba(74, 222, 128, .08); --ok-border: rgba(74, 222, 128, .35);
    --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .08); --warn-border: rgba(251, 191, 36, .35);
    --bad: #f87171; --bad-bg: rgba(248, 113, 113, .08); --bad-border: rgba(248, 113, 113, .4);
    --neutral: #64748b; --shadow: none;
  }
  .brand-mark .m-bg { fill: #fff; }
  .brand-mark .m-ic { stroke: #1e2a4a; }
  .brand-mark .m-y { stroke: #1e293b; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 "Inter", system-ui, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- shell ---- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; width: 223px; }
.brand-mark { width: 52px; height: 32px; flex: none; }
.brand-text { line-height: 1.1; }
.brand-text strong { display: block; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.brand-text span { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--primary-text); font-weight: 600; font-size: 14px; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

.layout { display: grid; grid-template-columns: 272px 1fr; min-height: calc(100vh - 64px); }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; }
.side h4 { margin: 12px 12px 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.side h4:first-child { margin-top: 4px; }
.side a { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 15px; margin-bottom: 4px; }
.side a:hover { color: var(--text); background: var(--surface-2); }
.side a.active { background: var(--nav-active); color: var(--text); font-weight: 600; }
.content { padding: 40px 32px 48px; max-width: 1180px; width: 100%; }

/* ---- page head ---- */
.head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 28px; }
.head h1 { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.head p { margin: 6px 0 0; color: var(--muted); font-size: 16px; }
.head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding-top: 6px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 12px; }
.back:hover { color: var(--text); }

/* ---- notice (only for real problems) ---- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; margin-bottom: 20px; border-radius: 12px;
  border: 1px solid var(--bad-border); background: var(--bad-bg); color: var(--text); }
.notice svg { color: var(--bad); margin-top: 2px; }
.notice.warn { border-color: var(--warn-border); background: var(--warn-bg); }
.notice.warn svg { color: var(--warn); }
.notice .x { margin-left: auto; }

/* ---- buttons ---- */
button, .btn { font: inherit; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
button.primary:hover { filter: brightness(1.15); background: var(--primary); }
button.danger { color: var(--bad); }
button.small { height: 32px; padding: 0 10px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }
button.busy { background: var(--surface-2) !important; color: var(--muted) !important; border-color: var(--border) !important; pointer-events: none; filter: none; }
button.busy::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; height: 34px; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-head .right { margin-left: auto; font-weight: 400; }
.card-body { padding: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid2 > .card { margin-bottom: 0; }
.card-gap { height: 20px; }
button.primary.danger-bg { background: var(--bad); border-color: var(--bad); color: #fff; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); }
.tile .label { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; }
.tile .label svg { width: 30px; height: 30px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
.tile .value { font-size: 28px; font-weight: 700; margin-top: 10px; letter-spacing: -.01em; }
.tile .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* key/value rows like SetPoint settings */
.kv { display: grid; grid-template-columns: 180px 1fr; }
.kv > div { padding: 12px 20px; border-top: 1px solid var(--border); }
.kv > div:nth-child(-n+2) { border-top: 0; }
.kv > div:nth-child(odd) { color: var(--muted); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 14px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 14px 20px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
tr.stripe td:first-child { box-shadow: inset 4px 0 0 var(--neutral); }
tr.stripe.ok td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
tr.stripe.warn td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
tr.stripe.bad td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
td.actions { white-space: nowrap; text-align: right; }
td.actions button + button { margin-left: 6px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.empty { padding: 28px 20px; color: var(--muted); text-align: center; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; border: 1px solid; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.pill.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.pill.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-border); }
.pill.neutral { color: var(--muted); border-color: var(--border); }

/* ---- forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 14px; font-weight: 500; }
input, select { font: inherit; font-size: 14px; width: 100%; height: 40px; padding: 0 12px; margin-top: 6px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); }
input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
input[type=file] { padding: 7px 10px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
td input, td select { margin-top: 0; height: 34px; min-width: 90px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 160px; }

.keybox { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 18px 20px; border-radius: 12px; border: 1px dashed var(--primary); margin-bottom: 20px; background: var(--surface); }
.keybox code { font-size: 20px; letter-spacing: .06em; font-weight: 600; }

/* ---- dialog ---- */
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .dlg-body { padding: 22px 22px 8px; }
dialog h3 { margin: 0 0 8px; font-size: 17px; }
dialog p { margin: 0; color: var(--muted); }
dialog .form-foot { margin-top: 18px; }

/* ---- login / enroll ---- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(420px, 100%); }
.login .brand { width: auto; margin-bottom: 24px; justify-content: center; }
.login .card-body p { margin: 0 0 16px; color: var(--muted); }
.login button.primary { width: 100%; justify-content: center; height: 42px; }
.login .msg { min-height: 1.5em; margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.login label { margin-bottom: 16px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: flex; gap: 4px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 12px; }
  .side h4 { display: none; }
  .side a { margin: 0; white-space: nowrap; }
  .brand { width: auto; }
  .content { padding: 24px 16px 40px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2, .form-grid { grid-template-columns: 1fr; }
  .head { flex-direction: column; }
  .head .actions { margin-left: 0; justify-content: flex-start; }
  .kv { grid-template-columns: 130px 1fr; }
  .user span { display: none; }
}
