/* ============================================================
   THE MILL CRM — Stylesheet
   Earthy, utilitarian-refined. Cabin + Playfair Display.
   ============================================================ */

/* ── MOBILE UTILITIES ────────────────────────────────────── */
.mobile-only  { display: none; }
.desktop-only { display: block; }

@media (max-width: 768px) {
  .mobile-only  { display: block; }
  .desktop-only { display: none; }
}

:root {
  --green:        #224624;
  --green-mid:    #112910;
  --green-light:  #CCE9DA;
  --green-xlight: #E1E5E3;
  --amber:        #7a5c0a;
  --amber-light:  #F7DD83;
  --red:          #963030;
  --red-light:    #fceaea;
  --blue:         #1e4d78;
  --blue-light:   #e5eef7;
  --slate:        #3b4a5a;

  --bg:           #ffffff;
  --surface:      #ffffff;
  --surface2:     #E1E5E3;
  --border:       #CCE9DA;
  --border-light: #E1E5E3;

  --text:         #18201a;
  --text2:        #3a4a3c;
  --text3:        #6b7d6d;

  --sidebar-w:    228px;
  --topbar-h:     58px;
  --radius:       8px;
  --radius-sm:    5px;
  --shadow:       0 1px 8px rgba(34,70,36,.07);
  --shadow-md:    0 4px 20px rgba(34,70,36,.11);
  --shadow-lg:    0 8px 40px rgba(34,70,36,.16);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Poppins', system-ui, sans-serif;
  --font-mono:    'Poppins', monospace;
}

/* Inter numerals for currency values */
.currency {
  font-family: 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ── UTILITIES ───────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--text3); font-size: 12px; }
.mono { font-family: var(--font-mono); }

/* ── APP LAYOUT ──────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--green);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-top {
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark-sm {
  font-size: 26px;
  color: rgba(255,255,255,.85);
  line-height: 1;
}
.sidebar-name {
  font-family: var(--font-display);
  font-size: 20px;
  color: #fff;
  line-height: 1;
}
.sidebar-role {
  font-size: 10px;
  color: rgba(255,255,255,.5);
  letter-spacing: .1em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-label {
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
  padding: 12px 10px 4px;
  font-family: var(--font-mono);
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .14s, color .14s;
}
.nav-btn .ni { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-btn:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,.18); color: #fff; }
.nb {
  margin-left: auto;
  background: var(--amber-light);
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  min-width: 20px;
  text-align: center;
}

.sidebar-foot {
  padding: 12px 12px 14px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-chip { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name  { font-size: 12.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-dept  { font-size: 10px; color: rgba(255,255,255,.5); font-family: var(--font-mono); text-transform: uppercase; }
.signout-btn {
  background: none; border: none; color: rgba(255,255,255,.45);
  font-size: 18px; cursor: pointer; padding: 4px;
  border-radius: 4px; transition: color .14s;
  flex-shrink: 0;
}
.signout-btn:hover { color: #fff; }

/* ── MAIN ────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  justify-content: space-between;
}
.topbar-left { flex: 1 1 auto; min-width: 0; }
.page-title  { font-family: var(--font-display); font-size: 21px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Right cluster never wraps: search (shrinks to its min), Log Activity, bell, flag,
   per-page + Add. The inline style on the element in index.html is overridden here
   so a single rule owns the widths; at 1366px the cluster fits with room to spare. */
.topbar-right { display: flex !important; align-items: center; gap: 10px; flex: 0 1 auto !important; max-width: none !important; flex-wrap: nowrap; justify-content: flex-end; }
.topbar-right > * { flex-shrink: 0; }

.search-wrap { position: relative; flex: 1 1 300px; min-width: 160px; max-width: 300px; }
#log-activity-btn { padding: 7px 14px; }
.search-ico  { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 16px; pointer-events: none; }
.search-input {
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  width: 100%;
  outline: none;
  transition: border .14s;
}
.search-input:focus { border-color: var(--green); }
/* input[type=text] (below) outranks .search-input and resets its padding to 10px, so the
   placeholder ran under the ⌕ icon. On desktop the text is indented past the icon rather
   than padded: the box is sized from its content, and extra padding would widen it and
   shift the rest of the header. Phones use padding (MOBILE HEADER). */
@media (min-width: 769px) {
  .topbar .search-input { text-indent: 22px; }
}
/* Resources search: same cause. This box takes its width from its wrapper (flex: 1 on
   desktop, a full grid row on phones), not its content, so padding is safe at all widths. */
