/* =========================================================================
   TTW — app.css
   Tiptop Warehouse Workflow — Front-End Foundation (V8.5.0)

   Heritage / editorial design language. Cream paper, deep navy,
   restrained warm tones, hairline rules, distinctive serif display,
   clean sans body, monospace for numbers.

   Single source of truth. All design tokens live in :root.
   Override at the page level only when truly necessary.
   ========================================================================= */


/* -------------------------------------------------------------------------
   1. Webfonts (self-hosted, latin subset)
   ------------------------------------------------------------------------- */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/jetbrains-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


/* -------------------------------------------------------------------------
   2. Design tokens
   ------------------------------------------------------------------------- */

:root {
  /* Layout */
  --sidebar-width: 232px;
  --topbar-h: 60px;
  --content-max: 1360px;

  /* Breakpoints (token layer; not all used as media queries yet) */
  --bp-sm: 640px;
  --bp-md: 900px;
  --bp-lg: 1100px;

  /* Surfaces */
  --bg: #f0ede8;
  --surface: #fff;
  --surface-alt: #f9f8f6;
  --surface-hover: #f4f2ef;
  --border: #e0ddd6;
  --border-dark: #c9c4ba;

  /* Text */
  --text: #1e1d1a;
  --text-secondary: #55524b;
  --text-muted: #8a857b;
  --text-light: #b0aa9f;

  /* Brand: Tiptop navy (ratified — single primary token set) */
  --accent: #0a2f86;
  --accent-hover: #082468;
  --accent-light: #1d4ed8;   /* reserved for links/info only */
  --accent-subtle: #dbeafe;

  /* Brand secondary: warm ochre (replaces amber) */
  --ochre: #b8893a;
  --ochre-subtle: #e8d5a8;
  --ochre-bg: #faf5e8;
  --ochre-border: #d4b876;

  /* Status */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-border: #86efac;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --purple-border: #ddd6fe;

  /* Sidebar */
  --sidebar-bg: #1a1917;
  --sidebar-hover: #2a2925;
  --sidebar-text: #c8c3b8;
  --sidebar-active-bg: rgba(10, 47, 134, 0.18);

  /* Type scale */
  --font-xs: 11px;
  --font-sm: 12.5px;
  --font-base: 14px;
  --font-md: 15px;
  --font-lg: 17px;
  --font-xl: 20px;
  --font-2xl: 24px;
  --font-3xl: 30px;
  --font-display: 44px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radius scale */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --radius-pill: 999px;

  /* Shadow scale */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);

  /* Focus ring (uses brand navy — replaces prior amber ring) */
  --focus-ring: 0 0 0 3px rgba(10, 47, 134, 0.16);
  --focus-ring-soft: 0 0 0 3px rgba(10, 47, 134, 0.08);

  /* Motion */
  --transition: 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.25s ease;

  /* V9.0 — The Ledger (signature design language) */
  /* The "rule" — a single hairline that anchors stat-strip numerics.
     Three variants: --rule (navy, primary), --rule-soft (border-dark,
     for secondaries), --rule-ochre (heritage highlight). */
  --rule: 1px solid var(--accent);
  --rule-soft: 1px solid var(--border-dark);
  --rule-ochre: 1px solid var(--ochre);
  --rule-ochre-fade: 1px solid var(--ochre-border);

  /* Stat-strip typographic rhythm. Two tiers of numerics:
     is-primary  → Fraunces opsz 144 (heritage display)
     is-secondary → JetBrains Mono 14.5px (tabular, editorial) */
  --stat-strip-padding-y: 18px;
  --stat-strip-eyebrow-size: 10.5px;
  --stat-strip-eyebrow-tracking: 1.2px;
  --stat-strip-sub-size: 12px;
  --stat-strip-numeric-primary-size: 28px;
  --stat-strip-numeric-secondary-size: 14.5px;
  --stat-strip-numeric-primary-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  --stat-strip-numeric-secondary-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Progress bar — single source of truth for invoice/bill/AR progress */
  --progress-bar-h: 4px;
  --progress-track: var(--border);
  --progress-fill: var(--success);
  --progress-fill-ochre: var(--ochre);
  --progress-fill-danger: var(--danger);

  /* .tag pills (info chips, not status) */
  --tag-bg: var(--surface-alt);
  --tag-fg: var(--text);
  --tag-accent-bg: var(--accent-subtle);
  --tag-accent-fg: var(--accent);
  --tag-padding-y: 3px;
  --tag-padding-x: 9px;
  --tag-radius: 999px;
  --tag-size: 11px;
}


/* -------------------------------------------------------------------------
   3. Reset & base
   ------------------------------------------------------------------------- */

html { height: 100%; scroll-padding-top: 18px; }
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  min-height: 100%;
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont,
               system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Subtle paper-grain texture — only on the app shell, never on print pages.
   The SVG noise is a tiny inline pattern, very low opacity. */
.app-shell {
  position: relative;
  min-height: 100vh;
}
.app-shell::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10  0 0 0 0 0.09  0 0 0 0 0.08  0 0 0 0.035 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
  opacity: 1;
  mix-blend-mode: multiply;
}
.app-shell > * { position: relative; z-index: 1; }


/* -------------------------------------------------------------------------
   4. Typography helpers
   ------------------------------------------------------------------------- */

h1, h2, h3, h4 { font-family: 'Inter', system-ui, sans-serif; font-weight: 650; color: var(--text); letter-spacing: -0.2px; }

.text-display {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-optical-sizing: auto;
  font-variation-settings: 'opsz' 144, 'SOFT' 0;
  font-weight: 600;
  letter-spacing: -0.6px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums lining-nums;
}

.text-serif { font-family: 'Fraunces', Georgia, 'Times New Roman', serif; font-optical-sizing: auto; }

.text-mono {
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: var(--font-sm);
  font-variant-numeric: tabular-nums lining-nums;
}

.tabular { font-variant-numeric: tabular-nums lining-nums; }


/* -------------------------------------------------------------------------
   5. Accessibility
   ------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -200px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  z-index: 10000;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: top 0.2s ease;
}
.skip-link:focus { top: 8px; }

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


/* -------------------------------------------------------------------------
   6. Spinner / loading
   ------------------------------------------------------------------------- */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
  color: var(--text-muted);
}
.spinner-lg { width: 22px; height: 22px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  display: block;
  background: linear-gradient(90deg, var(--surface-alt) 0%, var(--surface-hover) 50%, var(--surface-alt) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }


/* -------------------------------------------------------------------------
   7. Focus rings (global)
   ------------------------------------------------------------------------- */

:where(a, button, input, select, textarea, .filter-btn, .page-link,
       .nav-link, .cmd-trigger, .mobile-nav-link, .account-menu-trigger):focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}


/* -------------------------------------------------------------------------
   8. Layout shell
   ------------------------------------------------------------------------- */

.layout { display: flex; min-height: 100vh; align-items: stretch; }


/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #171614 0%, #151412 100%);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 220;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
  box-shadow: 10px 0 28px rgba(0, 0, 0, 0.18);
}
.sidebar-brand {
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  display: block;
}
.brand-logo {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 56px;
  border-radius: 14px;
  object-fit: contain;
  display: block;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
  background: #fff;
  padding: 8px 10px;
  border: 1px solid rgba(10, 47, 134, 0.08);
}
.brand-logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: linear-gradient(135deg, #ffffff 0%, #f5f7fb 100%);
  border: 1px solid rgba(10, 47, 134, 0.10);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}
.brand-text { margin-top: 12px; }
.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.1px;
}
.brand-text small { font-size: 10px; color: #8ea0d6; display: block; }
.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  font-size: 9px;
  color: #d8e2ff;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.sidebar-nav { padding: 6px 0 12px; flex: 1; }
.nav-section {
  padding: 14px 16px 6px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #4e4b44;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.nav-section .ti { width: 14px; height: 14px; stroke: #3d3b37; transition: transform var(--transition); }
.nav-section.collapsed .ti { transform: rotate(-90deg); }
.nav-group { overflow: hidden; transition: max-height 0.25s ease; }
.nav-group.collapsed { max-height: 0 !important; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  border-radius: 10px;
  margin: 1px 8px;
  position: relative;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 600;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--ochre);
  border-radius: var(--radius-pill);
}
.nav-link svg { width: 16px; height: 16px; opacity: 0.5; flex-shrink: 0; transition: opacity var(--transition); }
.nav-link:hover svg, .nav-link.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  line-height: 1.5;
}
.nav-badge.warn { background: var(--warning); }
.sidebar-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  margin-top: auto;
}
.sidebar-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 10.5px;
  color: #7f8db4;
  line-height: 1.7;
}
.sidebar-meta-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-size: 10.5px;
  color: #7f8db4;
}
.sidebar-meta-brand img {
  width: 18px; height: 18px;
  object-fit: contain;
  border-radius: 6px;
  display: block;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}
