/* Autoentic ERP — UI restyled after Cloudflare's Kumo design language
   (https://kumo-ui.com, MIT). Kumo ships as React + Tailwind, which this
   server-rendered Jinja app can't consume, so its *token system* is ported
   here 1:1 instead: the semantic surface ladder (canvas → elevated → base →
   tint), hairline rings instead of heavy borders, tight radii, a compact
   12–14px type scale, minimal two-part shadows, and the blue brand accent.
   Values are Kumo's own oklch tokens, resolved per theme.
   Variable NAMES are unchanged, so every component rule below restyles at once. */

:root {
  /* ── type: Kumo's compact scale (12 / 13 / 14 / 16) ── */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display",
                  "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text",
             "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, monospace;
  --text-xs: 12px; --text-sm: 13px; --text-base: 14px; --text-lg: 16px;

  /* ── radii: Kumo is restrained (rounded-md 6 / lg 8) ── */
  --r-sm: 6px; --r-md: 8px; --r-lg: 10px; --r-xl: 12px; --r-pill: 999px;

  /* ── module hues (dark values) ── */
  --c-blue: #0A84FF; --c-green: #30D158; --c-cyan: #64D2FF; --c-purple: #BF5AF2;
  --c-mint: #63E6BE; --c-orange: #FF9F0A; --c-indigo: #7D7AFF; --c-brown: #C09B72;

  /* ── DARK (default) — Kumo dark tokens ── */
  --ground: oklch(10% 0 0);                   /* kumo-canvas */
  --ink: oklch(97% 0 0);                      /* text-default */
  --ink-dim: oklch(70.8% 0 0);                /* text-subtle */
  /* --ink-faint carries real tertiary content here (.muted, KPI labels, table
     headers), so it sits above Kumo's placeholder token to keep WCAG AA. */
  --ink-faint: oklch(62% 0 0);
  --ink-placeholder: oklch(55.6% 0 0);        /* text-placeholder (inputs only) */
  --line: oklch(26.9% 0 0);                   /* kumo-hairline */
  --separator: oklch(26.9% 0 0);
  --line-strong: oklch(32% 0 0);              /* kumo-line */
  --card: oklch(17% 0 0);                     /* kumo-base */
  --card-solid: oklch(17% 0 0);
  --field: oklch(21% 0.006 285.885);          /* kumo-control */
  --hover: oklch(100% 0 0 / .04);
  --hover-strong: oklch(37.1% 0 0);           /* kumo-fill-hover */
  --hi: oklch(100% 0 0 / .04);
  --surface-1: oklch(100% 0 0 / .03);
  --sidebar: oklch(12% 0 0);                  /* kumo-elevated */
  --accent: oklch(0.5772 0.2324 260);         /* kumo-brand */
  --accent-soft: oklch(0.5772 0.2324 260 / .25);
  --accent-ink: #fff;
  --btn-bg: oklch(0.5772 0.2324 260);
  --btn-text: #fff;
  --btn-hi: transparent;
  --mark-bg: oklch(98.5% 0 0);                /* kumo-contrast */
  --mark-text: oklch(10% 0 0);
  --title-grad: none;
  --shadow: 0 4px 12px oklch(0% 0 0 / .3);    /* kumo shadow-drop */
  --shadow-sm: 0 1px 2px oklch(0% 0 0 / .3);
  --grain-opacity: 0;                         /* Kumo surfaces are flat */
  --grain-blend: normal;
  --green: oklch(76.5% 0.177 163.223);        /* kumo-success */
  --red: oklch(57.7% 0.245 27.325);           /* kumo-danger */
  --amber: oklch(64.5% 0.168 50);             /* kumo-warning */
  --blue: oklch(70.7% 0.165 254.624);         /* text-link */
  color-scheme: dark;
}

