:root {
  color-scheme: light;
  --canvas: #f3f4ed;
  --paper: #fffef9;
  --ink: #203329;
  --muted: #50635a;
  --edge: #dbe1d8;
  --rail: #21372e;
  --rail-text: #edf4e7;
  --accent: #236754;
  --accent-soft: #e2f0e8;
  --warn: #805123;
  --warn-soft: #fbeddc;
  --error: #9d3d36;
  --error-soft: #fce9e6;
  --radius: 16px;
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.12; letter-spacing: -.045em; }
h2 { font-size: 21px; letter-spacing: -.027em; }
h3 { font-size: 16px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .64; }
:focus-visible { outline: 3px solid #348465; outline-offset: 3px; }
.eyebrow { color: #467062; font-weight: 760; font-size: 11px; letter-spacing: .12em; }
.intro, .hint, .meta { color: var(--muted); }
.hint, .meta { font-size: 13px; }
.intro { margin-top: 8px; }
.auth-view, .boot-view { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-view { background: radial-gradient(ellipse at 16% 8%, #e2efe4, transparent 62%), var(--canvas); }
.auth-card { width: min(100%, 440px); padding: clamp(22px, 7vw, 38px); background: var(--paper); border: 1px solid var(--edge); border-radius: 24px; box-shadow: 0 18px 60px #23372913; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px; background: #e3eeb5; color: #234233; }
.brand-mark svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.auth-card .brand-mark { width: 50px; height: 50px; margin-bottom: 20px; }
.auth-card h1 { margin-top: 5px; font-size: clamp(27px, 8vw, 36px); }
.mode-tabs { display: flex; gap: 4px; margin: 24px 0 18px; padding: 4px; border-radius: 12px; background: #ecf0ea; }
.mode-tabs button { flex: 1; border: 0; border-radius: 9px; background: none; padding: 9px 8px; color: var(--muted); font-weight: 650; }
.mode-tabs button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px #20332915; }
.form-stack { display: grid; gap: 9px; }
.form-stack label, .field label { font-size: 13px; font-weight: 700; }
.form-stack .primary { margin-top: 4px; }
input, select, textarea { width: 100%; min-height: 43px; padding: 8px 11px; border: 1px solid #c8d3ca; border-radius: 9px; background: #fff; }
textarea { resize: vertical; min-height: 84px; }
.primary, .secondary, .text-button { min-height: 42px; padding: 8px 14px; font-weight: 650; border-radius: 9px; }
.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.primary:hover:not(:disabled) { background: #195342; }
.secondary { background: var(--paper); border: 1px solid #c8d3ca; }
.secondary:hover:not(:disabled) { background: #eef4ed; }
.text-button { border: 0; background: transparent; color: var(--accent); padding-inline: 4px; text-align: left; }
.message { padding: 10px 14px; border-radius: 9px; background: var(--accent-soft); color: #214c3e; margin-top: 12px; }
.message[data-tone="error"] { background: var(--error-soft); color: var(--error); }
.workspace { min-height: 100dvh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { background: var(--rail); color: var(--rail-text); padding: 22px 16px; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 3px 4px 18px; margin-bottom: 16px; border-bottom: 1px solid #ffffff23; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { color: #c0d2c5; font-size: 12px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: #dce9dc; border-radius: 9px; min-height: 43px; padding: 8px 10px; white-space: nowrap; text-decoration: none; }
.sidebar nav a:hover { background: #ffffff15; }
.sidebar nav a[aria-current="page"] { background: #dceebf; color: #263b2d; font-weight: 750; }
.sidebar nav svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.main { width: min(100%, 1420px); min-width: 0; margin: 0 auto; padding: clamp(20px, 4vw, 42px); }
.topbar { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.topbar h1 { margin-top: 5px; }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
#account-email { max-width: 240px; font-size: 13px; overflow-wrap: anywhere; color: var(--muted); }
#notice { margin: 0 0 14px; }
.flow { display: grid; gap: 16px; }
.panel { min-width: 0; padding: clamp(15px, 3vw, 22px); border-radius: var(--radius); border: 1px solid var(--edge); background: var(--paper); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; flex-wrap: wrap; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; }
.metric { display: grid; gap: 5px; min-height: 104px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font-size: clamp(24px, 4vw, 35px); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.field { display: grid; gap: 5px; min-width: 0; }
.toolbar .field { flex: 1 1 180px; }
.toolbar .compact { flex: 0 1 190px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
th, td { padding: 9px 10px; border-bottom: 1px solid #e5eae2; vertical-align: middle; }
th { white-space: nowrap; color: var(--muted); font-size: 12px; background: #f4f7f1; }
td { overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faf5; }
td .text-button { min-height: 34px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.empty { padding: 12px 0; color: var(--muted); }
.tag { display: inline-block; background: #edf1eb; color: #39564a; padding: 3px 8px; border-radius: 20px; font-size: 12px; font-weight: 660; white-space: nowrap; }
.tag[data-tone="warning"] { background: var(--warn-soft); color: var(--warn); }
.tag[data-tone="ok"] { background: var(--accent-soft); color: #225a47; }
.detail-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.definition { display: grid; grid-template-columns: minmax(90px, .8fr) minmax(0, 1.2fr); gap: 7px 10px; margin: 0; font-size: 14px; }
.definition dt { color: var(--muted); }
.definition dd { margin: 0; overflow-wrap: anywhere; }
.entry-list { display: grid; gap: 0; }
.entry { display: grid; gap: 2px; padding: 9px 0; border-bottom: 1px solid var(--edge); }
.entry:last-child { border-bottom: 0; }
.copy { white-space: pre-wrap; overflow-wrap: anywhere; margin: 9px 0 12px; }
.preview-figure { margin: 12px 0; }
.preview-figure svg { display: block; width: 100%; max-height: 400px; border: 1px solid var(--edge); border-radius: 12px; background: #edf2e9; }
.preview-figure figcaption { color: var(--muted); font-size: 12px; margin-top: 5px; }
dialog { color: var(--ink); width: min(510px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--edge); border-radius: 18px; padding: 20px; background: var(--paper); overflow: auto; }
dialog::backdrop { background: #14271d8f; }
dialog header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
#action-content { display: grid; gap: 10px; }
@media (max-width: 800px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { padding: 10px 12px 8px; }
  .sidebar-brand { padding: 0 3px 8px; margin-bottom: 6px; }
  .sidebar-brand .brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
  .sidebar-brand .brand-mark svg { width: 18px; height: 18px; }
  .sidebar nav { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 2px 3px 5px; gap: 3px; }
  .sidebar nav a { flex-direction: column; justify-content: center; min-height: 45px; gap: 3px; padding: 5px 1px; font-size: 11px; }
  .main { padding: 18px 12px 25px; }
}
@media (max-width: 590px) {
  .columns { grid-template-columns: minmax(0, 1fr); }
  .topbar { align-items: flex-start; }
  .account { flex-direction: column-reverse; align-items: flex-end; gap: 3px; }
  #account-email { max-width: 112px; font-size: 11px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pager { justify-content: flex-start; }
  th, td { padding-inline: 7px; }
}
.diagnostic-text { overflow: auto; max-height: 440px; padding: 12px; border-radius: 10px; background: #edf2ed; color: #244436; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
#view summary { cursor: pointer; font-weight: 700; }
#view .form-stack { margin-top: 12px; }