.sidebar-meta-brand a { color: #9db7ff; text-decoration: none; font-weight: 600; }
.sidebar-meta-brand a:hover { color: #dbeafe; }
.sidebar-meta strong { display: block; color: #eef2ff; font-size: 11.5px; }
.sidebar-meta a { color: #9db7ff; text-decoration: none; }
.sidebar-meta a:hover { color: #dbeafe; }
.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-avatar {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 12px; font-weight: 600; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 10px; color: #4a4740; }
.sidebar-signout {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  margin-top: 4px;
  border-radius: 6px;
  font-size: 11.5px;
  color: #7f8db4;
  text-decoration: none;
  transition: all var(--transition);
}
.sidebar-signout:hover { background: #2a2925; color: #dbeafe; }


/* Main */
.main {
  margin-left: var(--sidebar-width);
  min-width: 0;
  min-height: 100vh;
  display: block;
  position: relative;
  background: linear-gradient(180deg, #f7f4ef 0%, #f0ede8 140px, #f0ede8 100%);
  overflow-x: hidden;
}

/* Topbar */
.topbar {
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid rgba(201, 196, 186, 0.85);
  padding: 10px 24px;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  top: auto;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.page-title {
  font-size: var(--font-md + 1px);  /* 16px */
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -0.2px;
}
.hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--text);
}
.hamburger svg { width: 20px; height: 20px; }
.content {
  display: block;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px 24px 44px;
}
.content > :first-child { margin-top: 0 !important; }
.content::before { content: ''; display: block; height: 0; clear: both; }


/* Topbar: command palette trigger */
.cmd-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.cmd-trigger:hover { border-color: var(--accent); color: var(--text); }
.cmd-trigger kbd { background: var(--border); border-radius: 3px; padding: 1px 5px; font-size: 10px; font-family: inherit; }


/* Topbar: quick action buttons
   V9.3.0 — .qa-btn fully migrated to .btn / .btn-primary / .btn-ghost
   in base.html. The .qa-btn class no longer appears in any screen
   template, so its CSS rules are dropped. */

/* Topbar: account menu (V8.5.0 — moves user info from sidebar footer) */
.account-menu { position: relative; }
.account-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.account-menu-trigger:hover { background: var(--surface-hover); border-color: var(--border-dark); color: var(--text); }
.account-menu-trigger .avatar {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.account-menu-trigger .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.account-menu-trigger .name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.account-menu-trigger .chev { width: 12px; height: 12px; opacity: 0.6; transition: transform var(--transition); }
.account-menu.open .account-menu-trigger .chev { transform: rotate(180deg); }
.account-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 50;
  display: none;
}
.account-menu.open .account-menu-dropdown { display: block; }
.account-menu-meta {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.account-menu-meta .who { font-size: 13px; font-weight: 650; color: var(--text); }
.account-menu-meta .role { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.account-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.account-menu-item:hover { background: var(--surface-hover); color: var(--text); }
.account-menu-item svg { width: 14px; height: 14px; opacity: 0.7; flex-shrink: 0; }
.account-menu-item.danger { color: var(--danger); }
.account-menu-item.danger:hover { background: var(--danger-bg); color: var(--danger); }
.account-menu-form { margin: 0; }
.account-menu-sep { height: 1px; background: var(--border); margin: 6px 0; }


/* Toasts */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: all;
  animation: toast-in 0.25s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  max-width: 380px;
}
.toast.success { background: #1a2e1a; color: #86efac; border: 1px solid rgba(134, 239, 172, 0.2); }
.toast.error   { background: #2e1a1a; color: #fca5a5; border: 1px solid rgba(252, 165, 165, 0.2); }
.toast.warning { background: #2e251a; color: #fcd34d; border: 1px solid rgba(252, 211, 77, 0.2); }
.toast.info    { background: #1a1e2e; color: #93c5fd; border: 1px solid rgba(147, 197, 253, 0.2); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast-close {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  opacity: 0.6;
  font-size: 18px;
  color: inherit;
  line-height: 1;
  padding: 0 2px;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }


/* Command palette */
.cmd-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 14vh;
}
.cmd-overlay.open { display: flex; }
.cmd-box {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  border: 1px solid var(--border);
}
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cmd-input-wrap svg { width: 18px; height: 18px; stroke: var(--text-muted); flex-shrink: 0; }
#cmd-input {
  flex: 1;
  border: none; outline: none;
  font-size: var(--font-md);
  background: transparent;
  color: var(--text);
  font-family: inherit;
}
#cmd-input::placeholder { color: var(--text-muted); }
.cmd-results { max-height: 380px; overflow-y: auto; }
.cmd-section-header {
  padding: 8px 18px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}
.cmd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  color: var(--text);
}
.cmd-item:hover, .cmd-item.selected { background: var(--surface-hover); }
.cmd-item svg { width: 15px; height: 15px; stroke: var(--text-muted); flex-shrink: 0; }
.cmd-item-text { flex: 1; font-size: 13.5px; }
.cmd-item-sc { font-size: 11px; color: var(--text-muted); }
.cmd-item-sc kbd { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-size: 10px; }
.cmd-empty { padding: 32px; text-align: center; color: var(--text-muted); font-size: 13px; }
.cmd-footer {
  padding: 8px 18px;
  border-top: 1px solid var(--border);
  display: flex; gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
}
.cmd-footer kbd { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-family: inherit; }


/* Quick-pay modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 8000;
  display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 14px; font-weight: 650; }
.modal-close {
  background: none; border: none; cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
}
.modal-close:hover { background: var(--surface-hover); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}


/* -------------------------------------------------------------------------
   9. Cards
   ------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 13.5px; font-weight: 650; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.surface-muted { background: var(--surface-alt); }
.section-stack > * + * { margin-top: 16px; }

.brand-logo-fallback span { display: block; padding-top: 2px; }

.filter-card { margin-bottom: 16px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.quick-filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.quick-filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}
.quick-filter:hover { background: var(--surface-hover); border-color: var(--border-dark); color: var(--text); }
.quick-filter.active { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }
.quick-filter.muted { color: var(--text-muted); }
.report-note {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}
.table-total-row td { font-weight: 700; background: var(--surface-alt); }
.cell-negative { color: var(--danger); font-weight: 700; }
.image-preview-frame {
  margin-top: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 96px; min-width: 220px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.image-preview-frame img { max-height: 84px; max-width: 220px; display: block; object-fit: contain; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.template-option-card { padding: 16px; }
.template-option-card strong { display: block; font-size: 13px; color: var(--text); }
.template-option-card p { margin-top: 6px; font-size: 12px; color: var(--text-muted); }


/* -------------------------------------------------------------------------
   10. Stat cards
   ------------------------------------------------------------------------- */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.stat-card .label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-card .value {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-optical-sizing: auto;
  font-variation-settings: 'opsz' 144;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.6px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums lining-nums;
}
.stat-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.stat-card.warning::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before  { background: var(--danger); }
.stat-card.info::before    { background: var(--blue); }
.stat-card.purple::before  { background: var(--purple); }


/* -------------------------------------------------------------------------
   11. Tables
   ------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: -2px; padding: 2px; }
.table-wrap table { table-layout: fixed; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 9px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--surface-alt);
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--transition);
}
.table-wrap th, .table-wrap td, .card, .detail-card, .detail-row span,
.preview-title, .preview-subtitle, .nav-link, .badge, .page-subtitle,
.empty-state p {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.grid-2 > *, .grid-3 > *, .card > * { min-width: 0; }
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover td { background: var(--surface-hover); }
tr:last-child td { border-bottom: none; }
td a { color: var(--accent); text-decoration: none; font-weight: 550; }
td a:hover { color: var(--accent-hover); text-decoration: underline; }
.text-right { text-align: right; }
.text-mono {
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: var(--font-sm);
  font-variant-numeric: tabular-nums lining-nums;
}

.sort-link { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.sort-link .arrow { font-size: 10px; color: var(--text-light); transition: color var(--transition); }
.sort-link:hover .arrow { color: var(--accent); }
.sort-link.active { color: var(--text); }
.sort-link.active .arrow { color: var(--accent); }
.table-wrap.sticky-head { max-height: calc(100vh - var(--topbar-h) - 40px); overflow: auto; }
.table-wrap.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}
.report-density-compact td { padding-top: 7px; padding-bottom: 7px; font-size: 12px; }
.report-density-compact th { padding-top: 7px; padding-bottom: 7px; }
.density-toggle { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.density-chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: none;
}
.density-chip.active { background: var(--surface-alt); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.bulk-toolbar {
  display: flex; gap: 10px; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  flex-wrap: wrap;
}
.bulk-toolbar .bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulk-toolbar select { min-width: 180px; }
.selection-count { font-size: 12px; color: var(--text-muted); }
.table-check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.table-row-alert td    { background: linear-gradient(0deg, rgba(220, 38, 38, 0.06), rgba(220, 38, 38, 0.06)); }
.table-row-softwarn td { background: linear-gradient(0deg, rgba(217, 119, 6, 0.07), rgba(217, 119, 6, 0.07)); }
.table-row-matched td  { background: var(--success-bg); }
.toolbar-note { font-size: 11px; color: var(--text-muted); }
.page-shell { display: grid; gap: 18px; }
.page-shell.compact { gap: 14px; }
.shell-row { display: grid; gap: 14px; }


/* -------------------------------------------------------------------------
   12. Buttons
   ------------------------------------------------------------------------- */

/* =========================================================================
   V9.3.0 — One button system. Six tokens, two sizes.
     .btn          secondary (default, hairline border)
     .btn-primary  single navy CTA per page
     .btn-danger   destructive (e.g. Delete, Unlock)
     .btn-ghost    quiet / Cancel — borderless, hover surfaces
     .btn-link     inline link-style action
     .btn-icon     32x32 square icon-only

   Sizes:
     .btn          default — 8x14 padding, 13.5px text (page actions, modals)
     .btn-sm       4x10 padding, 12px text     (list rows, dense tables)
     (no .btn-xs — collapses to .btn-sm)

   Groupings:
     .btn-group    flex row of buttons (gap 6, wraps)
     .btn-row      single-row right-aligned variant
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: 5px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.3;
  font-family: inherit;
}
.btn:hover { border-color: var(--border-dark); background: var(--surface-hover); color: var(--text); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-primary:focus-visible { box-shadow: 0 0 0 3px rgba(10, 47, 134, 0.28); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:focus-visible { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }
.btn-purple { background: var(--purple); color: #fff; border-color: var(--purple); }
.btn-purple:hover { background: #6d28d9; color: #fff; }

/* Quiet / Cancel / View all — borderless, hover surfaces the row */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: transparent; }

/* Inline link-style action — underline on hover */
.btn-link {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  padding-left: 4px; padding-right: 4px;
}
.btn-link:hover { color: var(--accent-hover); text-decoration: underline; background: transparent; }

/* Square icon-only — 32x32 on desktop */
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-dark); }
.btn-icon.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-border); }
.btn-icon.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Sizes — single scale */
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-icon.btn-sm { width: 26px; height: 26px; }

/* Groupings */
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* V9.3.0 — page-actions pattern. The standard topbar-right actions
   row used by every page. Left = primary CTA, right = page meta.
   The block sits inside `{% block actions %}` in base.html. */
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-actions .meta { margin-left: auto; font-size: 12px; color: var(--text-muted); display: inline-flex; gap: 12px; align-items: center; }


/* -------------------------------------------------------------------------
   13. Badges
   ------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.2px;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge-draft     { background: #f1f0ee; color: #6b6760; }
.badge-draft::before     { background: #a9a49a; }
.badge-sent      { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border); }
.badge-sent::before      { background: var(--blue); }
.badge-pending   { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-pending::before   { background: var(--warning); }
.badge-paid      { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-paid::before      { background: var(--success); }
.badge-partial   { background: var(--ochre-bg); color: var(--ochre); border: 1px solid var(--ochre-border); }
.badge-partial::before   { background: var(--ochre); }
.badge-overdue   { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-overdue::before   { background: var(--danger); animation: pulse-dot 2s infinite; }
.badge-cancelled { background: #f1f0ee; color: #999; }
.badge-cancelled::before { background: #bbb; }
.badge-holding   { background: var(--ochre-bg); color: var(--ochre); border: 1px solid var(--ochre-border); }
.badge-holding::before   { background: var(--ochre); }
.badge-deposited { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-deposited::before { background: var(--success); }
.badge-bounced   { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-bounced::before   { background: var(--danger); }
.badge-issued    { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border); }
.badge-issued::before    { background: var(--blue); }
.badge-received  { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-received::before  { background: var(--success); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }


/* -------------------------------------------------------------------------
   14. Forms
   ------------------------------------------------------------------------- */

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
  font-family: inherit;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring-soft);
}
.form-input::placeholder { color: var(--text-light); }
.form-input:disabled { background: var(--surface-alt); color: var(--text-muted); }
select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a857b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
textarea.form-input { resize: vertical; min-height: 56px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.form-actions {
  display: flex; gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.form-check { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.form-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }
.errorlist { list-style: none; margin-top: 3px; }
.errorlist li { font-size: 11.5px; color: var(--danger); }
.form-error {                                  /* V8.5.0 — was undefined in CSS */
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
  display: block;
  font-weight: 500;
}


/* -------------------------------------------------------------------------
   15. Line items (formset)
   ------------------------------------------------------------------------- */

.line-items { margin-top: 18px; }
.line-items h4 {
  font-size: 12.5px;
  font-weight: 650;
  margin-bottom: 10px;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.line-items h4::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.line-item-row {
  display: grid;
  grid-template-columns: 2.5fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 6px;
  padding: 12px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.line-item-row:focus-within { border-color: var(--accent); background: var(--surface); }
.line-item-row .form-group { margin-bottom: 0; }
.line-item-row .delete-check {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px;
  color: var(--danger);
  padding-bottom: 8px;
  cursor: pointer;
}
#line-items-total {
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  color: var(--text);
}


/* -------------------------------------------------------------------------
   16. Alerts
   ------------------------------------------------------------------------- */

.alert {
  padding: 11px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  animation: slideDown 0.2s ease;
}
.alert::before { font-size: 14px; flex-shrink: 0; }
.alert-success { background: var(--success-bg); color: #15803d; border: 1px solid var(--success-border); }
.alert-success::before { content: '✓'; font-weight: 700; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid var(--warning-border); }
.alert-warning::before { content: '⚠'; }
.alert-error, .alert-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid var(--danger-border); }
.alert-error::before, .alert-danger::before { content: '✕'; font-weight: 700; }
.alert-info { background: var(--blue-bg); color: #1d4ed8; border: 1px solid var(--blue-border); }
.alert-info::before { content: 'ℹ'; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }


/* -------------------------------------------------------------------------
   17. Cheque banner
   ------------------------------------------------------------------------- */

.cheque-alert-banner {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #991b1b;
  display: flex; align-items: center; gap: 8px;
}
.cheque-alert-banner a { color: var(--danger); font-weight: 600; }


/* -------------------------------------------------------------------------
   18. Toolbar
   ------------------------------------------------------------------------- */

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center;
  flex: 1; max-width: 320px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
  font-family: inherit;
}
.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring-soft);
}
.search-box::before {
  content: '';
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a857b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat center/contain;
  pointer-events: none;
}
.filter-group { display: flex; gap: 3px; flex-wrap: wrap; }
.toolbar-count { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.pagination-wrap { padding: 12px 20px; }
.card-flush { padding: 0; overflow: hidden; }
.cell-meta { font-size: 12px; color: var(--text-muted); }
.cell-sm { font-size: 12px; }
.check-label { display: flex; align-items: center; gap: 8px; }
.page-ellipsis { border: none; padding: 6px 2px; }
.page-total { font-size: 11px; color: var(--text-muted); padding: 6px 6px; margin-left: 4px; }
.filter-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-muted);
  transition: all var(--transition);
}
.filter-btn:hover { background: var(--surface-hover); color: var(--text); }
.filter-btn.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }


/* -------------------------------------------------------------------------
   19. Empty state
   ------------------------------------------------------------------------- */

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon {
  width: 48px; height: 48px;
  margin: 0 auto 14px;
  background: var(--surface-alt);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.empty-icon svg { width: 22px; height: 22px; stroke: var(--text-light); }
.empty-state p { font-size: 13.5px; margin-bottom: 16px; }


/* -------------------------------------------------------------------------
   20. Pagination
   ------------------------------------------------------------------------- */

.pagination { display: flex; align-items: center; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.page-link {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--surface);
  transition: all var(--transition);
}
.page-link:hover { background: var(--surface-hover); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-link.disabled { opacity: 0.4; pointer-events: none; }


/* -------------------------------------------------------------------------
   21. Detail layout
   ------------------------------------------------------------------------- */

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-row {
  display: flex; justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); font-weight: 500; }
.detail-value { color: var(--text); font-weight: 500; text-align: right; }
.total-row { font-weight: 700; font-size: 14px; }


/* -------------------------------------------------------------------------
   22. Misc
   ------------------------------------------------------------------------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted   { color: var(--text-muted); }
.confirm-box { max-width: 420px; margin: 80px auto; }
.confirm-box .card { text-align: center; padding: 32px; }
.confirm-box h3 { margin-bottom: 8px; font-size: 16px; }
.confirm-box p { color: var(--text-muted); margin-bottom: 20px; font-size: 13px; }
.section-title {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}
.info-box {
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: #1d4ed8;
  margin-bottom: 14px;
}
.warn-box {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 14px;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 150; }
.sidebar-overlay.show { display: block; }
.mobile-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 250;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(201, 196, 186, 0.9);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  gap: 8px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
}
.mobile-nav-link {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 9px 6px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
  transition: all var(--transition);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.mobile-nav-link svg { width: 18px; height: 18px; stroke: currentColor; opacity: 0.9; }
.mobile-nav-link.active { background: var(--accent-subtle); color: var(--accent); }
.mobile-nav-link.more-btn { background: transparent; }
.mobile-nav-link.more-btn:hover, .mobile-nav-link:hover { background: var(--surface-hover); color: var(--text); }
.mobile-only { display: none !important; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }


/* -------------------------------------------------------------------------
   23. Invoice entry shell, AR snapshot, preview
   ------------------------------------------------------------------------- */

.invoice-sticky-bar {
  position: static;
  display: flex; justify-content: space-between; gap: 14px; align-items: center;
  padding: 14px 16px;
  margin-top: 18px;
  border: 1px solid var(--border-dark);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}
.invoice-sticky-bar .summary { font-size: 13px; color: var(--text-secondary); }
.invoice-sticky-bar .summary strong {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: 18px;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
}
.line-row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
/* V9.3.0 — .mini-icon-btn is a transitional alias for .btn-icon.
   The plan is to migrate the 3 formset-row callers (Delete row buttons
   in OB migration, journal lines, etc.) to .btn-icon in a later sweep. */
.product-search-input { margin-bottom: 6px; }
.preview-shell { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.preview-pane { position: static; }
.invoice-entry-shell { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr); gap: 18px; align-items: start; }
.invoice-entry-main, .invoice-entry-side { min-width: 0; }
.invoice-entry-side { display: grid; gap: 16px; }
.invoice-section-card { padding: 18px; }
.invoice-section-card + .invoice-section-card { margin-top: 16px; }
.invoice-section-title {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.invoice-section-title h3 { font-size: 15px; margin: 0; }
.invoice-section-title p { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; }
.invoice-kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.invoice-kpi {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
}
.invoice-kpi .label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.invoice-kpi .value {
  font-size: 18px;
  font-weight: 750;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
}
.invoice-side-note { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.ar-sidebar-shell .ar-context-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ar-sidebar-shell .ar-list { max-height: 360px; overflow: auto; padding-right: 4px; }
.ar-sidebar-shell .ar-list-item { padding: 10px 12px; }
.ar-more-note { font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.vat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

@media (max-width: 1100px) {
  .invoice-entry-shell { grid-template-columns: 1fr; }
  .invoice-kpi-grid { grid-template-columns: 1fr 1fr; }
}

.preview-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.preview-header {
  display: flex; gap: 14px; align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.preview-logo {
  width: 72px; height: 72px;
  border: 1px dashed var(--border-dark);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-alt);
  overflow: hidden;
  flex-shrink: 0;
}
.preview-logo img { width: 100%; height: 100%; object-fit: contain; }
.preview-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.preview-title {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}
.preview-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.preview-block { padding: 12px 0; border-top: 1px solid var(--border); }
.preview-block:first-of-type { border-top: 0; padding-top: 0; }
.preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.preview-chip {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}


/* -------------------------------------------------------------------------
   24. Dashboard, action cards, breadcrumbs, page header
   ------------------------------------------------------------------------- */

.dashboard-section-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-bottom: 18px; }
.action-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.action-card h3 { font-size: 15px; }
.action-list { display: grid; gap: 8px; }
.action-list a, .action-list button { justify-content: flex-start; }
.metric-list { display: grid; gap: 10px; }
.metric-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  font-size: 12px;
}
.metric-row strong { color: var(--text); }
.recipient-pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  margin: 4px 6px 0 0;
}
.price-delta { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--accent); }
.email-block {
  padding: 14px;
  border: 1px dashed var(--border-dark);
  border-radius: 14px;
  background: var(--surface-alt);
  font-size: 13px;
  white-space: pre-line;
}
.report-hero { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; flex-wrap: wrap; }
.report-hero h3 { font-size: 16px; }
.report-hero p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.breadcrumbs {
  display: flex; gap: 8px; align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.breadcrumbs a { color: var(--accent); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-header-meta h2 {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-optical-sizing: auto;
  font-size: var(--font-2xl);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.6px;
  margin: 2px 0 6px;
}
.page-header-meta p { font-size: 13px; color: var(--text-muted); max-width: 760px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dashboard-hero {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 246, 242, 0.96) 100%);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.dashboard-hero .breadcrumbs { margin-bottom: 6px; }
.dashboard-stats { margin-bottom: 18px; }


/* -------------------------------------------------------------------------
   25. Print
   ------------------------------------------------------------------------- */

@page { margin: 15mm; }
@media print {
  .sidebar, .sidebar-overlay, .topbar, .btn, .no-print,
  .cmd-overlay, .modal-overlay, #toast-container { display: none !important; }
  .app-shell::before { display: none !important; }
  .app-shell, .main, body { background: #fff !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  a { color: inherit; text-decoration: none; }
}


/* -------------------------------------------------------------------------
   26. Responsive
   ------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .preview-shell { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
  .invoice-sticky-bar { flex-direction: column; align-items: flex-start; }
  .bulk-toolbar { align-items: flex-start; }
  .dashboard-section-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 0px; --topbar-h: 72px; }
  body { font-size: 15px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3); }
  .hamburger { display: flex; }
  .mobile-nav, .mobile-only { display: flex !important; }
  .main { margin-left: 0; }
  .content { width: 100%; padding: 16px 14px 108px; }
  .topbar { padding: 10px 14px; min-height: var(--topbar-h); height: auto; align-items: flex-start; flex-wrap: wrap; }
  .topbar-left { width: 100%; justify-content: space-between; }
  .topbar-right { width: 100%; overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; justify-content: flex-start; scrollbar-width: none; }
  .topbar-right::-webkit-scrollbar { display: none; }
  .page-title { font-size: 15px; }
  .cmd-trigger { min-width: max-content; }
  .btn, .page-link, .filter-btn, .mobile-nav-link { min-height: 42px; }
  .btn { padding: 10px 14px; }
  .search-box { max-width: none; width: 100%; }
  .toolbar { gap: 12px; align-items: stretch; }
  .toolbar > * { max-width: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-2, .detail-grid { grid-template-columns: 1fr; }
  .line-item-row { grid-template-columns: 1fr; gap: 10px; padding: 14px; }
  .line-item-row .form-group[style*='grid-template-columns'] { display: block !important; }
  .line-item-headers { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .table-wrap { overflow: visible; }
  .table-wrap table:not(.keep-table-mobile),
  .table-wrap table:not(.keep-table-mobile) thead,
  .table-wrap table:not(.keep-table-mobile) tbody,
  .table-wrap table:not(.keep-table-mobile) tr,
  .table-wrap table:not(.keep-table-mobile) th,
  .table-wrap table:not(.keep-table-mobile) td { display: block; width: 100%; }
  .table-wrap table:not(.keep-table-mobile) thead { display: none; }
  .table-wrap table:not(.keep-table-mobile) tbody { padding: 10px; }
  .table-wrap table:not(.keep-table-mobile) tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 10px;
    padding: 10px 12px;
  }
  .table-wrap table:not(.keep-table-mobile) tr:last-child { margin-bottom: 0; }
  .table-wrap table:not(.keep-table-mobile) td { border: none; padding: 7px 0; font-size: 13.5px; }
  .table-wrap table:not(.keep-table-mobile) td::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 2px;
  }
  .table-wrap table:not(.keep-table-mobile) td:first-child { padding-top: 0; }
  .table-wrap table:not(.keep-table-mobile) td:last-child { padding-bottom: 0; }
  .table-wrap table:not(.keep-table-mobile) td:first-child::before { margin-bottom: 4px; }
  .table-wrap table:not(.keep-table-mobile) td.text-right { text-align: left; }
  .table-wrap table:not(.keep-table-mobile) td .btn-group { justify-content: flex-start; }
  .table-wrap table.keep-table-mobile { min-width: 720px; }
  .form-actions { position: static; background: transparent; padding: 0; border: none; border-radius: 0; box-shadow: none; margin-top: 22px; }
  #line-items-total { position: static; background: rgba(255, 255, 255, 0.98); padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04); margin-top: 10px; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filter-group { flex-wrap: wrap; }
  .topbar-right .btn:not(.btn-primary) { display: none; }
  .cmd-trigger { display: none; }
  .card { padding: 16px; }
  .card-header { gap: 10px; align-items: flex-start; }
  .card-header .btn-group { width: 100%; }
}

@media (max-width: 500px) {
  .topbar { padding: 10px 12px; }
  .content { padding-inline: 12px; }
  .table-wrap table:not(.keep-table-mobile) tr { padding: 10px; }
  .btn, .qa-btn { width: 100%; justify-content: center; }
  .form-actions .btn:first-child { flex: 1; }
  .form-actions a[style*='margin-left:auto'] { margin-left: 0 !important; }
}


/* -------------------------------------------------------------------------
   27. V8.5.1 additions — Component primitives polish
   ------------------------------------------------------------------------- */

/* Form field partial refinements */
.form-group.has-error .form-input,
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea { border-color: var(--danger); }
.form-group.has-error .form-input:focus,
.form-group.has-error input:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12); }
.form-required-marker { color: var(--danger); margin-left: 2px; font-weight: 700; }
.form-errors-summary ul { margin: 8px 0 0 18px; padding: 0; }
.form-errors-summary li { font-weight: 500; }
.form-error-summary-links { font-size: 12px; margin-top: 8px; }
.form-error-summary-links a { color: var(--danger); text-decoration: underline; font-weight: 500; }
.form-error-summary-links a:hover { color: #7f1d1d; }

/* Empty state refinements (V8.5.1 partial uses these) */
.empty-state-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.1px;
}
.empty-state-body { color: var(--text-muted); margin-bottom: 16px; }
.empty-state .btn { margin: 0 auto; }
.empty-state form { display: inline-block; }
.empty-state-sm { padding: 28px 16px; }
.empty-state-sm .empty-icon { width: 40px; height: 40px; margin-bottom: 10px; }
.empty-state-sm .empty-icon svg { width: 18px; height: 18px; }
.empty-state-muted .empty-icon { background: transparent; border: 1px dashed var(--border-dark); }
.empty-state-muted .empty-state-title { color: var(--text-secondary); font-weight: 600; }
.empty-state-muted .empty-state-body { color: var(--text-muted); font-size: 12.5px; }


/* -------------------------------------------------------------------------
   28. V8.5.1 — Stat-card and badge polish
   ------------------------------------------------------------------------- */

/* Badge refinements — paid/credit/holding use --ochre instead of generic warning */
.badge-paid      { background: var(--ochre-bg); color: #92400e; border: 1px solid var(--ochre-border); }
.badge-paid::before      { background: var(--ochre); }
.badge-partial   { background: var(--ochre-bg); color: var(--ochre); border: 1px solid var(--ochre-border); }
.badge-partial::before   { background: var(--ochre); }
.badge-holding   { background: var(--ochre-bg); color: var(--ochre); border: 1px solid var(--ochre-border); }
.badge-holding::before   { background: var(--ochre); }
.badge-deposited { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-deposited::before { background: var(--success); }
.badge-received  { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-received::before  { background: var(--success); }
/* Sent / issued / pending stay blue / amber to retain semantic distinction */

/* Stat-card refinements — bigger numeric, more breathing room */
.stat-card .value {
  font-size: 26px;
  font-weight: 600;
  font-variation-settings: 'opsz' 144, 'SOFT' 0;
  letter-spacing: -0.8px;
}
.stat-card .label { letter-spacing: 0.8px; }
.stat-card .sub { display: flex; align-items: center; gap: 4px; }
.stat-card .sub .delta-up   { color: var(--success); font-weight: 700; }
.stat-card .sub .delta-down { color: var(--danger); font-weight: 700; }
.stat-card .sub .delta-flat { color: var(--text-muted); font-weight: 600; }


/* -------------------------------------------------------------------------
   29. V8.5.1 — List page & table polish
   ------------------------------------------------------------------------- */

.table-wrap.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-alt);
  box-shadow: inset 0 -1px 0 var(--border);
}
.table-wrap.sticky-head.compact-rows td { padding-top: 7px; padding-bottom: 7px; }
/* Zebra rows for list pages — opt-in via .zebra */
.table-wrap.zebra tbody tr:nth-child(even) td { background: var(--surface-alt); }
.table-wrap.zebra tbody tr:hover td { background: var(--surface-hover); }

/* Empty-row styling — for list pages that still use the inline <tr> pattern */
.table-empty-row td {
  padding: 40px 16px !important;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}


/* -------------------------------------------------------------------------
   30. V8.5.2 — Dashboard triage
   ------------------------------------------------------------------------- */

.dashboard { display: block; }

/* Tier 1 — stats + action queue side by side */
.dashboard-tier-1 {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-5);
  align-items: start;
}
.dashboard-tier-1 .stats-grid { margin: 0; }

/* Stat-card sub-text colors (replaces inline style="color:var(--danger);font-weight:600") */
.stat-card .stat-warn { color: var(--danger); font-weight: 600; }
.stat-card .stat-good { color: var(--success); font-weight: 600; }
.stat-card .sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* Action queue (Tier 1 right column) */
.action-queue {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}
.action-queue-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.action-queue-head h3 { margin: 0; font-size: var(--font-md); }
.action-queue-count { font-size: 12px; color: var(--text-muted); }
.action-queue-section + .action-queue-section { margin-top: var(--space-4); }
.action-queue-section h4 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin: 0 0 var(--space-2) 0;
}
.action-queue-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  margin-left: auto;
}
.action-queue-alert h4 { color: var(--danger); }
.action-queue-alert .action-queue-pill { background: var(--danger-bg); color: var(--danger); }
.action-queue-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.action-queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  transition: background 0.12s;
}
.action-queue-item:hover { background: var(--surface-hover); }
.action-queue-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}
.action-queue-link:hover .action-queue-primary strong { text-decoration: underline; }
.action-queue-primary { font-size: 13px; color: var(--text); }
.action-queue-primary strong { font-weight: 600; }
.action-queue-secondary { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-queue-amount { font-size: 13px; font-weight: 600; color: var(--text); text-align: right; white-space: nowrap; }
.action-queue-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; padding-top: 4px; }
.action-queue-empty { font-size: 12.5px; color: var(--text-muted); margin: 0; padding: 8px 4px; font-style: italic; }
.action-queue-more {
  display: inline-block;
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: none;
  margin-top: 6px;
  font-weight: 500;
}
.action-queue-more:hover { text-decoration: underline; }

