/* style.css — the back-office design system (APP-VITRINA-S1).
   The visual system is the one atina proved on this same engine (ink + one
   accent + white/zinc surfaces, Inter, tracking-tight titles, tabular-nums,
   soft shadows, generous radii, purposeful ≤300 ms motion) — ported to the
   density of a back-office and kept 100% GENERIC: nothing here names a
   resource, a state or a domain. Every color, radius, shadow and font is a
   token on :root so a consumer re-skins the WHOLE panel from theme.css
   (served at /app/theme.css — Config.AppThemeCSS / APPXIMO_APP_THEME_CSS)
   without touching this bundle: ONE variable, --app-accent, is enough for a
   brand (every accent-derived color is a color-mix of it). Light is the
   base; dark redefines the same tokens under prefers-color-scheme (auto) and
   [data-theme=dark] (explicit); [data-theme=light] pins light. Hand-written,
   compiled-static CSS: no build step, no CDN — the CSP is font-src 'self'
   and Inter ships bundled (fonts/inter-latin-var.woff2, latin subset). */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/inter-latin-var.woff2") format("woff2-variations"), url("./fonts/inter-latin-var.woff2") format("woff2");
}

:root {
  /* ── the brand seam: change THIS ONE for your brand ───────────────────── */
  --app-accent: #0b0b0c;
  --app-on-accent: #ffffff;
  /* derived from the accent (override individually only if you must) */
  --app-accent-strong: color-mix(in srgb, var(--app-accent) 82%, #000);
  --app-accent-soft: color-mix(in srgb, var(--app-accent) 9%, #fff);
  --app-accent-ring: color-mix(in srgb, var(--app-accent) 32%, transparent);
  --app-accent-glow: 0 10px 28px -10px color-mix(in srgb, var(--app-accent) 60%, transparent);

  /* ── ink + surfaces ───────────────────────────────────────────────────── */
  --app-ink: #0b0b0c;
  --app-ink-800: #141416;
  --app-ink-700: #1d1d21;
  --app-bg: #fafafa;
  --app-surface: #ffffff;
  --app-surface-2: #f4f4f5;
  --app-surface-3: #e4e4e7;
  --app-border: rgba(228, 228, 231, .85);
  --app-border-strong: #d4d4d8;
  --app-text: #0b0b0c;
  --app-text-2: #3f3f46;
  --app-muted: #71717a;
  --app-faint: #a1a1aa;

  /* ── semantic ─────────────────────────────────────────────────────────── */
  --app-danger: #dc2626;
  --app-danger-bg: #fef2f2;
  --app-danger-border: #fecaca;
  --app-ok: #047857;
  --app-ok-bg: #ecfdf5;
  --app-info: #0369a1;
  --app-info-bg: #f0f9ff;
  --app-info-border: #bae6fd;
  --app-warn: #b45309;
  --app-warn-bg: #fffbeb;

  /* ── state-machine palette, BY POSITION (state 1..8 in lifecycle order —
        never by name; the 9th wraps) ───────────────────────────────────── */
  --app-s1: #0369a1; --app-s1-bg: #e0f2fe;
  --app-s2: #b45309; --app-s2-bg: #fef3c7;
  --app-s3: #6d28d9; --app-s3-bg: #ede9fe;
  --app-s4: #047857; --app-s4-bg: #d1fae5;
  --app-s5: #be123c; --app-s5-bg: #ffe4e6;
  --app-s6: #0f766e; --app-s6-bg: #ccfbf1;
  --app-s7: #a21caf; --app-s7-bg: #fae8ff;
  --app-s8: #3f3f46; --app-s8-bg: #f4f4f5;

  /* ── shape, depth, type, motion ───────────────────────────────────────── */
  --app-radius-lg: 1.25rem;
  --app-radius: .9rem;
  --app-radius-sm: .6rem;
  --app-shadow-soft: 0 1px 2px rgba(11, 11, 12, .04), 0 12px 32px -12px rgba(11, 11, 12, .14);
  --app-shadow-lift: 0 2px 4px rgba(11, 11, 12, .05), 0 24px 48px -16px rgba(11, 11, 12, .22);
  --app-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --app-ease: cubic-bezier(.22, 1, .36, 1);
  --app-nav-w: 16rem;

  /* ── sidebar (ink by default; a light nav is 4 tokens away) ──────────── */
  --app-nav-bg: var(--app-ink);
  --app-nav-text: rgba(255, 255, 255, .72);
  --app-nav-text-strong: #ffffff;
  --app-nav-hover: rgba(255, 255, 255, .06);
  --app-nav-active: rgba(255, 255, 255, .1);
  --app-nav-border: rgba(255, 255, 255, .1);
  --app-nav-dot: var(--app-accent);
}

/* On the ink sidebar an ink accent is invisible — keep the active dot visible
   whatever the accent is, by mixing it toward white. */
:root { --app-nav-dot: color-mix(in srgb, var(--app-accent) 55%, #fff); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --app-accent-strong: color-mix(in srgb, var(--app-accent) 80%, #fff);
    --app-accent-soft: color-mix(in srgb, var(--app-accent) 18%, #141416);
    --app-bg: #0f0f11;
    --app-surface: #18181b;
    --app-surface-2: #202024;
    --app-surface-3: #2a2a30;
    --app-border: rgba(63, 63, 70, .7);
    --app-border-strong: #3f3f46;
    --app-text: #f4f4f5;
    --app-text-2: #d4d4d8;
    --app-muted: #a1a1aa;
    --app-faint: #71717a;
    --app-danger: #f87171; --app-danger-bg: #2a1616; --app-danger-border: #4c1d1d;
    --app-ok: #34d399; --app-ok-bg: #0f2a20;
    --app-info: #7dd3fc; --app-info-bg: #0f2233; --app-info-border: #1e3a56;
    --app-warn: #fbbf24; --app-warn-bg: #2a2011;
    --app-s1: #7dd3fc; --app-s1-bg: #0c2a3d;
    --app-s2: #fcd34d; --app-s2-bg: #3a2a08;
    --app-s3: #c4b5fd; --app-s3-bg: #2a1f4d;
    --app-s4: #6ee7b7; --app-s4-bg: #0b3324;
    --app-s5: #fda4af; --app-s5-bg: #3f1220;
    --app-s6: #5eead4; --app-s6-bg: #0b2f2c;
    --app-s7: #f0abfc; --app-s7-bg: #3b0f43;
    --app-s8: #d4d4d8; --app-s8-bg: #27272a;
    --app-shadow-soft: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
    --app-shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 24px 48px -16px rgba(0, 0, 0, .7);
    --app-nav-bg: #050506;
  }
  :root:not([data-theme="light"]) .btn-primary { --app-on-accent: #0b0b0c; --app-accent: #f4f4f5; }
}
:root[data-theme="dark"] {
  --app-accent-strong: color-mix(in srgb, var(--app-accent) 80%, #fff);
  --app-accent-soft: color-mix(in srgb, var(--app-accent) 18%, #141416);
  --app-bg: #0f0f11;
  --app-surface: #18181b;
  --app-surface-2: #202024;
  --app-surface-3: #2a2a30;
  --app-border: rgba(63, 63, 70, .7);
  --app-border-strong: #3f3f46;
  --app-text: #f4f4f5;
  --app-text-2: #d4d4d8;
  --app-muted: #a1a1aa;
  --app-faint: #71717a;
  --app-danger: #f87171; --app-danger-bg: #2a1616; --app-danger-border: #4c1d1d;
  --app-ok: #34d399; --app-ok-bg: #0f2a20;
  --app-info: #7dd3fc; --app-info-bg: #0f2233; --app-info-border: #1e3a56;
  --app-warn: #fbbf24; --app-warn-bg: #2a2011;
  --app-s1: #7dd3fc; --app-s1-bg: #0c2a3d;
  --app-s2: #fcd34d; --app-s2-bg: #3a2a08;
  --app-s3: #c4b5fd; --app-s3-bg: #2a1f4d;
  --app-s4: #6ee7b7; --app-s4-bg: #0b3324;
  --app-s5: #fda4af; --app-s5-bg: #3f1220;
  --app-s6: #5eead4; --app-s6-bg: #0b2f2c;
  --app-s7: #f0abfc; --app-s7-bg: #3b0f43;
  --app-s8: #d4d4d8; --app-s8-bg: #27272a;
  --app-shadow-soft: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
  --app-shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 24px 48px -16px rgba(0, 0, 0, .7);
  --app-nav-bg: #050506;
}
:root[data-theme="dark"] .btn-primary { --app-on-accent: #0b0b0c; --app-accent: #f4f4f5; }

/* ── base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light dark; -webkit-text-size-adjust: 100%; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  font: 14px/1.5 var(--app-font);
  color: var(--app-text);
  background: var(--app-bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01", "ss03";
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; letter-spacing: -.025em; text-wrap: balance; }
h1 { font-size: 1.55rem; font-weight: 700; line-height: 1.15; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background: var(--app-surface-2); border-radius: 4px; padding: .06em .32em; }
.muted { color: var(--app-muted); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; font-weight: 600; color: var(--app-muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 1.05em; height: 1.05em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.15em; }
::selection { background: var(--app-accent); color: var(--app-on-accent); }
:focus-visible { outline: 3px solid var(--app-accent-ring); outline-offset: 1px; }

/* motion — one pass, ≤ .3 s, the system's easing; none under reduced motion */
@keyframes app-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes app-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes app-slide-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes app-sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes app-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.reveal { animation: app-fade-up .3s var(--app-ease) both; }
.reveal-2 { animation: app-fade-up .3s var(--app-ease) .05s both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ── controls ──────────────────────────────────────────────────────────── */
:where(.input, input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea) {
  width: 100%;
  padding: .58rem .8rem;
  border: 1px solid var(--app-border-strong);
  border-radius: var(--app-radius-sm);
  background: var(--app-surface);
  color: var(--app-text);
  font: inherit;
  font-size: .94rem;
  min-height: 2.6rem;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--app-faint); }
:where(input, select, textarea):hover { border-color: var(--app-muted); }
:where(input, select, textarea):focus { outline: none; border-color: var(--app-accent); box-shadow: 0 0 0 4px var(--app-accent-ring); }
:where(input, select, textarea):disabled { background: var(--app-surface-2); color: var(--app-muted); cursor: not-allowed; }
textarea { min-height: 6rem; resize: vertical; line-height: 1.45; }
textarea.short { min-height: 3.2rem; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; }
:where(select) { appearance: none; -webkit-appearance: none; padding-right: 2.2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; }
select.compact { min-height: 2.25rem; padding: .3rem 2rem .3rem .7rem; font-size: .86rem; border-radius: 999px; width: auto; max-width: 14rem; }
.field-err input, .field-err select, .field-err textarea, .field-err .chips { border-color: var(--app-danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--app-danger) 20%, transparent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1rem;
  border: 1px solid var(--app-border-strong);
  border-radius: var(--app-radius-sm);
  background: var(--app-surface);
  color: var(--app-text);
  font: inherit; font-weight: 600; font-size: .9rem;
  min-height: 2.6rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .15s var(--app-ease), box-shadow .15s;
}
.btn:hover { background: var(--app-surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--app-accent); border-color: var(--app-accent); color: var(--app-on-accent); box-shadow: var(--app-accent-glow); }
.btn-primary:hover { background: var(--app-accent-strong); border-color: var(--app-accent-strong); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--app-text-2); }
.btn-ghost:hover { background: var(--app-surface-2); color: var(--app-text); }
.btn-danger { color: var(--app-danger); border-color: var(--app-danger-border); background: var(--app-surface); }
.btn-danger:hover { background: var(--app-danger-bg); }
.btn-danger.solid { background: var(--app-danger); border-color: var(--app-danger); color: #fff; }
.btn-sm { min-height: 2.15rem; padding: .3rem .7rem; font-size: .84rem; }
.btn-icon { padding: .45rem; width: 2.4rem; min-height: 2.4rem; border-radius: 999px; }
.btn-icon.btn-sm { width: 2.15rem; min-height: 2.15rem; }
.btn .spin { width: .95em; height: .95em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 999px; animation: app-spin .7s linear infinite; }
@keyframes app-spin { to { transform: rotate(360deg); } }

/* chips: enum (neutral outline) and lifecycle (positional color + dot) */
.chip {
  display: inline-flex; align-items: center; gap: .38rem;
  padding: .2rem .62rem;
  border-radius: 999px;
  border: 1px solid var(--app-border-strong);
  background: var(--app-surface);
  color: var(--app-text-2);
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  line-height: 1.5; white-space: nowrap; max-width: 100%;
}
.chip .dot { width: .45rem; height: .45rem; border-radius: 999px; background: currentColor; flex: none; }
.chip.state { border-color: transparent; text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; }
.chip.s1 { color: var(--app-s1); background: var(--app-s1-bg); }
.chip.s2 { color: var(--app-s2); background: var(--app-s2-bg); }
.chip.s3 { color: var(--app-s3); background: var(--app-s3-bg); }
.chip.s4 { color: var(--app-s4); background: var(--app-s4-bg); }
.chip.s5 { color: var(--app-s5); background: var(--app-s5-bg); }
.chip.s6 { color: var(--app-s6); background: var(--app-s6-bg); }
.chip.s7 { color: var(--app-s7); background: var(--app-s7-bg); }
.chip.s8 { color: var(--app-s8); background: var(--app-s8-bg); }
.chip.terminal .dot { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.chip.on { color: var(--app-ok); background: var(--app-ok-bg); border-color: transparent; }
.chip.off { color: var(--app-muted); background: var(--app-surface-2); border-color: transparent; }
.chip.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-transform: none; letter-spacing: 0; }

/* chip-radio group (state field in forms, filters) */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .3rem 0; }
.chips label { cursor: pointer; }
.chips input { position: absolute; opacity: 0; width: 0; height: 0; }
.chips .chip { transition: transform .15s var(--app-ease), box-shadow .15s; }
.chips input:checked + .chip { box-shadow: 0 0 0 2px var(--app-surface), 0 0 0 4px currentColor; }
.chips input:focus-visible + .chip { outline: 3px solid var(--app-accent-ring); }
.chips label:hover .chip { transform: translateY(-1px); }
.chips .arrow { color: var(--app-faint); align-self: center; font-size: .9rem; }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; min-height: 2rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 2.5rem; height: 1.45rem; border-radius: 999px; background: var(--app-surface-3); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: .17rem; left: .17rem; width: 1.1rem; height: 1.1rem; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--app-ease); }
.switch input:checked + .track { background: var(--app-accent); }
.switch input:checked + .track::after { transform: translateX(1.05rem); }
.switch input:focus-visible + .track { outline: 3px solid var(--app-accent-ring); }
.switch .lbl { font-size: .92rem; color: var(--app-text-2); }

/* avatar / monogram */
.avatar { display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: .6rem; background: var(--app-accent); color: var(--app-on-accent); font-weight: 700; font-size: .78rem; letter-spacing: .02em; flex: none; }
.avatar.round { border-radius: 999px; }
.avatar.sm { width: 1.6rem; height: 1.6rem; font-size: .62rem; border-radius: .45rem; }
.avatar.dim { background: var(--app-surface-3); color: var(--app-muted); }

/* ── the consumer's return bar (ENG-46): text + one link, above everything ── */
.consumer-bar {
  position: sticky; top: 0; z-index: 70;
  background: var(--app-accent); color: var(--app-on-accent);
  font-size: .84rem; font-weight: 600; text-align: center;
  padding: .45rem 1rem; min-height: 2.25rem; display: flex; align-items: center; justify-content: center;
}
.consumer-bar a { color: inherit; text-decoration: none; }
.consumer-bar a::after { content: " →"; opacity: .8; }
.consumer-bar a:hover { text-decoration: underline; }
body.has-bar .corner { top: 3rem; }
body.has-bar nav.side { height: calc(100dvh - 2.25rem); top: 2.25rem; }
body.has-bar .login-wrap { min-height: calc(100dvh - 2.25rem); }
@media (max-width: 900px) {
  body.has-bar .topbar { top: 2.25rem; }
  body.has-bar nav.side { top: 0; height: 100dvh; }
}

/* ── login ─────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-brand {
  background: var(--app-ink); color: #fff; position: relative; overflow: hidden;
  padding: clamp(1.6rem, 5vw, 4rem);
  display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
}
.login-brand::before {
  content: ""; position: absolute; inset: -20% -10% auto auto; width: 60%; aspect-ratio: 1; border-radius: 999px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--app-accent) 40%, transparent), transparent 70%);
  opacity: .9; pointer-events: none;
}
.login-brand .eyebrow { color: rgba(255,255,255,.55); }
.login-brand .word { font-size: clamp(2.6rem, 6vw, 4.6rem); font-weight: 760; letter-spacing: -.05em; line-height: .95; margin-top: .6rem; overflow-wrap: anywhere; }
.login-brand .claim { margin-top: 1rem; color: rgba(255,255,255,.7); font-size: 1rem; max-width: 30rem; text-wrap: pretty; }
.login-brand .foot { font-size: .8rem; color: rgba(255,255,255,.45); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.login-brand .foot code { background: rgba(255,255,255,.1); color: rgba(255,255,255,.8); }
.login-side { display: grid; place-items: center; padding: 1.5rem; }
.login {
  width: min(24rem, 100%);
  display: flex; flex-direction: column; gap: .8rem;
}
.login h1 { font-size: 1.4rem; }
.login .sub { color: var(--app-muted); font-size: .9rem; margin-top: -.3rem; }
.login label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; font-weight: 600; color: var(--app-text-2); }
.login .row { display: flex; gap: .55rem; margin-top: .2rem; }
.login .row .btn { flex: 1; }
.login small { color: var(--app-muted); font-size: .8rem; line-height: 1.45; }
.corner { position: fixed; top: .8rem; right: .9rem; display: flex; gap: .3rem; z-index: 30; }

/* ── shell ─────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--app-nav-w) minmax(0, 1fr); min-height: 100dvh; }
nav.side {
  background: var(--app-nav-bg); color: var(--app-nav-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  padding: 1.1rem .8rem 1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: .3rem .5rem .9rem; border-bottom: 1px solid var(--app-nav-border); margin-bottom: .6rem; }
.brand .avatar { background: rgba(255,255,255,.12); color: #fff; }
.brand .name { color: var(--app-nav-text-strong); font-weight: 700; letter-spacing: -.03em; font-size: 1.05rem; line-height: 1.15; overflow-wrap: anywhere; }
.brand .sub { font-size: .72rem; color: rgba(255,255,255,.45); font-variant-numeric: tabular-nums; }
nav.side h2 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em; color: rgba(255,255,255,.4); margin: .9rem .6rem .35rem; font-weight: 600; }
nav.side ul { list-style: none; margin: 0; padding: 0; }
nav.side li a, nav.side li.item {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .55rem; border-radius: .6rem; cursor: pointer;
  color: var(--app-nav-text); text-decoration: none; font-weight: 500; font-size: .9rem;
  transition: background .15s, color .15s; position: relative;
}
nav.side li.item:hover { background: var(--app-nav-hover); color: var(--app-nav-text-strong); }
nav.side li.item.active { background: var(--app-nav-active); color: var(--app-nav-text-strong); }
nav.side li.item.active::before { content: ""; position: absolute; left: -.8rem; top: 50%; transform: translateY(-50%); width: 3px; height: 1.2rem; border-radius: 0 3px 3px 0; background: var(--app-nav-dot); }
nav.side li.item .mono { width: 1.7rem; height: 1.7rem; border-radius: .5rem; background: rgba(255,255,255,.08); color: rgba(255,255,255,.8); font-size: .66rem; font-weight: 700; display: grid; place-items: center; letter-spacing: .04em; flex: none; }
nav.side li.item.active .mono { background: var(--app-nav-dot); color: var(--app-ink); }
nav.side li.item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav.side li.item .count { font-size: .72rem; font-variant-numeric: tabular-nums; color: rgba(255,255,255,.5); background: rgba(255,255,255,.07); border-radius: 999px; padding: .05rem .5rem; }
nav.side li.item.active .count { color: var(--app-nav-text-strong); background: rgba(255,255,255,.12); }
nav.side li.item.denied { opacity: .38; cursor: not-allowed; }
nav.side li.item.virtual { cursor: default; color: rgba(255,255,255,.5); }
nav.side .grow { flex: 1; }
.userblock { border-top: 1px solid var(--app-nav-border); margin-top: .8rem; padding-top: .8rem; display: flex; align-items: center; gap: .6rem; }
.userblock .avatar { background: rgba(255,255,255,.12); color: #fff; }
.userblock .who { flex: 1; min-width: 0; }
.userblock .who b { display: block; color: var(--app-nav-text-strong); font-size: .84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userblock .who span { font-size: .72rem; color: rgba(255,255,255,.5); }
.prefs { display: flex; gap: .15rem; margin-top: .5rem; }
.prefs .btn { color: rgba(255,255,255,.65); border-color: transparent; background: transparent; }
.prefs .btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.corner .btn-ghost { background: var(--app-surface); border-color: var(--app-border); }

/* mobile topbar + drawer */
.topbar { display: none; }
.drawer-bg { display: none; }

main.main { min-width: 0; display: flex; flex-direction: column; }
.page { padding: 1.6rem 2rem 3rem; max-width: 96rem; width: 100%; }

/* ── page header ───────────────────────────────────────────────────────── */
.phead { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.phead .sub { color: var(--app-muted); margin-top: .3rem; font-size: .92rem; }
.phead .actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.toolbar { display: flex; align-items: center; gap: .55rem; margin-bottom: .9rem; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 14rem; max-width: 22rem; }
.search svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--app-faint); pointer-events: none; }
.search input { padding-left: 2.3rem; border-radius: 999px; min-height: 2.5rem; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--app-surface-2); border-radius: 999px; padding: .2rem; gap: .1rem; }
.seg button { border: none; background: transparent; color: var(--app-muted); padding: .32rem .75rem; border-radius: 999px; font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; min-height: 2.1rem; transition: background .15s, color .15s; }
.seg button.on { background: var(--app-surface); color: var(--app-text); box-shadow: var(--app-shadow-soft); }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.filters .clear { color: var(--app-muted); font-size: .82rem; }

/* ── cards ─────────────────────────────────────────────────────────────── */
.card { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius-lg); box-shadow: var(--app-shadow-soft); }
.card-dark { background: var(--app-ink-800); color: #fff; border: 1px solid rgba(255,255,255,.1); border-radius: var(--app-radius-lg); box-shadow: var(--app-shadow-lift); }

/* home: stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .9rem; }
.stat { padding: 1.1rem 1.2rem 1rem; display: flex; flex-direction: column; gap: .2rem; cursor: pointer; text-decoration: none; color: inherit; transition: transform .2s var(--app-ease), box-shadow .2s; position: relative; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--app-shadow-lift); }
.stat .lbl { font-size: .82rem; font-weight: 600; color: var(--app-text-2); display: flex; align-items: center; gap: .5rem; min-width: 0; }
.stat .lbl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .n { font-size: 2rem; font-weight: 700; letter-spacing: -.04em; line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: .3rem; }
.stat .hint { font-size: .78rem; color: var(--app-muted); }
.stat .go { position: absolute; right: 1rem; top: 1rem; color: var(--app-faint); transition: color .15s, transform .2s var(--app-ease); }
.stat:hover .go { color: var(--app-text); transform: translateX(2px); }
.stat.denied { cursor: not-allowed; opacity: .55; }
.stat.denied:hover { transform: none; box-shadow: var(--app-shadow-soft); }
.home-hero { padding: 1.6rem 1.7rem; margin-bottom: 1.2rem; display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.home-hero .eyebrow { color: rgba(255,255,255,.5); }
.home-hero h1 { font-size: 1.9rem; color: #fff; margin-top: .3rem; }
.home-hero p { color: rgba(255,255,255,.65); margin-top: .4rem; max-width: 40rem; }
.home-hero .kpis { display: flex; gap: 1.6rem; }
.home-hero .kpi b { display: block; font-size: 1.6rem; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.home-hero .kpi b.txt { font-size: 1.05rem; margin-top: .45rem; }
.home-hero .kpi span { font-size: .74rem; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .1em; }

/* ── table ─────────────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .62rem .95rem; border-bottom: 1px solid var(--app-border); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 1.2rem; }
th:last-child, td:last-child { padding-right: 1rem; }
thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em; font-weight: 600;
  color: var(--app-muted); white-space: nowrap; background: var(--app-surface);
  position: sticky; top: 0; z-index: 1;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--app-text); }
thead th .sk { display: inline-flex; align-items: center; gap: .3rem; }
thead th .sk svg { opacity: 0; transition: opacity .15s; width: .8rem; height: .8rem; }
thead th.sortable:hover .sk svg, thead th.sorted .sk svg { opacity: 1; }
thead th.sorted { color: var(--app-text); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--app-surface-2); }
tbody tr.clickable { cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }
td { font-size: .92rem; max-width: 22rem; }
td .cell { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.primary .cell { font-weight: 600; color: var(--app-text); }
td .rel { color: var(--app-text-2); }
td .date { color: var(--app-text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
td .nil { color: var(--app-faint); }
td.rowact { text-align: right; white-space: nowrap; width: 1%; }
td.rowact .btn { opacity: 0; transition: opacity .15s; }
tbody tr:hover td.rowact .btn, td.rowact .btn:focus-visible { opacity: 1; }
.tfoot { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .7rem 1.2rem; border-top: 1px solid var(--app-border); font-size: .84rem; color: var(--app-muted); flex-wrap: wrap; }
.tfoot .pg { display: flex; gap: .3rem; align-items: center; }
.tfoot .pg .btn { min-height: 2.1rem; padding: .25rem .7rem; font-size: .82rem; }
.tfoot .pg .btn.btn-icon { padding: .25rem .45rem; }
.tfoot .pg .btn:disabled { opacity: .35; cursor: default; }
.tfoot .per { display: inline-flex; align-items: center; gap: .4rem; margin-right: .5rem; }
.tfoot .per select.compact { min-height: 2.1rem; padding: .15rem 1.6rem .15rem .5rem; font-size: .82rem; }
.tfoot .goto { display: inline-flex; align-items: center; gap: .3rem; }
.tfoot .goto input { width: 3.6rem; min-height: 2.1rem; padding: .15rem .4rem; font-size: .82rem; text-align: center; }
.tfoot .goto input::-webkit-outer-spin-button, .tfoot .goto input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tfoot .timing { color: var(--app-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tfoot .where em.dim { font-style: normal; color: var(--app-faint); }

/* skeleton (a loading state — the only looping animation, gone with the data) */
.skel-rows { padding: .4rem 1.2rem .8rem; }
.skel-row { display: grid; grid-template-columns: 2.5fr 1.5fr 1fr 1fr .6fr; gap: 1.2rem; padding: .78rem 0; border-bottom: 1px solid var(--app-border); }
.skel-row:last-child { border-bottom: none; }
.skel { height: .8rem; border-radius: 6px; background: linear-gradient(90deg, var(--app-surface-2) 25%, var(--app-surface-3) 50%, var(--app-surface-2) 75%); background-size: 200% 100%; animation: app-shimmer 1.4s linear infinite; }
.skel.card-skel { height: 3.4rem; border-radius: .6rem; }
.skel.w60 { width: 60%; } .skel.w40 { width: 40%; } .skel.w80 { width: 80%; } .skel.pill { width: 4.5rem; height: 1.2rem; border-radius: 999px; }

/* empty + error states */
.empty { padding: 3rem 1.5rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.empty .ico { width: 3rem; height: 3rem; border-radius: 1rem; display: grid; place-items: center; background: var(--app-surface-2); color: var(--app-muted); margin-bottom: .3rem; }
.empty b { font-size: 1rem; font-weight: 650; }
.empty p { color: var(--app-muted); max-width: 26rem; font-size: .9rem; }
.empty .btn { margin-top: .6rem; }
.banner { padding: .7rem .95rem; border-radius: var(--app-radius-sm); margin: .5rem 0; font-size: .9rem; display: flex; gap: .6rem; align-items: flex-start; line-height: 1.45; }
.banner svg { margin-top: .15rem; }
.banner.err { background: var(--app-danger-bg); color: var(--app-danger); border: 1px solid var(--app-danger-border); }
.banner.info { background: var(--app-info-bg); color: var(--app-info); border: 1px solid var(--app-info-border); }
.banner.info code { background: color-mix(in srgb, var(--app-info) 14%, transparent); }
.banner .btn { margin-left: auto; min-height: 1.9rem; padding: .15rem .6rem; font-size: .82rem; }
.fatal { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.fatal .card { padding: 1.5rem; max-width: 30rem; }

/* ── board (kanban derived from the state machine; columns by position) ── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(16rem, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .8rem; align-items: start; scroll-snap-type: x proximity; }
.col { background: color-mix(in srgb, var(--app-surface-2) 70%, transparent); border-radius: var(--app-radius); padding: .6rem; min-height: 12rem; display: flex; flex-direction: column; gap: .5rem; scroll-snap-align: start; transition: background .15s, box-shadow .15s; }
.col.over { background: var(--app-accent-soft); box-shadow: inset 0 0 0 2px var(--app-accent); }
.col.illegal { opacity: .55; }
.col > header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem .35rem .35rem; }
.col > header .count { font-size: .76rem; color: var(--app-muted); font-variant-numeric: tabular-nums; }
.kcard { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius-sm); padding: .65rem .8rem; box-shadow: var(--app-shadow-soft); cursor: grab; transition: transform .2s var(--app-ease), box-shadow .2s, opacity .15s; }
.kcard:hover { transform: translateY(-1px); box-shadow: var(--app-shadow-lift); }
.kcard.dragging { opacity: .45; transform: rotate(1.5deg); }
.kcard b { display: block; font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .kv { display: flex; justify-content: space-between; gap: .6rem; font-size: .8rem; color: var(--app-muted); margin-top: .2rem; }
.kcard .kv span:last-child { color: var(--app-text-2); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .moves { display: none; gap: .3rem; flex-wrap: wrap; margin-top: .5rem; }
.col .more { font-size: .8rem; color: var(--app-muted); text-align: center; padding: .3rem; }
.col .more.dim { opacity: .6; }
.kcard .mv { cursor: pointer; }

/* ── toolbar tools group, selection column, bulk bar, progress panel (APP-PODER-S1) ── */
.toolbar .tools { display: flex; gap: .2rem; align-items: center; flex-wrap: wrap; }
.toolbar .tools #sel-page-btn { display: none; }   /* phones only: the card layout has no header checkbox */
th.selc, td.selc { width: 1%; padding-right: .2rem; }
th.selc input, td.selc input { width: 1.05rem; height: 1.05rem; min-height: 0; accent-color: var(--app-accent); cursor: pointer; margin: 0; }
tbody tr.selected { background: color-mix(in srgb, var(--app-accent) 7%, transparent); }
.bulkbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .6rem 1.2rem; border-bottom: 1px solid var(--app-border); background: color-mix(in srgb, var(--app-accent) 6%, var(--app-surface)); font-size: .88rem; }
.bulkbar select.compact { min-height: 2.1rem; font-size: .84rem; }
.bulkbar .btn-sm { min-height: 2.1rem; }
.bulk-confirm { margin: .6rem 1.2rem; }
.bulk-confirm .names { margin: .3rem 0 .2rem; padding-left: 1.1rem; font-size: .88rem; columns: 2; }
.bulk-confirm .names li.dim { list-style: none; margin-left: -1.1rem; }
.bulk-confirm.danger { border-color: var(--app-danger-border); }
.progress { margin: .6rem 1.2rem; padding: .7rem .9rem; border: 1px solid var(--app-border); border-radius: var(--app-radius-sm); background: var(--app-surface-2); font-size: .86rem; }
.progress .ptitle { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-weight: 600; margin-bottom: .4rem; }
.progress .pbar { height: .45rem; border-radius: 999px; background: var(--app-border); overflow: hidden; }
.progress .pfill { height: 100%; background: var(--app-accent); transition: width .25s; }
.progress.ok .pfill { background: var(--app-ok); }
.progress.err .pfill { background: var(--app-danger); }
.progress .pmsg { margin-top: .35rem; color: var(--app-muted); }
.progress .plog { margin-top: .4rem; display: flex; flex-direction: column; gap: .2rem; max-height: 14rem; overflow: auto; }
.progress .pline { display: flex; gap: .4rem; align-items: flex-start; }
.progress .pline.err { color: var(--app-danger); }
.progress .pline.warn { color: var(--app-warn); }
.progress .pline svg { flex: none; margin-top: .15rem; }
@media (max-width: 900px) { .bulk-confirm .names { columns: 1; } }

/* ── popovers (columns, views): anchored to their button, one open at a time ── */
[hidden] { display: none !important; }   /* a class with its own display (flex/grid) must still honor the hidden attribute */
.menu-wrap { position: relative; }
.menu-wrap .btn .count { background: color-mix(in srgb, var(--app-accent) 14%, transparent); color: var(--app-accent); border-radius: 999px; padding: 0 .4rem; font-size: .72rem; margin-left: .2rem; }
.popover { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20; min-width: 15rem; max-width: 22rem; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius-sm); box-shadow: var(--app-shadow-lg, 0 12px 32px rgba(0,0,0,.14)); padding: .6rem; display: flex; flex-direction: column; gap: .5rem; }
.popover .plist { list-style: none; margin: 0; padding: 0; max-height: 40vh; overflow: auto; }
.popover .plist li { display: flex; align-items: center; gap: .3rem; }
.popover .plist li > button.apply-view { flex: 1; text-align: left; background: none; border: 0; padding: .35rem .4rem; border-radius: 6px; cursor: pointer; color: var(--app-text); font: inherit; }
.popover .plist li > button.apply-view:hover { background: var(--app-surface-2); }
.popover .plist.cols label { display: flex; align-items: center; gap: .5rem; padding: .25rem .3rem; cursor: pointer; font-size: .9rem; }
.popover .plist.cols input { width: auto; min-height: 0; accent-color: var(--app-accent); }
.popover .row { display: flex; gap: .4rem; align-items: center; }
.popover .row input[type=text] { flex: 1; min-height: 2.1rem; padding: .2rem .5rem; font-size: .85rem; }
.popover p.dim { margin: 0; font-size: .82rem; color: var(--app-muted); }
@media (max-width: 900px) { .popover { position: fixed; left: .8rem; right: .8rem; top: auto; bottom: 1rem; max-width: none; } }

/* ── detail (APP-PODER-S1): fields, lifecycle strip, parents, children, files ── */
.detail .phead .sub.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }
.detail #d-back { margin-bottom: .4rem; padding-left: .2rem; }
.dgrid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.dcol { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.block { padding: 1rem 1.2rem; }
.block h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--app-muted); font-weight: 600; margin: 0 0 .7rem; }
.block h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.block.dim p { color: var(--app-muted); font-size: .9rem; margin: 0; }
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .8rem 1.2rem; }
.dt { min-width: 0; }
.dt.full { grid-column: 1 / -1; }
.dt > span { display: block; font-size: .74rem; color: var(--app-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .2rem; }
.dt .dd { font-size: .95rem; overflow-wrap: anywhere; }
.dt .dd .txt { white-space: pre-wrap; }
.dt .dd .nil, .dd.nil, .nil { color: var(--app-faint); }
pre.json { margin: .3rem 0 0; padding: .7rem .8rem; background: var(--app-surface-2); border-radius: var(--app-radius-sm); font: .8rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: auto; max-height: 22rem; white-space: pre; }
.chip.warn { background: var(--app-warn-bg, color-mix(in srgb, #d97706 14%, transparent)); color: var(--app-warn, #b45309); border-color: transparent; }
.lifecycle { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.lifecycle .step { opacity: .55; transition: opacity .15s; }
.lifecycle .step.now { opacity: 1; outline: 2px solid var(--app-accent); outline-offset: 2px; border-radius: 999px; }
.lifecycle .arr { color: var(--app-faint); display: inline-flex; }
.lifecycle .arr svg { width: .9rem; height: .9rem; }
#d-life .moves { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
#d-life .ro { display: inline-flex; align-items: center; gap: .3rem; margin-top: .6rem; color: var(--app-muted); font-size: .85rem; }
.relrow { display: flex; align-items: center; gap: .8rem; }
.relrow > div { min-width: 0; flex: 1; }
.relrow b { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relrow .peek { display: flex; flex-wrap: wrap; gap: .2rem .9rem; color: var(--app-text-2); font-size: .82rem; margin-top: .15rem; }
.relrow .peek em { font-style: normal; color: var(--app-muted); }
.relrow .btn { flex: none; }
.count-line { margin-bottom: .5rem; }
.count-line b { font-size: 1.3rem; font-weight: 700; }
.peeklist { list-style: none; margin: 0 0 .6rem; padding: 0; }
.peeklist li { display: flex; align-items: center; gap: .5rem; padding: .45rem 0; border-top: 1px solid var(--app-border); cursor: pointer; font-size: .9rem; }
.peeklist li:first-child { border-top: none; }
.peeklist li > span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peeklist li svg { color: var(--app-faint); }
.peeklist li:hover > span:first-child { color: var(--app-accent); }
.chip.pin { gap: .3rem; }
.chip.pin .unpin { background: none; border: 0; padding: 0; margin-left: .1rem; display: inline-flex; cursor: pointer; color: inherit; }
.chip.pin .unpin svg { width: .75rem; height: .75rem; }
.dd img.preview { max-width: 100%; max-height: 14rem; border-radius: var(--app-radius-sm); display: block; margin-bottom: .4rem; }
@media (max-width: 900px) { .dgrid { grid-template-columns: 1fr; } }

/* ── relation search (Part F): an input with a result list under it ── */
.relsearch { position: relative; }
.relsearch .relopts { position: absolute; left: 0; right: 0; top: 100%; z-index: 15; margin: .2rem 0 0; padding: .3rem; list-style: none; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius-sm); box-shadow: var(--app-shadow-lg, 0 12px 32px rgba(0,0,0,.14)); max-height: 14rem; overflow: auto; }
.relsearch .relopts li { padding: .4rem .55rem; border-radius: 6px; cursor: pointer; font-size: .9rem; }
.relsearch .relopts li:hover { background: var(--app-surface-2); }
.relsearch .relopts li.dim { color: var(--app-muted); cursor: default; }

/* ── JSON editor (APP-PODER-S1): highlight layer under a transparent textarea ── */
.jsoned { display: flex; flex-direction: column; gap: .4rem; }
.jtools { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.jtools .jstate { font-size: .78rem; color: var(--app-muted); }
.jtools .jstate.bad { color: var(--app-danger); }
.jtools .jstate.ok { color: var(--app-ok, #15803d); }
.jwrap { position: relative; border: 1px solid var(--app-border); border-radius: var(--app-radius-sm); background: var(--app-surface-2); overflow: hidden; }
.jsoned.invalid .jwrap { border-color: var(--app-danger-border); }
.jwrap .jhl, .jwrap textarea { margin: 0; padding: .7rem .8rem; font: .82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; white-space: pre; overflow-wrap: normal; min-height: 10rem; max-height: 60vh; }
.jwrap .jhl { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: var(--app-text); }
.jwrap textarea { position: relative; width: 100%; resize: vertical; background: transparent; color: transparent; caret-color: var(--app-text); border: 0; box-shadow: none; overflow: auto; display: block; }
.jwrap textarea::selection { background: color-mix(in srgb, var(--app-accent) 25%, transparent); }
.jwrap textarea:focus { outline: none; box-shadow: none; }
.jhl .k { font-style: normal; color: var(--app-accent); }
.jhl .s, .jtree .s { font-style: normal; color: #0f766e; }
.jhl .n, .jtree .n { font-style: normal; color: #b45309; }
.jhl .b, .jtree .b { font-style: normal; color: #7c3aed; }
.jhl .z, .jtree .z, .jtree .p { font-style: normal; color: var(--app-muted); }
.jtree { border: 1px solid var(--app-border); border-radius: var(--app-radius-sm); background: var(--app-surface-2); padding: .6rem .8rem; font: .82rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 60vh; overflow: auto; }
.jtree ul { list-style: none; margin: 0; padding-left: 1.1rem; }
.jtree details > summary { cursor: pointer; list-style: none; display: inline; }
.jtree details > summary::before { content: '▸ '; color: var(--app-faint); font-size: .7rem; }
.jtree details[open] > summary::before { content: '▾ '; }
.jtree .k { font-style: normal; color: var(--app-accent); }
.jwarn .banner { margin: .2rem 0 0; font-size: .82rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .jhl .s, :root:not([data-theme="light"]) .jtree .s { color: #5eead4; } :root:not([data-theme="light"]) .jhl .n, :root:not([data-theme="light"]) .jtree .n { color: #fbbf24; } :root:not([data-theme="light"]) .jhl .b, :root:not([data-theme="light"]) .jtree .b { color: #c4b5fd; } }
:root[data-theme="dark"] .jhl .s, :root[data-theme="dark"] .jtree .s { color: #5eead4; }
:root[data-theme="dark"] .jhl .n, :root[data-theme="dark"] .jtree .n { color: #fbbf24; }
:root[data-theme="dark"] .jhl .b, :root[data-theme="dark"] .jtree .b { color: #c4b5fd; }

/* ── drawer (form) ─────────────────────────────────────────────────────── */
.drawer-bgd { position: fixed; inset: 0; background: rgba(11, 11, 12, .45); z-index: 50; animation: app-fade .2s both; display: flex; justify-content: flex-end; }
.drawer { background: var(--app-surface); width: min(34rem, 100%); height: 100dvh; display: flex; flex-direction: column; box-shadow: var(--app-shadow-lift); animation: app-slide-in .26s var(--app-ease) both; }
.drawer > header { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.4rem .9rem; border-bottom: 1px solid var(--app-border); }
.drawer > header .ttl { flex: 1; min-width: 0; }
.drawer > header .ttl .eyebrow { margin-bottom: .15rem; }
.drawer > header h2 { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer .body { flex: 1; overflow-y: auto; padding: 1.1rem 1.4rem; }
.drawer form { display: flex; flex-direction: column; gap: .95rem; }
.drawer > footer { display: flex; gap: .5rem; padding: .9rem 1.4rem; border-top: 1px solid var(--app-border); background: var(--app-surface); }
.drawer > footer .grow { flex: 1; }
.f { display: flex; flex-direction: column; gap: .32rem; }
.f > label, .f > .lbl { font-size: .8rem; font-weight: 600; color: var(--app-text-2); display: flex; gap: .3rem; align-items: baseline; }
.f .req { color: var(--app-danger); }
.f .help { font-size: .76rem; color: var(--app-muted); }
.f .ferr { color: var(--app-danger); font-size: .78rem; font-style: normal; display: none; }
.f.field-err .ferr { display: block; }
.f .ro { padding: .55rem .8rem; border-radius: var(--app-radius-sm); background: var(--app-surface-2); color: var(--app-muted); font-size: .9rem; display: flex; align-items: center; gap: .5rem; }
.filewrap { display: flex; flex-direction: column; gap: .5rem; }
.filewrap .pick { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.filewrap input[type=file] { display: none; }
.filewrap .fname { font-size: .84rem; color: var(--app-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.filewrap img.preview { max-height: 9rem; max-width: 100%; border-radius: var(--app-radius-sm); border: 1px solid var(--app-border); object-fit: cover; }
.filewrap .ok { color: var(--app-ok); font-size: .82rem; }
.filewrap .err { color: var(--app-danger); font-size: .82rem; }
.confirm { background: var(--app-danger-bg); border: 1px solid var(--app-danger-border); border-radius: var(--app-radius-sm); padding: .8rem .95rem; display: flex; flex-direction: column; gap: .6rem; margin-bottom: .9rem; }
.confirm b { color: var(--app-danger); font-size: .92rem; }
.confirm .hint { font-size: .84rem; }
.confirm .row { display: flex; gap: .5rem; justify-content: flex-end; }

/* ── toasts ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 90; display: flex; flex-direction: column; gap: .5rem; max-width: min(24rem, calc(100vw - 2rem)); }
.toast { background: var(--app-ink-800); color: #fff; border-radius: var(--app-radius-sm); padding: .65rem .9rem; box-shadow: var(--app-shadow-lift); display: flex; gap: .6rem; align-items: flex-start; font-size: .88rem; animation: app-sheet-up .25s var(--app-ease) both; border-left: 3px solid var(--app-ok); }
.toast.err { border-left-color: var(--app-danger); }
.toast.info { border-left-color: var(--app-info); }
.toast svg { margin-top: .12rem; flex: none; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

/* demo-mode notice: discreet, persistent, never modal */
.demobar {
  position: fixed; left: 50%; bottom: .9rem; transform: translateX(-50%);
  z-index: 40; max-width: min(36rem, calc(100vw - 1.6rem));
  background: var(--app-warn-bg); color: var(--app-warn);
  border: 1px solid color-mix(in srgb, var(--app-warn) 30%, transparent);
  border-radius: 999px; padding: .45rem 1.1rem; font-size: .82rem; font-weight: 500;
  box-shadow: var(--app-shadow-lift); text-align: center; width: max-content;
  display: flex; gap: .5rem; align-items: center;
}
.demobar + .toasts { bottom: 3.6rem; }
.chip.demo { color: var(--app-warn); background: var(--app-warn-bg); border-color: transparent; }

/* pagination footer on narrow screens: the where/timing line first, the pager below, nothing overflows */
@media (max-width: 900px) {
  .tfoot { flex-direction: column; align-items: stretch; gap: .5rem; padding: .7rem .9rem; }
  .tfoot .pg { justify-content: space-between; flex-wrap: wrap; }
  .tfoot .per { margin-right: 0; }
  .tfoot .goto input { width: 3rem; }
}

/* ── mobile (≤ 900px): drawer nav, stacked cards, full-height sheet ─────── */
@media (max-width: 900px) {
  .shell { display: block; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 20;
    background: var(--app-surface); border-bottom: 1px solid var(--app-border);
    padding: .5rem .7rem; align-items: center; gap: .5rem;
  }
  .topbar .name { font-weight: 700; letter-spacing: -.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  nav.side {
    position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(20rem, 84vw); height: 100dvh;
    transform: translateX(-102%); transition: transform .26s var(--app-ease);
    box-shadow: var(--app-shadow-lift);
  }
  body.drawer-open nav.side { transform: none; }
  body.drawer-open .drawer-bg { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(11, 11, 12, .45); animation: app-fade .2s both; }
  .page { padding: 1rem .9rem 5rem; }
  h1 { font-size: 1.3rem; }
  .phead { margin-bottom: .8rem; }
  .phead .actions .btn-primary .txt { display: none; }
  .phead .actions .btn-primary { border-radius: 999px; width: 2.6rem; padding: 0; }
  .search { max-width: none; flex-basis: 100%; }
  .home-hero { padding: 1.2rem 1.1rem; }
  .home-hero h1 { font-size: 1.5rem; }
  .stats { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
  .stat { padding: .85rem .9rem; }
  .stat .n { font-size: 1.6rem; }

  .card.list { background: none; border: none; box-shadow: none; }
  .tablewrap { overflow: visible; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr {
    background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-soft); margin-bottom: .6rem; padding: .5rem .3rem;
  }
  tbody tr:hover { background: var(--app-surface); }
  td { border: none; padding: .26rem .8rem; display: flex; gap: .8rem; align-items: baseline; max-width: none; }
  td::before { content: attr(data-l); flex: 0 0 36%; max-width: 36%; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--app-muted); font-weight: 600; overflow-wrap: anywhere; padding-top: .15rem; }
  td .cell { flex: 1; white-space: normal; overflow-wrap: anywhere; }
  td.num { text-align: left; }
  td.primary { padding-top: .35rem; }
  td.primary::before { content: none; }
  td.primary .cell { font-size: 1rem; }
  td.rowact { justify-content: flex-end; padding-top: .1rem; width: auto; gap: .3rem; }
  td.rowact::before { content: none; }
  tbody tr { position: relative; }
  td.selc { position: absolute; top: .55rem; right: .7rem; padding: 0; width: auto; }
  td.selc::before { content: none; }
  td.primary { padding-right: 2.6rem; }
  .toolbar .tools #sel-page-btn { display: inline-flex; }
  td.rowact .btn { opacity: 1; }
  .tfoot { padding: .5rem .2rem; border-top: none; }

  .board { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; margin: 0 -.9rem; padding: 0 .9rem .8rem; }
  .kcard { cursor: pointer; }
  .kcard .moves { display: flex; }

  .drawer-bgd { align-items: flex-end; }
  .drawer { width: 100%; height: 94dvh; border-radius: var(--app-radius-lg) var(--app-radius-lg) 0 0; animation: app-sheet-up .28s var(--app-ease) both; }
  .drawer > footer { padding-bottom: max(.9rem, env(safe-area-inset-bottom)); }
  .drawer > footer .btn { flex: 1; }
  .demobar { width: calc(100vw - 1.4rem); max-width: none; border-radius: var(--app-radius-sm); bottom: .7rem; }
  .toasts { left: 1rem; right: 1rem; max-width: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { padding: 1.4rem 1.3rem 1.2rem; gap: .8rem; min-height: 0; }
  .login-brand .word { font-size: 2.2rem; }
  .login-brand .claim { display: none; }
  .login-brand .foot { display: none; }
  .login-side { align-items: start; padding: 1.4rem 1.2rem; }
  .corner { top: .6rem; right: .6rem; }
}
