/* ============================================================
   JobLedger — product design system
   Register: product. Design serves the task; the tool disappears.
   Tokens and rationale: see DESIGN.md at the repo root.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Neutrals, warm-tinted. Never pure black or white. */
  --n-0:   oklch(0.995 0.004 78);
  --n-50:  oklch(0.976 0.008 78);
  --n-100: oklch(0.945 0.012 76);
  --n-200: oklch(0.902 0.016 74);
  --n-300: oklch(0.820 0.018 70);
  --n-400: oklch(0.680 0.020 65);
  --n-500: oklch(0.552 0.020 60);
  --n-600: oklch(0.440 0.020 58);
  --n-700: oklch(0.350 0.018 55);
  --n-800: oklch(0.270 0.016 52);
  --n-900: oklch(0.210 0.014 50);
  --n-950: oklch(0.155 0.012 48);

  /* Accent: terracotta. Primary actions, selection and focus only. */
  --a-100: oklch(0.945 0.030 45);
  --a-200: oklch(0.885 0.058 44);
  --a-400: oklch(0.760 0.100 43);
  --a-500: oklch(0.672 0.135 42);
  --a-600: oklch(0.598 0.140 40);
  --a-700: oklch(0.500 0.130 38);

  /* Money semantics. Used for outcomes, never for decoration. */
  --pos-100: oklch(0.945 0.032 155);
  --pos-700: oklch(0.440 0.090 155);
  --neg-100: oklch(0.948 0.030 25);
  --neg-700: oklch(0.462 0.150 25);
  --warn-100: oklch(0.955 0.050 85);
  --warn-700: oklch(0.498 0.100 75);

  /* Roles */
  --paper: var(--n-50);
  --surface: var(--n-0);
  --sidebar: var(--n-900);
  --ink: var(--n-900);
  --muted: var(--n-500);
  --border: var(--n-200);

  /* Shape */
  --r-control: 6px;
  --r-card: 10px;
  --r-panel: 16px;
  --r-pill: 999px;

  /* Elevation, tinted toward the brand hue */
  --e-1: 0 1px 2px oklch(0.21 0.014 50 / 0.06);
  --e-2: 0 4px 12px -2px oklch(0.21 0.014 50 / 0.08);
  --e-3: 0 16px 40px -12px oklch(0.21 0.014 50 / 0.16);

  /* Motion: ease-out, exponential. No bounce. */
  --ease: cubic-bezier(0.165, 0.84, 0.44, 1);
  --t-1: 120ms;
  --t-2: 180ms;
  --t-3: 240ms;

  --font: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

html, body { min-height: 100vh; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.011em; line-height: 1.25; }

/* Money and any figure that sits in a column. Tabular so digits don't jitter. */
.num { font-variant-numeric: tabular-nums; }

/* One focus treatment for the whole product. */
:focus-visible {
  outline: 2px solid var(--a-500);
  outline-offset: 2px;
  border-radius: 3px;
}
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { max-width: 1140px; margin: 0 auto; padding: 32px 32px 96px; }
@media (max-width: 700px) { .wrap { padding: 24px 20px 72px; } }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 236px; flex-shrink: 0; background: var(--sidebar); color: var(--n-200);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  transition: transform var(--t-3) var(--ease);
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 18px 12px 18px 18px;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 0.9375rem; font-weight: 600; color: var(--n-0); letter-spacing: -0.015em;
}
.sidebar-brand .mark {
  width: 25px; height: 25px; border-radius: 7px; background: var(--n-0);
  border: 1px solid oklch(1 0 0 / 0.12);
  display: grid; place-items: center; flex-shrink: 0; color: var(--a-600);
}
.sidebar-brand .mark svg { width: 15px; height: 15px; }
.sidebar-cog {
  width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center;
  border: none; background: none; border-radius: var(--r-control);
  color: var(--n-400); cursor: pointer;
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
}
.sidebar-cog:hover { background: oklch(1 0 0 / 0.08); color: var(--n-0); }
.sidebar-cog:focus-visible { outline-color: var(--a-400); }
.sidebar-cog svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-nav { flex: 1; padding: 4px 10px; overflow-y: auto; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 1px; border-radius: 7px;
  color: var(--n-300); text-decoration: none;
  font-size: 0.8125rem; font-weight: 500;
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
}
.sidebar-link svg {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.75;
}
.sidebar-link:hover { background: oklch(1 0 0 / 0.06); color: var(--n-0); }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link[aria-current="page"] { background: oklch(1 0 0 / 0.09); color: var(--n-0); }
.sidebar-link[aria-current="page"] svg { opacity: 1; color: var(--a-400); }
.sidebar-link:focus-visible { outline-color: var(--a-400); }

