/*
 * MAIO — one token system, three states (ported from BNST/css/theme.css):
 *   :root                                        -> light
 *   @media (prefers-color-scheme: dark) :root:not([data-theme="light"])
 *   :root[data-theme="dark"]                     -> explicit dark
 * Components only ever reference var(--token).
 */

:root {
  --bg: #c8ccd2;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dcdfe4;
  --border-light: #eceef1;
  --border-strong: #c3c8cf;
  --text: #1c2536;
  --text-muted: #5b6577;
  --primary: #2f6fed;
  --accent: #2f6fed;
  --primary-fg: #ffffff;
  --primary-weak: #e8f0fe;
  --danger: #d3392f;
  --danger-bg: #fdeceb;
  --warn-fg: #8a6100;
  --warn-bg: #fff4d6;
  --ok-fg: #1f7a43;
  --ok-bg: #e5f5ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .08);
  --shadow-pop: 0 2px 6px rgba(16, 24, 40, .10), 0 16px 40px rgba(16, 24, 40, .16);
  --radius: 12px;
  --sidebar-w: 244px;
  --topbar-h: 60px;
  /* chart series — fixed categorical order, CVD-checked (dataviz reference palette) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300; --series-other: #9aa3b2;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1012;
    --surface: #1a1b1e;
    --surface-2: #232428;
    --border: #303237;
    --border-light: #26282c;
    --border-strong: #42454c;
    --text: #e8e9ec;
    --text-muted: #a2a6ad;
    --primary: #5b93ff;
    --accent: #5b93ff;
    --primary-fg: #0b1220;
    --primary-weak: #1c2638;
    --danger: #ff6b60;
    --danger-bg: #3a1f1d;
    --warn-fg: #ffce7a;
    --warn-bg: #38300f;
    --ok-fg: #7ee0a6;
    --ok-bg: #123324;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
    --shadow-pop: 0 2px 8px rgba(0, 0, 0, .5), 0 20px 48px rgba(0, 0, 0, .6);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #0ca30c; --series-other: #5d6b82;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1012;
  --surface: #1a1b1e;
  --surface-2: #232428;
  --border: #303237;
  --border-light: #26282c;
  --border-strong: #42454c;
  --text: #e8e9ec;
  --text-muted: #a2a6ad;
  --primary: #5b93ff;
  --accent: #5b93ff;
  --primary-fg: #0b1220;
  --primary-weak: #1c2638;
  --danger: #ff6b60;
  --danger-bg: #3a1f1d;
  --warn-fg: #ffce7a;
  --warn-bg: #38300f;
  --ok-fg: #7ee0a6;
  --ok-bg: #123324;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-pop: 0 2px 8px rgba(0, 0, 0, .5), 0 20px 48px rgba(0, 0, 0, .6);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #0ca30c; --series-other: #5d6b82;
}

* { box-sizing: border-box; }

/* Theme toggle shows what you'd switch TO: a moon in light mode, a sun in dark mode. */
.th-moon, .th-sun { display: inline-flex; align-items: center; justify-content: center; }
.th-sun { display: none; }
:root[data-theme="dark"] .th-sun { display: inline-flex; }
:root[data-theme="dark"] .th-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .th-sun { display: inline-flex; }
  :root:not([data-theme="light"]) .th-moon { display: none; }
}

