:root {
  /* Synced with web/src/styles/global.css */
  --bg: #F2EDE4;
  --paper: #E8E2D8;
  --fg: #1C1C1A;
  --muted: #6B6560;
  --accent: #A0261E;
  --line: #d6cfc1;
  --line-soft: #e3dccb;
  --card: #E8E2D8;
  --danger: #8a2020;
  --highlight: rgba(160, 38, 30, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, "Helvetica Neue", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: "kern" 1, "liga" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form {
  background: var(--card); border: 1px solid var(--line);
  padding: 36px; display: grid; gap: 16px; width: 340px;
}
.login h1 {
  margin: 0 0 8px;
  font-weight: 700; font-size: 26px;
  letter-spacing: -0.03em;
}
.login label {
  display: grid; gap: 6px;
  color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 500;
}
.login input {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); padding: 10px 12px; font: inherit; font-size: 15px;
}
.login input:focus { outline: none; border-color: var(--accent); }
.login button {
  background: var(--fg); color: var(--paper); border: none;
  padding: 12px; font: inherit; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer;
}
.login button:hover { background: var(--accent); }
.err { color: var(--danger); margin: 0; min-height: 1em; font-size: 13px; }

/* Account/2FA */
.me-btn {
  background: transparent;
  color: rgba(255,255,255,0.55);
  border: 1px dashed rgba(255,255,255,0.18);
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: 2px;
  margin-right: 14px;
  transition: border-color 0.15s, color 0.15s;
}
.me-btn:hover { border-color: var(--accent); color: var(--bg); }

.acc-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.acc-section-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 500;
}
.acc-qr {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px;
  display: grid;
  place-items: center;
}
.acc-qr svg { display: block; width: 200px; height: 200px; }
.acc-secret {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  display: block;
  user-select: all;
  word-break: break-all;
}

/* 2FA badge for Users table */
.tfa-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 2px;
  line-height: 1.4;
  margin-left: 8px;
}
.tfa-on { color: #3a7a3a; border-color: #3a7a3a; }
.tfa-off { color: var(--muted); border-color: var(--line); }

/* Google sign-in button on the login form */
.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.google-btn:hover { border-color: var(--accent); }
.google-btn svg { flex-shrink: 0; }

.login-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  margin: 4px 0;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.login-divider span { padding: 0 4px; }

/* ---------- App shell ---------- */
.app > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.app > header h1 {
  display: flex; align-items: center; gap: 14px;
  margin: 0;
  font-weight: 600; font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--bg);
}
.app > header h1 img {
  height: 26px; width: auto; display: block;
}
.app > header h1 .divider {
  width: 1px; height: 16px; background: rgba(255,255,255,0.2);
}
.app > header h1 .crumb {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
}
#me {
  color: rgba(255,255,255,0.55);
  margin-right: 14px;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.app > header button.ghost {
  background: transparent;
  color: var(--bg);
  border-color: rgba(255,255,255,0.25);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 6px 12px;
}
.app > header button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  background: var(--paper);
}
.tabs button {
  background: transparent; color: var(--muted);
  border: none; padding: 14px 22px;
  cursor: pointer; font: inherit;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s;
}
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.tabs button:hover:not(.active) { color: var(--fg); }

.tab { padding: 32px 28px; }
.tab h2 {
  font-weight: 700;
  margin: 0 0 24px;
  color: var(--fg);
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

/* ---------- Buttons ---------- */
button {
  font: inherit;
}
.ghost {
  background: transparent; color: var(--fg);
  border: 1px solid var(--line); padding: 8px 14px;
  font: inherit; cursor: pointer;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }
.primary {
  background: var(--fg); color: var(--paper);
  border: none; padding: 10px 20px;
  font: inherit; font-size: 13px; font-weight: 500;
  letter-spacing: 0.10em; text-transform: uppercase;
  cursor: pointer;
}
.primary:hover { background: var(--accent); }
.app > header button.ghost { font-size: 12px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--paper); }
th, td {
  text-align: left; padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft); vertical-align: top;
}
th {
  color: var(--muted); font-weight: 500;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.10em;
  background: var(--paper); position: sticky; top: 0;
  border-bottom: 1px solid var(--line);
}
tbody tr { cursor: default; transition: background 0.08s; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--highlight); }
td button, td select {
  background: transparent; color: var(--fg);
  border: 1px solid var(--line); padding: 4px 8px;
  font: inherit; cursor: pointer;
}
td button.del { color: var(--danger); border-color: transparent; padding: 4px; }
td button.del:hover { border-color: var(--danger); }

/* ---------- Recurring tasks: table polish ---------- */
#recurring-table tbody tr { transition: background 0.08s; }
#recurring-table tbody tr:hover { background: var(--highlight); }
#recurring-table tbody tr.editing { background: var(--highlight); box-shadow: inset 3px 0 0 var(--accent); }
#recurring-table .rec-title { font-weight: 500; }
#recurring-table .rec-desc { color: var(--muted); font-size: 12px; margin-top: 3px; max-width: 420px; }
/* Flat badges for cadence + category, matching the admin's squared chips. */
.badge {
  display: inline-block; padding: 2px 8px; font-size: 11px;
  border: 1px solid var(--line-soft); background: var(--bg);
  color: var(--muted); letter-spacing: 0.03em; white-space: nowrap;
}
.badge.cadence { text-transform: capitalize; }
.badge.category { text-transform: uppercase; letter-spacing: 0.08em; }
/* Quieter, unified row actions: muted until hover; delete reddens. */
#recurring-table td.row-actions { text-align: right; white-space: nowrap; }
.row-actions button {
  background: transparent; border: none; color: var(--muted);
  padding: 4px 8px; font: inherit; font-size: 13px; cursor: pointer;
  transition: color 0.08s;
}
.row-actions button:hover { color: var(--accent); }
.row-actions button.del { color: var(--muted); }
.row-actions button.del:hover { color: var(--danger); }

