/* ==========================================================================
   Appizer design system — Jutera-aligned.
   Token VALUES are identical to ~/code/jutera/shared/static/style.css so
   Appizer, Jutera, FreeRouter and Multify read as one family. Names carry an
   `az-` prefix because Jutera's unprefixed .btn/.card/.grid/.input collide with
   Tailwind utilities and existing Appizer classes.
   Light/dark via html[data-theme]; see /js/theme.js. Tailwind color utilities
   are remapped onto these tokens in views/partials/head-assets.ejs.
   Plan + decisions: devnotes/jutera-restyle-plan.md
   ========================================================================== */

/* ---- Tokens -------------------------------------------------------------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --az-bg: #ffffff;        --az-bg-rgb: 255 255 255;
  --az-card: #f7f7f7;      --az-card-rgb: 247 247 247;
  --az-card2: #efefef;     --az-card2-rgb: 239 239 239;
  --az-text: #0f0f0f;      --az-text-rgb: 15 15 15;
  --az-muted: #666666;     --az-muted-rgb: 102 102 102;
  --az-border: #e0e0e0;    --az-border-rgb: 224 224 224;
  --az-success: #16a34a;   --az-success-rgb: 22 163 74;
  --az-success-soft: #ecfdf5;
  --az-warn: #b45309;      --az-warn-rgb: 180 83 9;
  --az-warn-soft: #fffbeb;
  --az-danger: #dc2626;    --az-danger-rgb: 220 38 38;
  --az-danger-soft: #fef2f2;
  --az-hl: rgba(255, 206, 51, .85);
  --az-hl-solid: #ffce33;
  --az-shadow-pop: 0 8px 24px rgba(0, 0, 0, .15);
  --az-topbar-h: 53px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --az-bg: #0f0f0f;        --az-bg-rgb: 15 15 15;
  --az-card: #1a1a1a;      --az-card-rgb: 26 26 26;
  --az-card2: #252525;     --az-card2-rgb: 37 37 37;
  --az-text: #ffffff;      --az-text-rgb: 255 255 255;
  --az-muted: #a0a0a0;     --az-muted-rgb: 160 160 160;
  --az-border: #333333;    --az-border-rgb: 51 51 51;
  --az-success: #22c55e;   --az-success-rgb: 34 197 94;
  --az-success-soft: rgba(34, 197, 94, .14);
  --az-warn: #f59e0b;      --az-warn-rgb: 245 158 11;
  --az-warn-soft: rgba(245, 158, 11, .14);
  --az-danger: #f87171;    --az-danger-rgb: 248 113 113;
  --az-danger-soft: rgba(248, 113, 113, .14);
  --az-hl: rgba(255, 196, 38, .92);
  --az-hl-solid: #ffc426;
  --az-shadow-pop: 0 8px 24px rgba(0, 0, 0, .5);
}

/* ---- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--az-bg);
  color: var(--az-text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img, video { max-width: 100%; height: auto; }
h1, h2, h3, h4, h5, h6 { line-height: 1.25; letter-spacing: -.01em; }
code, kbd, samp, pre, .az-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .9em;
}
:focus-visible { outline: 2px solid var(--az-text); outline-offset: 2px; }
::selection { background: var(--az-hl); color: #0f0f0f; }

/* ---- Brand --------------------------------------------------------------- */
.az-wordmark {
  font-family: 'Krona One', sans-serif;
  font-weight: 400;
  font-size: 1.05rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--az-text);
  white-space: nowrap;
}
.az-wordmark.lg { font-size: 1.6rem; }
.az-wordmark.xl { font-size: 2.6rem; }
/* Highlighter under emphasized words (Jutera .sub-hl). */
.az-hl {
  background-image: linear-gradient(transparent 68%, var(--az-hl) 68%, var(--az-hl) 90%, transparent 90%);
  background-repeat: no-repeat;
  padding: 0 .08em;
}
.az-eyebrow {
  display: inline-block;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--az-muted);
  margin: 0;
}
.az-lede { color: var(--az-muted); max-width: 65ch; }
.az-muted { color: var(--az-muted); }
.az-hint { color: var(--az-muted); font-size: .82rem; }