/* A visible keyboard focus ring everywhere (mouse clicks don't show it). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

:where(a, button, summary, .sb-link, .sb-sublink, .input, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

img { max-width: 100%; }

/* ---------- centred auth card ---------- */
/* ---------- the maiobiz wordmark (logo D1) ---------- */
/* Space Grotesk Bold, subset to the letters of "maiobiz" (1.3 KB, SIL Open Font Licence), self-hosted. */
@font-face {
  font-family: "Space Grotesk WM";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/space-grotesk-wordmark.woff2") format("woff2");
}
.wm { display: inline-block; font-family: "Space Grotesk WM", "Space Grotesk", Inter, system-ui, sans-serif; font-weight: 700; letter-spacing: -.02em; line-height: 1; white-space: nowrap; color: inherit; }
.wm-i { position: relative; }
.wm-dot { position: absolute; left: 50%; top: .07em; width: .27em; height: .27em; margin-left: -.135em; border-radius: 50%; background: #22c3e6; }
.brand-mark { flex: none; display: block; }

/* ---------- sign-in pages: Aurora glow + illustration (concept 10b) ----------
   Always dark, whatever theme the app is in, so the glass card reads over the glow. */
.auth-aurora {
  --bg: #0f1012; --surface: rgba(26, 27, 30, .7); --surface-2: rgba(35, 36, 40, .75);
  --border: rgba(255, 255, 255, .12); --border-light: rgba(255, 255, 255, .08); --border-strong: rgba(255, 255, 255, .18);
  --text: #f1f2f4; --text-muted: #b4b8bf; --primary: #5b93ff; --accent: #5b93ff; --primary-fg: #0b1220; --primary-weak: #1c2638;
  --danger: #ff6b60; --danger-bg: rgba(58, 31, 29, .8); --warn-fg: #ffce7a; --warn-bg: rgba(56, 48, 15, .8); --ok-fg: #7ee0a6; --ok-bg: rgba(18, 51, 36, .8);
  color-scheme: dark;
  min-height: 100vh; min-height: 100dvh; color: var(--text);
  background:
    radial-gradient(560px 460px at 22% 40%, rgba(47, 111, 237, .55), transparent 70%),
    radial-gradient(460px 400px at 86% 82%, rgba(34, 195, 230, .36), transparent 70%),
    radial-gradient(400px 330px at 60% 10%, rgba(124, 58, 237, .30), transparent 70%),
    #0f1012;
  background-attachment: fixed;
}
.auth-wrap {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 520px);
  align-items: center;
  gap: 24px;
  padding: 96px 6vw 64px;
  max-width: 1360px;
  margin: 0 auto;
  box-sizing: border-box;
}
.auth-brand { position: absolute; top: 32px; left: 6vw; display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.auth-brand:hover { text-decoration: none; }
.auth-art { display: flex; justify-content: center; align-items: center; }
.auth-art svg { width: 100%; max-width: 620px; height: auto; }
.auth-card {
  width: 100%;
  max-width: 440px;
  justify-self: center;
  background: rgba(26, 27, 30, .66);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  padding: 36px;
  box-sizing: border-box;
}
.auth-card h1 { margin: 0 0 6px; font-size: 26px; text-align: center; }
.auth-card .sub { margin: 0 0 24px; color: var(--text-muted); font-size: 14.5px; text-align: center; }
.auth-card .btn { width: 100%; }
.auth-card .btn:not(.secondary) { background: linear-gradient(135deg, #2f6fed, #22c3e6); border-color: transparent; color: #fff; }
.auth-card .input { background: rgba(15, 16, 18, .55); }
.auth-foot { position: absolute; bottom: 22px; left: 0; right: 0; margin: 0; text-align: center; color: #8b8f96; font-size: 13px; }
/* the art drifts and blinks a little; not for people who asked for less motion */
.aa-bob { animation: aa-bob 6s ease-in-out infinite; }
.aa-bob.b { animation-delay: -2s; } .aa-bob.c { animation-delay: -4s; }
@keyframes aa-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.aa-blink { animation: aa-blink 5s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes aa-blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.aa-steam { animation: aa-steam 4s ease-in-out infinite; } .aa-steam.b { animation-delay: -2s; }
@keyframes aa-steam { 0% { opacity: 0; transform: translateY(6px); } 40% { opacity: .7; } 100% { opacity: 0; transform: translateY(-14px); } }
@media (prefers-reduced-motion: reduce) { .aa-bob, .aa-blink, .aa-steam { animation: none; } }
/* tablets and phones: just the card, over the glow */
@media (max-width: 980px) {
  .auth-wrap { grid-template-columns: minmax(0, 1fr); padding: 88px 16px 64px; }
  .auth-art { display: none; }
  .auth-brand { left: 16px; top: 24px; }
  .auth-card { padding: 28px 22px; }
}
.brand-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 8px;
  vertical-align: middle;
}

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
  min-height: 40px;
  font-family: inherit;
}
select.input { -webkit-appearance: none; appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
textarea.input { min-height: 72px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  padding: 10px 16px;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: var(--primary);
  color: var(--primary-fg);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  text-align: center;
  transition: filter .12s ease, background-color .12s ease;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { filter: brightness(.96); }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.btn.secondary:hover { background: var(--border); filter: none; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 7px 12px; font-size: 13px; min-height: 34px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin: 4px 0 18px; }

/* ---------- alerts ---------- */
.alert { border-radius: 9px; padding: 10px 13px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.error  { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert.notice { background: var(--warn-bg);  color: var(--warn-fg); border-color: #e9d8a6; }
.alert.ok     { background: var(--ok-bg);    color: var(--ok-fg);   border-color: #a6dcbb; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 5px; }

/* ---------- app shell ---------- */
.ic { display: block; flex: none; }
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.app-sidebar {
  --sb-text: #c7ccd6;
  --sb-muted: #8b93a7;
  --sb-cyan: #22c3e6;
  width: var(--sidebar-w);
  flex: 0 0 auto;
  background: linear-gradient(180deg, #232529 0%, #1a1b1e 100%);
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 40;
  transition: width .18s ease, transform .2s ease;
}
.sb-top {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 12px 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.sb-brand-icon { color: var(--sb-cyan); }
.sb-brand-text { color: #ffffff; }
.sb-collapse, .sb-close {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer; flex: none;
  background: rgba(255, 255, 255, .07); color: var(--sb-muted);
  width: 28px; height: 28px; border-radius: 7px;
}
.sb-collapse:hover, .sb-close:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.sb-close { display: none; font-size: 20px; line-height: 1; }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 3px; }

.sb-link {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px; border-radius: 9px;
  color: var(--sb-text); text-decoration: none;
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  white-space: nowrap; cursor: pointer;
  background: none; border: 0; text-align: left;
  transition: background .14s, color .14s;
}
.sb-link:hover { background: rgba(255, 255, 255, .09); color: #fff; text-decoration: none; }
.sb-link.active {
  background: linear-gradient(135deg, var(--sb-cyan) 0%, #0e7fa8 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 195, 230, .3);
}
.sb-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-caret { opacity: .55; transition: transform .2s ease; }
.sb-group.open > .sb-group-toggle .sb-caret { transform: rotate(180deg); }
.sb-group.open > .sb-group-toggle { color: #fff; }

.sb-submenu { overflow: hidden; max-height: 0; transition: max-height .22s ease; }
.sb-submenu.show { max-height: 460px; }
.sb-sublink {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px 8px 26px; margin-top: 1px;
  border-radius: 8px;
  color: var(--sb-muted); text-decoration: none; font-size: 12.5px;
  white-space: nowrap; transition: background .14s, color .14s;
}
.sb-sublink .ic { color: var(--sb-cyan); }
.sb-sublink:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sb-sublink.active { background: rgba(34, 195, 230, .16); color: #fff; font-weight: 600; }
.sb-sublink.active .ic { color: #fff; }

/* "needs you" counts (App\Support\NavBadges) */
.sb-badge {
  margin-left: auto; flex: none;
  min-width: 19px; padding: 1px 6px; border-radius: 999px;
  background: #f59e0b; color: #1a1b1e; font-size: 10.5px; font-weight: 800; line-height: 16px; text-align: center;
}
.sb-group-toggle .sb-badge-group { margin-left: 0; background: rgba(245, 158, 11, .22); color: #fbbf24; }
.sb-group.open > .sb-group-toggle .sb-badge-group { display: none; }

/* who is signed in — pinned to the foot of the menu */
.sb-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .07);
}
.sb-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(34, 195, 230, .16); color: var(--sb-cyan); font-size: 12px; font-weight: 800;
}
.sb-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sb-who strong { color: #fff; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.sb-who span { color: var(--sb-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn.on { border-color: var(--primary); color: var(--primary); }

/* rail (desktop collapsed) — 66px icon strip, expands to full on hover */
@media (min-width: 821px) {
  html.pre-rail .app-sidebar { width: 66px; }
  html.pre-rail .app-sidebar :is(.sb-brand, .sb-label, .sb-caret, .sb-badge) { display: none; }
  html.pre-rail .app-sidebar .sb-foot { justify-content: center; padding: 12px 0; }
  html.pre-rail .app-sidebar .sb-top { justify-content: center; padding: 0; }
  html.pre-rail .app-sidebar .sb-link { justify-content: center; padding: 10px; }

  body.nav-rail .app-sidebar { width: 66px; }
  body.nav-rail .app-sidebar:hover { width: var(--sidebar-w); box-shadow: 10px 0 34px rgba(0, 0, 0, .4); }
  body.nav-rail .app-sidebar:not(:hover) :is(.sb-brand, .sb-label, .sb-caret, .sb-badge) { display: none; }
  body.nav-rail .app-sidebar:not(:hover) .sb-foot { justify-content: center; padding: 12px 0; }
  body.nav-rail .app-sidebar:not(:hover) .sb-submenu { max-height: 0 !important; }
  body.nav-rail .app-sidebar:not(:hover) .sb-top { justify-content: center; padding: 0; }
  body.nav-rail .app-sidebar:not(:hover) .sb-link { justify-content: center; padding: 10px; }
  /* the collapse button becomes the "expand" affordance when railed */
  body.nav-rail .sb-collapse { transform: scaleX(-1); }
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 26, .5);
  z-index: 39;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .crumb { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.crumb-ic { color: var(--primary); flex: none; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; flex: 0 0 auto; }
.topbar .who > form { display: flex; }
.icon-btn.nav-toggle { display: none; }

/* profile chip + dropdown */
details.menu.profile { position: relative; }
.profile-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 4px 4px; border-radius: 999px;
  cursor: pointer; list-style: none;
  border: 1px solid transparent;
}
.profile-chip:hover { background: var(--surface-2); border-color: var(--border); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: var(--primary-fg);
  font-size: 12px; font-weight: 700; flex: none;
  border: 2px solid var(--primary-weak);
}
.profile-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.profile-role { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.profile-name { display: flex; align-items: center; gap: 6px; }
.role-pill { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.role-pill.owner { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.profile-company { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); white-space: nowrap; margin-top: 2px; }
.code-pill { font-size: 9.5px; font-weight: 600; padding: 0 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.crumb-mobile { display: none; align-items: center; gap: 7px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
details.menu.profile .menu-panel { padding: 0; min-width: 220px; overflow: hidden; }
.pm-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.pm-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-size: 13px; color: var(--text);
  text-decoration: none;
}
.pm-row:hover { background: var(--surface-2); text-decoration: none; }
.pm-row .ic { color: var(--text-muted); }
.pm-row.danger, .pm-row.danger .ic { color: var(--danger); }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--border); }
.icon-btn.bell { position: relative; text-decoration: none; }
.icon-btn.bell .dot {
  position: absolute; top: -5px; right: -5px;
  background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 1;
  padding: 2px 5px; min-width: 16px; text-align: center;
}

.content { padding: 24px; max-width: 1500px; width: 100%; margin-inline: auto; }
.page-title { margin: 0 0 4px; font-size: 20px; }
.page-sub { margin: 0 0 20px; color: var(--text-muted); font-size: 13px; }

/* ---------- cards / kpis / tables ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 16px 18px; }
.kpi:has(.kpi-ic) { display: flex; align-items: center; gap: 13px; }
.kpi .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.kpi .value { font-size: 23px; font-weight: 700; margin-top: 4px; }
.kpi-ic {
  flex: none; width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}
.kpi-ic.i-blue   { background: var(--primary-weak); color: var(--primary); }
.kpi-ic.i-green  { background: var(--ok-bg);      color: var(--ok-fg); }
.kpi-ic.i-amber  { background: var(--warn-bg);    color: var(--warn-fg); }
.kpi-ic.i-violet { background: #efe9ff;           color: #7c3aed; }
.kpi-ic.i-slate  { background: var(--surface-2);  color: var(--text-muted); }
.kpi-ic.i-red    { background: var(--danger-bg);  color: var(--danger); }
:root[data-theme="dark"] .kpi-ic.i-violet { background: #2a2540; color: #b794ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kpi-ic.i-violet { background: #2a2540; color: #b794ff; } }

/* ---------- shared list-page date range (components/date-range) ---------- */
.date-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 18px; }
.range-pill { padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-muted); text-decoration: none; }
.range-pill:hover { color: var(--text); text-decoration: none; }
.range-pill.active { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.range-sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 4px; }
.range-custom { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range-custom .input { width: auto; padding: 6px 8px; font-size: 13px; }

/* ---------- receive stock (stock/intake) + stock report ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border-strong); margin-bottom: 16px; }
.tab { padding: 9px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.supplier-box { border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px 0; margin: 0; }
.supplier-box legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.supplier-box legend .muted { font-weight: 400; }
.entry-grid .input { padding: 6px 8px; font-size: 13px; min-width: 90px; }
.serial-preview { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.serial-preview:empty { display: none !important; }
.import-rules { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; font-size: 13.5px; }
.import-rules ul { margin: 8px 0 10px; padding-left: 18px; }
.badge.danger { background: var(--danger-bg, #fde8e8); color: var(--danger-fg, var(--danger)); border-color: transparent; }
.stock-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stock-summary a.kpi { text-decoration: none; color: inherit; }
.stock-summary a.kpi:hover { border-color: var(--primary); }
/* ---------- Company profile: per-branch identity ---------- */
.branch-ids { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.branch-id-card .field { margin-bottom: 8px; }
.mark-preview { width: 64px; height: 64px; flex: none; border-radius: 10px; border: 1px solid var(--border-strong); background: #fff;
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mark-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.monogram { font: 800 20px/1 ui-monospace, Consolas, monospace; letter-spacing: 1px; color: #111; border: 2.5px solid #111;
  border-radius: 6px; padding: 7px 6px; }

/* ---------- in-page confirm / alert dialog (partials/confirm-dialog) ---------- */
.confirm-dialog { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 16, 32, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: rm-fade .12s ease-out; }
.cd-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border-strong); border-top: 4px solid var(--primary);
  border-radius: 12px; box-shadow: var(--shadow-pop); padding: 20px 20px 16px; text-align: center; animation: cd-pop .14s ease-out; }
.cd-card.cd-danger { border-top-color: var(--danger); }
.cd-icon { width: 40px; height: 40px; margin: 0 auto 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; background: var(--primary-weak, var(--surface-2)); color: var(--primary); }
.cd-danger .cd-icon { background: var(--danger-bg, #fde8e8); color: var(--danger); }
.cd-msg { margin: 0 0 18px; font-size: 15px; line-height: 1.45; color: var(--text); }
.cd-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cd-actions .btn { min-width: 110px; }
@keyframes cd-pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .confirm-dialog, .cd-card { animation: none; } }

/* ---------- A4 document print-preview modal (layouts/app, data-print-preview) ---------- */
.print-modal { position: fixed; inset: 0; z-index: 210; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 16, 32, .5); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); animation: rm-fade .15s ease-out; }
body.pm-open { overflow: hidden; }
.pm-card { background: var(--surface); border: 2px solid var(--primary); border-radius: 14px; box-shadow: var(--shadow-pop);
  width: min(920px, 100%); height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.pm-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.pm-title { font-size: 15px; }
.pm-tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 9px; }
.pm-sp { flex: 1; }
.pm-x { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.pm-x:hover { color: var(--text); }
.pm-body { position: relative; flex: 1; min-height: 0; background: #525659; }
.pm-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #525659; opacity: 0; transition: opacity .15s; }
.pm-ready .pm-body iframe { opacity: 1; }
.pm-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #e8eaed; font-size: 14px; }
.pm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); }
.pm-actions [data-pm-print] { min-width: 120px; }
@media (max-width: 620px) { .print-modal { padding: 0; } .pm-card { height: 100vh; border-radius: 0; border: 0; } .pm-actions .btn { flex: 1; } }
@media (prefers-reduced-motion: reduce) { .print-modal { animation: none; } }

/* ---------- POS: receipt preview modal over the till ---------- */
.receipt-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 16, 32, .45); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); animation: rm-fade .15s ease-out; }
body.rm-open { overflow: hidden; }
.rm-card { background: var(--surface); border: 2px solid var(--primary); border-radius: 14px; box-shadow: var(--shadow-pop);
  width: min(440px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.rm-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.rm-x { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.rm-x:hover { color: var(--text); }
.rm-body { overflow-y: auto; background: #edf0f4; flex: 1; min-height: 0; }
.rm-body iframe { display: block; width: 100%; height: 60vh; border: 0; background: #edf0f4; }
.rm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); }
.rm-actions #rm-print { min-width: 140px; }
@keyframes rm-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .receipt-modal { animation: none; } }
@media (max-width: 480px) { .rm-actions .btn { flex: 1; } }
/* Receipt preview switched off: an off-screen frame prints it; a small bar offers reprint / view. */
.receipt-print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }
.receipt-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 190; display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; max-width: calc(100% - 24px); padding: 10px 12px 10px 16px; background: var(--surface); border: 2px solid var(--primary);
  border-radius: 12px; box-shadow: var(--shadow-pop); font-size: 14px; transition: opacity .4s; }
.receipt-toast.fade { opacity: 0; pointer-events: none; }
.plan-reject { opacity: .75; }
.plan-reject td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

/* ---------- dashboard: gradient banner, quick-action tiles ---------- */
.dash-banner {
  background: linear-gradient(100deg, #2f6fed, #7c3aed);
  color: #fff; border-radius: var(--radius); padding: 20px 24px; margin-bottom: 22px;
  font-weight: 600; font-size: 15px;
}
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.qa-tile {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px; margin: 0;
  text-decoration: none; color: inherit; transition: border-color .15s, transform .1s;
}
.qa-tile:hover { border-color: var(--primary); transform: translateY(-1px); }
.qa-tile .kpi-ic { width: 36px; height: 36px; }
.qa-tile strong { display: block; font-size: 14px; }
.qa-tile span { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }

.analytics-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .analytics-grid { grid-template-columns: 1fr; } }

/* horizontal-scroll wrapper for wide tables */
.table-wrap, .card[style*="overflow-x"] { -webkit-overflow-scrolling: touch; }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); white-space: nowrap; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--surface-2); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }

.muted { color: var(--text-muted); }
.stack > * + * { margin-top: var(--stack-gap, 14px); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- disclosure menus (inline edit / action popovers) ---------- */
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::marker { content: ""; }
details:not(.menu) > summary:not(.btn) { position: relative; padding-left: 18px; }
details:not(.menu) > summary:not(.btn)::before {
  content: "\25B8"; position: absolute; left: 2px; top: .2em;
  color: var(--text-muted); font-size: 11px;
  transition: transform .15s ease;
}
details:not(.menu)[open] > summary:not(.btn)::before { transform: rotate(90deg); }

details.menu { position: relative; display: inline-block; }
.menu-panel {
  position: absolute;
  right: 0;
  z-index: 50;
  margin-top: 6px;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  padding: 14px;
  text-align: left;
}
details[open] > summary.btn { background: var(--border); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .content { padding: 20px 16px; }
}

@media (max-width: 820px) {
  .icon-btn.nav-toggle { display: inline-flex; }
  .app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100vh; height: 100dvh;
    transform: translateX(-100%);
    box-shadow: var(--shadow-pop);
    width: min(82vw, 300px);
    flex-basis: auto;
  }
  .sb-collapse { display: none; }
  .app-sidebar .sb-close { display: inline-flex; margin-left: auto; }
  body.nav-open .app-sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; }
  body.nav-open { overflow: hidden; }

  .btn.small { min-height: 38px; }
  .sb-link { padding: 12px; }
  .sb-sublink { padding: 10px 12px 10px 44px; }
}

@media (max-width: 620px) {
  .topbar { padding: 10px 14px; }
  .topbar .crumb { flex: 1; }
  .topbar .who { gap: 8px; }
  .profile-meta { display: none; }
  .crumb-mobile { display: flex; }
  .content { padding: 16px 13px; }
  .card { padding: 16px; overflow-x: auto; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
  .kpi .value { font-size: 21px; }
  .page-title { font-size: 18px; }
  table.grid { font-size: 13px; }
  table.grid th, table.grid td { padding: 8px 10px; }

  /* action popovers dock to the screen edges instead of clipping */
  .menu-panel {
    position: fixed;
    left: 12px; right: 12px;
    top: auto;
    margin-top: 8px;
    min-width: 0;
    max-width: none;
    max-height: 70vh;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  .app-sidebar, .topbar, .nav-backdrop, .no-print { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* ---- expense receipts (expenses/_receipt-picker) ---- */
.receipt-picker { display: flex; flex-direction: column; gap: 6px; position: relative; }
.receipt-picker .rp-label { font-size: 13px; font-weight: 600; }
.receipt-picker .rp-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.receipt-picker .rp-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.receipt-picker .rp-chosen { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); max-width: 360px; }
.receipt-picker .rp-chosen[hidden] { display: none; }
.receipt-picker .rp-chosen img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border-light); }
.receipt-picker .rp-chosen img[hidden] { display: none; }
.receipt-picker .rp-name { flex: 1; font-size: 12.5px; color: var(--text-muted); }
.receipt-picker .rp-clear { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--text-muted); padding: 0 4px; }
.proof-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.proof-link { font-size: 13px; font-weight: 600; text-decoration: none; }
.proof-code { font-size: 12px; padding: 2px 6px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border-light); }

/* ---- barcode scanning ---- */
.scan-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.scan-box .input { max-width: 320px; }
.scan-flash { animation: scan-flash .6s ease-out; }
@keyframes scan-flash { from { box-shadow: 0 0 0 3px var(--accent, #2563eb); } to { box-shadow: 0 0 0 0 transparent; } }
.scan-msg { font-size: 12.5px; }
.scan-msg.bad { color: var(--danger); }

/* ---- plain list search bar (partials/list-search) ---- */
.list-search { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 10px 12px; flex-wrap: wrap; }
.list-search .input { flex: 1; min-width: 180px; }

/* ---------- subscriptions (dev/subscriptions, dev/partials/subscription-*) ---------- */
a.kpi { text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--primary); }
.sub-badge { white-space: nowrap; }
.sub-cycle { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.sub-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; font-size: 14px; }
.sub-facts .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 2px; }
.sub-banner { display: flex; align-items: center; gap: 8px; }
.sub-banner svg { flex: none; }
.sub-dialog { width: min(560px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--border-strong); border-top: 4px solid var(--primary);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.sub-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.sub-dialog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.sub-dialog-x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 2px 6px; }
.sub-dialog-x:hover { color: var(--text); }
.sub-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.sub-quick .range-pill { cursor: pointer; padding: 4px 10px; font-size: 12px; }

/* ---------- client portal access card (customers/show) ---------- */
.portal-ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.portal-way-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.portal-way-title .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.portal-ways a.mono { word-break: break-all; }

/* ---------- WhatsApp click-to-chat buttons (partials/whatsapp-button) ---------- */
.btn.wa-btn { background: #1f9d55; border-color: #1f9d55; color: #fff; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn.wa-btn:hover { background: #178a49; border-color: #178a49; color: #fff; text-decoration: none; }
.wa-missing { font-size: 12px; white-space: nowrap; }

/* ---------- owner SMS wording (settings/branding) ---------- */
.sms-alert { border-top: 1px solid var(--border); padding-top: 12px; }
.sms-alert:first-of-type { border-top: 0; padding-top: 0; }
.sms-tpl { margin: 8px 0 0 26px; display: grid; gap: 6px; }
.sms-tpl textarea { resize: vertical; font-size: 13.5px; }
.sms-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; color: var(--text-muted); }
.sms-chips .range-pill { cursor: pointer; padding: 3px 9px; font-size: 11.5px; font-family: ui-monospace, Consolas, monospace; }
.sms-reset { background: none; border: 0; color: var(--primary); cursor: pointer; font-size: 12px; margin-left: auto; }
.sms-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.sms-count { font-size: 11.5px; }

/* ---------- toasts + dismissible flash banners (partials/toasts) ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 400; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { position: relative; padding: 10px 34px 10px 13px; border-radius: 9px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); border: 1px solid transparent; animation: toast-in .18s ease-out; transition: opacity .3s, transform .3s; }
.toast.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: #a6dcbb; }
.toast.error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); }
.toast-x, .flash-x { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 17px; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.toast-x:hover, .flash-x:hover { opacity: 1; }
.alert[data-flash] { position: relative; padding-right: 32px; transition: opacity .4s; }
.alert.fading { opacity: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast, .alert[data-flash] { animation: none; transition: none; } }

/* ---------- categories & brands manager (inventory/index #taxonomy) ---------- */
.tax-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; margin-top: 14px; }
.tax-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tax-add textarea { resize: vertical; font-size: 13.5px; min-height: 56px; }
.tax-add-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.tax-search { padding: 6px 10px; font-size: 13px; }
.tax-list { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.tax-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-top: 1px solid var(--border); }
.tax-row:first-child { border-top: 0; }
.tax-row.off .tax-name { opacity: .5; text-decoration: line-through; }
.tax-row.fresh { animation: tax-fresh 1.6s ease-out; }
.tax-name { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; color: inherit; font: inherit; font-size: 13.5px; padding: 5px 6px; border-radius: 6px; }
.tax-name:hover { border-color: var(--border); }
.tax-name:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.tax-uses { font-size: 11.5px; color: var(--text-muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; min-width: 26px; text-align: center; }
.tax-toggle { background: none; border: 0; color: var(--primary); cursor: pointer; font-size: 12.5px; padding: 4px 2px; }
.tax-toggle:disabled { opacity: .5; }
.tax-empty { margin: 0; font-size: 13px; }
@keyframes tax-fresh { from { background: var(--ok-bg); } to { background: transparent; } }

/* ---------- stock count sheet (stock/count) ---------- */
.count-table th.r, .count-table td.r { text-align: right; }
.count-table .count-in { width: 100px; text-align: right; padding: 5px 8px; }
.count-diff { font-weight: 600; white-space: nowrap; }
.count-diff.up { color: var(--ok-fg); }
.count-diff.down { color: var(--danger); }
.count-diff.ok { color: var(--text-muted); }

/* ---------- cancellation requests (approvals/index) + reason popovers ---------- */
.appr-row { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 12px; }
.appr-row:first-of-type { border-top: 0; padding-top: 0; }
.appr-actions { display: flex; gap: 8px; align-items: flex-start; }
.cancel-pop textarea { resize: vertical; font-size: 13px; }

/* ---------- POS per-line price override ---------- */
.cart-price-row { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.cart-price { width: 96px; padding: 3px 6px; font-size: 12.5px; }
.cart-price.up { border-color: var(--ok-fg); color: var(--ok-fg); }
.cart-price.down { border-color: var(--warn-fg); color: var(--warn-fg); }
.price-auth { border: 1px solid var(--warn-fg); background: var(--warn-bg); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }

.grid th.r, .grid td.r { text-align: right; }

/* ---------- discounts & offers (discounts/index) ---------- */
.offer-picker { border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.offer-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.offer-tools .input { flex: 1; min-width: 180px; padding: 6px 9px; font-size: 13px; }
.offer-tools .range-pill { cursor: pointer; padding: 3px 10px; font-size: 12px; }
.offer-list { max-height: 280px; overflow-y: auto; }
.offer-item { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-top: 1px solid var(--border); font-size: 13.5px; cursor: pointer; }
.offer-item:first-child { border-top: 0; }
.offer-item:hover { background: var(--surface-2); }
.tile-offer { font-size: 10.5px; margin-top: 2px; align-self: flex-start; }

/* ---------- page tabs (components/page-tabs) ---------- */
.page-tabs { margin: 4px 0 18px; }
[data-tab-panel][hidden] { display: none !important; }

/* ---------- branch opening hours (settings/hours) ---------- */
.hours-grid { max-width: 560px; }
.hours-grid .input[type=time] { width: 130px; padding: 5px 8px; }
.hours-grid input:disabled { opacity: .4; }

/* ---------- analytics (analytics/index + partials/rank, split, delta) ---------- */
.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; }
.an-head { align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.an-branch { display: flex; align-items: center; gap: 8px; }
.an-branch .input { width: auto; min-width: 180px; }
.an-range { margin-bottom: 14px; }
.an-kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.an-kpis .kpi > div { min-width: 0; }
@media (max-width: 620px) {
  /* two narrow cards a row on phones: drop the icon tile, shrink the figure */
  .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-kpis .kpi { padding: 12px; }
  .an-kpis .kpi-ic { display: none; }
  .an-kpis .value { font-size: 17px; white-space: normal; }
  .an-kpis.compact .value { font-size: 16px; }
  .an-head .an-branch, .an-head .an-branch .input { width: 100%; }
  .an-range .range-sep { display: none; }
  /* page tabs scroll sideways on a phone rather than wrapping onto two rows */
  .page-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .page-tabs::-webkit-scrollbar { display: none; }
  .page-tabs .tab { white-space: nowrap; flex: none; }
}
.an-kpis .kpi { align-items: flex-start; }
.an-kpis .value { font-size: 21px; white-space: nowrap; }
.an-kpis .value.neg { color: var(--danger); }
.an-kpis.compact .value { font-size: 19px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.35; }
.delta { display: inline-flex; align-items: center; gap: 4px; margin-top: 7px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); }
.delta.good { background: var(--ok-bg); color: var(--ok-fg); }
.delta.bad { background: var(--danger-bg); color: var(--danger); }
.delta-vs { font-weight: 500; opacity: .85; }
.delta.none { background: none; padding: 0; font-weight: 500; font-size: 11.5px; }
.an-kpis .value .cur { font-size: 12px; font-weight: 700; color: var(--text-muted); letter-spacing: .02em; margin-right: 1px; }
.an-note { display: flex; gap: 8px; align-items: flex-start; }
.an-card { margin-bottom: 18px; }
.an-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.an-card-head h2 { font-size: 14.5px; margin: 0; font-weight: 700; }
.an-card-head h2 .muted { font-weight: 500; }
.an-card-head a { font-size: 12.5px; white-space: nowrap; }
.an-section { font-size: 15px; margin: 6px 0 12px; }
.an-section .muted { font-weight: 500; font-size: 12.5px; }
.an-chart { position: relative; }
.an-empty { color: var(--text-muted); margin: 4px 0; font-size: 13px; }
.an-table, .an-how { margin-top: 10px; font-size: 13px; }
.an-table summary, .an-how summary { cursor: pointer; color: var(--text-muted); font-size: 12.5px; }
.an-table .grid { margin-top: 8px; }
.an-how { margin: 2px 0 18px; }
.an-how ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-muted); line-height: 1.6; }
.an-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; align-items: start; }
.an-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 900px) { .an-grid { grid-template-columns: 1fr; } }
.warn-text { color: var(--warn-fg); }

/* ranked bars: name | bar | value — one hue, every value printed */
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(60px, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.rank-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub { display: block; font-size: 11.5px; color: var(--text-muted); }
.rank-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.rank-bar > span { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.rank-bar.alt > span { background: var(--series-2); }
.rank-value { font-weight: 600; text-align: right; white-space: nowrap; }
.pair-bars { display: flex; flex-direction: column; gap: 4px; }
.rank.pair .rank-value { font-size: 12px; line-height: 1.35; }
@media (max-width: 560px) {
  .rank-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 5px; }
  .rank-row > .rank-bar, .rank-row > .pair-bars { grid-column: 1 / -1; grid-row: 2; }
}

/* thin segmented bar + named list (how one whole splits) */
.split-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; margin-bottom: 10px; }
.split-bar > span { flex-basis: 0; min-width: 3px; }
.split-list { list-style: none; margin: 0; padding: 0; }
.split-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 40px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.split-list li:last-child { border-bottom: 0; }
.split-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-val { font-weight: 600; white-space: nowrap; }
.split-pct { text-align: right; color: var(--text-muted); font-size: 12px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.s1 { background: var(--series-1); } .s2 { background: var(--series-2); } .s3 { background: var(--series-3); }
.s4 { background: var(--series-4); } .s5 { background: var(--series-5); } .s6 { background: var(--series-6); }
.s-other { background: var(--series-other); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* label … value breakdown rows (BNST "mini-stat") */
.ms-list { margin: 0; }
.ms-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.ms-list > div:last-child { border-bottom: 0; }
.ms-list dt { color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.ms-list dd { margin: 0; font-weight: 600; text-align: right; }
.ms-list .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ms-list .d-blue { background: var(--series-1); } .ms-list .d-amber { background: var(--series-4); }
.ms-list .d-green { background: var(--series-6); } .ms-list .d-violet { background: var(--series-5); }
.ms-list .d-slate { background: var(--series-other); }

/* ---------- products list: detailed rows (inventory/index) ---------- */
.inv-row { cursor: pointer; }
.inv-row:hover td { background: var(--surface-2); }
.inv-caret { display: inline-block; width: 12px; color: var(--text-muted); font-size: 10px; transition: transform .15s; }
.inv-row.open .inv-caret { transform: rotate(90deg); }
.inv-specs { color: var(--text-muted); font-size: 12.5px; margin: 2px 0 0 12px; }
.inv-row .muted.mono { margin-left: 12px; }
.inv-detail td { background: var(--surface-2); padding: 10px 16px 14px 28px; }
.inv-dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 24px; margin: 0; font-size: 13px; }
.inv-dl > div { display: flex; gap: 10px; }
.inv-dl dt { color: var(--text-muted); min-width: 92px; }
.inv-dl dd { margin: 0; }
.serial-fix { border-color: var(--warn-fg); background: var(--warn-bg); }
.serial-fix strong { color: var(--text); }
.serial-fix-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border-strong); }