.tbl-controls .search-input { padding-left: 32px; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: opacity .14s, transform .1s;
}
.btn:hover   { opacity: .87; }
.btn:active  { transform: scale(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-danger  { background: var(--red); color: #fff; }
.btn-amber   { background: var(--amber); color: #fff; }
.btn-sm      { padding: 4px 11px; font-size: 12px; }
.btn-full    { width: 100%; justify-content: center; }
.btn-outline { background: none; border: 1px solid var(--border); color: var(--text2); }
.btn-outline:hover { background: var(--surface2); }

/* ── FORMS ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
label {
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text2);
  font-family: var(--font-mono);
}
/* Account autosave: per-field status inside the label (app.js setAcctFieldStatus) */
.autosave-status {
  margin-left: 8px; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--text3); opacity: 1; transition: opacity .4s;
}
.autosave-status.is-saved { color: var(--green); }
.autosave-status.is-fading { opacity: 0; }
.autosave-status.is-failed { color: var(--red); cursor: pointer; text-decoration: underline; }
.acct-confirm-field { display: flex; gap: 6px; align-items: center; }
.acct-confirm-field .btn { flex-shrink: 0; }
input[type=text], input[type=email], input[type=tel],
input[type=date], input[type=number], input[type=password],
select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border .14s, box-shadow .14s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34,70,36,.12);
}
textarea { resize: vertical; min-height: 72px; }
.form-hint { font-size: 11.5px; color: var(--text3); }

/* ── CARDS / TABLES ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-weight: 700; font-size: 14px; }
.card-body  { padding: 18px; }

.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface2); }
th {
  padding: 9px 14px; text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  font-family: var(--font-mono); color: var(--text2); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td {
  padding: 10px 14px; font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--border-light); vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; cursor: pointer; }
tbody tr:hover { background: var(--green-xlight); }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 20px; font-size: 10.5px; font-weight: 700;
  font-family: var(--font-mono); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em;
}
.bg-green  { background: var(--green-light);  color: var(--green); }
.bg-amber  { background: var(--amber-light);  color: var(--amber); }
.bg-red    { background: var(--red-light);    color: var(--red); }
.bg-blue   { background: var(--blue-light);   color: var(--blue); }
.bg-gray   { background: var(--surface2);     color: var(--text2); }
.bg-slate  { background: #e8ecf0;             color: var(--slate); }

.bg-stage-explore    { background: #e8f0fe; color: #1a56db; }
.bg-stage-discover   { background: #fdf6b2; color: #92400e; }
.bg-stage-create     { background: #fce8ff; color: #7e3af2; }
.bg-stage-present    { background: #feecdc; color: #c05621; }
.bg-stage-close      { background: #def7ec; color: #03543f; }
.bg-stage-strengthen { background: #d1fae5; color: #065f46; }
.bg-stage-dormant    { background: #f3f4f6; color: #6b7280; }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text3); margin-bottom: 7px; font-family: var(--font-mono); }
.stat-value { font-family: var(--font-display); font-size: 30px; line-height: 1; color: var(--text); }
.stat-sub   { font-size: 12px; color: var(--text3); margin-top: 5px; }
.stat-card.accent-green .stat-value { color: var(--green); }
.stat-card.accent-amber .stat-value { color: var(--amber); }
.stat-card.accent-blue  .stat-value { color: var(--blue); }

/* ── TABLE CONTROLS ──────────────────────────────────────── */
.tbl-controls {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.filter-sel {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  outline: none; cursor: pointer;
  width: auto; min-width: 130px;
}
.filter-sel:focus { border-color: var(--green); }

/* ── AVATAR ──────────────────────────────────────────────── */
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green); color: #fff;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar-blue { background: var(--blue); }

/* ── MODAL ───────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(18,32,20,.52);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  position: relative;
  transform: translateY(14px); transition: transform .18s;
}
.overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title  { font-family: var(--font-display); font-size: 18px; }
.modal-close  {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text3); line-height: 1; padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body   { padding: 18px 22px; }
.modal-footer { padding: 12px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── ACCOUNT SEARCH WIDGET ───────────────────────────────── */
.acct-search-wrap { position: relative; }
.acct-search-input { width: 100%; }
.acct-search-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 600;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 200px; overflow-y: auto; margin-top: 2px;
}
.acct-search-option { padding: 8px 12px; cursor: pointer; font-size: 13px; }
.acct-search-option:hover { background: var(--surface2); }
.acct-search-option.clear { color: var(--text3); font-style: italic; }
.acct-search-option.active { background: var(--green-xlight); }

/* Reusable account type-ahead (mountAccountSearch) */
.acs .acs-sub   { font-size: 11.5px; color: var(--text3); margin-top: 1px; }
.acs .acs-empty { color: var(--text3); font-style: italic; cursor: default; }
.acs .acs-empty:hover { background: none; }
.acs-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 6px 8px 6px 12px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--green-xlight); font-size: 13px; font-weight: 600; color: var(--text);
}
.acs-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acs-chip-x {
  border: none; background: none; cursor: pointer; color: var(--text2);
  font-size: 12px; line-height: 1; padding: 2px 4px; border-radius: 50%;
}
.acs-chip-x:hover { background: var(--surface2); color: var(--red); }

