/* Ponto — design system. Tokens first; components only read var(--…).
   Contrast values are measured (docs/BRAND.md), each on the surface it sits on. */

@font-face { font-family: "Inter"; src: url("/static/fonts/Inter-Medium.ttf") format("truetype"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/Inter-SemiBold.ttf") format("truetype"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/static/fonts/JetBrainsMono-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: light dark;
  --bg: #F6F5F1; --surface: #FFFFFF; --surface-2: #EFEEE8; --surface-3: #E6E4DC;
  --border: rgba(18, 26, 22, .10); --border-strong: rgba(18, 26, 22, .20);
  --text: #121A16; --text-2: #46524C; --text-3: #5F6A65;
  --accent: #146B52; --accent-ink: #FFFFFF;
  --success: #11713A; --warning: #8A5100; --danger: #B42318; --info: #1F5FBF;
  --focus: #1F5FBF;
  --shadow-1: 0 1px 2px rgba(18, 26, 22, .06), 0 1px 1px rgba(18, 26, 22, .04);
  --shadow-2: 0 12px 32px rgba(18, 26, 22, .12), 0 2px 8px rgba(18, 26, 22, .06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;
  --ease-tap: cubic-bezier(.2, 0, 0, 1); --ease-in: cubic-bezier(.05, .7, .1, 1); --ease-out: cubic-bezier(.3, 0, .8, .15);
  --sidebar: 256px;
  --cat-1: #146B52; --cat-2: #1F5FBF; --cat-3: #8A5100; --cat-4: #7C3AAD; --cat-5: #B42318; --cat-6: #3F6212;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1311; --surface: #151D1A; --surface-2: #1C2622; --surface-3: #24302B;
    --border: rgba(255, 255, 255, .09); --border-strong: rgba(255, 255, 255, .18);
    --text: #ECF1EE; --text-2: #A9B5AF; --text-3: #909C96;
    --accent: #3FBF94; --accent-ink: #0D1311;
    --success: #4CC774; --warning: #E8A33D; --danger: #F2705F; --info: #6EA2F5; --focus: #6EA2F5;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 16px 40px rgba(0, 0, 0, .5);
    --cat-1: #3FBF94; --cat-2: #6EA2F5; --cat-3: #E8A33D; --cat-4: #C49AF0; --cat-5: #F2705F; --cat-6: #A3D16A;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1311; --surface: #151D1A; --surface-2: #1C2622; --surface-3: #24302B;
  --border: rgba(255, 255, 255, .09); --border-strong: rgba(255, 255, 255, .18);
  --text: #ECF1EE; --text-2: #A9B5AF; --text-3: #909C96;
  --accent: #3FBF94; --accent-ink: #0D1311;
  --success: #4CC774; --warning: #E8A33D; --danger: #F2705F; --info: #6EA2F5; --focus: #6EA2F5;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 16px 40px rgba(0, 0, 0, .5);
  --cat-1: #3FBF94; --cat-2: #6EA2F5; --cat-3: #E8A33D; --cat-4: #C49AF0; --cat-5: #F2705F; --cat-6: #A3D16A;
}

/* -------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* component classes (.alert, .row…) must not resurrect hidden elements */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 500 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 120ms var(--ease-out) both fade-out; }
::view-transition-new(root) { animation: 220ms var(--ease-in) both fade-in; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 20px; }
h3, .h3 { font-size: 16px; }
p, figure, blockquote { margin: 0; }
a { color: inherit; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
img, svg { display: block; max-width: 100%; }
.i { width: 20px; height: 20px; flex: none; }
.i-sm { width: 16px; height: 16px; flex: none; }
.i-lg { width: 28px; height: 28px; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; z-index: 100; background: var(--surface); padding: 8px 16px; border-radius: var(--r-sm); }
.skip:focus { top: 16px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--text-2); }
.meta { color: var(--text-3); font-size: 13px; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 32px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* -------------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--surface); padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 8px 12px 16px; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; color: var(--text); }
.brand-logo { max-height: 32px; max-width: 140px; object-fit: contain; }
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.nav-group { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.nav-group + .nav-group { border-top: 1px solid var(--border); }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; transition: background-color 120ms var(--ease-tap), color 120ms var(--ease-tap);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-link[aria-current="page"] .i { color: var(--accent); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.me { display: flex; align-items: center; gap: 12px; padding: 8px 12px; text-decoration: none; border-radius: var(--r-sm); }
.me:hover { background: var(--surface-2); }
.me-name { display: block; font-weight: 600; font-size: 14px; }
.me-role { display: block; }
button.nav-link { width: 100%; border: 0; background: transparent; font: inherit; cursor: pointer; text-align: left; }
.me-role { font-size: 12px; color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.top-actions { display: flex; gap: 4px; align-items: center; }
.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 32px 64px; }
.page-narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--text-2); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); text-decoration: none; font-size: 14px; margin-bottom: 8px; min-height: 32px; }
.crumb:hover { color: var(--text); }

