/* Daybook: a theme for dashboards and internal tools.
   Tokens live on :root. Dark mode follows the system unless [data-theme] is set on <html>.
   Density: [data-density="compact"] on <html>. Collapsed sidebar: [data-sidebar="slim"]. */

:root {
  color-scheme: light;
  /* neutrals */
  --ground: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --surface-3: #f1f1ef;
  --line: #e7e6e3;
  --line-2: #d6d5d1;
  --ink: #191917;
  --ink-2: #4a4945;
  --ink-3: #696864;
  --ink-4: #a4a39e;
  /* the one accent: cobalt */
  --accent: #2b55d6;
  --accent-hover: #2148bd;
  --accent-soft: #eef2fd;
  --accent-line: #c9d5f7;
  --accent-ink: #2146b8;
  --on-accent: #ffffff;
  --chart-ahead: #bccaf3;
  --chart-ref: #8b8a85;
  /* state colours: glyphs, trends, owed money, alerts */
  --ok: #19774a;
  --ok-soft: #e9f5ee;
  --warn: #9a5208;
  --warn-soft: #fdf3e4;
  --warn-line: #f0d6ad;
  --danger: #c0372a;
  --danger-soft: #fcecea;
  --danger-line: #f2c4be;

  /* type */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --t-12: 0.75rem;
  --t-13: 0.8125rem;
  --t-14: 0.875rem;
  --t-16: 1rem;
  --t-20: 1.25rem;
  --t-24: 1.5rem;
  --t-32: 2rem;

  /* space */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 48px;
  --s-10: 64px;
  --gutter: 32px;

  /* shape */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --shadow-canvas: 0 0 0 1px var(--line), 0 1px 2px rgba(24, 24, 20, 0.04), 0 2px 8px -2px rgba(24, 24, 20, 0.04);
  --shadow-float: 0 0 0 1px rgba(24, 24, 20, 0.07), 0 2px 4px -1px rgba(24, 24, 20, 0.06), 0 12px 32px -8px rgba(24, 24, 20, 0.18);
  --shadow-btn: 0 1px 1px rgba(24, 24, 20, 0.05);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);

  /* density */
  --row-h: 44px;
  --cell-x: 12px;
  --ctrl-h: 34px;
  --nav-h: 32px;

  /* layout */
  --sb-w: 244px;
  --sb-slim: 60px;
  --topbar-h: 52px;

  /* motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur-1: 120ms;
  --dur-2: 180ms;
  --dur-3: 240ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0d0d0e;
    --surface: #161617;
    --surface-2: #1a1a1c;
    --surface-3: #212123;
    --line: #29292c;
    --line-2: #38383c;
    --ink: #ededeb;
    --ink-2: #b6b5b1;
    --ink-3: #908f8b;
    --ink-4: #5e5d5a;
    --accent: #7c9bff;
    --accent-hover: #96afff;
    --accent-soft: #1b2340;
    --accent-line: #33437a;
    --accent-ink: #a8bbff;
    --on-accent: #0a1130;
    --chart-ahead: #34437a;
    --chart-ref: #8f8e8a;
    --ok: #55c48a;
    --ok-soft: #12261b;
    --warn: #e5a752;
    --warn-soft: #2a1f10;
    --warn-line: #574019;
    --danger: #f2806f;
    --danger-soft: #2c1513;
    --danger-line: #5e2a24;
    --shadow-canvas: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-float: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.4), 0 16px 40px -8px rgba(0, 0, 0, 0.6);
    --shadow-btn: 0 1px 1px rgba(0, 0, 0, 0.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0d0d0e;
  --surface: #161617;
  --surface-2: #1a1a1c;
  --surface-3: #212123;
  --line: #29292c;
  --line-2: #38383c;
  --ink: #ededeb;
  --ink-2: #b6b5b1;
  --ink-3: #908f8b;
  --ink-4: #5e5d5a;
  --accent: #7c9bff;
  --accent-hover: #96afff;
  --accent-soft: #1b2340;
  --accent-line: #33437a;
  --accent-ink: #a8bbff;
  --on-accent: #0a1130;
  --chart-ahead: #34437a;
  --chart-ref: #8f8e8a;
  --ok: #55c48a;
  --ok-soft: #12261b;
  --warn: #e5a752;
  --warn-soft: #2a1f10;
  --warn-line: #574019;
  --danger: #f2806f;
  --danger-soft: #2c1513;
  --danger-line: #5e2a24;
  --shadow-canvas: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-float: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.4), 0 16px 40px -8px rgba(0, 0, 0, 0.6);
  --shadow-btn: 0 1px 1px rgba(0, 0, 0, 0.3);
}

:root[data-density="compact"] {
  --row-h: 34px;
  --cell-x: 10px;
  --ctrl-h: 30px;
  --nav-h: 28px;
}

/* ---------------- base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-14);
  line-height: 1.45;
  font-feature-settings: "cv11", "ss03";
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img, svg { display: block; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); color: var(--ink); }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "cv11", "ss03", "tnum"; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 16px; height: 16px; flex: none; stroke-width: 1.75; }
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 20px; height: 20px; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

.skip-link {
  position: fixed; left: 12px; top: -48px; z-index: 100;
  background: var(--ink); color: var(--surface); padding: 8px 12px; border-radius: var(--r-sm);
  transition: top var(--dur-2) var(--ease);
}
.skip-link:focus { top: 12px; }

kbd, .kbd {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  font: 500 11px/1 var(--font);
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* ---------------- app shell ---------------- */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--dur-3) var(--ease);
}
:root[data-sidebar="slim"] .app { grid-template-columns: var(--sb-slim) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 10px 10px 12px;
  gap: 2px;
  overflow: hidden auto;
  view-transition-name: sidebar;
}
.sidebar__top { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }

.workspace {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; flex: 1;
  height: 40px; padding: 0 8px 0 6px;
  border-radius: var(--r-md);
  text-align: left;
}
.workspace:hover { background: var(--surface-3); }
.workspace__logo {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--ink); color: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.workspace__logo svg { width: 18px; height: 18px; }
.workspace__text { min-width: 0; flex: 1; display: grid; line-height: 1.2; }
.workspace__name { font-weight: 600; font-size: var(--t-14); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.workspace__sub { font-size: var(--t-12); color: var(--ink-3); white-space: nowrap; }
.workspace .icon { color: var(--ink-4); }

.nav { display: grid; gap: 1px; }
.nav__item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: var(--nav-h); padding: 0 8px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
}
.nav__item:hover { background: var(--surface-3); color: var(--ink); }
.nav__item[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line), var(--shadow-btn); }
.nav__item[aria-current="page"] .icon { color: var(--accent); }
.nav__item .icon { color: var(--ink-3); }
.nav__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav__count { font-size: var(--t-12); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav-group { margin-top: 18px; display: grid; gap: 1px; }
.nav-group__title {
  height: 24px; padding: 0 8px;
  display: flex; align-items: center;
  font-size: var(--t-12); font-weight: 500; color: var(--ink-3);
  white-space: nowrap;
}
.sidebar__foot { margin-top: auto; display: grid; gap: 1px; padding-top: 12px; }

.usage {
  margin: 8px 0 6px; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--t-12); color: var(--ink-3);
}
.usage strong { display: block; color: var(--ink); font-weight: 500; font-size: var(--t-13); margin-bottom: 6px; }
.usage .meter { margin: 6px 0 4px; }

/* slim sidebar (desktop) */
:root[data-sidebar="slim"] .sidebar { padding-inline: 10px; }
:root[data-sidebar="slim"] .workspace__text,
:root[data-sidebar="slim"] .workspace > .icon,
:root[data-sidebar="slim"] .nav__label,
:root[data-sidebar="slim"] .nav__count,
:root[data-sidebar="slim"] .nav-group__title,
:root[data-sidebar="slim"] .usage { display: none; }
:root[data-sidebar="slim"] .workspace { flex: none; width: 40px; padding: 0 7px; }
:root[data-sidebar="slim"] .sidebar__top { flex-direction: column; align-items: flex-start; }
:root[data-sidebar="slim"] .nav__item { width: 40px; justify-content: center; padding: 0; }
:root[data-sidebar="slim"] .nav-group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
/* tooltips for the slim rail */
:root[data-sidebar="slim"] .nav__item[data-tip]:hover::after,
:root[data-sidebar="slim"] .nav__item[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: fixed; left: calc(var(--sb-slim) + 2px);
  transform: translateY(-2px);
  padding: 4px 8px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--surface);
  font-size: var(--t-12); font-weight: 500;
  pointer-events: none; z-index: 60;
}

.main { min-width: 0; padding: 8px 8px 8px 0; }
.canvas {
  min-height: calc(100vh - 16px);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-canvas);
  display: flex; flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  height: var(--topbar-h);
  padding: 0 12px 0 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--t-13); color: var(--ink-3); white-space: nowrap; }
.crumbs a:hover { color: var(--ink); }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 500; }
.crumbs .icon { color: var(--ink-4); width: 14px; height: 14px; }
.topbar__spacer { flex: 1; }

.search-btn {
  display: flex; align-items: center; gap: 8px;
  width: min(320px, 32vw); height: 32px; padding: 0 6px 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-3); font-size: var(--t-13);
  transition: border-color var(--dur-1) var(--ease);
}
.search-btn:hover { border-color: var(--line-2); color: var(--ink-2); }
.search-btn span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-btn kbd { background: var(--surface); }
.topbar__actions { display: flex; align-items: center; gap: 2px; }
.divider-v { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--surface);
}

.account { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 6px 0 2px; border-radius: var(--r-sm); }
.account:hover { background: var(--surface-3); }
.avatar {
  width: 26px; height: 26px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--surface-3); color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.avatar--accent { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-line); }
.avatar--sm { width: 22px; height: 22px; font-size: 10px; }
.avatar--lg { width: 36px; height: 36px; font-size: 13px; }

.menu-btn { display: none; }

/* drawer + scrim (phones and tablets) */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(12, 12, 10, 0.36);
  opacity: 0; transition: opacity var(--dur-2) var(--ease);
}
.scrim.is-on { opacity: 1; }

@media (max-width: 899px) {
  .app, :root[data-sidebar="slim"] .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    width: min(296px, 86vw); height: 100%;
    background: var(--ground);
    box-shadow: var(--shadow-float);
    transform: translateX(-104%);
    transition: transform var(--dur-3) var(--ease), visibility 0s linear var(--dur-3);
    visibility: hidden;
    view-transition-name: none;
  }
  .sidebar.is-open { transform: none; visibility: visible; transition: transform var(--dur-3) var(--ease); }
  :root[data-sidebar="slim"] .sidebar .workspace__text,
  :root[data-sidebar="slim"] .sidebar .nav__label,
  :root[data-sidebar="slim"] .sidebar .nav__count,
  :root[data-sidebar="slim"] .sidebar .nav-group__title { display: revert; }
  :root[data-sidebar="slim"] .sidebar .nav__item { width: auto; justify-content: flex-start; padding: 0 8px; }
  :root[data-sidebar="slim"] .sidebar .workspace { flex: 1; width: auto; }
  :root[data-sidebar="slim"] .sidebar__top { flex-direction: row; }
  .sidebar__collapse { display: none; }
  .menu-btn { display: inline-grid; }
  .main { padding: 0; }
  .canvas { border-radius: 0; box-shadow: none; min-height: 100vh; }
  .topbar { border-radius: 0; padding: 0 8px; }
  .search-btn { width: auto; flex: 1; max-width: 320px; }
  .account__name, .topbar .divider-v { display: none; }
  .crumbs { display: none; }
}
@media (max-width: 480px) {
  .search-btn kbd { display: none; }
  .topbar [data-density-toggle] { display: none; }
}