/* Kumo light tokens — shared by the explicit toggle and the OS preference */
:root[data-theme="light"], :root:not([data-theme]) {
  --c-blue: #007AFF; --c-green: #34C759; --c-cyan: #32ADE6; --c-purple: #AF52DE;
  --c-mint: #00C2B2; --c-orange: #FF9500; --c-indigo: #5856D6; --c-brown: #A2845E;

  --ground: oklch(98.75% 0 0);                /* kumo-canvas */
  --ink: oklch(21% 0.006 285.885);            /* text-default */
  --ink-dim: oklch(45% 0 0);                  /* secondary — deepened for AA headroom */
  --ink-faint: oklch(55.6% 0 0);              /* text-subtle; tertiary content */
  --ink-placeholder: oklch(70.8% 0 0);        /* text-placeholder (inputs only) */
  --line: oklch(93.5% 0 0);                   /* kumo-hairline */
  --separator: oklch(93.5% 0 0);
  --line-strong: oklch(14.5% 0 0 / .1);       /* kumo-line */
  --card: #fff;                               /* kumo-base */
  --card-solid: #fff;
  --field: #fff;                              /* kumo-control */
  --hover: oklch(14.5% 0 0 / .035);
  --hover-strong: oklch(92.2% 0 0);           /* kumo-fill */
  --hi: oklch(100% 0 0 / .9);
  --surface-1: oklch(97% 0 0);                /* kumo-tint */
  --sidebar: oklch(98% 0 0);                  /* kumo-elevated */
  --accent: oklch(0.5772 0.2324 260);         /* kumo-brand */
  --accent-soft: oklch(0.5772 0.2324 260 / .18);
  --accent-ink: #fff;
  --btn-bg: oklch(0.5772 0.2324 260);
  --btn-text: #fff;
  --btn-hi: transparent;
  --mark-bg: oklch(8.5% 0 0);                 /* kumo-contrast */
  --mark-text: oklch(98.5% 0 0);
  --title-grad: none;
  --shadow: 0 4px 12px oklch(0% 0 0 / .08);   /* kumo shadow-drop */
  --shadow-sm: 0 1px 2px oklch(0% 0 0 / .08);
  --grain-opacity: 0;
  --grain-blend: normal;
  --green: oklch(59.6% 0.145 163.225);        /* kumo-success */
  --red: oklch(63.7% 0.237 25.331);           /* kumo-danger */
  --amber: oklch(73.9% 0.177 58.2);           /* kumo-warning */
  --blue: oklch(42.4% 0.199 265.638);         /* text-link */
  color-scheme: light;
}
/* Dark is the default above; re-assert it when the OS prefers dark and the
   user hasn't picked a theme (the selector above would otherwise win). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --c-blue: #0A84FF; --c-green: #30D158; --c-cyan: #64D2FF; --c-purple: #BF5AF2;
    --c-mint: #63E6BE; --c-orange: #FF9F0A; --c-indigo: #7D7AFF; --c-brown: #C09B72;
    --ground: oklch(10% 0 0);
    --ink: oklch(97% 0 0); --ink-dim: oklch(70.8% 0 0); --ink-faint: oklch(62% 0 0);
    --ink-placeholder: oklch(55.6% 0 0);
    --line: oklch(26.9% 0 0); --separator: oklch(26.9% 0 0);
    --line-strong: oklch(32% 0 0);
    --card: oklch(17% 0 0); --card-solid: oklch(17% 0 0);
    --field: oklch(21% 0.006 285.885);
    --hover: oklch(100% 0 0 / .04); --hover-strong: oklch(37.1% 0 0);
    --hi: oklch(100% 0 0 / .04); --surface-1: oklch(100% 0 0 / .03);
    --sidebar: oklch(12% 0 0);
    --accent-soft: oklch(0.5772 0.2324 260 / .25);
    --mark-bg: oklch(98.5% 0 0); --mark-text: oklch(10% 0 0);
    --shadow: 0 4px 12px oklch(0% 0 0 / .3);
    --shadow-sm: 0 1px 2px oklch(0% 0 0 / .3);
    --green: oklch(76.5% 0.177 163.223); --red: oklch(57.7% 0.245 27.325);
    --amber: oklch(64.5% 0.168 50); --blue: oklch(70.7% 0.165 254.624);
    color-scheme: dark;
  }
}

/* ── per-module accent: colour-coded navigation ── */
[data-module="accounting"] { --module: var(--c-blue); }
[data-module="sales"]      { --module: var(--c-green); }
[data-module="track"]      { --module: var(--c-cyan); }
[data-module="hrm"]        { --module: var(--c-purple); }
[data-module="services"]   { --module: var(--c-mint); }
[data-module="purchasing"] { --module: var(--c-orange); }
[data-module="inventory"]  { --module: var(--c-indigo); }
[data-module="workshop"]   { --module: var(--c-brown); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04";
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: var(--grain-opacity); mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.shell, .flashes, .login-body { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em;
     color: var(--ink-dim); font-weight: 600; margin: 24px 0 10px 2px; }

/* money + data align in columns */
.kpi-value, .lv-table td, .lv-table th, table.plain td, table.plain th,
.align-right, input[type=number] { font-variant-numeric: tabular-nums; }

/* ── surfaces: Kumo is flat + a 1px hairline ring, no glass ── */
.card, .form-card, .lv-tablewrap, .chart-card, .app-tile,
.importer-panel, .m2m-list, .login-card, .flash, .glass {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

/* ── shell ── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 268px; flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 22px 16px 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--r-sm); flex: none;
  background: var(--mark-bg); color: var(--mark-text);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 2px 8px rgba(0,0,0,.22);
}
/* the marks are single paths filled with currentColor, so they take the tile's
   ink in one theme and its paper in the other without a second asset */
.brand-mark svg { width: 19px; height: auto; display: block; }
.brand-name { display: flex; min-width: 0; }
.brand-name svg { width: auto; height: 13px; display: block; }
.brand-tag {
  font-family: var(--font-display); font-size: 9.5px; font-weight: 600;
  letter-spacing: .09em; color: var(--ink-dim); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 4px; margin-top: 1px; flex: none;
}

.side-nav { padding: 6px 10px; flex: 1; }
.side-group { margin-bottom: 1px; }
.side-module-row { display: flex; align-items: center; gap: 2px; }
.side-module {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 11px; border-radius: var(--r-md);
  color: var(--ink-dim); font-size: 14.5px; font-weight: 450;
  transition: background .16s, color .16s;
}
.side-module:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.side-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-module-active { background: var(--hover-strong); color: var(--ink); font-weight: 550; }

/* the module hue lives on the icon — colour-coded navigation */
.side-icon {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--module, var(--ink-faint));
  background: color-mix(in srgb, var(--module, transparent) 14%, transparent);
  transition: background .16s;
}
.side-icon svg { width: 18px; height: 18px; }
.side-module-active .side-icon { background: color-mix(in srgb, var(--module, transparent) 24%, transparent); }

.side-caret {
  width: 28px; height: 32px; flex-shrink: 0; margin: 0; padding: 0;
  background: transparent; border: none; cursor: pointer; color: var(--ink-faint);
  display: grid; place-items: center; border-radius: 8px;
}
.side-caret:hover { background: var(--hover); color: var(--ink); }
.side-caret svg { width: 15px; height: 15px;
  transition: transform .24s cubic-bezier(.4, 0, .2, 1); }
.side-group.open > .side-module-row .side-caret svg { transform: rotate(90deg); }

/* Submenus slide rather than snap. `display` can't transition and a guessed
   max-height eases wrongly whenever the guess is off, so the height is measured
   and set by toggleGroup() in base.html — exact, and the same speed whether a
   module has two links or twelve. (grid-template-rows 0fr->1fr reads nicer but
   an `fr` against indefinite free space doesn't ramp — it holds at zero.) */
.side-sub {
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: height .24s cubic-bezier(.4, 0, .2, 1), opacity .16s ease;
}
.side-group.open > .side-sub { opacity: 1; }
/* spacing lives on the inner element so it is clipped away with the height —
   a margin on the outer would leave a gap behind when closed */
.side-sub-inner {
  display: flex; flex-direction: column; gap: 1px;
  margin: 1px 0 6px 42px;
  border-left: 1.5px solid var(--separator); padding-left: 10px;
}
.side-sub a { padding: 6px 10px; border-radius: 8px; color: var(--ink-faint); font-size: 13.5px; }
.side-sub a:hover { color: var(--ink); background: var(--hover); text-decoration: none; }
.side-sub a.active { color: var(--module, var(--accent)); background: var(--hover); font-weight: 550; }

.side-footer {
  padding: 12px 18px; border-top: 1px solid var(--separator);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px;
}
.side-user { color: var(--ink-faint); flex: 1; overflow: hidden; text-overflow: ellipsis; }
.side-footer a { color: var(--ink-dim); }
.side-version { padding: 0 18px 12px; font-size: 11px; color: var(--ink-faint); opacity: .65; }
.theme-toggle {
  width: auto; margin: 0; padding: 5px 9px; cursor: pointer; font-size: 14px; line-height: 1;
  background: var(--hover); border: 1px solid var(--line); border-radius: 8px; color: var(--ink-dim);
}
.theme-toggle:hover { background: var(--hover-strong); color: var(--ink); }

.main { flex: 1; min-width: 0; }
.content { max-width: 1240px; margin: 0 auto; padding: 26px 30px 72px; }

/* ── page headers, with a module accent bar ── */
.page-title, .page-head h1 { font-size: 26px; }
.page-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 2px 0 22px; padding-left: 13px; position: relative;
}
.page-head::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 4px;
  border-radius: var(--r-pill); background: var(--module, var(--accent)); opacity: .9;
}
.page-title { margin: 2px 0 22px; }
.page-head .spacer { flex: 1; }
.page-head .muted { font-size: 13px; }