/* ---------- Inline add form ---------- */
.inline { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.inline input, .inline select {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); padding: 8px 10px; font: inherit;
}
.inline input:focus, .inline select:focus { outline: none; border-color: var(--accent); }
.inline button {
  background: var(--fg); color: var(--paper); border: none;
  padding: 8px 18px; font: inherit; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.inline button:hover { background: var(--accent); }

.row-between {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}

/* ---------- Search & filter ---------- */
.toolbar { display: grid; gap: 12px; margin-bottom: 20px; }
.search-wrap {
  position: relative;
  display: flex; gap: 8px; align-items: center;
}
.search-wrap input {
  flex: 1;
  background: var(--paper); border: 1px solid var(--line);
  color: var(--fg); padding: 10px 14px; font: inherit; font-size: 15px;
}
.search-wrap input:focus { outline: none; border-color: var(--accent); }
.search-wrap input::placeholder { color: var(--muted); }
.count {
  color: var(--muted); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}

.chips-group { display: grid; gap: 8px; }
.chips-label {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.14em; font-weight: 500;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips.clamped { max-height: 30px; overflow: hidden; }
.chips.expanded { max-height: none; }

/* Toggle + clear always appear first in the row, so they're visible when clamped */
.chip.chip-toggle, .chip-clear { order: -1; }

.chip.chip-toggle {
  background: var(--paper);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chip.chip-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.chip-toggle-arrow {
  display: inline-block;
  font-size: 9px;
  margin-right: 5px;
  line-height: 1;
  transition: transform 0.15s ease;
}
.chip-toggle-count {
  font-size: 11px;
  letter-spacing: 0.02em;
}
.chip {
  background: var(--paper); border: 1px solid var(--line);
  color: var(--fg); padding: 4px 10px;
  font: inherit; font-size: 12px;
  cursor: pointer; transition: all 0.08s;
  border-radius: 0;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip .count-badge { color: var(--muted); margin-left: 6px; font-size: 11px; }
.chip.active {
  background: var(--accent); color: var(--paper); border-color: var(--accent);
}
.chip.active .count-badge { color: rgba(255,255,255,0.7); }
.chip-clear {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 4px 8px; font: inherit; font-size: 11px;
  text-decoration: underline;
}
.chip-clear:hover { color: var(--accent); }

/* Inline tag pills inside rows */
.tag-pill {
  display: inline-block; background: var(--bg);
  border: 1px solid var(--line-soft); padding: 1px 7px;
  font-size: 11px; color: var(--muted);
  margin-right: 4px; margin-bottom: 2px;
}

/* Compactable cluster: one row by default, expand via the chevron */
.tag-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  row-gap: 4px;
}
.tag-cluster.clamped {
  max-height: 22px;
  overflow: hidden;
}
.tag-cluster.expanded { max-height: none; overflow: visible; }

.tag-cluster-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 0 5px;
  height: 18px;
  cursor: pointer;
  border-radius: 2px;
  margin-right: 4px;
  margin-bottom: 2px;
  order: -1;   /* always render first → always in row 1, before clipped pills */
  font-variant-numeric: tabular-nums;
}
.tag-cluster-toggle:hover { border-color: var(--accent); color: var(--accent); }
.tag-cluster-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 9px;
  line-height: 1;
}
.tag-cluster.expanded .tag-cluster-arrow { transform: rotate(90deg); }
.tag-cluster.expanded .tag-cluster-count { display: none; }
.tag-cluster-count { line-height: 1; }

/* ---------- Modal (CSV import) ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(26, 24, 21, 0.55);
  display: grid; place-items: center;
  z-index: 50; padding: 24px;
}
.modal-card {
  background: var(--paper); border: 1px solid var(--line);
  width: min(820px, 100%); max-height: 90vh; overflow: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  margin: 0;
  font-weight: 700; font-size: 18px;
  letter-spacing: -0.02em;
}
.modal-body { padding: 22px; display: grid; gap: 16px; }
.modal-body h4 {
  margin: 8px 0 0; font-weight: 500; font-size: 11px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.10em;
}

.file {
  display: block; cursor: pointer;
  border: 1px dashed var(--line); padding: 28px; text-align: center;
  color: var(--muted); background: var(--bg);
}
.file:hover { border-color: var(--accent); color: var(--fg); }
.file input { display: none; }

.inline-field { display: grid; gap: 6px; }
.inline-field span {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.10em;
}
.inline-field input {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); padding: 9px 11px; font: inherit;
}
.inline-field input:focus { outline: none; border-color: var(--accent); }

.mapping { display: grid; gap: 8px; }
.mapping .pair {
  display: grid; grid-template-columns: 1fr 220px; gap: 12px; align-items: center;
}
.mapping select {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); padding: 6px 8px; font: inherit;
}
.mapping .col-name { color: var(--fg); font-size: 13px; }
.mapping .col-name .muted { color: var(--muted); font-size: 12px; }

.preview-wrap { overflow-x: auto; border: 1px solid var(--line); }
#import-preview { width: 100%; border-collapse: collapse; font-size: 12px; }
#import-preview th, #import-preview td {
  border-bottom: 1px solid var(--line-soft); padding: 6px 8px; vertical-align: top;
  white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
#import-preview th { color: var(--muted); font-weight: 500; }

#import-submit, #import-done {
  background: var(--fg); color: var(--paper); border: none;
  padding: 10px 20px; font: inherit; font-size: 12px;
  letter-spacing: 0.10em; text-transform: uppercase;
  cursor: pointer; justify-self: end;
}
#import-submit:hover, #import-done:hover { background: var(--accent); }

/* ---------- Drawer (contact detail) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(26, 24, 21, 0.35);
  z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 100%);
  background: var(--paper);
  border-left: 1px solid var(--line);
  z-index: 70;
  transform: translateX(100%);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.drawer-head h3 {
  margin: 0;
  font-weight: 700; font-size: 20px;
  letter-spacing: -0.025em;
}
.drawer-actions { display: flex; gap: 8px; }
.drawer-body {
  padding: 24px; overflow-y: auto; flex: 1;
  display: grid; gap: 18px; align-content: start;
}

.field { display: grid; gap: 6px; }
.field label {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.14em; font-weight: 500;
}
.field input, .field textarea {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); padding: 9px 11px;
  font: inherit; font-size: 14px;
  font-family: inherit;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 100px; }
.field .saved {
  font-size: 10px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.14em;
  opacity: 0; transition: opacity 0.3s;
}
.field .saved.show { opacity: 1; }

.notes-bullets {
  background: var(--bg); border: 1px solid var(--line);
  padding: 12px 14px; font-size: 13px;
}
.notes-bullets ul { margin: 0; padding-left: 18px; }
.notes-bullets li { margin: 2px 0; }
.notes-bullets .toggle {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 11px; padding: 4px 0 0;
  text-decoration: underline;
}

.drawer-meta {
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.04em; padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.empty {
  padding: 60px 24px; text-align: center; color: var(--muted);
  font-size: 14px;
}
.empty .serif {
  display: block; font-size: 22px; font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--fg); margin-bottom: 8px;
}

/* ---------- Team time ---------- */
.team-section { margin-bottom: 28px; }
.team-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.team-section-label {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.team-sub {
  font-size: 11px; color: var(--muted); letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.team-live-count {
  font-size: 11px; color: var(--accent); font-weight: 500;
  letter-spacing: 0.04em;
}
.team-live {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.team-live-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  text-align: center;
}
.team-live-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  display: grid;
  gap: 6px;
}
.team-live-card.paused {
  border-left-color: #6a635a;
}
.team-live-card-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.team-live-card-elapsed {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
}
.team-live-card.paused .team-live-card-elapsed { color: #6a635a; }
.team-live-card-desc {
  font-size: 14px;
  color: var(--fg);
  word-break: break-word;
}
.team-live-card-meta {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.team-headline {
  display: flex; gap: 28px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.team-headline-stat {
  display: flex; flex-direction: column;
}
.team-headline-num {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.team-headline-label {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}

.team-period.chips {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: 0;
}
.team-period .chip {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 5px 12px;
  font: inherit; font-size: 12px;
  cursor: pointer;
  border-radius: 2px;
}
.team-period .chip:hover { border-color: var(--accent); color: var(--accent); }
.team-period .chip.active {
  background: var(--accent); color: var(--paper);
  border-color: var(--accent);
}

.team-chart {
  display: flex; align-items: flex-end;
  gap: 4px;
  height: 80px;
  padding: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.team-chart-bar {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  cursor: default;
}
.team-chart-bar-fill {
  width: 100%;
  background: var(--accent);
  opacity: 0.6;
  min-height: 1px;
  transition: opacity 0.15s;
  border-radius: 1px;
}
.team-chart-bar:hover .team-chart-bar-fill { opacity: 1; }
.team-chart-bar-label {
  font-size: 9px; color: var(--muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.team-chart-bar.today .team-chart-bar-fill { opacity: 1; }
.team-chart-bar.today .team-chart-bar-label { color: var(--accent); font-weight: 500; }

.team-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}
@media (max-width: 900px) { .team-tables { grid-template-columns: 1fr; } }

.team-tables table {
  width: 100%;
}
.team-tables td.total,
#team-recent-table td.total,
#team-recent-table td.dur {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* User initial badge — used by team time + assignees on board tiles */
.user-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
  flex-shrink: 0;
}
.user-badge[data-color="0"] { background: #e6d8c9; color: #6b4a2b; border-color: #d8c4ac; }
.user-badge[data-color="1"] { background: #d9e2d6; color: #3a5a3a; border-color: #bdd0b8; }
.user-badge[data-color="2"] { background: #e0d4e6; color: #5a3a73; border-color: #c8b5d4; }
.user-badge[data-color="3"] { background: #e2d4d4; color: #843030; border-color: #d2b5b5; }
.user-badge[data-color="4"] { background: #d4dfe6; color: #2e556b; border-color: #b5cad4; }
.user-badge[data-color="5"] { background: #e6e0c8; color: #6e5a1f; border-color: #d8cea0; }
.user-badge.sm { width: 16px; height: 16px; font-size: 8px; }
.user-badge.lg { width: 28px; height: 28px; font-size: 12px; }

/* Tile assignee badge sits in the meta row */
.board-tile-assignee {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted);
}

/* Inline timer button on the tile face */
.tile-timer-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
  opacity: 0;          /* hidden by default — revealed on tile hover */
  transition: opacity 0.1s, border-color 0.1s, color 0.1s;
}
.board-tile:hover .tile-timer-btn { opacity: 1; }
.tile-timer-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.tile-timer-btn .tile-timer-glyph { font-size: 10px; }
/* Running state: always visible, oxblood */
.tile-timer-btn.running,
.board-tile.is-tracking .tile-timer-btn {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper);
}
.tile-timer-btn.running:hover { background: #861f1a; }
.tile-timer-elapsed { font-weight: 500; }

/* Subtle accent line on the tile when it's the one being tracked */
.board-tile.is-tracking {
  border-color: var(--accent);
  box-shadow: -3px 0 0 var(--accent);
}

/* Tile chip in time-entry rows */
.time-entry-tile {
  color: var(--muted);
  font-size: 11px;
}

/* ---------- Users tab ---------- */
.role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 2px;
  line-height: 1.4;
}
.role-admin { color: var(--accent); border-color: var(--accent); }
.role-user { color: var(--muted); border-color: var(--line); }
.you-tag {
  margin-left: 8px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.user-actions {
  display: flex; gap: 6px; justify-content: flex-end;
}
#user-pw-hint { color: var(--muted); font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 11px; margin-left: 6px; }

/* ---------- Board (Trello-style) ---------- */
.board-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
  margin: 0 -28px;
  padding: 0 28px 8px;
}
.board {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-height: 200px;
}
.board-column {
  flex: 0 0 280px;
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
}
.board-column.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--highlight); }
.board-column.dragging { opacity: 0.5; }

.board-col-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: grab;
}
.board-col-head input {
  background: transparent; border: none;
  font: inherit; font-size: 13px; font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--fg);
  width: 100%; padding: 4px 6px;
  border-radius: 2px;
}
.board-col-head input:hover { background: var(--bg); }
.board-col-head input:focus { background: var(--bg); outline: 1px solid var(--accent); }
.board-col-count {
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.board-col-menu {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 4px 6px; font-size: 14px; line-height: 1;
}
.board-col-menu:hover { color: var(--accent); }

.board-tiles {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}
.board-tile {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.08s, transform 0.06s;
  border-radius: 2px;
  position: relative;
  overflow: hidden; /* clip progress bar to rounded corners */
}
.board-tile:hover { border-color: var(--accent); }
.board-tile.dragging { opacity: 0.4; transform: rotate(1deg); }

/* Slim progress bar at the very top of the tile */
.tile-progress {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: rgba(28, 28, 26, 0.08);
}
.tile-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}
.tile-progress-fill.complete { background: #6ba47a; }

.board-tile-title {
  font-size: 14px; line-height: 1.4; color: var(--fg);
  margin-top: 2px; /* breathing room from progress bar */
}

/* Inline checklist on tile */
.tile-checklist {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tile-checklist-item label {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px;
  align-items: start;
  padding: 3px 4px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
}
.tile-checklist-item label:hover { background: rgba(0, 0, 0, 0.03); }
.tile-checklist-item input[type="checkbox"] {
  width: 13px; height: 13px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.tile-checklist-item .tile-cb-text {
  color: var(--fg);
  word-break: break-word;
}
.tile-checklist-item.done .tile-cb-text {
  text-decoration: line-through;
  color: var(--muted);
  opacity: 0.7;
}

.tile-checklist-toggle {
  padding: 2px 4px;
}
.tile-toggle-done {
  background: transparent; border: none;
  color: var(--muted); font: inherit;
  font-size: 11px; letter-spacing: 0.04em;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.15);
  text-underline-offset: 2px;
}
.tile-toggle-done:hover { color: var(--accent); text-decoration-color: var(--accent); }

.tile-checklist-add-li { padding: 2px 4px; margin-top: 2px; }
.tile-add-item {
  background: transparent; border: none;
  color: var(--muted); font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 3px 4px;
  letter-spacing: 0.02em;
}
.tile-add-item:hover { color: var(--accent); }

.tile-add-item-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}
.tile-add-item-form input {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  border-radius: 2px;
}
.tile-add-item-form input:focus { outline: none; border-color: var(--accent); }
.tile-add-item-actions { display: flex; gap: 6px; align-items: center; }
.tile-add-item-actions button {
  background: var(--fg); color: var(--paper); border: none;
  padding: 5px 12px; font: inherit; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500;
  cursor: pointer; border-radius: 2px;
}
.tile-add-item-actions button.cancel {
  background: transparent; color: var(--muted); padding: 5px;
}
.tile-add-item-actions button.cancel:hover { color: var(--accent); }
.board-tile-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 8px;
  font-size: 11px; color: var(--muted);
  align-items: center;
  min-height: 22px; /* so a tile with only an assignee still has room */
}
.board-tile-contact {
  background: var(--paper); border: 1px solid var(--line-soft);
  padding: 1px 6px; font-size: 10px; letter-spacing: 0.04em;
}
.board-tile-checklist {
  display: inline-flex; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums;
}
.board-tile-checklist.complete { color: var(--accent); }
.board-tile-desc-mark {
  width: 12px; height: 2px; background: var(--muted); opacity: 0.4;
  display: inline-block;
}

.board-add-tile {
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  background: transparent; color: var(--muted);
  font: inherit; font-size: 12px;
  text-align: left;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.board-add-tile:hover { color: var(--accent); background: var(--bg); }

.board-add-column-tile {
  flex: 0 0 280px;
}
.board-add-tile-form {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line-soft);
}
.board-add-tile-form textarea {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); padding: 8px 10px; font: inherit; font-size: 13px;
  min-height: 60px; resize: vertical;
}
.board-add-tile-form textarea:focus { outline: none; border-color: var(--accent); }
.board-add-tile-actions { display: flex; gap: 6px; align-items: center; }
.board-add-tile-actions button {
  background: var(--fg); color: var(--paper); border: none;
  padding: 6px 12px; font: inherit; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.board-add-tile-actions button.cancel {
  background: transparent; color: var(--muted); padding: 6px;
}

/* Tile modal */
.tile-modal-title {
  background: transparent; border: none;
  font: inherit;
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--fg);
  width: 100%; padding: 4px 8px;
  border-radius: 2px;
}
.tile-modal-title:hover { background: var(--bg); }
.tile-modal-title:focus { background: var(--bg); outline: 1px solid var(--accent); }

.checklist {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.checklist-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.checklist-label {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.checklist-progress {
  font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.checklist-progress.complete { color: var(--accent); }

.checklist-items { display: flex; flex-direction: column; gap: 4px; }
.checklist-item {
  display: grid; grid-template-columns: 18px 1fr auto;
  gap: 10px; align-items: center;
  padding: 6px 8px;
  border-radius: 2px;
}
.checklist-item:hover { background: var(--bg); }
.checklist-item input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.checklist-item input[type="text"] {
  background: transparent; border: none;
  font: inherit; font-size: 14px;
  color: var(--fg); padding: 4px 0;
  width: 100%;
}
.checklist-item input[type="text"]:focus { outline: none; }
.checklist-item.done input[type="text"] {
  text-decoration: line-through;
  color: var(--muted);
}
.checklist-item .del {
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  padding: 2px 6px; font-size: 14px;
  opacity: 0; transition: opacity 0.1s;
}
.checklist-item:hover .del { opacity: 1; }
.checklist-item .del:hover { color: var(--danger); }

.checklist-add {
  display: flex; gap: 6px;
  margin-top: 8px;
}
.checklist-add input {
  flex: 1;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); padding: 8px 10px; font: inherit; font-size: 13px;
}
.checklist-add input:focus { outline: none; border-color: var(--accent); }
.checklist-add button {
  background: var(--fg); color: var(--paper); border: none;
  padding: 6px 14px; font: inherit; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}

/* ---------- Running timer indicator (header) ---------- */
.timer-indicator {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent); color: var(--paper);
  padding: 6px 10px 6px 14px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s;
}
.timer-indicator.paused { background: #6a635a; }
.timer-indicator .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--paper);
  animation: pulse 1.4s ease-in-out infinite;
}
.timer-indicator.paused .dot {
  animation: none;
  background: transparent;
  border: 2px solid var(--paper);
  width: 6px; height: 6px;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.timer-indicator .timer-desc {
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: rgba(255,255,255,0.85);
}
.timer-stop {
  background: rgba(0,0,0,0.2); color: var(--paper);
  border: 1px solid rgba(255,255,255,0.3); padding: 3px 10px;
  font: inherit; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer;
}
.timer-stop:hover { background: rgba(0,0,0,0.4); }

/* ---------- Time report ---------- */
.report-card { width: min(1000px, 100%); max-height: 92vh; }
.report-builder { display: grid; gap: 14px; margin-bottom: 20px; }
.report-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.report-row .inline-field input,
.report-row .inline-field select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 9px 11px;
  font: inherit; font-size: 14px;
  border-radius: 2px;
}
.report-row .inline-field input:focus,
.report-row .inline-field select:focus { outline: none; border-color: var(--accent); }
.report-quick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.report-quick-chips .chip {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--fg);
  font: inherit; font-size: 12px;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 2px;
}
.report-quick-chips .chip:hover { border-color: var(--accent); color: var(--accent); }
.report-quick-chips .chip.active { background: var(--accent); color: var(--paper); border-color: var(--accent); }

.report-output {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.report-header {
  margin-bottom: 14px;
}
.report-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
}
.report-header .meta {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.report-grand-total {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 2px solid var(--fg);
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 15px;
}

.report-group {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
}
.report-group-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
}
.report-group-head .total { font-variant-numeric: tabular-nums; }
.report-subgroup {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.report-subgroup:last-child { border-bottom: none; }
.report-subgroup .name { color: var(--fg); }
.report-subgroup .count { color: var(--muted); font-size: 11px; margin-left: 8px; }
.report-subgroup .total { font-variant-numeric: tabular-nums; }

.report-empty {
  padding: 30px 12px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 2px;
}

/* Print styles — only the report content prints, no admin chrome */
@media print {
  /* The report modal lives INSIDE #app, so we can't just hide every
     direct child of body — we'd hide #app too and the modal with it.
     Hide body's other direct children, AND hide #app's other children
     except the modal itself. */
  body > *:not(#app) { display: none !important; }
  #app > * { display: none !important; }
  #app > #report-modal { display: block !important; }
  /* Reset modal positioning so it prints inline at the page top */
  #report-modal {
    position: static;
    background: white;
    padding: 0;
  }
  .modal-card.report-card {
    box-shadow: none;
    border: none;
    width: 100%;
    max-height: none;
    max-width: none;
  }
  .modal-body { padding: 0; }
  .no-print { display: none !important; }
  .report-output { border-top: none; padding-top: 0; }
  .report-group { break-inside: avoid; }
  .report-group-head { background: white; }
  .report-header h2 { font-size: 18pt; }
  /* Add a print header */
  .report-output::before {
    content: "Time report — Complicated CRM";
    display: block;
    font-size: 9pt;
    color: #666;
    margin-bottom: 8px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
  }
  @page { margin: 1.5cm; }
}

/* ---------- Duplicate finder ---------- */
.dedupe-group {
  border: 1px solid var(--line);
  background: var(--paper);
  margin-bottom: 16px;
  border-radius: 2px;
}
.dedupe-group-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.dedupe-group-head .reason { color: var(--accent); }
.dedupe-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.dedupe-row:last-child { border-bottom: none; }
.dedupe-info {
  display: grid;
  gap: 4px;
  font-size: 13px;
  min-width: 0;
}
.dedupe-info .name { font-size: 14px; font-weight: 500; }
.dedupe-info .sub { color: var(--muted); font-size: 12px; }
.dedupe-info .meta { color: var(--muted); font-size: 11px; }
.dedupe-keep {
  background: var(--fg);
  color: var(--paper);
  border: none;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
}
.dedupe-keep:hover { background: var(--accent); }
.dedupe-keep[disabled] { opacity: 0.5; cursor: default; }

.dedupe-empty {
  padding: 32px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Saved searches (above the toolbar) ---------- */
.saved-searches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.saved-searches-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
  font-weight: 500;
}
.saved-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--fg);
  padding: 4px 4px 4px 10px;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.08s, color 0.08s;
}
.saved-chip:hover { border-color: var(--accent); color: var(--accent); }
.saved-chip .saved-remove {
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  padding: 0 4px; font-size: 12px; line-height: 1;
  border-radius: 2px;
}
.saved-chip .saved-remove:hover { color: var(--accent); background: rgba(160,38,30,0.08); }

/* ---------- Mobile-only / desktop-only utility ---------- */
.mobile-only { display: none; }
@media (max-width: 640px) {
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }
}

/* ---------- Action row + overflow (kebab) menu ---------- */
.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.overflow-wrap { position: relative; display: inline-flex; align-items: center; gap: 8px; }
.overflow-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.overflow-menu { display: flex; align-items: center; gap: 8px; }

@media (max-width: 640px) {
  .overflow-toggle { display: inline-flex; }
  .overflow-menu {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 220px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 2px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.22);
    z-index: 40;
  }
  .overflow-menu.open { display: flex; }
  .overflow-menu .overflow-item {
    border: none;
    border-bottom: 1px solid var(--line-soft);
    border-radius: 0;
    background: transparent;
    text-align: left;
    padding: 12px 14px;
    font-size: 13px;
    letter-spacing: 0.04em;
    width: 100%;
    color: var(--fg);
    text-transform: none;
  }
  .overflow-menu .overflow-item:last-child { border-bottom: none; }
  .overflow-menu .overflow-item:hover { background: var(--bg); color: var(--accent); }
}

/* ---------- Filter toggle (mobile) ---------- */
.filter-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--paper);
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
  padding: 0 5px;
}
.filter-badge.hidden { display: none; }