.sidebar-foot { padding: 12px 18px 18px; border-top: 1px solid oklch(1 0 0 / 0.08); }
.sidebar-business {
  font-size: 0.75rem; font-weight: 600; color: var(--n-300);
  margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-signout {
  width: 100%; padding: 7px 12px; border-radius: var(--r-control);
  background: none; border: 1px solid oklch(1 0 0 / 0.14); color: var(--n-300);
  font-family: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer;
  transition: border-color var(--t-1) var(--ease), color var(--t-1) var(--ease), background var(--t-1) var(--ease);
}
.sidebar-signout:hover { border-color: oklch(1 0 0 / 0.3); color: var(--n-0); background: oklch(1 0 0 / 0.04); }
.sidebar-signout:focus-visible { outline-color: var(--a-400); }

.app-main { flex: 1; margin-left: 236px; min-width: 0; transition: margin-left var(--t-3) var(--ease); }

/* Desktop-only sidebar collapse: fully hides the rail (not an icon-only
   rail — matches the toggle behaviour, not a distinct mini-sidebar mode)
   and lets the content reclaim the width. Independent of the mobile
   drawer below: that's an off-canvas overlay opened per-visit, this is a
   persistent per-device preference read on every page load. */
.app-shell.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
.app-shell.sidebar-collapsed .app-main { margin-left: 0; }

.sidebar-collapse-toggle {
  display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  border-radius: var(--r-control); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); cursor: pointer; position: relative;
}
.sidebar-collapse-toggle svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.sidebar-collapse-toggle::after {
  content: attr(data-tooltip);
  position: absolute; top: calc(100% + 8px); left: 0;
  background: var(--n-900); color: var(--n-0);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap; line-height: 1;
  padding: 6px 9px; border-radius: 6px; box-shadow: var(--e-2);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--t-1) var(--ease), transform var(--t-1) var(--ease);
  z-index: 50;
}
.sidebar-collapse-toggle:hover::after,
.sidebar-collapse-toggle:focus-visible::after { opacity: 1; transform: none; }
@media (max-width: 920px) { .sidebar-collapse-toggle { display: none; } }

.app-topbar {
  display: flex; align-items: center; gap: 14px;
  height: 58px; padding: 0 32px;
  background: oklch(0.995 0.004 78 / 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
@media (max-width: 700px) { .app-topbar { padding: 0 16px; } }

.topbar-search {
  position: relative; flex: 1; max-width: 330px;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px; border-radius: var(--r-control);
  background: var(--n-50); border: 1px solid var(--border);
  color: var(--n-400);
  transition: border-color var(--t-1) var(--ease), background var(--t-1) var(--ease);
}
.topbar-search:focus-within { border-color: var(--a-500); background: var(--n-0); }
.topbar-search svg {
  width: 14px; height: 14px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round;
}
.topbar-search input {
  width: 100%; border: none; background: none; outline: none;
  font-family: inherit; font-size: 0.8125rem; color: var(--ink);
}
.topbar-search input::placeholder { color: var(--n-400); }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; width: 340px;
  max-width: calc(100vw - 40px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--e-3);
  overflow: hidden; z-index: 35;
}
.search-result {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 9px 13px; font-size: 0.8125rem; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--n-100);
  transition: background var(--t-1) var(--ease);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result:focus-visible { background: var(--n-50); }
.search-result .meta { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.search-empty { padding: 14px 13px; font-size: 0.8125rem; color: var(--muted); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topbar-icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-control);
  border: none; background: none; color: var(--n-500);
  display: grid; place-items: center; cursor: pointer; text-decoration: none;
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
}
.topbar-icon-btn:hover { background: var(--n-100); color: var(--ink); }
.topbar-icon-btn svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.topbar-avatar {
  width: 31px; height: 31px; margin-left: 5px; border-radius: var(--r-pill);
  background: var(--a-100); color: var(--a-700);
  display: grid; place-items: center;
  font-size: 0.75rem; font-weight: 700; text-decoration: none;
  transition: background var(--t-1) var(--ease);
}
.topbar-avatar:hover { background: var(--a-200); }

.sidebar-toggle { display: none; }
.sidebar-scrim { display: none; }

@media (max-width: 920px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: var(--e-3); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-toggle {
    display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
    border-radius: var(--r-control); border: 1px solid var(--border);
    background: var(--surface); color: var(--ink); cursor: pointer;
  }
  .sidebar-toggle svg {
    width: 17px; height: 17px;
    fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round;
  }
  .topbar-search { display: none; }
  .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 39;
    background: oklch(0.155 0.012 48 / 0.45);
    opacity: 0; pointer-events: none;
    transition: opacity var(--t-3) var(--ease);
  }
  .sidebar-scrim.open { opacity: 1; pointer-events: auto; }
}

