/* Amberflare console. Dashboard layout (top bar, grouped sidebar, cards), amber accent, light and dark.
   System fonts only, so the Content-Security-Policy can stay 'self'. */
:root {
  --bg: #f4f4f5; --paper: #ffffff; --paper-2: #fafafa; --ink: #1d1d1f; --ink-2: #48484f; --muted: #6e6e76;
  --rule: #e4e4e7; --rule-2: #d4d4d8;
  --brand: #d97706; --brand-ink: #b45309; --brand-soft: #fff7ed; --brand-line: #fdba74;
  --link: #0b63c5; --primary: #0b63c5; --primary-hover: #0a4f9e; --primary-ink: #ffffff;
  --ok: #15803d; --ok-soft: #ecfdf3; --warn: #a16207; --warn-soft: #fefce8; --crit: #c42b1c; --crit-soft: #fef2f2;
  --idle: #8a8a93; --code-bg: #f1f1f3; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113; --paper: #1b1b1e; --paper-2: #202024; --ink: #ececef; --ink-2: #c4c4ca; --muted: #9a9aa3;
    --rule: #2c2c31; --rule-2: #3a3a40;
    --brand: #f59e0b; --brand-ink: #fbbf24; --brand-soft: #2a1f0e; --brand-line: #92400e;
    --link: #6aa9f5; --primary: #3b82f6; --primary-hover: #2f6fd8;
    --ok: #4ade80; --ok-soft: #102a1b; --warn: #facc15; --warn-soft: #2a250c; --crit: #f87171; --crit-soft: #2e1515;
    --idle: #77777f; --code-bg: #26262b; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; margin: 0; }
h3 { font-size: 14px; font-weight: 650; margin: 18px 0 6px; }
p { margin: 0 0 10px; max-width: 110ch; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
pre { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hide-sm { }

/* ---------- Shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--paper); border-bottom: 1px solid var(--rule); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-toggle { display: none; background: none; border: 0; color: var(--ink-2); padding: 6px; border-radius: 6px; cursor: pointer; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 999px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--bg); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.user-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.menu { position: absolute; right: 0; top: 42px; min-width: 220px; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; }
.menu-head { padding: 8px 10px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; overflow-wrap: anywhere; }
.menu button { width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font: inherit; color: var(--ink); cursor: pointer; }
.menu button:hover { background: var(--bg); }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - 56px); width: 100%; }
.sidebar { background: var(--paper); border-right: 1px solid var(--rule); padding: 14px 10px 24px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--ink-2); font-weight: 500; }
.sidebar a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.sidebar a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.sidebar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-section { margin: 16px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.content { padding: 24px clamp(16px, 2.5vw, 40px) 64px; min-width: 0; width: 100%; }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head .titles { flex: 1 1 360px; min-width: 0; }
.page-head p { color: var(--muted); margin: 6px 0 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--brand-ink); text-transform: uppercase; letter-spacing: .06em; }
.lede { color: var(--muted); margin-bottom: 20px; }

/* ---------- Cards / panels ---------- */
.card, .panel { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow); }
.card { padding: 20px 22px; }
.panel { margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.panel-head .actions { margin-left: auto; display: flex; gap: 8px; }
.panel-body { padding: 18px; }
.panel-body > :last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); display: block; color: inherit; }
a.stat:hover { border-color: var(--brand-line); text-decoration: none; }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .sub { font-size: 12.5px; color: var(--ink-2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.panel > .table-wrap { margin: 0; }
.table-wrap:not(.panel > .table-wrap) { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; margin-bottom: 18px; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; vertical-align: middle; padding: 10px 16px; border-bottom: 1px solid var(--rule); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--paper-2); }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--paper-2); white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
td.detail { font-family: var(--mono); font-size: 12px; color: var(--ink-2); max-width: 420px; overflow-wrap: anywhere; }
td.actions-cell { text-align: right; white-space: nowrap; }
.row-title { font-weight: 600; color: var(--ink); }
a.row-title:hover { color: var(--link); }
.row-sub { font-size: 12.5px; color: var(--muted); }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state svg { width: 44px; height: 44px; fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h2 { margin: 10px 0 6px; }
.empty-state p { margin: 0 auto 16px; color: var(--muted); }

/* ---------- Status ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.status.ok::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status.warn::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status.crit::before { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }
.pill, .tag { display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--rule-2); color: var(--ink-2); background: var(--paper); white-space: nowrap; }
.pill.ok, .tag.ok, .tag.token, .tag.mtls { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.pill.warn, .tag.warning, .tag.notice, .tag.public { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.pill.crit, .tag.crit, .tag.critical { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); background: var(--crit-soft); }
.pill.brand, .tag.sso { color: var(--brand-ink); border-color: var(--brand-line); background: var(--brand-soft); }

/* ---------- Callouts / toast ---------- */
.callout { border: 1px solid var(--rule); border-left: 3px solid var(--link); background: var(--paper); padding: 12px 16px; border-radius: 8px; margin: 0 0 16px; }
.callout.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.crit { border-left-color: var(--crit); background: var(--crit-soft); }
.callout.brand { border-left-color: var(--brand); background: var(--brand-soft); }
.callout p:last-child { margin: 0; }
.toast { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ink); padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; }

/* ---------- Forms ---------- */
form.inline { display: inline; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
label, .field > .label { font-size: 13px; font-weight: 600; color: var(--ink); }
label { display: grid; gap: 5px; }
.hint { font-size: 12.5px; font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--paper); border: 1px solid var(--rule-2); border-radius: 7px; padding: 8px 10px; min-width: 0; width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.input-group { display: flex; }
.input-group > :first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 0 0 auto; width: auto; }
.input-group > :last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 20px; }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }
.choice-list { display: grid; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--rule-2); border-radius: 9px; padding: 12px 14px; cursor: pointer; font-weight: 400; background: var(--paper); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: 3px; }
.choice b { display: block; font-weight: 600; }
.choice span { color: var(--muted); font-size: 13px; }