@media (max-width: 640px) {
  #contacts-toolbar .filter-group { display: none; }
  #contacts-toolbar.filters-open .filter-group { display: grid; }
  #filter-toggle.is-active {
    background: var(--accent);
    color: var(--paper);
    border-color: var(--accent);
  }
}

/* ---------- Mobile cards for the Contacts table ---------- */
@media (max-width: 640px) {
  #tab-contacts #contacts-table thead { display: none; }
  #tab-contacts #contacts-table,
  #tab-contacts #contacts-table tbody,
  #tab-contacts #contacts-table tr {
    display: block;
    width: 100%;
  }
  #tab-contacts #contacts-table tr.clickable {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 12px 14px;
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 24px 1fr;
    column-gap: 12px;
    row-gap: 6px;
    align-items: start;
  }
  #tab-contacts #contacts-table tr.clickable.row-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    background: var(--paper);
  }
  #tab-contacts #contacts-table td {
    border: none;
    padding: 0;
    background: transparent;
  }
  /* Checkbox cell anchored to the top-left */
  #tab-contacts #contacts-table td.col-select {
    width: auto;
    grid-row: 1 / 4;
    padding-top: 2px;
    padding-left: 0;
  }
  /* Name in larger type, top of card */
  #tab-contacts #contacts-table td:nth-of-type(2) {
    font-size: 16px;
    font-weight: 500;
    grid-column: 2;
    grid-row: 1;
    line-height: 1.3;
  }
  /* Email */
  #tab-contacts #contacts-table td:nth-of-type(3) {
    grid-column: 2;
    grid-row: 2;
    color: var(--muted);
    font-size: 13px;
  }
  #tab-contacts #contacts-table td:nth-of-type(3):empty { display: none; }
  /* Company */
  #tab-contacts #contacts-table td:nth-of-type(4) {
    grid-column: 2;
    grid-row: 3;
    color: var(--muted);
    font-size: 13px;
  }
  #tab-contacts #contacts-table td:nth-of-type(4):empty { display: none; }
  /* Source + Tags share a meta line */
  #tab-contacts #contacts-table td:nth-of-type(5),
  #tab-contacts #contacts-table td:nth-of-type(6) {
    grid-column: 2;
    grid-row: 4;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  #tab-contacts #contacts-table td:nth-of-type(5):empty,
  #tab-contacts #contacts-table td:nth-of-type(6):empty { display: none; }

  /* The add-contact card collapses to a single column on mobile */
  .contact-add-grid { grid-template-columns: 1fr; }

  /* The bulk bar wraps */
  .bulk-bar { flex-wrap: wrap; row-gap: 6px; padding: 8px 12px; }
  .bulk-bar .bulk-count { width: 100%; }

  /* E. Compact header on mobile — strip "ADMIN" crumb, shrink logo, tighter padding */
  .app > header { padding: 8px 14px; }
  .app > header #me { display: none; }
  .app > header h1 .divider,
  .app > header h1 .crumb { display: none; }
  .app > header h1 img { height: 22px; }
  .app > header button.ghost { padding: 4px 10px; font-size: 10px; letter-spacing: 0.1em; }

  /* Tabs scroll horizontally rather than overflowing */
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding: 0 16px; }
  .tabs button { white-space: nowrap; padding: 14px 14px; }

  /* B. Time quick-start: stack vertically. Description, contact, START. */
  .time-quick {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .time-quick button { padding: 14px; font-size: 13px; }

  /* Section h2 a touch smaller so the title + action row fit one line */
  .tab h2 { font-size: 24px; margin-bottom: 16px; }
  .tab { padding: 18px 16px; }
}