/* ---------------- page frame ---------------- */
.page { width: 100%; max-width: 1440px; padding: 0 var(--gutter) var(--s-9); }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
  flex-wrap: wrap;
  padding: 28px var(--gutter) 20px;
  max-width: 1440px;
}
.page-head h1 { font-size: var(--t-24); line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.page-head__meta { margin-top: 6px; font-size: var(--t-13); color: var(--ink-3); }
.page-head__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 899px) {
  :root { --gutter: 16px; }
  .page-head { padding-top: 20px; padding-bottom: 16px; }
}

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctrl-h); padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: var(--t-13); font-weight: 500; white-space: nowrap;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 0 0 1px var(--line-2) inset, var(--shadow-btn);
  transition: background-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-2); box-shadow: 0 0 0 1px var(--ink-4) inset, var(--shadow-btn); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { box-shadow: 0 0 0 1px var(--line-2) inset, var(--focus); }
.btn .icon { color: var(--ink-3); }
.btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 0 1px var(--accent-hover), 0 1px 2px rgba(20, 40, 110, 0.2); }
.btn--primary:hover { background: var(--accent-hover); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 0 1px var(--accent-hover), 0 1px 2px rgba(20, 40, 110, 0.2); }
.btn--primary .icon { color: currentColor; }
.btn--primary:focus-visible { box-shadow: var(--focus); }
.btn--ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); box-shadow: none; color: var(--ink); }
.btn--danger { color: var(--danger); box-shadow: 0 0 0 1px var(--danger-line) inset, var(--shadow-btn); }
.btn--danger .icon { color: currentColor; }
.btn--danger:hover { background: var(--danger-soft); box-shadow: 0 0 0 1px var(--danger) inset; }
.btn--danger-fill { background: var(--danger); color: #fff; box-shadow: 0 0 0 1px var(--danger) inset; }
.btn--danger-fill:hover { background: color-mix(in srgb, var(--danger) 88%, #000); box-shadow: 0 0 0 1px var(--danger) inset; }
:root[data-theme="dark"] .btn--danger-fill { color: #1d0805; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn--danger-fill { color: #1d0805; } }
.btn--danger-fill .icon { color: currentColor; }
.btn--sm { height: 28px; padding: 0 10px; font-size: var(--t-12); }
.btn--icon { width: var(--ctrl-h); padding: 0; }
.btn--sm.btn--icon { width: 28px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn[aria-busy="true"] { pointer-events: none; color: transparent; position: relative; }
.btn[aria-busy="true"] .icon { opacity: 0; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-accent) transparent var(--on-accent) var(--on-accent);
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link { color: var(--accent-ink); font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* segmented control */
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-3); border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg button {
  height: calc(var(--ctrl-h) - 6px); padding: 0 10px;
  border-radius: 4px;
  font-size: var(--t-12); font-weight: 500; color: var(--ink-3);
  transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line), var(--shadow-btn); }

/* ---------------- the lifecycle ring (signature) ---------------- */
.ring { width: 14px; height: 14px; flex: none; overflow: visible; }
.ring__track { fill: none; stroke: currentColor; stroke-width: 1.5; }
.ring__fill {
  fill: none; stroke: currentColor; stroke-width: 4.5;
  stroke-dasharray: calc(var(--f, 0) * 14.14) 14.14;
  transform: rotate(-90deg); transform-origin: 7px 7px;
  transition: stroke-dasharray var(--dur-3) var(--ease);
}
.ring__mark { fill: none; stroke: var(--surface); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ring--deposit { color: var(--warn); }
.ring--deposit .ring__track { stroke-dasharray: 2.1 1.5; }
.ring--confirmed { color: var(--ink-2); }
.ring--out { color: var(--accent); }
.ring--returned { color: var(--ink-3); }
.ring--overdue { color: var(--danger); }
.ring--cancelled { color: var(--ink-4); }
.ring--cancelled .ring__mark { stroke: currentColor; stroke-width: 1.5; }

.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-weight: 500; color: var(--ink-2); font-size: var(--t-13); }
.status--overdue { color: var(--danger); }
.status--deposit { color: var(--warn); }

/* ---------------- panels ---------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 0; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.panel__head h2, .panel__title { font-size: var(--t-14); font-weight: 600; letter-spacing: -0.005em; }
.panel__sub { font-size: var(--t-12); color: var(--ink-3); }
.panel__body { padding: 16px; }
.panel__foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: var(--t-13); color: var(--ink-3); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.count-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--surface-3); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line);
}
.count-badge--danger { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-line); }

/* ---------------- overview ---------------- */
.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--r-md);
  margin-bottom: 16px;
}
.kpi { padding: 16px 20px 18px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi__label { display: flex; align-items: center; gap: 6px; font-size: var(--t-13); color: var(--ink-2); font-weight: 500; }
.kpi__value {
  margin-top: 10px;
  font-size: var(--t-32); line-height: 1; font-weight: 560; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; font-feature-settings: "cv11", "ss03", "tnum";
  white-space: nowrap;
}
.kpi__value small { font-size: 0.56em; font-weight: 500; color: var(--ink-3); letter-spacing: -0.01em; margin-left: 1px; }
.kpi__unit { font-size: 0.56em; color: var(--ink-3); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.kpi__trend { margin-top: 10px; display: flex; align-items: center; gap: 4px; font-size: var(--t-12); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__trend b { font-weight: 600; font-variant-numeric: tabular-nums; }
.trend--good b, .trend--good .icon { color: var(--ok); }
.trend--bad b, .trend--bad .icon { color: var(--danger); }
.trend--flat b { color: var(--ink-2); }

.grid-main { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.grid-main + .grid-main { margin-top: 16px; }
@media (max-width: 1180px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .kpi { padding: 14px 14px 16px; }
  .kpi__value { font-size: 1.5rem; }
  .kpi__trend { white-space: normal; }
}

/* chart */
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--t-12); color: var(--ink-3); margin-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.legend i.ahead { background: var(--chart-ahead); }
.legend i.ref { width: 14px; height: 0; border-radius: 0; border-top: 1.5px dashed var(--chart-ref); background: none; }
.chart { position: relative; margin-top: 14px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart svg:focus-visible { box-shadow: none; outline: none; }
.chart .grid line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .bar rect.v { fill: var(--accent); transition: opacity var(--dur-1) var(--ease); }
.chart .bar.ahead rect.v { fill: var(--chart-ahead); }
.chart .bar rect.hit { fill: transparent; }
.chart .bar.is-active rect.hover-bg { fill: var(--surface-3); }
.chart .bar rect.hover-bg { fill: transparent; }
.chart.has-active .bar:not(.is-active) rect.v { opacity: 0.55; }
.chart .bar:focus { outline: none; }
.chart .bar:focus-visible rect.hover-bg { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.chart .ref line { stroke: var(--chart-ref); stroke-dasharray: 4 3; stroke-width: 1.25; }
.chart .ref text { fill: var(--ink-3); font-size: 11px; font-weight: 500; }
.chart .now line { stroke: var(--ink); stroke-width: 1; }
.chart .now text { fill: var(--ink); font-size: 11px; font-weight: 600; }
.chart .now rect { fill: var(--ink); }
.chart .now .now-label { fill: var(--surface); }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 168px; padding: 10px 12px;
  background: var(--surface); border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  font-size: var(--t-12); color: var(--ink-3);
  opacity: 0; transform: translateY(4px);
  transition: opacity var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.tooltip.is-on { opacity: 1; transform: none; }
.tooltip__date { font-weight: 600; color: var(--ink); font-size: var(--t-13); margin-bottom: 6px; }
.tooltip__row { display: flex; justify-content: space-between; gap: 16px; }
.tooltip__row b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.tooltip__row i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); margin-right: 6px; vertical-align: 0; }
.tooltip__row i.ahead { background: var(--chart-ahead); }
.chart-summary {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
.chart-summary div + div { padding-left: 16px; border-left: 1px solid var(--line); }
.chart-summary dt { font-size: var(--t-12); color: var(--ink-3); }
.chart-summary dd { margin-top: 2px; font-size: var(--t-16); font-weight: 560; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
@media (max-width: 560px) {

  .chart-summary { grid-template-columns: 1fr 1fr; row-gap: 12px; }
  .chart-summary div:nth-child(3) { grid-column: 1 / -1; padding-left: 0; border-left: 0; }
}

/* attention list */
.attention li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 2px 10px; padding: 14px 16px; }
.attention li + li { border-top: 1px solid var(--line); }
.attention .glyph { padding-top: 2px; display: grid; justify-items: center; }
.attention .glyph .icon { color: var(--ink-3); }
.attention h3 { font-size: var(--t-14); font-weight: 500; line-height: 1.35; }
.attention p { font-size: var(--t-13); color: var(--ink-3); margin-top: 2px; }
.attention .actions { grid-column: 2; margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

/* activity */
.feed li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 12px 16px; }
.feed li + li { border-top: 1px solid var(--line); }
.feed p { font-size: var(--t-13); color: var(--ink-2); line-height: 1.5; padding-top: 3px; }
.feed p b { color: var(--ink); font-weight: 500; }
.feed time { font-size: var(--t-12); color: var(--ink-3); white-space: nowrap; padding-top: 4px; font-variant-numeric: tabular-nums; }
.feed .money { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.feed li.is-new { background: linear-gradient(var(--accent-soft), var(--accent-soft)) no-repeat; background-size: 100% 100%; transition: background-size 1200ms var(--ease) 1400ms; }
.feed li.is-new.is-settled { background-size: 0 100%; }

/* stock meters */
.stock li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 11px 16px; }
.stock li + li { border-top: 1px solid var(--line); }
.stock .icon { color: var(--ink-3); }
.stock .name { font-weight: 500; font-size: var(--t-13); }
.stock .of { font-size: var(--t-12); color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: right; }
.stock .of b { color: var(--ink); font-weight: 500; }
.stock .meter { grid-column: 2 / 4; }
.meter { height: 4px; border-radius: 2px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--v, 0%); background: var(--ink-2); border-radius: 2px; transition: width 600ms var(--ease); }
.meter--accent i { background: var(--accent); }
.meter--warn i { background: var(--warn); }

/* ---------------- tables ---------------- */
.tabs {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  padding: 0 12px; border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 8px;
  font-size: var(--t-13); font-weight: 500; color: var(--ink-3); white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0;
  background: var(--ink); transform: scaleX(0); transition: transform var(--dur-2) var(--ease);
}
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.tab .count-badge { height: 17px; }

.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.toolbar__spacer { flex: 1; }
.field-search { position: relative; flex: 1 1 260px; max-width: 340px; }
.field-search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.field-search input { padding-left: 32px; padding-right: 32px; }
.field-search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.preview-state { display: flex; align-items: center; gap: 8px; font-size: var(--t-12); color: var(--ink-3); }

.table-wrap { overflow-x: auto; contain: paint; }
table.data { width: 100%; font-size: var(--t-13); }
.data th {
  position: sticky; top: var(--topbar-h); z-index: 2;
  height: 34px; padding: 0 var(--cell-x);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: var(--t-12); font-weight: 500; color: var(--ink-3);
  text-align: left; white-space: nowrap;
}
.data td { height: var(--row-h); padding: 0 var(--cell-x); border-bottom: 1px solid var(--line); vertical-align: middle; }
.data tbody tr { transition: background-color var(--dur-1) var(--ease); }
.data tbody tr:hover { background: var(--surface-2); }
.data tbody tr[aria-selected="true"] { background: var(--accent-soft); }
.data tbody tr[aria-selected="true"] td { border-bottom-color: var(--accent-line); }
.data .r { text-align: right; }
.data .c-check { width: 40px; padding-right: 0; }
.data .c-no { width: 76px; }
.data .c-menu { width: 48px; text-align: right; }
.data .main-line { color: var(--ink); font-weight: 500; white-space: nowrap; }
.data .sub-line { display: block; color: var(--ink-3); font-size: var(--t-12); white-space: nowrap; margin-top: 1px; }
.data .serial { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.data .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.data .owed { color: var(--ink); font-weight: 500; }
.data .owed--late { color: var(--danger); }
.data .muted { color: var(--ink-3); }
.data .items { color: var(--ink-2); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data a.row-link { font-weight: 500; }
.data a.row-link:hover { color: var(--accent-ink); }
:root[data-density="compact"] .data .sub-line { display: none; }
:root[data-density="compact"] .data .items { max-width: 340px; }

.sort { display: inline-flex; align-items: center; gap: 4px; height: 24px; margin: 0 -6px; padding: 0 6px; border-radius: 4px; font-weight: 500; color: inherit; }
.sort:hover { color: var(--ink); background: var(--surface-3); }
.sort .icon { width: 12px; height: 12px; opacity: 0.6; }
th[aria-sort] .sort { color: var(--ink); }
th[aria-sort] .sort .icon { opacity: 1; color: var(--accent); }
th.r .sort { flex-direction: row-reverse; }

.check {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 16px; height: 16px; border-radius: 4px; display: grid; place-items: center;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2);
  cursor: pointer; vertical-align: middle;
  transition: background-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.check:hover { box-shadow: inset 0 0 0 1px var(--ink-4); }
.check:checked, .check:indeterminate { background: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.check:checked::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border: solid var(--on-accent); border-width: 0 0 1.75px 1.75px; transform: rotate(-45deg);
}
.check:indeterminate::after { content: ""; width: 8px; height: 1.75px; background: var(--on-accent); border-radius: 1px; }
.check:focus-visible { box-shadow: inset 0 0 0 1px var(--accent), var(--focus); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; font-size: var(--t-13); color: var(--ink-3); }
.pager__nav { display: flex; align-items: center; gap: 4px; }
.pager__nav .btn { min-width: 30px; height: 30px; padding: 0 8px; }
.pager__nav .btn[aria-current="page"] { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-2); font-weight: 600; }
.pager__size { display: flex; align-items: center; gap: 8px; }
.pager__size select { width: auto; height: 30px; padding-right: 28px; }

/* skeleton */
.sk { display: block; height: 10px; border-radius: 3px; background: var(--surface-3); position: relative; overflow: hidden; }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  animation: shimmer 1.4s var(--ease) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* empty */
.empty { display: grid; justify-items: center; text-align: center; padding: 72px 24px 80px; }
.empty__icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-3); margin-bottom: 16px; }
.empty__icon .icon { width: 20px; height: 20px; }
.empty h2 { font-size: var(--t-16); font-weight: 600; letter-spacing: -0.01em; }
.empty p { margin-top: 6px; color: var(--ink-3); max-width: 42ch; font-size: var(--t-13); }
.empty .btn { margin-top: 18px; }

/* bulk-action bar */
.bulk {
  position: fixed; left: 50%; bottom: 20px; z-index: 30;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 14px;
  background: var(--ink); color: var(--surface);
  border-radius: 10px; box-shadow: var(--shadow-float);
  transform: translate(-50%, 0);
  max-width: calc(100vw - 24px);
}
.bulk__count { font-size: var(--t-13); font-weight: 500; margin-right: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bulk .btn { background: transparent; color: var(--surface); box-shadow: none; height: 30px; }
.bulk .btn .icon { color: currentColor; opacity: 0.7; }
.bulk .btn:hover { background: color-mix(in srgb, var(--surface) 14%, transparent); }
.bulk .btn:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.bulk .sep { width: 1px; height: 18px; background: color-mix(in srgb, var(--surface) 22%, transparent); margin: 0 4px; }
.bulk kbd { background: transparent; color: color-mix(in srgb, var(--surface) 60%, transparent); border-color: color-mix(in srgb, var(--surface) 25%, transparent); }
@media (max-width: 640px) {
  .bulk { left: 12px; right: 12px; transform: none; bottom: 12px; }
  .bulk .btn span.lbl-long, .bulk kbd, .bulk .sep { display: none; }
  .bulk__count { margin-right: auto; }
}

/* stacked table on phones */
@media (max-width: 720px) {
  .data.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data.stack, .data.stack tbody { display: block; }
  .data.stack tr {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    grid-template-areas: "chk who money" "chk what status" "chk items menu";
    gap: 2px 8px; padding: 12px 12px 12px 12px;
    border-bottom: 1px solid var(--line);
  }
  .data.stack td { display: block; height: auto; padding: 0; border: 0; }
  .data.stack .c-check { grid-area: chk; padding-top: 2px; width: auto; }
  .data.stack .c-no { display: none; }
  .data.stack .c-cust { grid-area: who; }
  .data.stack .c-date { grid-area: what; }
  .data.stack .c-items { grid-area: items; }
  .data.stack .items { max-width: none; white-space: normal; font-size: var(--t-12); color: var(--ink-3); }
  .data.stack .c-total { display: none; }
  .data.stack .c-bal { grid-area: money; text-align: right; }
  .data.stack .c-status { grid-area: status; text-align: right; }
  .data.stack .c-menu { grid-area: menu; width: auto; align-self: end; }
  .data.stack .sub-line, :root[data-density="compact"] .data.stack .sub-line { display: none; }
  .data.stack .c-date .main-line { font-weight: 400; color: var(--ink-3); font-size: var(--t-12); }
  .data.stack .c-cust .serial-inline { display: inline; }
  .toolbar .preview-state > span { display: none; }
}
.serial-inline { display: none; color: var(--ink-3); font-weight: 400; margin-right: 6px; font-variant-numeric: tabular-nums; }

/* ---------------- popover menus ---------------- */
.menu {
  position: absolute; z-index: 60; min-width: 200px; padding: 4px;
  background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-float);
  transform-origin: top right;
}
.menu[data-open] { animation: pop var(--dur-2) var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(-2px); } }
.menu__label { padding: 8px 8px 6px; font-size: var(--t-12); color: var(--ink-3); }
.menu__label b { display: block; color: var(--ink); font-weight: 500; font-size: var(--t-13); }
.menu__item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  height: 32px; padding: 0 8px; border-radius: 4px;
  font-size: var(--t-13); color: var(--ink-2); text-align: left;
}
.menu__item .icon { color: var(--ink-3); }
.menu__item kbd { margin-left: auto; }
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-3); color: var(--ink); box-shadow: none; }
.menu__item--danger, .menu__item--danger .icon { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px -4px; }