/* ── ACCOUNT DETAIL PAGE ─────────────────────────────────── */
.acct-detail-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap;
}
.acct-detail-name { flex: 1; font-family: var(--font-display); font-size: 22px; margin: 0; }
.acct-detail-actions { display: flex; gap: 8px; }
/* "View only · Department" — a manager on another department's account. */
.view-only-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface2); color: var(--text2); border: 1px solid var(--border); white-space: nowrap;
}
.acct-detail-layout {
  display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start;
}
.acct-edit-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.acct-edit-section-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text3); padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.acct-activity-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.acct-activity-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.acct-activity-title { font-size: 13px; font-weight: 700; }
.acct-activity-list { max-height: calc(100vh - 220px); overflow-y: auto; }
.acct-activity-item {
  padding: 10px 16px; border-bottom: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 3px;
}
.acct-activity-item:last-child { border-bottom: none; }
.acct-activity-item:hover { background: var(--surface2); }
.acct-activity-meta { display: flex; align-items: center; gap: 8px; }
.acct-activity-summary { font-size: 13px; font-weight: 500; }
.acct-activity-notes { font-size: 12px; color: var(--text3); }
@media (max-width: 900px) {
  .acct-detail-layout { grid-template-columns: 1fr; }
  .acct-activity-list { max-height: 400px; }
}

/* ── TRANSACTION HISTORY (account detail) ─────────────────── */
.txn-filterbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.txn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.txn-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text3);
}
.txn-presets, .txn-views, .txn-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.txn-row select, .txn-row input[type="date"], .txn-search {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; background: var(--bg); color: var(--text); font-family: inherit;
}
.txn-row select { max-width: 240px; }
.txn-search { flex: 1; min-width: 180px; }
.txn-totals {
  padding: 9px 12px; margin-bottom: 10px; border-radius: var(--radius);
  background: var(--surface2); font-size: 13px; color: var(--text2);
}
.txn-table-wrap { overflow-x: auto; }
.txn-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.txn-table th {
  padding: 6px 8px; text-align: left; font-weight: 600; color: var(--text3);
  border-bottom: 2px solid var(--border-light); white-space: nowrap;
}
.txn-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
/* This section is full width of the detail column so descriptions are never clipped. */
.txn-table td.txn-desc { white-space: normal; word-break: break-word; min-width: 220px; }
.txn-table .txn-num { text-align: right; white-space: nowrap; }
.txn-table .txn-nowrap { white-space: nowrap; }
.txn-table .txn-dim { color: var(--text3); }
.txn-table .txn-mono { font-family: var(--font-mono, monospace); }
.txn-table .txn-neg { color: var(--red); }
.txn-table th.txn-sortable { cursor: pointer; user-select: none; }
.txn-table th.txn-sortable:hover { color: var(--text); }
.txn-sort { color: var(--text3); font-size: 10px; }
.txn-sort.on { color: var(--green); }
.txn-empty { padding: 18px 4px; color: var(--text3); font-size: 13px; }
/* Account page Activity section: notes shown in full, never truncated */
.acct-act-notes { white-space: pre-wrap; word-break: break-word; color: var(--text2); font-size: 12px; margin-top: 3px; }
/* Account page Emails section: expanded message body, plain text only */
.acct-em-body { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; color: var(--text); background: var(--surface2); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px; max-height: 420px; overflow-y: auto; }
.txn-pager { display: flex; align-items: center; gap: 10px; padding-top: 10px; }
.txn-pager .btn[disabled] { opacity: .45; cursor: default; }
.txn-pageinfo { font-size: 12px; color: var(--text3); }

/* ── DETAIL PANEL ────────────────────────────────────────── */
.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text3); margin-bottom: 10px; font-family: var(--font-mono);
  padding-bottom: 6px; border-bottom: 1px solid var(--border-light);
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.dk { font-size: 10.5px; color: var(--text3); font-family: var(--font-mono); }
.dv { font-size: 13.5px; color: var(--text); font-weight: 500; }