/* ---------- Add-contact card ---------- */
.contact-add-card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 18px 20px;
  margin-bottom: 16px;
  border-radius: 2px;
}
.contact-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin-bottom: 14px;
}
.contact-add-card .inline-field input {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 9px 11px;
  font: inherit; font-size: 14px;
  border-radius: 2px;
}
.contact-add-card .inline-field input:focus { outline: none; border-color: var(--accent); }
.contact-add-actions {
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ---------- Contacts bulk selection ---------- */
th.col-select, td.col-select {
  width: 32px;
  text-align: center;
  padding-left: 14px;
  padding-right: 4px;
}
#select-all,
td.col-select input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  width: 14px; height: 14px;
}
tr.row-selected { background: var(--highlight); }
tr.row-selected:hover { background: rgba(160, 38, 30, 0.10); }

.bulk-bar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--fg);
  color: var(--bg);
  padding: 10px 16px;
  margin-bottom: 12px;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.bulk-bar .ghost {
  color: var(--bg);
  border-color: rgba(255,255,255,0.25);
  background: transparent;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 6px 12px;
}
.bulk-bar .ghost:hover { border-color: var(--bg); color: var(--bg); background: rgba(255,255,255,0.06); }
.bulk-bar .ghost[style*="danger"]:hover { color: #ffb0a8 !important; border-color: #ffb0a8 !important; }
.bulk-count {
  font-size: 12px;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.bulk-count #bulk-selected-count { color: var(--accent); }

.bulk-popover {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: 2px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}
.bulk-popover-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 500;
}
.bulk-popover input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 9px 11px;
  font: inherit; font-size: 14px;
  border-radius: 2px;
}
.bulk-popover input:focus { outline: none; border-color: var(--accent); }
.bulk-popover-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 12px;
}