/* Tiny status dots (used in the queue section headers) */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.dot-danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.dot-ochre { background: var(--ochre); box-shadow: 0 0 0 3px var(--ochre-bg); }
.dot-success { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.dot-muted { background: var(--border-dark); }

/* Tier 2 — quick actions */
.dashboard-tier-2 { margin-top: var(--space-6); }
.dashboard-tier-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin: 0 0 var(--space-3) 0;
}
.dashboard-tier-head h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-secondary); margin: 0; display: inline; }
.dashboard-tier-head .dashboard-tier-meta { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.quick-action:hover { background: var(--surface-hover); border-color: var(--accent); }
.quick-action:active { transform: translateY(1px); }
.quick-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent);
  margin-bottom: 4px;
}
.quick-action-icon svg { width: 16px; height: 16px; }
.quick-action-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.quick-action-sub { font-size: 11.5px; color: var(--text-muted); }

/* Tier 3 — collapsible recent activity */
.dashboard-tier-3 { margin-top: var(--space-6); }
.dashboard-tier-3 > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
}
.dashboard-tier-3 > summary::-webkit-details-marker { display: none; }
.dashboard-tier-3 > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.15s;
  color: var(--text-muted);
  font-size: 11px;
}
.dashboard-tier-3[open] > summary::before { transform: rotate(90deg); }
.dashboard-tier-3 > summary:hover { color: var(--text); }
.dashboard-tier-meta { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.recent-activity-card { margin-top: var(--space-3); padding: 0; }
.recent-activity { list-style: none; padding: 0; margin: 0; }
.recent-activity-item { border-bottom: 1px solid var(--border); }
.recent-activity-item:last-child { border-bottom: none; }
.recent-activity-link {
  display: grid;
  grid-template-columns: 60px 100px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}
.recent-activity-link:hover { background: var(--surface-hover); }
.recent-activity-date { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.recent-activity-kind { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.recent-activity-kind::before {
  content: '●';
  display: inline-block;
  margin-right: 5px;
  color: var(--text-muted);
  font-size: 8px;
  vertical-align: 1px;
}
.recent-activity-invoice .recent-activity-kind::before { color: var(--accent); }
.recent-activity-bill .recent-activity-kind::before { color: #7c3aed; }
.recent-activity-price .recent-activity-kind::before { color: var(--ochre); }
.recent-activity-primary { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-activity-primary strong { font-weight: 600; }
.recent-activity-secondary { color: var(--text-muted); font-size: 12px; }
.recent-activity-amount { font-size: 13px; font-weight: 600; text-align: right; }
.recent-activity-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-alt); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }


/* -------------------------------------------------------------------------
   31. V8.5.2 — Dashboard compact density
   ------------------------------------------------------------------------- */

.dashboard--compact .dashboard-tier-1 { gap: var(--space-4); }
.dashboard--compact .dashboard-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dashboard--compact .stat-card { padding: 12px 14px; }
.dashboard--compact .stat-card .value { font-size: 22px; }
.dashboard--compact .stat-card .label { font-size: 10.5px; }
.dashboard--compact .action-queue { padding: var(--space-3) var(--space-4); }
.dashboard--compact .action-queue-section + .action-queue-section { margin-top: var(--space-3); }
.dashboard--compact .action-queue-item { padding: 7px 9px; }
.dashboard--compact .dashboard-tier-2 { margin-top: var(--space-4); }
.dashboard--compact .quick-actions { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-2); }
.dashboard--compact .quick-action { padding: 10px 12px; }
.dashboard--compact .dashboard-tier-3 { margin-top: var(--space-4); }


/* -------------------------------------------------------------------------
   32. V8.5.2 — Dashboard responsive
   ------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .dashboard-tier-1 { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recent-activity-link { grid-template-columns: 50px 1fr auto; gap: 10px; }
  .recent-activity-kind { display: none; }
}
@media (max-width: 700px) {
  .action-queue { padding: 14px 16px; }
  .quick-actions { grid-template-columns: 1fr; }
  .recent-activity-link { grid-template-columns: 1fr; gap: 4px; padding: 10px 14px; }
  .recent-activity-date { font-size: 11px; }
  .recent-activity-amount { text-align: left; }
  .dashboard--compact .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
  .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-stats .stat-card { padding: 10px 12px; }
  .stat-card .value { font-size: 20px; }
  .stat-card .label { font-size: 10.5px; }
  .dashboard--compact .dashboard-stats .stat-card { padding: 8px 10px; }
  .dashboard--compact .stat-card .value { font-size: 18px; }
}


/* -------------------------------------------------------------------------
   33. V8.5.3 — Tax mode selector (invoice form)
   The 3-state segmented control that replaces the dashed "+ Tax tiers" button.
   ------------------------------------------------------------------------- */

.tax-mode {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
  padding: 2px 0 var(--space-3, 12px);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-3, 12px);
  flex-wrap: wrap;
}
.tax-mode-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 700;
}
.segmented-control {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  padding: 2px;
  gap: 0;
}
.segment {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  transition: background var(--transition, 0.15s), color var(--transition, 0.15s), box-shadow var(--transition, 0.15s);
}
.segment:hover {
  color: var(--text);
}
.segment.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  font-weight: 600;
}
.segment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tax-explainer {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 var(--radius, 8px) var(--radius, 8px) 0;
  margin: 0 0 var(--space-3, 12px);
}
.tax-explainer strong {
  color: var(--text);
  font-weight: 700;
}
.tax-explainer[hidden] { display: none; }
.tax-mode-panel[hidden] { display: none; }