/* ---- Buttons ------------------------------------------------------------- */
.az-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid var(--az-text);
  background: var(--az-text);
  color: var(--az-bg);
  padding: .5rem .95rem;
  font: 600 .9rem 'Instrument Sans', sans-serif;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
  transition: opacity .15s, background-color .15s, border-color .15s, color .15s;
}
.az-btn:hover { opacity: .88; }
.az-btn.secondary { background: transparent; color: var(--az-text); border-color: var(--az-border); }
.az-btn.secondary:hover { opacity: 1; border-color: var(--az-muted); background: var(--az-card); }
.az-btn.ghost { background: transparent; color: var(--az-muted); border-color: transparent; }
.az-btn.ghost:hover { opacity: 1; color: var(--az-text); background: var(--az-card); }
.az-btn.danger { background: var(--az-danger); border-color: var(--az-danger); color: #fff; }
.az-btn.danger.secondary { background: transparent; color: var(--az-danger); }
.az-btn.success { background: var(--az-success); border-color: var(--az-success); color: #fff; }
.az-btn.small { padding: .3rem .65rem; font-size: .82rem; }
.az-btn.large { padding: .7rem 1.2rem; font-size: .95rem; }
.az-btn.block { display: flex; width: 100%; }
.az-btn:disabled, .az-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.az-btn .bi { font-size: .9em; }

.az-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 .55rem;
  border: 1px solid var(--az-border);
  background: var(--az-bg);
  color: var(--az-text);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.az-iconbtn:hover { border-color: var(--az-muted); background: var(--az-card); }
.az-linklike {
  background: none; border: 0; padding: 0; color: inherit; font: inherit;
  text-decoration: underline; text-underline-offset: .15em; cursor: pointer;
}
.az-linklike:hover { color: var(--az-text); }

/* ---- Forms --------------------------------------------------------------- */
.az-input,
select.az-input,
textarea.az-input {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--az-border);
  background: var(--az-bg);
  color: var(--az-text);
  border-radius: 6px;
  font: inherit;
  font-size: .92rem;
  line-height: 1.4;
}
.az-input::placeholder { color: var(--az-muted); opacity: .8; }
.az-input:hover { border-color: var(--az-muted); }
.az-input:focus, .az-input:focus-visible { outline: 2px solid var(--az-text); outline-offset: 1px; border-color: var(--az-text); }
.az-input:disabled, .az-input[readonly] { background: var(--az-card); color: var(--az-muted); }
.az-input.invalid, .az-input[aria-invalid="true"] { border-color: var(--az-danger); }
.az-input.small { padding: .35rem .55rem; font-size: .85rem; }
select.az-input.small { padding-right: 2.2rem; }
/* Search field with inset icon. Centered by calc (top 50% minus half the
   icon height) rather than a transform, which some cascades override. */
.az-search { position: relative; }
.az-search > .bi {
  position: absolute; left: .7rem; top: 50%; margin-top: -.475rem;
  height: .95rem; display: block;
  color: var(--az-muted); pointer-events: none; line-height: 1; font-size: .95rem;
}
.az-search .az-input { padding-left: 2.3rem; }
.az-search.end > .bi { left: auto; right: .7rem; }
.az-search.end .az-input { padding-left: .7rem; padding-right: 2.3rem; }
select.az-input {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23888888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center; background-size: .72rem .5rem;
}
textarea.az-input { min-height: 6rem; resize: vertical; }
input[type="date"].az-input, input[type="color"].az-input { padding-right: .7rem; }
.az-label { display: block; font-weight: 600; font-size: .85rem; margin: .9rem 0 .3rem; }
.az-label.first, .az-field:first-child .az-label { margin-top: 0; }
.az-label .req { color: var(--az-danger); }
.az-field { margin-bottom: .2rem; }
.az-field .az-hint { margin-top: .3rem; }
.az-error { color: var(--az-danger); font-size: .82rem; margin-top: .3rem; }
input[type="checkbox"].az-check, input[type="radio"].az-check {
  width: 1rem; height: 1rem; accent-color: var(--az-text); cursor: pointer; margin: 0 .45rem 0 0; vertical-align: -2px;
}
.az-checkrow { display: flex; align-items: center; gap: .4rem; font-size: .9rem; margin: .4rem 0; cursor: pointer; }
/* Switch */
.az-switch { position: relative; display: inline-block; width: 2.3rem; height: 1.3rem; flex: none; }
.az-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.az-switch .knob {
  position: absolute; inset: 0; background: var(--az-border); border-radius: 999px; cursor: pointer; transition: background .15s;
}
.az-switch .knob::before {
  content: ""; position: absolute; width: 1rem; height: 1rem; left: .15rem; top: .15rem;
  background: var(--az-bg); border-radius: 50%; transition: transform .15s;
}
.az-switch input:checked + .knob { background: var(--az-text); }
.az-switch input:checked + .knob::before { transform: translateX(1rem); }
.az-switch input:focus-visible + .knob { outline: 2px solid var(--az-text); outline-offset: 2px; }
/* Input + button group (copy fields) */
.az-inputgroup { display: flex; }
.az-inputgroup .az-input { border-radius: 6px 0 0 6px; }
.az-inputgroup .az-btn, .az-inputgroup .az-iconbtn { border-radius: 0; margin-left: -1px; height: auto; }
.az-inputgroup > :last-child { border-radius: 0 6px 6px 0; }

/* ---- Cards + stats ------------------------------------------------------- */
.az-card {
  background: var(--az-card);
  border: 1px solid var(--az-border);
  padding: 1.1rem;
  border-radius: 8px;
}
.az-card.flush { padding: 0; overflow: hidden; }
.az-card.plain { background: var(--az-bg); }
.az-card.clickable { cursor: pointer; transition: border-color .15s; }
.az-card.clickable:hover { border-color: var(--az-muted); }
.az-card > :first-child { margin-top: 0; }
.az-card > :last-child { margin-bottom: 0; }
.az-card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; }
.az-card-head h2, .az-card-head h3 { margin: 0; font-size: 1.05rem; }
.az-card-title { font-weight: 700; font-size: 1rem; margin: 0 0 .2rem; }
.az-stat b { font-size: 1.55rem; display: block; line-height: 1.15; font-weight: 700; margin: .25rem 0; }
.az-stat span { color: var(--az-muted); font-size: .82rem; display: block; }
.az-stat .delta { font-weight: 600; }
.az-stat .delta.up { color: var(--az-success); }
.az-stat .delta.down { color: var(--az-danger); }
.az-grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
.az-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.az-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.az-grid4 > *, .az-grid3 > *, .az-grid2 > * { min-width: 0; }

