/* Adjuro dashboard styles. Reuses the design tokens defined in web/glass.css
   (--bg, --ink, --accent, --line, --card, --serif, --mono, --ease, …) — the
   palette is NEVER redefined here. Only dashboard-specific layout/components. */

:root {
  --app-maxw: 1440px; --app-auth-maxw: 520px; --app-side-w: 232px;
  /* Dashboard-scoped gutter — tighter than the shared --gutter so content
     reaches closer to the screen edges. Applied to header, wrap, and footer
     together so they stay aligned. */
  --app-gutter: clamp(18px, 2.6vw, 40px);
}

body { min-height: 100vh; display: flex; flex-direction: column; }

/* Auth pages (signin/verify) stay narrow + centered inside the wide wrap. */
.app-auth { max-width: var(--app-auth-maxw); margin: 0 auto; }

/* ---- Header ---------------------------------------------------------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px var(--app-gutter);
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  position: sticky; top: 0; z-index: 20;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -0.02em; }
.app-header .mark { width: 26px; height: 26px; color: var(--accent); display: grid; place-items: center; }
.app-header .mark svg { width: 100%; height: 100%; }
.app-header .name { font-size: 17px; }
.app-tag { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; }
.app-header-actions { display: flex; align-items: center; gap: 10px; }

/* ---- Layout ---------------------------------------------------------- */
.app-wrap { width: 100%; max-width: var(--app-maxw); margin: 0 auto; padding: clamp(28px, 5vw, 56px) var(--app-gutter) 80px; flex: 1; }
.app-footer { border-top: 1px solid var(--line); padding: 22px var(--app-gutter); display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.app-footer a { color: var(--ink-2); text-decoration: none; }
.app-footer a:hover { color: var(--accent); }

/* ---- Headings -------------------------------------------------------- */
.app-eyebrow { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.app-eyebrow .num { color: var(--ink-3); margin-right: 8px; }
.app-h1 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.02em; line-height: 1.05; font-size: clamp(30px, 5vw, 46px); color: var(--ink); margin: 10px 0 0; text-wrap: balance; }
.app-dek { font-family: var(--serif); font-style: italic; font-size: clamp(15px, 1.4vw, 18px); line-height: 1.6; color: var(--ink-2); margin-top: 14px; max-width: 52ch; text-wrap: pretty; }
.app-section { margin-top: clamp(34px, 5vw, 52px); }
.app-section > h2 { font-family: var(--serif); font-weight: 500; font-size: 22px; letter-spacing: -0.01em; color: var(--ink); margin: 8px 0 14px; }

/* ---- Cards ----------------------------------------------------------- */
.app-card { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-card); padding: clamp(22px, 3vw, 32px); }
.app-card + .app-card { margin-top: 16px; }
.app-card-row { display: flex; align-items: baseline; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line-2); }
.app-card-row:first-child { border-top: 0; }
.app-card-row .k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); flex: 0 0 130px; }
.app-card-row .v { font-family: var(--mono); font-size: 13.5px; color: var(--ink); word-break: break-all; flex: 1; display: flex; align-items: center; gap: 8px; }

/* ---- Forms ----------------------------------------------------------- */
.app-field { margin-top: 16px; }
.app-label { display: block; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 7px; }
.app-input { width: 100%; font-family: var(--font); font-size: 15px; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; transition: border-color 0.2s, box-shadow 0.2s; }
.app-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.app-input.mono { font-family: var(--mono); font-size: 13px; }
.app-error { color: var(--danger); font-size: 13.5px; margin-top: 12px; min-height: 1em; }
.app-note { color: var(--ink-2); font-size: 14px; margin-top: 14px; line-height: 1.6; }
.app-note code, .app-inline-code { font-family: var(--mono); font-size: 12.5px; color: var(--accent); }