/* ---------------- command palette ---------------- */
dialog { color: inherit; }
dialog::backdrop { background: rgba(12, 12, 10, 0.32); }
.palette {
  width: min(600px, calc(100vw - 24px)); padding: 0; margin: 12vh auto auto;
  border: 0; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-float);
  overflow: hidden;
}
.palette[open] { animation: dialog-in var(--dur-2) var(--ease); }
.palette[open]::backdrop { animation: fade-in var(--dur-2) var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.98) translateY(-4px); } }
@keyframes fade-in { from { opacity: 0; } }
.palette__input { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; border-bottom: 1px solid var(--line); }
.palette__input .icon { color: var(--ink-3); }
.palette__input input { flex: 1; height: 100%; border: 0; background: none; outline: none; font-size: var(--t-16); }
.palette__input input::placeholder { color: var(--ink-4); }
.palette__list { max-height: min(380px, 52vh); overflow-y: auto; padding: 6px; }
.palette__group { padding: 10px 10px 4px; font-size: var(--t-12); color: var(--ink-3); font-weight: 500; }
.palette__opt {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: var(--t-14); color: var(--ink-2); cursor: pointer;
}
.palette__opt .icon { color: var(--ink-3); }
.palette__opt .meta { margin-left: auto; font-size: var(--t-12); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.palette__opt[aria-selected="true"] { background: var(--surface-3); color: var(--ink); }
.palette__opt[aria-selected="true"] .meta-enter { opacity: 1; }
.palette__empty { padding: 28px 16px; text-align: center; color: var(--ink-3); font-size: var(--t-13); }
.palette__foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: var(--t-12); color: var(--ink-3); background: var(--surface-2); }
.palette__foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------- confirm dialog ---------------- */
.confirm {
  width: min(460px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-float);
}
.confirm[open] { animation: dialog-in var(--dur-2) var(--ease); }
.confirm[open]::backdrop { animation: fade-in var(--dur-2) var(--ease); }
.confirm__body { padding: 20px 20px 4px; }
.confirm h2 { font-size: var(--t-16); font-weight: 600; letter-spacing: -0.01em; }
.confirm p { margin-top: 8px; color: var(--ink-2); font-size: var(--t-13); line-height: 1.55; }
.confirm ul { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--t-13); color: var(--ink-2); display: grid; gap: 4px; }
.confirm ul li { display: flex; gap: 8px; }
.confirm ul .icon { color: var(--danger); margin-top: 2px; }
.confirm .field { margin-top: 16px; }
.confirm__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; margin-top: 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 14px; min-height: 44px;
  background: var(--ink); color: var(--surface);
  border-radius: 10px; box-shadow: var(--shadow-float);
  font-size: var(--t-13); font-weight: 500;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.toast.is-on { opacity: 1; transform: none; pointer-events: auto; }
