/* FPSS Admin - single stylesheet, no build step. Light/dark follow the OS setting. */
:root {
  color-scheme: light dark;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5d6b7b;
  --line: #e2e7ee;
  --brand: #0a5db8;
  --brand-strong: #084a94;
  --on-brand: #ffffff;
  --ok: #17794a;
  --ok-bg: #e4f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff1cf;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --info-bg: #e6f0fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1319;
    --panel: #161d26;
    --text: #e7ecf2;
    --muted: #93a1b1;
    --line: #263140;
    --brand: #4da3ff;
    --brand-strong: #7bbaff;
    --on-brand: #06121f;
    --ok: #5fd394;
    --ok-bg: #12301f;
    --warn: #f0c15a;
    --warn-bg: #352a0e;
    --bad: #ff8f87;
    --bad-bg: #3a1714;
    --info-bg: #12263d;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
p { margin: 0 0 12px; }
code, .mono { font-family: ui-monospace, Consolas, "SF Mono", monospace; font-size: 0.93em; }
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt-1 { margin-top: 12px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }

/* ---- shell ---------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--brand), var(--brand-strong)); display: inline-block; }
.who { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }

.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.sidebar { padding: 14px 10px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.sidebar a { padding: 8px 12px; border-radius: 8px; color: var(--text); }
.sidebar a:hover { background: var(--info-bg); text-decoration: none; }
.sidebar a.active { background: var(--info-bg); color: var(--brand); font-weight: 600; }
.content { padding: 24px; max-width: 1200px; width: 100%; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .sidebar a { white-space: nowrap; }
  .content { padding: 16px; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .who-email, .env-badge { display: none; }
  .page-head { margin-bottom: 14px; }
  h1 { font-size: 20px; }
}

/* ---- page chrome ---------------------------------------------------------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.narrow { max-width: 520px; }
.card.danger { border-color: var(--bad); }
.card.danger h2 { color: var(--bad); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .num { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat .note { color: var(--muted); font-size: 12px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.flash.info { background: var(--info-bg); color: var(--brand); border-color: var(--brand); }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); margin-bottom: 16px; }

/* ---- tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--brand) 6%, transparent); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 14px; }

/* ---- badges --------------------------------------------------------------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.brand { background: var(--info-bg); color: var(--brand); }

/* ---- forms and buttons ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); border-color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 3px 10px; font-size: 13px; }
.btn.disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

input, select, textarea {
  font: inherit; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; max-width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
textarea { width: 100%; min-height: 80px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select { width: 100%; }
.field .hint { font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 160px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

.q-edit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.q-edit input[name="question"] { flex: 1 1 260px; min-width: 200px; }
.btn-icon { padding: 3px 9px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-error { margin-bottom: 14px; }
.card.wide { max-width: 760px; }

/* ---- key/value + inspection detail --------------------------------------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.qa-note { color: var(--muted); font-size: 13px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: 0.12em; font-weight: 700; }

/* ---- sign-in -------------------------------------------------------------- */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.bare-main { width: 100%; max-width: 400px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; }
.login-card h1 { margin: 14px 0 8px; }
.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.login-card .btn { width: 100%; }