/* ---- Pills + badges ------------------------------------------------------ */
.az-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .1rem .55rem;
  border: 1px solid var(--az-border);
  border-radius: 999px;
  font-size: .75rem; font-weight: 600; line-height: 1.5;
  white-space: nowrap;
  color: var(--az-text);
}
.az-pill.ok { color: var(--az-success); border-color: var(--az-success); }
.az-pill.warn { color: var(--az-warn); border-color: var(--az-warn); }
.az-pill.danger { color: var(--az-danger); border-color: var(--az-danger); }
.az-pill.mut { color: var(--az-muted); }
.az-pill.fill { background: var(--az-text); color: var(--az-bg); border-color: var(--az-text); }
.az-pill.hl { background: var(--az-hl); color: #0f0f0f; border-color: transparent; }
.az-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 999px; background: var(--az-muted); vertical-align: middle; }
.az-dot.ok, .az-live-dot { background: var(--az-success); }
.az-dot.warn { background: var(--az-warn); }
.az-dot.danger { background: var(--az-danger); }

/* ---- Tables -------------------------------------------------------------- */
.az-tbl-wrap { overflow-x: auto; }
table.az-tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.az-tbl th {
  text-align: left; color: var(--az-muted); font-weight: 600;
  padding: .55rem .6rem; border-bottom: 1px solid var(--az-border); white-space: nowrap;
}
table.az-tbl td { padding: .55rem .6rem; border-bottom: 1px solid var(--az-border); vertical-align: top; }
table.az-tbl tbody tr:hover td { background: var(--az-card); }
table.az-tbl tr:last-child td { border-bottom: 0; }
table.az-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.az-tbl.compact th, table.az-tbl.compact td { padding: .35rem .5rem; }
.az-card.flush table.az-tbl th { background: var(--az-card2); }