/* ---------- Activity feed ---------- */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.activity-day-head {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}
.activity-day-head:first-child { margin-top: 0; }
.activity-item {
  display: grid;
  grid-template-columns: 64px 24px 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--paper); }
.activity-time {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.activity-user .user-badge { margin-top: -2px; }
.activity-text { color: var(--fg); line-height: 1.5; }
.activity-text .ent {
  color: var(--accent);
  font-weight: 500;
}
.activity-text .muted { color: var(--muted); }
.activity-action {
  display: inline-block;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  padding: 1px 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 6px;
  border-radius: 2px;
}
.activity-restore {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font: inherit; font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  cursor: pointer;
  border-radius: 2px;
}
.activity-restore:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Tag chip input ---------- */
.tag-input { position: relative; }
.tag-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 4px 6px;
  border-radius: 2px;
  min-height: 36px;
  align-items: center;
}
.tag-chips:focus-within { border-color: var(--accent); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--fg);
  padding: 3px 4px 3px 8px;
  border-radius: 2px;
  line-height: 1.2;
}
.tag-chip .tag-remove {
  background: transparent; border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
  border-radius: 2px;
}
.tag-chip .tag-remove:hover { color: var(--accent); background: rgba(160,38,30,0.08); }
.tag-input-field {
  flex: 1; min-width: 120px;
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 4px 4px;
  font: inherit;
  font-size: 13px;
}
.tag-input-field:focus { outline: none; }
.tag-input-field::placeholder { color: var(--muted); }
.tag-dropdown {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14);
  max-height: 200px;
  overflow-y: auto;
  z-index: 40;
  border-radius: 2px;
}
.tag-suggestion {
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
}
.tag-suggestion:last-child { border-bottom: none; }
.tag-suggestion.active { background: var(--bg); color: var(--accent); }

