/* Ledger on defuss-db. The colour tokens are the defuss-db site's (docs/assets/site.css), so the frame matches the
   page that embeds it; they sit outside any layer, after defuss-shadcn's own unlayered tokens, and win. Everything
   else uses defuss-shadcn tokens; the ok and warning hues have no token and stay literals. */
:root {
  --background: oklch(0.985 0.004 183);
  --foreground: oklch(0.22 0.025 189);
  --card: oklch(1 0 0);
  --popover: oklch(1 0 0);
  --muted: oklch(0.955 0.012 185);
  --muted-foreground: oklch(0.43 0.027 188);
  --border: oklch(0.885 0.016 185);
  --input: oklch(0.885 0.016 185);
  --primary: oklch(0.43 0.077 186);
  --primary-foreground: oklch(0.99 0 0);
  --ring: oklch(0.54 0.089 186);
  --chart-2: #246b69;
  --radius: 0.85rem;
  --font-sans: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --dv-ok: oklch(0.5 0.13 155);
  --dv-amber: #915627;
}
.dark {
  --background: oklch(0.175 0.023 191);
  --foreground: oklch(0.955 0.009 186);
  --card: oklch(0.215 0.023 189);
  --popover: oklch(0.215 0.023 189);
  --muted: oklch(0.265 0.024 188);
  --muted-foreground: oklch(0.76 0.025 187);
  --border: oklch(0.34 0.026 190);
  --input: oklch(0.34 0.026 190);
  --primary: oklch(0.80 0.092 179);
  --primary-foreground: oklch(0.175 0.027 190);
  --ring: oklch(0.80 0.092 179);
  --chart-2: #86ccbd;
  --dv-ok: oklch(0.75 0.13 155);
  --dv-amber: #e6b082;
}