/* ---- Code ---------------------------------------------------------------- */
.az-code {
  position: relative;
  background: var(--az-text);
  color: var(--az-bg);
  padding: 1rem; padding-right: 3rem;
  overflow-x: auto;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8rem; line-height: 1.55;
  margin: 0;
}
.az-code code, .az-code pre { color: inherit; font-size: inherit; background: none; padding: 0; margin: 0; font-family: inherit; }
.az-copy-btn {
  position: absolute; top: .55rem; right: .55rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem;
  border: 1px solid rgba(128, 128, 128, .45); border-radius: 6px;
  background: transparent; color: var(--az-bg); opacity: .75; cursor: pointer;
}
.az-copy-btn:hover { opacity: 1; }
.az-copy-btn.copied { opacity: 1; color: #4ade80; border-color: #4ade80; }
code.az-inline, .az-md code {
  background: rgba(127, 127, 127, .16); padding: .08rem .3rem; border-radius: 4px; font-size: .86em;
}
/* Rendered markdown (chat, AI summaries) */
.az-md p { margin: .45rem 0; }
.az-md h1, .az-md h2, .az-md h3, .az-md h4 { margin: .8rem 0 .3rem; }
.az-md ul, .az-md ol { margin: .45rem 0; padding-left: 1.25rem; }
.az-md li { margin: .2rem 0; }
.az-md pre { background: rgba(127, 127, 127, .14); padding: .7rem; border-radius: 8px; overflow-x: auto; }
.az-md pre code { background: none; padding: 0; }
.az-md blockquote { margin: .5rem 0; padding: .2rem .8rem; border-left: 3px solid var(--az-border); opacity: .85; }
.az-md table { border-collapse: collapse; margin: .6rem 0; font-size: .9em; display: block; overflow-x: auto; }
.az-md th, .az-md td { border: 1px solid var(--az-border); padding: .35rem .55rem; text-align: left; }
.az-md a { color: inherit; text-decoration: underline; }

/* ---- Banners + toasts ---------------------------------------------------- */
.az-banner {
  display: flex; align-items: flex-start; gap: .7rem;
  border: 1px solid var(--az-border);
  background: var(--az-card);
  padding: .8rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .92rem;
}
.az-banner > .body { flex: 1; min-width: 0; }
.az-banner > .body p { margin: .2rem 0; }
.az-banner.ok { border-color: var(--az-success); background: var(--az-success-soft); }
.az-banner.warn { border-color: var(--az-warn); background: var(--az-warn-soft); }
.az-banner.danger { border-color: var(--az-danger); background: var(--az-danger-soft); }
.az-banner .close {
  background: none; border: 0; color: var(--az-muted); cursor: pointer; padding: 0 .1rem; font: inherit; line-height: 1;
}
.az-banner .close:hover { color: var(--az-text); }

#az-toasts {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem; align-items: flex-end;
  pointer-events: none;
}
.az-toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: .6rem;
  background: var(--az-text); color: var(--az-bg);
  padding: .7rem 1rem;
  border-radius: 6px;
  max-width: min(92vw, 420px);
  font-size: .9rem; font-weight: 500;
  box-shadow: var(--az-shadow-pop);
  transform: translateY(.6rem); opacity: 0;
  transition: transform .2s, opacity .2s;
}
.az-toast.show { transform: none; opacity: 1; }
.az-toast .ico { flex: none; }
.az-toast.ok .ico { color: #4ade80; }
.az-toast.danger .ico { color: #f87171; }
.az-toast.warn .ico { color: var(--az-hl-solid); }
.az-toast .close { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0 0 0 .4rem; font: inherit; }
.az-toast .close:hover { opacity: 1; }
@media (max-width: 860px) { #az-toasts { bottom: 4.2rem; left: 1rem; align-items: stretch; } .az-toast { max-width: none; } }

/* ---- Key/value, bars, checklists ---------------------------------------- */
.az-kv { display: grid; grid-template-columns: 11rem 1fr; gap: .4rem .9rem; font-size: .9rem; margin: 0; }
.az-kv dt { color: var(--az-muted); }
.az-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.az-bar-row { display: grid; grid-template-columns: 2.6rem 1fr 4rem; gap: .6rem; align-items: center; margin: .35rem 0; font-size: .82rem; }
.az-bar-row > span:last-child { text-align: right; color: var(--az-muted); font-variant-numeric: tabular-nums; }
.az-bar { height: .65rem; background: var(--az-card2); border-radius: 2px; overflow: hidden; }
.az-bar i { display: block; height: 100%; background: var(--az-text); }
.az-bar.ok i { background: var(--az-success); }
.az-list { list-style: none; padding: 0; margin: 0; }
.az-list li { padding: .55rem 0; border-bottom: 1px solid var(--az-border); display: flex; gap: .6rem; justify-content: space-between; align-items: center; }
.az-list li:last-child { border-bottom: 0; }

/* ---- Segmented control + tabs ------------------------------------------- */
.az-seg { display: inline-flex; border: 1px solid var(--az-border); border-radius: 6px; overflow: hidden; flex-wrap: wrap; }
.az-seg button, .az-seg a {
  border: 0; background: var(--az-bg); color: var(--az-muted);
  padding: .35rem .7rem; cursor: pointer; text-decoration: none;
  font: 600 .82rem 'Instrument Sans', sans-serif; line-height: 1.5;
}
.az-seg button + button, .az-seg a + a, .az-seg button + a, .az-seg a + button { border-left: 1px solid var(--az-border); }
.az-seg .on, .az-seg [aria-pressed="true"], .az-seg [aria-selected="true"] { background: var(--az-text); color: var(--az-bg); }
.az-tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--az-border); overflow-x: auto; }
.az-tabs a, .az-tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: .55rem .8rem; color: var(--az-muted); font: 600 .88rem 'Instrument Sans', sans-serif;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.az-tabs a:hover, .az-tabs button:hover { color: var(--az-text); }
.az-tabs .on, .az-tabs [aria-selected="true"] { color: var(--az-text); border-bottom-color: var(--az-text); }
.az-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  border: 1px solid var(--az-border); background: transparent; color: inherit;
  padding: .35rem .7rem; border-radius: 999px; cursor: pointer; font: inherit; font-size: .85rem;
}
.az-chip:hover { border-color: var(--az-muted); }
.az-chip[aria-pressed="true"], .az-chip.on { background: var(--az-text); color: var(--az-bg); border-color: var(--az-text); }