.btn { font: inherit; font-weight: 600; font-size: 13.5px; border-radius: 7px; padding: 8px 14px; border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--rule-2); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--paper); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 45%, transparent); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.link { background: none; border: 0; color: var(--link); padding: 4px 0; font-weight: 500; }
.btn.block { width: 100%; justify-content: center; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.secret { font-family: var(--mono); font-size: 14px; background: var(--code-bg); padding: 6px 10px; border-radius: 6px; user-select: all; overflow-wrap: anywhere; display: inline-block; }
.pager { display: flex; gap: 14px; }

/* ---------- Copy box, tabs, steps ---------- */
.copy { position: relative; }
.copy pre { padding-right: 84px; min-height: 44px; }
.copy button { position: absolute; top: 7px; right: 7px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 14px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--brand); }
[data-tab-panel][hidden] { display: none; }
.steps { list-style: none; padding: 0; margin: 0 0 22px; display: flex; gap: 0; counter-reset: s; flex-wrap: wrap; }
.steps li { counter-increment: s; display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; padding-right: 26px; position: relative; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; border: 1.5px solid var(--rule-2); background: var(--paper); }
.steps li:not(:last-child)::after { content: ""; position: absolute; right: 8px; top: 50%; width: 10px; border-top: 1.5px solid var(--rule-2); }
.steps li.done { color: var(--ok); }
.steps li.done::before { content: "✓"; border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.steps li.current { color: var(--ink); }
.steps li.current::before { border-color: var(--brand); background: var(--brand); color: #fff; }
.howto { counter-reset: h; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.howto > li { counter-increment: h; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; }
.howto > li::before { content: counter(h); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--brand-soft); color: var(--brand-ink); border: 1px solid var(--brand-line); }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.rules-table input, .rules-table select { padding: 6px 8px; }
.rules-table td { padding: 8px 10px; vertical-align: top; }

/* ---------- Sign-in ---------- */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 18px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.auth-foot { color: var(--muted); font-size: 12.5px; }
.card.narrow { max-width: 420px; width: 100%; padding: 28px; }
.card.narrow h1 { font-size: 21px; margin-bottom: 8px; }
.qr { text-align: center; margin: 8px 0 14px; }
.qr img { image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--rule); }
.centred { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: fixed; top: 56px; left: 0; bottom: 0; width: 260px; z-index: 15; height: auto; box-shadow: 4px 0 16px rgba(0,0,0,.12); }
  body.nav-open .sidebar { display: flex; }
  .content { padding: 20px 16px 48px; }
  .user-name { display: none; }
  .hide-sm { display: none; }
}
.grow { flex: 1; }
details > summary { cursor: pointer; color: var(--link); margin-bottom: 10px; }
.ul-tight { margin: 4px 0 0 18px; padding: 0; }

/* Fit the screen: content uses the full width, and long values wrap instead of widening the page. */
html, body { max-width: 100%; }
.panel, .card, .stat, .callout, .toast { min-width: 0; }
td, th { overflow-wrap: anywhere; }
th { overflow-wrap: normal; }
td.nowrap, td.num, td.actions-cell { overflow-wrap: normal; }
.copy pre, .secret, .row-sub, .mono { overflow-wrap: anywhere; word-break: break-word; }
.page-head .titles h1 { overflow-wrap: anywhere; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
@media (min-width: 1700px) { .sidebar { width: 248px; } .shell { grid-template-columns: 248px minmax(0, 1fr); } }
.big-code { font-size: 26px; letter-spacing: .15em; font-weight: 700; text-align: center; padding: 14px 84px 14px 14px; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checklist li { padding-left: 24px; position: relative; }
.checklist li::before { content: "✓"; position: absolute; left: 2px; color: var(--ok); font-weight: 700; }
.feature { border-color: var(--brand-line); }
.feature .panel-head { background: var(--brand-soft); }