/* ── app grid ── */
.app-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.app-tile { border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 6px;
            color: var(--ink); transition: transform .18s, box-shadow .18s; }
.app-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.app-icon { font-size: 22px; }
.app-label { font-weight: 600; font-family: var(--font-display); }
.app-desc { color: var(--ink-faint); font-size: 12.5px; }

/* ── stat cards ── */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.card { border-radius: var(--r-lg); padding: 16px 18px; }
.kpi-label { color: var(--ink-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 550; }
.kpi-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; }
.kpi-sub { color: var(--ink-faint); font-size: 12.5px; margin-top: 3px; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }

/* ── buttons ── */
/* Kumo buttons: flat fill, rounded-lg, subtle ring — no gradient or lift */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 500;
  border-radius: var(--r-md); padding: 7px 14px; border: 1px solid transparent;
  color: var(--btn-text); background: var(--btn-bg);
  box-shadow: var(--shadow-sm);
  transition: background-color .14s, box-shadow .14s, opacity .14s;
}
.btn:hover { background: oklch(48.8% 0.243 264.376); text-decoration: none; }  /* kumo-brand-hover */
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:active { opacity: .9; }
.btn-small { padding: 5px 10px; font-size: var(--text-xs); border-radius: var(--r-sm); }
.btn-secondary {
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--hover-strong); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red); opacity: .88; }