.tax-tier-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  flex-wrap: wrap;
}
.tax-tier-breakdown {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 12px;
  letter-spacing: -0.1px;
}


/* -------------------------------------------------------------------------
   34. V8.5.3 — Mode pill (compact entry mode indicator)
   Small ochre pill in the page-header-actions for the sales fast-entry role.
   ------------------------------------------------------------------------- */

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--ochre-bg, #faf5e8);
  border: 1px solid var(--ochre-border, #d4b876);
  color: var(--ochre, #b8893a);
  border-radius: var(--radius-pill, 999px);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: help;
  white-space: nowrap;
}
.mode-pill svg {
  flex-shrink: 0;
}
.mode-pill-compact {
  /* the default .mode-pill already styles for compact mode */
}


/* -------------------------------------------------------------------------
   35. V8.5.3 — Tax mode responsive
   ------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .tax-mode {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .segmented-control {
    width: 100%;
  }
  .segment {
    flex: 1;
    text-align: center;
  }
  .tax-tier-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .tax-tier-breakdown {
    margin-bottom: 8px;
  }
}




/* -------------------------------------------------------------------------
   36. V9.0.0 — "The Ledger" — Signature components
   ------------------------------------------------------------------------- */

/* ----- 36a. Stat strip (hairline-anchored naked numerics) ----- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(var(--stat-strip-cols, 5), minmax(0, 1fr));
  border-top: var(--rule);
  border-bottom: var(--rule);
  margin: 0;
}
.stat-strip-item {
  padding: var(--stat-strip-padding-y) 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  min-width: 0;
}
.stat-strip-item + .stat-strip-item {
  border-left: var(--rule-soft);
}
.stat-strip-item .eyebrow {
  font-size: var(--stat-strip-eyebrow-size);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--stat-strip-eyebrow-tracking);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-strip-item .numeric {
  display: block;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.3px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-strip-item.is-primary .numeric {
  font-family: var(--stat-strip-numeric-primary-family);
  font-optical-sizing: auto;
  font-variation-settings: 'opsz' 144, 'SOFT' 0;
  font-weight: 600;
  font-size: var(--stat-strip-numeric-primary-size);
  color: var(--text);
}
.stat-strip-item.is-secondary .numeric {
  font-family: var(--stat-strip-numeric-secondary-family);
  font-size: var(--stat-strip-numeric-secondary-size);
  font-weight: 500;
  color: var(--text);
}
.stat-strip-item .sub {
  font-size: var(--stat-strip-sub-size);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-strip-item.is-ochre .numeric { color: var(--ochre); }
.stat-strip-item.is-danger .numeric { color: var(--danger); }
.stat-strip-item.is-success .numeric { color: var(--success); }

/* Stat strip link (clickable cell — turn the whole item into a link) */
a.stat-strip-item { text-decoration: none; color: inherit; transition: background var(--transition); }
a.stat-strip-item:hover { background: var(--surface-hover); }

@media (max-width: 900px) {
  .stat-strip { grid-template-columns: repeat(var(--stat-strip-cols-mobile, 2), minmax(0, 1fr)); }
  .stat-strip-item { padding: 14px 14px; }
  .stat-strip-item.is-primary .numeric { font-size: 22px; }
}
@media (max-width: 540px) {
  .stat-strip { grid-template-columns: 1fr; }
  .stat-strip-item + .stat-strip-item { border-left: 0; border-top: var(--rule-soft); }
}


/* ----- 36b. Ledger progress (single source of truth for paid/balance/total) ----- */

.ledger-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.ledger-progress .ledger-progress-body { flex: 1; min-width: 0; }
.ledger-progress .ledger-progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  gap: 8px;
  flex-wrap: wrap;
}
.ledger-progress .ledger-progress-stats strong { color: var(--text); font-weight: 600; }
.ledger-progress .ledger-progress-stats .is-danger { color: var(--danger); }
.ledger-progress .ledger-progress-stats .is-success { color: var(--success); }
.ledger-progress .ledger-progress-track {
  height: var(--progress-bar-h);
  background: var(--progress-track);
  border-radius: calc(var(--progress-bar-h) / 2);
  overflow: hidden;
  position: relative;
}
.ledger-progress .ledger-progress-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: calc(var(--progress-bar-h) / 2);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.ledger-progress.is-ochre .ledger-progress-fill { background: var(--progress-fill-ochre); }
.ledger-progress.is-danger .ledger-progress-fill { background: var(--progress-fill-danger); }
.ledger-progress .ledger-progress-badge { flex-shrink: 0; }