/* ---- Buttons --------------------------------------------------------- */
.app-button { font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 11px 18px; border-radius: 11px; border: 1px solid var(--line); background: none; color: var(--ink); transition: background 0.2s, border-color 0.2s, transform 0.15s, opacity 0.2s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.app-button:hover { background: var(--line-2); }
.app-button:active { transform: translateY(1px); }
.app-button:disabled { opacity: 0.5; cursor: not-allowed; }
.app-button-primary { background: var(--accent); border-color: var(--accent); color: oklch(0.99 0.01 190); }
.app-button-primary:hover { background: var(--accent); filter: brightness(1.08); }
.app-button.ghost { border-color: transparent; color: var(--ink-2); }
.app-button.ghost:hover { color: var(--ink); background: var(--line-2); }
.app-button.danger { border-color: color-mix(in oklch, var(--danger) 40%, var(--line)); color: var(--danger); }
.app-button.danger:hover { background: color-mix(in oklch, var(--danger) 12%, transparent); }
.app-button.small { padding: 6px 11px; font-size: 12.5px; }
.app-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* ---- Copy button + tooltip ------------------------------------------ */
.copy-btn { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; border: 1px solid var(--line); background: none; color: var(--ink-3); border-radius: 7px; padding: 3px 8px; transition: color 0.2s, border-color 0.2s; flex: none; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

/* ---- Tables ---------------------------------------------------------- */
.app-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; }
.app-table th { text-align: left; font-weight: 500; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); padding: 0 14px 11px 0; border-bottom: 1px solid var(--line); }
.app-table td { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line-2); color: var(--ink); vertical-align: top; word-break: break-all; }
.app-table tr:last-child td { border-bottom: 0; }
.app-table .trunc { cursor: copy; }
.status-valid { color: var(--ok); }
.status-pending { color: var(--amber); }
.status-revoked { color: var(--danger); }
.app-empty { font-family: var(--serif); font-style: italic; color: var(--ink-2); padding: 18px 0; }

/* ---- Code block ------------------------------------------------------ */
.app-code { position: relative; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px; padding: 18px 16px; overflow-x: auto; white-space: pre; }
.app-code .copy-btn { position: absolute; top: 12px; right: 12px; }

/* ---- Key reveal modal ------------------------------------------------ */
.app-backdrop { position: fixed; inset: 0; z-index: 50; background: oklch(0 0 0 / 0.55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; }
.app-key-reveal { width: 100%; max-width: 520px; background: var(--glass-strong); border: 1px solid var(--line); border-radius: var(--radius-card); padding: clamp(22px, 4vw, 32px); box-shadow: 0 30px 80px -30px oklch(0 0 0 / 0.7); }
.app-key-reveal h3 { font-family: var(--serif); font-weight: 500; font-size: 22px; color: var(--ink); margin: 0 0 6px; }
.app-key-reveal p { color: var(--ink-2); font-size: 14px; line-height: 1.55; margin: 10px 0; }
.app-key-box { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 13px; color: var(--accent); background: var(--bg-2); border: 1px solid var(--accent-soft); border-radius: 11px; padding: 13px 14px; margin: 16px 0; word-break: break-all; }
.app-key-box span { flex: 1; }
.app-warn { color: var(--amber); font-size: 13px; font-family: var(--mono); }

/* Shared keyboard focus ring — buttons/links/chips rely on the UA outline
   otherwise, which is inconsistent with the input focus ring and easy to lose
   against the cream/dark surfaces. */
.app-button:focus-visible, .chip:focus-visible, .app-nav-item:focus-visible,
.app-nav-signout:focus-visible, .seg button:focus-visible, .out-tab:focus-visible,
.copy-btn:focus-visible, .scope-chip:focus-visible, .qa-card:focus-visible,
.bfield-inline-btn:focus-visible, .agent-pick:focus-visible, .preset-tag:focus-visible,
.out-actions .toggle:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px;
}