/* ── forms ── */
form label { display: block; margin-bottom: 13px; font-size: 12.5px; color: var(--ink-dim); font-weight: 550; }
input, select, textarea {
  width: 100%; padding: 7px 10px; margin-top: 5px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: var(--text-base); font-family: inherit; color: var(--ink); background: var(--field);
  transition: border-color .14s, box-shadow .14s;
}
input::placeholder, textarea::placeholder { color: var(--ink-placeholder); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);   /* kumo focus ring */
}
select option { background: var(--card-solid); color: var(--ink); }
.form-card { border-radius: var(--r-lg); padding: 22px; max-width: 780px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }

/* Rupiah money input: "Rp" prefix inside the field, no spinner arrows.
   The wrapper carries any width/flex sizing; the input fills it. JS groups the
   thousands with dots as you type and strips them back to digits on submit. */
.rp { position: relative; display: flex; align-items: center; margin-top: 5px; }
.rp > input { margin-top: 0; padding-left: 32px; width: 100%; text-align: right;
  font-variant-numeric: tabular-nums; }
.rp::before { content: "Rp"; position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); font-size: var(--text-sm); font-weight: 500;
  color: var(--ink-faint); pointer-events: none; }
/* Kill the up/down spinner everywhere it's pointless (money is type=text anyway). */
input.money::-webkit-outer-spin-button,
input.money::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.money { -moz-appearance: textfield; appearance: textfield; }

details.m2m { position: relative; min-width: 150px; margin: 0; }
details.m2m summary { list-style: none; cursor: pointer; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 9px 12px; background: var(--field); font-size: 13.5px; color: var(--ink-dim); }
details.m2m summary::-webkit-details-marker { display: none; }
details.m2m[open] summary { border-color: var(--accent); color: var(--ink); }
.m2m-list { position: absolute; z-index: 30; margin-top: 6px; min-width: 224px; max-height: 210px;
  overflow-y: auto; border-radius: var(--r-md); padding: 10px 12px; display: flex;
  flex-direction: column; gap: 7px; box-shadow: var(--shadow); }