@media (max-width: 640px) {
  .ledger-progress { flex-direction: column; align-items: stretch; }
  .ledger-progress .ledger-progress-badge { align-self: flex-end; }
}


/* ----- 36c. Contact card (customer/vendor identity) ----- */

.contact-card { display: flex; flex-direction: column; }
.contact-card a { color: var(--accent); text-decoration: none; }
.contact-card a:hover { text-decoration: underline; }
.contact-card .contact-name {
  font-family: var(--stat-strip-numeric-primary-family);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.3px;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: var(--rule-soft);
}
.contact-card .contact-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13.5px;
  border-bottom: var(--rule-soft);
  gap: 16px;
}
.contact-card .contact-row:last-child { border-bottom: 0; }
.contact-card .contact-label {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  min-width: 90px;
}
.contact-card .contact-value { text-align: right; min-width: 0; word-break: break-word; }
.contact-card .contact-value.is-stacked {
  text-align: left;
  white-space: pre-line;
  width: 100%;
}
.contact-card .contact-notes {
  display: block;
  text-align: left;
  white-space: pre-line;
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
  width: 100%;
}


/* ----- 36d. AR snapshot (promoted from payment_form.html inline <style>) ----- */

.ar-inline-box { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); }
.ar-context-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.ar-mini-card { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ar-mini-card.alert { background: var(--danger-bg); border-color: var(--danger-border); }
.ar-mini-card.success { background: var(--success-bg); border-color: var(--success-border); }
.ar-mini-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 4px; }
.ar-mini-value { font-size: 16px; font-weight: 700; font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; }
.ar-mini-card.alert .ar-mini-value { color: var(--danger); }
.ar-mini-card.success .ar-mini-value { color: var(--success); }
.ar-section + .ar-section { margin-top: 14px; }
.ar-section-head { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.45px; margin-bottom: 8px; }
.ar-list { display: grid; gap: 8px; }
.ar-list-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ar-list-item.current { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(10, 47, 134, 0.15); }
.ar-primary { font-size: 13px; font-weight: 700; color: var(--text); }
.ar-secondary { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ar-note { font-size: 12px; color: var(--text); margin-top: 6px; line-height: 1.45; }
.ar-chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--accent-subtle); color: var(--accent); font-size: 11px; font-weight: 700; margin-top: 4px; }

