/* ═══════════════════════════════════════════════════════════
   DAIS Practice Manager — stylesheet
   Extracted from index.html. Brand colours live in :root below.
   ═══════════════════════════════════════════════════════════ */

:root {
  --navy: #053D70;
  --navy-dark: #032850;
  --gold: #FFC000;
  --gold-light: #FFD84D;
  --slate: #1E293B;
  --slate-mid: #334155;
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-mid: #475569;
  --text-light: #94A3B8;
  --green: #16A34A;
  --green-bg: #DCFCE7;
  --amber: #D97706;
  --amber-bg: #FEF3C7;
  --red: #DC2626;
  --red-bg: #FEE2E2;
  --blue: #2563EB;
  --blue-bg: #DBEAFE;
  --sidebar-w: 240px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }
/* ── LARGE TEXT MODE — personal accessibility toggle, persisted per-device ──
   Desktop/tablet uses `zoom` to scale everything uniformly. Mobile (≤768px) gets
   its own tuned font/icon sizes further down — zoom behaves inconsistently with
   mobile's fixed bottom-sheet modals and bottom nav, so it's scoped out here. */
@media (min-width: 769px) {
  body.large-text { zoom: 1.15; }
}
#large-text-toggle-btn.active { background: var(--navy); color: #fff !important; border-color: var(--navy) !important; }

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s;
  overflow: hidden; /* logo and footer stay pinned; only nav-scroll-area scrolls */
}
.sidebar-logo {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.nav-scroll-area {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0; /* required for flex children to actually scroll instead of overflowing */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.nav-scroll-area::-webkit-scrollbar { width: 5px; }
.nav-scroll-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
.nav-scroll-area::-webkit-scrollbar-track { background: transparent; }
.logo-mark {
  /* DAIS Advisors mark — three nested triangles, from the firm's logo file.
     Inline data URI so the app stays a single self-contained HTML file with
     no external image request. */
  width: 36px; height: 36px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='274 853 825 824'%3E%3Cpath d='M274 1677 686.5 853 1099 1677 683.489 1117.59 274 1677Z' fill='%23FBCE2E'/%3E%3Cpath d='M372 1677 735 1017 1098 1677 732.35 1228.93 372 1677Z' fill='%23FBCE2E'/%3E%3Cpath d='M473 1677 786 1149 1099 1677 783.715 1318.54 473 1677Z' fill='%23FBCE2E'/%3E%3C/svg%3E") center/contain no-repeat;
  flex-shrink: 0;
}
.logo-text { color: #fff; }
.logo-text .firm { font-family: 'Poppins', sans-serif; font-size: 15px; font-weight: 700; letter-spacing: 0.5px; }
.logo-text .sub { font-size: 10px; color: rgba(255,255,255,0.5); letter-spacing: 1px; text-transform: uppercase; }

.nav-section { padding: 8px 0; }
.nav-label { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,255,255,0.35); padding: 8px 20px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 20px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  transition: all 0.15s;
  position: relative;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.07); }
.nav-item.active { color: var(--gold); background: rgba(255,192,0,0.1); }
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--gold); border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--navy);
}
.user-info { flex: 1; }
.user-name { font-size: 12px; font-weight: 600; color: #fff; }
.user-role { font-size: 10px; color: rgba(255,255,255,0.4); }

/* ── MAIN ── */
#main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── TOPBAR ── */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  gap: 12px;
}
.topbar-title { font-family: 'Poppins', sans-serif; font-size: 16px; font-weight: 600; color: var(--navy); flex: 1; }
.topbar-search {
  display: flex; align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px; gap: 8px;
  font-size: 13px; color: var(--text-mid);
  min-width: 240px;
}
.topbar-search input {
  border: none; background: transparent; font-size: 13px;
  color: var(--text); outline: none; flex: 1;
  font-family: 'Inter', sans-serif;
}
/* ── TOPBAR ACTIONS (New Assignment / A+ / Export / Sign Out) ── */
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-utility-row { display: flex; align-items: center; gap: 12px; }
.topbar-icon-btn { font-size: 13px; padding: 8px 14px; white-space: nowrap; }
.topbar-icon-btn.large-text-btn,
.topbar-icon-btn.export-btn { border-color: #053D70; color: #053D70; }
.topbar-icon-btn.signout-btn { border-color: #DC2626; color: #DC2626; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-mid); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── CONTENT ── */
#content { padding: 24px; flex: 1; }

/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }

/* ── STAT CARDS ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.green::after { background: var(--green); }
.stat-card.amber::after { background: var(--amber); }
.stat-card.red::after { background: var(--red); }
.stat-card.blue::after { background: var(--blue); }
.stat-card.purple::after { background: #8B5CF6; }
/* 6 units: four normal tiles (1 each) + Recurring Filings (2), which carries
   three rows of numbers and needs roughly double the width to stay on one line. */
.dashboard-stats-row { grid-template-columns: repeat(6, 1fr); }
.stat-card.stat-wide { grid-column: span 2; }
@media (max-width: 1100px) and (min-width: 769px) {
  .dashboard-stats-row { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .stat-card.stat-wide { grid-column: span 1; }
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-light); margin-bottom: 8px; }
.stat-value { font-family: 'Poppins', sans-serif; font-size: 32px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text-mid); margin-top: 6px; }
.stat-icon { position: absolute; top: 16px; right: 16px; font-size: 22px; opacity: 0.15; }

/* ── SECTION HEADERS ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; margin-top: 6px;
}
.section-title { font-size: 14px; font-weight: 700; color: var(--text); }
.section-sub { font-size: 12px; color: var(--text-mid); }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2.align-start { align-items: start; }
.grid-3.align-start { align-items: start; }
#dash-top-row { align-items: stretch; }
#dash-top-row > .card { display: flex; flex-direction: column; }
#dash-top-row > .card > .card-body { flex: 1; }
#dash-top-row > .card > .quick-actions-body { flex: 1; }
.quick-actions-body { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; height: 100%; }
.quick-actions-body .btn { width: 100%; justify-content: center; flex: 1; font-size: 14px; padding: 10px 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── CARD ── */
.card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text); flex: 1; }
.card-body { padding: 0; }