/* ============================================================
   BUTTONS — full state set
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 8px 14px;
  border-radius: var(--r-control); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 0.8125rem; font-weight: 600;
  white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background var(--t-1) var(--ease), border-color var(--t-1) var(--ease),
              color var(--t-1) var(--ease), transform var(--t-1) var(--ease);
}
.btn svg {
  width: 15px; height: 15px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn:hover { background: var(--n-50); border-color: var(--n-300); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; transform: none;
  background: var(--n-50); border-color: var(--border);
}

.btn-primary { background: var(--a-500); border-color: var(--a-500); color: var(--n-0); }
.btn-primary:hover { background: var(--a-600); border-color: var(--a-600); }
.btn-primary[disabled] { background: var(--a-500); border-color: var(--a-500); }

.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--n-100); border-color: transparent; color: var(--ink); }

.btn-danger { color: var(--neg-700); border-color: var(--border); }
.btn-danger:hover { background: var(--neg-100); border-color: var(--neg-100); }

/* Loading: swap label for a spinner without changing the button's width. */
.btn.is-loading { color: transparent; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 14px; height: 14px;
  border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent;
  color: var(--n-0);
  animation: spin 620ms linear infinite;
}
.btn:not(.btn-primary).is-loading::after { color: var(--n-600); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header { margin-bottom: 28px; }
.page-header-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 28px;
}
.page-title { font-size: 1.4375rem; font-weight: 600; letter-spacing: -0.018em; }
.page-subtitle { font-size: 0.8125rem; color: var(--muted); margin-top: 3px; max-width: 62ch; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8125rem; color: var(--muted); text-decoration: none;
  margin-bottom: 14px; border-radius: 4px;
  transition: color var(--t-1) var(--ease);
}
.back-link:hover { color: var(--ink); }
.back-link svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ============================================================
   STATS
   ============================================================ */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .stats { grid-template-columns: 1fr; } }

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 16px 18px;
}
.stat-label {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}
.stat-value {
  font-size: 1.4375rem; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; margin-top: 7px;
}
.stat-sub { font-size: 0.75rem; color: var(--muted); margin-top: 3px; }
.stat.pos .stat-value { color: var(--pos-700); }
.stat.neg .stat-value { color: var(--neg-700); }

/* ============================================================
   PANEL + TABLE
   ============================================================ */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-panel); margin-bottom: 24px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 0.9375rem; font-weight: 600; }
.panel-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-foot { padding: 10px 12px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; white-space: nowrap;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); background: var(--n-50);
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
tbody td { padding: 7px 14px; border-bottom: 1px solid var(--n-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background var(--t-1) var(--ease); }
tbody tr.clickable:hover { background: var(--n-50); }
tbody tr.clickable:focus-visible { background: var(--n-50); outline-offset: -2px; }
tfoot td {
  padding: 11px 14px; border-top: 1px solid var(--border);
  background: var(--n-50); font-size: 0.8125rem; font-weight: 600;
}
td.right, th.right, tfoot td.right { text-align: right; font-variant-numeric: tabular-nums; }

th.sortable { cursor: pointer; user-select: none; transition: color var(--t-1) var(--ease); }
th.sortable:hover { color: var(--ink); }
th.sortable .arrow { margin-left: 4px; font-size: 0.625rem; opacity: 0.9; }

/* Inline editable cells */
td input[type=text], td input[type=number], td input[type=date], td select {
  width: 100%; padding: 6px 8px;
  border: 1px solid transparent; border-radius: var(--r-control);
  background: transparent; color: var(--ink);
  font-family: inherit; font-size: 0.8125rem;
  transition: border-color var(--t-1) var(--ease), background var(--t-1) var(--ease);
}
td input:hover, td select:hover { border-color: var(--border); }
td input:focus, td select:focus {
  outline: none; border-color: var(--a-500); background: var(--surface);
  box-shadow: 0 0 0 3px oklch(0.672 0.135 42 / 0.13);
}
td input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }

.col-amount { width: 116px; }
.col-qty { width: 84px; }
.col-rate { width: 96px; }
.col-category { width: 136px; }
.col-date { width: 140px; }
.col-job { width: 168px; }
.col-del { width: 44px; }

.amount-cell { display: flex; align-items: center; }
.amount-prefix { color: var(--muted); font-size: 0.8125rem; padding-right: 2px; }

.icon-btn {
  display: grid; place-items: center; width: 28px; height: 28px; margin: 0 auto;
  border: none; border-radius: var(--r-control); background: none;
  color: var(--n-400); cursor: pointer;
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
}
.icon-btn svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round;
}
.icon-btn:hover { background: var(--neg-100); color: var(--neg-700); }

.add-row-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 8px 14px; border-radius: var(--r-control);
  border: 1px solid var(--a-500); background: var(--a-500); color: var(--n-0);
  font-family: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
  transition: background var(--t-1) var(--ease), border-color var(--t-1) var(--ease), transform var(--t-1) var(--ease);
}
.add-row-btn svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round;
}
.add-row-btn:hover { background: var(--a-600); border-color: var(--a-600); }
.add-row-btn:active { transform: translateY(1px); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.01em;
  background: var(--n-100); color: var(--n-600);
  text-transform: capitalize;
}
.badge.in_progress { background: var(--warn-100); color: var(--warn-700); }
.badge.complete,
.badge.paid       { background: var(--pos-100); color: var(--pos-700); }
.badge.invoiced,
.badge.sent       { background: var(--a-100); color: var(--a-700); }
.badge.overdue    { background: var(--neg-100); color: var(--neg-700); }

/* ============================================================
   PROFIT BANNER
   ============================================================ */
.profit-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding: 20px 22px; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-panel);
}
.pb-label {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}
.pb-value {
  font-size: 1.75rem; font-weight: 600; letter-spacing: -0.022em;
  font-variant-numeric: tabular-nums; margin-top: 4px;
}
.pb-value.pos { color: var(--pos-700); }
.pb-value.neg { color: var(--neg-700); }
.pb-breakdown {
  text-align: right; font-size: 0.8125rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pb-breakdown b { color: var(--ink); font-weight: 600; }
@media (max-width: 560px) {
  .profit-banner { flex-direction: column; align-items: flex-start; }
  .pb-breakdown { text-align: left; }
}

/* ============================================================
   CHART
   ============================================================ */
.chart-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-panel); padding: 20px 22px 16px; margin-bottom: 24px;
}
.chart-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 6px;
}
.chart-head h3 { font-size: 0.8125rem; font-weight: 600; }
.chart-legend { display: flex; gap: 16px; font-size: 0.75rem; color: var(--muted); }
.chart-legend .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  margin-right: 6px; vertical-align: middle;
}
.dot.rev { background: var(--a-500); }
.dot.cost { background: var(--n-300); }
.chart-scroll { overflow-x: auto; padding-top: 16px; }
.chart-bars { display: flex; align-items: flex-end; gap: 18px; height: 156px; min-width: min-content; padding: 0 2px; }
.chart-col { display: flex; flex-direction: column; align-items: center; gap: 7px; flex-shrink: 0; width: 58px; }
.chart-col .bars { display: flex; align-items: flex-end; gap: 3px; height: 126px; }
.chart-col .bar {
  width: 13px; border-radius: 3px 3px 0 0; min-height: 2px;
  transition: height var(--t-3) var(--ease);
}
.chart-col .bar.rev { background: var(--a-500); }
.chart-col .bar.cost { background: var(--n-300); }
.chart-col .col-label { font-size: 0.6875rem; color: var(--muted); }

/* ============================================================
   FORMS — full state set
   ============================================================ */