.toast .icon { color: var(--surface); opacity: 0.8; }
.toast button { padding: 4px 8px; border-radius: 4px; color: var(--surface); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.toast button:hover { background: color-mix(in srgb, var(--surface) 14%, transparent); }
@media (max-width: 640px) { .toast { left: 12px; right: 12px; bottom: 12px; } }

/* ---------------- record (detail) ---------------- */
.record-head { padding: 24px var(--gutter) 0; max-width: 1440px; }
.record-head__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.record-head__id { display: flex; align-items: center; gap: 10px; font-size: var(--t-13); color: var(--ink-3); margin-bottom: 8px; }
.record-head__id .num { color: var(--ink-2); font-weight: 500; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px 0 6px;
  border-radius: var(--r-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  font-size: var(--t-12); font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.record-head h1 { font-size: var(--t-24); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: var(--t-13); color: var(--ink-2); }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.meta-row .icon { color: var(--ink-3); width: 14px; height: 14px; }

.lifecycle {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 20px; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.lifecycle li { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 2px 10px; padding: 12px 14px; min-width: 0; }
.lifecycle li + li { border-left: 1px solid var(--line); }
.lifecycle .ring { margin-top: 2px; }
.lifecycle b { font-size: var(--t-13); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lifecycle small { grid-column: 2; font-size: var(--t-12); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lifecycle li.is-done b { color: var(--ink-2); }
.lifecycle li.is-current { background: var(--surface-2); }
.lifecycle li.is-current::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--ink); }
.lifecycle li.is-next b { color: var(--ink-3); }
@media (max-width: 720px) {
  .lifecycle { grid-template-columns: 1fr 1fr; }
  .lifecycle li:nth-child(3) { border-left: 0; }
  .lifecycle li:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

.record-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; padding: 20px var(--gutter) var(--s-9); max-width: 1440px; align-items: start; }
@media (max-width: 1100px) { .record-body { grid-template-columns: minmax(0, 1fr); } }
.record-tabs { border-bottom: 1px solid var(--line); display: flex; gap: 2px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.record-tabs .tab { padding: 0 6px; }
.record-tabs .tab:first-child { margin-left: -6px; }
.tabpanel:focus-visible { box-shadow: none; }

.alert {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 4px 10px;
  padding: 12px 14px; margin-bottom: 20px;
  border-radius: var(--r-md); background: var(--warn-soft); box-shadow: inset 0 0 0 1px var(--warn-line);
  font-size: var(--t-13); color: var(--ink-2);
}
.alert .icon { color: var(--warn); margin-top: 1px; }
.alert b { color: var(--ink); font-weight: 600; }
.alert .actions { grid-column: 2; display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.lines { width: 100%; font-size: var(--t-13); }
.lines th { text-align: left; font-size: var(--t-12); font-weight: 500; color: var(--ink-3); padding: 0 0 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lines td { padding: 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.lines th + th, .lines td + td { padding-left: 16px; }
.lines .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .item b { display: block; font-weight: 500; color: var(--ink); }
.lines .item span { color: var(--ink-3); font-size: var(--t-12); }
.lines tfoot td { border-bottom: 0; padding: 6px 0; color: var(--ink-2); }
.lines tfoot tr:first-child td { padding-top: 12px; }
.lines tfoot .total td { font-weight: 600; color: var(--ink); font-size: var(--t-14); border-top: 1px solid var(--line); padding-top: 10px; }
.lines tfoot .owed td { color: var(--ink); font-weight: 500; }
.section-title { font-size: var(--t-14); font-weight: 600; margin: 28px 0 12px; }
.section-title:first-child { margin-top: 0; }
@media (max-width: 560px) {
  .lines .hide-sm { display: none; }
}

.props { display: grid; grid-template-columns: 140px minmax(0, 1fr); font-size: var(--t-13); }
.props dt, .props dd { padding: 9px 0; border-bottom: 1px solid var(--line); }
.props dt { color: var(--ink-3); }
.props dd { color: var(--ink); }
@media (max-width: 560px) { .props { grid-template-columns: 112px minmax(0, 1fr); } }

/* timeline */
.timeline { position: relative; }
.timeline li { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; padding-bottom: 20px; }
.timeline li::before { content: ""; position: absolute; left: 13.5px; top: 26px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .node { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-3); }
.timeline .node .icon { width: 14px; height: 14px; }
.timeline .node--warn { background: var(--warn-soft); box-shadow: inset 0 0 0 1px var(--warn-line); color: var(--warn); }
.timeline .what { padding-top: 4px; font-size: var(--t-13); color: var(--ink-2); line-height: 1.5; }
.timeline .what b { color: var(--ink); font-weight: 500; }
.timeline .what .quote { display: block; margin-top: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); }
.timeline time { padding-top: 5px; font-size: var(--t-12); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline li.is-upcoming .node { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); border: 0; }
.timeline li.is-upcoming .node { background-image: none; }
.timeline li.is-upcoming .what { color: var(--ink-3); }
.timeline li.is-upcoming .what b { color: var(--ink-2); }
.timeline li.is-upcoming::before { background: repeating-linear-gradient(to bottom, var(--line-2) 0 3px, transparent 3px 6px); }
.timeline li.now { padding-bottom: 20px; align-items: center; }
.timeline li.now .node { width: 28px; height: 18px; border-radius: 0; background: none; box-shadow: none; }
.timeline li.now .node::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline li.now .what { padding: 0; display: flex; align-items: center; gap: 10px; font-size: var(--t-12); font-weight: 600; color: var(--accent-ink); }
.timeline li.now .what::after { content: ""; flex: 1; height: 1px; background: var(--accent-line); }
.timeline li.now::before { top: 18px; }

/* notes */
.notes li { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 4px 12px; }
.notes li:first-child { padding-top: 0; }
.notes .who { font-size: var(--t-13); font-weight: 500; display: flex; gap: 8px; align-items: baseline; }
.notes .who time { font-size: var(--t-12); color: var(--ink-3); font-weight: 400; }
.notes p { grid-column: 2; font-size: var(--t-13); color: var(--ink-2); line-height: 1.55; max-width: 68ch; }
.composer { margin-top: 16px; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line-2); background: var(--surface); transition: box-shadow var(--dur-1) var(--ease); }
.composer:focus-within { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }
.composer textarea { width: 100%; min-height: 84px; resize: vertical; border: 0; background: none; padding: 12px; outline: none; font-size: var(--t-13); line-height: 1.5; box-shadow: none; }
.composer__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 12px; border-top: 1px solid var(--line); font-size: var(--t-12); color: var(--ink-3); }
.composer.is-invalid { box-shadow: inset 0 0 0 1px var(--danger); }

/* facts aside */
.facts { display: grid; gap: 16px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.facts .panel__body { padding: 4px 16px 8px; }
.fact-list > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; padding: 9px 0; font-size: var(--t-13); }
.fact-list > div + div { border-top: 1px solid var(--line); }
.fact-list dt { color: var(--ink-3); }
.fact-list dd { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.fact-list dd small { display: block; color: var(--ink-3); font-size: var(--t-12); }
.person { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.person b { font-weight: 600; display: block; }
.person span { font-size: var(--t-12); color: var(--ink-3); }
.person .actions { margin-left: auto; display: flex; gap: 2px; }
.pay { padding: 14px 16px 16px; }
.pay__row { display: flex; justify-content: space-between; font-size: var(--t-13); color: var(--ink-3); }
.pay__row b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.pay__big { margin: 6px 0 12px; font-size: var(--t-24); font-weight: 560; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.pay__big small { font-size: var(--t-13); font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-left: 6px; }
.pay .meter { height: 6px; border-radius: 3px; margin-bottom: 10px; }
.pay .meter i { border-radius: 3px; }

/* ---------------- forms (settings) ---------------- */
.settings { display: grid; grid-template-columns: 200px minmax(0, 720px); gap: 48px; padding: 4px var(--gutter) 120px; max-width: 1100px; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 20px); align-self: start; display: grid; gap: 1px; }
.settings-nav a { display: flex; align-items: center; height: 32px; padding: 0 10px; border-radius: var(--r-sm); color: var(--ink-3); font-weight: 500; font-size: var(--t-13); }
.settings-nav a:hover { color: var(--ink); background: var(--surface-3); }
.settings-nav a[aria-current="true"] { color: var(--ink); background: var(--surface-3); }
.settings-nav a.danger { color: var(--danger); }
@media (max-width: 899px) {
  .settings { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-nav { position: static; display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 8px; border-bottom: 1px solid var(--line); }
  .settings-nav a { white-space: nowrap; }
}
.form-section { padding: 28px 0 32px; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--topbar-h) + 16px); }
.form-section:first-of-type { padding-top: 12px; }
.form-section__head { margin-bottom: 20px; }
.form-section h2 { font-size: var(--t-16); font-weight: 600; letter-spacing: -0.01em; }
.form-section__head p { margin-top: 4px; color: var(--ink-3); font-size: var(--t-13); max-width: 60ch; }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px 16px; }
.form-grid .span-6 { grid-column: span 6; }
.form-grid .span-4 { grid-column: span 4; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) {
  .form-grid .span-4, .form-grid .span-3, .form-grid .span-2 { grid-column: span 6; }
}
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .label { font-size: var(--t-13); font-weight: 500; color: var(--ink); }
.field .opt { color: var(--ink-3); font-weight: 400; }
.help { font-size: var(--t-12); color: var(--ink-3); }
.input, select.input, textarea.input {
  width: 100%; height: var(--ctrl-h); padding: 0 10px;
  border: 0; border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-btn);
  font-size: var(--t-13); color: var(--ink);
  transition: box-shadow var(--dur-1) var(--ease);
}
textarea.input { height: auto; min-height: 76px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.input::placeholder { color: var(--ink-4); }
.input:hover { box-shadow: inset 0 0 0 1px var(--ink-4), var(--shadow-btn); }
.input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  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='%23898883' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px;
}
.input-group { display: flex; align-items: stretch; border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-btn); background: var(--surface); transition: box-shadow var(--dur-1) var(--ease); }
.input-group:focus-within { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }
.input-group .input { box-shadow: none; background: transparent; }
.input-group .affix { display: grid; place-items: center; padding: 0 10px; color: var(--ink-3); font-size: var(--t-13); border-right: 1px solid var(--line); }
.input-group .affix:last-child { border-right: 0; border-left: 1px solid var(--line); }
.input[aria-invalid="true"], .input-group:has([aria-invalid="true"]) { box-shadow: inset 0 0 0 1px var(--danger), 0 0 0 3px var(--danger-soft); }
.input-group .input[aria-invalid="true"] { box-shadow: none; }
.error { display: flex; align-items: flex-start; gap: 6px; font-size: var(--t-12); color: var(--danger); font-weight: 500; }
.error .icon { width: 14px; height: 14px; margin-top: 1px; }

.error-summary {
  margin: 0 0 8px; padding: 14px 16px;
  border-radius: var(--r-md); background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger-line);
}
.error-summary:focus-visible { box-shadow: inset 0 0 0 1px var(--danger), var(--focus); }
.error-summary h2 { display: flex; align-items: center; gap: 8px; font-size: var(--t-14); font-weight: 600; color: var(--danger); }
.error-summary ul { margin-top: 8px; padding-left: 24px; display: grid; gap: 4px; }
.error-summary a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--danger-line); text-underline-offset: 3px; font-size: var(--t-13); }
.error-summary a:hover { text-decoration-color: var(--danger); }