.m2m-chips { display: inline-flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.m2m-placeholder { color: var(--ink-faint); }
.echip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 550;
  background: var(--accent-soft); border: 1px solid transparent; color: var(--accent); }
.echip b { cursor: pointer; font-weight: 700; opacity: .65; }
.echip b:hover { opacity: 1; }

/* ── flashes ── */
.flashes { max-width: 1240px; margin: 18px auto 0; padding: 0 30px; }
.flash { padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 8px; font-size: 13.5px; color: var(--ink);
         border-left: 3px solid var(--line-strong); }
.flash-error { border-left-color: var(--red); }
.flash-success { border-left-color: var(--green); }
.flash-info { border-left-color: var(--accent); }

/* ── list views ── */
.lv-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.lv-search { display: flex; gap: 6px; }
.lv-search input { width: 240px; margin: 0; border-radius: var(--r-pill); padding-left: 15px; }
.lv-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 550;
  background: var(--hover); border: 1px solid var(--line); color: var(--ink-dim); transition: all .15s; }
.chip:hover { color: var(--ink); border-color: var(--line-strong); text-decoration: none; }
.chip-active { background: var(--accent); border-color: transparent; color: #fff !important;
  box-shadow: var(--shadow-sm); }
.chip-clear { color: var(--red); }
.lv-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lv-count { color: var(--ink-faint); font-size: 12.5px; }
.lv-tablewrap { overflow-x: auto; border-radius: var(--r-lg); }
.lv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lv-table th, .lv-table td { padding: 11px 14px; border-bottom: 1px solid var(--separator);
  text-align: left; white-space: nowrap; }
.lv-table td { white-space: normal; color: var(--ink); }
.lv-table tbody tr:last-child td { border-bottom: none; }
.lv-table thead th { background: var(--surface-1); font-size: 11px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.lv-table thead th a { color: var(--ink-dim); text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.lv-filters th { padding: 6px 10px; background: var(--surface-1); }
.lv-filters input, .lv-filters select { font-size: 12.5px; padding: 6px 8px; margin: 0; border-radius: 8px; }
.lv-half { width: 46%; display: inline-block; }
.lv-clickable { cursor: pointer; transition: background .12s; }
.lv-clickable:hover { background: var(--hover); }
.lv-empty { text-align: center; color: var(--ink-faint); padding: 28px !important; }
.align-right { text-align: right !important; }
.align-center { text-align: center !important; }
.lv-filterform > .btn { margin-top: 12px; }
.lv-pagination { display: flex; gap: 14px; align-items: center; justify-content: center;
  margin-top: 16px; color: var(--ink-dim); font-size: 13px; }

/* ── welcome ── */
.welcome { max-width: 660px; margin: 15vh auto 0; text-align: center; }
.welcome-date { color: var(--ink-faint); font-size: 12px; letter-spacing: .15em; text-transform: uppercase; font-weight: 550; }
.welcome-title { font-family: var(--font-display); font-size: 38px; margin: 12px 0 10px;
  letter-spacing: -0.03em; font-weight: 600; color: var(--ink); }
.welcome-sub { color: var(--ink-dim); font-size: 15px; margin-bottom: 30px; }
.welcome-nudge { display: inline-block; padding: 11px 22px; border-radius: var(--r-pill);
  font-weight: 600; font-size: 13.5px; color: var(--accent); background: var(--accent-soft);
  border: 1px solid transparent; transition: transform .16s, filter .16s; }
.welcome-nudge:hover { transform: translateY(-1px); filter: brightness(1.06); text-decoration: none; }

/* ── import popover ── */
details.importer { position: relative; display: inline-block; }
details.importer summary { list-style: none; cursor: pointer; display: inline-block; }
details.importer summary::-webkit-details-marker { display: none; }
.importer-panel { position: absolute; right: 0; z-index: 40; margin-top: 8px; width: 352px;
  border-radius: var(--r-md); padding: 15px; box-shadow: var(--shadow); }
.importer-hint { color: var(--ink-faint); font-size: 12.5px; margin-top: 9px; line-height: 1.55; }

/* ── login ── */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { border-radius: var(--r-xl); padding: 36px; width: 352px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 22px; font-size: 24px; }
.login-card h1 span { color: var(--accent); }
.login-brand { display: flex; align-items: flex-end; gap: 8px; color: var(--ink); }
.login-brand svg { width: 100%; max-width: 196px; height: auto; }
.login-brand span { font-size: 13px; font-weight: 700; letter-spacing: .1em; line-height: 1.9; }
.login-card button { width: 100%; margin-top: 10px; justify-content: center; }

/* ── badges + misc ── */
.badge { display: inline-block; padding: 3px 11px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; border: 1px solid transparent;
  background: var(--hover); color: var(--ink-dim); }
.badge-green { color: var(--green); background: color-mix(in srgb, var(--green) 15%, transparent); }
.badge-red { color: var(--red); background: color-mix(in srgb, var(--red) 15%, transparent); }
.badge-amber { color: var(--amber); background: color-mix(in srgb, var(--amber) 17%, transparent); }
.badge-blue { color: var(--blue); background: color-mix(in srgb, var(--blue) 15%, transparent); }
.badge-gray { color: var(--ink-faint); }

/* Branch code chip. Uncoloured branches keep the neutral outline so a list
   with only some branches coloured still lines up. */
.branch-chip {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid var(--line); color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.swatches { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.swatch { margin: 0; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch span {
  display: block; width: 26px; height: 26px; border-radius: 8px;
  background: var(--sw); border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.swatch-none span { background: repeating-linear-gradient(45deg,
  var(--hover) 0 5px, transparent 5px 10px); border-color: var(--line); }
.swatch input:checked + span { border-color: var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-faint); }
.chart-card { border-radius: var(--r-lg); padding: 18px; }
.chart-card h3 { margin-top: 0; }
.chart-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
table.plain { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.plain th, table.plain td { padding: 10px 12px; border-bottom: 1px solid var(--separator); text-align: left; }
table.plain tr:last-child td { border-bottom: none; }
table.plain th { color: var(--ink-faint); font-weight: 550; font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em; }
code { font-family: var(--font-mono); background: var(--hover-strong); padding: 2px 7px;
  border-radius: 6px; font-size: 12.5px; }
hr { border: none; border-top: 1px solid var(--separator); }
pre { font-family: var(--font-mono); }

/* ── mobile ── */
.mobile-topbar, .sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .shell { display: block; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 60; padding: 10px 14px;
    background: var(--sidebar);
    -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%);
    border-bottom: 1px solid var(--line);
  }
  .mobile-brand { display: flex; align-items: center; gap: 10px; color: var(--ink);
    font-family: var(--font-display); font-weight: 600; font-size: 15.5px; }
  .mobile-brand:hover { text-decoration: none; }
  .mobile-brand .brand-mark { width: 30px; height: 30px; }
  .mobile-brand .brand-mark svg { width: 17px; }
  .mobile-brand .brand-name svg { height: 12px; }
  .hamburger {
    width: 40px; height: 40px; padding: 11px 9px; margin: 0; flex-shrink: 0;
    display: flex; flex-direction: column; justify-content: space-between;
    background: var(--hover); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer;
  }
  .hamburger span { display: block; height: 2px; width: 100%; background: var(--ink);
    border-radius: 2px; transition: transform .2s, opacity .2s; }

  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 80;
    width: 284px; max-width: 84vw; height: 100vh;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow);
  }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 70;
    background: rgba(0,0,0,.42); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .shell.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  .shell.nav-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .shell.nav-open .hamburger span:nth-child(2) { opacity: 0; }
  .shell.nav-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .main { width: 100%; }
  .content { padding: 18px 16px 56px; }
  .flashes { padding: 12px 16px 0; }
  .chart-grid, .form-grid { grid-template-columns: 1fr; }
  .welcome { margin-top: 8vh; }
  .welcome-title { font-size: 32px; }
  h1, .page-head h1, .page-title { font-size: 22px; }
}

/* Someone who has asked their OS to reduce motion means it — the sidebar should
   still open and close, just without the travel. */
@media (prefers-reduced-motion: reduce) {
  .side-sub, .side-caret svg, .side-module, .side-icon { transition: none; }
}