.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 0.75rem; font-weight: 600; color: var(--n-700);
}
.field .hint { font-size: 0.75rem; color: var(--muted); margin-top: 5px; }
.field .error-text {
  display: none; margin-top: 5px;
  font-size: 0.75rem; font-weight: 500; color: var(--neg-700);
}
.field.has-error .error-text { display: block; }

.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=date], .field input[type=number], .field select, .field textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 0.875rem; line-height: 1.4;
  transition: border-color var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease);
}
.field textarea { resize: vertical; min-height: 68px; }
.field input::placeholder, .field textarea::placeholder { color: var(--n-400); }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--n-300); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--a-500);
  box-shadow: 0 0 0 3px oklch(0.672 0.135 42 / 0.13);
}
.field input[disabled], .field select[disabled], .field textarea[disabled] {
  background: var(--n-100); color: var(--n-400); cursor: not-allowed;
}
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--neg-700); }
.field.has-error input:focus { box-shadow: 0 0 0 3px oklch(0.462 0.150 25 / 0.15); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.checkbox-row { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--a-500); cursor: pointer; }
.checkbox-row label { font-size: 0.8125rem; color: var(--ink); cursor: pointer; margin: 0; font-weight: 500; }

/* Standalone select used in toolbars */
.select-control {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 0.8125rem; font-weight: 500; cursor: pointer;
  transition: border-color var(--t-1) var(--ease);
}
.select-control:hover { border-color: var(--n-300); }
.select-control:focus { outline: none; border-color: var(--a-500); box-shadow: 0 0 0 3px oklch(0.672 0.135 42 / 0.13); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar label { font-size: 0.75rem; font-weight: 600; color: var(--muted); }

/* ============================================================
   EMPTY STATE — teaches the next action
   ============================================================ */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 56px 24px;
}
.empty-art {
  width: 44px; height: 44px; margin-bottom: 16px; color: var(--n-300);
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
}
.empty h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 5px; }
.empty p { font-size: 0.8125rem; color: var(--muted); max-width: 42ch; margin-bottom: 18px; }

/* ============================================================
   SKELETON — shaped like the content it stands in for
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--n-100) 25%, var(--n-50) 37%, var(--n-100) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 5px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--n-100); }
}
.sk-line { height: 11px; }
.sk-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--n-100); }
.sk-row:last-child { border-bottom: none; }

/* ============================================================
   TOAST
   ============================================================ */
.toast-region {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  display: flex; flex-direction: column-reverse; gap: 9px;
  max-width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}
@media (max-width: 560px) { .toast-region { right: 12px; left: 12px; bottom: 12px; max-width: none; } }