.toggle-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 0; }
.toggle-row + .toggle-row { border-top: 1px solid var(--line); }
.toggle-row label { font-weight: 500; font-size: var(--t-13); cursor: pointer; }
.toggle-row p { font-size: var(--t-12); color: var(--ink-3); margin-top: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; margin: 0; cursor: pointer;
  position: relative; width: 32px; height: 18px; border-radius: 9px;
  background: var(--line-2); transition: background-color var(--dur-2) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform var(--dur-2) var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
.switch:focus-visible { box-shadow: var(--focus); border-radius: 9px; }

.team li { display: grid; grid-template-columns: 32px minmax(0, 1fr) 150px; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.team li:first-child { border-top: 1px solid var(--line); }
.team b { font-weight: 500; font-size: var(--t-13); display: block; }
.team span { font-size: var(--t-12); color: var(--ink-3); }
.team .input { height: 30px; }
@media (max-width: 480px) { .team li { grid-template-columns: 32px minmax(0, 1fr); } .team li > :last-child { grid-column: 2; } }

.danger-zone { margin-top: 32px; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--danger-line); scroll-margin-top: calc(var(--topbar-h) + 16px); }
.danger-zone__head { padding: 16px 16px 4px; }
.danger-zone h2 { font-size: var(--t-16); font-weight: 600; color: var(--danger); }
.danger-zone__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 16px; }
.danger-zone__row + .danger-zone__row { border-top: 1px solid var(--danger-line); }
.danger-zone__row b { font-weight: 500; font-size: var(--t-13); display: block; }
.danger-zone__row p { font-size: var(--t-12); color: var(--ink-3); margin-top: 2px; max-width: 56ch; }
@media (max-width: 560px) { .danger-zone__row { grid-template-columns: 1fr; } .danger-zone__row .btn { justify-self: start; } }