/* ── LOGIN ───────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  background: var(--green);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 36px 40px;
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-brand { text-align: center; margin-bottom: 6px; }
.brand-mark  { font-size: 36px; color: var(--green); line-height: 1; margin-bottom: 6px; }
.brand-name  { font-family: var(--font-display); font-size: 28px; color: var(--text); }
.brand-sub   { font-size: 11px; color: var(--text3); letter-spacing: .12em; text-transform: uppercase; font-family: var(--font-mono); margin-top: 3px; }
.login-hint  { font-size: 12px; color: var(--text3); text-align: center; }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.alert-error   { background: var(--red-light);   color: var(--red); }
.alert-success { background: var(--green-light);  color: var(--green); }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { padding: 48px 20px; text-align: center; color: var(--text3); }
.es-icon { font-size: 36px; margin-bottom: 10px; }
.es-text { font-size: 14px; }

/* ── DASH GRID ───────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }

/* ── REP TEAM TABLE (manager) ────────────────────────────── */
.rep-bar {
  height: 6px; background: var(--green-light); border-radius: 3px; overflow: hidden;
}
.rep-bar-fill { height: 100%; background: var(--green); border-radius: 3px; }

/* ── PIPELINE KANBAN STRIP ───────────────────────────────── */
.stage-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stage-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: center;
}
.stage-col-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); font-family: var(--font-mono); margin-bottom: 4px; }
.stage-col-count { font-family: var(--font-display); font-size: 22px; color: var(--text); }
.stage-col-value { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }

/* ── TOAST ───────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-md);
  animation: slideUp .2s ease; min-width: 200px;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast-with-action { display: flex; align-items: center; gap: 12px; }
.toast-action {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius-sm); padding: 2px 10px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}

/* ── STAGE DESCRIPTIONS + Log Activity stage row ─────────── */
.stage-desc { margin-top: 8px; font-size: 12.5px; color: var(--text2); }
.stage-since { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--text3); }
.stage-since + .stage-desc { margin-top: 2px; }
.act-stage-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-chip {
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text2); font-family: var(--font-body);
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.stage-chip:hover { border-color: var(--green); color: var(--text); }
.stage-chip.is-current { background: var(--surface2); border-color: var(--text3); color: var(--text); }
.stage-chip.is-picked { background: var(--green); border-color: var(--green); color: #fff; }

/* ── NEEDS ATTENTION (dashboard card, full list, snooze, customize) ── */
.form-hint { font-size: 11.5px; color: var(--text3); font-family: var(--font-body); font-weight: 400; letter-spacing: 0; text-transform: none; }
.na-links { display: inline-flex; gap: 12px; font-size: 12px; }
.na-links a { color: var(--blue); text-decoration: none; font-weight: 600; }
.na-links a:hover { text-decoration: underline; }
.na-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border-light); cursor: pointer; }
.na-row:hover { background: var(--green-xlight); }
.na-main { flex: 1; min-width: 0; }
.na-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.na-meta { font-size: 11px; color: var(--text3); display: flex; align-items: center; gap: 6px; }
.na-when { text-align: right; min-width: 70px; }
.na-days { font-size: 20px; font-family: var(--font-display); color: var(--amber); line-height: 1.1; }
.na-days-label { font-size: 10px; color: var(--text3); }
.na-actions { display: flex; gap: 6px; flex-shrink: 0; }
.na-never { padding: 10px 16px; font-size: 12.5px; }
.na-never a { color: var(--text2); text-decoration: none; font-weight: 600; }
.na-never a:hover { color: var(--blue); text-decoration: underline; }
.na-summary { font-size: 13px; color: var(--text2); }
.na-snooze-picks { display: flex; gap: 8px; flex-wrap: wrap; }
.na-stage-list { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.na-check { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-body); font-size: 13px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text); cursor: pointer; }
.na-check input { width: auto; }

/* ── SALES GAPS (Gaps page + account-page card) ──────────── */
.stat-card-link { cursor: pointer; }
.stat-card-link:hover { border-color: var(--green); }
.gaps-section { margin-bottom: 18px; }
.gaps-count { font-family: var(--font-mono); font-size: 12px; color: var(--text3); margin-left: 6px; }
.gaps-sub, .gaps-dim { font-size: 11.5px; color: var(--text3); }
.gaps-why { font-size: 12.5px; color: var(--text2); }
.gaps-more { padding: 10px 14px; text-align: center; }
.gaps-switch { display: inline-flex; gap: 4px; }
.gap-account { color: var(--text); text-decoration: none; }
.gap-account:hover { color: var(--green); text-decoration: underline; }
.gap-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.acct-gap-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border-light);
}
.acct-gap-main { min-width: 0; flex: 1; }
.acct-gap-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-gap-value { margin-left: auto; font-size: 12.5px; }
.acct-gap-dismissed { margin-top: 10px; font-size: 12.5px; color: var(--text2); }
.acct-gap-dismissed summary { cursor: pointer; padding: 4px 0; }
.acct-gap-exclude {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-family: var(--font-body); font-size: 12.5px; font-weight: 500;
  letter-spacing: 0; text-transform: none; color: var(--text2); cursor: pointer;
}
.acct-gap-exclude input { width: auto; }
.flash-highlight { outline: 2px solid var(--green); outline-offset: 4px; border-radius: var(--radius-sm); }
@keyframes slideUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── PAGE ANIMATION ──────────────────────────────────────── */
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.page-anim { animation: fadeUp .2s ease; }