/* ====================================================================== */
/* Sidebar shell — Stripe-style fixed left rail (full viewport height),     */
/* with the page content offset into the remaining space. The offsets only   */
/* apply on desktop + when a dashboard view is mounted (body.has-sidebar);    */
/* auth pages and mobile fall back to the stacked layout below.               */
/* ====================================================================== */
.app-shell { display: block; }
.app-side {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--app-side-w); z-index: 40;
  display: flex; flex-direction: column; gap: 16px;
  padding: 16px 14px 16px; overflow-y: auto;
  background: var(--bg-2); border-right: 1px solid var(--line);
}
/* Brand lives at the top of the rail (the static header's brand is hidden
   while the sidebar is mounted — see body.has-sidebar rules). */
.side-brand { display: flex; align-items: center; gap: 9px; padding: 6px 8px 16px; margin-bottom: 2px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -0.02em; }
.side-brand .mark { width: 24px; height: 24px; color: var(--accent); flex: none; display: grid; place-items: center; }
.side-brand .mark svg { width: 100%; height: 100%; }
.side-brand .name { font-size: 16px; }
.side-brand .app-tag { font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; }
.app-nav { display: flex; flex-direction: column; gap: 2px; }
.app-nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; color: var(--ink-2); font-size: 14.5px; font-weight: 500; border: 1px solid transparent; transition: background 0.18s, color 0.18s, border-color 0.18s; }
.app-nav-item:hover { background: var(--line-2); color: var(--ink); }
.app-nav-item.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklch, var(--accent) 28%, transparent); }
.app-nav-item .ni-ico { width: 18px; height: 18px; flex: none; display: grid; place-items: center; }
.app-nav-item .ni-ico svg { width: 18px; height: 18px; }
.app-side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.asf-tenant { padding: 0 2px; }
.asf-name { font-size: 13.5px; font-weight: 600; color: var(--ink); word-break: break-word; }
.asf-id { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.app-nav-signout { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; border: 1px solid var(--line); background: none; color: var(--ink-2); font-family: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: background 0.18s, color 0.18s, border-color 0.18s; }
.app-nav-signout:hover { color: var(--danger); border-color: color-mix(in oklch, var(--danger) 40%, var(--line)); }
.app-nav-signout .ni-ico svg { width: 17px; height: 17px; }
.app-main { min-width: 0; }
.app-main > .app-section:first-child { margin-top: 0; }

/* The sidebar carries the brand while it's mounted, so suppress the duplicate
   in the static top header. */
body.has-sidebar .app-header .brand { display: none; }
body.has-sidebar .app-header { justify-content: flex-end; }

/* Desktop: offset the full-width chrome (header / content / footer) into the
   space to the right of the fixed rail. Content is left-aligned and capped for
   readable line lengths (Stripe-style), filling laptops, breathing on ultrawide. */
@media (min-width: 861px) {
  body.has-sidebar .app-header { margin-left: var(--app-side-w); }
  body.has-sidebar .app-footer { margin-left: var(--app-side-w); }
  body.has-sidebar .app-wrap {
    max-width: none; margin: 0 0 0 var(--app-side-w);
    padding: clamp(28px, 4vw, 48px) clamp(24px, 4vw, 56px) 80px;
  }
  body.has-sidebar .app-wrap > .app-shell { max-width: 1320px; }
}

/* page lead used at the top of each view */
.app-lead { margin-bottom: 4px; }
.app-lead .app-h1 { font-size: clamp(28px, 4vw, 40px); }

/* ====================================================================== */
/* Metric cards (overview)                                                */
/* ====================================================================== */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line-2); border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; }
.metric { background: var(--card); padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 8px; min-height: 112px; }
.metric .ml { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.metric .mv { font-family: var(--mono); font-size: clamp(26px, 3vw, 34px); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin-top: auto; line-height: 1; }
.metric .mv.accent { color: var(--accent); }
.metric .mv.ok { color: var(--ok); }
.metric .mv.amber { color: var(--amber); }
.metric .mv.danger { color: var(--danger); }
.metric .ms { font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); }