/* ── ASSIGNMENT TABLE ── */
.assign-table { width: 100%; border-collapse: collapse; }
.assign-table th {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-light); padding: 10px 16px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  text-align: left;
}
.assign-table td {
  padding: 11px 16px;
  font-size: 12px; color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.assign-table tr:last-child td { border-bottom: none; }
.assign-table tr:hover td { background: #f8fafc; }
.assign-table td.client { font-weight: 600; }
.assign-table td.id { font-family: monospace; font-size: 11px; color: var(--text-mid); }

/* ── COMPACT variant — for narrower dashboard cards (e.g. Recent Assignments)
   where the default padding/column balance leaves too little room for the
   Client column, forcing long names to wrap across multiple lines. ── */
.assign-table.compact { table-layout: fixed; }
.assign-table.compact th, .assign-table.compact td { padding: 9px 6px; }
.assign-table.compact td.id { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assign-table.compact th:nth-child(1), .assign-table.compact td:nth-child(1) { width: 9%; }
.assign-table.compact th:nth-child(2), .assign-table.compact td:nth-child(2) { width: 24%; }
.assign-table.compact th:nth-child(3), .assign-table.compact td:nth-child(3) { width: 30%; }
.assign-table.compact th:nth-child(4), .assign-table.compact td:nth-child(4) { width: 13%; }
.assign-table.compact th:nth-child(5), .assign-table.compact td:nth-child(5) { width: 24%; }
.assign-table.compact td.client { word-break: break-word; line-height: 1.3; }
.assign-table.compact td:nth-child(5) { text-align: center; }
.assign-table.compact td:nth-child(5) .badge { display: inline-block; white-space: normal; line-height: 1.25; text-align: center; padding: 4px 7px; max-width: 100%; }

/* ── STATUS BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 700;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: #F1F5F9; color: var(--text-mid); }
.badge-navy { background: #E0EAF5; color: var(--navy); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red { background: var(--red); animation: pulse-dot 1.5s infinite; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ── PROGRESS BAR ── */
.progress-wrap { background: var(--bg); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-green { background: var(--green); }
.progress-amber { background: var(--amber); }
.progress-navy { background: var(--navy); }

/* ── PRIORITY ── */
.priority { font-size: 10px; font-weight: 700; }
.priority-high { color: var(--red); }
.priority-medium { color: var(--amber); }
.priority-low { color: var(--green); }

/* ── WORKLOAD BAR ── */
.workload-row { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.workload-row:hover { background: #f8fafc; }
.workload-row:last-child { border-bottom: none; }
.staff-info { width: 90px; }
.staff-name { font-size: 12px; font-weight: 600; }
.remark-bell {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; font-family: 'Inter', sans-serif;
  border-radius: 999px; margin-left: 6px; cursor: pointer;
  vertical-align: middle; line-height: 1;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.6);
  animation: remark-glow 1.4s infinite;
}
@keyframes remark-glow {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.55); transform: scale(1); }
  70%  { box-shadow: 0 0 0 6px rgba(239,68,68,0); transform: scale(1.08); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); transform: scale(1); }
}
.staff-dept { font-size: 10px; color: var(--text-light); }
.workload-bar-wrap { flex: 1; }
.workload-count { font-size: 12px; font-weight: 700; width: 28px; text-align: right; color: var(--text-mid); }

/* ── FOLLOW-UP ── */
.followup-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.followup-item:last-child { border-bottom: none; }
.followup-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.followup-content { flex: 1; }
.followup-client { font-size: 12px; font-weight: 600; }
.followup-desc { font-size: 11px; color: var(--text-mid); margin-top: 2px; }
.followup-date { font-size: 10px; font-weight: 700; flex-shrink: 0; }

/* ── AGING TABLE ── */
.aging-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  border-bottom: 1px solid var(--border); transition: background 0.15s;
}
.aging-row:hover { background: #f8fafc; }
.aging-row:last-child { border-bottom: none; }
.aging-label { font-size: 12px; width: 90px; }
.aging-bar-wrap { flex: 1; }
.aging-count { font-size: 13px; font-weight: 700; width: 30px; text-align: right; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
/* WhatsApp-related modals must stack ABOVE the assignment detail modal */
#wa-asgupdate-modal, #wa-template-modal, #wa-linkdoc-modal, #notif-confirm-modal, #wa-docreq-modal, #wa-adddoc-modal, #wa-remark-modal { z-index: 600; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 640px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.modal-title { font-family: 'Poppins', sans-serif; font-size: 16px; font-weight: 700; flex: 1; }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; background: var(--bg);
  font-size: 16px; color: var(--text-mid);
}
.modal-body { padding: 20px 24px; }

/* ── KPI MODAL — category chips, collapsible filter row, quick-filter chips ──
   Desktop: all shown in full, matching the previous inline styles.
   Mobile overrides live in the phone media query below. */
.kpi-modal-catbar { flex:1; display:flex; flex-wrap:wrap; gap:6px; justify-content:center; align-items:center; padding:0 12px; }
.kpi-filter-bar-wrap { padding:12px 16px; border-bottom:1px solid var(--border); background:var(--bg); position:sticky; top:0; z-index:5; }
.kpi-filter-controls { display:flex; flex-wrap:wrap; gap:8px; }
.kpi-filter-toggle { display:none; } /* only needed as a collapse trigger on narrow screens */

/* ── Maximize / restore (⛶ button in every modal header) ──
   The modal fills the screen and its scrollable region stretches to match,
   instead of staying pinned to its original max-height. */
.modal-overlay.maximized > .modal {
  width: 98vw !important;
  max-width: 98vw !important;
  height: 96vh !important;
  max-height: 96vh !important;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-overlay.maximized > .modal > * { flex: 0 0 auto; }
.modal-overlay.maximized > .modal > [data-maxgrow] {
  flex: 1 1 auto !important;
  max-height: none !important;
  height: auto !important;
  overflow-y: auto !important;
}
.modal-maximize { font-size: 14px; }
/* Phones already show modals near-fullscreen, so the control would be pointless */
@media (max-width: 768px) { .modal-maximize { display: none !important; } }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── FORM ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-mid); }
.form-control {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--navy); }
select.form-control { background: #fff; cursor: pointer; }

/* ── STAGE TRACKER ── */
.stage-track { display: flex; gap: 0; overflow-x: auto; padding: 16px 18px; }
.stage {
  flex: 1; min-width: 100px;
  display: flex; flex-direction: column; align-items: center;
  position: relative;
}
.stage::before {
  content: '';
  position: absolute;
  top: 12px; left: calc(50% + 12px);
  width: calc(100% - 24px);
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.stage:last-child::before { display: none; }
.stage-circle {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  position: relative; z-index: 1;
  flex-shrink: 0;
}
.stage-done .stage-circle { background: var(--green); color: #fff; }
.stage-done::before { background: var(--green) !important; }
.stage-active .stage-circle { background: var(--navy); color: #fff; box-shadow: 0 0 0 4px rgba(5,61,112,0.15); }
.stage-pending .stage-circle { background: var(--border); color: var(--text-light); }
.stage-label { font-size: 10px; margin-top: 6px; text-align: center; color: var(--text-mid); font-weight: 500; }

/* ── TOOLTIP ── */
[data-tip] { position: relative; cursor: default; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--slate); color: #fff;
  font-size: 10px; padding: 4px 8px; border-radius: 5px;
  white-space: nowrap; pointer-events: none; z-index: 999;
}

/* ── TABS ── */
.tabs { display: flex; gap: 2px; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 18px; }
.tab-btn {
  flex: 1; padding: 7px 14px; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: none; background: transparent;
  color: var(--text-mid); font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}
.tab-btn.active { background: var(--surface); color: var(--navy); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* ── NOTICE / ALERT BOX ── */
.alert-box {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; margin-bottom: 14px;
}
.alert-red { background: var(--red-bg); border: 1px solid #FCA5A5; }
.alert-amber { background: var(--amber-bg); border: 1px solid #FCD34D; }
.alert-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-text { font-size: 12px; color: var(--text); line-height: 1.5; }
.alert-text strong { font-weight: 700; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── MINI CHART ── */
.mini-bar-row { display: flex; align-items: center; gap: 10px; padding: 7px 18px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.mini-bar-row:hover { background: #f8fafc; }
.mini-bar-row:last-child { border-bottom: none; }
.mini-bar-label { font-size: 11px; font-weight: 500; width: 110px; flex-shrink: 0; }
.mini-bar-track { flex: 1; background: var(--bg); height: 8px; border-radius: 4px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 4px; }
.mini-bar-num { font-size: 11px; font-weight: 700; color: var(--text-mid); width: 24px; text-align: right; }

/* ── CLIENT MODULE ── */
.client-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer; transition: all 0.15s;
}
.client-card:hover { border-color: var(--navy); box-shadow: 0 2px 12px rgba(5,61,112,0.08); }
.client-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.client-id { font-size: 10px; color: var(--text-light); font-family: monospace; }
.client-meta { font-size: 11px; color: var(--text-mid); margin-top: 8px; }
.client-open { display: inline-block; margin-top: 8px; font-size: 10px; font-weight: 700; color: var(--navy); background: #E0EAF5; padding: 2px 7px; border-radius: 10px; }

/* ── KPI CLICKABLE CARDS ── */
.kpi-clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
}
.kpi-clickable:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.10); }
.kpi-clickable:active { transform: translateY(-1px); }
.kpi-arrow { font-size: 9px; opacity: 0.45; margin-left: 3px; vertical-align: middle; }

/* ── HAMBURGER ── */
#hamburger-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 22px; padding: 6px 10px 6px 4px;
  color: var(--navy); line-height: 1; flex-shrink: 0;
}

/* ── SIDEBAR OVERLAY ── */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.visible { display: block; }

/* ── BOTTOM NAV ── */
#bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 150; /* must stay BELOW .modal-overlay (500) so modals never get hidden behind it */
  justify-content: space-around;
  padding: 4px 0 env(safe-area-inset-bottom, 6px);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.07);
}
.bnav {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 5px 8px;
  font-size: 20px; border: none; background: none;
  color: var(--text-mid); cursor: pointer;
  font-family: 'Inter', sans-serif; flex: 1;
}
.bnav span { font-size: 9px; font-weight: 600; color: var(--text-mid); }
.bnav.active, .bnav.active span { color: var(--navy); }

/* ── MOBILE BASE ── */
/* ── TABLET ── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 210px; }
  .stats-row, .dashboard-stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card.stat-wide { grid-column: span 2; }   /* full-width row on tablet */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  #content { padding: 18px; }
}

/* ── MOBILE ── */
@media (max-width: 768px) {
  #sidebar { transform:translateX(-100%); z-index:100; box-shadow:4px 0 24px rgba(0,0,0,0.2); width:260px !important; }
  #sidebar.open { transform:translateX(0); }
  #main { margin-left:0 !important; }
  .nav-item { font-size:15px; padding:12px 20px; }
  .nav-icon  { font-size:18px; width:22px; }
  #hamburger-btn { display:flex; font-size:24px; }
  #topbar { padding:8px 10px 8px 4px; gap:6px; height:auto; min-height:58px; flex-wrap:wrap; row-gap:8px; }
  .topbar-title { font-size:16px; font-weight:700; }
  .topbar-search { display:none; }
  .btn-gold { padding:9px 14px; font-size:14px; }
  /* topbar action buttons drop to their own full-width row, CTA on top,
     utility buttons sharing the row below — no font-size reduction */
  .topbar-actions { flex:1 1 100%; flex-direction:column; gap:8px; order:5; }
  .topbar-cta { width:100%; justify-content:center; padding:11px; font-size:14px; }
  .topbar-utility-row { width:100%; gap:8px; }
  .topbar-icon-btn { flex:1; justify-content:center; padding:9px 6px; font-size:13px; }
  #bottom-nav { display:flex; height:62px; }
  .bnav { font-size:22px; }
  .bnav span { font-size:10px; font-weight:600; }
  #content { padding:14px 12px 82px 12px; }
  body { font-size:15px; }
  .stats-row, .dashboard-stats-row { grid-template-columns:1fr 1fr; gap:10px; margin-bottom:14px; }
  .stat-card  { padding:16px 14px 14px; }
  .stat-label { font-size:11px; }
  .stat-value { font-size:30px; }
  .stat-sub   { font-size:12px; }
  .stat-icon  { font-size:20px; top:12px; right:12px; opacity:0.12; }
  .grid-2,.grid-3,#cal-grid { grid-template-columns:1fr; gap:12px; }
  .client-grid { grid-template-columns:1fr; }
  .form-grid { grid-template-columns:1fr !important; }
  .form-group.full { grid-column:1 !important; }
  .card-title   { font-size:14px; }
  .card-header  { padding:14px 16px; flex-wrap:wrap; gap:8px; }
  .section-title{ font-size:15px; }
  .form-label   { font-size:13px; }
  .form-control { font-size:15px; padding:11px 14px; }
  .badge        { font-size:11px; padding:3px 9px; }
  .btn          { font-size:14px; }
  .btn-sm       { font-size:12px; padding:6px 12px; }

  /* ── CASCADE TABLE → CARDS ── */
  .assign-table thead { display:none; }
  .assign-table tbody tr { display:block; background:#fff; border:1px solid var(--border); border-radius:10px; margin-bottom:10px; padding:0; box-shadow:0 1px 4px rgba(0,0,0,0.06); cursor:pointer; }
  .assign-table tbody tr:hover { box-shadow:0 3px 12px rgba(5,61,112,0.10); border-color:var(--navy); }
  .assign-table tbody td { display:block; border:none; padding:0; font-size:14px; text-align:left !important; }
  /* .compact sets fixed % widths for the desktop table layout — on mobile every
     cell becomes a full-width block line, so those leftover percentage widths
     must be cleared or text gets squeezed into a narrow column with empty
     space beside it instead of wrapping naturally across the full card. */
  .assign-table.compact td { width:auto !important; }
  .assign-table th:nth-child(4),.assign-table td:nth-child(4),
  .assign-table th:nth-child(5),.assign-table td:nth-child(5),
  .assign-table th:nth-child(6),.assign-table td:nth-child(6),
  .assign-table th:nth-child(7),.assign-table td:nth-child(7),
  .assign-table th:nth-child(8),.assign-table td:nth-child(8) { display:block !important; }
  .assign-table td:nth-child(1) { background:#EFF6FF; border-radius:10px 10px 0 0; padding:8px 14px 6px; font-family:monospace; font-size:12px; font-weight:700; color:var(--navy); border-bottom:1px solid var(--border); }
  .assign-table td:nth-child(2) { padding:10px 14px 4px; font-size:16px; font-weight:700; color:var(--text); }
  .assign-table td:nth-child(3) { padding:0 14px 8px; font-size:14px; color:var(--text-mid); border-bottom:1px solid var(--border); }
  .assign-table td:nth-child(4),.assign-table td:nth-child(5),.assign-table td:nth-child(6),.assign-table td:nth-child(7) { display:inline-block !important; padding:6px 6px 6px 14px; font-size:12px; vertical-align:middle; }
  .assign-table td:nth-child(4) { padding-top:8px; }
  .assign-table td:nth-child(8) { padding:6px 14px 10px; text-align:right !important; }
  .assign-table td:nth-child(8) .badge { font-size:12px; padding:4px 12px; }

  /* ── MODALS → BOTTOM SHEET ── */
  .modal-overlay { align-items:flex-end; z-index:500; }
  .modal {
    width:100vw !important; max-width:100vw !important; margin:0;
    border-radius:16px 16px 0 0;
    position:fixed; bottom:0; top:auto; left:0; right:0;
    /* dvh shrinks correctly when the on-screen keyboard opens; vh does NOT on many mobile browsers,
       which was causing fields like Due Date to be pushed off-screen behind the keyboard */
    max-height: calc(100dvh - 70px);
    max-height: calc(100vh - 70px); /* fallback for browsers without dvh support */
    display:flex; flex-direction:column;
    overflow:hidden;
  }
  .modal-body { overflow-y:auto; flex:1 1 auto; -webkit-overflow-scrolling:touch; }
  .modal-footer { flex-shrink:0; background:var(--surface); position:relative; z-index:1; }
  .modal-header  { padding:16px 18px; }
  .modal-title   { font-size:17px; }
  .modal-body    { padding:16px 18px; }

  /* ── KPI MODAL on mobile — collapse three separate wrapping rows of controls
     (category chips / filter dropdowns / quick-filter chips) down to something
     that fits above the fold: chips scroll horizontally, filters hide behind
     a toggle, so the assignment list itself is visible right away. ── */
  #kpi-modal .modal-header { flex-wrap:wrap; row-gap:8px; }
  #kpi-modal .modal-header > div:first-child { flex:1 1 auto; min-width:0; }
  #kpi-modal .modal-close { order:2; }
  #kpi-modal .kpi-modal-catbar {
    order:3; flex:1 1 100%;
    flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch;
    justify-content:flex-start; padding:2px 0 0;
    scrollbar-width:none;
  }
  #kpi-modal .kpi-modal-catbar::-webkit-scrollbar { display:none; }
  .kpi-filter-bar-wrap { padding:10px 14px; }
  .kpi-filter-toggle { display:inline-flex; align-items:center; gap:5px; }
  .kpi-filter-controls { display:none; margin-top:10px; }
  .kpi-filter-controls.expanded { display:flex; }
  .kpi-summary-bar { flex-wrap:nowrap !important; overflow-x:auto !important; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
  .kpi-summary-bar::-webkit-scrollbar { display:none; }
  .kpi-summary-bar button { flex-shrink:0; }
  .modal-footer  { padding:14px 18px; gap:10px; }
  .modal-footer .btn { flex:1; font-size:15px; padding:12px; }
  .stage-circle  { width:28px; height:28px; font-size:12px; }
  .stage-label   { font-size:10px; }
  /* Ensure whichever field the user taps scrolls fully into view above the keyboard */
  .form-control, .form-group { scroll-margin-top: 16px; scroll-margin-bottom: 16px; }
  #client-dropdown-list { max-height:160px !important; }

  /* ── CLIENT CARDS ── */
  .client-card { padding:14px 16px; }
  .client-name { font-size:16px; }
  .client-id   { font-size:12px; }
  .client-meta { font-size:13px; }

  /* ── WORKLOAD ── */
  .staff-name  { font-size:14px; }
  .staff-dept  { font-size:12px; }
  .workload-count { font-size:14px; }

  /* ── FOLLOWUPS ── */
  .followup-client { font-size:14px; }
  .followup-desc   { font-size:13px; }

  /* ── CALENDAR ── */
  .cal-event-name { font-size:14px; }
  .cal-event-meta { font-size:12px; }
  .cal-date-day   { font-size:20px; }

  /* ── AUTH ── */
  .auth-card   { padding:28px 22px; }
  .auth-title  { font-size:22px; }
  .auth-input  { font-size:16px; padding:13px 14px; }
  .auth-btn    { font-size:16px; padding:14px; }
}

/* ── LARGE TEXT MODE on mobile — same personal toggle as desktop, tuned values
   instead of `zoom` (zoom behaves inconsistently with fixed bottom-sheets/
   bottom-nav on mobile browsers, so we bump the real font/icon sizes instead) ── */
@media (max-width: 768px) {
  body.large-text                { font-size:17px; }
  body.large-text .nav-item      { font-size:17px; padding:13px 20px; }
  body.large-text .nav-icon      { font-size:21px; width:25px; }
  body.large-text .topbar-title  { font-size:18px; }
  body.large-text #hamburger-btn { font-size:27px; }
  body.large-text .bnav          { font-size:25px; }
  body.large-text .bnav span     { font-size:11px; }
  body.large-text .btn           { font-size:16px; }
  body.large-text .btn-sm        { font-size:13px; padding:7px 13px; }
  body.large-text .btn-gold      { font-size:16px; padding:10px 16px; }
  body.large-text .card-title    { font-size:16px; }
  body.large-text .section-title { font-size:17px; }
  body.large-text .form-label    { font-size:14px; }
  body.large-text .form-control  { font-size:16px; padding:12px 15px; }
  body.large-text .badge         { font-size:12px; padding:4px 10px; }
  body.large-text .stat-value    { font-size:33px; }
  body.large-text .stat-label    { font-size:12px; }
  body.large-text .stat-sub      { font-size:13px; }
  body.large-text .stat-icon     { font-size:22px; }

  /* table-cards */
  body.large-text .assign-table tbody td      { font-size:15px; }
  body.large-text .assign-table td:nth-child(1) { font-size:13px; }
  body.large-text .assign-table td:nth-child(2) { font-size:17px; }
  body.large-text .assign-table td:nth-child(3) { font-size:15px; }
  body.large-text .assign-table td:nth-child(4),
  body.large-text .assign-table td:nth-child(5),
  body.large-text .assign-table td:nth-child(6),
  body.large-text .assign-table td:nth-child(7) { font-size:13px; }
  body.large-text .assign-table td:nth-child(8) .badge { font-size:13px; padding:5px 13px; }

  /* modals */
  body.large-text .modal-title       { font-size:18px; }
  body.large-text .modal-footer .btn { font-size:16px; }
  body.large-text .stage-circle      { width:31px; height:31px; font-size:13px; }
  body.large-text .stage-label       { font-size:11px; }

  /* client cards, staff workload, followups, calendar */
  body.large-text .client-name     { font-size:17px; }
  body.large-text .client-id       { font-size:13px; }
  body.large-text .client-meta     { font-size:14px; }
  body.large-text .staff-name      { font-size:15px; }
  body.large-text .staff-dept      { font-size:13px; }
  body.large-text .workload-count  { font-size:15px; }
  body.large-text .followup-client { font-size:15px; }
  body.large-text .followup-desc   { font-size:14px; }
  body.large-text .cal-event-name  { font-size:15px; }
  body.large-text .cal-event-meta  { font-size:13px; }
  body.large-text .cal-date-day    { font-size:22px; }
}

/* ── SMALL PHONES ── */
@media (max-width: 400px) {
  .stats-row { gap:8px; }
  .stat-value { font-size:26px; }
  .stat-icon  { display:none; }
  #content    { padding:10px 10px 80px; }
  .assign-table td:nth-child(2) { font-size:15px; }
  .modal-title { font-size:16px; }
}

/* ── PAGE TRANSITION ── */
.page { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── DOC TRACKER ── */
.doc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
}
.doc-row:last-child { border-bottom: none; }
.doc-check {
  width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: all 0.15s;
}
.doc-check.checked { background: var(--green); border-color: var(--green); color: #fff; font-size: 11px; }
.doc-name { flex: 1; font-size: 12px; font-weight: 500; }
.doc-client { font-size: 11px; color: var(--text-mid); }
.doc-date { font-size: 10px; color: var(--text-light); }

/* ═══════════════════════════════════════════════════
   WORKFLOW ENGINE STYLES
═══════════════════════════════════════════════════ */

/* Suggestion modal checklist */
.wf-suggestion-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.wf-suggestion-item:last-child { border-bottom: none; }
.wf-suggestion-item:hover { background: var(--bg); }
.wf-suggestion-item input[type=checkbox] {
  width: 16px; height: 16px; margin-top: 2px;
  accent-color: var(--navy); cursor: pointer; flex-shrink: 0;
}
.wf-task-name { font-size: 13px; font-weight: 600; color: var(--text); }
.wf-task-meta { display: flex; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.wf-task-days { font-size: 11px; color: var(--text-mid); }
.wf-task-cat  { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--blue-bg); color: var(--blue); }
.wf-optional  { font-size: 10px; color: var(--text-light); font-style: italic; }

/* Workflow timeline in detail view */
.wf-timeline { padding: 10px 18px; }
.wf-tree-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px; cursor: pointer;
}
.wf-tree-item:last-child { border-bottom: none; }
.wf-tree-item:hover .wf-tree-id { color: var(--navy); text-decoration: underline; }
.wf-tree-prefix { color: var(--text-light); font-family: monospace; font-size: 13px; flex-shrink: 0; }
.wf-tree-id    { font-family: monospace; font-size: 11px; color: var(--text-mid); flex-shrink: 0; min-width: 90px; }
.wf-tree-name  { flex: 1; font-weight: 500; }
.wf-tree-days  { font-size: 11px; font-weight: 700; flex-shrink: 0; }

/* Workflow dashboard widget row */
.wf-widget-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
}
.wf-widget-row:last-child { border-bottom: none; }
.wf-widget-row:hover { background: var(--bg); }
.wf-widget-client { font-size: 12px; font-weight: 600; flex: 1; }
.wf-widget-task   { font-size: 11px; color: var(--text-mid); }
.wf-days-badge {
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 20px; flex-shrink: 0; white-space: nowrap;
}
.wf-days-urgent  { background: var(--red-bg);   color: var(--red); }
.wf-days-soon    { background: var(--amber-bg);  color: var(--amber); }
.wf-days-ok      { background: var(--green-bg);  color: var(--green); }
.wf-days-na      { background: #F1F5F9;           color: var(--text-light); }

/* Workflow source chip */
.wf-source-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  background: #EDE9FE; color: #6D28D9;
  border-radius: 20px; margin-top: 4px;
}

/* ── SEARCHABLE CLIENT DROPDOWN ── */
.client-option {
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.client-option:last-child { border-bottom: none; }
.client-option:hover { background: var(--bg); }
.client-opt-name { font-weight: 600; color: var(--text); }
.client-opt-pan  { font-size: 10px; color: var(--text-light); margin-top: 1px; }

/* ═══════════════════════════════════════════════════
   AUTH / LOGIN SYSTEM STYLES
═══════════════════════════════════════════════════ */

/* Full-screen login wall — shown before auth */
#auth-wall {
  position: fixed; inset: 0; z-index: 9000;
  background: linear-gradient(135deg, #032850 0%, #053D70 50%, #0A5FA0 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
}
#auth-wall.hidden { display: none; }

.auth-card {
  background: #fff;
  border-radius: 18px;
  padding: 40px 36px;
  width: 400px;
  max-width: 92vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  position: relative;
}

.auth-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px; justify-content: center;
}
.auth-logo-mark {
  width: 42px; height: 42px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='274 853 825 824'%3E%3Cpath d='M274 1677 686.5 853 1099 1677 683.489 1117.59 274 1677Z' fill='%23FBCE2E'/%3E%3Cpath d='M372 1677 735 1017 1098 1677 732.35 1228.93 372 1677Z' fill='%23FBCE2E'/%3E%3Cpath d='M473 1677 786 1149 1099 1677 783.715 1318.54 473 1677Z' fill='%23FBCE2E'/%3E%3C/svg%3E") center/contain no-repeat;
}
.auth-logo-text .firm {
  font-family: 'Poppins', sans-serif;
  font-size: 18px; font-weight: 700;
  color: var(--navy); line-height: 1;
}
.auth-logo-text .sub {
  font-size: 10px; color: var(--text-light);
  letter-spacing: 1.5px; text-transform: uppercase;
}

.auth-title {
  font-size: 20px; font-weight: 700;
  color: var(--text); text-align: center;
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 13px; color: var(--text-mid);
  text-align: center; margin-bottom: 28px;
}

.auth-form-group {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 16px;
}
.auth-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--text-mid);
}
.auth-input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 14px; font-family: 'Inter', sans-serif;
  color: var(--text); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(5,61,112,0.1);
}