@media (max-width: 900px) {
  .stats-row  { grid-template-columns: 1fr 1fr; }
  .dash-grid  { grid-template-columns: 1fr; }
  .stage-strip { grid-template-columns: repeat(3,1fr); }
  .form-grid  { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ── TABLET (768px and below) ────────────────────────────── */
@media (max-width: 768px) {
  /* Mobile menu toggle: an icon button in the header row (see MOBILE HEADER below) */

  /* Sidebar - hidden by default on mobile. No shadow while hidden: its blur used to
     reach past the left screen edge as a faint gray band down every page. */
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease, visibility 0s linear 0.3s;
    box-shadow: none;
    visibility: hidden;
  }

  .sidebar.mobile-open {
    left: 0;
    box-shadow: var(--shadow-lg);
    visibility: visible;
    transition: left 0.3s ease, visibility 0s;
  }

  /* Better touch targets for nav buttons */
  .sidebar .nav-btn {
    min-height: 48px;
    font-size: 15px;
    padding: 12px 16px;
  }

  /* Overlay when menu is open */
  .mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }

  .mobile-overlay.active {
    display: block;
  }

  /* Main content */
  .main-content { margin-left: 0; padding: 60px 12px 12px; }

  /* Tables: LIST tables become cards, DATA tables scroll inside .data-scroll —
     see MOBILE PAGES at the end of this file */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-wrap td, .tbl-wrap th { padding: 12px 8px; }

  /* Touch-friendly controls and cards (phones and tablets) */
  .card { padding: 14px; }
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 36px; }
  .toast-wrap { bottom: 12px; right: 12px; left: 12px; }
  .toast { width: 100%; }
  .acct-detail-actions { justify-content: stretch; }
  .acct-detail-actions .btn { flex: 1; }

  /* Modals: full-screen sheets — see MOBILE MODALS at the end of this file */

  /* Forms */
  .form-grid { grid-template-columns: 1fr !important; }

  /* Form inputs — prevents iOS zoom on focus */
  input, select, textarea { font-size: 16px !important; min-height: 44px; padding: 10px 12px; }
  textarea { min-height: 100px; }

  /* Bigger checkboxes */
  input[type="checkbox"] { width: 20px; height: 20px; min-height: 20px; }

  /* Stats: two per row on tablets (one per row on phones, in the 480px block) */
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Stage strip single column */
  .stage-strip { grid-template-columns: 1fr !important; }

  /* Account detail header — stack actions */
  .acct-detail-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .acct-detail-header .btn { width: 100%; justify-content: center; }

  /* Better spacing on account cards */
  .acct-activity-card { margin-bottom: 12px; }
  .acct-activity-header { min-height: 48px; display: flex; align-items: center; font-size: 15px; padding: 12px 16px; }

  /* Mic button bigger on mobile */
  .mic-btn { width: 44px; height: 44px; font-size: 18px; }
}

/* ── PHONE (480px and below) ─────────────────────────────── */
@media (max-width: 480px) {
  /* Typography */
  .page-title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
  .acct-detail-name { font-size: 18px; line-height: 1.3; }

  /* Topbar: see MOBILE HEADER at the end of this file */

  /* Cards, buttons, toasts and account-header buttons: moved to the 768px block */

  /* Tables - reduce font size on very small screens */
  table { font-size: 12px; }
  th, td { padding: 8px 6px; }

  /* Stats single column on phone */
  .stats-row { grid-template-columns: 1fr !important; }

  /* Hide less important table columns on phone */
  .hide-mobile { display: none; }
}

/* ── ANNUAL GM GOAL CARDS ────────────────────────────────── */
.goal-card { padding: 20px 24px; }
.goal-card-title {
  font-size: 12px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px;
}
.goal-card-amounts { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.goal-ytd    { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--text); }
.goal-target { font-size: 13px; color: var(--text3); flex: 1; }
.goal-pct    { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--green); }
.goal-progress-track {
  height: 10px; background: var(--green-xlight);
  border-radius: 5px; overflow: hidden; margin-bottom: 8px;
}
.goal-progress-fill {
  height: 100%; background: var(--green); border-radius: 5px;
  transition: width .4s ease;
}
.goal-progress-fill.complete { background: linear-gradient(90deg, var(--green) 0%, var(--green-mid) 100%); }
.goal-pace     { font-size: 12.5px; font-weight: 600; }
.goal-footnote { font-size: 11.5px; color: var(--text3); margin-top: 8px; line-height: 1.45; }
.goal-input    { max-width: 170px; }

/* Phone-only copies of a modal footer's Delete / secondary buttons (app.js
   mirrorModalSideActions). Never shown on desktop, where the footer keeps them. */
.modal-side-actions { display: none; }

/* ── MOBILE HEADER (768px and below) ──────────────────────── */
/* One row in normal flow: [☰] [search, flexes] [log activity] [reminders] [alerts] [+].
   Nothing floats; the Menu button no longer has its own fixed position or z-index, so
   the modal overlay (z-index 500) covers the whole header. */
@media (max-width: 768px) {
  .topbar {
    height: auto; min-height: var(--topbar-h);
    padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    gap: 6px; justify-content: flex-start;
  }
  .topbar-left { display: none; }            /* the page title has no room in the row */
  .mobile-menu-toggle {
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 44px; width: 44px; height: 44px; padding: 0;
    border: none; border-radius: var(--radius-sm);
    background: var(--green); color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
  }
  .topbar-right { flex: 1 1 auto !important; min-width: 0; gap: 6px; }
  .topbar-right > .search-wrap { flex: 1 1 auto; min-width: 0; max-width: none; }
  /* .topbar raises specificity above input[type=text], which otherwise drops the room for the ⌕ icon */
  .topbar .search-input { height: 44px; padding-left: 32px; }
  #log-activity-btn, #bell-btn, #alert-bell-btn, #add-btn {
    width: 44px; min-width: 44px; height: 44px; min-height: 44px;
    padding: 0 !important; justify-content: center; font-size: 18px !important;
  }
  #log-activity-btn .lbl { display: none; }   /* icon only */
  #add-btn { font-size: 0 !important; }       /* "+ Account" etc. becomes "+"; the label stays readable to screen readers */
  #add-btn::before { content: '+'; font-size: 24px; line-height: 1; }
  /* Drop-downs from the header span the screen instead of overflowing it */
  #search-results, #notif-panel, #alert-notif-panel {
    position: fixed !important; top: calc(var(--topbar-h) + 4px) !important;
    left: 12px !important; right: 12px !important; width: auto !important; max-width: none !important;
    max-height: 70vh !important;
  }
}

/* ── MOBILE MODALS (768px and below) ──────────────────────── */
/* Every modal shares .overlay > .modal > .modal-header / .modal-body / .modal-footer,
   so these rules apply to all of them: a full-screen sheet with a fixed header, a
   scrolling body and a fixed footer. */
@media (max-width: 768px) {
  .overlay { padding: 0; align-items: stretch; justify-content: stretch; }
  .modal {
    width: 100%; max-width: none !important;
    height: 100vh; height: 100dvh; max-height: none;
    margin: 0; border-radius: 0; box-shadow: none;
    display: flex; flex-direction: column; overflow: hidden;
  }
  .modal-header {
    position: sticky; top: 0; z-index: 2; flex: 0 0 auto; gap: 8px;
    background: var(--surface);
    padding: max(6px, env(safe-area-inset-top)) 6px 6px 16px;
  }
  .modal-title { font-size: 17px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .modal-close {
    flex: 0 0 44px; width: 44px; height: 44px; padding: 0;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
  }
  .modal-body {
    flex: 1 1 auto; min-height: 0; max-height: none;
    overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  }
  /* Footer: one row — Cancel, then the primary action (always last) taking the larger share */
  .modal-footer {
    position: sticky; bottom: 0; z-index: 2; flex: 0 0 auto;
    background: var(--surface);
    flex-direction: row; flex-wrap: nowrap; gap: 10px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }
  .modal-footer > .btn {
    flex: 1 1 0; min-width: 0; min-height: 48px; padding: 10px 12px;
    justify-content: center; font-size: 15px; overflow: hidden; text-overflow: ellipsis;
  }
  .modal-footer > .btn:last-child { flex-grow: 2; }
  /* Delete and secondary actions show at the bottom of the body instead */
  .modal-footer > .modal-delete, .modal-footer > .modal-extra { display: none; }
  .modal-side-actions {
    display: flex; flex-direction: column; gap: 10px;
    margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border);
  }
  .modal-side-actions .btn { width: 100%; min-height: 48px; justify-content: center; font-size: 15px; }
  .modal-side-actions .modal-delete {
    margin-top: 12px; background: transparent; color: var(--red); border: 1px solid var(--red);
  }

  /* Fields: full width, never wider than the sheet; 16px so iOS does not zoom on focus */
  .modal .form-grid { gap: 12px; }
  .modal .form-grid > *, .modal .form-group { min-width: 0; }
  .modal .form-group { gap: 3px; }
  .modal .form-group > label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
  .modal input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
  .modal select, .modal textarea {
    width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; font-size: 16px !important;
  }
  /* iOS Safari ignores width on date/time inputs without this reset */
  .modal input[type=date], .modal input[type=time],
  .modal input[type=datetime-local], .modal input[type=month] {
    -webkit-appearance: none; appearance: none; display: block; text-align: left; min-height: 44px;
  }
  .modal input::-webkit-date-and-time-value { text-align: left; }
  /* Textareas: tall to start, grow with content (app.js fitModalTextarea) */
  .modal textarea { min-height: 140px; resize: none; }
  /* Textarea + mic: the mic moves up into the label row, right-aligned, and the textarea
     takes the full width. The wrapper and its click wiring are unchanged
     (initVoiceInput); display: contents only lets its children join this grid. */
  .modal .form-group:has(> .textarea-mic-wrapper) {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; row-gap: 4px; align-items: center;
  }
  .modal .form-group:has(> .textarea-mic-wrapper) > * { grid-column: 1 / -1; }
  .modal .form-group:has(> .textarea-mic-wrapper) > label { grid-column: 1; grid-row: 1; }
  .modal .form-group > .textarea-mic-wrapper { display: contents; }
  .modal .textarea-mic-wrapper > textarea { grid-column: 1 / -1; grid-row: 2; }
  .modal .textarea-mic-wrapper > .mic-btn { grid-column: 2; grid-row: 1; margin: 0; width: 44px; height: 44px; }

  /* No background scrolling while a modal is open (app.js toggles body.modal-open) */
  body.modal-open, body.modal-open .content { overflow: hidden; }
}