/* ---- Dropdown menus ------------------------------------------------------ */
.az-menu {
  position: absolute; z-index: 40; min-width: 12rem; max-width: calc(100vw - 2rem);
  background: var(--az-bg); border: 1px solid var(--az-border); border-radius: 8px;
  box-shadow: var(--az-shadow-pop); padding: .35rem; margin-top: .35rem;
}
.az-menu.right { right: 0; }
.az-menu[hidden] { display: none; }
.az-menu a, .az-menu button {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  padding: .5rem .65rem; border-radius: 6px; border: 0; background: none;
  color: var(--az-text); font: inherit; font-size: .9rem; text-align: left; text-decoration: none; cursor: pointer;
}
.az-menu a:hover, .az-menu button:hover, .az-menu a.on { background: var(--az-card); }
.az-menu .danger { color: var(--az-danger); }
.az-menu hr { border: 0; border-top: 1px solid var(--az-border); margin: .35rem 0; }
.az-menu .az-menu-label { padding: .4rem .65rem .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--az-muted); }
.az-menu .bi { width: 1.1rem; text-align: center; color: var(--az-muted); }

/* ---- Dialogs (native <dialog>) ------------------------------------------ */
dialog.az-dialog {
  border: 1px solid var(--az-border);
  border-radius: 10px;
  padding: 0;
  width: 560px; max-width: min(94vw, 560px);
  background: var(--az-bg); color: var(--az-text);
  box-shadow: var(--az-shadow-pop);
}
dialog.az-dialog.wide { width: 920px; max-width: min(94vw, 920px); }
dialog.az-dialog.xwide { width: 1120px; max-width: min(96vw, 1120px); }
dialog.az-dialog.narrow { width: 420px; max-width: min(94vw, 420px); }
dialog.az-dialog::backdrop { background: rgba(0, 0, 0, .45); }
[data-theme="dark"] dialog.az-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.az-dialog-head {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--az-border);
}
.az-dialog-head > div { flex: 1; min-width: 0; }
.az-dialog-head h2, .az-dialog-head h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.az-dialog-head .az-hint { margin: .15rem 0 0; }
.az-dialog-body { padding: 1rem 1.1rem; max-height: min(70vh, 720px); overflow-y: auto; }
.az-dialog-foot {
  display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap;
  padding: .8rem 1.1rem; border-top: 1px solid var(--az-border); background: var(--az-card);
  border-radius: 0 0 10px 10px;
}
.az-dialog-foot.between { justify-content: space-between; }
body.az-modal-open { overflow: hidden; }
@media (max-width: 640px) {
  dialog.az-dialog, dialog.az-dialog.wide, dialog.az-dialog.xwide, dialog.az-dialog.narrow {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; border-bottom: 0;
    max-height: 92dvh;
  }
  .az-dialog-foot { border-radius: 0; padding-bottom: calc(.8rem + env(safe-area-inset-bottom)); }
  .az-dialog-foot .az-btn { flex: 1; }
}