/* signing-key + status row */
.app-tiles { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 16px; }
.app-tile { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-card); padding: 20px 22px; }
.app-tile .tt { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.app-tile .tbig { font-family: var(--serif); font-size: 30px; font-weight: 500; letter-spacing: -0.02em; color: var(--ink); margin-top: 8px; display: flex; align-items: baseline; gap: 8px; }
.app-tile .tbig small { font-family: var(--mono); font-size: 12px; color: var(--ink-3); font-weight: 400; }
.app-tile .tsub { font-size: 13px; color: var(--ink-2); margin-top: 8px; line-height: 1.5; }
.app-tile .kidline { font-family: var(--mono); font-size: 12px; color: var(--accent); margin-top: 10px; word-break: break-all; display: flex; align-items: center; gap: 8px; }
.app-statuspill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.app-statuspill.ok { color: var(--ok); border-color: color-mix(in oklch, var(--ok) 35%, transparent); }
.app-statuspill.amber { color: var(--amber); border-color: color-mix(in oklch, var(--amber) 35%, transparent); }

/* quick action cards */
.qa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.qa-card { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-family: inherit; transition: transform 0.25s var(--ease), border-color 0.25s, background 0.25s; }
.qa-card:hover { transform: translateY(-3px); border-color: var(--ink-3); }
.qa-card .qt { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.qa-card .qd { font-size: 13px; color: var(--ink-2); }
.qa-card .qarrow { color: var(--accent); font-size: 13px; font-family: var(--mono); margin-top: 2px; }

/* ====================================================================== */
/* Toolbar: filter chips + search (receipts)                              */
/* ====================================================================== */
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--ink-2); cursor: pointer; transition: background 0.18s, color 0.18s, border-color 0.18s; }
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklch, var(--accent) 32%, transparent); }
.app-search { flex: 1; min-width: 180px; }
.app-search input { width: 100%; font-family: var(--mono); font-size: 12.5px; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; }
.app-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.app-table tbody tr.clickable { cursor: pointer; }
.app-table tbody tr.clickable:hover td { background: var(--line-2); }
.status-expired { color: var(--ink-3); }
.app-count { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* ====================================================================== */
/* Receipt builder                                                        */
/* ====================================================================== */
/* Form is capped at a comfortable input width; the code output takes the rest
   (snippets read better wide, short form fields don't need the room). */
.builder-grid { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); align-items: start; }
.builder-form, .builder-out { min-width: 0; }

/* segmented type switch */
.seg { display: inline-flex; padding: 3px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); gap: 3px; }
.seg button { font-family: inherit; font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); cursor: pointer; transition: background 0.18s, color 0.18s; }
.seg button.active { background: var(--accent); color: oklch(0.99 0.01 190); }

.seg-desc { font-size: 13.5px; color: var(--ink-2); margin: 12px 0 4px; line-height: 1.6; }

.bfield { margin-top: 14px; }
.bfield label { display: block; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; }
.bfield label .opt { color: var(--ink-3); text-transform: none; letter-spacing: 0; }
.bfield input { width: 100%; font-family: var(--mono); font-size: 13px; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; transition: border-color 0.18s, box-shadow 0.18s; }
.bfield input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bfield.invalid input { border-color: color-mix(in oklch, var(--danger) 55%, var(--line)); }
.bfield .bhelp { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; line-height: 1.45; }
.bfield .berr { font-size: 11.5px; color: var(--danger); margin-top: 5px; min-height: 1em; }
.bfield .with-btn { display: flex; gap: 8px; align-items: stretch; }
.bfield .with-btn input { flex: 1; }
.bfield-inline-btn { font-family: var(--mono); font-size: 11px; white-space: nowrap; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: none; color: var(--ink-2); cursor: pointer; transition: color 0.18s, border-color 0.18s; }
.bfield-inline-btn:hover { color: var(--accent); border-color: var(--accent); }