/* ── MOBILE PAGES (768px and below) ───────────────────────── */
/* Page layout, LIST tables as cards, DATA tables in a scroll wrapper. Desktop has no rules
   for any class used here (.list-table, .lc-*, .data-scroll, .dash-*, .fb-*), so it is
   unchanged. */
@media (max-width: 768px) {
  .content { padding: 16px; }

  /* Page heading: the header row has no room for the title (app.js sets data-title; the
     account page clears it, since the account name is its heading) */
  #content[data-title]:not([data-title=""])::before {
    content: attr(data-title); display: block;
    font-family: var(--font-display); font-size: 20px; line-height: 1.25; color: var(--text);
    margin: 0 0 12px;
  }

  /* LIST tables → one card per row. Cells marked lc-head / lc-tag share the top line;
     lc, lc-actions cells stack below in order; every other cell is hidden. The row keeps
     its onclick, so the whole card is the tap target. */
  .tbl-wrap:has(> table.list-table) { background: none; border: 0; box-shadow: none; border-radius: 0; overflow: visible; }
  .txn-table-wrap:has(> table.list-table) { overflow: visible; }
  table.list-table, table.list-table > tbody { display: block; width: 100%; min-width: 0; }
  table.list-table > thead { display: none; }
  table.list-table > tbody > tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; row-gap: 4px;
    padding: 12px 14px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  table.list-table > tbody > tr + tr { margin-top: 12px; }
  table.list-table > tbody > tr > td { display: none; }
  table.list-table > tbody > tr > td.lc-head, table.list-table > tbody > tr > td.lc-tag,
  table.list-table > tbody > tr > td.lc, table.list-table > tbody > tr > td.lc-actions,
  table.list-table > tbody > tr > td[colspan] {
    display: block; padding: 0; border: 0; min-width: 0 !important;
    white-space: normal !important; overflow-wrap: anywhere; text-align: left !important;
  }
  table.list-table td.lc-head { grid-column: 1; grid-row: 1; align-self: center; }
  table.list-table td.lc-tag  { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; }
  table.list-table td.lc, table.list-table td.lc-actions, table.list-table td[colspan] { grid-column: 1 / -1; }
  table.list-table td.lc-after   { order: 1; }
  table.list-table td.lc-actions { order: 2; margin-top: 6px; }
  table.list-table td.lc-strong  { font-weight: 600; font-size: 15px !important; color: var(--text); }
  table.list-table td.lc-muted   { font-size: 12.5px !important; color: var(--text3); }
  table.list-table td[data-label]::before {
    content: attr(data-label); margin-right: 6px;
    font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text3);
  }
  table.list-table td.lc-actions, table.list-table td.lc-actions .gap-actions, table.list-table td.lc-actions .na-actions {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start;
  }
  table.list-table td.lc-actions .btn { flex: 1 1 auto; justify-content: center; margin: 0 !important; }
  table.list-table td.lc-actions .gap-actions, table.list-table td.lc-actions .na-actions { flex: 1 1 100%; }
  table.list-table td.lc .goal-input { max-width: none; margin-top: 4px; }

  /* DATA tables stay tables and scroll sideways inside their wrapper — never the page.
     First column sticks; the right edge fades while there is more to see (app.js toggles
     .at-end); numbers keep their right alignment. */
  .data-scroll {
    overflow-x: auto !important; -webkit-overflow-scrolling: touch; max-width: 100%;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
  }
  .data-scroll.at-end { -webkit-mask-image: none; mask-image: none; }
  .data-scroll > table { min-width: 100%; }
  .data-scroll tbody tr { background-color: var(--surface); }
  .data-scroll tbody tr:hover { background-color: var(--green-xlight); }
  .data-scroll th:first-child, .data-scroll td:first-child {
    position: sticky; left: 0; z-index: 1; background-color: inherit; box-shadow: 1px 0 0 var(--border-light);
  }
  /* .data-scroll-stick2: the second column sticks instead (admin logs, whose first column
     is the row checkbox; the checkbox scrolls with the row and is usable at scroll start) */
  .data-scroll-stick2 th:first-child, .data-scroll-stick2 td:first-child { position: static; box-shadow: none; }
  .data-scroll-stick2 th:nth-child(2), .data-scroll-stick2 td:nth-child(2) {
    position: sticky; left: 0; z-index: 1; background-color: inherit; box-shadow: 1px 0 0 var(--border-light);
  }

  /* Dashboard: two-column rows wrap, side-by-side panels stack */
  .dash-gm-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .dash-gm-row > * { min-width: 0; }
  .dash-gm-value { white-space: nowrap; font-size: 26px !important; }
  .dash-stack { grid-template-columns: minmax(0, 1fr) !important; }
  .dash-stack > * { min-width: 0; }

  /* Account page: one column, nothing wider than the screen */
  .acct-detail-layout { grid-template-columns: minmax(0, 1fr); }
  .acct-detail-layout > * { min-width: 0; }

  /* Filter bars: a two-column grid. fb-full spans the row, fb-first / fb-last reorder,
     fb-spacer (a desktop flex spacer) is dropped, fb-pair keeps a button pair together. */
  .filter-bar, .tbl-controls {
    display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: stretch;
  }
  .filter-bar > *, .tbl-controls > * { min-width: 0 !important; width: 100%; }
  .filter-bar > .btn, .tbl-controls > .btn { justify-content: center; }
  .fb-full  { grid-column: 1 / -1; }
  .fb-first { order: -1; }
  .fb-last  { order: 1; }
  .fb-spacer { display: none !important; }
  .fb-pair { display: flex !important; gap: 8px; }
  .fb-pair > .btn { flex: 1 1 0; justify-content: center; }
}

/* Phones: a gross-margin card can't fit at half width, so one per row */
@media (max-width: 480px) {
  .dash-gm-row { grid-template-columns: minmax(0, 1fr) !important; }
  .dash-gm-value { font-size: 28px !important; }
  .dash-hero { flex-direction: column; align-items: flex-start !important; gap: 12px; }
  .dash-hero > div:last-child { text-align: left !important; }
  /* Leaderboard: name on the first line, the three figures on the second */
  .lb-row { flex-wrap: wrap; row-gap: 8px; }
  .lb-row > div:nth-child(3) { flex: 1 1 calc(100% - 100px) !important; min-width: 0; }
  .lb-row > div:nth-child(n+4) { flex: 1 1 0; min-width: 0 !important; margin-right: 0 !important; text-align: left !important; }
}

/* Sales by Rep / My Sales: per-account header and the totals strip */
@media (max-width: 768px) {
  .rep-acct-head { flex-wrap: wrap; row-gap: 8px; }
  .rep-acct-head > div:first-child { min-width: 0; }
  .rep-totals > * { min-width: 0; }
}
@media (max-width: 480px) {
  .rep-acct-figs { flex: 1 1 100%; gap: 16px !important; justify-content: space-between; }
  .rep-acct-figs > div { text-align: left !important; min-width: 0 !important; }
  .rep-totals { grid-template-columns: minmax(0, 1fr) !important; }
  .rep-totals > div { border-right: 0 !important; border-bottom: 1px solid var(--border); }
  .rep-totals > div:last-child { border-bottom: 0; }
}

/* Gaps section headers and the account page's transaction filters */
@media (max-width: 768px) {
  .gaps-section .card-header { flex-wrap: wrap; row-gap: 4px; }
  .gaps-section .card-header .gaps-sub { flex: 1 1 100%; }
  .txn-row > select, .txn-row > .txn-search { flex: 1 1 100%; min-width: 0; }
}