/* ---- App shell ----------------------------------------------------------- */
.az-skip {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; z-index: 10000;
  background: var(--az-text); color: var(--az-bg); padding: .5rem 1rem; border-radius: 6px; text-decoration: none; font-weight: 600;
}
.az-skip:focus { left: 1rem; top: 1rem; width: auto; height: auto; }
.az-topbar {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem 1.25rem;
  border-bottom: 1px solid var(--az-border);
  position: sticky; top: 0; z-index: 20;
  background: var(--az-bg);
  min-height: var(--az-topbar-h);
}
.az-topbar .az-sp, .az-sp { flex: 1; }
.az-topbar .product { font-weight: 600; color: var(--az-muted); font-size: .9rem; white-space: nowrap; }
.az-layout { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100dvh - var(--az-topbar-h)); }
.az-sidenav {
  border-right: 1px solid var(--az-border);
  padding: 1rem .7rem;
  display: flex; flex-direction: column; gap: .15rem;
  position: sticky; top: var(--az-topbar-h);
  height: calc(100dvh - var(--az-topbar-h)); overflow-y: auto;
}
.az-sidenav a, .az-sidenav button.navlike {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .65rem; text-decoration: none; border-radius: 6px;
  color: var(--az-muted); font-weight: 500; font-size: .92rem;
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font-family: inherit;
}
.az-sidenav a .bi, .az-sidenav button.navlike .bi { width: 1.1rem; text-align: center; font-size: .85rem; }
.az-sidenav a.on, .az-sidenav a:hover, .az-sidenav button.navlike:hover { color: var(--az-text); background: var(--az-card); }
.az-sidenav a.on { font-weight: 600; }
.az-sidenav .grp {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--az-muted);
  margin: .9rem .65rem .3rem;
}
.az-sidenav .grp:first-child { margin-top: 0; }
.az-sidenav .sub { display: block; }
.az-sidenav .sub a { padding-left: 2.35rem; font-size: .86rem; }
.az-sidenav .spacer { flex: 1; min-height: 1rem; }
.az-sidenav .foot { border-top: 1px solid var(--az-border); padding-top: .5rem; margin-top: .5rem; }
.az-main { padding: 1.4rem 1.25rem; max-width: 1600px; width: 100%; margin: 0 auto; min-width: 0; }
.az-main.wide { max-width: 1600px; padding: 1.4rem 1.5rem; }
.az-main.full { max-width: none; }
.az-main h1 { font-size: 1.55rem; margin: .1rem 0 .4rem; letter-spacing: -.01em; }
.az-main h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
.az-main h2[id], .az-main h3[id] { scroll-margin-top: 4.5rem; }
.az-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.az-page-head > div { min-width: 0; }
.az-page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.az-page-head h1 { margin: 0 0 .25rem; }
.az-page-head .az-lede { margin: 0; }
.az-sticky-bar {
  position: sticky; top: var(--az-topbar-h); z-index: 15;
  display: flex; gap: .7rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--az-bg); padding: .55rem 0; border-bottom: 1px solid var(--az-border); margin-bottom: 1rem;
}
.az-mobile-nav { display: none; }
.az-site-footer {
  border-top: 1px solid var(--az-border);
  padding: 1rem; text-align: center;
  color: var(--az-muted); font-size: .85rem;
}
.az-site-footer a { color: inherit; }
@media (max-width: 860px) {
  .az-layout { grid-template-columns: 1fr; }
  .az-sidenav { display: none; }
  .az-main, .az-main.wide { padding: 1rem .9rem 5.2rem; }
  .az-grid4 { grid-template-columns: 1fr 1fr; }
  .az-grid3 { grid-template-columns: 1fr 1fr; }
  .az-grid2 { grid-template-columns: 1fr; }
  .az-mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--az-bg); border-top: 1px solid var(--az-border);
    overflow-x: auto; padding-bottom: env(safe-area-inset-bottom);
  }
  .az-mobile-nav a {
    flex: 1 0 auto; min-width: 4.2rem; text-align: center; padding: .6rem .3rem;
    font-size: .72rem; text-decoration: none; color: var(--az-muted); white-space: nowrap;
    display: flex; flex-direction: column; align-items: center; gap: .2rem;
  }
  .az-mobile-nav a .bi { font-size: 1rem; }
  .az-mobile-nav a.on { color: var(--az-text); font-weight: 700; }
  .az-site-footer { margin-bottom: 3.2rem; }
  .az-topbar .product { display: none; }
}
@media (max-width: 480px) {
  .az-grid4, .az-grid3 { grid-template-columns: 1fr; }
  .az-kv { grid-template-columns: 1fr; }
}

/* ---- Marketing / public pages ------------------------------------------ */
.az-lp { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
.az-sec { padding: 3.5rem 0; border-top: 1px solid var(--az-border); }
.az-sec-head { max-width: 42rem; margin: 0 0 1.8rem; }
.az-sec h2 { font-size: clamp(1.45rem, 2.8vw, 2rem); line-height: 1.15; letter-spacing: -.02em; margin: .4rem 0 .5rem; }
.az-sec-head p { color: var(--az-muted); margin: 0; font-size: 1rem; }
.az-cta-band {
  background: var(--az-text); color: var(--az-bg); border-radius: 16px; padding: 2.5rem;
  display: flex; justify-content: space-between; align-items: center; gap: 2rem;
}
.az-cta-band h2, .az-cta-band h3 { margin: 0 0 .4rem; }
.az-cta-band p { margin: 0; opacity: .75; max-width: 36rem; }
.az-cta-band .az-btn { background: var(--az-bg); color: var(--az-text); border-color: var(--az-bg); }
.az-cta-band .az-btn.secondary { background: transparent; color: var(--az-bg); border-color: rgba(128, 128, 128, .6); }
.az-footer { border-top: 1px solid var(--az-border); background: var(--az-card); margin-top: 2rem; }
.az-footer-in { max-width: 1120px; margin: 0 auto; padding: 3rem 1.25rem 1.5rem; }
.az-footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr; gap: 2rem; }
.az-footer h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--az-muted); margin: .2rem 0 .9rem; font-weight: 700; }
.az-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.az-footer li a { text-decoration: none; color: var(--az-text); font-size: .92rem; }
.az-footer li a:hover { text-decoration: underline; }
.az-footer-brand .az-hint { margin: .9rem 0 0; max-width: 32ch; font-size: .88rem; line-height: 1.5; }
.az-footer-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  border-top: 1px solid var(--az-border); margin-top: 2.5rem; padding-top: 1.2rem; color: var(--az-muted); font-size: .82rem;
}
@media (max-width: 860px) {
  .az-footer-grid { grid-template-columns: 1fr 1fr; gap: 1.8rem 1.5rem; }
  .az-footer-brand { grid-column: 1 / -1; }
  .az-footer-in { padding: 2.2rem 1rem 1.2rem; }
  .az-cta-band { flex-direction: column; align-items: flex-start; padding: 1.8rem; }
  .az-sec { padding: 2.5rem 0; }
}
@media (max-width: 480px) { .az-footer-grid { grid-template-columns: 1fr; } }