.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px 11px 13px;
  background: var(--n-900); color: var(--n-100);
  border-radius: var(--r-card); box-shadow: var(--e-3);
  font-size: 0.8125rem; line-height: 1.45;
  pointer-events: auto;
  opacity: 0; transform: translateY(8px);
  transition: opacity var(--t-3) var(--ease), transform var(--t-3) var(--ease);
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast.leaving { opacity: 0; transform: translateY(4px); }
.toast-icon {
  flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px;
  display: grid; place-items: center; border-radius: 50%;
}
.toast-icon svg {
  width: 12px; height: 12px; fill: none; stroke: currentColor;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.toast-success .toast-icon { background: var(--pos-100); color: var(--pos-700); }
.toast-error .toast-icon { background: var(--neg-100); color: var(--neg-700); }
.toast-info .toast-icon { background: var(--a-100); color: var(--a-700); }
.toast-text { flex: 1; word-break: break-word; }
.toast-close {
  flex-shrink: 0; width: 20px; height: 20px; padding: 0;
  border: none; background: none; color: var(--n-400); cursor: pointer;
  display: grid; place-items: center; border-radius: 4px;
  transition: color var(--t-1) var(--ease);
}
.toast-close:hover { color: var(--n-0); }
.toast-close svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toast-close:focus-visible { outline-color: var(--a-400); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: oklch(0.155 0.012 48 / 0.45);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-scrim.open { display: flex; animation: scrim-in var(--t-2) var(--ease); }
.modal {
  width: 100%; max-width: 430px; padding: 24px;
  background: var(--surface); border-radius: var(--r-panel); box-shadow: var(--e-3);
  animation: modal-in var(--t-3) var(--ease);
  max-height: calc(100vh - 40px); overflow-y: auto;
}
.modal h2 { font-size: 1rem; font-weight: 600; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }

.reorder-list { list-style: none; border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; background: var(--surface); }
.reorder-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 4px;
  font-size: 0.875rem; font-weight: 500; color: var(--ink);
  border-bottom: 1px solid var(--n-100);
  position: relative; background: var(--surface);
  -webkit-user-select: none; user-select: none;
}
.reorder-row:last-child { border-bottom: none; }
.reorder-row.dragging { z-index: 5; box-shadow: var(--e-2); border-radius: var(--r-control); }
.reorder-cat-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.reorder-row span:not(.reorder-arrows) { flex: 1; }
.reorder-arrows { display: flex; gap: 2px; }

.reorder-handle {
  width: 24px; height: 24px; flex-shrink: 0; display: grid; place-items: center;
  border: none; background: none; padding: 0; color: var(--n-300); cursor: grab;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.reorder-handle:hover { color: var(--muted); }
.reorder-row.dragging .reorder-handle { cursor: grabbing; }
.grip-dots { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.reorder-btn {
  width: 24px; height: 24px; display: grid; place-items: center;
  border: none; background: none; border-radius: 5px; color: var(--muted); cursor: pointer;
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease);
}
.reorder-btn:hover:not(:disabled) { background: var(--n-100); color: var(--ink); }
.reorder-btn:disabled { opacity: 0.3; cursor: default; }
.reorder-btn:focus-visible { outline-color: var(--a-500); }
.reorder-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================
   INLINE MESSAGE (forms)
   ============================================================ */
.msg { display: none; padding: 9px 12px; border-radius: var(--r-control); font-size: 0.8125rem; margin-bottom: 16px; }
.msg.error { display: block; background: var(--neg-100); color: var(--neg-700); }
.msg.success { display: block; background: var(--pos-100); color: var(--pos-700); }
.msg.info { display: block; background: var(--a-100); color: var(--a-700); }

/* ============================================================
   AUTH PAGES
   Single card carries the mark, heading, form and footer link, so the
   whole thing reads as one object — including for the hover lift below.
   ============================================================ */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { width: 100%; max-width: 372px; text-align: center; position: relative; z-index: 1; }

/* Animated dot-grid background (login only). Fixed + z-index:0 so it sits
   behind the card regardless of DOM order; pointer-events:none so it never
   intercepts clicks on the form above it. */
#bg-dots { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bg-noise { position: fixed; inset: 0; z-index: 0; pointer-events: none; mix-blend-mode: overlay; opacity: 0.025; }

.auth-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-panel); padding: 32px 28px 28px;
  transition: transform var(--t-3) var(--ease), box-shadow var(--t-3) var(--ease);
}
.auth-panel:hover {
  transform: translateY(-6px);
  box-shadow: 0 30px 64px -20px oklch(0.21 0.014 50 / 0.30);
}

.auth-brand {
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  margin: 0 auto 18px;
}
.auth-brand .mark {
  width: 44px; height: 44px; border-radius: 12px; background: var(--n-0);
  border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--a-600);
  box-shadow: 0 8px 18px -6px oklch(0.672 0.135 42 / 0.25);
}
.auth-brand .mark svg { width: 24px; height: 24px; }

.auth-card h1 { font-size: 1.3125rem; letter-spacing: -0.018em; margin-bottom: 5px; }
.auth-card .lede { font-size: 0.8125rem; color: var(--muted); margin-bottom: 26px; }
.auth-panel .field, .auth-panel .checkbox-row { text-align: left; }

.field-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.field-label-row label { margin-bottom: 0; }
.field-link { font-size: 0.75rem; font-weight: 600; color: var(--a-700); text-decoration: none; }
.field-link:hover { text-decoration: underline; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 38px; }
.password-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 27px; height: 27px; border: none; background: none; padding: 0;
  display: grid; place-items: center; border-radius: 6px; color: var(--muted); cursor: pointer;
  transition: color var(--t-1) var(--ease), background var(--t-1) var(--ease);
}
.password-toggle:hover { background: var(--n-100); color: var(--ink); }
.password-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .eye-closed { display: none; }
.password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }

.auth-foot { margin-top: 18px; text-align: center; font-size: 0.8125rem; color: var(--muted); }
.auth-foot a { color: var(--a-700); font-weight: 600; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }
