/* The naira sign (₦) always comes from the device's own system font: some
   brand fonts draw it broken, especially large. A face bound to ONLY that
   character leads every font stack, so every other letter keeps the brand
   font. local() = nothing to download. */
@font-face {
  font-family: 'NairaSign';
  src: local('Arial'), local('Helvetica Neue'), local('Helvetica'), local('Segoe UI'), local('Roboto');
  unicode-range: U+20A6;
}
:root {
  /* Market Day theme: soft green-grey ground, deep indigo, marigold. */
  --primary: #2B2A8C;
  --primary-dark: #1F1E6B;
  --on-primary: #FFFFFF;
  --primary-bg: #E7E7F7;
  --focus-ring: rgba(43, 42, 140, 0.18);
  --sun: #F4B23E;
  --sun-bg: #FFF1D6;
  --sun-text: #7A4B00;
  --success: #1D6B3F;
  --success-bg: #DDF1E4;
  --danger: #A8261A;
  --danger-bg: #FBE3E0;
  --danger-border: #F2C2BC;
  --warning: #9A5300;
  --bg: #EEF1EA;
  --card-bg: #FFFFFF;
  --border: #DCE1D5;
  --text: #1A1F16;
  --text-muted: #4F5848;
  --sidebar-bg: #EEF1EA;
  --sidebar-border: #DCE1D5;
  --nav-hover: #E2E7DB;
  --th-bg: #F6F8F3;
  --input-bg: #FFFFFF;
  --row-hover: #F6F8F3;
  --kpi-bg: #23226F;
  --sidebar-w: 216px;
  --font-body: 'NairaSign', 'Figtree', 'Noto Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* 'Noto Sans' is loaded with only the naira sign in it, so listing it first
     swaps in its cleaner ₦ (Bricolage's own is wide and heavy) and nothing else. */
  --font-display: 'NairaSign', 'Noto Sans', 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="dark"] {
  --primary: #9E9CFF;
  --primary-dark: #B7B5FF;
  --on-primary: #12140F;
  --primary-bg: #26254F;
  --focus-ring: rgba(158, 156, 255, 0.25);
  --sun-bg: #3A2E12;
  --sun-text: #F7C873;
  --success: #7BD6A0;
  --success-bg: #183323;
  --danger: #FF8A7A;
  --danger-bg: #3A1D19;
  --danger-border: #5C2A23;
  --warning: #F7C873;
  --bg: #12140F;
  --card-bg: #1C1F18;
  --border: #30352B;
  --text: #EEF1E8;
  --text-muted: #A9B2A0;
  --sidebar-bg: #12140F;
  --sidebar-border: #262A21;
  --nav-hover: #252920;
  --th-bg: #22261E;
  --input-bg: #171A13;
  --row-hover: #22261E;
  --kpi-bg: #1F1E4A;
}
:root[data-theme="dark"] body { color: var(--text); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'NairaSign', var(--app-font, var(--font-body));
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
/* Consistent form controls */
input:not([type=checkbox]):not([type=radio]):not([type=file]),
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]):focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
select {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2364748b' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Native date/month pickers render their calendar-picker icon and popup
   using OS/browser chrome, not page CSS - without telling the browser which
   scheme is active, that chrome defaults to light and becomes unreadable
   (dark icon on a dark input, or a light popup that clashes) once the app
   is in dark mode. color-scheme is the correct fix: it's the same signal
   the browser uses for every other native control (scrollbars, etc). */
input[type=date], input[type=month], input[type=time], input[type=datetime-local] {
  color-scheme: light;
}
:root[data-theme="dark"] input[type=date],
:root[data-theme="dark"] input[type=month],
:root[data-theme="dark"] input[type=time],
:root[data-theme="dark"] input[type=datetime-local] {
  color-scheme: dark;
}

/* ---------- Custom dropdown (progressive enhancement over <select>) ---------- */
.custom-select { position: relative; width: 100%; }
.custom-select-native {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none;
}
.custom-select-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: inherit; font-size: 14px; text-align: left;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--input-bg); color: var(--text); cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.custom-select-trigger:hover { border-color: #94a3b8; }
.custom-select.open .custom-select-trigger,
.custom-select-native:focus + .custom-select-trigger {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring);
}
.custom-select-trigger:disabled { opacity: 0.6; cursor: not-allowed; }
.custom-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-chevron { flex-shrink: 0; color: var(--text-muted); display: flex; transition: transform 0.15s ease; }
.custom-select.open .custom-select-chevron { transform: rotate(180deg); }
.custom-select-listbox {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 24px -6px rgba(15,23,42,0.16), 0 2px 6px rgba(15,23,42,0.06);
  max-height: 240px; overflow-y: auto; padding: 4px 0;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.custom-select-listbox.drop-up { top: auto; bottom: calc(100% + 4px); transform: translateY(4px); }
.custom-select.open .custom-select-listbox { opacity: 1; transform: none; pointer-events: auto; }
/* Compact rows; the chosen one is a touch bolder with a check on the right. */
.custom-select-option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px; font-size: 13.5px; cursor: pointer; color: var(--text);
  white-space: nowrap; transition: background-color 0.1s ease;
}
.custom-select-option span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.custom-select-option:hover, .custom-select-option.active { background: var(--nav-hover); }
.custom-select-option.selected { font-weight: 600; }
.custom-select-option.selected::after {
  content: ''; flex-shrink: 0; width: 14px; height: 14px; background: var(--primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(1100px 550px at 50% -10%, #e7edff, #f4f6f9 62%);
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 38px 34px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 14px 44px rgba(15,23,42,0.10);
  border: 1px solid #eef1f6;
}
.login-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
  text-align: center;
}
.login-card p.sub {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 14px;
  text-align: center;
}

/* ---------- Loading spinner ---------- */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 20px; gap: 14px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #e2e8f0; border-top-color: var(--primary); animation: spin 0.75s linear infinite; }
.loading-text { color: var(--text-muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth / login screen ---------- */
/* This screen is a fixed brand treatment (blue gradient + a white card) that
   was never designed to have a dark variant - but its text/input colors
   still read from the shared theme variables, which DO flip when the viewer
   has dark mode on (a real, pre-login-reachable state: it's read from
   localStorage before any login happens). That left pale-on-white headings
   and a dark input box stranded inside the always-white card. Re-pinning the
   variables to their light values here, scoped to .auth, makes the whole
   screen immune to the app's dark-mode toggle instead of half-applying it. */
.auth {
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --input-bg: #ffffff;
  --card-bg: #ffffff;
  --nav-hover: #e9edf4;
  /* `color` is inherited, and body already resolved it to the dark-mode
     value before this override point in the tree - re-declaring it here
     (not just the custom properties above) forces everything under .auth
     that doesn't set its own color to re-resolve against the light values. */
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 64px;
  padding: 40px;
  background: linear-gradient(145deg, #1e3a8a 0%, #2563eb 52%, #6d5efc 100%);
}
.auth-pattern { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.13; pointer-events: none; }
.auth-brand { position: relative; z-index: 1; color: #fff; max-width: 400px; animation: zFadeUp 0.6s ease; }
.auth-brand .storefront { width: 150px; height: auto; margin-bottom: 22px; }
.auth-brand h2 { font-size: 30px; line-height: 1.15; margin: 0 0 12px; font-weight: 800; }
.auth-brand > p { font-size: 15px; line-height: 1.55; opacity: 0.9; margin: 0 0 22px; }
.auth-feats { list-style: none; margin: 0; padding: 0; }
.auth-feats li { position: relative; padding: 8px 0 8px 30px; font-size: 14.5px; opacity: 0.96; }
.auth-feats li::before { content: ''; position: absolute; left: 0; top: 8px; width: 19px; height: 19px; border-radius: 50%; background: rgba(255,255,255,0.22); }
.auth-feats li::after { content: ''; position: absolute; left: 6px; top: 12px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.auth-form { position: relative; z-index: 1; width: 400px; max-width: 100%; animation: zFadeUp 0.6s ease 0.05s both; }
.auth-form .login-card { box-shadow: 0 24px 60px rgba(15,23,42,0.28); }
@media (max-width: 880px) {
  .auth { padding: 20px; gap: 0; }
  .auth-brand { display: none; }
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.field input, .field select, .field textarea { width: 100%; }
.field textarea { resize: vertical; min-height: 64px; }
.field input[type=checkbox], .field input[type=radio] { width: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.error-msg { background: #fef2f2; color: var(--danger); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 16px; text-align: center; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  transition: transform 0.2s ease;
  z-index: 40;
  border-right: 1px solid var(--sidebar-border);
  padding: 8px 0;
  /* Fixed to the window height, so on short screens the nav must scroll or
     the bottom items (Settings, Users, theme, sign-out area) are unreachable. */
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar .brand {
  padding: 14px 16px 18px;
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(140deg, #2563eb, #6366f1);
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; font-weight: 700; font-size: 15px; color: var(--text); line-height: 1.2; min-width: 0; }
.brand-text small { font-weight: 400; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 3px 12px;
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: var(--nav-hover); color: var(--text); }
.nav-item.active { background: var(--card-bg); color: var(--primary); font-weight: 600; box-shadow: 0 2px 8px rgba(15,23,42,0.07); }
.nav-svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar-backdrop { display: none; }

/* ---------- Branches ---------- */
.branch-switcher { margin: 0 12px 10px; padding: 10px 12px 12px; background: var(--card-bg); border: 1px solid var(--sidebar-border); border-radius: 14px; }
.branch-switcher-label { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.branch-switcher .custom-select-trigger { min-height: 36px; font-size: 13px; font-weight: 600; }
.branch-locked { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--text); }
.branch-locked svg { width: 15px; height: 15px; color: var(--primary); flex-shrink: 0; }
.branch-pill { display: inline-flex; align-items: center; gap: 5px; margin-left: 10px; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--nav-hover); color: var(--text); font-size: 12px; font-weight: 600; white-space: nowrap; max-width: 40vw; min-width: 0; flex-shrink: 0; }
.branch-pill span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.branch-pill svg { width: 13px; height: 13px; color: var(--primary); flex-shrink: 0; }
/* The title side of the top bar gives way (ellipsis) before the sign-out
   side does, so a branch pill can never push Logout off a phone screen. */
.topbar > div:first-child { min-width: 0; flex: 1 1 auto; }
.topbar h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .user-chip { flex-shrink: 0; margin-left: 10px; }
@media (max-width: 560px) {
  .topbar h2 { font-size: 16px; }
  .branch-pill { flex-shrink: 1; max-width: 34vw; margin-left: 8px; font-size: 11.5px; }
}
.branch-note { margin: -4px 0 14px; padding: 8px 12px; border-radius: 8px; background: var(--th-bg); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.branch-note b { color: var(--text); }
.hint-block { margin: 10px 0 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover td { background: var(--row-hover); }

/* ---------- Money accounts & business position ---------- */
.money-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.money-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.money-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.money-card-head span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.money-card .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.position-list { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.position-list td { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.position-list td.num { text-align: right; white-space: nowrap; padding-left: 12px; }
.position-list tr.sub td { padding-left: 14px; font-size: 13px; color: var(--text-muted); }
.position-list tr.sub td.num { color: var(--text-muted); }
.position-list tr.total td { border-bottom: none; border-top: 2px solid var(--border); font-weight: 700; padding-top: 12px; }
.position-list tr.muted td { color: var(--text-muted); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .text-muted { font-size: 12px; }
.period-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.period-bar .field { margin: 0; }
.period-bar input[type="date"] { min-width: 150px; }
.sidebar-footer { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--sidebar-border); display: flex; align-items: center; gap: 10px; }
.sidebar-footer .avatar { width: 30px; height: 30px; font-size: 12px; }
.sidebar-footer-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.sidebar-footer-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h2 { margin: 0; font-size: 18px; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar .greeting { color: var(--text-muted); }
.topbar .greeting b { color: var(--text); font-weight: 600; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(140deg, #2563eb, #6366f1);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; text-transform: uppercase;
}
@media (max-width: 560px) { .topbar .user-chip .uname { display: none; } }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; margin-right: 12px; color: var(--text); }

.content { padding: 20px 24px 60px; flex: 1; }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card.accent-green .value { color: var(--success); }
.stat-card.accent-red .value { color: var(--danger); }
.stat-card.accent-blue .value { color: var(--primary); }
.stat-card.accent-orange .value { color: var(--warning); }

.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 12px; }
.section-title:first-child { margin-top: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--th-bg); font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1e40af; }
:root[data-theme="dark"] .badge-blue { background: #1e3a5f; color: #bfdbfe; }

/* ---------- Forms / Modals ---------- */
/* Any button that can't be used right now looks it (e.g. a form waiting
   for matching passwords, the pager's Previous on page 1). */
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; }

/* Terms / Privacy under the sign-in form */
.hint.legal-links { display: flex; justify-content: center; gap: 8px; font-size: 12.5px; margin-top: 6px; }
.hint.legal-links a { color: var(--text-muted); }

/* Password boxes: Show / Hide, and the "Passwords match" note */
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 64px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--primary); font: inherit; font-size: 12.5px; font-weight: 700; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.pw-toggle:hover { background: var(--th-bg); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.pw-match { font-size: 12.5px; margin-top: 6px; min-height: 0; }
.pw-match.ok { color: var(--success); }
.pw-match.bad { color: var(--danger); }
/* A From / To pair of dates, side by side (Staff Performance, P&L, Cash Flow) */
.date-range { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 12px; margin-bottom: 18px; }
.date-range .field { margin: 0; }
@media (max-width: 560px) { .date-range { grid-template-columns: 1fr 1fr; } }

/* Lists a page at a time (public/js/pager.js) */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 12px 2px 4px; font-size: 13px; }
.pager-count { color: var(--text-muted); }
.pager-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-num { min-width: 34px; justify-content: center; }
.pager-gap { color: var(--text-muted); padding: 0 4px; }
.pager-size { display: flex; align-items: center; gap: 8px; color: var(--text-muted); margin: 0; font-weight: 400; }
.pager-size .custom-select { width: 84px; }
@media (max-width: 640px) {
  .pager { justify-content: center; }
  .pager-count { width: 100%; text-align: center; }
}
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; }
/* Filter dropdowns sit side by side instead of each taking a whole row */
.toolbar .filters .custom-select { width: 180px; flex: 0 0 auto; }
.toolbar .filters { align-items: center; }
.search-input { min-width: 220px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
  animation: overlayIn 0.18s ease;
}
.modal-overlay .modal { animation: modalIn 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
.modal-overlay.closing { animation: overlayOut 0.18s ease forwards; }
.modal-overlay.closing .modal { animation: modalOut 0.16s ease forwards; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes modalOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-overlay .modal, .modal-overlay.closing, .modal-overlay.closing .modal,
  .drawer-overlay .drawer, .drawer-overlay.closing .drawer { animation: none; }
}
.modal-actions[hidden] { display: none !important; }
/* One popup at a time (api.js): a covered popup waits, hidden, as it was. */
.popup-hidden { display: none !important; }
/* Side drawer (openDrawer in api.js) - after DigAjo's: 520px from the right,
   a short settle-in (a few pixels and a fade, not a full-width slide), the
   body scrolls, the footer stays. Full screen below 780px. */
.modal-overlay.drawer-overlay { padding: 0; justify-content: flex-end; align-items: stretch; overflow: hidden;
  background: rgba(10, 14, 8, 0.44); animation: overlayIn 0.15s cubic-bezier(0.2, 0, 0, 1) both; cursor: pointer; }
.drawer { width: 520px; max-width: 100vw; height: 100%; background: var(--card-bg); display: flex; flex-direction: column; cursor: auto;
  border-left: 1px solid var(--border); box-shadow: 0 26px 54px -28px rgba(0, 0, 0, 0.28), -18px 0 40px -24px rgba(0, 0, 0, 0.22);
  animation: drawerIn 0.24s cubic-bezier(0.2, 0, 0, 1) both; }
.drawer-overlay.closing { animation: overlayOut 0.15s ease forwards; }
.drawer-overlay.closing .drawer { animation: drawerOut 0.15s ease forwards; }
@keyframes drawerIn { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes drawerOut { from { transform: none; opacity: 1; } to { transform: translateX(16px); opacity: 0; } }
.drawer:focus { outline: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); flex: none; }
.drawer-head-text { flex: 1; min-width: 0; }
.drawer-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drawer-title-row h3 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.drawer-badges { display: inline-flex; gap: 6px; }
.drawer-badges:empty, .drawer-subwrap:empty { display: none; }
.drawer-loading { padding: 48px 0; }
.drawer-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }
.drawer .intake-sections { display: block; }
.drawer .section-title { margin: 22px 0 8px; font-size: 14px; }
.drawer .intake-sections > div:first-child .section-title { margin-top: 2px; }
.drawer .intake-dl { grid-template-columns: minmax(120px, 160px) 1fr; }
.drawer-close { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-muted); cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.drawer-close:hover { background: var(--nav-hover); color: var(--text); }
.drawer-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 24px; }
.drawer-foot { flex: none; border-top: 1px solid var(--border); padding: 14px 20px; background: var(--th-bg); }
.drawer-foot .modal-actions { margin-top: 0; flex-wrap: wrap; gap: 9px; }
.drawer-foot:has(.drawer-actions:empty):not(:has(.inline-step)) { display: none; }
@media (max-width: 780px) {
  .drawer { width: 100vw; border-left: 0; }
}
@media (max-width: 560px) {
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 16px; padding-right: 16px; }
}
/* Every form / detail popup is shown as a side drawer (asDrawer in api.js);
   only confirmations (.confirm-overlay) stay centred. Same look and motion
   as the drawer above; the popup's own title pins to the top and its buttons
   to the bottom while the middle scrolls. */
.modal-overlay.as-drawer { padding: 0; justify-content: flex-end; align-items: stretch; overflow: hidden;
  background: rgba(10, 14, 8, 0.44); animation: overlayIn 0.15s cubic-bezier(0.2, 0, 0, 1) both; cursor: pointer; }
.as-drawer > .modal { position: relative; height: 100%; border-radius: 0; border-left: 1px solid var(--border); overflow-y: auto; overscroll-behavior: contain;
  padding: 0 20px; cursor: auto; box-shadow: 0 26px 54px -28px rgba(0, 0, 0, 0.28), -18px 0 40px -24px rgba(0, 0, 0, 0.22);
  animation: drawerIn 0.24s cubic-bezier(0.2, 0, 0, 1) both; display: flex; flex-direction: column; }
.as-drawer.closing { animation: overlayOut 0.15s ease forwards; }
.as-drawer.closing > .modal { animation: drawerOut 0.15s ease forwards; }
.as-drawer > .modal > h3:first-of-type { position: sticky; top: 0; z-index: 2; margin: 0 -20px 22px; padding: 18px 64px 16px 20px;
  background: var(--card-bg); border-bottom: 1px solid var(--border); font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.as-drawer .as-drawer-close { position: sticky; top: 14px; z-index: 3; align-self: flex-end; margin: 0 -8px -46px 0; }
.as-drawer > .modal > div:not(.modal-actions):not(.inline-step) { flex: none; }
/* A form fills the drawer so its buttons sit at the very bottom. */
.as-drawer > .modal > form { flex: 1 0 auto; display: flex; flex-direction: column; }
.as-drawer > .modal > form > .modal-actions { margin-top: auto; }
.as-drawer > .modal > form > *:nth-last-child(2) { margin-bottom: 20px; }
.as-drawer .modal-actions { position: sticky; bottom: 0; z-index: 2; margin: auto -20px 0; padding: 14px 20px; gap: 9px; flex-wrap: wrap;
  background: var(--th-bg); border-top: 1px solid var(--border); }
.as-drawer > .modal > *:last-child:not(.modal-actions):not(form) { margin-bottom: 20px; }
.as-drawer .inline-step { position: sticky; bottom: 12px; z-index: 2; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.25); }
.as-drawer > .modal.nudge { animation: drawerNudge 0.28s ease; }
@keyframes drawerNudge { 0%, 100% { transform: none; } 30% { transform: translateX(-6px); } 60% { transform: translateX(3px); } }
@media (max-width: 780px) {
  .as-drawer > .modal { width: 100vw !important; border-left: 0; }
}
@media (max-width: 560px) {
  .modal-overlay.as-drawer { padding: 0; align-items: stretch; }
  .as-drawer > .modal { padding: 0 16px; }
  .as-drawer > .modal > h3:first-of-type { margin: 0 -16px 22px; padding-left: 16px; }
  .as-drawer .modal-actions { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .as-drawer > .modal, .as-drawer.closing > .modal, .as-drawer > .modal.nudge { animation: none; }
}

/* A question asked inside a popup or drawer (inlineStep in api.js) */
.inline-step { border: 1.5px solid var(--primary); background: var(--primary-bg); border-radius: 16px; padding: 14px 16px; margin-top: 18px; }
.drawer-foot .inline-step { margin-top: 0; }
.inline-step.danger { border-color: var(--danger); background: var(--danger-bg); }
.inline-step-title { font-weight: 700; font-size: 15px; }
.inline-step-msg { margin: 4px 0 0; color: var(--text-muted); font-size: 13.5px; line-height: 1.5; }
.inline-step .field { margin: 12px 0 0; }
.inline-step-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.modal {
  background: var(--card-bg); border-radius: 20px; padding: 24px; width: 100%; max-width: 520px;
}
.modal h3 { margin: 0 0 18px; font-size: 17px; }
.modal .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.line-items-table { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.line-items-table table { min-width: 480px; }
.line-items-table input, .line-items-table select { width: 100%; padding: 6px 8px !important; border-radius: 8px; min-width: 60px; }
.text-muted { color: var(--text-muted); }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt-0 { margin-top: 0; }
.toast {
  position: fixed; bottom: 20px; right: 20px; background: #111827; color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 13px; z-index: 200; box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon { width: 54px; height: 54px; margin: 0 auto 14px; color: #cbd5e1; }
.empty-icon svg { width: 100%; height: 100%; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-sub { font-size: 13px; margin-top: 4px; max-width: 340px; margin-left: auto; margin-right: auto; line-height: 1.5; }

/* ---------- Responsive tables -> cards on small screens ---------- */
@media (max-width: 640px) {
  .table-wrap:not(.line-items-table) table thead { display: none; }
  .table-wrap:not(.line-items-table) table,
  .table-wrap:not(.line-items-table) table tbody { display: block; width: 100%; }
  .table-wrap:not(.line-items-table) table tr {
    display: block; padding: 6px 12px 10px;
    border-bottom: 1px solid var(--border);
  }
  .table-wrap:not(.line-items-table) table tr:last-child { border-bottom: none; }
  .table-wrap:not(.line-items-table) table td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 7px 0; border: none; white-space: normal; text-align: right;
  }
  .table-wrap:not(.line-items-table) table td::before {
    content: attr(data-label); font-weight: 600; color: var(--text-muted);
    font-size: 12px; text-align: left; flex-shrink: 0;
  }
  .table-wrap:not(.line-items-table) table td[colspan] { display: block; text-align: center; }
  .table-wrap:not(.line-items-table) table td[colspan]::before { display: none; }
  .table-wrap:not(.line-items-table) table td:not([data-label]) { justify-content: flex-end; flex-wrap: wrap; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-block; }
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .modal .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  /* A real element (not just a box-shadow) so it can actually capture the
     tap: closes the menu and swallows the click instead of letting it pass
     through to whatever button happens to be underneath. */
  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 39;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sidebar.open + .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}
@media (max-width: 480px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
  .toolbar .filters .custom-select { width: 100%; }
}

/* ---------- Redesigned dashboard ---------- */
@keyframes zFadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes zFadeIn { from { opacity: 0; } to { opacity: 1; } }

.zgrid-anim { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.zcard { opacity: 0; animation: zFadeUp 0.55s ease forwards; }
.zcard:nth-child(1) { animation-delay: 0.02s; }
.zcard:nth-child(2) { animation-delay: 0.10s; }
.zcard:nth-child(3) { animation-delay: 0.18s; }
.zcard:nth-child(4) { animation-delay: 0.26s; }
.zcard:nth-child(5) { animation-delay: 0.34s; }

.ztiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.ztile { border: 1px solid var(--border); border-radius: 16px; padding: 16px; position: relative; overflow: hidden; background: var(--card-bg); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.ztile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,0.07); }
.ztile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.ztile.a-indigo::before { background: #6366f1; }
.ztile.a-violet::before { background: #8b5cf6; }
.ztile.a-green::before { background: #22c55e; }
.ztile.a-rose::before { background: #ec4899; }
.ztile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ztile-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.ztile-value { font-size: 24px; font-weight: 800; margin-top: 8px; letter-spacing: -0.5px; }
.ztile-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.chg { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.chg.up { background: #dcfce7; color: #166534; }
.chg.down { background: #fee2e2; color: #991b1b; }

.zexp { display: flex; align-items: center; gap: 18px; }
.zexp-chart { width: 170px; flex-shrink: 0; }
.zexp-legend { flex: 1; min-width: 0; }
.leg-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; opacity: 0; animation: zFadeIn 0.5s ease forwards; }
.leg-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.leg-name { flex: 1; color: var(--text); }
.leg-pct { font-weight: 700; }

.zgauge { display: flex; flex-direction: column; align-items: center; }
.gauge-svg { width: 100%; max-width: 260px; }
.gauge-readout { text-align: center; margin-top: -6px; }
.gauge-score { font-size: 26px; font-weight: 800; }
.gauge-label { font-size: 13px; color: var(--text-muted); }

.zkpi { background: linear-gradient(150deg, #0f2417, #0b1120 72%); color: #e5e7eb; border: none; border-radius: 24px; }
.zkpi strong { color: #fff; }
.kpi-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 2px; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 14px; opacity: 0; animation: zFadeIn 0.5s ease forwards; }
.kpi-row:last-child { border-bottom: none; }
.kpi-val { font-weight: 700; color: #fff; }

/* Business goals on the dashboard: one tile per goal, a bar to the target
   and a faint mark where the business should be by today. */
.zgoals { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.zgoal { border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; background: var(--card-bg); cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; text-align: left; font: inherit; color: inherit; width: 100%; }
.zgoal:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,0.07); }
.zgoal:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.zgoal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.zgoal-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.zgoal-value { font-size: 20px; font-weight: 800; margin-top: 6px; letter-spacing: -0.4px; white-space: nowrap; }
.zgoal-value { overflow: hidden; text-overflow: ellipsis; }
.zgoal-of { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-top: 1px; white-space: nowrap; }
.zgoal-bar { position: relative; height: 8px; border-radius: 999px; background: var(--border); margin: 10px 0 8px; }
.zgoal-fill { height: 100%; border-radius: 999px; background: var(--primary); width: 0; transition: width 0.9s ease; }
.zgoal-fill.done { background: var(--success); }
.zgoal-fill.behind { background: var(--warning); }
.zgoal-mark { position: absolute; top: -3px; width: 2px; height: 14px; border-radius: 2px; background: var(--text); opacity: 0.35; }
.zgoal-sub { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; }
.zgoal-hist { display: flex; align-items: flex-end; gap: 10px; height: 120px; margin: 8px 0 4px; }
.zgoal-hist-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: 11.5px; color: var(--text-muted); }
.zgoal-hist-bar { width: 100%; max-width: 46px; border-radius: 8px 8px 3px 3px; background: var(--warning); min-height: 3px; }
.zgoal-hist-bar.hit { background: var(--success); }
@media (prefers-reduced-motion: reduce) { .zgoal-fill { transition: none; } }

/* Setup checklist: numbered steps, ticked off as they're done. */
.setup-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 4px 22px; }
.setup-step { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setup-mark { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; border: 1.5px solid var(--border); color: var(--text-muted); }
.setup-step.done .setup-mark { background: var(--success); border-color: var(--success); color: #fff; }
.setup-text { flex: 1; min-width: 0; }
.setup-title { font-size: 14px; font-weight: 600; }
.setup-sub { font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }
.setup-step.done .setup-title { color: var(--text-muted); text-decoration: line-through; text-decoration-thickness: 1px; }

@media (max-width: 900px) {
  .zgrid-anim { grid-template-columns: 1fr; }
  .ztiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .ztiles { grid-template-columns: 1fr; }
  .zexp { flex-direction: column; }
  .zexp-chart { width: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  .zcard, .leg-row, .kpi-row { animation: none; opacity: 1; }
  #gauge-needle { transition: none !important; }
}

/* ---------- Row hover + theme toggle ---------- */
.table-wrap:not(.line-items-table) table tbody tr { transition: background 0.12s ease; }
@media (min-width: 641px) {
  .table-wrap:not(.line-items-table) table tbody tr:hover { background: var(--row-hover); }
}
.theme-toggle {
  /* Sized to its text, not stretched across the sidebar */
  display: flex; align-items: center; gap: 9px; width: fit-content; max-width: calc(100% - 24px);
  margin: 0 12px 8px; padding: 9px 16px 9px 12px; border-radius: 12px;
  background: transparent; border: 1px solid var(--sidebar-border);
  color: var(--text-muted); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { background: var(--nav-hover); color: var(--text); }
.theme-toggle svg { width: 17px; height: 17px; }

/* Dark-mode tweaks for elements that read poorly on dark */
:root[data-theme="dark"] .btn-danger { background: rgba(220,38,38,0.14); border-color: rgba(220,38,38,0.35); }
:root[data-theme="dark"] .badge-gray { background: #24324a; color: #aebfd6; }
:root[data-theme="dark"] .badge-green { background: #173d2a; color: #86efac; }
:root[data-theme="dark"] .badge-orange { background: #452a14; color: #fdba74; }
:root[data-theme="dark"] .badge-red { background: #4a1d1d; color: #fca5a5; }
:root[data-theme="dark"] .ztile:hover { box-shadow: 0 8px 22px rgba(0,0,0,0.35); }
:root[data-theme="dark"] .topbar { border-bottom-color: var(--border); }

.sidebar-bottom { margin-top: auto; }

/* ---------- Skeleton shimmer ---------- */
.skel { position: relative; overflow: hidden; background: var(--border); border-radius: 8px; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent); animation: shimmer 1.3s infinite; }
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* ---------- Segmented choice (e.g. theme) ---------- */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--th-bg); }
.seg-opt { position: relative; cursor: pointer; margin: 0; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: block; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-muted); transition: background 0.15s ease, color 0.15s ease; }
.seg-opt input:checked + span { background: var(--card-bg); color: var(--primary); box-shadow: 0 1px 3px rgba(15,23,42,0.12), inset 0 0 0 1.5px var(--primary); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---------- Sidebar sections ---------- */
.nav-groups { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; }
.nav-group-head {
  /* Same height and padding as the items under it, so the hover matches. */
  display: flex; align-items: center; justify-content: space-between; width: calc(100% - 24px);
  min-height: 42px; margin: 2px 12px; padding: 9px 14px; background: none; border: none; border-radius: 12px; cursor: pointer;
  color: var(--text-muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-group-head:hover { background: var(--nav-hover); color: var(--text); }
.nav-group.has-active > .nav-group-head { color: var(--primary); }
.nav-group-head:focus:not(:focus-visible) { outline: none; }
.nav-group-head:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.nav-group-chevron { width: 14px; height: 14px; flex-shrink: 0; transition: transform 0.2s ease-in-out; transform: rotate(-90deg); }
.nav-group.open .nav-group-chevron { transform: none; }
/* One section open at a time; it slides open and shut. Its items hang off a
   thin guide line, indented under the heading. */
.nav-group-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.2s ease-in-out; }
.nav-group.open .nav-group-items { grid-template-rows: 1fr; }
.nav-group-inner { overflow: hidden; min-height: 0; }
.nav-group-list { margin: 2px 12px 6px 26px; padding-left: 8px; border-left: 2px solid var(--border); }
.nav-groups .nav-group-list .nav-item { padding: 9px 8px; margin: 2px 0; gap: 10px; }
/* A menu label never wraps - the bold of the selected item used to push
   "Staff Performance" onto two lines. */
.nav-item { white-space: nowrap; overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .nav-group-items, .nav-group-chevron { transition: none !important; }
}

/* ---------- Inventory: variations ---------- */
.btn-link { background: none; border: none; padding: 0 6px 0 0; color: var(--text-muted); font-size: 13px; cursor: pointer; }
.btn-link:hover { color: var(--text); }
.variant-row td { background: var(--th-bg); font-size: 13.5px; }
.row-muted td { opacity: 0.6; }

.row-menu { position: fixed; z-index: 1000; min-width: 170px; padding: 6px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 28px rgba(15,23,42,0.16); }
.row-menu button { display: block; width: 100%; text-align: left; padding: 8px 12px; border: none; background: none; border-radius: 8px; font-size: 14px; color: var(--text); }
.row-menu button:hover, .row-menu button:focus-visible { background: var(--nav-hover); outline: none; }
.row-menu button.danger { color: var(--danger); }
[data-more], [data-vmore] { min-width: 34px; padding-left: 8px; padding-right: 8px; font-weight: 700; letter-spacing: 1px; }

.set-row { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; gap: 10px; align-items: end; margin-bottom: 4px; }
.set-row .field { margin-bottom: 10px; }
.set-row .set-remove { margin-bottom: 12px; }

.unit-row { display: grid; grid-template-columns: minmax(80px, 1fr) auto 70px auto minmax(90px, 1fr) auto; gap: 6px; align-items: center; margin-bottom: 6px; font-size: 13px; }
.unit-row input { padding: 7px 9px !important; }

/* Inventory: let the item column wrap so row actions stay on screen */
#inv-tbody td:first-child { white-space: normal; min-width: 180px; max-width: 300px; }
#inv-tbody td:first-child .badge { margin-top: 2px; }

/* =====================================================================
   Market Day theme layer. Same screens, same data - only the look.
   ===================================================================== */
h1, h2, h3, .topbar h2, .modal h3, .section-title, .card-head h3, .brand-text,
.stat-card .value, .ztile-value, .money-card .value, .gauge-score, .empty-title {
  font-family: 'NairaSign', var(--app-font, var(--font-display));
  letter-spacing: -0.01em;
}
.stat-card .value, .ztile-value, .money-card .value { letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* Inputs: a little taller, softer corners */
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea, .custom-select-trigger {
  border-radius: 12px; min-height: 42px;
}
textarea { min-height: 64px; }
.custom-select-trigger:hover { border-color: var(--text-muted); }
.field label { color: var(--text); font-weight: 700; }

/* Buttons: pill shaped, bold */
.btn { border-radius: 999px; padding: 10px 18px; font-weight: 700; min-height: 40px; transition: background 0.15s ease, opacity 0.15s ease; }
.btn-sm { padding: 6px 13px; min-height: 34px; font-size: 13px; }
.btn-primary { color: var(--on-primary); }
.btn-outline { background: var(--card-bg); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--text-muted); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1.5px solid var(--danger-border); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: var(--danger); opacity: 0.9; }
:root[data-theme="dark"] .btn-danger-solid { color: #12140F; }
:root[data-theme="dark"] .btn-danger { background: var(--danger-bg); border-color: var(--danger-border); }
.btn-primary:focus-visible, .btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.error-msg { background: var(--danger-bg); color: var(--danger); border-radius: 12px; }

/* Cards and tables sit on the ground without hard outlines */
.card, .table-wrap, .money-card, .ztile, .branch-switcher { border-color: transparent; }
.card { border-radius: 22px; }
.table-wrap { border-radius: 20px; }
.money-card { border-radius: 18px; }
th { background: var(--th-bg); letter-spacing: 0.04em; }
.modal { border-radius: 24px; }
.modal-overlay { background: rgba(18, 20, 15, 0.55); }

/* Badges */
/* Pills: one line always (never "Not / added"), a small dot in the pill's
   own colour, and a hairline edge so the grey ones still read on a card. */
.badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; vertical-align: middle;
  padding: 4px 10px 4px 9px; font-size: 11.5px; font-weight: 700; line-height: 1.35; letter-spacing: 0.01em; border: 1px solid transparent; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; flex: none; }
.addon-row .badge, .admin-addon-row .badge { flex: none; }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-orange { background: var(--sun-bg); color: var(--sun-text); }
.badge-blue { background: var(--primary-bg); color: var(--primary); }
.badge-gray { background: var(--th-bg); color: var(--text-muted); border-color: var(--border); }
:root[data-theme="dark"] .badge-green { background: var(--success-bg); color: var(--success); }
:root[data-theme="dark"] .badge-red { background: var(--danger-bg); color: var(--danger); }
:root[data-theme="dark"] .badge-orange { background: var(--sun-bg); color: var(--sun-text); }
:root[data-theme="dark"] .badge-blue { background: var(--primary-bg); color: var(--primary); }
:root[data-theme="dark"] .badge-gray { background: var(--th-bg); color: var(--text-muted); }
.chg.up { background: var(--success-bg); color: var(--success); }
.chg.down { background: var(--danger-bg); color: var(--danger); }

/* Sidebar */
.sidebar { border-right: none; padding: 10px 0; }
.brand-mark { background: var(--primary); border-radius: 12px; }
.brand-text { font-size: 16px; }
.nav-item { color: var(--text); border-radius: 12px; min-height: 42px; }
.nav-item:hover { background: var(--nav-hover); }
.nav-item.active { background: var(--primary); color: var(--on-primary); font-weight: 700; box-shadow: none; }
.nav-group-head { color: var(--text-muted); opacity: 1; }
.branch-switcher { background: var(--card-bg); border-radius: 16px; }
.theme-toggle { border-radius: 999px; border-color: var(--border); color: var(--text); }
/* The divider lines up with the buttons above it instead of running to the page edge */
.sidebar-footer { border-top-color: var(--border); margin: 4px 12px 0; padding: 12px 4px; }
.avatar { background: var(--sun); color: #1A1F16; }

/* Top bar blends into the page */
.topbar { background: var(--bg); border-bottom: none; padding: 16px 24px 8px; }
.topbar h2 { font-size: 24px; font-weight: 800; }
:root[data-theme="dark"] .topbar { border-bottom: none; }
.branch-pill { background: var(--card-bg); }

/* Dashboard tiles: no side stripes; the first tile carries the colour */
.ztile { border-radius: 22px; }
.ztile::before { display: none; }
.ztile.a-indigo { background: var(--primary); color: var(--on-primary); }
.ztile.a-indigo .ztile-label, .ztile.a-indigo .ztile-sub { color: var(--on-primary); opacity: 0.85; }
.ztile.a-rose { background: var(--sun-bg); }
.ztile:hover { box-shadow: none; transform: none; }
.zkpi { background: var(--kpi-bg); border-radius: 22px; }
.segmented { border-radius: 999px; border-color: var(--border); background: var(--card-bg); }
.seg-opt span { border-radius: 999px; }
.seg-opt input:checked + span { background: var(--primary); color: var(--on-primary); box-shadow: none; }

/* Login: solid indigo with the marigold mark */
.auth { background: #2B2A8C; --primary: #2B2A8C; --primary-dark: #1F1E6B; --on-primary: #FFFFFF; --primary-bg: #E7E7F7; --focus-ring: rgba(43, 42, 140, 0.18); --danger: #A8261A; --danger-bg: #FBE3E0; --th-bg: #F6F8F3; }
.auth .login-card { border-radius: 24px; border: none; }
.login-card h1 { font-family: var(--font-display); font-size: 26px; font-weight: 800; }
.auth-brand h2 { font-family: var(--font-display); font-size: 38px; letter-spacing: -0.02em; }
.auth .btn-primary { background: #2B2A8C; color: #fff; }
.auth .avatar, .auth .brand-mark { background: #F4B23E; color: #1A1F16; }

.toast { border-radius: 14px; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
:root[data-theme="dark"] .toast.error, :root[data-theme="dark"] .toast.success { color: #12140F; }
.spinner { border-color: var(--border); border-top-color: var(--primary); }
.empty-icon { color: var(--border); }

/* ---------- Phones ---------- */
.tabbar { display: none; }
@media (max-width: 768px) {
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: var(--card-bg); border-radius: 22px 22px 0 0;
    box-shadow: 0 -1px 0 var(--border), 0 -8px 24px rgba(18, 20, 15, 0.06);
    padding: 4px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab-item {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 54px; border: 0; background: none; color: var(--text-muted);
    font-size: 11.5px; font-weight: 700; border-radius: 14px; padding: 4px 0;
  }
  .tab-item .nav-svg { width: 22px; height: 22px; }
  .tab-item.active { color: var(--primary); }
  .tab-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
  .content { padding-bottom: 104px; }
  .toast { bottom: 92px; left: 16px; right: 16px; }
  .topbar { padding: 12px 16px 6px; }
  .topbar h2 { font-size: 20px; }
  /* Bigger tap targets; 16px text stops phones zooming into fields */
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea, .custom-select-trigger { font-size: 16px; min-height: 46px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .nav-item { min-height: 46px; }
  /* Pop-ups rise from the bottom and use the full width */
  .modal-overlay { padding: 24px 0 0; align-items: flex-end; }
  .modal { border-radius: 24px 24px 0 0; max-width: 100%; padding: 22px 18px calc(24px + env(safe-area-inset-bottom)); }
}

/* Sign-in pages: fields need a visible edge on the white card */
.auth .field input:not([type=checkbox]):not([type=radio]), .auth .field select, .auth .custom-select-trigger, .auth .slug-input {
  background: #F6F6F1; border: 1px solid #CFD3C8;
}
.auth .field input:not([type=checkbox]):not([type=radio]):focus, .auth .custom-select-trigger:focus, .auth .slug-input:focus-within {
  background: #fff; border-color: #2B2A8C; box-shadow: 0 0 0 3px rgba(43, 42, 140, 0.16);
}
.auth .slug-input input { background: transparent !important; border: 0 !important; }
/* Sign-up: two columns on wider screens, one on phones */
.auth-form.wide { width: 640px; }
.auth-form.wide .login-card { max-width: none; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
.form-2col .span-2 { grid-column: 1 / -1; }
.form-2col .field { min-width: 0; }
@media (max-width: 1180px) { .auth:has(.auth-form.wide) .auth-brand { display: none; } }
@media (max-width: 640px) { .form-2col { grid-template-columns: 1fr; } .auth-form.wide .login-card { padding: 30px 22px; } }

/* ---------- SabiLedger admin console ---------- */
.admin-auth .login-card { text-align: left; }
.admin-mark, .admin-brand { width: 44px; height: 44px; border-radius: 14px; background: #2B2A8C; color: #F4B23E; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.admin-mark svg, .admin-brand svg { width: 24px; height: 24px; }
.admin-brand { width: 36px; height: 36px; margin: 0; border-radius: 12px; }
.admin-brand { background: var(--primary); color: var(--sun); }
:root[data-theme="dark"] .admin-brand { color: var(--on-primary); }
.admin-auth .login-card h1, .admin-auth .login-card p.sub { text-align: left; }
.otp-input { letter-spacing: 6px; font-size: 20px !important; text-align: center; }
.admin-banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; margin-bottom: 16px; border-radius: 16px; background: var(--primary-bg); color: var(--text); font-size: 13.5px; line-height: 1.5; }
.admin-banner svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--primary); margin-top: 1px; }
.admin-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .admin-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .admin-tiles { grid-template-columns: 1fr; } }
.admin-tile.sun { background: var(--sun-bg); }
.admin-tile { background: var(--card-bg); border-radius: 22px; padding: 18px 20px; min-width: 0; }
.admin-tile-label { font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.admin-tile-value { font-family: 'NairaSign', var(--app-font, var(--font-display)); font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.admin-tile-note { font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-top: 2px; }
.admin-tile.primary { background: var(--primary); }
.admin-tile.ink { background: var(--text); }
.admin-tile.primary div, .admin-tile.primary .admin-tile-label, .admin-tile.primary .admin-tile-note { color: var(--on-primary); }
.admin-tile.ink div, .admin-tile.ink .admin-tile-label, .admin-tile.ink .admin-tile-note { color: var(--bg); }
.admin-biz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.admin-biz-head h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.admin-feed-row { display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.admin-feed-row:first-child { border-top: none; }
.admin-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--primary); margin-top: 5px; }
.admin-team-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; }
.admin-team-row:first-of-type { border-top: none; }
.btn-svg { width: 16px; height: 16px; }
.admin-waiting { margin-bottom: 16px; border: 2px solid var(--sun) !important; }
.admin-waiting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.admin-waiting-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .admin-waiting-row { flex-direction: column; align-items: stretch; } .admin-waiting-actions { justify-content: flex-start; } }
.admin-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.admin-flag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--danger-bg); color: var(--danger); white-space: nowrap; }
.admin-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-filter { border: 1px solid var(--border); background: var(--card-bg); color: var(--text); border-radius: 999px; padding: 8px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.admin-filter span { color: var(--text-muted); font-weight: 700; margin-left: 2px; }
.admin-filter.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.admin-filter.active span { color: var(--on-primary); opacity: 0.8; }
.admin-log-filters select { width: auto; min-width: 180px; }
.admin-approve { margin-bottom: 16px; border: 2px solid var(--sun) !important; }
/* An address field with its domain shown after it */
.slug-input { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--input-bg); overflow: hidden; }
.slug-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.slug-input input { border: 0 !important; box-shadow: none !important; flex: 1 1 auto; min-width: 0; background: transparent !important; }
.slug-input span { padding: 0 12px 0 2px; color: var(--text-muted); font-size: 14px; white-space: nowrap; }
.slug-status { font-size: 12.5px; margin-top: 6px; min-height: 16px; }
.slug-status.ok { color: var(--success); }
.slug-status.bad { color: var(--danger); }
/* Sign-in page on a business's own address, and the waiting screen */
.biz-logo { display: block; max-height: 64px; max-width: 70%; margin: 0 auto 10px; object-fit: contain; }
.biz-initial { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px; background: var(--sun); color: #1A1F16; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 26px; }
.hint.powered { font-size: 12px; opacity: 0.8; }
.waiting-card { text-align: center; }
.waiting-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 999px; background: var(--sun-bg, #FFF1D6); color: #7A4B00; display: flex; align-items: center; justify-content: center; }
.waiting-icon.no { background: var(--danger-bg); color: var(--danger); }
.waiting-icon svg { width: 28px; height: 28px; }
.waiting-reason { background: var(--th-bg); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin: 0 0 16px; }
.signin-address { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 16px; border-radius: 14px; background: var(--primary-bg); }
/* Demo business banner */
.demo-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 24px 0; padding: 10px 14px; border-radius: 14px; background: var(--sun-bg); color: var(--text); font-size: 13.5px; }
.demo-banner a { font-weight: 700; color: var(--primary); }
@media (max-width: 768px) { .demo-banner { margin: 8px 16px 0; } }

/* Add-on switches (admin console) */
.admin-addons { margin-bottom: 16px; }
.admin-addon-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.admin-addon-row:first-child { border-top: none; padding-top: 2px; }
.switch { position: relative; display: inline-flex; flex-shrink: 0; width: 44px; height: 26px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { width: 100%; height: 100%; border-radius: 999px; background: #C3C7BC; transition: background-color 0.18s ease; position: relative; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.18s ease; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.6; }
.addon-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.addon-row:first-of-type { border-top: none; }
:root[data-theme="dark"] .switch-track { background: #4A4F45; }
/* Product tags */
.tag-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
/* Inventory: room between the lines under an item name; the branch split
   sits under the stock figure it explains; row buttons line up on the right
   so the "..." is in the same place on every row. */
.inv-sub { font-size: 12px; color: var(--text-muted); line-height: 1.45; margin-top: 3px; }
.inv-where { margin-top: 5px; font-size: 11.5px; line-height: 1.5; color: var(--text-muted); white-space: nowrap; }
.inv-where span { opacity: .85; }
.row-acts { display: flex; justify-content: flex-end; align-items: center; gap: 6px; white-space: nowrap; }
.row-acts > .btn { margin: 0; }
.tag-chip { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 700; line-height: 1; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.tag-indigo { background: #E7E7F7; color: #2B2A8C; }
.tag-green { background: #E2F2E6; color: #1F6B36; }
.tag-amber { background: #FDF0D5; color: #7A4B00; }
.tag-red { background: #FBE3E0; color: #A8261A; }
.tag-blue { background: #E1EDFB; color: #1D4F91; }
.tag-teal { background: #DDF2EF; color: #11645A; }
.tag-pink { background: #FBE4EF; color: #9B2257; }
.tag-gray { background: #ECEDE8; color: #4D524A; }
:root[data-theme="dark"] .tag-chip { filter: saturate(1.1); background: color-mix(in srgb, currentColor 18%, transparent); }
:root[data-theme="dark"] .tag-indigo { color: #B9B8F2; } :root[data-theme="dark"] .tag-green { color: #8FD6A3; }
:root[data-theme="dark"] .tag-amber { color: #F4C873; } :root[data-theme="dark"] .tag-red { color: #F2A196; }
:root[data-theme="dark"] .tag-blue { color: #9CC2F2; } :root[data-theme="dark"] .tag-teal { color: #86D6CB; }
:root[data-theme="dark"] .tag-pink { color: #F2A3C6; } :root[data-theme="dark"] .tag-gray { color: #C4C8BF; }
.tag-pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; margin-bottom: 12px; }
.tag-pick { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.tag-pick:hover { background: var(--nav-hover); }
.tag-pick input { width: auto; }
.tag-new-row { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.tag-new-row input { flex: 1 1 auto; min-width: 0; }
.tag-manage-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.tag-manage-row:first-child { border-top: none; }
.tag-manage-row .custom-select, .tag-manage-row select { width: 110px; }
/* Uploading a list */
.upload-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 28px 16px; margin: 6px 0 4px; border: 2px dashed var(--border); border-radius: 16px; cursor: pointer; text-align: center; transition: border-color 0.15s ease, background-color 0.15s ease; }
.upload-drop:hover, .upload-drop.over { border-color: var(--primary); background: var(--primary-bg); }
.upload-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-drop:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.upload-drop-title { font-weight: 700; color: var(--primary); }
.upload-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.upload-summary > div { background: var(--th-bg); border-radius: 14px; padding: 10px 14px; }
.upload-summary b { display: block; font-size: 22px; font-family: var(--font-display); }
.upload-summary span { font-size: 12.5px; color: var(--text-muted); }
.upload-summary .bad b { color: var(--danger); }

/* ---------- Date picker (public/js/datepicker.js) ---------- */
.dp-field { position: relative; display: block; width: 100%; min-width: 0; }
.dp-native { position: absolute !important; left: 0; bottom: 0; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; opacity: 0; pointer-events: none; }
.dp-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 42px;
  font-family: inherit; font-size: 14px; text-align: left; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; background: var(--input-bg); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dp-trigger:hover { border-color: var(--text-muted); }
.dp-trigger:focus-visible, .dp-open .dp-trigger { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.dp-trigger svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-muted); }
.dp-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-trigger .dp-placeholder { color: var(--text-muted); }
.dp-trigger:disabled { opacity: 0.6; cursor: not-allowed; }
.dp-trigger.dp-invalid { border-color: var(--danger); }
.auth .dp-trigger { background: #F6F6F1; border-color: #CFD3C8; }
@media (max-width: 768px) { .dp-trigger { font-size: 16px; min-height: 46px; } }

.dp-pop {
  position: fixed; z-index: 10001; width: 300px; max-width: calc(100vw - 16px); padding: 12px;
  background: var(--card-bg); color: var(--text); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 16px 36px -8px rgba(15,23,42,0.22), 0 2px 6px rgba(15,23,42,0.06);
  animation: dpIn 0.14s ease;
}
@keyframes dpIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.dp-title { display: flex; gap: 4px; }
.dp-title select { min-height: 32px !important; padding: 4px 26px 4px 10px; font-size: 14px; font-weight: 700; border-radius: 10px !important; background-position: right 9px center; border-color: transparent; background-color: transparent; }
.dp-title select:hover { background-color: var(--nav-hover); }
.dp-nav { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; }
.dp-nav:hover { background: var(--nav-hover); }
.dp-nav svg { width: 16px; height: 16px; }
.dp-week { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px; }
.dp-week span { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--text-muted); padding: 4px 0; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-day { height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; font-variant-numeric: tabular-nums; }
.dp-day:hover:not(:disabled) { background: var(--nav-hover); }
.dp-day.out { color: var(--text-muted); opacity: 0.55; }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); font-weight: 700; }
.dp-day.sel { background: var(--primary); color: var(--on-primary); font-weight: 700; opacity: 1; }
.dp-day:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.dp-day:disabled { opacity: 0.3; cursor: not-allowed; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.dp-link { border: 0; background: none; color: var(--primary); font: inherit; font-size: 13.5px; font-weight: 700; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.dp-link:hover:not(:disabled) { background: var(--primary-bg); }
.dp-link:disabled { opacity: 0.4; cursor: not-allowed; }

/* While a pop-up is open the page behind it stays still. */
html.modal-open, html.modal-open body { overflow: hidden; }
.modal-overlay { overscroll-behavior: contain; }
/* CNG add-on: vehicles and NIN */
.plate-chip { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 6px; background: var(--th-bg); border: 1px solid var(--border); white-space: nowrap; }
.cng-section { padding: 14px 0; border-top: 1px solid var(--border); }
.cng-section:first-of-type { border-top: none; padding-top: 4px; }
.cng-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cng-section-head h4 { margin: 0; font-size: 14px; }
.cng-nin-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cng-nin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: 0.06em; flex: 1 1 auto; }
.cng-vehicle { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--border); }
.cng-vehicle-form { background: var(--th-bg); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
/* Scanning into a sale */
.scan-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; padding: 0 12px; border: 1px dashed var(--border); border-radius: 12px; background: var(--th-bg); }
.scan-row:focus-within { border-style: solid; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.scan-row svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--text-muted); }
.scan-row input { border: 0 !important; box-shadow: none !important; background: transparent !important; flex: 1 1 auto; padding-left: 0; }
/* Text messages */
.sms-setup-note { background: var(--sun-bg); margin-bottom: 14px; font-size: 13.5px; }
.sms-setup-note a { color: var(--primary); font-weight: 700; }
.sms-fillins { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sms-choice { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; cursor: pointer; font-weight: 500 !important; color: var(--text) !important; }
.sms-choice input { width: auto; }
.sms-pick { border: 1px solid var(--border); border-radius: 12px; padding: 10px; max-height: 260px; overflow-y: auto; }
.sms-pick-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 6px 4px; font-size: 13.5px; cursor: pointer; font-weight: 500 !important; color: var(--text) !important; }
.sms-pick-row input { width: auto; }
.sms-preview { margin-top: 12px; }
.sms-bubble { background: var(--primary-bg); border-radius: 14px 14px 14px 4px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; margin-bottom: 8px; }
.sms-template-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.sms-template-form { margin-bottom: 12px; }
/* Help */
.help-hero { background: var(--primary); color: var(--on-primary); border-radius: 22px; padding: 22px 24px; margin-bottom: 16px; }
.help-hero h3 { margin: 0 0 12px; color: var(--on-primary); font-size: 22px; }
.help-hero .search-input { width: 100%; max-width: 560px; background: #fff; color: #1A1F16; }
.help-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 14px; }
.help-cat h4, .help-list h4 { margin: 0 0 6px; font-size: 14px; }
.help-link { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; margin: 0 -10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; }
.help-link:hover { background: var(--nav-hover); color: var(--primary); }
.help-link .text-muted { font-size: 12px; white-space: nowrap; }
.help-article { max-width: 760px; margin-top: 12px; }
.help-article h2 { margin: 2px 0 12px; font-size: 24px; }
.help-cat-label { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); }
.help-body { font-size: 15px; line-height: 1.65; }
.help-body h4 { margin: 18px 0 6px; font-size: 15px; }
.help-body ol, .help-body ul { padding-left: 22px; margin: 8px 0 12px; }
.help-body li { margin: 4px 0; }
.help-body a { color: var(--primary); font-weight: 600; }
.help-btn { width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); font-weight: 800; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.help-btn:hover { border-color: var(--primary); color: var(--primary); }
/* Settings: two columns that stack independently, full width */
.settings-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.settings-col > .card { margin: 0; }
.settings-col > .card:empty { display: none; }
@media (max-width: 1000px) { .settings-cols { grid-template-columns: minmax(0, 1fr); } }
/* Paired fields sit side by side on pages too (not only in pop-ups) */
.card .form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); column-gap: 14px; }
.card .form-row.form-row-3 { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
.card .form-row > .field { min-width: 0; }

/* Team > Roles: one card per role, and the tick-box editor. */
.role-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; align-items: start; }
.role-card { margin: 0; }
.role-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.role-card-head h3 { margin-bottom: 2px; }
.role-meta { font-size: 12.5px; }
.role-sum { margin-top: 12px; display: grid; gap: 6px; }
.role-group-sum { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.role-group-sum ul { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.role-peek .role-group-sum { display: block; }
.role-group-name { font-weight: 600; }
.role-all { margin: 0; font-size: 13px; }
.role-modal { max-width: 760px; width: 100%; }
.role-pick-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 4px 0 10px; font-size: 12.5px; flex-wrap: wrap; }
.role-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.role-group { border: 1px solid var(--border); border-radius: 12px; padding: 4px 12px 10px; margin: 0; min-width: 0; }
.role-group legend { padding: 0 4px; }
.role-check { display: flex; align-items: flex-start; gap: 9px; padding: 5px 0; font-size: 13.5px; line-height: 1.4; cursor: pointer; }
.role-check input { margin-top: 2px; flex: none; width: 16px; height: 16px; accent-color: var(--primary); }
.role-check-group { font-weight: 700; font-size: 13px; text-transform: none; }
.role-peek { margin: 0 0 14px; font-size: 13px; }
.role-peek summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.role-peek > div { margin-top: 8px; display: grid; gap: 6px; }
@media (max-width: 560px) {
  .role-card-head { flex-direction: column; }
  .role-card-head .row-acts { justify-content: flex-start; }
}
.roles-table td { vertical-align: middle; }
.roles-table th.num, .roles-table td.num { white-space: nowrap; }
.roles-table .role-meta { margin-top: 2px; }
/* Team > Add/Edit User: ticking what one person can do. */
.person-rights { border-top: 1px solid var(--border); margin: 6px 0 14px; padding-top: 14px; }
.person-rights-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; font-size: 14px; }
.person-rights-head .text-muted { font-size: 12.5px; }
.person-rights-head .pr-changed { color: var(--primary); font-weight: 600; }
.person-rights .btn-link { margin-top: 8px; font-size: 12.5px; color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
[data-rp].is-disabled .role-groups { opacity: 0.6; }
/* Settings > Extra fields */
.fields-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.fields-head .admin-filters { margin-bottom: 0; }
.fields-list { border-top: 1px solid var(--border); }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.field-row.is-off .field-row-main { opacity: 0.6; }
.field-row-main { min-width: 0; flex: 1 1 180px; }
/* Admin console > Set-up template */
.admin-tpl-preview { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; font-size: 13px; }
.admin-tpl-preview ul { margin: 0; padding-left: 18px; line-height: 1.6; }
.admin-tpl-preview + .btn { margin-top: 10px; }
/* Billing */
.bl-groups { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 4px 0; }
.fee-table td { vertical-align: middle; }
.fee-table input[data-fl-amount] { max-width: 140px; text-align: right; }
.modal .section-title { margin: 16px 0 8px; font-size: 14px; }
.cf-list { list-style: none; margin: 0 0 6px; padding: 0; font-size: 13.5px; }
.cf-list li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.bl-summary { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.modal .form-row.form-row-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0 14px; }
/* Website intake */
.line-locked .custom-select, .line-locked .line-item-select { pointer-events: none; opacity: .75; }
.line-locked .line-qty, .line-locked .line-price, .line-locked .line-discount { background: var(--th-bg); }
.wp-list { display: grid; gap: 12px; }
.wp-row { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; background: var(--card-bg); }
.wp-head { display: flex; align-items: flex-end; gap: 12px; }
.wp-head .wp-item { flex: 1; min-width: 0; margin-bottom: 0; }
.wp-head .btn { flex: none; margin-bottom: 2px; }
.wp-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 0 12px; margin-top: 12px; }
.wp-fields .field { margin-bottom: 10px; }
.intake-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.btn.intake-copy { padding: 1px 9px; min-height: 0; font-size: 11.5px; line-height: 1.6; margin: 0 2px; vertical-align: 1px; }
.wp-loan { margin: 2px 0 0; }
.intake-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.intake-photos { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.intake-photos figure { margin: 0; text-align: center; }
.intake-photos img { width: 120px; height: 150px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--th-bg); }
.intake-photos figcaption { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: capitalize; }
.intake-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 0 20px; }
.intake-dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 13.5px; }
.intake-dl dt { color: var(--text-muted); }
.intake-dl dd { margin: 0; overflow-wrap: anywhere; }

/* An error inside a popup or drawer (toast() puts it here, never on top). */
.inline-error { display: flex; align-items: flex-start; gap: 10px; background: var(--danger-bg, #fef2f2); color: var(--danger); border: 1px solid var(--danger-border);
  border-radius: 10px; padding: 9px 10px 9px 12px; font-size: 13px; line-height: 1.45; margin: 12px 0; animation: inline-error-in .18s ease-out; }
.inline-error span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.inline-error-x { background: none; border: 0; color: inherit; font-size: 18px; line-height: 1; padding: 0 2px; cursor: pointer; opacity: .7; }
.inline-error-x:hover { opacity: 1; }
@keyframes inline-error-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .inline-error { animation: none; } }

/* A customer's record (customers.js openCustomerRecord). */
.row-link { background: none; border: 0; padding: 0; font: inherit; color: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.row-link:hover { color: var(--primary); }
.cr-vehicle { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; padding: 6px 0; border-top: 1px solid var(--border); }
.cr-vehicle:first-of-type { border-top: 0; }
.cr-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cr-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 13.5px; color: inherit;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.cr-item:hover { border-color: var(--primary); }
.cr-item-tall { align-items: flex-start; }
.cr-item > span:first-child { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cr-item-sub { font-size: 12.5px; color: var(--text-muted); overflow-wrap: anywhere; }
.cr-item-end { white-space: nowrap; display: flex; align-items: center; gap: 8px; }

/* New sale: searching website codes, and what the website sent. */
.code-pick { position: relative; }
.code-pick-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.12); max-height: 300px; overflow: auto; padding: 4px; }
.code-pick-row { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; font: inherit; font-size: 13px; color: inherit; background: none; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.code-pick-row:hover, .code-pick-row.active { background: var(--primary-bg); }
.code-pick-meta { font-size: 12px; color: var(--text-muted); }
.code-pick-empty { font-size: 12.5px; margin: 8px 10px; }
.code-details { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.code-details summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.code-details .section-title { margin-top: 10px; }
.intake-text { padding: 8px 0; border-top: 1px solid var(--border); }
.intake-text:first-of-type { border-top: 0; }

/* Counts of things waiting (e.g. new website items) on menu items and tabs. */
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 19px; height: 19px; padding: 0 6px; margin-left: auto;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.admin-filter .count-badge { margin-left: 7px; color: #fff; font-weight: 700; }
.admin-filter.active .count-badge { background: #fff; color: var(--primary); }
.nav-group-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-left: auto; margin-right: 8px; flex: none; }
.nav-group.open .nav-group-dot { display: none; }

/* A button waiting for the server (api.js "One click at a time"): its label
   gives way to a spinner and it takes no clicks until the answer is back. */
.is-busy { position: relative; pointer-events: none; color: transparent !important; }
.is-busy > * { visibility: hidden; }
.is-busy::after { content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--busy-ink, #fff) var(--busy-ink, #fff) var(--busy-ink, #fff) transparent; opacity: .9; animation: busy-spin .7s linear infinite; }
.btn-outline.is-busy, .btn-danger.is-busy, .admin-filter.is-busy, .row-link.is-busy, .cr-item.is-busy { --busy-ink: var(--primary); }
@keyframes busy-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .is-busy::after { animation-duration: 1.6s; } }

/* Text Messages: tabs on the left, the Termii balance on the right. */
.sms-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.sms-topbar .admin-filters { margin: 0; }
.sms-balance { display: flex; align-items: center; gap: 8px; font-size: 13.5px; white-space: nowrap; }

/* Read out by screen readers, not shown. */
.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; }

/* Bank reconciliation (pages/bank.js) */
.drawer.bank-drawer { width: 680px; }
.bank-card { text-align: left; cursor: pointer; font: inherit; color: inherit; transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.bank-card:hover { border-color: var(--primary); }
.bank-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-bg); }
.bank-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.bank-card-sub { font-size: 12.5px; color: var(--text-muted); }
.bank-card-sub b { color: var(--text); font-weight: 600; white-space: nowrap; }
.bank-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 4px 0 12px; }
.upload-summary.bank-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
.bank-narr { overflow-wrap: anywhere; min-width: 140px; }
.bank-summary > div { background: var(--bg, #f8fafc); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.bank-summary span { display: block; font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.bank-summary b { display: block; font-size: 15px; margin-top: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bank-in { color: var(--success); }
.bank-out { color: var(--text); }
.bank-breaks { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
.bank-ok { color: var(--success); font-weight: 600; margin: 0 0 8px; }
.bank-warn { color: var(--warning); font-weight: 600; }
.bank-cols { margin: 12px 0 0; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.bank-cols summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.bank-cols-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; margin-top: 10px; }
.bank-accept { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-size: 13.5px; cursor: pointer; }
@media (max-width: 640px) {
  .bank-cols-grid { grid-template-columns: 1fr; }
}
.bank-total { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 16px; background: var(--card-bg); border-radius: 18px; padding: 14px 18px; margin-bottom: 12px; }
.bank-total span { display: block; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.bank-total b { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bank-total p { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--text-muted); }
.bank-bad { color: var(--danger); }
.bank-warn-text { color: var(--warning); font-weight: 600; }
.bank-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 24px 0 12px; }
.bank-tab { border: 1px solid var(--border); background: var(--card-bg); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.bank-tab.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary, #fff); }
.bank-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.bank-tab-n { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--th-bg); color: var(--text-muted); font-size: 12px; text-align: center; }
.bank-tab.on .bank-tab-n { background: rgba(255,255,255,0.22); color: inherit; }
.bank-tab-n.warn { background: var(--sun-bg, #fff3cd); color: var(--sun-text, #8a5a00); }
.bank-h { font-size: 13px; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.bank-cands { display: flex; flex-direction: column; gap: 6px; }
.bank-cand { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: default; }
.bank-cand input[type=checkbox] { flex-shrink: 0; }
.bank-cand-main { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; overflow-wrap: anywhere; }
.bank-cand-main .text-muted { font-size: 12.5px; }
.bank-cand .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bank-split { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: 13.5px; font-weight: 600; }
.bank-rec-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
#bl-rec .field { margin-bottom: 10px; }
.bank-recon { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 4px 0 10px; }
.bank-recon td { padding: 7px 4px; border-bottom: 1px solid var(--border); }
.bank-recon td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bank-recon-total td { font-weight: 700; border-bottom: 0; }
.form-section { margin: 6px 0 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text); }
.form-section .text-muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.bank-files { display: flex; flex-direction: column; gap: 8px; }
.bank-file { display: grid; grid-template-columns: minmax(0, 1fr) 170px auto auto; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.bank-file-main { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.bank-file-main .text-muted { font-size: 12.5px; }
.bank-file-acct { min-width: 0; font-size: 13px; }
.bank-file-actions { display: flex; gap: 4px; align-items: center; }
@media (max-width: 640px) { .bank-file { grid-template-columns: 1fr; } }
input.caps { text-transform: uppercase; }
input.caps::placeholder { text-transform: none; }
.money-card-edit { align-self: flex-start; padding: 0; margin-top: 2px; font-size: 12.5px; }