/* scope chips (selectable) */
.scope-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.scope-chip { font-family: var(--mono); font-size: 11.5px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--ink-2); cursor: pointer; transition: background 0.18s, color 0.18s, border-color 0.18s; }
.scope-chip.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklch, var(--accent) 32%, transparent); }
.scope-free { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.scope-tag { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11.5px; padding: 5px 6px 5px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.scope-tag button { background: none; border: 0; color: inherit; cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }

/* saved-agent picker */
.agent-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.agent-pick { font-family: var(--mono); font-size: 11px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: none; color: var(--ink-2); cursor: pointer; }
.agent-pick:hover { color: var(--accent); border-color: var(--accent); }

/* output panel */
.out-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.out-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.out-tab { font-family: var(--mono); font-size: 11.5px; padding: 6px 12px; border-radius: 9px; border: 1px solid transparent; background: none; color: var(--ink-2); cursor: pointer; transition: background 0.18s, color 0.18s; }
.out-tab:hover { color: var(--ink); background: var(--line-2); }
.out-tab.active { background: var(--bg-2); color: var(--accent); border-color: var(--line); }
.out-actions { margin-left: auto; display: flex; gap: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.out-code { position: relative; font-family: var(--mono); font-size: 12px; line-height: 1.65; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px; padding: 16px; overflow-x: auto; white-space: pre; max-height: 60vh; }
.out-invalid { border: 1px dashed color-mix(in oklch, var(--amber) 50%, var(--line)); border-radius: 12px; padding: 14px 16px; color: var(--amber); font-size: 13px; background: color-mix(in oklch, var(--amber) 7%, transparent); }
.out-note { font-size: 12px; color: var(--ink-2); margin-top: 10px; line-height: 1.6; }
.builder-presets { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.preset-tag { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11.5px; padding: 5px 7px 5px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); cursor: pointer; }
.preset-tag:hover { color: var(--ink); border-color: var(--ink-3); }
.preset-tag .del { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }
.preset-tag .del:hover { color: var(--danger); }

/* ====================================================================== */
/* Settings                                                               */
/* ====================================================================== */
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(22px, 3vw, 36px); align-items: start; }
.set-grid > .app-section { margin-top: 0; }
.app-select { width: 100%; font-family: var(--mono); font-size: 13px; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238A8770'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 30px; }
.app-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.saved-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.saved-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.saved-row .grow { flex: 1; word-break: break-all; }
.saved-row button { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 12px; }
.saved-row button:hover { color: var(--danger); }
.app-section .sec-note { font-size: 13px; color: var(--ink-2); margin: 4px 0 14px; line-height: 1.6; max-width: 62ch; }

/* drawer (receipt detail) reuses .app-key-reveal as modal body */
.app-key-reveal.wide { max-width: 640px; }
.drawer-kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 14px 0; font-family: var(--mono); font-size: 12.5px; }
.drawer-kv .dk { color: var(--ink-3); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.08em; }
.drawer-kv .dv { color: var(--ink); word-break: break-all; }

/* ====================================================================== */
/* Responsive                                                             */
/* ====================================================================== */
@media (max-width: 960px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .app-tiles { grid-template-columns: 1fr; }
  .qa-grid { grid-template-columns: 1fr; }
  .builder-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .set-grid { grid-template-columns: 1fr; }
  /* Unpin the rail: back to a stacked, full-width horizontal nav. */
  .app-side { position: static; width: auto; z-index: auto; gap: 14px; padding: 0; margin-bottom: 4px; background: none; border-right: 0; overflow: visible; }
  .side-brand { padding: 2px 2px 12px; }
  .app-nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .app-nav-item { white-space: nowrap; }
  .app-side-foot { margin-top: 12px; flex-direction: row; align-items: center; justify-content: space-between; border-top: 0; padding-top: 0; }
}
@media (max-width: 560px) {
  .app-card-row { flex-direction: column; gap: 4px; }
  .app-card-row .k { flex-basis: auto; }
  .hide-sm { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .qa-grid { grid-template-columns: 1fr; }
  .out-actions { width: 100%; margin-left: 0; }
  .drawer-kv { grid-template-columns: 1fr; gap: 2px 0; }
  .drawer-kv .dk { margin-top: 8px; }
}