.tabbar {
  display: none; position: fixed; inset: auto 0 0 0; z-index: 30; background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-top: 1px solid var(--border); padding: 4px 4px max(4px, env(safe-area-inset-bottom));
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  grid-auto-flow: column; grid-auto-columns: 1fr;
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px;
  border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; font-size: 11px; font-weight: 600;
  background: none; border: 0; font-family: inherit; cursor: pointer;
}
.tab[aria-current="page"] { color: var(--accent); }
.tab .dot { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; display: grid; place-items: center; }

.drawer { padding: 0; border: 0; width: min(320px, 88vw); height: 100dvh; max-height: none; margin: 0 auto 0 0; background: var(--surface); color: var(--text); }
.drawer::backdrop { background: rgba(10, 14, 12, .45); }
.drawer[open] { animation: drawer-in 260ms var(--ease-in); }
.drawer .sidebar { position: static; height: 100%; border: 0; }
@keyframes drawer-in { from { transform: translateX(-24px); opacity: 0; } }

@media (max-width: 900px) {
  .shell { display: block; }
  .shell > .sidebar { display: none; }
  .topbar { display: flex; }
  .tabbar { display: grid; }
  .page { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 24px; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .hide-sm { display: none !important; }
}
@media (min-width: 901px) { .show-sm { display: none !important; } }

/* -------------------------------------------------------------------- buttons */
.btn {
  --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: var(--r-sm); border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font: 600 14px/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 100ms var(--ease-tap), background-color 120ms var(--ease-tap), box-shadow 120ms var(--ease-tap);
}
.btn:hover { background: color-mix(in srgb, var(--b-bg) 92%, var(--text)); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { --b-bg: var(--accent); --b-fg: var(--accent-ink); --b-bd: transparent; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); box-shadow: var(--shadow-1); }
.btn-danger { --b-bg: var(--surface); --b-fg: var(--danger); --b-bd: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer; position: relative; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .count { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; display: grid; place-items: center; }
form.inline { display: inline; }

/* -------------------------------------------------------------------- surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 24px; }
.card-tight { padding: 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2, .card-head h3, .h3 { font-size: 16px; }
.card-link { display: block; text-decoration: none; transition: border-color 120ms var(--ease-tap), box-shadow 120ms var(--ease-tap); }
.card-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi-value { font: 600 28px/1.1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-label { color: var(--text-2); font-size: 13px; }
.kpi-hint { color: var(--text-3); font-size: 12px; }
.kpi-accent .kpi-value { color: var(--accent); }

.stack-top { margin-top: 16px; }
.card-pad { padding: 16px 24px; margin: 0; }
.card-flush .card-head { margin-bottom: 0; border-bottom: 1px solid var(--border); }

/* -------------------------------------------------------------------- lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }
.list-link { display: flex; align-items: center; gap: 12px; text-decoration: none; flex: 1; min-width: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color 120ms var(--ease-tap); }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .num { text-align: right; white-space: nowrap; }
.table a.rowlink { text-decoration: none; font-weight: 600; }
.table a.rowlink:hover { text-decoration: underline; }
.table tr:has(a.rowlink) { position: relative; }
.table tr:has(a.rowlink):hover { background: var(--surface-2); }
.table a.rowlink::after { content: ""; position: absolute; inset: 0; }
.table tr:has(a.rowlink) :is(a, button, input, select, label, form):not(.rowlink) { position: relative; z-index: 1; }
.table tr:has(a.rowlink) td:has(input[type="checkbox"]) { position: relative; z-index: 1; }
.table td.mono { white-space: nowrap; }
.table tfoot td { font-weight: 600; background: var(--surface-2); }
.check { width: 18px; height: 18px; accent-color: var(--accent); }

/* -------------------------------------------------------------------- badges & avatars */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-plain::before { display: none; }
.b-success { background: color-mix(in srgb, var(--success) 14%, var(--surface)); color: var(--success); }
.b-warning { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); color: var(--warning); }
.b-danger { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.b-info { background: color-mix(in srgb, var(--info) 12%, var(--surface)); color: var(--info); }
.b-accent { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 50%, transparent); animation: pulse 2s var(--ease-in) infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; color: #fff; background: var(--cat-1); }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.av-1 { background: #146B52; } .av-2 { background: #1F5FBF; } .av-3 { background: #8A5300; } .av-4 { background: #6D2E9E; } .av-5 { background: #A3201A; } .av-6 { background: #3F6212; }

/* -------------------------------------------------------------------- forms */
.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text); }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: 500 15px/1.4 var(--font); transition: border-color 120ms var(--ease-tap), box-shadow 120ms var(--ease-tap);
}
.textarea { min-height: 96px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--text) 35%, transparent); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input[type="color"] { padding: 4px; width: 64px; height: 40px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.input-sm, .select-sm { min-height: 32px; font-size: 13px; padding: 4px 10px; }
.select-sm { padding-right: 32px; }
.checkline { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.checkline input { margin-top: 2px; }
.checkline span { font-size: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 140px; flex: 1 1 140px; }
.filters .field label { font-size: 12px; color: var(--text-2); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }

.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: var(--r-sm); flex-wrap: wrap; }
.seg a, .seg button, .seg label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: 6px; text-decoration: none; color: var(--text-2); font: 600 13px var(--font); border: 0; background: transparent; cursor: pointer; }
.seg [aria-current="page"], .seg [aria-pressed="true"], .seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 6px; min-height: 32px; }
.seg label { padding: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 12px 12px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* -------------------------------------------------------------------- feedback */
.flash { position: fixed; z-index: 60; right: 24px; top: 24px; max-width: min(440px, calc(100vw - 32px)); display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); animation: toast-in 260ms var(--ease-in); }
.flash.leaving { animation: toast-out 180ms var(--ease-out) forwards; }
.flash-success .i { color: var(--success); } .flash-error .i { color: var(--danger); } .flash-info .i { color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
@media (max-width: 900px) { .flash { left: 16px; right: 16px; top: calc(64px + env(safe-area-inset-top)); } }
.alert { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); font-size: 14px; }
.alert .i { margin-top: 1px; }
.alert-error { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-error .i { color: var(--danger); }
.alert-warning { background: color-mix(in srgb, var(--warning) 8%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-warning .i { color: var(--warning); }
.alert-info .i { color: var(--info); }
.empty { text-align: center; padding: 48px 24px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .i-lg { color: var(--text-3); }
.empty strong { color: var(--text); font-weight: 600; }

dialog.modal { border: 1px solid var(--border); border-radius: var(--r-xl); padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
dialog.modal::backdrop { background: rgba(10, 14, 12, .45); }
dialog.modal[open] { animation: modal-in 240ms var(--ease-in); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 24px 24px 0; }
.modal-body { padding: 16px 24px 24px; }
@media (max-width: 640px) { dialog.modal { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: var(--r-xl) var(--r-xl) 0 0; padding-bottom: env(safe-area-inset-bottom); } }

/* -------------------------------------------------------------------- auth */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-panel { background: #0F1714; color: #ECF1EE; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-panel .brand-mark { color: #ECF1EE; width: 40px; height: 40px; --accent: #3FBF94; }
.auth-panel h2 { font-size: 40px; line-height: 1.1; letter-spacing: -0.03em; max-width: 12ch; }
.auth-panel p { color: #A9B5AF; max-width: 40ch; margin-top: 16px; }
.auth-panel .contour { position: absolute; right: -120px; bottom: -120px; width: 520px; height: 520px; opacity: .12; color: #3FBF94; pointer-events: none; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 48px; }
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-card h1 { font-size: 28px; margin-bottom: 8px; }
.auth-card .lead { color: var(--text-2); margin-bottom: 24px; }
.auth-foot { display: flex; justify-content: center; gap: 4px; margin-top: 32px; flex-wrap: wrap; }
.auth-foot a { font-size: 13px; color: var(--text-2); text-decoration: none; padding: 4px 8px; border-radius: 6px; }
.auth-foot a[aria-current="true"] { color: var(--text); background: var(--surface-2); }
@media (max-width: 900px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-panel { padding: 24px 16px; min-height: auto; } .auth-panel h2 { font-size: 24px; } .auth-panel p, .auth-panel .contour { display: none; } .auth-form { padding: 32px 16px; justify-content: flex-start; } }

/* -------------------------------------------------------------------- check-in (provider) */
.today { max-width: 560px; margin: 0 auto; }
.clock-face { text-align: center; padding: 8px 0 24px; }
.clock-time { font: 600 56px/1 var(--mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.clock-date { color: var(--text-2); margin-top: 8px; }
.clock-date::first-letter, .day-title::first-letter, .week-head::first-letter { text-transform: uppercase; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.checkbtn {
  --c: var(--accent); --ci: var(--accent-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; width: 216px; height: 216px; margin: 24px auto;
  border-radius: 50%; border: 0; background: var(--c); color: var(--ci); font: 600 18px/1.2 var(--font); cursor: pointer; text-align: center; padding: 24px;
  box-shadow: 0 0 0 12px color-mix(in srgb, var(--c) 14%, transparent), 0 0 0 26px color-mix(in srgb, var(--c) 6%, transparent);
  transition: transform 120ms var(--ease-tap), box-shadow 200ms var(--ease-tap);
}
.checkbtn:hover { box-shadow: 0 0 0 14px color-mix(in srgb, var(--c) 18%, transparent), 0 0 0 30px color-mix(in srgb, var(--c) 8%, transparent); }
.checkbtn:active { transform: scale(.97); }
.checkbtn .i-lg { width: 36px; height: 36px; }
.checkbtn-out { --c: var(--text); --ci: var(--surface); }
.checkbtn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.checkbtn small { font-weight: 500; font-size: 13px; opacity: .85; }
.timer { font: 600 32px/1 var(--mono); font-variant-numeric: tabular-nums; }
.shift-card { display: flex; gap: 16px; align-items: center; }
.shift-time { font: 600 15px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.method-switch { display: flex; justify-content: center; margin-top: 8px; }
.geo-status { text-align: center; min-height: 24px; font-size: 14px; color: var(--text-2); }
.geo-status.err { color: var(--danger); }

/* -------------------------------------------------------------------- planning */
.week { display: grid; grid-template-columns: 200px repeat(7, minmax(112px, 1fr)); min-width: 1000px; }
.week-head { position: sticky; top: 0; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); padding: 12px; border-bottom: 1px solid var(--border); }
.week-head.is-today { color: var(--accent); }
.week-head .num { display: block; font-size: 18px; color: var(--text); margin-top: 2px; }
.week-head.is-today .num { color: var(--accent); }
.week-person { padding: 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; min-width: 0; }
.week-person .meta { display: block; }
.week-cell { padding: 6px; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); min-height: 72px; display: flex; flex-direction: column; gap: 4px; position: relative; }
.week-cell.is-today { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.week-cell .add { position: absolute; inset: 0; opacity: 0; display: grid; place-items: center; color: var(--text-3); text-decoration: none; transition: opacity 120ms var(--ease-tap); }
.week-cell:hover .add, .week-cell .add:focus-visible { opacity: 1; }
.week-cell .add:hover { color: var(--accent); }
.chip { position: relative; z-index: 1; display: block; padding: 6px 8px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-left: 3px solid var(--accent); text-decoration: none; font-size: 12px; line-height: 1.3; }
.chip:hover { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
.chip strong { display: block; font: 600 12px var(--mono); font-variant-numeric: tabular-nums; }
.chip span { color: var(--text-2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-pending { border-left-color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); }
.day-list > section + section { margin-top: 24px; }
.day-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.day-title.is-today { color: var(--accent); }

/* -------------------------------------------------------------------- chat */
.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100dvh - 160px); min-height: 480px; }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; }
.chat-item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; text-decoration: none; border-bottom: 1px solid var(--border); }
.chat-item:hover { background: var(--surface-2); }
.chat-item[aria-current="page"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.chat-item .unread { min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 600; display: grid; place-items: center; padding: 0 6px; }
.chat-thread { display: flex; flex-direction: column; min-height: 0; }
.chat-head { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 8px; max-width: 78%; align-items: flex-end; }
.msg-body { background: var(--surface-2); border-radius: 16px 16px 16px 4px; padding: 8px 12px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-meta { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.msg.mine { margin-left: auto; flex-direction: row-reverse; }
.msg.mine .msg-body { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-radius: 16px 16px 4px 16px; }
.msg.mine .msg-meta { text-align: right; }
.msg.deleted .msg-body { font-style: italic; color: var(--text-3); background: transparent; border: 1px dashed var(--border-strong); }
.chat-compose { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 8px; align-items: flex-end; }
.chat-compose .textarea { min-height: 44px; max-height: 160px; }
@media (max-width: 900px) {
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 210px); }
  .chat.has-thread .chat-list { display: none; }
  .chat:not(.has-thread) .chat-thread { display: none; }
  .msg { max-width: 90%; }
  .chat-messages { padding: 16px; }
}

/* -------------------------------------------------------------------- photos */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.photo { position: relative; border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); aspect-ratio: 4 / 3; border: 1px solid var(--border); }
.photo a { display: block; height: 100%; }
.photo img { width: 100%; height: 100%; object-fit: cover; transition: transform 300ms var(--ease-in); }
.gallery.gallery-sm { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo a:hover img { transform: scale(1.03); }
.photo figcaption { position: absolute; inset: auto 0 0 0; padding: 24px 12px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); color: #fff; font-size: 12px; }
.photo figcaption strong { display: block; font-weight: 600; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); text-align: center; cursor: pointer; color: var(--text-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--text); }
.dropzone input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

/* -------------------------------------------------------------------- data viz */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 160px) minmax(0, 1fr) 72px; gap: 12px; align-items: center; font-size: 14px; }
.bar-row svg { width: 100%; height: 10px; }
.bar-track { fill: var(--surface-2); }
.bar-fill { fill: var(--accent); }
.spark { width: 100%; height: 64px; }
.spark .col { fill: color-mix(in srgb, var(--accent) 70%, transparent); }
.spark .col.today { fill: var(--accent); }
.grid-7-labels { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 8px; text-align: center; font-size: 12px; color: var(--text-2); }
.grid-7-labels > span::first-letter { text-transform: uppercase; }
.grid-7-labels .num { display: block; color: var(--text); font-size: 12px; text-transform: none; }
.grid-7-labels .today-label { color: var(--accent); font-weight: 600; }

/* -------------------------------------------------------------------- invoice view */
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 40px; }
.doc-band { height: 4px; background: var(--accent); border-radius: 2px; margin: -40px -40px 32px; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 32px 0; }
.doc-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.totals { margin-left: auto; width: min(320px, 100%); margin-top: 16px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 2px solid var(--accent); font-weight: 600; font-size: 18px; padding-top: 10px; margin-top: 4px; }
.payinfo { background: var(--surface-2); border-radius: var(--r-md); padding: 16px; margin-top: 24px; display: grid; grid-template-columns: max-content 1fr; gap: 6px 24px; font-size: 14px; }
@media (max-width: 700px) { .doc { padding: 24px 16px; } .doc-band { margin: -24px -16px 24px; } .doc-parties { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------------- misc */
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 24px; margin: 0; font-size: 14px; }
.dl dt { color: var(--text-2); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .dl dd { margin-bottom: 8px; } }
.code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.qr { width: 220px; height: 220px; background: #fff; padding: 12px; border-radius: var(--r-md); border: 1px solid var(--border); }
.qr-inline svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: var(--r-md); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: -8px; width: 1px; background: var(--border-strong); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.notif { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); text-decoration: none; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.notif.unread .notif-title { font-weight: 600; }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--accent); flex: none; }
.lang-menu { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 12px 8px; }
.lang-menu a { font-size: 12px; padding: 4px 8px; border-radius: 6px; text-decoration: none; color: var(--text-2); }
.lang-menu a[aria-current="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.page-narrow-inner { max-width: 880px; }
.brand-logo-preview { max-height: 64px; max-width: 220px; object-fit: contain; background: var(--surface-2); padding: 8px; border-radius: var(--r-sm); }
.swatch { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); display: inline-block; vertical-align: middle; }
.poster { max-width: 680px; margin: 0 auto; text-align: center; padding: 48px 24px; }
.poster .qr { width: 360px; height: 360px; margin: 32px auto; }
.poster h1 { font-size: 40px; }
.err-page { min-height: 70dvh; display: grid; place-items: center; text-align: center; }
.err-code { font: 600 72px/1 var(--mono); color: var(--text-3); }
.prose { max-width: 72ch; }
.prose h2 { margin: 32px 0 8px; font-size: 18px; }
.prose p, .prose li { color: var(--text-2); }
.prose ul { padding-left: 20px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 16px 0; }
.prose td, .prose th { border-bottom: 1px solid var(--border); padding: 8px; text-align: left; vertical-align: top; }

@media print {
  .sidebar, .topbar, .tabbar, .no-print, .flash { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
  .page { padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* -------------------------------------------------------------------- v1.1 */
.demo-banner { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 8px 16px; background: color-mix(in srgb, var(--info) 12%, var(--surface)); color: var(--text); font-size: 13px; border-bottom: 1px solid var(--border); }
.demo-banner a { font-weight: 600; }
.demo-switch { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
@media (max-width: 640px) {
  .demo-banner { gap: 4px 8px; padding: 8px 12px; font-size: 12px; justify-content: flex-start; }
  .demo-banner > svg { display: none; }
  .demo-switch { gap: 4px; }
  .demo-switch .btn-sm { min-height: 28px; padding: 2px 8px; font-size: 12px; }
}
.quote-lines td { padding: 6px 8px; }
.quote-lines input.num { text-align: right; }