.auth-btn {
  width: 100%; padding: 13px;
  background: var(--navy); color: #fff;
  border: none; border-radius: 9px;
  font-size: 14px; font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer; margin-top: 8px;
  transition: background 0.15s, transform 0.1s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-btn:hover { background: var(--navy-dark); }
.auth-btn:active { transform: scale(0.99); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-error {
  background: var(--red-bg);
  border: 1px solid #FCA5A5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px; color: var(--red);
  margin-bottom: 14px; display: none;
}
.auth-error.show { display: block; }

.auth-forgot {
  text-align: right; margin-top: -8px; margin-bottom: 14px;
}
.auth-forgot a {
  font-size: 12px; color: var(--navy);
  text-decoration: none; font-weight: 500;
}
.auth-forgot a:hover { text-decoration: underline; }

.auth-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px; color: var(--text-light);
}

/* Role badge on login card */
.auth-role-badge {
  display: inline-block;
  padding: 3px 10px; border-radius: 20px;
  font-size: 10px; font-weight: 700;
  margin-left: 6px; vertical-align: middle;
}
.role-partner { background: #EDE9FE; color: #6D28D9; }
.role-staff   { background: var(--blue-bg); color: var(--blue); }
.role-view    { background: var(--green-bg); color: var(--green); }

/* Sidebar user info — updated after login */
.sidebar-footer { cursor: default; }
.user-avatar-initials {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: var(--navy);
  flex-shrink: 0;
}
.auth-sign-out {
  margin-left: auto;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  padding: 5px 10px;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.auth-sign-out:hover {
  background: rgba(220,38,38,0.7);
  border-color: transparent;
  color: #fff;
}

/* Reset password screen */
.auth-screen { display: none; }
.auth-screen.active { display: block; }

/* Loading spinner */
.auth-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Role-based nav hiding */
.nav-item.hidden-for-role { display: none !important; }

/* Welcome toast */
.auth-welcome {
  position: fixed; top: 20px; right: 20px;
  background: var(--navy); color: #fff;
  border-left: 4px solid var(--gold);
  padding: 14px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 8000;
  animation: slideInRight 0.3s ease, fadeOut 0.4s 3s forwards;
}
@keyframes slideInRight { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }
@keyframes fadeOut { to { opacity: 0; pointer-events: none; } }

/* ── BILLING MODULE ── */
.bill-tab {
  padding: 8px 16px; font-size: 12px; font-weight: 500;
  background: none; border: none; cursor: pointer;
  color: var(--text-mid); border-bottom: 2px solid transparent;
  white-space: nowrap; font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}
.bill-tab.active { color: var(--navy); border-bottom-color: var(--navy); }
.bill-tab:hover  { color: var(--navy); }
.bill-tab-content { display: none; }
.bill-tab-content.active { display: block; }

/* Invoice PDF preview */
.inv-preview {
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  font-family: 'Inter', sans-serif;
  max-width: 700px; margin: 0 auto;
}
.inv-header-pdf {
  background: #053D70; padding: 20px 24px;
  display: flex; justify-content: space-between; align-items: flex-start;
}
.inv-firm-name { color: #FFC000; font-size: 15px; font-weight: 700; }
.inv-firm-sub  { color: rgba(255,255,255,0.6); font-size: 11px; margin-top: 3px; }
.inv-number-label { text-align: right; color: rgba(255,255,255,0.7); font-size: 11px; }
.inv-number-label strong { display: block; color: #fff; font-size: 16px; font-weight: 700; }
.inv-body-pdf { padding: 20px 24px; }
.inv-parties-pdf { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.inv-party-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-light); margin-bottom: 5px; }
.inv-party-nm  { font-size: 13px; font-weight: 700; color: var(--text); }
.inv-party-dt  { font-size: 11px; color: var(--text-mid); line-height: 1.6; margin-top: 2px; }
.inv-items-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 0; }
.inv-items-table th { padding: 8px 10px; background: var(--bg); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-mid); border-bottom: 1px solid var(--border); }
.inv-items-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); }
.inv-items-table tr:last-child td { border-bottom: none; }
.inv-totals-pdf { background: var(--bg); padding: 14px 24px; }
.inv-total-line { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.inv-total-final { font-size: 14px; font-weight: 700; color: var(--navy); padding-top: 8px; border-top: 2px solid var(--navy); margin-top: 6px; }
.inv-footer-pdf { padding: 14px 24px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-light); }

