/* ═══════════════════════════════════════════════════════════════════════
   Ledger Nova Admin Dashboard — Design System
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #F4F4F4;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F9FAFB;
  --bg-input: #F4F4F4;
  --bg-sidebar: #FFFFFF;
  --border: rgba(0,0,0,0.08);
  --border-focus: #19519F;
  --brand: #19519F;
  --brand-light: #1565C0;
  --brand-glow: rgba(25,81,159,0.15);
  --green: #008236;
  --green-bg: rgba(0,130,54,0.08);
  --red: #C10007;
  --red-bg: rgba(193,0,7,0.08);
  --text: #101828;
  --text-secondary: #475569;
  --text-muted: #6B7280;
  --text-dim: #9CA3AF;
  --radius: 24px;
  --radius-sm: 16px;
  --radius-xs: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  /* Our own dropdown chevron. Every <select> sets appearance:none and paints
     this instead, because the native menulist arrow anchors to the BORDER box
     and ignores padding-right — it sits jammed against the chip's edge no
     matter what padding we give it. Stroke is --text-muted (#6B7280) inline;
     a data URI can't read a CSS variable, and # must be escaped as %23. */
  --select-chevron: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
}

* { margin:0; padding:0; box-sizing:border-box; }
svg { display:inline-block; vertical-align:middle; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ───────────────────────────────────────────────────────── */
/* height, not just width. `width` styles a VERTICAL scrollbar only; a horizontal
   one is sized by `height`, and leaving it unset falls back to the chunky OS
   default. That went unnoticed while nothing in the app scrolled sideways —
   the scrolling tables and the phone sort-chip row both do. */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:#D1D5DB; border-radius:3px; }

/* ═══════════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════════════ */
.login-page {
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  position:relative; overflow:hidden;
}

.login-bg-orb {
  position:absolute; border-radius:50%; filter:blur(100px); opacity:0.15; pointer-events:none;
  animation: orbFloat 12s ease-in-out infinite;
}
.login-bg-orb--1 { width:500px; height:500px; background:#19519F; top:-10%; left:-10%; opacity:0.08; }
.login-bg-orb--2 { width:400px; height:400px; background:#7C3AED; bottom:-10%; right:-10%; animation-delay:4s; opacity:0.06; }
.login-bg-orb--3 { width:300px; height:300px; background:#0EA5E9; top:50%; left:60%; animation-delay:8s; opacity:0.06; }

@keyframes orbFloat {
  0%,100% { transform:translate(0,0) scale(1); }
  33% { transform:translate(30px,-20px) scale(1.05); }
  66% { transform:translate(-20px,30px) scale(0.95); }
}

.login-card {
  width:100%; max-width:400px; padding:40px 36px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.6s ease-out;
  z-index:1;
}

@keyframes fadeUp {
  from { opacity:0; transform:translateY(20px); }
  to { opacity:1; transform:translateY(0); }
}

.login-logo { text-align:center; margin-bottom:32px; }
.login-logo-icon {
  width:56px; height:56px; margin:0 auto 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-radius:18px; display:flex; align-items:center; justify-content:center;
  color:white; box-shadow: 0 4px 20px var(--brand-glow);
}
.login-title { font-size:24px; font-weight:800; letter-spacing:-0.5px; color:var(--text); }
.login-subtitle { font-size:14px; color:var(--text-muted); margin-top:4px; font-weight:500; }

.form-group { margin-bottom:18px; }
.form-group label { display:block; font-size:13px; font-weight:600; color:var(--text-secondary); margin-bottom:6px; }
.form-group input {
  width:100%; padding:12px 16px; font-size:14px; font-family:inherit;
  background:var(--bg-input); border:1px solid var(--border); border-radius:var(--radius-sm);
  color:var(--text); outline:none; transition:border var(--transition);
}
.form-group input::placeholder { color:var(--text-dim); }
.form-group input:focus { border-color:var(--border-focus); box-shadow: 0 0 0 3px var(--brand-glow); }

.login-error { background:var(--red-bg); color:var(--red); padding:10px 14px; border-radius:var(--radius-xs); font-size:13px; margin-bottom:14px; border:1px solid rgba(193,0,7,0.2); }

.login-btn {
  width:100%; padding:14px; font-size:15px; font-weight:700; font-family:inherit;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color:white; border:none; border-radius:var(--radius-sm); cursor:pointer;
  transition: all var(--transition); display:flex; align-items:center; justify-content:center; gap:8px;
}
.login-btn:hover { transform:translateY(-1px); box-shadow: 0 6px 24px var(--brand-glow); }
.login-btn:active { transform:translateY(0); }

.login-footer { text-align:center; font-size:12px; color:var(--text-dim); margin-top:20px; }

/* ── Forgot password ─────────────────────────────────────────────── */
.login-forgot-row { display: flex; justify-content: flex-end; margin: -6px 0 14px; }
.login-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--brand); font-family: inherit;
}
.login-link:hover { text-decoration: underline; }
.forgot-panel { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.forgot-panel label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.forgot-panel input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; }
.forgot-msg { margin-top: 10px; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.forgot-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
/* Additions to the block above: without these the panel's input sits on default
   white with a browser focus ring, three lines under two .form-group inputs that
   are --bg-input with a brand-glow ring. Same tokens as .form-group input:focus. */
.forgot-panel input { background: var(--bg-input); color: var(--text); outline: none; }
.forgot-panel input::placeholder { color: var(--text-dim); }
.forgot-panel input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--brand-glow); }

.spinner {
  width:18px; height:18px; border:2px solid rgba(255,255,255,0.3);
  border-top-color:white; border-radius:50%; animation:spin 0.6s linear infinite;
}
.spinner.large { width:32px; height:32px; border-width:3px; border-color:rgba(0,0,0,0.1); border-top-color:var(--brand); }

@keyframes spin { to { transform:rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ═══════════════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ═══════════════════════════════════════════════════════════════════════ */
.dashboard { display:flex; min-height:100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width:240px; min-height:100vh; padding:20px 12px;
  background:var(--bg-sidebar); border-right:1px solid var(--border);
  display:flex; flex-direction:column; position:fixed; top:0; left:0; z-index:10;
}
.sidebar-brand { display:flex; align-items:center; gap:10px; padding:8px 12px; margin-bottom:28px; }
.sidebar-logo-icon {
  width:36px; height:36px; border-radius:10px;
  background: transparent;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.sidebar-brand-text { font-size:16px; font-weight:800; letter-spacing:-0.3px; color:var(--text); }

.sidebar-nav { flex:1; display:flex; flex-direction:column; gap:2px; }

.nav-item {
  display:flex; align-items:center; gap:10px; padding:10px 14px;
  font-size:14px; font-weight:500; color:var(--text-secondary);
  background:transparent; border:none; border-radius:var(--radius-xs);
  cursor:pointer; transition:all var(--transition); font-family:inherit; text-align:left; width:100%;
}
.nav-item svg { flex-shrink:0; vertical-align:middle; }
.nav-item:hover { background:rgba(0,0,0,0.03); color:var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(25,81,159,0.1), rgba(21,101,192,0.05));
  color:var(--brand); font-weight:600;
}
.nav-item.active svg { stroke:var(--brand-light); }

.sidebar-footer { padding:12px 8px; border-top:1px solid var(--border); }
.sidebar-user { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.sidebar-avatar {
  width:34px; height:34px; border-radius:12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700; color:white;
}
.sidebar-user-info { overflow:hidden; }
.sidebar-user-name { display:block; font-size:13px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-user-email { display:block; font-size:11px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.logout-btn {
  width:100%; padding:8px; display:flex; align-items:center; justify-content:center;
  background:rgba(193,0,7,0.05); border:1px solid rgba(193,0,7,0.1); border-radius:var(--radius-xs);
  color:var(--red); cursor:pointer; transition:all var(--transition);
}
.logout-btn:hover { background:rgba(193,0,7,0.1); }

/* ── Main Content ────────────────────────────────────────────────────── */
/* min-width:0 is load-bearing, not tidying. This is a flex item, and a flex
   item's default min-width is `auto` — meaning it CANNOT shrink below its own
   content's min-content width. The 7-column tables inside it are ~716px wide,
   so at a 360px viewport the whole shell was forced out to 474px, taking the
   header with it. The header was never too wide; its parent was.
   Measured: removing this puts documentElement.scrollWidth at 475 instead of 360. */
.main-content { flex:1; min-width:0; margin-left:240px; display:flex; flex-direction:column; min-height:100vh; }

.main-header {
  padding:18px 36px; display:flex; align-items:center; gap:20px;
  background:var(--bg-card);
  border-bottom:1px solid rgba(0,0,0,0.04);
  box-shadow:0 1px 8px rgba(0,0,0,0.03);
  position:sticky; top:0; z-index:30;
}
.header-left { flex-shrink:0; min-width:0; }
.page-title { font-size:22px; font-weight:800; letter-spacing:-0.5px; line-height:1.15; color:var(--text); }
.page-subtitle { font-size:12px; color:var(--text-dim); margin-top:2px; font-weight:500; letter-spacing:0.1px; }

/* ── Search Bar ──────────────────────────────────────────────────────── */
.header-center { flex:1; max-width:480px; margin:0 auto; }
.header-search {
  position:relative; display:flex; align-items:center;
}
.header-search-icon {
  position:absolute; left:14px; color:var(--text-dim); pointer-events:none;
  opacity:0.6; transition:opacity var(--transition);
}
.header-search:focus-within .header-search-icon { opacity:1; color:var(--brand); }
.header-search input {
  width:100%; padding:10px 44px 10px 40px; font-size:13.5px; font-family:inherit;
  background:var(--bg); border:1.5px solid transparent; border-radius:50px;
  color:var(--text); outline:none; transition:all 0.25s ease;
  letter-spacing:0.1px;
}
.header-search input::placeholder { color:var(--text-dim); font-weight:400; }
.header-search input:focus {
  background:var(--bg-card); border-color:var(--brand);
  box-shadow:0 0 0 4px var(--brand-glow), 0 2px 12px rgba(25,81,159,0.08);
}
.search-kbd {
  position:absolute; right:12px;
  padding:3px 8px; font-size:10px; font-weight:700; font-family:'Inter',monospace;
  background:rgba(0,0,0,0.05); border:1px solid rgba(0,0,0,0.08); border-radius:6px;
  color:var(--text-dim); line-height:1.3; pointer-events:none;
}
.header-search input:focus + .search-kbd { opacity:0; }

/* ── Header Actions ──────────────────────────────────────────────────── */
.header-actions { display:flex; align-items:center; gap:6px; flex-shrink:0; }
.header-divider {
  width:1px; height:28px; background:var(--border); margin:0 8px; flex-shrink:0;
}

/* ── Unified Icon Button ─────────────────────────────────────────────── */
.header-icon-btn {
  width:40px; height:40px; border-radius:12px; border:none;
  background:transparent; color:var(--text-muted); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:all 0.2s ease; position:relative;
}
.header-icon-btn:hover {
  background:var(--bg); color:var(--text);
  transform:scale(1.05);
}
.header-icon-btn:active { transform:scale(0.95); }
.header-icon-btn.spinning svg { animation:spin 1s linear infinite; }
.header-icon-btn--danger { color:var(--red); }
.header-icon-btn--danger:hover { background:var(--red-bg); color:var(--red); }

/* ── Notification Bell ───────────────────────────────────────────────── */
.header-notif-wrap { position:relative; }
/* Flex-centred, never line-height-centred: `* { box-sizing:border-box }` makes
   the 2px border eat into `height`, so a line-height equal to the height pushes
   the digits below centre and clips them. */
.notif-badge {
  position:absolute; top:-4px; right:-4px; min-width:22px; height:22px;
  padding:0 6px;
  display:flex; align-items:center; justify-content:center;
  background:#EF4444; color:white;
  font-size:11px; font-weight:700; line-height:1; letter-spacing:0.2px;
  border-radius:999px; border:2px solid var(--bg-card);
  box-shadow:0 0 0 1px rgba(239,68,68,0.3);
}
.notif-dropdown {
  position:absolute; top:calc(100% + 10px); right:-12px; z-index:50;
  width:360px; max-height:440px;
  background:var(--bg-card); border:1px solid var(--border); border-radius:20px;
  box-shadow:0 20px 60px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.03);
  overflow:hidden; animation:modalSlide 0.2s ease-out;
}
.notif-dropdown-header {
  padding:16px 20px; display:flex; align-items:center; justify-content:space-between;
  border-bottom:1px solid var(--border); background:rgba(0,0,0,0.01);
}
.notif-dropdown-title { font-size:15px; font-weight:700; letter-spacing:-0.2px; }
.notif-dropdown-action {
  font-size:12px; font-weight:600; color:var(--brand); background:none; border:none;
  cursor:pointer; font-family:inherit; padding:4px 10px; border-radius:8px;
  transition:background var(--transition);
}
.notif-dropdown-action:hover { background:var(--brand-glow); }
.notif-dropdown-list { max-height:340px; overflow-y:auto; }
.notif-dropdown-item {
  padding:14px 20px; display:flex; gap:12px; border-bottom:1px solid rgba(0,0,0,0.03);
  transition:background var(--transition); cursor:default;
}
.notif-dropdown-item:last-child { border-bottom:none; }
.notif-dropdown-item:hover { background:rgba(25,81,159,0.02); }
.notif-dropdown-item .activity-dot { margin-top:5px; flex-shrink:0; }
.notif-dropdown-item-title { font-size:13px; font-weight:600; color:var(--text); line-height:1.35; }
.notif-dropdown-item-body { font-size:11.5px; color:var(--text-muted); margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:260px; }
.notif-dropdown-item-time { font-size:10px; color:var(--text-dim); margin-top:4px; }
.notif-dropdown-empty { padding:40px 20px; text-align:center; font-size:13px; color:var(--text-dim); }

/* ── User Profile (Header) ───────────────────────────────────────────── */
.header-user {
  display:flex; align-items:center; gap:10px;
  padding:4px 16px 4px 4px;
  background:var(--bg); border:none; border-radius:50px;
  cursor:pointer; transition:all 0.2s ease;
}
.header-user:hover { background:rgba(0,0,0,0.06); box-shadow:0 2px 8px rgba(0,0,0,0.05); }
.header-user:active { transform:scale(0.98); }
.header-user .sidebar-avatar {
  width:34px; height:34px; border-radius:50%;
  background: linear-gradient(135deg, #19519F, #2196F3);
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700; color:white;
  box-shadow:0 2px 8px rgba(25,81,159,0.25);
  position:relative;
}
.header-user .sidebar-avatar::after {
  content:''; position:absolute; bottom:0; right:0;
  width:10px; height:10px; border-radius:50%;
  background:#22C55E; border:2px solid var(--bg);
}
.header-user .sidebar-user-info { overflow:hidden; }
.header-user .sidebar-user-name { display:block; font-size:13px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:120px; line-height:1.2; }
.header-user .sidebar-user-email { display:block; font-size:10.5px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:120px; line-height:1.3; }



/* Fluid gutter: 32px of side padding is 18% of a 360px screen. clamp() gives
   the desktop value back at width without a breakpoint, so no media query owns
   this and there is one rule to reason about instead of three. */
.content-area {
  flex:1; overflow-y:auto;
  padding: clamp(16px, 2.5vw, 24px) clamp(12px, 3vw, 32px) clamp(24px, 3vw, 32px);
}

.loading-state { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:16px; padding:80px 0; color:var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════════════════ */
.stats-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:16px; margin-bottom:28px; }

/* Column-count modifiers. These exist so the feature modules do not set
   grid-template-columns as an inline style attribute: nothing in a stylesheet
   outranks inline except !important, so an inline value made the phone rules
   unenforceable without one. */
.stats-grid--2 { grid-template-columns:repeat(2,1fr); }
.stats-grid--3 { grid-template-columns:repeat(3,1fr); }
.stats-grid--4 { grid-template-columns:repeat(4,1fr); }
/* Five is the ceiling any section needs: the widest fixed row is Members, and
   its card count is 1 + the roles in workspace_members' CHECK constraint
   (viewer / editor / contributor / admin). Deliberately NOT open-ended -- a
   row whose column count follows the data is what wrapped the Transactions
   KPIs, and the fix there was to remove the dependency, not widen the grid. */
.stats-grid--5 { grid-template-columns:repeat(5,1fr); }

/* The realtime pill. Was built entirely from an inline cssText in
   js/core/realtime.js, which meant no media query could hide it without
   !important. The dynamic half — the background and colour that flip between
   Live and Offline — is still set from JS, because that is state, not layout. */
.realtime-indicator {
  display:inline-flex; align-items:center; gap:6px;
  font-size:11px; font-weight:500; padding:4px 10px;
  border-radius:20px; margin-left:8px;
  transition:all 0.3s ease;
}

.stat-card {
  padding:22px; border-radius:var(--radius); background:var(--bg-card);
  border:1px solid var(--border); transition:all var(--transition);
  animation: fadeUp 0.5s ease-out both;
}
.stat-card:hover { border-color:rgba(255,255,255,0.1); transform:translateY(-2px); box-shadow:var(--shadow); }

.stat-card .stat-icon {
  width:40px; height:40px; border-radius:14px; display:flex; align-items:center; justify-content:center;
  margin-bottom:14px;
}
.stat-card .stat-icon svg { width:20px; height:20px; }
.stat-card .stat-icon.blue { background:rgba(25,81,159,0.15); color:var(--brand-light); }
.stat-card .stat-icon.green { background:var(--green-bg); color:var(--green); }
.stat-card .stat-icon.red { background:var(--red-bg); color:var(--red); }
.stat-card .stat-icon.purple { background:rgba(124,58,237,0.12); color:#8B5CF6; }
.stat-card .stat-icon.cyan { background:rgba(6,182,212,0.12); color:#06B6D4; }

.stat-value { font-size:28px; font-weight:800; letter-spacing:-0.5px; margin-bottom:4px; }
.stat-label { font-size:13px; color:var(--text-muted); font-weight:500; }

/* ═══════════════════════════════════════════════════════════════════════
   DATA TABLES
   ═══════════════════════════════════════════════════════════════════════ */
.section-card {
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
  overflow:hidden; margin-bottom:24px; animation: fadeUp 0.5s ease-out both;
}
.section-card-header {
  padding:18px 22px; display:flex; align-items:center; justify-content:space-between;
  border-bottom:1px solid var(--border); gap:12px;
}
.section-card-title { font-size:15px; font-weight:700; letter-spacing:-0.2px; display:inline-flex; align-items:center; gap:8px; }
.section-card-title svg { width:18px; height:18px; flex-shrink:0; }
.section-card-badge {
  padding:4px 10px; border-radius:20px; font-size:12px; font-weight:600; line-height:1;
  background:rgba(25,81,159,0.12); color:var(--brand-light);
  display:inline-flex; align-items:center;
}

.data-table { width:100%; border-collapse:collapse; }
.data-table th {
  padding:12px 18px; text-align:left; font-size:12px; font-weight:600;
  color:var(--text-dim); text-transform:uppercase; letter-spacing:0.5px;
  border-bottom:1px solid var(--border); background:rgba(0,0,0,0.02);
}
.data-table th.th-sort { cursor:pointer; user-select:none; white-space:nowrap; }
.data-table th.th-sort:hover { color:var(--text); background:var(--bg-card-hover); }
.data-table th.th-sort.is-sorted { color:var(--brand); }
.data-table td {
  padding:14px 18px; font-size:13px; border-bottom:1px solid var(--border);
  color:var(--text-secondary); vertical-align:middle;
}
.data-table tr:last-child td { border-bottom:none; }
.data-table tr:hover td { background:rgba(0,0,0,0.015); }

/* A whole row that opens something. Stronger than the plain :hover tint above
   (0.015) so a row that DOES something is visibly distinct from one that is
   only being passed over — the same distinction .activity-item-enhanced draws.
   Literal tints rather than a var(): there is no --bg-hover token in this
   project, and a fallback nobody can override is worse than a literal.

   The outline sits on the <tr>, not the <td>s. `overflow` and `outline` on
   table rows are unreliable, but a plain outline on a row with
   border-collapse:collapse is drawn correctly by every browser this dashboard
   supports, and offset:-2px keeps it inside the card's rounded corner. */
.data-table tr.is-clickable { cursor:pointer; }
.data-table tr.is-clickable:hover td { background:rgba(0,0,0,0.03); }
.data-table tr.is-clickable:focus-visible { outline:2px solid var(--brand); outline-offset:-2px; }

.data-table .text-primary { color:var(--text); font-weight:600; }
.data-table .text-green { color:var(--green); font-weight:600; }
.data-table .text-red { color:var(--red); font-weight:600; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display:inline-block; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600;
}
.badge-in { background:var(--green-bg); color:var(--green); }
.badge-out { background:var(--red-bg); color:var(--red); }
.badge-owner { background:rgba(124,58,237,0.12); color:#8B5CF6; }
.badge-admin { background:rgba(0,130,54,0.12); color:#008236; }
.badge-contributor { background:rgba(2,132,199,0.12); color:#0284C7; }
.badge-viewer { background:rgba(100,116,139,0.12); color:#94A3B8; }
.badge-pending { background:rgba(245,158,11,0.12); color:#F59E0B; }
.badge-active { background:var(--green-bg); color:var(--green); }
.badge-record { background:rgba(25,81,159,0.12); color:var(--brand-light); }
.badge-soft { background:rgba(245,158,11,0.12); color:#F59E0B; }
.badge-strict { background:var(--red-bg); color:var(--red); }

/* Book configuration badges (G-9). Neither .badge-strict nor .badge-soft is
   redefined here — both already exist above and the Workspaces table renders
   control mode with them, so Books reuses them rather than showing the same
   fact in a second colour.
   Literal hex to match the neighbouring badges (there are no --amber/--purple
   tokens in this stylesheet; the palette defines only --green, --red, --brand
   and the --text-* scale).
   Blue, NOT amber: amber is .badge-soft, and a book can be soft AND
   invoice-required at once — two amber pills side by side would read as one
   setting. */
.badge-invoice-required { background:rgba(2,132,199,0.12);  color:#0284C7; }
.badge-budgeting        { background:rgba(124,58,237,0.12); color:#8B5CF6; }

/* ── Currency pill ───────────────────────────────────────────────────── */
.currency-pill {
  display:inline-block; padding:2px 8px; border-radius:12px; font-size:11px; font-weight:600;
  background:rgba(255,255,255,0.06); color:var(--text-secondary); margin-right:4px;
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state { padding:48px; text-align:center; color:var(--text-dim); }
.empty-state svg { margin-bottom:12px; opacity:0.4; }
.empty-state p { font-size:14px; }

/* ── Filters ─────────────────────────────────────────────────────────── */
.filters-bar { display:flex; gap:10px; margin-bottom:20px; flex-wrap:wrap; }
.filter-input {
  padding:9px 14px; font-size:13px; font-family:inherit;
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-xs);
  color:var(--text); outline:none; transition:border var(--transition);
  /* Grows to fill the filters bar instead of sitting at a fixed 180px, which
     truncated placeholders like "Search workspaces by name...". Capped so it
     doesn't stretch across an ultrawide screen, and it still wraps to its own
     line below 600px via .filters-bar's flex-wrap. */
  flex:1 1 320px; min-width:260px; max-width:520px;
}
.filter-input::placeholder { color:var(--text-dim); }
.filter-input:focus { border-color:var(--border-focus); }
.filter-select {
  /* line-height explicit: the default leaves ~0.4px of slack under a 13px font,
     which a taller fallback face (if the Inter webfont fails) would clip. */
  /* padding-right carries the chevron: 12px gutter + 12px glyph + 12px gap to
     the label. Any rule that re-declares `padding` here must keep that room. */
  padding:9px 36px 9px 14px; font-size:13px; line-height:1.4; font-family:inherit;
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-xs);
  color:var(--text); outline:none; cursor:pointer;
  appearance:none; -webkit-appearance:none;
  background-image:var(--select-chevron);
  background-repeat:no-repeat;
  background-position:right 12px center;
}

/* ── Activity feed ───────────────────────────────────────────────────── */
.activity-item {
  display:flex; gap:14px; padding:16px 20px; border-bottom:1px solid var(--border);
  transition: background var(--transition);
}
.activity-item:last-child { border-bottom:none; }
.activity-item:hover { background:rgba(0,0,0,0.015); }
/* Overview's Recent Activity rows, which open the same notification modal the
   Activity feed's rows do. Kept in step with .activity-item-enhanced.is-clickable
   further down: the two feeds render different markup but must not feel like
   different affordances. */
.activity-item.is-clickable { cursor:pointer; }
.activity-item.is-clickable:hover { background:rgba(0,0,0,0.03); }
.activity-item.is-clickable:focus-visible { outline:2px solid var(--brand); outline-offset:-2px; }
.activity-dot {
  width:10px; height:10px; border-radius:50%; margin-top:5px; flex-shrink:0;
  background:var(--brand-light);
}
.activity-dot.green { background:var(--green); }
.activity-dot.red { background:var(--red); }
.activity-dot.purple { background:#8B5CF6; }
.activity-dot.blue { background:var(--brand-light); }
.activity-content { flex:1; }
.activity-title { font-size:13px; font-weight:600; color:var(--text); margin-bottom:2px; }
/* The Access Log wraps both emails in <strong> (it is the one feed that does).
   Left alone, <strong> takes the UA's `font-weight: bolder`, which is RELATIVE:
   against this 600 parent the spec maps it to 900, and index.html loads Inter's
   900 cut — so the emails rendered three steps heavier than their own line and
   read as shouting. An explicit 700 keeps them one clear step above the
   connective words ("changed role for") without the compounding. */
.activity-title strong { font-weight:700; }
.activity-body { font-size:12px; color:var(--text-muted); line-height:1.5; }
.activity-time { font-size:11px; color:var(--text-dim); margin-top:4px; }

/* ── Stagger animations ─────────────────────────────────────────────── */
.stat-card:nth-child(1) { animation-delay:0.05s; }
.stat-card:nth-child(2) { animation-delay:0.1s; }
.stat-card:nth-child(3) { animation-delay:0.15s; }
.stat-card:nth-child(4) { animation-delay:0.2s; }
.stat-card:nth-child(5) { animation-delay:0.25s; }
.stat-card:nth-child(6) { animation-delay:0.3s; }

/* ── Progress bar ────────────────────────────────────────────────────── */
.progress-wrap { margin-top:8px; }
.progress-bar-bg {
  width:100%; height:8px; border-radius:8px; background:var(--bg);
  overflow:hidden;
}
.progress-bar-fill {
  height:100%; border-radius:8px; transition:width 0.6s ease-out;
  background:linear-gradient(90deg, var(--brand), var(--brand-light));
}
.progress-bar-fill.warn { background:linear-gradient(90deg, #F59E0B, #EAB308); }
.progress-bar-fill.danger { background:linear-gradient(90deg, var(--red), #E11D48); }
.progress-label { font-size:11px; color:var(--text-dim); margin-top:4px; display:flex; justify-content:space-between; }

/* ── Budget cards ────────────────────────────────────────────────────── */
.budget-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:16px; margin-bottom:24px; }
.budget-card {
  padding:20px; border-radius:var(--radius); background:var(--bg-card);
  border:1px solid var(--border); animation:fadeUp 0.5s ease-out both;
}
.budget-card-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.budget-card-title { font-size:14px; font-weight:700; }
.budget-card-sub { font-size:12px; color:var(--text-muted); }
.budget-card-amount { font-size:22px; font-weight:800; letter-spacing:-0.3px; }
.budget-card-limit { font-size:12px; color:var(--text-dim); margin-top:2px; }

/* ── Additional badges ───────────────────────────────────────────────── */
.badge-accepted { background:var(--green-bg); color:var(--green); }
.badge-expired { background:rgba(100,116,139,0.12); color:#94A3B8; }
.badge-declined { background:var(--red-bg); color:var(--red); }

/* ── Currency pill (light) ───────────────────────────────────────────── */
.currency-pill {
  display:inline-block; padding:2px 8px; border-radius:12px; font-size:11px; font-weight:600;
  background:rgba(0,0,0,0.05); color:var(--text-secondary); margin-right:4px;
}

/* ── Detail pairs ────────────────────────────────────────────────────── */
.detail-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; padding:18px 22px; }
.detail-item label { display:block; font-size:11px; color:var(--text-dim); text-transform:uppercase; letter-spacing:0.5px; margin-bottom:2px; }
.detail-item span { font-size:14px; font-weight:600; color:var(--text); }

/* ═══════════════════════════════════════════════════════════════════════
   OVERVIEW GRID
   ═══════════════════════════════════════════════════════════════════════ */
.overview-two-col{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-bottom:24px;}
.overview-three-col{display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;margin-bottom:24px;}
.overview-full{margin-bottom:24px;}
@media(max-width:900px){.overview-two-col,.overview-three-col{grid-template-columns:1fr;}}

/* ═══════════════════════════════════════════════════════════════════════
   BAR CHART
   ═══════════════════════════════════════════════════════════════════════ */
.bar-chart{display:flex;align-items:flex-end;gap:8px;height:160px;padding:16px 22px 8px;}
.bar-col{flex:1;display:flex;flex-direction:column;align-items:center;gap:6px;}
.bar-fill{width:100%;border-radius:8px 8px 0 0;background:linear-gradient(180deg,var(--brand),var(--brand-light));min-height:4px;transition:height 0.8s cubic-bezier(.4,0,.2,1);position:relative;}
.bar-fill.accent{background:linear-gradient(180deg,#7C3AED,#A78BFA);}
.bar-value{font-size:11px;font-weight:700;color:var(--text);}
.bar-label{font-size:10px;color:var(--text-dim);font-weight:500;text-align:center;}
.chart-footer{padding:0 22px 16px;display:flex;justify-content:space-between;}
.chart-legend{display:flex;gap:16px;}
.chart-legend-item{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--text-muted);}
.chart-legend-dot{width:8px;height:8px;border-radius:50%;}

/* ═══════════════════════════════════════════════════════════════════════
   DONUT / RING CHART
   ═══════════════════════════════════════════════════════════════════════ */
.donut-wrap{display:flex;align-items:center;gap:24px;padding:20px 22px;}
.donut-svg{width:120px;height:120px;flex-shrink:0;}
.donut-ring{fill:none;stroke-width:14;stroke-linecap:round;transition:stroke-dashoffset 1s ease-out;}
.donut-legend{flex:1;display:flex;flex-direction:column;gap:10px;}
.donut-legend-item{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--text-secondary);}
.donut-legend-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0;}
.donut-legend-value{margin-left:auto;font-weight:700;color:var(--text);}

/* ═══════════════════════════════════════════════════════════════════════
   PLATFORM CARDS
   ═══════════════════════════════════════════════════════════════════════ */
.platform-cards{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;padding:20px 22px;}
.platform-card{padding:16px;border-radius:var(--radius-sm);border:1px solid var(--border);text-align:center;transition:all var(--transition);}
.platform-card:hover{transform:translateY(-2px);box-shadow:var(--shadow);}
.platform-icon{width:40px;height:40px;margin:0 auto 8px;border-radius:14px;background:rgba(25,81,159,0.08);display:flex;align-items:center;justify-content:center;color:var(--brand-light);}
.platform-icon svg{width:20px;height:20px;}
.platform-name{font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:4px;text-transform:uppercase;letter-spacing:0.5px;}
.platform-value{font-size:22px;font-weight:800;color:var(--text);letter-spacing:-0.3px;}
.platform-pct{font-size:11px;color:var(--text-dim);margin-top:2px;}

/* ═══════════════════════════════════════════════════════════════════════
   STAR RATINGS
   ═══════════════════════════════════════════════════════════════════════ */
.star-rating-wrap{padding:20px 22px;}
.star-avg{display:flex;align-items:center;gap:12px;margin-bottom:16px;}
.star-avg-num{font-size:36px;font-weight:900;color:var(--text);letter-spacing:-1px;}
.star-avg-stars{color:#F59E0B;font-size:20px;letter-spacing:2px;}
.star-avg-count{font-size:12px;color:var(--text-dim);}
.star-row{display:flex;align-items:center;gap:8px;margin-bottom:6px;}
.star-row-label{font-size:12px;font-weight:600;color:var(--text-muted);width:14px;text-align:right;}
.star-row-bar{flex:1;height:8px;border-radius:8px;background:var(--bg);overflow:hidden;}
.star-row-fill{height:100%;border-radius:8px;background:linear-gradient(90deg,#F59E0B,#FBBF24);transition:width 0.8s ease-out;}
.star-row-count{font-size:11px;color:var(--text-dim);width:30px;text-align:right;}

/* ═══════════════════════════════════════════════════════════════════════
   REVIEW CARDS
   ═══════════════════════════════════════════════════════════════════════ */
.review-list{padding:0;}
.review-item{padding:16px 22px;border-bottom:1px solid var(--border);transition:background var(--transition);}
.review-item:last-child{border-bottom:none;}
.review-item:hover{background:rgba(0,0,0,0.015);}
.review-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;}
.review-user{display:flex;align-items:center;gap:8px;}
.review-avatar{width:28px;height:28px;border-radius:50%;background:linear-gradient(135deg,var(--brand),var(--brand-light));display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;color:white;}
.review-name{font-size:13px;font-weight:600;color:var(--text);}
.review-stars{color:#F59E0B;font-size:13px;letter-spacing:1px;}
.review-body{font-size:13px;color:var(--text-secondary);line-height:1.5;}
.review-meta{font-size:11px;color:var(--text-dim);margin-top:6px;display:flex;gap:12px;}

/* ═══════════════════════════════════════════════════════════════════════
   USER CARDS / DETAIL
   ═══════════════════════════════════════════════════════════════════════ */
.user-avatar-lg{width:36px;height:36px;border-radius:50%;background:linear-gradient(135deg,var(--brand),var(--brand-light));display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:white;flex-shrink:0;}
.user-info-cell{display:flex;align-items:center;gap:10px;}
.user-detail-name{font-size:13px;font-weight:600;color:var(--text);}
.user-detail-email{font-size:11px;color:var(--text-dim);}
.badge-online{background:var(--green-bg);color:var(--green);}
.badge-offline{background:rgba(100,116,139,0.12);color:#94A3B8;}
.badge-new{background:rgba(124,58,237,0.12);color:#8B5CF6;}
.badge-warning{background:rgba(245,158,11,0.12);color:#D97706;}
.badge-info{background:rgba(59,130,246,0.12);color:#3B82F6;}

/* ═══════════════════════════════════════════════════════════════════════
   STAT ICON ADDITIONS
   ═══════════════════════════════════════════════════════════════════════ */
.stat-card .stat-icon.amber{background:rgba(245,158,11,0.12);color:#F59E0B;}
.stat-card .stat-icon.teal{background:rgba(20,184,166,0.12);color:#14B8A6;}
.stat-card .stat-icon.indigo{background:rgba(99,102,241,0.12);color:#6366F1;}
.stat-card .stat-trend{font-size:11px;font-weight:600;margin-top:4px;}
.stat-card .stat-trend.up{color:var(--green);}
.stat-card .stat-trend.down{color:var(--red);}
/* A KPI card that doubles as a filter toggle for the table below it (Invites).
   Mirrors .role-card.is-selected -- same brand ring, not a full color invert
   like .type-chip.is-active, so the card's own icon color stays legible. */
.stat-card.is-clickable{cursor:pointer;}
.stat-card.is-clickable.is-active{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-glow);}

/* ═══════════════════════════════════════════════════════════════════════
   VERSION TABLE
   ═══════════════════════════════════════════════════════════════════════ */
.version-bar-wrap{display:flex;align-items:center;gap:10px;}
.version-bar{flex:1;height:6px;border-radius:6px;background:var(--bg);overflow:hidden;}
.version-bar-fill{height:100%;border-radius:6px;background:linear-gradient(90deg,var(--brand),var(--brand-light));}
.version-pct{font-size:11px;font-weight:600;color:var(--text-muted);width:36px;text-align:right;}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width:768px) {
  .main-header { padding:14px 16px; flex-wrap:wrap; gap:10px; }
  .header-center { max-width:100%; order:10; flex-basis:100%; }
  .header-user .sidebar-user-info { display:none; }
  .header-user { padding:4px; border-radius:50%; }
  .header-divider { display:none; }
  .stats-grid { grid-template-columns:1fr 1fr; }
  .budget-grid { grid-template-columns:1fr; }
  .platform-cards{grid-template-columns:1fr;}
  .overview-two-col,.overview-three-col{grid-template-columns:1fr;}
  .notif-dropdown { right:-60px; width:300px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   QUICK ACTION BUTTONS
   ═══════════════════════════════════════════════════════════════════════ */
.quick-action-btn {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  width:100%; padding:12px 16px; font-size:13px; font-weight:600; font-family:inherit;
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-xs);
  color:var(--text-secondary); cursor:pointer; transition:all var(--transition); text-align:left;
  line-height:1.4;
}
.quick-action-btn:hover { background:var(--bg-card-hover); color:var(--text); border-color:var(--brand-glow); transform:translateX(4px); }
.quick-action-btn span { display:inline-flex; align-items:center; gap:8px; }
.quick-action-btn svg { width:16px; height:16px; flex-shrink:0; vertical-align:middle; }

/* ═══════════════════════════════════════════════════════════════════════
   EXPORT BUTTON
   ═══════════════════════════════════════════════════════════════════════ */
.export-btn {
  display:inline-flex; align-items:center; gap:8px;
  padding:10px 18px; font-size:13px; font-weight:600; font-family:inherit;
  background:linear-gradient(135deg, var(--brand), var(--brand-light));
  color:white; border:none; border-radius:var(--radius-xs); cursor:pointer;
  transition:all var(--transition); line-height:1;
}
.export-btn:hover { transform:translateY(-1px); box-shadow:0 4px 16px var(--brand-glow); }
.export-btn svg { width:16px; height:16px; flex-shrink:0; vertical-align:middle; }

/* ═══════════════════════════════════════════════════════════════════════
   ADDITIONAL BADGES
   ═══════════════════════════════════════════════════════════════════════ */
.badge-danger { background:var(--red-bg) !important; color:var(--red) !important; }

/* ── Text utilities ──────────────────────────────────────────────────── */
.text-green { color:var(--green); font-weight:600; }
.text-red { color:var(--red); font-weight:600; }
.text-primary { color:var(--text); font-weight:600; }

/* ═══════════════════════════════════════════════════════════════════════
   MODAL SYSTEM
   ═══════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position:fixed; inset:0; z-index:100;
  background:rgba(0,0,0,0.45); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  display:flex; align-items:center; justify-content:center;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.modal-card {
  width:100%; max-width:520px; max-height:85vh;
  background:var(--bg-card); border:1px solid var(--border); border-radius:24px;
  box-shadow:0 24px 80px rgba(0,0,0,0.18);
  animation: modalSlide 0.3s cubic-bezier(.4,0,.2,1);
  display:flex; flex-direction:column; overflow:hidden;
}
@keyframes modalSlide { from { opacity:0; transform:translateY(24px) scale(0.96); } to { opacity:1; transform:translateY(0) scale(1); } }
.modal-header {
  padding:20px 24px 16px; display:flex; align-items:center; justify-content:space-between;
  border-bottom:1px solid var(--border);
}
.modal-title { font-size:17px; font-weight:700; letter-spacing:-0.2px; }
.modal-close {
  width:32px; height:32px; border-radius:12px; border:none;
  background:rgba(0,0,0,0.05); font-size:18px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  color:var(--text-muted); transition:all var(--transition);
}
.modal-close:hover { background:rgba(0,0,0,0.1); color:var(--text); }
.modal-body { padding:20px 24px 24px; overflow-y:auto; }

/* ═══════════════════════════════════════════════════════════════════════
   FORM ELEMENTS (enhanced)
   ═══════════════════════════════════════════════════════════════════════ */
.form-row { margin-bottom:16px; }
.form-row label { display:block; font-size:12px; font-weight:600; color:var(--text-secondary); margin-bottom:6px; text-transform:uppercase; letter-spacing:0.3px; }
.form-row input, .form-row textarea, .form-row select {
  width:100%; padding:11px 14px; font-size:13px; font-family:inherit;
  background:var(--bg-input); border:1px solid var(--border); border-radius:var(--radius-xs);
  color:var(--text); outline:none; transition:border var(--transition);
}
.form-row select {
  padding-right:36px; cursor:pointer;
  appearance:none; -webkit-appearance:none;
  background-image:var(--select-chevron);
  background-repeat:no-repeat;
  background-position:right 12px center;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { border-color:var(--border-focus); box-shadow:0 0 0 3px var(--brand-glow); }
.form-row textarea { resize:vertical; min-height:80px; }
.form-row .form-hint { font-size:11px; color:var(--text-dim); margin-top:4px; }
.form-actions { display:flex; gap:10px; justify-content:flex-end; margin-top:20px; }
.btn-primary {
  display:inline-flex; align-items:center; gap:6px;
  padding:10px 22px; font-size:13px; font-weight:700; font-family:inherit;
  background:linear-gradient(135deg, var(--brand), var(--brand-light));
  color:white; border:none; border-radius:var(--radius-xs); cursor:pointer;
  transition:all var(--transition); line-height:1;
}
.btn-primary svg { width:16px; height:16px; flex-shrink:0; }
.btn-primary:hover { transform:translateY(-1px); box-shadow:0 4px 16px var(--brand-glow); }
.btn-primary:disabled { opacity:0.5; cursor:not-allowed; transform:none; }
.btn-secondary {
  display:inline-flex; align-items:center; gap:6px;
  padding:10px 22px; font-size:13px; font-weight:600; font-family:inherit;
  background:transparent; color:var(--text-secondary);
  border:1px solid var(--border); border-radius:var(--radius-xs); cursor:pointer;
  transition:all var(--transition); line-height:1;
}
.btn-secondary svg { width:16px; height:16px; flex-shrink:0; }
.btn-secondary:hover { background:rgba(0,0,0,0.03); }
.btn-danger {
  display:inline-flex; align-items:center; gap:6px;
  padding:10px 22px; font-size:13px; font-weight:700; font-family:inherit;
  background:var(--red); color:white; border:none;
  border-radius:var(--radius-xs); cursor:pointer; transition:all var(--transition); line-height:1;
}
.btn-danger svg { width:16px; height:16px; flex-shrink:0; }
.btn-danger:hover { opacity:0.9; }
.btn-sm { padding:6px 14px; font-size:12px; }

/* ═══════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATION
   ═══════════════════════════════════════════════════════════════════════ */
.toast {
  position:fixed; bottom:24px; right:24px; z-index:200;
  padding:14px 22px; border-radius:var(--radius-sm);
  font-size:13px; font-weight:600; color:white;
  box-shadow:0 8px 32px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
}
.toast.success { background:var(--green); }
.toast.error { background:var(--red); }
.toast.info { background:var(--brand); }
@keyframes toastIn { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(16px); } }

/* ═══════════════════════════════════════════════════════════════════════
   SETTINGS TABS
   ═══════════════════════════════════════════════════════════════════════ */
/* width:fit-content so the control hugs its tabs. Without it the .settings-tab
   flex:1 below stretches four tabs across the full page width, which on a wide
   monitor turns the active pill into a ~470px slab floating in empty space. */
/* Both bars (#settings-tabs, #sysinfo-tabs) span the content area. `width` is
   left at its default rather than set to 100%: this is a block-level flex
   container, so it already fills its parent, and `width:100%` would fight the
   padding on a border-box change later. The width:fit-content added in 31e3c59
   is gone — with `.settings-tab { flex:1 }` the tabs share the full bar evenly,
   which is what both bars want. */
.settings-tabs { display:flex; max-width:100%; gap:4px; margin-bottom:24px; background:var(--bg-input); border-radius:var(--radius-sm); padding:4px; flex-wrap:wrap; }
.settings-tab {
  flex:1; padding:10px 16px; font-size:13px; font-weight:600; font-family:inherit;
  background:transparent; border:none; border-radius:var(--radius-xs);
  color:var(--text-muted); cursor:pointer; transition:all var(--transition);
  display:inline-flex; align-items:center; justify-content:center; gap:6px; line-height:1;
  /* `flex:1` is flex-basis:0, so tabs are sized as EQUAL columns rather than by
     their labels — a column can end up narrower than its own text. At four tabs
     that was invisible; a fifth split the bar five ways and wrapped the two
     longest labels onto a second line, which line-height:1 then collided.
     nowrap raises each tab's min-content width to its full label, and flex
     items floor at min-width:auto, so no tab can be squeezed below its text. */
  white-space:nowrap;
}
.settings-tab svg { width:16px; height:16px; flex-shrink:0; }
.settings-tab:hover { color:var(--text); }
.settings-tab.active { background:var(--bg-card); color:var(--brand); box-shadow:0 1px 4px rgba(0,0,0,0.06); }
.settings-panel { display:none; }
.settings-panel.active { display:block; animation:fadeUp 0.3s ease-out; }

/* ═══════════════════════════════════════════════════════════════════════
   PROFILE CARD
   ═══════════════════════════════════════════════════════════════════════ */
.profile-header {
  display:flex; align-items:center; gap:20px; padding:24px;
  border-bottom:1px solid var(--border);
}
.profile-avatar-lg {
  width:64px; height:64px; border-radius:50%;
  background:linear-gradient(135deg, var(--brand), var(--brand-light));
  display:flex; align-items:center; justify-content:center;
  font-size:24px; font-weight:800; color:white; flex-shrink:0;
}
.profile-info h3 { font-size:18px; font-weight:700; margin-bottom:2px; }
.profile-info p { font-size:13px; color:var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════
   NOTIFICATION ACTIONS
   ═══════════════════════════════════════════════════════════════════════ */
/* flex:1 1 auto is load-bearing. As a plain shrink-to-fit flex item this box sized
   itself to a WRAPPED layout (482px) even with ~1030px of free space beside the
   title, dropping Export onto a second line. Claiming the free space lets all four
   controls sit on one row; justify-content keeps them right-aligned once they have
   it. flex-wrap stays so they still stack below ~820px.

   Deliberately NOT setting align-items: the default stretch is what equalises the
   controls (the button is 26px on its own, the inputs 32px). A fixed height would
   do it too but clips descenders — see the note above .filter-select--sm. */
.notif-actions {
  display:flex; gap:8px; flex-wrap:wrap;
  flex:1 1 auto; justify-content:flex-end;
}
.notif-actions .btn-sm { white-space:nowrap; }
.activity-item-enhanced {
  display:flex; gap:14px; padding:16px 20px; border-bottom:1px solid var(--border);
  transition: background var(--transition); position:relative;
}
.activity-item-enhanced:last-child { border-bottom:none; }
.activity-item-enhanced:hover { background:rgba(0,0,0,0.015); }
.activity-item-enhanced.unread { background:rgba(25,81,159,0.03); }
.activity-item-enhanced.unread .activity-dot { box-shadow:0 0 0 3px var(--brand-glow); }
.activity-badge {
  position:absolute; top:12px; right:16px;
  padding:2px 8px; border-radius:12px; font-size:10px; font-weight:600;
  text-transform:uppercase; letter-spacing:0.3px;
}

/* ── Notification detail ─────────────────────────────────────────────
   Colours come from the :root palette at the top of this file. There is no
   --bg-hover and no --text-primary token in this project (the text token is
   plain --text), so the hover tints below are literals in the same family as
   the existing .activity-item-enhanced:hover rule rather than a var() with a
   fallback that could never be overridden. */
.activity-item-enhanced.is-clickable { cursor:pointer; }
.activity-item-enhanced.is-clickable:hover { background:rgba(0,0,0,0.03); }
.activity-item-enhanced.is-clickable:focus-visible { outline:2px solid var(--brand); outline-offset:-2px; }
.notif-dropdown-item.is-clickable { cursor:pointer; }
/* Stronger than the base .notif-dropdown-item:hover (0.02) so a row that DOES
   something is visibly distinct from one that is only being passed over. */
.notif-dropdown-item.is-clickable:hover { background:rgba(25,81,159,0.05); }
.notif-dropdown-item.is-clickable:focus-visible { outline:2px solid var(--brand); outline-offset:-2px; }
.notif-detail-head { padding-bottom:14px; margin-bottom:14px; border-bottom:1px solid var(--border); }
.notif-detail-title { font-size:16px; font-weight:600; color:var(--text); }
.notif-detail-body { font-size:13px; color:var(--text-muted); margin-top:6px; line-height:1.5; }
.notif-jump { color:var(--brand); text-decoration:none; font-weight:500; }
.notif-jump:hover { text-decoration:underline; }
.notif-payload { margin-top:14px; }
.notif-payload summary { cursor:pointer; font-size:12px; color:var(--text-dim); user-select:none; }
.notif-payload pre {
  margin-top:8px; padding:12px; border-radius:var(--radius-xs); background:var(--bg-input);
  font-size:11px; line-height:1.5; overflow-x:auto; max-height:240px; color:var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════
   TABLE ACTION BUTTONS (CRUD)
   ═══════════════════════════════════════════════════════════════════════ */
.action-btn-group { display:flex; gap:4px; justify-content:flex-end; }
.action-btn {
  width:32px; height:32px; border-radius:10px; border:none;
  background:transparent; cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center;
  transition:all 0.2s ease; color:var(--text-dim);
}
.action-btn svg { width:15px; height:15px; }
.action-btn:hover { transform:scale(1.1); }
.action-btn.view-btn:hover { background:rgba(25,81,159,0.1); color:var(--brand); }
.action-btn.edit-btn:hover { background:rgba(245,158,11,0.12); color:#F59E0B; }
.action-btn.delete-btn:hover { background:var(--red-bg); color:var(--red); }
.action-btn:active { transform:scale(0.95); }

/* ── Modal Form Layout ───────────────────────────────────────────────── */
.modal-form { display:flex; flex-direction:column; gap:14px; }
.modal-form-row { display:flex; flex-direction:column; gap:4px; }
.modal-form-row label {
  font-size:11px; font-weight:600; color:var(--text-dim);
  text-transform:uppercase; letter-spacing:0.5px;
}
.modal-form-row input,
.modal-form-row select,
.modal-form-row textarea {
  width:100%; padding:10px 14px; font-size:13px; font-family:inherit;
  background:var(--bg-input); border:1px solid var(--border); border-radius:12px;
  color:var(--text); outline:none; transition:all 0.2s ease;
}
.modal-form-row select {
  padding-right:36px; cursor:pointer;
  appearance:none; -webkit-appearance:none;
  background-image:var(--select-chevron);
  background-repeat:no-repeat;
  background-position:right 12px center;
}
.modal-form-row input:focus,
.modal-form-row select:focus,
.modal-form-row textarea:focus {
  border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-glow);
}
.modal-form-row textarea { resize:vertical; min-height:72px; }
.modal-form-row .form-hint { font-size:10px; color:var(--text-dim); margin-top:2px; }
.modal-form-actions {
  display:flex; gap:10px; justify-content:flex-end; margin-top:8px; padding-top:14px;
  border-top:1px solid var(--border);
}
/* Same geometry as the Settings "Save Changes" button, matching
   .delete-confirm-actions. The min-width stops a one-word label ("Save") from
   shrink-wrapping to half the width of the Cancel beside it. */
.modal-form-actions button { min-width:130px; justify-content:center; }

/* Icon picker for the category modals. Was an inline repeat(8,1fr), which put
   the last two chips at x=367..462 in a 360px viewport — off screen, and
   unfixable from a stylesheet because inline wins. auto-fit lets the count
   fall to whatever the width allows. */
#cat-icon-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(40px, 1fr)); gap:6px; }
.modal-form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }

/* ── Detail View Modal ───────────────────────────────────────────────── */
.detail-view { display:flex; flex-direction:column; gap:0; }
.detail-view-row {
  display:flex; justify-content:space-between; align-items:flex-start;
  padding:10px 0; border-bottom:1px solid rgba(0,0,0,0.04);
}
.detail-view-row:last-child { border-bottom:none; }
.detail-view-label { font-size:12px; font-weight:600; color:var(--text-dim); text-transform:uppercase; letter-spacing:0.3px; min-width:100px; }
.detail-view-value { font-size:13px; font-weight:500; color:var(--text); text-align:right; word-break:break-all; max-width:300px; }

/* A row whose content is a BLOCK, not a value: label above, content full width.
   The default row is flex/space-between with the value right-aligned and capped
   at 300px, which is correct for "Expense" and wrong for a grid of thumbnails —
   those ended up in a narrow column stranded mid-modal. */
.detail-view-row-stacked { flex-direction:column; align-items:stretch; gap:8px; }
.detail-view-row-stacked .detail-view-value {
  max-width:none; width:100%; text-align:left;
}

/* ── Delete Confirmation ─────────────────────────────────────────────── */
.delete-confirm-body { text-align:center; padding:8px 0; }
.delete-confirm-body .delete-icon {
  width:56px; height:56px; border-radius:50%; margin:0 auto 16px;
  background:var(--red-bg); display:flex; align-items:center; justify-content:center;
  color:var(--red);
}
.delete-confirm-body .delete-icon svg { width:28px; height:28px; }
.delete-confirm-body h4 { font-size:16px; font-weight:700; margin-bottom:8px; }
.delete-confirm-body p { font-size:13px; color:var(--text-muted); line-height:1.5; margin-bottom:20px; }
/* Which account is being acted on — sits between the question and the
   consequence, so it must not carry the 20px gap the consequence does. */
.delete-confirm-body .delete-confirm-target {
  font-size:13px; font-weight:600; color:var(--text);
  margin-bottom:10px; word-break:break-all;
}
.delete-confirm-body p:last-of-type { margin-bottom:24px; }
/* Consequence of THIS delete, filled in after the modal opens. Deliberately
   plain text rather than an alert box: it is a fact about what will happen,
   not a scolding, and the boxed warning that used to sit here read as one.
   :empty keeps it from reserving space while the lookup is in flight or when
   the user owns nothing. */
.delete-confirm-note {
  font-size:12px; color:var(--text-dim); line-height:1.5;
  margin:-10px 0 20px; padding:0 4px;
}
.delete-confirm-note:empty { display:none; }
/* Same geometry as the Settings "Save Changes" button (.btn-primary); the
   min-width keeps a two-word label from shrink-wrapping next to Cancel. */
.delete-confirm-actions { display:flex; gap:10px; justify-content:center; }
.delete-confirm-actions button { min-width:130px; justify-content:center; }

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.section-toolbar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.section-toolbar .btn-sm { white-space:nowrap; }

/* ── Badge for editor role ───────────────────────────────────────────── */
.badge-editor { background:rgba(6,182,212,0.12); color:#06B6D4; }
.badge-inactive { background:rgba(100,116,139,0.12); color:#94A3B8; }
.badge-removed { background:var(--red-bg); color:var(--red); }
.badge-cancelled { background:rgba(100,116,139,0.12); color:#94A3B8; }

/* ── Pagination (Transactions) ───────────────────────────────────────── */
.pager {
  display:flex; align-items:center; justify-content:space-between;
  gap:16px; flex-wrap:wrap;
  padding:14px 20px; border-top:1px solid var(--border);
}
.pager-info { font-size:12px; color:var(--text-dim); white-space:nowrap; }
.pager-controls { display:flex; align-items:center; gap:4px; flex-wrap:wrap; }
.pager-btn {
  min-width:32px; height:32px; padding:0 10px;
  border:1px solid var(--border); border-radius:8px;
  background:var(--bg-card); color:var(--text);
  font-size:12px; font-weight:600; cursor:pointer;
  transition:background .15s, border-color .15s, color .15s;
}
.pager-btn:hover:not(:disabled):not(.is-active) { background:var(--bg-card-hover); border-color:var(--border-focus); }
.pager-btn:disabled { opacity:.4; cursor:not-allowed; }
.pager-btn.is-active { background:var(--brand); border-color:var(--brand); color:#fff; cursor:default; }
.pager-gap { padding:0 4px; color:var(--text-dim); font-size:12px; }
.pager-size { display:flex; align-items:center; gap:8px; }
.pager-size label { font-size:12px; color:var(--text-dim); }
.pager-size .filter-select {
  height:32px; padding:0 26px 0 10px; font-size:12px;
  background-position:right 9px center;
}
@media (max-width:640px) {
  .pager { justify-content:center; }
  .pager-info { width:100%; text-align:center; }
}

/* Transfer / reversal markers on the transaction ledger */
.badge-linked   { background:var(--brand-glow); color:var(--brand); }
.badge-reversed { background:rgba(100,116,139,0.12); color:#64748B; }

/* Receipt-count badge on a ledger row (G-4). Uses the existing green pair, the
   same as .badge-in / .badge-active. */
.badge-receipt { background:var(--green-bg); color:var(--green); }

/* Receipt grid in the transaction detail modal (G-4b).
   auto-fill with a minmax track rather than a fixed column count: the modal is
   a bottom sheet below 700px, so a hardcoded 3-up would overflow it. */
.receipt-grid {
  display:grid; gap:8px; margin-top:6px; width:100%;
  grid-template-columns:repeat(auto-fill, minmax(96px, 1fr));
}
.receipt-grid-status {
  grid-column:1 / -1; font-size:12px; color:var(--text-muted); padding:6px 0;
}
.receipt-grid-error { color:var(--red); }

.receipt-tile {
  display:flex; align-items:center; justify-content:center; position:relative;
  aspect-ratio:1; overflow:hidden; text-decoration:none;
  border:1px solid var(--border); border-radius:var(--radius-xs);
  background:var(--bg-input); transition:border-color var(--transition);
}
.receipt-tile:hover { border-color:var(--brand); }
/* cover, not contain: a receipt photo is usually portrait and the tile is
   square, so contain would leave most of the tile empty. The full image is one
   click away, so a cropped preview loses nothing. */
.receipt-tile img { width:100%; height:100%; object-fit:cover; display:block; }

.receipt-tile-kind {
  font-size:12px; font-weight:700; letter-spacing:0.04em; color:var(--brand);
}
.receipt-tile-pdf, .receipt-tile-failed {
  flex-direction:column; gap:4px; padding:8px; text-align:center;
}
.receipt-tile-label { font-size:10px; color:var(--text-muted); line-height:1.3; }
.receipt-tile-failed { border-style:dashed; }
.receipt-tile-failed .receipt-tile-kind { color:var(--red); }

/* Collapsed raw ids at the foot of a detail modal. Present for the admin who
   needs to paste a uuid into a query, absent for everyone else. */
.detail-ids { margin-top:2px; }
.detail-ids summary {
  cursor:pointer; font-size:12px; color:var(--text-muted); user-select:none;
}
.detail-ids summary:hover { color:var(--brand); }
.detail-id-row {
  display:flex; gap:10px; align-items:baseline; justify-content:flex-end;
  flex-wrap:wrap; margin-top:6px; font-size:11px;
}
.detail-id-row span { color:var(--text-muted); }
.detail-id-row code {
  font-family:ui-monospace, SFMono-Regular, Menlo, monospace;
  color:var(--text-secondary); word-break:break-all;
}

/* Boot splash — covers the async session check so the login card never flashes */
.boot-splash {
  position:fixed; inset:0; z-index:9999;
  display:flex; align-items:center; justify-content:center;
  background:var(--bg);
}

/* Overview currency scope — money is never summed across currencies */
.currency-scope {
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  margin-bottom:16px; padding:10px 14px;
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-xs);
}
.currency-scope-label { font-size:12px; font-weight:600; color:var(--text-secondary); }
.currency-scope .filter-select {
  height:32px; padding:0 26px 0 10px; font-size:12px;
  background-position:right 9px center;
}
.currency-scope-hint { font-size:11px; color:var(--text-dim); }
.badge-deleted { background:var(--red-bg); color:var(--red); }

/* Activity type breakdown chips */
.type-strip { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.type-chip {
  display:inline-flex; align-items:center; gap:6px;
  padding:6px 12px; border:1px solid var(--border); border-radius:999px;
  background:var(--bg-card); color:var(--text-secondary);
  font-size:12px; font-weight:600; font-family:inherit; cursor:pointer;
  transition:border-color .15s, background .15s, color .15s;
}
.type-chip:hover { border-color:var(--border-focus); background:var(--bg-card-hover); }
.type-chip.is-active { background:var(--brand); border-color:var(--brand); color:#fff; }
.type-chip-count { opacity:.65; font-weight:500; }
.type-chip-unread {
  padding:1px 7px; border-radius:999px;
  background:var(--red-bg); color:var(--red); font-size:10px; font-weight:700;
}
.type-chip.is-active .type-chip-count { opacity:.85; }

/* Compact select. Shrinks padding with the font instead of forcing a height —
   a fixed height on top of .filter-select's 9px padding leaves ~12px of box for
   a 12px font, which clips descenders (the y/p in "All Types"). */
.filter-select--sm {
  padding:6px 28px 6px 10px;
  font-size:12px;
  line-height:1.5;
  height:auto;
  background-position:right 10px center;
}

/* Compact search input for card headers (Activity feed) */
.filter-input--sm {
  padding:6px 10px; font-size:12px; line-height:1.5;
  flex:0 1 260px; min-width:200px; max-width:300px;
}

/* ═══ Admin & Access ═══════════════════════════════════════════════════
   Only two new components: the role radio-cards and the permission matrix.
   The roster table, stat cards, tabs, modal chrome and badges are all
   existing classes — a new section should read as part of the product, not
   as a bolt-on. Task 4's modal is what consumes everything below. */

.role-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.role-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px; text-align: left; cursor: pointer;
  background: var(--bg-input);
  /* Transparent rather than absent, so selecting a card does not add 1.5px of
     box and nudge the whole grid. */
  border: 1.5px solid transparent;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.role-card:hover { background: var(--bg-card-hover); }
.role-card.is-selected {
  background: var(--bg-card);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.role-card-name { font-size: 13px; font-weight: 600; color: var(--text); }
.role-card-blurb { font-size: 11px; color: var(--text-muted); line-height: 1.35; }

.perm-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-muted);
}
.perm-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px;
}
.perm-drift { font-size: 11px; color: var(--text-dim); }
.perm-note {
  font-size: 12px; color: var(--text-secondary);
  background: var(--bg-input); border-radius: var(--radius-xs);
  padding: 10px 12px; margin-bottom: 16px;
}

.perm-group { margin-bottom: 14px; }
.perm-group-label {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  padding-bottom: 6px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 16px;
}
.perm-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer;
  padding: 5px 6px; border-radius: 8px;
  transition: var(--transition);
}
.perm-item:hover { background: var(--bg-card-hover); }
.perm-item input { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; }

/* Locked rows stay VISIBLE. Hiding a permission an operator cannot grant makes
   them think it is missing; showing it disabled teaches the rule. */
.perm-item.is-locked { cursor: not-allowed; color: var(--text-dim); }
.perm-item.is-locked:hover { background: transparent; }
.perm-item.is-locked input { cursor: not-allowed; }
/* nowrap on the REASON, so the permission's own label is what wraps in a narrow
   column. A two-line "Super Admin / only" pill reads as a rendering accident;
   a wrapped label reads as a long label. */
.perm-locked-note {
  margin-left: auto; font-size: 10px; color: var(--text-dim);
  background: var(--bg-input); border-radius: 6px; padding: 2px 6px;
  white-space: nowrap; flex-shrink: 0;
}

/* The matrix is the tallest thing any modal here shows; scroll it internally
   rather than the page, so the role cards above and the action buttons below
   stay reachable.
   34vh, measured rather than guessed: at 46vh on a 900px-tall viewport the
   identity block, the role cards and the matrix together pushed Cancel/Save
   past the card's own 85vh ceiling, so the buttons needed a second scroll —
   which is the exact thing this rule exists to prevent. */
#access-matrix { max-height: 34vh; overflow-y: auto; padding-right: 4px; }

/* The matrix needs more room than a confirm dialog does. Scoped with :has() so
   the width applies only while THIS modal is open — .modal-card is a single
   shared element that every modal in the app reuses, so setting its width
   imperatively would leak into whichever dialog opened next. */
.modal-card:has(#access-matrix) { max-width: 760px; }

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════
   Design docs/2026-08-17-responsive-admin-dashboard-design.md §3.

   TWO boundaries, and they are LITERAL on purpose. A custom property does not
   work in a media query condition: `@media (max-width: var(--bp-md))` parses
   without error and then never matches, silently. Do not tidy these into tokens.

       Desktop   >= 900px    fixed sidebar, real tables, centred modals
       Tablet    700-899px   drawer nav, tables scroll, 2-col grids
       Phone     <  700px    drawer nav, card-stack tables, sheet modals

   Overrides are written max-width:899px and max-width:699px.

   `overflow-x:hidden` was removed from `body` here. It did not make anything
   fit — it cut off whatever stuck out, which is why 250px of overflow across
   60 elements went unnoticed. Putting it back would hide the next regression
   the same way. Fix the offending element instead; `tool/responsive-probe.js`
   will name it.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Drawer navigation (< 900px) ─────────────────────────────────────── */

/* The toggle is desktop-hidden, not mobile-shown, so it cannot leak onto a
   wide screen if a later rule reorders. */
.nav-toggle {
  display:none; align-items:center; justify-content:center;
  width:40px; height:40px; flex-shrink:0;
  border:1px solid var(--border); border-radius:var(--radius-xs);
  background:var(--bg-card); color:var(--text-secondary);
  cursor:pointer; transition:all var(--transition);
}
.nav-toggle:hover { background:var(--bg-card-hover); color:var(--text); }
.nav-toggle:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }

.nav-backdrop {
  position:fixed; inset:0; z-index:50;
  background:rgba(0,0,0,0.45);
  backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px);
  opacity:0; transition:opacity .28s ease;
}
.nav-backdrop.is-visible { opacity:1; }

@media (max-width:899px) {
  .nav-toggle { display:inline-flex; }

  .sidebar {
    /* Was display:none, which is why no nav existed on a phone at all. */
    display:flex;
    width:min(280px, 84vw);
    /* z-index MUST beat .main-header's 30, or the drawer slides in UNDERNEATH
       the sticky header and loses its top ~70px. The sidebar's base z-index is
       10, which is correct only while it is a static column. */
    z-index:60;
    transform:translateX(-100%);
    transition:transform .28s cubic-bezier(.4,0,.2,1);
    /* 13 items do not fit a short phone in landscape. */
    overflow-y:auto;
  }
  .sidebar.is-open { transform:none; box-shadow:0 0 60px rgba(0,0,0,0.25); }

  .main-content { margin-left:0; }
}

@media (prefers-reduced-motion:reduce) {
  .sidebar, .nav-backdrop { transition:none; }
}

/* ── Header reflow ───────────────────────────────────────────────────── */

@media (max-width:899px) {
  .main-header { padding:14px 16px; flex-wrap:wrap; gap:12px; }
  /* Search onto its own row. order:10 puts it after the actions in visual
     order while leaving it before them in the DOM for tab order. */
  .header-center { order:10; flex-basis:100%; max-width:100%; margin:0; }
  .header-left { flex:1; min-width:0; }
  .page-title { font-size:19px; }
  .header-divider { display:none; }
  .header-user .sidebar-user-info { display:none; }
  .header-user { padding:4px; border-radius:50%; }
}

@media (max-width:699px) {
  /* No .content-area rule here — Task 3's clamp() already reaches its 12px
     minimum by this width. */
  .page-subtitle { display:none; }

  /* ── Header collision fix ───────────────────────────────────────────
     Measured at 360px BEFORE this block: .header-actions took 249px of the
     328px content box, leaving .header-left just 15px for a title needing 86px.
     With overflow:visible the title text rendered OUTSIDE its box and landed
     underneath the notification bell.

     The overflow probe cannot catch this — overlapping boxes do not overflow,
     so every geometric assertion passed on a visibly broken header. Only the
     screenshot showed it.

     Three changes buy the title its 86px back: */
  .main-header { padding:12px; gap:8px; }
  /* Decorative status; its 55px is what the page title needs on a 360px header.
     Realtime still runs — only the badge is hidden. No !important now that the
     element's layout comes from .realtime-indicator instead of an inline style. */
  .realtime-indicator { display:none; }
  /* Truncate, never spill. Required regardless of the space won above, because
     "Transactions" and "Admin & Access" cannot fit any phone header. */
  .page-title { font-size:17px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  /* The drawer already gives a phone a way to reach everything, and global
     search costs a full row it cannot spare. It stays reachable via "/" and
     returns at >=700px. */
  .header-center { display:none; }
  /* No !important needed since the column counts moved to .stats-grid--3/--4
     (see the base rules). Same specificity, and this block is later in the
     file, so source order decides. */
  .stats-grid { grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:12px; }
  .stat-card { padding:16px; }
  .stat-value { font-size:clamp(20px, 6vw, 28px); }
}

/* ── Table scrolling (>= 700px) ──────────────────────────────────────────
   Below 700px tables become card stacks instead — see the next block.

   The <table> is its own scroll container. Verified that header and body
   columns stay aligned under display:block: the anonymous table box preserves
   the formatting context, so thead and tbody are still laid out by one
   algorithm. A wrapper div would mean editing 20 render sites for no gain.

   This is NOT phone-only. The Users table is 1034px inside a 970px card at
   1280px, and .section-card's overflow:hidden was clipping the Actions column
   with no scrollbar to suggest anything was missing. */
/* The scroll container is a WRAPPER, not the table itself.
   js/core/table-cards.js inserts [data-table-scroll] around each .data-table.

   The obvious shortcut — `display:block; overflow-x:auto` on the <table> — is
   wrong, and its failure only shows when there is SPARE room, which is why it
   passed every phone and 1280px test. `display:block` makes the table a
   full-width block, but thead/tbody are not valid block children, so CSS wraps
   them in an ANONYMOUS TABLE BOX, and an anonymous table is width:auto —
   shrink-to-fit. Measured on Books at 1920px: the block was 1608px while its
   thead/tbody were 752px, so the table drew in the left half of a 1610px card
   and left 856px empty.

   Keeping the table a real table means its own width:100% applies and the
   columns spread across the card; the wrapper supplies the scrolling when the
   content genuinely does not fit. Verified at 1920px: content right edge goes
   from 1025 to 1881, columns stay aligned, and a constrained wrapper still
   scrolls. */
[data-table-scroll] {
  max-width:100%;
  overflow-x:auto;
  /* Momentum scrolling on touch laptops and iPads. */
  -webkit-overflow-scrolling:touch;
}

/* Below 700px the rows are card-stacked and nothing needs to scroll sideways.
   This is not cosmetic: overflow-x:auto makes an element a scroll container,
   and tool/responsive-probe.js exempts everything inside one — leaving it on
   would blanket-exempt every card stack from overflow checking. */
@media (max-width:699px) {
  [data-table-scroll] { overflow-x:visible; }
}

/* ── Column proportions (>= 700px) ───────────────────────────────────────
   Once the table fills its card, `table-layout:auto` hands the surplus width
   to whichever column has the widest content — which is always the description.
   Measured on Transactions at 1920px: Description took 914px (57% of the
   table) while Category, Book and Date were squeezed into three wrapped lines
   each at 144/129/100px.

   Two rules fix it, and both are needed:

   nowrap stops the short columns wrapping, so each claims its natural
   single-line width instead of being compressed into a column of stacked
   words. .text-primary is the description-style cell (books, invites, members,
   transactions, workspaces, activity, settings, systeminfo all mark one) and
   stays wrappable, since it is the one column with genuinely long text.

   max-width is a HINT here, not a hard cap — auto layout uses it when
   computing preferred widths, then still distributes slack. That is the
   desired behaviour: the column grows on a wide screen but stops dominating.
   Measured effect at 1920px — Description 914 -> 511 (57% -> 32%), Category
   144 -> 242, Book 129 -> 202, Date 100 -> 166.

   table-layout:fixed was the obvious alternative and is worse: with no
   per-column widths it splits evenly, giving the Type badge the same 230px as
   the description. */
@media (min-width:700px) {
  .data-table th, .data-table td { white-space:nowrap; }
  .data-table td.text-primary { white-space:normal; max-width:360px; }
}

/* ── Table card stack (< 700px) ──────────────────────────────────────────
   Each row becomes a labelled card. Labels come from data-label, stamped by
   js/core/table-cards.js from the live <thead>.

   The header row is NOT display:none. Hiding it would silently remove
   click-to-sort on phones, and those <th class="th-sort"> elements already
   carry the listeners bound by core/table-sort.js. Restyling them as a
   scrolling chip row keeps sorting working with zero new JavaScript. */
@media (max-width:699px) {
  .data-table, .data-table tbody, .data-table tr, .data-table td { display:block; width:auto; }

  /* Header becomes a horizontal row of sort chips. */
  .data-table thead { display:block; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .data-table thead tr { display:flex; gap:6px; padding:8px 10px; }
  .data-table th {
    flex:0 0 auto; border:none; padding:6px 12px; border-radius:20px;
    background:var(--bg); color:var(--text-dim); white-space:nowrap;
    font-size:11px; letter-spacing:0.4px;
  }
  .data-table th.th-sort.is-sorted { background:var(--brand-glow); color:var(--brand); }
  /* Non-sortable headers (key:null — "Actions") are not clickable, so a chip
     for them would be a control that does nothing. */
  .data-table th:not(.th-sort) { display:none; }

  .data-table tr {
    margin:10px; padding:4px 0; border:1px solid var(--border);
    border-radius:var(--radius-xs); background:var(--bg-card);
  }
  .data-table tr:hover td, .data-table tr.is-clickable:hover td { background:transparent; }

  .data-table td {
    display:grid; grid-template-columns:minmax(84px, 38%) 1fr; gap:12px;
    padding:8px 12px; border:none; align-items:start;
    font-size:13px; word-break:break-word;
  }
  .data-table td + td { border-top:1px solid var(--border); }
  /* A grid item fills its track by default, which stretched every status pill
     across the whole value column. align-items:start above governs the BLOCK
     axis; this is the inline one. */
  .data-table td > .badge,
  .data-table td > .activity-badge,
  .data-table td > .currency-pill { justify-self:start; }
  .data-table td::before {
    content:attr(data-label);
    font-size:10.5px; font-weight:600; letter-spacing:0.4px;
    text-transform:uppercase; color:var(--text-dim); padding-top:2px;
  }
  /* The empty/loading row is a single colspan cell with no label. */
  .data-table td[colspan]:not([data-label]) { display:block; text-align:center; }
  .data-table td[colspan]:not([data-label])::before { content:none; }

  /* Actions stay a row of buttons, not a stacked column. */
  .data-table .action-btn-group { display:flex; gap:8px; flex-wrap:wrap; }
  .data-table .action-btn { width:36px; height:36px; }   /* >= 36px tap target */
}

/* ── Modal sheets (< 700px) ──────────────────────────────────────────────
   One rule covers all 14 openModal() call sites: they share #modal-card. */
@media (max-width:699px) {
  .modal-overlay { align-items:flex-end; }
  .modal-card {
    width:100%; max-width:none;
    /* dvh, not vh. vh is the LARGEST viewport height, so with the iOS URL bar
       showing, a 92vh sheet has its footer under the browser chrome and the
       submit button cannot be tapped. */
    max-height:92dvh;
    border-radius:24px 24px 0 0;
    animation:sheetUp .28s cubic-bezier(.4,0,.2,1);
  }
  @keyframes sheetUp { from { transform:translateY(100%); } to { transform:none; } }

  .modal-header { padding:16px 18px 12px; }
  .modal-title { font-size:16px; }
  .modal-body {
    padding:16px 18px;
    padding-bottom:calc(20px + env(safe-area-inset-bottom));
  }
  /* Two-up form rows collapse; the modal is 360px wide minus 36px of padding,
     so 1fr 1fr leaves ~155px per field. The class is .modal-form-grid — a
     rule written against .form-grid/.form-row-2 matches nothing here. */
  .modal-body .modal-form-grid { grid-template-columns:1fr; }
  /* iOS Safari auto-zooms the page when focusing an input under 16px, and the
     zoom is NOT undone on blur — the user is left on a zoomed page. */
  .modal-body input, .modal-body select, .modal-body textarea { font-size:16px; }

  /* .modal-form-actions is justify-content:flex-end with min-width:130px per
     button. Three buttons need 390px+ in a 316px body, and with flex-end and no
     wrap the FIRST one overflows leftward — "Reset to preset" measured at
     left:-85, entirely unpressable. Wrapping is what makes it reachable; the
     narrower min-width keeps two on a line where they fit. */
  .modal-form-actions { flex-wrap:wrap; justify-content:stretch; }
  .modal-form-actions button { min-width:0; flex:1 1 46%; }
}
@media (max-width:699px) and (prefers-reduced-motion:reduce) {
  .modal-card { animation:none; }
}

/* ── Filter bars and pagers (< 700px) ────────────────────────────────── */
@media (max-width:699px) {
  /* min-width:260px on a 336px content box leaves the selects nowhere to go. */
  .filters-bar { gap:8px; }
  .filter-input { min-width:0; flex:1 1 100%; }
  .filter-select { flex:1 1 calc(50% - 4px); min-width:0; }

  .section-card-header { padding:14px 14px; flex-wrap:wrap; gap:8px; }

  .pager { flex-wrap:wrap; gap:10px; justify-content:center; }
  .pager-info { width:100%; text-align:center; order:-1; }
  .pager-btn { min-width:36px; min-height:36px; }
}

/* ── Auth pages (login + recovery) ───────────────────────────────────────
   #login-page and #recovery-page share these classes, so this covers both. */

/* dvh, not vh. On iOS vh is the LARGEST viewport height, so with the URL bar
   showing a 100vh page is taller than the screen and the card drifts under the
   browser chrome. The padding is what gives the card a gutter — measured
   left:0 right:360 in a 360px viewport before this. */
.login-page { min-height:100dvh; padding:24px 16px; }

@media (max-width:699px) {
  .login-card { padding:28px 22px; max-width:none; }
  .login-title { font-size:20px; }
  /* iOS Safari zooms the page when focusing an input under 16px and does not
     undo it on blur, leaving the user stranded on a zoomed page. */
  .login-card input { font-size:16px; }
  .login-page { padding-bottom:calc(24px + env(safe-area-inset-bottom)); }
}

/* ── Notification panel (< 700px) ────────────────────────────────────────
   Was width:360px at right:-60px, which put its left edge at -32px in a 360px
   viewport — a third of the panel unreachable. Anchored to the viewport rather
   than to the bell, because there is no offset from a 40px button that fits a
   360px panel on a 360px screen. */
@media (max-width:699px) {
  .notif-dropdown {
    position:fixed;
    top:auto; bottom:0; left:0; right:0;
    width:auto; max-height:70dvh;
    border-radius:20px 20px 0 0;
    padding-bottom:env(safe-area-inset-bottom);
  }
  .notif-dropdown-list { max-height:none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   FIXED KPI ROWS + THE TALLY ROW-LIST
   ═══════════════════════════════════════════════════════════════════════
   The Transactions row used to render one card per currency, so its column
   count came from the DATA: six currencies plus the count and transfer
   cards made eight cards, the base auto-fit template fits seven at 1920px,
   and the eighth wrapped onto a line of its own. A seventh currency would
   have wrapped two. No width or gap tweak survives that -- the fix is that
   the per-currency figures now share ONE card, which pins the count at
   three. Only three counts are possible, so each gets a template.

   These live at the END of the file deliberately: .stats-grid rules inside
   the 768px and phone blocks above have identical specificity, so source
   order is what lets these win. Same reasoning as .stats-grid--3/--4. */
.stats-grid--kpi1 { grid-template-columns:minmax(200px,320px); }
.stats-grid--kpi2 { grid-template-columns:1fr 1.5fr; }
.stats-grid--kpi3 { grid-template-columns:1fr 1.5fr 1.1fr; }

/* ── The tally row-list ──────────────────────────────────────────────────
   A list of "label ... value(s)" lines inside one stat card. Its caller is
   the Transactions money card (currency, in, out, tx count). It is written
   as a primitive rather than as money-specific CSS because it exists to
   solve "N figures that cannot become N cards" -- the Members roles card
   used it until roles moved to a card each, which they can afford to do
   because a CHECK constraint bounds them and currencies are unbounded.

   THE GRID IS THE BLOCK, NOT THE ROW. .tally-row and .tally-group are
   display:contents, so every cell of every line is a direct grid item of
   .tally-rows and they all share ONE set of columns. Per-row grids were the
   first attempt and cannot do this: `auto` sizes per grid, so compact rows
   came out misaligned, and the `1fr` that fixed alignment flung the last
   value to the far edge of a 660px card. Sharing columns gives both.
   The wrappers still exist because the phone rule needs them back as real
   boxes in order to restack a pair. */
.stat-card--tally { display:flex; flex-direction:column; }
/* THE TRACK COUNT MUST EQUAL THE NUMBER OF CELLS ONE LINE CONTRIBUTES.
   Because the rows are display:contents there is nothing to contain a short
   line: with three tracks and two cells per line, the Members roles card laid
   out as "CONTRIBUTOR 8 ADMIN / 3 VIEWER 1" -- every label paired with the
   wrong count. Adding a variant means counting its cells first. */
.tally-rows {
  --tally-cols:auto 1fr;                   /* label · value(+slack) */
  display:grid; grid-template-columns:var(--tally-cols);
  column-gap:18px; row-gap:7px; align-items:baseline;
}
/* 4 cells: lead, the two amounts inside .tally-group, then the note. */
.tally-rows--pair { --tally-cols:44px auto auto 1fr; }
.tally-row, .tally-group { display:contents; }
.tally-lead {
  font-size:11px; font-weight:700; letter-spacing:0.4px;
  color:var(--text-muted); text-transform:uppercase;
}
/* display:contents generates no box, but the element stays in the tree for
   INHERITANCE -- which is the only reason these type styles reach the value
   spans inside a group. */
.tally-group, .tally-value { font-size:15px; font-weight:700; line-height:1.4; white-space:nowrap; }
/* start, not end: the note belongs to the cluster it describes.
   justify-self:end parked it against the card's right edge, a hundred-odd
   pixels away from the number it counts. */
.tally-note { font-size:11px; font-weight:500; color:var(--text-dim); white-space:nowrap; justify-self:start; }

/* The height cap. Rows beyond the first few are one click away, so twenty
   currencies render at the height of three. */
.tally-more { margin-top:9px; }
.tally-more > summary {
  cursor:pointer; list-style:none; font-size:11px; font-weight:600;
  color:var(--text-muted); padding:2px 0; user-select:none;
}
.tally-more > summary::-webkit-details-marker { display:none; }
.tally-more > summary::before { content:'\25B8'; display:inline-block; margin-right:5px; }
.tally-more[open] > summary::before { content:'\25BE'; }
.tally-more > summary:hover { color:var(--text-secondary); }
.tally-more .tally-rows { margin-top:7px; }
.stat-card--tally .stat-label { margin-top:auto; padding-top:12px; }

/* Two columns: the tally card takes the full width above the other two, so
   its rows never have to live in a third of the screen. */
@media (max-width:1099px) {
  .stats-grid--kpi1,
  .stats-grid--kpi2,
  .stats-grid--kpi3 { grid-template-columns:1fr 1fr; }
  .stats-grid--kpi .stat-card--tally { grid-column:1 / -1; order:-1; }
}

/* One column, and a PAIR restacks: at 360px the two amounts go one above the
   other and the per-currency count drops -- the amounts are what an admin
   reads there, and the count is still in the ledger below. A single-value
   tally (Members by role) needs none of this and keeps its shared columns. */
@media (max-width:699px) {
  .stats-grid--kpi1,
  .stats-grid--kpi2,
  .stats-grid--kpi3 { grid-template-columns:1fr; }
  .tally-rows--pair { display:block; }
  .tally-rows--pair .tally-row {
    display:grid; grid-template-columns:44px minmax(0,1fr);
    column-gap:10px; align-items:baseline;
  }
  .tally-rows--pair .tally-row + .tally-row { margin-top:7px; }
  .tally-rows--pair .tally-group { display:grid; grid-template-columns:1fr; }
  .tally-note { display:none; }
}