/* ---------- Combobox (typeahead picker) ---------- */
.combobox { position: relative; }
.combobox-input {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 12px 14px;
  font: inherit; font-size: 15px;
  border-radius: 2px;
}
.combobox-input:focus { outline: none; border-color: var(--accent); }
.combobox-input::placeholder { color: var(--muted); }
.combobox-dropdown {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14);
  max-height: 280px;
  overflow-y: auto;
  z-index: 40;
  border-radius: 2px;
}
.combobox-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.combobox-item:last-child { border-bottom: none; }
.combobox-item.active { background: var(--bg); }
.combobox-label { color: var(--fg); }
.combobox-sublabel {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-align: right;
  flex-shrink: 0;
}
.combobox-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Smaller variant in modal contexts (where padding around fields is tighter) */
.inline-field .combobox-input,
.inline-field .combobox .combobox-input {
  padding: 9px 11px;
  font-size: 14px;
  background: var(--bg);
}

/* ---------- Recent chips (above time quick-start) ---------- */
.recent-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.recent-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
  font-weight: 500;
}
.recent-chip {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.1s, color 0.1s;
  max-width: 320px;
  display: inline-flex; align-items: center; gap: 8px;
}
.recent-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.recent-chip-desc {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-chip-contact {
  color: var(--muted);
  font-size: 11px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}
.recent-chip:hover .recent-chip-contact { color: var(--accent); opacity: 0.7; }

/* ---------- Duration row (manual entry) ---------- */
.duration-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center;
}
.duration-row input {
  flex: 1; min-width: 140px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); padding: 9px 11px; font: inherit; font-size: 14px;
  border-radius: 2px;
}
.duration-row input:focus { outline: none; border-color: var(--accent); }
.duration-chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 5px 10px;
  font: inherit; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500;
  cursor: pointer;
  border-radius: 2px;
}
.duration-chip:hover { border-color: var(--accent); color: var(--accent); }
.duration-preview {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ---------- Time tab ---------- */
.time-quick {
  display: grid; grid-template-columns: 1fr 220px auto; gap: 10px;
  margin-bottom: 24px; align-items: stretch;
}
.time-quick input, .time-quick select {
  background: var(--paper); border: 1px solid var(--line);
  color: var(--fg); padding: 12px 14px; font: inherit; font-size: 15px;
}
.time-quick input:focus, .time-quick select:focus {
  outline: none; border-color: var(--accent);
}
.time-quick input::placeholder { color: var(--muted); }
.time-quick button { padding: 12px 28px; }
.time-quick.running button { background: var(--accent); }

.time-day-group { margin-bottom: 20px; }
.time-day-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 14px;
  background: var(--paper); border: 1px solid var(--line);
  border-bottom: none;
  font-size: 13px;
}
.time-day-head .day-label {
  font-size: 14px; font-weight: 600; color: var(--fg);
  letter-spacing: -0.01em;
}
.time-day-head .day-total {
  color: var(--muted); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.time-entries {
  border: 1px solid var(--line);
  background: var(--paper);
}
.time-entry {
  display: grid;
  grid-template-columns: 1fr 200px 100px 140px 28px;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer; align-items: center;
  transition: background 0.08s;
}
.time-entry:last-child { border-bottom: none; }
.time-entry:hover { background: var(--highlight); }
.time-entry .desc { font-size: 14px; }
.time-entry .desc .empty-desc { color: var(--muted); font-style: italic; }
.time-entry .contact { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-entry .duration {
  font-variant-numeric: tabular-nums;
  color: var(--fg); font-weight: 500; font-size: 14px;
  text-align: right;
}
.time-entry .times { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.time-entry .replay {
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); padding: 4px 6px;
  font: inherit; font-size: 12px;
  cursor: pointer;
}
.time-entry .replay:hover { color: var(--accent); border-color: var(--accent); }
.time-entry.running { background: var(--highlight); }
.time-entry.running .duration { color: var(--accent); }
.time-entry.paused .duration { color: #6a635a; font-style: italic; }
.time-entry.paused .desc::after {
  content: " · paused";
  color: #6a635a; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-left: 6px;
}

.time-summary-table {
  margin-bottom: 24px;
  border: 1px solid var(--line);
}
.time-summary-table td.total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---------- Drawer: time section ---------- */
.drawer-section {
  border-top: 1px solid var(--line);
  padding-top: 18px; margin-top: 4px;
}
.drawer-section h4 {
  margin: 0 0 12px;
  font-weight: 600; font-size: 13px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}
.drawer-time-summary {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.drawer-time-summary .total {
  font-variant-numeric: tabular-nums;
  color: var(--accent); font-weight: 500;
}
.drawer-time-list {
  display: grid; gap: 6px; font-size: 13px;
}
.drawer-time-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 6px 8px;
  background: var(--bg); border: 1px solid var(--line-soft);
  cursor: pointer;
}
.drawer-time-row:hover { border-color: var(--accent); }
.drawer-time-row .meta { color: var(--muted); font-size: 11px; }
.drawer-time-row .dur { font-variant-numeric: tabular-nums; color: var(--fg); }

/* ════════════════════════════════════════════════════════════
   MOBILE OVERRIDES (must live at the end of the file so they
   beat any desktop rules defined later in source order).
   ════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* ─── Time quick-start: stack vertically ─── */
  .time-quick {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 16px;
  }
  .time-quick button { padding: 14px; font-size: 13px; }
  /* The header timer indicator can wrap to a second line on tiny screens */
  .timer-indicator { flex-wrap: wrap; row-gap: 4px; }

  /* ─── Search-wrap: wrap the row, keep Filter visible ─── */
  .search-wrap { flex-wrap: wrap; gap: 8px; }
  .search-wrap input { flex: 1 1 100%; min-width: 0; }
  .search-wrap .count { font-size: 11px; }
  #save-search-btn { display: none; }   /* moves into the kebab on mobile in a future pass */

  /* ─── Recent chips row scrolls horizontally ─── */
  .recent-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .recent-chips .recent-chip { flex-shrink: 0; }

  /* ─── Time entries: card layout per row ─── */
  .time-entry {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "desc duration"
      "contact times"
      "actions actions";
    row-gap: 4px;
    column-gap: 10px;
    padding: 12px 14px;
  }
  .time-entry .desc      { grid-area: desc; font-size: 14px; }
  .time-entry .duration  { grid-area: duration; text-align: right; }
  .time-entry .contact   { grid-area: contact; font-size: 12px; }
  .time-entry .times     { grid-area: times; text-align: right; font-size: 11px; }
  .time-entry .replay    { grid-area: actions; justify-self: end; }

  /* ─── Generic table → card. Applies to leads/deals/users/team tables ─── */
  #tab-leads table thead,
  #tab-deals table thead,
  #tab-users table thead,
  #tab-team-time table thead { display: none; }

  #tab-leads table, #tab-leads tbody, #tab-leads tr,
  #tab-deals table, #tab-deals tbody, #tab-deals tr,
  #tab-users table, #tab-users tbody, #tab-users tr,
  #tab-team-time table, #tab-team-time tbody, #tab-team-time tr {
    display: block;
    width: 100%;
  }
  #tab-leads tr, #tab-deals tr, #tab-users tr, #tab-team-time tr {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  #tab-leads td, #tab-deals td, #tab-users td, #tab-team-time td {
    display: block;
    border: none;
    padding: 2px 0;
    font-size: 13px;
  }
  /* Add small "label" prefixes for the table-as-card rows, useful for context */
  #tab-leads td:nth-of-type(1)::before { content: "When · "; color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
  #tab-leads td:nth-of-type(2)         { font-size: 15px; font-weight: 500; margin-top: 2px; }
  #tab-leads td:nth-of-type(5)::before { content: "Message · "; color: var(--muted); font-size: 11px; letter-spacing: 0.04em; display: block; margin-top: 4px; }

  /* ─── Team time: live cards & headlines should stack ─── */
  .team-live { grid-template-columns: 1fr; }
  .team-tables { grid-template-columns: 1fr; }
  .team-headline { gap: 16px; }
  .team-headline-num { font-size: 20px; }

  /* ─── Board: stack columns vertically; no horizontal scrolling ─── */
  .board-scroll {
    overflow-x: hidden;
    margin: 0;
    padding: 0 0 8px;
  }
  .board {
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
  }
  .board-column {
    flex: 1 0 auto;
    width: 100%;
    max-height: none;     /* no internal scroll on mobile — let the page scroll */
  }
  .board-tiles { max-height: none; }
  /* No drag affordance on touch — clicking the header should not look grabbable */
  .board-col-head { cursor: default; }

  /* Move-to select fills the bottom of each tile, mobile-only */
  .tile-move-row {
    margin-top: 8px;
    border-top: 1px dashed var(--line-soft);
    padding-top: 6px;
  }
  .tile-move-select {
    width: 100%;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 2px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236B6560' d='M0 0l5 6 5-6z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 22px;
  }
  .tile-move-select:focus { outline: none; border-color: var(--accent); }
  /* "Move ↗" is the prompt option — render placeholder color */
  .tile-move-select option:first-child { color: var(--muted); }

  /* ─── Drawer becomes a bottom-sheet on mobile ─── */
  .drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 88vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }
  .drawer.open { transform: translateY(0); }

  /* ─── Modals: less padding, fill width ─── */
  .modal { padding: 12px; }
  .modal-card { width: 100% !important; max-height: 88vh; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px; gap: 14px; }

  /* ─── Tile modal contents: stack the title row sensibly ─── */
  .tile-modal-title { font-size: 18px; }

  /* ─── Action row: prevent ADD CONTACT button stretching weirdly ─── */
  .action-row { gap: 6px; }
  .action-row .primary { flex: 1; max-width: 220px; }
}


/* ─── Stats tab (GoAccess iframe reports) ─── */
.stats-sites {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.25rem;
}
.stats-site-btn {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: flex-start;
  background: #fff;
  border: 1px solid #e4dfd4;
  border-radius: 4px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.stats-site-btn:hover:not([disabled]) { border-color: #A0261E; }
.stats-site-btn.active {
  border-color: #A0261E;
  background: #fbf6ec;
}
.stats-site-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.stats-site-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: #1c1c1a;
}
.stats-site-meta {
  font-size: 0.72rem;
  color: #6b6560;
  letter-spacing: 0.02em;
}
.stats-frame {
  width: 100%;
  height: calc(100vh - 240px);
  min-height: 520px;
  border: 1px solid #e4dfd4;
  border-radius: 4px;
  background: #fff;
}