/* ── STAFF ROLE RESTRICTIONS ── */
body.staff-role [data-partner-only],
body.staff-role .partner-only { display: none !important; }
/* ── VIEWER: read-only. Hides every element that writes data. ──
   This is presentation only — the real block is the requireWrite() guards
   in JS and, authoritatively, the RLS policies in Postgres. */
body.viewer-role [data-write-action],
body.viewer-role .btn-gold,
body.viewer-role [onclick*="openModal('new-assignment-modal')"],
body.viewer-role [onclick*="openModal('new-client-modal')"] { display: none !important; }
/* Staff-only elements: hidden from Partners */
body:not(.staff-role) [data-staff-only] { display: none !important; }
/* Hide billing page for staff */
body.staff-role #page-billing { display: none !important; }

/* ── CLIENT VIEW ── */
.cv-client-header { background:linear-gradient(135deg,var(--navy) 0%,#0A5FA0 100%); border-radius:12px; padding:18px 20px; color:#fff; margin-bottom:14px; display:flex; align-items:flex-start; justify-content:space-between; flex-wrap:wrap; gap:12px; }
.cv-client-name   { font-size:20px; font-weight:700; color:#fff; }
.cv-client-meta   { font-size:12px; color:rgba(255,255,255,0.7); margin-top:4px; line-height:1.7; }
.cv-stat-chips    { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.cv-chip          { padding:4px 12px; border-radius:20px; font-size:11px; font-weight:700; background:rgba(255,255,255,0.15); color:#fff; }
.cv-chip.open     { background:rgba(255,192,0,0.25); color:#FFC000; }
.cv-chip.overdue  { background:rgba(220,38,38,0.3); color:#FCA5A5; }
.cv-chip.done     { background:rgba(22,163,74,0.3); color:#86EFAC; }
.cv-section-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:1px; color:var(--text-light); padding:10px 0 6px; margin-bottom:2px; display:flex; align-items:center; justify-content:space-between; }
.cv-suggestion-item { padding:10px 14px; cursor:pointer; border-bottom:1px solid var(--border); font-size:13px; transition:background 0.1s; }
.cv-suggestion-item:last-child { border-bottom:none; }
.cv-suggestion-item:hover { background:var(--bg); }
.cv-suggestion-name { font-weight:600; color:var(--text); }
.cv-suggestion-meta { font-size:11px; color:var(--text-light); margin-top:1px; }

/* ── COMPLIANCE CALENDAR ── */
.cal-filter-btn { padding:4px 12px; font-size:11px; font-weight:600; background:none; border:1.5px solid var(--border); border-radius:20px; cursor:pointer; color:var(--text-mid); font-family:Inter,sans-serif; transition:all 0.15s; }
.cal-filter-btn.active,.cal-filter-btn:hover { background:var(--navy); color:#fff; border-color:var(--navy); }
.cal-event-row { display:flex; align-items:flex-start; gap:12px; padding:10px 16px; border-bottom:1px solid var(--border); transition:background 0.1s; }
.cal-event-row:last-child { border-bottom:none; }
.cal-event-row:hover { background:var(--bg); }
.cal-event-row.today-event  { background:#FFFBEB; border-left:3px solid var(--gold); }
.cal-event-row.overdue-event{ background:#FFF1F2; border-left:3px solid var(--red); }
.cal-date-badge { min-width:46px; text-align:center; flex-shrink:0; background:var(--bg); border-radius:8px; padding:4px 6px; border:1px solid var(--border); }
.cal-date-day   { font-size:18px; font-weight:700; line-height:1; color:var(--text); }
.cal-date-month { font-size:10px; color:var(--text-light); text-transform:uppercase; letter-spacing:0.5px; }
.cal-date-badge.overdue .cal-date-day { color:var(--red); }
.cal-date-badge.today { border-color:var(--navy); background:#EFF6FF; }
.cal-date-badge.today .cal-date-day { color:var(--navy); }
.cal-event-name { font-size:13px; font-weight:600; color:var(--text); }
.cal-event-meta { font-size:11px; color:var(--text-light); margin-top:2px; }
.cal-days-badge { font-size:10px; font-weight:700; padding:2px 8px; border-radius:20px; flex-shrink:0; white-space:nowrap; align-self:flex-start; }
.cal-days-over  { background:var(--red-bg);  color:var(--red); }
.cal-days-today { background:#FEF9C3;         color:#854D0E; }
.cal-days-soon  { background:var(--amber-bg); color:var(--amber); }
.cal-days-ok    { background:var(--green-bg); color:var(--green); }
.cal-days-far   { background:var(--bg);       color:var(--text-light); border:1px solid var(--border); }
@media (max-width:768px) { #cal-grid { grid-template-columns:1fr !important; } }
@media (max-width:768px) { #kb-grid { grid-template-columns:1fr !important; } }

/* ════════════════════════════════════════════════════════
   ITR FEE QUOTATION TOOL — scoped styles (Button 2)
   ════════════════════════════════════════════════════════ */
/* ── ITR FEE QUOTATION TOOL — scoped styles ──
   Every rule is prefixed with .itr-fee-tool so nothing here can collide
   with the main app's own .card/.field/.action-bar/etc. classes, which
   have different definitions. Color variables are scoped to this class
   too (not :root) so they don't leak into or get overridden by the rest
   of the app's design system. */
.itr-fee-tool {
  --itr-navy:#053D70; --itr-navy-dark:#032d54; --itr-navy-light:#e8f0f8;
  --itr-gold:#FFC000; --itr-gold-dark:#e6ac00;
  --itr-green:#16a34a; --itr-green-light:#dcfce7;
  --itr-amber:#d97706; --itr-amber-light:#fef3c7;
  --itr-red:#dc2626; --itr-red-light:#fee2e2;
  --itr-gray-50:#f8fafc; --itr-gray-100:#f1f5f9; --itr-gray-200:#e2e8f0;
  --itr-gray-400:#94a3b8; --itr-gray-600:#475569; --itr-gray-800:#1e293b;
  --itr-radius:10px; --itr-shadow:0 2px 12px rgba(5,61,112,0.08);
  font-family:'Inter',sans-serif; color:var(--itr-gray-800);
}

/* CARDS */
.itr-fee-tool .card{background:#fff;border-radius:var(--itr-radius);box-shadow:var(--itr-shadow);margin-bottom:16px;overflow:hidden;}
.itr-fee-tool .card-header{padding:16px 20px;border-bottom:1px solid var(--itr-gray-100);display:flex;align-items:center;gap:10px;}
.itr-fee-tool .card-header h3{font-size:14px;font-weight:700;color:var(--itr-navy);}
.itr-fee-tool .card-icon{width:32px;height:32px;border-radius:8px;background:var(--itr-navy-light);display:flex;align-items:center;justify-content:center;font-size:16px;flex-shrink:0;}
.itr-fee-tool .card-body{padding:20px;}

/* CLIENT GRID */
.itr-fee-tool .client-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;}
@media(max-width:600px){.itr-fee-tool .client-grid{grid-template-columns:1fr 1fr;}}
.itr-fee-tool .field label{display:block;font-size:11px;font-weight:700;color:var(--itr-gray-600);text-transform:uppercase;letter-spacing:0.6px;margin-bottom:5px;}
.itr-fee-tool .field input,.itr-fee-tool .field select{width:100%;padding:10px 12px;border:1.5px solid var(--itr-gray-200);border-radius:8px;font-size:13px;font-family:inherit;background:#fff;transition:border-color 0.2s;}
.itr-fee-tool .field input:focus,.itr-fee-tool .field select:focus{outline:none;border-color:var(--itr-navy);box-shadow:0 0 0 3px rgba(5,61,112,0.08);}

/* INCOME GRID */
.itr-fee-tool .income-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 40px;}
@media(max-width:640px){.itr-fee-tool .income-grid{grid-template-columns:1fr;}}
.itr-fee-tool .cat-title{font-size:11px;font-weight:700;color:var(--itr-navy);text-transform:uppercase;letter-spacing:0.8px;margin-top:16px;margin-bottom:8px;padding-bottom:6px;border-bottom:1px solid var(--itr-navy-light);}
.itr-fee-tool .check-item{display:flex;align-items:center;justify-content:space-between;padding:7px 10px;border-radius:6px;cursor:pointer;transition:background 0.15s;}
.itr-fee-tool .check-item:hover{background:var(--itr-navy-light);}
.itr-fee-tool .check-item span{font-size:13px;color:var(--itr-gray-800);}
.itr-fee-tool .check-item input{width:16px;height:16px;accent-color:var(--itr-navy);cursor:pointer;flex-shrink:0;}

/* COMPLEXITY ROW */
.itr-fee-tool .complexity-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;}
@media(max-width:500px){.itr-fee-tool .complexity-grid{grid-template-columns:1fr;}}

/* ACTION BUTTONS */
.itr-fee-tool .action-bar{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px;}
.itr-fee-tool .act-btn{display:flex;align-items:center;gap:7px;padding:11px 18px;border-radius:9px;border:none;cursor:pointer;font-size:13px;font-weight:600;font-family:inherit;transition:all 0.2s;flex:1;min-width:140px;justify-content:center;}
.itr-fee-tool .act-btn:hover{transform:translateY(-1px);box-shadow:0 4px 12px rgba(0,0,0,0.15);}
.itr-fee-tool .act-wa{background:#25D366;color:#fff;}
.itr-fee-tool .act-pdf{background:var(--itr-red);color:#fff;}
.itr-fee-tool .act-copy{background:var(--itr-gray-600);color:#fff;}
.itr-fee-tool .act-paid{background:var(--itr-green);color:#fff;}

/* RESULT BOX */
.itr-fee-tool .result-box{background:var(--itr-navy-light);border-radius:9px;padding:16px 18px;font-family:monospace;font-size:13px;line-height:1.7;color:var(--itr-gray-800);white-space:pre-wrap;border-left:3px solid var(--itr-navy);}
.itr-fee-tool .result-placeholder{color:var(--itr-gray-400);font-style:italic;font-family:inherit;font-size:13px;}

/* GENERATE BTN */
.itr-fee-tool .gen-btn{width:100%;padding:14px;background:var(--itr-navy);color:#fff;border:none;border-radius:10px;font-size:14px;font-weight:700;cursor:pointer;font-family:inherit;transition:background 0.2s;display:flex;align-items:center;justify-content:center;gap:8px;margin-bottom:12px;}
.itr-fee-tool .gen-btn:hover{background:var(--itr-navy-dark);}

/* TOAST (scoped id since this tool's toast also uses an id selector) */
.itr-fee-tool .itr-toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%) translateY(80px);background:var(--itr-gray-800);color:#fff;padding:12px 22px;border-radius:50px;font-size:13px;font-weight:600;box-shadow:0 8px 24px rgba(0,0,0,0.2);z-index:999999;transition:transform 0.3s cubic-bezier(.4,0,.2,1);white-space:nowrap;}
.itr-fee-tool .itr-toast.show{transform:translateX(-50%) translateY(0);}

/* PAID MODAL — this is a real overlay, so it must NOT be scoped under
   .itr-fee-tool's normal-flow box (it needs position:fixed over the
   whole viewport), but its class names are still prefixed to avoid
   colliding with the main app's own .modal-overlay/.modal classes. */
.itr-modal-bg{position:fixed;inset:0;background:rgba(0,0,0,0.5);z-index:99990;display:flex;align-items:center;justify-content:center;padding:16px;}
.itr-modal-box{background:#fff;border-radius:16px;padding:28px;width:100%;max-width:400px;box-shadow:0 24px 64px rgba(0,0,0,0.25);font-family:'Inter',sans-serif;}
.itr-modal-box .itr-modal-title{font-size:17px;font-weight:800;color:var(--itr-navy);margin-bottom:6px;}
.itr-modal-box .itr-modal-sub{font-size:12px;color:var(--itr-gray-400);margin-bottom:20px;}
.itr-modal-box .itr-modal-field label{font-size:11px;font-weight:700;color:var(--itr-gray-600);text-transform:uppercase;letter-spacing:0.6px;display:block;margin-bottom:5px;}
.itr-modal-box .itr-modal-field input{width:100%;padding:11px 13px;border:1.5px solid var(--itr-gray-200);border-radius:9px;font-size:14px;font-family:inherit;}
.itr-modal-box .itr-modal-field input:focus{outline:none;border-color:var(--itr-navy);}
.itr-modal-box .itr-modal-err{color:var(--itr-red);font-size:11px;margin-top:4px;display:none;}
.itr-modal-box .itr-modal-btns{display:flex;gap:10px;margin-top:20px;}
.itr-modal-box .itr-modal-confirm{flex:1;padding:12px;background:var(--itr-green);color:#fff;border:none;border-radius:9px;font-size:14px;font-weight:700;cursor:pointer;font-family:inherit;}
.itr-modal-box .itr-modal-cancel{flex:1;padding:12px;background:var(--itr-gray-100);color:var(--itr-gray-600);border:none;border-radius:9px;font-size:14px;cursor:pointer;font-family:inherit;}

/* MOBILE FIXES (relevant subset only) */
@media(max-width:480px){
  .itr-fee-tool .card-body{padding:14px;}
  .itr-fee-tool .act-btn{min-width:120px;font-size:12px;padding:10px 12px;}
}

/* PDF TEMPLATE (hidden, off-screen) */
.itr-fee-tool #pdf-tpl{display:none;}

/* ═══════════ WHATSAPP MODULE ═══════════ */
.wa-wrap { display:flex; gap:0; height:calc(100vh - var(--topbar-h) - 96px); min-height:420px; background:var(--surface); border:1px solid var(--border); border-radius:12px; overflow:hidden; }
.wa-list { width:320px; min-width:260px; border-right:1px solid var(--border); display:flex; flex-direction:column; background:#FAFBFC; }
.wa-list-head { padding:12px; border-bottom:1px solid var(--border); display:flex; gap:8px; align-items:center; }
.wa-list-head input { flex:1; padding:8px 10px; border:1px solid var(--border); border-radius:8px; font-size:13px; font-family:Inter,sans-serif; }
.wa-list-body { flex:1; overflow-y:auto; }
.wa-contact { display:flex; gap:10px; padding:11px 12px; cursor:pointer; border-bottom:1px solid #F1F5F9; align-items:center; }
.wa-contact:hover { background:#F1F5F9; }
.wa-contact.active { background:#E8F0E9; }
.wa-avatar { width:40px; height:40px; border-radius:50%; background:var(--navy); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:14px; flex-shrink:0; }
.wa-avatar.unmatched { background:#94A3B8; }
.wa-c-main { flex:1; min-width:0; }
.wa-c-name { font-size:13px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.wa-c-prev { font-size:11.5px; color:var(--text-mid); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.wa-c-meta { text-align:right; flex-shrink:0; }
.wa-c-time { font-size:10px; color:var(--text-light); }
.wa-unread { display:inline-flex; align-items:center; justify-content:center; min-width:18px; height:18px; padding:0 5px; background:#16A34A; color:#fff; border-radius:9px; font-size:10px; font-weight:700; margin-top:3px; }
.wa-thread { flex:1; display:flex; flex-direction:column; min-width:0; background:#EFEAE2; }
.wa-thread-head { padding:10px 16px; background:var(--surface); border-bottom:1px solid var(--border); display:flex; align-items:center; gap:10px; }
.wa-thread-body { flex:1; overflow-y:auto; padding:16px 4%; display:flex; flex-direction:column; gap:6px; }
.wa-bubble { max-width:70%; padding:7px 11px; border-radius:10px; font-size:13px; line-height:1.45; box-shadow:0 1px 1px rgba(0,0,0,0.08); word-wrap:break-word; white-space:pre-wrap; position:relative; }
.wa-bubble.in  { background:#fff; align-self:flex-start; border-top-left-radius:2px; }
.wa-bubble.out { background:#D9FDD3; align-self:flex-end; border-top-right-radius:2px; }
.wa-bubble .wa-meta { font-size:9.5px; color:var(--text-light); text-align:right; margin-top:3px; }
.wa-bubble .wa-sender { font-size:10px; font-weight:700; color:var(--navy); margin-bottom:2px; }
.wa-bubble img.wa-img { max-width:260px; max-height:260px; border-radius:8px; display:block; cursor:pointer; }
.wa-doc-chip { display:flex; align-items:center; gap:8px; background:rgba(0,0,0,0.04); border-radius:8px; padding:8px 10px; text-decoration:none; color:var(--text); font-size:12px; font-weight:600; }
.wa-doc-chip:hover { background:rgba(0,0,0,0.08); }
.wa-tpl-tag { font-size:9px; font-weight:700; color:#7C3AED; text-transform:uppercase; letter-spacing:.4px; }
.wa-day-sep { align-self:center; background:#fff; border-radius:8px; padding:3px 12px; font-size:10.5px; font-weight:600; color:var(--text-mid); box-shadow:0 1px 1px rgba(0,0,0,0.08); margin:8px 0 4px; }
.wa-composer { padding:10px 12px; background:var(--surface); border-top:1px solid var(--border); display:flex; gap:8px; align-items:flex-end; }
.wa-composer textarea { flex:1; resize:none; border:1px solid var(--border); border-radius:10px; padding:9px 12px; font-size:13px; font-family:Inter,sans-serif; max-height:110px; min-height:38px; }
.wa-icon-btn { width:38px; height:38px; border-radius:50%; border:none; cursor:pointer; font-size:16px; display:flex; align-items:center; justify-content:center; flex-shrink:0; background:#F1F5F9; }
.wa-icon-btn:hover { background:#E2E8F0; }
.wa-send-btn { background:var(--navy); color:#fff; }
.wa-send-btn:hover { background:var(--navy-dark); }
.wa-window-bar { padding:6px 16px; font-size:11px; font-weight:600; text-align:center; }
.wa-window-bar.open   { background:#DCFCE7; color:#166534; }
.wa-window-bar.closed { background:#FEF3C7; color:#92400E; }
.wa-empty { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--text-mid); font-size:13px; gap:8px; }
.wa-status-ticks { font-size:10px; }
.wa-status-ticks.read { color:#2563EB; }
#wa-nav-badge { background:#16A34A; }
@media (max-width:768px) {
  .wa-wrap { height:calc(100vh - var(--topbar-h) - 140px); }
  .wa-list { width:100%; min-width:0; }
  .wa-wrap.thread-open .wa-list { display:none; }
  .wa-wrap:not(.thread-open) .wa-thread { display:none; }
  .wa-bubble { max-width:85%; }
}