.savebar {
  position: fixed; left: 50%; bottom: 20px; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 14px; border-radius: 10px;
  background: var(--surface); box-shadow: var(--shadow-float);
  transform: translate(-50%, 0);
  font-size: var(--t-13); color: var(--ink-2);
  max-width: calc(100vw - 24px);
}
.savebar span { margin-right: 8px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.savebar span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
@media (max-width: 640px) { .savebar { left: 12px; right: 12px; transform: none; bottom: 12px; } .savebar span { margin-right: auto; } }

/* ---------------- motion ---------------- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; animation-timing-function: var(--ease); }
.js .reveal-row { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .sk::after { display: none; }
  .js .reveal-row { opacity: 1; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---------------- additions ---------------- */
.ring--done { color: var(--ink-2); }
.ring--todo { color: var(--ink-4); }
.ring--todo .ring__mark { display: none; }
.table-wrap { overflow: visible; contain: none; }
.data .c-items { width: 100%; max-width: 0; }
.data .items { max-width: none; }
:root[data-density="compact"] .data .items { max-width: none; }
@media (max-width: 1040px) and (min-width: 721px) {
  .data .c-total, .data .c-no { display: none; }
  .serial-inline { display: inline; }
}
.field { align-content: start; }
.kpi__trend { display: block; }
.kpi__trend .icon { display: inline-block; vertical-align: -2px; margin-right: 2px; }
.record-head__id { flex-wrap: wrap; }
.record-head__id > * { white-space: nowrap; }
.grid-main--top { align-items: stretch; }
.grid-main--top > .panel:first-child { display: flex; flex-direction: column; }
.grid-main--top > .panel:first-child .panel__body { flex: 1; display: flex; flex-direction: column; }
.grid-main--top .chart { flex: 1; min-height: 248px; }
.chart .ref rect { fill: var(--surface); }
.attention li { padding: 12px 16px; }
.attention .actions { margin-top: 8px; }
@media (max-width: 720px) {
  .data.stack .c-items { width: auto; max-width: none; }
}
@media (max-width: 560px) { .grid-main--top .chart { min-height: 210px; } }
.palette__input input:focus-visible { box-shadow: none; }
@media (max-width: 640px) {
  .bulk .btn > span { display: none; }
  .bulk .btn { width: 36px; padding: 0; }
  .bulk .btn .icon { opacity: 1; }
}