/* Logo marquee (homepage). Kept from the pre-restyle site; honors reduced motion
   via the global reduced-motion block below. */
@keyframes az-marquee { 0% { transform: translateX(0%); } 100% { transform: translateX(-100%); } }
.animate-marquee { animation: az-marquee 25s linear infinite; }
.animate-marquee:hover { animation-play-state: paused; }
.mask-linear-fade {
  mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}
/* "Compatible with" marquee items: brand icons from thesvg.org (vendored in
   /icons/compat/) rendered as currentColor masks, so they take the muted ink
   color and stay legible on both light and dark backgrounds. */
.az-compat-item {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--az-muted); font-weight: 600; font-size: .95rem; white-space: nowrap;
}
.az-compat-icon {
  width: 1.4rem; height: 1.4rem; flex: none; background: currentColor;
  -webkit-mask-image: var(--icon); mask-image: var(--icon);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}

/* ---- Charts, loading, empty states -------------------------------------- */
.az-chart { width: 100%; height: 300px; }
.az-chart.tall { height: 360px; }
.az-chart.short { height: 220px; }
.az-chart .az-chart-fallback { padding: 1rem; color: var(--az-muted); font-size: .85rem; }
.az-skeleton {
  background: linear-gradient(90deg, var(--az-card) 25%, var(--az-card2) 37%, var(--az-card) 63%);
  background-size: 400% 100%; animation: az-shimmer 1.4s ease infinite; border-radius: 6px; min-height: 1em;
}
@keyframes az-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.az-spinner {
  display: inline-block; width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid var(--az-border); border-top-color: var(--az-text);
  animation: az-spin .8s linear infinite; vertical-align: -3px;
}
.az-spinner.lg { width: 1.6rem; height: 1.6rem; border-width: 3px; }
@keyframes az-spin { to { transform: rotate(360deg); } }
.az-empty {
  text-align: center; padding: 2.5rem 1rem; color: var(--az-muted);
  border: 1px dashed var(--az-border); border-radius: 8px;
}
.az-empty .bi { font-size: 1.6rem; margin-bottom: .6rem; opacity: .6; }
.az-spin { animation: az-spin 1s linear infinite; display: inline-block; }
@keyframes az-spin { to { transform: rotate(360deg); } }
.az-empty h3 { color: var(--az-text); margin: 0 0 .3rem; font-size: 1rem; }
.az-empty p { margin: 0 0 .9rem; font-size: .9rem; }
.az-avatar {
  width: 2rem; height: 2rem; border-radius: 50%; flex: none;
  background: var(--az-card2); color: var(--az-text);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem;
  overflow: hidden;
}
.az-avatar img { width: 100%; height: 100%; object-fit: cover; }
.az-avatar.sq { border-radius: 6px; }
.az-divider { border: 0; border-top: 1px solid var(--az-border); margin: 1.2rem 0; }
.az-or { display: flex; align-items: center; gap: .75rem; color: var(--az-muted); font-size: .8rem; margin: 1rem 0; }
.az-or::before, .az-or::after { content: ""; flex: 1; border-top: 1px solid var(--az-border); }

/* ---- Legacy coexistence ------------------------------------------------- */
/* Tailwind `bg-white` is remapped to var(--az-bg) in head-assets.ejs, so most
   existing views pick up dark mode automatically. The few places that still
   need a *literal* white well (third-party logos, Google button) use .az-white. */
.az-white { background: #ffffff !important; color: #1f1f1f; }

/* ---- Motion / print ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .az-topbar, .az-sidenav, .az-mobile-nav, .az-site-footer, #az-toasts { display: none !important; }
  .az-layout { display: block; }
  .az-main { max-width: none; padding: 0; }
}