@layer components {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { margin: 0; line-height: 1.5; background: var(--background); color: var(--foreground); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
  [hidden] { display: none !important; }
  code { font-family: var(--font-mono); font-size: .9em; }
  .dv-icon { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  /* one viewport-high frame: the center column flexes, every component fills what its toolbar leaves */
  .dv-app { height: 100dvh; }
  .dv-center { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
  .dv-bar { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-block-end: 1px solid var(--border); }
  .dv-brand { display: inline-flex; align-items: center; gap: .5rem; margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.5; white-space: nowrap; }
  .dv-brand .dv-icon { color: var(--chart-2); }
  .dv-bar-note { margin: 0 auto 0 0; min-width: 0; overflow: hidden; font-size: .75rem; color: var(--muted-foreground); white-space: nowrap; text-overflow: ellipsis; }
  .dv-tabs { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: .625rem; padding: .625rem .75rem .75rem; }
  /* a narrow frame scrolls the tab list instead of truncating its labels */
  .dv-tabs .tab-list { flex: none; max-width: 100%; overflow-x: auto; grid-auto-columns: max-content; }
  .dv-panel { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: .625rem; overflow: auto; }
  .dv-panel[hidden] { display: none !important; }
  .dv-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
  .dv-toolbar .select { width: auto; max-width: 100%; }
  .dv-hint { flex: 1 1 16rem; margin: 0; font-size: .75rem; color: var(--muted-foreground); text-wrap: pretty; }
  .dv-fill { flex: 1 1 0; min-height: 14rem; }
  .dv-report { display: flex; flex-direction: column; }
  .dv-report > .data-grid { flex: 1 1 0; min-height: 0; }

  /* two columns that stack on a narrow frame */
  .dv-columns { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: .75rem; }
  .dv-columns > .data-grid { min-height: 14rem; }
  @media (min-width: 60rem) { .dv-columns[data-wide="first"] { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
  .dv-stack { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
  .dv-small { height: 11.5rem; flex: none; }
  .dv-field { display: inline-flex; flex-direction: column; gap: .125rem; font-size: .75rem; color: var(--muted-foreground); }
  .dv-field .input, .dv-field .select { color: var(--foreground); }
  .dv-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; }
  .dv-form .dv-label, .dv-form-note { flex-basis: 100%; }
  .dv-form .input[type="number"] { width: 7rem; }
  .dv-amount { width: 7.5rem; }
  .dv-check { display: inline-flex; align-items: center; gap: .375rem; font-size: .8125rem; }
  .dv-search { display: flex; flex-direction: column; gap: .75rem; max-width: 36rem; padding-block: .5rem; }
  .dv-option-name { display: block; }
  .dv-option-detail { display: block; font-size: .75rem; color: var(--muted-foreground); }

  /* the editable status cell: a compact native select inside a 36px row */
  .dv-cell-select { height: 1.75rem; width: 100%; padding-block: 0; font-size: .8125rem; }
  .dv-cell-select[data-status="failed"] { color: var(--destructive); }
  .dv-cell-select[data-status="refunded"] { color: var(--muted-foreground); }
  .dv-cell-select[data-status="pending"] { color: var(--dv-amber); }

  .dv-invariant { margin: 0; font-size: .8125rem; font-variant-numeric: tabular-nums; }
  .dv-invariant[data-tone="ok"]::before { content: "✓ "; color: var(--dv-ok); font-weight: 700; }
  .dv-invariant[data-tone="error"] { color: var(--destructive); }
  #accounts[data-pinned="none"] [data-field="pinned"] { color: var(--muted-foreground); }

  /* the first visit's seeding, over the tabs */
  .dv-seed { position: absolute; inset: 3rem 0 0; z-index: 5; display: grid; place-items: center; padding: 1rem; background: color-mix(in oklch, var(--background) 82%, transparent); backdrop-filter: blur(2px); }
  .dv-seed-card { width: min(30rem, 100%); padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
  .dv-seed-title { margin: 0; font-size: 1.05rem; }
  .dv-seed-bar { width: 100%; height: .5rem; accent-color: var(--primary); }
  .dv-seed-step { margin: 0; font: .8125rem var(--font-mono); font-variant-numeric: tabular-nums; }

  /* inspector: the panel body scrolls as a whole; its parts keep their height */
  .dv-inspector { display: flex; flex-direction: column; gap: .75rem; overflow: auto; }
  .dv-inspector > * { flex: none; }
  .dv-store { display: flex; flex-direction: column; gap: .5rem; padding: .625rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-md, .5rem); background: var(--muted); }
  .dv-store-line { margin: 0; font-size: .8125rem; text-wrap: pretty; }
  .dv-component { margin: 0; font-size: .875rem; }
  .dv-component code { font-size: .75rem; color: var(--muted-foreground); overflow-wrap: anywhere; }
  .dv-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: .5rem 1rem; }
  .dv-stats .statistic-value, .dv-timing .statistic-value { font-size: 1.125rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .dv-timing .statistic-description { overflow-wrap: anywhere; }
  .dv-timing [data-tone="error"] { color: var(--destructive); }
  .dv-access:empty { display: none; }
  .dv-label { margin: .25rem 0 0; font-size: .6875rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-foreground); }
  .dv-presets { display: flex; flex-wrap: wrap; gap: .375rem; }
  .dv-extra { display: flex; flex-direction: column; gap: .375rem; }
  .dv-extra:empty { display: none; }
  .dv-edits { margin: 0; padding-inline-start: 1.25rem; font: .75rem var(--font-mono); }
  /* the code panel: the Code Example block's own dark surface and token colours, in both themes */
  .dv-query pre { min-height: 10rem; max-height: 22rem; overflow: auto; font-size: .75rem; }
  .dv-literal { color: oklch(0.82 0.12 70); }
  .dv-call { color: oklch(0.8 0.11 230); }
  .dv-type { color: oklch(0.85 0.09 190); }
  .dv-caption { margin: 0; font-size: .75rem; color: var(--muted-foreground); text-wrap: pretty; }

  @media (max-width: 40rem) {
    .dv-bar-note { display: none; }
    .dv-bar #reload { margin-inline-start: auto; }
    /* the landing page embeds this page in a frame about 290 px wide at phone width */
    .dv-bar { gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
    .dv-bar .btn { padding-inline: .5rem; }
  }
  @media (prefers-contrast: more) { .dv-hint, .dv-caption { color: var(--foreground); } }
}