@media (max-width: 720px) {
  .ar-context-grid { grid-template-columns: 1fr; }
  .ar-list-item { flex-direction: column; }
}


/* ----- 36e. .tag (info pills — not status) ----- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--tag-padding-y) var(--tag-padding-x);
  border-radius: var(--tag-radius);
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-size: var(--tag-size);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid transparent;
  text-decoration: none;
}
.tag.is-accent { background: var(--tag-accent-bg); color: var(--tag-accent-fg); }
.tag.is-ochre { background: var(--ochre-bg); color: var(--ochre); border-color: var(--ochre-border); }
.tag.is-outlined { background: transparent; border-color: var(--border-dark); }
a.tag:hover { background: var(--surface-hover); }
a.tag.is-accent:hover { background: var(--accent-subtle); filter: brightness(0.97); }
.tag .tag-x { margin-left: 2px; opacity: 0.6; font-size: 10px; }


/* ----- 36f. Detail row modifiers (replaces inline style="align-items:flex-start" etc.) ----- */

.detail-row.is-top { align-items: flex-start; }
.detail-row.is-stacked { flex-direction: column; gap: 4px; }
.detail-row.is-stacked .detail-label { margin-bottom: 2px; }
.detail-row.is-stacked .detail-value { text-align: left; width: 100%; }
.detail-row.is-subtotal { font-weight: 700; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.detail-row.is-soft { color: var(--text-muted); }
.detail-row .detail-value.is-stack { text-align: left; white-space: pre-line; }
.detail-row.is-credit { color: var(--success); }
.detail-row.is-debit { color: var(--danger); }


/* -------------------------------------------------------------------------
   37. V9.0.1 — Cheque status strip (signature header for cheque_detail)
   ------------------------------------------------------------------------- */

.cheque-status-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cheque-status-strip-info {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.cheque-status-strip-info .eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}
.cheque-status-strip-number {
  font-family: var(--stat-strip-numeric-primary-family);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 20px;
  color: var(--text);
  letter-spacing: -0.3px;
}
.cheque-status-strip-direction {
  font-size: 12px;
  color: var(--text-muted);
}
.cheque-status-strip-workflow {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cheque-status-step {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.cheque-status-step.is-holding { background: var(--ochre-bg); color: var(--ochre); border-color: var(--ochre-border); }
.cheque-status-step.is-deposited { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.cheque-status-step.is-bounced,
.cheque-status-step.is-cancelled { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.cheque-status-step.is-cleared { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border); }
.cheque-status-when { font-size: 12px; color: var(--text-muted); }
.cheque-status-strip-alert {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

@media (max-width: 640px) {
  .cheque-status-strip { gap: 10px; }
  .cheque-status-strip-number { font-size: 17px; }
}


/* -------------------------------------------------------------------------
   38. V9.0.2 — Form polish utilities
   ------------------------------------------------------------------------- */

.form-check-row { display: flex; align-items: center; gap: 8px; }
.form-check-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.form-check-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.form-actions-delete { margin-left: auto; }


/* -------------------------------------------------------------------------
   39. V9.0.3 — Sidebar & Topbar Signature Elements
   ------------------------------------------------------------------------- */

/* Ochre hairline below the brand block — a stamping seal under the logo */
.sidebar-brand::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 14px;
  background: linear-gradient(90deg, var(--ochre) 0%, transparent 90%);
  border-radius: 1px;
}

/* Active nav label uses Fraunces 600 — serif treatment, not just bold */
.sidebar .nav-link.active {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  letter-spacing: -0.1px;
}

/* Today's date eyebrow at the bottom of the sidebar */
.sidebar-today {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-today strong {
  display: block;
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 2px;
}

/* Hairline above the qa-btn row in the topbar — topbar reads as 2 layers */
.topbar-right { border-top: 1px solid var(--border); padding-top: 12px; }

/* The cmd-trigger gets a kbd hint already, but the kbd is for the visible
   shortcut. V9.0.3 leaves the kbd styling unchanged; the visible UX is
   the same. */


/* -------------------------------------------------------------------------
   40. V9.0.4 — Login page styles (moved from inline <style> in
   registration/login.html). The page has no sidebar/topbar; it owns
   its own visual layer (paper-grain, radial blue glow, login card).
   ------------------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  position: relative;
  background: var(--bg);
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10  0 0 0 0 0.09  0 0 0 0 0.08  0 0 0 0.035 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
  mix-blend-mode: multiply;
}
.login-page::after {
  content: '';
  position: fixed;
  top: -200px; right: -120px;
  width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(10, 47, 134, 0.10) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.login-wrap {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand img.brand-logo {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
  object-fit: contain;
  margin: 0 auto 18px;
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
  border: 1px solid var(--border);
  box-shadow: 0 14px 36px rgba(10, 47, 134, 0.10);
}
.login-brand .brand-logo-fallback {
  width: 100%;
  max-width: 320px;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #fff 0%, #f7f9fd 100%);
  color: var(--accent);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 14px 36px rgba(10, 47, 134, 0.10);
}
.login-brand h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin-bottom: 4px;
}
.login-brand p { font-size: 13px; color: var(--text-muted); }
.login-brand small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.login-card {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
}
.login-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.login-error svg { flex-shrink: 0; }
.login-form .form-group { margin-bottom: 16px; }
.login-form .form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.login-form .form-input {
  padding: 11px 14px;
  font-size: 14px;
  border-radius: var(--radius);
}
.login-form .btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 650;
  margin-top: 8px;
}
.login-form .btn-primary:hover { transform: none; }
.login-footer {
  text-align: center;
  margin-top: 22px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.7;
}
.login-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
.login-footer a:hover { text-decoration: underline; }


/* -------------------------------------------------------------------------
   41. V9.0.5 — Layout utilities (the small inline styles that recur)
   ------------------------------------------------------------------------- */
.ml-sm { margin-left: 8px; }
.mt-md { margin-top: 12px; }
.float-right { float: right; }
.cell-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }

.card-narrow { max-width: 560px; }
.card-wide { max-width: 860px; }
.surface-light { background: rgba(255, 255, 255, 0.45); }
.info-box {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 20px;
  font-size: 13px;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fw-semibold { font-weight: 600; }
.text-secondary { color: var(--text-secondary); }
.is-top { align-items: flex-start; }

/* V9.0.5 — truncate utility for narrow table cells */
.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-nowrap { white-space: nowrap; }


/* -------------------------------------------------------------------------
   42. V9.0.5 — Confirm card
   ------------------------------------------------------------------------- */
.confirm-card { max-width: 480px; margin: 60px auto; }
.confirm-card .card { padding: 32px; text-align: left; }
.confirm-card h3 { font-family: 'Fraunces', Georgia, serif; font-size: 20px; margin-bottom: 12px; }
.confirm-card-object { font-size: 16px; margin: 0 0 12px; padding: 12px 14px; background: var(--surface-alt); border-radius: var(--radius); }
.confirm-card-warning { color: var(--danger); font-size: 13px; margin: 0 0 20px; }
.confirm-card-actions { justify-content: flex-start; }


/* -------------------------------------------------------------------------
   43. V9.1.0 — Tax dashboard (tabs, step eyebrows, sidebar entry)
   ------------------------------------------------------------------------- */

/* Tab strip across the top of the Tax dashboard. Server-rendered active
   state — no client-side JS needed; the user just clicks to navigate. */
.tax-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0 8px;
  overflow-x: auto;
}
.tax-tab {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 120ms ease, border-color 120ms ease;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tax-tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.tax-tab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tax-tab.active {
  color: var(--text);
  border-bottom-color: var(--ochre);  /* V9.3.0 — ochre hairline, not navy */
}
.tax-tab-aux {
  margin-left: auto;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tax-tab-aux:hover {
  color: var(--text);
}

/* On narrow viewports, tighten the tab strip. */
@media (max-width: 640px) {
  .tax-tab { padding: 10px 12px; font-size: 13px; }
  .tax-tab-aux { margin-left: 0; }
}

/* -------------------------------------------------------------------------
   44. V9.2.0 — Tax dashboard (Setup status checklist, dtax formset,
       Rate-line one-liners)
   ------------------------------------------------------------------------- */

/* Setup status checklist (4 rows: TIN, VAT config, VAT period, WHT period). */
.tax-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tax-checklist-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.tax-checklist-row:last-child {
  border-bottom: 0;
}
.tax-checklist-icon {
  flex: 0 0 auto;
  font-size: 18px;
  width: 28px;
  text-align: center;
}
.tax-checklist-body {
  flex: 1 1 auto;
  min-width: 0;
}
.tax-checklist-label {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
}
.tax-checklist-detail {
  font-size: 12.5px;
  color: var(--text-muted);
}
.tax-checklist-action {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
  transition: background 120ms ease;
}
.tax-checklist-action:hover {
  background: var(--bg-hover, #f3f4f6);
  text-decoration: none;
}
.tax-checklist-good .tax-checklist-label { color: var(--text); }
.tax-checklist-warn { background: var(--warning-bg); }
.tax-checklist-bad  { background: var(--danger-bg); }
.tax-checklist-warn .tax-checklist-action,
.tax-checklist-bad  .tax-checklist-action { color: var(--accent); }

/* dtax formset editor (Setup tab → Default tax tiers). */
.dtax-shell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 0;
}
.dtax-row {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr 1.4fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
}
.dtax-row .dtax-remove {
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1;
}
.dtax-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 8px 0 4px;
}
.dtax-preset-wrap {
  position: relative;
  display: inline-block;
}
.dtax-preset-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  min-width: 200px;
  z-index: 20;
  display: flex;
  flex-direction: column;
}
/* V9.3.1 — `[hidden]` (browser default: display:none) loses to class
   selectors that set display. Without this, the menu renders open on
   load. Matches the .tax-explainer / .tax-mode-panel pattern above. */
.dtax-preset-menu[hidden] { display: none; }
.dtax-preset-menu button {
  text-align: left;
  background: transparent;
  border: 0;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.dtax-preset-menu button:hover {
  background: var(--bg-hover, #f3f4f6);
}
.dtax-preview {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  font-size: 12.5px;
  color: var(--text-muted);
}
.dtax-preview-empty {
  font-style: italic;
}
.dtax-preview-cell {
  display: inline-flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  min-width: 88px;
  text-align: right;
}
.dtax-preview-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.dtax-preview-value {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.dtax-preview-total {
  background: var(--success-bg);
  border-color: var(--success-border);
}
.dtax-preview-total .dtax-preview-value { color: var(--success); }
.dtax-preview-detail {
  width: 100%;
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

/* Rates tab: 4 one-liner rows. */
.tax-rate-lines {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tax-rate-line {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.tax-rate-line:last-child {
  border-bottom: 0;
}
.tax-rate-headline {
  flex: 0 0 220px;
  font-size: 14px;
}
.tax-rate-detail {
  flex: 1 1 auto;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.tax-rate-source {
  color: var(--text-muted);
  font-size: 12px;
}
.tax-rate-details {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--bg-soft, #fafafa);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tax-rate-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  padding: 4px 0;
}
.tax-rate-details > summary:hover { color: var(--text); }
.tax-rate-details[open] > summary { margin-bottom: 12px; }

@media (max-width: 640px) {
  .tax-checklist-row { flex-wrap: wrap; }
  .tax-checklist-action { width: 100%; text-align: center; margin-top: 6px; }
  .dtax-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .dtax-row .dtax-remove { grid-column: 2; justify-self: end; }
  .dtax-preview { width: 100%; margin-left: 0; }
  .tax-rate-line { flex-direction: column; align-items: flex-start; gap: 4px; }
  .tax-rate-headline { flex: none; }
}

/* ── Reports dashboard ────────────────────────────────────────────── */
.reports-dashboard .reports-group { margin-top: 28px; }
.reports-dashboard .reports-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 8px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.reports-dashboard .reports-group-head h3 {
  margin: 0; font-family: var(--font-display, 'Fraunces', Georgia, serif);
  font-size: 20px; font-weight: 500; color: var(--text);
}
.reports-dashboard .reports-group-count {
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.reports-dashboard .reports-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.reports-dashboard .report-card {
  display: grid; grid-template-columns: 36px 1fr 16px;
  align-items: center; gap: 14px;
  padding: 16px 18px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  color: var(--text);
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}
.reports-dashboard .report-card:hover {
  border-color: var(--accent, #1955a6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.reports-dashboard .report-card-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  color: var(--accent, #1955a6);
  background: color-mix(in srgb, var(--accent, #1955a6) 8%, transparent);
  border-radius: var(--radius-sm, 4px);
}
.reports-dashboard .report-card-icon svg { width: 18px; height: 18px; }
.reports-dashboard .report-card-body { min-width: 0; }
.reports-dashboard .report-card-title {
  font-weight: 600; font-size: 14px; color: var(--text);
  line-height: 1.25; margin-bottom: 2px;
}
.reports-dashboard .report-card-desc {
  font-size: 12.5px; color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.reports-dashboard .report-card-arrow {
  color: var(--text-muted);
  transition: color 120ms ease, transform 120ms ease;
}
.reports-dashboard .report-card-arrow svg { width: 14px; height: 14px; }
.reports-dashboard .report-card:hover .report-card-arrow {
  color: var(--accent, #1955a6);
  transform: translateX(2px);
}
/* V9.3.2 — Top-level nav link (e.g. Reports) sits between sections
   without its own .nav-section header. Add a hairline rule above so
   it doesn't crowd the section above it. */
.nav-link--top { margin-top: 4px; }
.nav-link--top::before {
  content: ''; display: block; position: absolute;
  left: 18px; right: 18px; top: -1px; height: 1px;
  background: rgba(255,255,255,0.08);
}
