/* ============================================================
   Inventive Media CRM — Design System
   Tokens pulled directly from https://inventivemedia.agency/assets/css/styles.css
   ============================================================ */

:root {
  --cream: #F5F0E8;
  --dark: #2C1A0E;
  --burgundy: #3D0C0C;
  --gold: #C4A44A;
  --gold-light: #D4B96A;
  --text-muted: #6B5B5B;
  --border: rgba(61, 12, 12, 0.12);
  --white: #FFFFFF;
  --card-bg: #FAF7F2;

  --success: #2E7D32;
  --success-bg: #E8F3E8;
  --danger: #B3261E;
  --danger-bg: #FBE9E7;
  --warn: #9A6B00;
  --warn-bg: #FBF1DA;
  --info: #2C5F8A;
  --info-bg: #E7F0F7;

  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;
  --font-display: 'Syne', var(--font-body);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 100px;

  --shadow-card: 0 20px 50px rgba(61, 12, 12, 0.08);
  --shadow-card-hover: 0 24px 60px rgba(61, 12, 12, 0.12);

  --sidebar-w: 240px;
  --topbar-h: 68px;
}

* { box-sizing: border-box; }
/* Any element using [hidden] to toggle visibility must actually hide, even
   when another rule here also sets `display` on it (e.g. .modal-overlay). */
[hidden] { display: none !important; }
html, body { height: 100%; }

/* No visible scrollbars by default (sidebar nav, modals, kanban columns,
   textareas, the page itself, etc.) — vertical scroll is always reachable
   via wheel/trackpad/touch/keys without a visible bar, so hiding it here
   just removes the ugly native OS bar with no loss of function. */
* {
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* legacy Edge/IE */
}
*::-webkit-scrollbar {
  display: none;                /* Chrome, Safari, Chromium-based Edge */
  width: 0;
  height: 0;
}

/* .table-wrap (wide tables in narrow cards) and .kanban (the pipeline board)
   scroll HORIZONTALLY by design — unlike vertical page scroll, a sideways
   scroll area isn't discoverable or mouse-draggable without a visible
   handle, so these get a slim on-brand bar instead of staying fully hidden. */
.table-wrap, .kanban {
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}
.table-wrap::-webkit-scrollbar, .kanban::-webkit-scrollbar {
  display: block;
  height: 8px;
}
.table-wrap::-webkit-scrollbar-track, .kanban::-webkit-scrollbar-track {
  background: transparent;
}
.table-wrap::-webkit-scrollbar-thumb, .kanban::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: var(--radius-pill);
}
.table-wrap::-webkit-scrollbar-thumb:hover, .kanban::-webkit-scrollbar-thumb:hover {
  background: var(--gold-light);
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 900;
  margin: 0 0 8px;
  line-height: 1.15;
  color: var(--dark);
}
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; font-weight: 700; }
h4 { font-size: 16px; font-weight: 700; }

p { line-height: 1.6; color: var(--text-muted); margin: 0 0 12px; }
a { color: inherit; }

.section-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.section-label::before {
  content: '';
  width: 24px;
  height: 2px;
  background: var(--gold);
  display: inline-block;
}

/* ============================================================
   App shell: sidebar + topbar
   ============================================================ */

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--dark);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(245, 240, 232, 0.1);
}
.sidebar-brand img { width: 34px; height: 34px; border-radius: 8px; display: block; }
.sidebar-brand span {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.2px;
  color: var(--cream);
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  color: rgba(245, 240, 232, 0.72);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: rgba(245, 240, 232, 0.08); color: var(--cream); }
.sidebar-nav a.active { background: var(--burgundy); color: var(--cream); }
.sidebar-nav .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.nav-badge {
  margin-left: auto; background: var(--gold); color: var(--dark);
  font-size: 10.5px; font-weight: 800; line-height: 1; padding: 3px 7px;
  border-radius: var(--radius-pill); flex-shrink: 0;
}
.nav-badge.nav-badge-due { background: var(--danger); color: var(--cream); }

.sidebar-footer {
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(245, 240, 232, 0.1);
  font-size: 13px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold); color: var(--dark);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 13px;
}
.sidebar-user-name { font-weight: 600; color: var(--cream); }
.sidebar-user-role { color: rgba(245, 240, 232, 0.55); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.sidebar-logout {
  display: block; text-align: center; padding: 9px; border-radius: var(--radius-pill);
  border: 1.5px solid rgba(245, 240, 232, 0.25); color: var(--cream);
  text-decoration: none; font-size: 12px; font-weight: 600;
}
.sidebar-logout:hover { background: rgba(245, 240, 232, 0.1); }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(245, 240, 232, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--dark);
}

.content { padding: 28px; flex: 1; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-card-hover); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 18px; }
  .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
  .card, .card-flat, .stat-card { padding: 18px 16px; }
  .us-map-bar-row { grid-template-columns: 88px 1fr 52px; gap: 6px; font-size: 12px; }
  .us-map-bar-row--compact { grid-template-columns: 100px 1fr 40px; }
  .modal { padding: 20px 16px; }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  .topbar h1 { font-size: 17px; }
  .stat-card .stat-value { font-size: 22px; }
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--dark); color: var(--cream); }
.btn-primary:hover { background: var(--burgundy); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--dark); border: 1.5px solid var(--dark); }
.btn-outline:hover { background: var(--dark); color: var(--cream); }
.btn-gold { background: var(--gold); color: var(--dark); }
.btn-gold:hover { background: var(--gold-light); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { opacity: 0.88; }
.btn-sm { padding: 8px 16px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-icon { padding: 10px; border-radius: 50%; }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}
.card-flat { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.card-link { display: block; text-decoration: none; color: inherit; transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.card-link:hover { box-shadow: var(--shadow-card-hover, 0 6px 20px rgba(61,12,12,0.12)); border-color: rgba(61,12,12,0.22); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-label {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 10px;
}
.stat-card .stat-value { font-family: var(--font-serif); font-size: 28px; font-weight: 900; color: var(--dark); }
.stat-card .stat-value.gold { color: var(--gold); -webkit-text-fill-color: initial; }
.stat-card .stat-value.balance-positive { color: var(--danger); }
.stat-card .stat-value.balance-zero { color: var(--success); }
.stat-card .stat-value.balance-negative { color: var(--info); }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.stat-card-link { display: block; text-decoration: none; color: inherit; border-color: var(--gold); transition: box-shadow 0.15s, transform 0.15s; }
.stat-card-link:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ============================================================
   Forms
   ============================================================ */

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-group { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], input[type="time"], input[type="month"], input[type="url"],
input[type="password"], input[type="search"], select, textarea {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.3;
  background: var(--white);
  color: var(--dark);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
/* Free-text-ish fields stretch to fill their container. */
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="password"], input[type="search"], input[type="url"], select, textarea {
  width: 100%;
}
/* Date/time pickers have a fixed natural content size — sizing them to 100%
   just stretches empty space and (in a flex row) forces each onto its own
   line, so they get a comfortable fixed-ish width instead. */
input[type="date"], input[type="time"], input[type="month"] {
  width: auto;
  min-width: 150px;
}
/* Native calendar/clock icon needs to sit on the same cream/white surface,
   not look like a separate control. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.65;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196, 164, 74, 0.15);
}
textarea { resize: vertical; min-height: 80px; font-family: var(--font-body); }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-chip {
  display: flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--border); border-radius: var(--radius-pill);
  padding: 7px 14px; font-size: 12.5px; cursor: pointer; user-select: none;
  transition: all 0.15s;
}
.checkbox-chip input { width: auto; margin: 0; }
.checkbox-chip.checked { background: var(--dark); color: var(--cream); border-color: var(--dark); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* Pill tab switcher (e.g. Invoice Email / Onboarding Email) */
.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-tab {
  border: 1.5px solid var(--border); background: var(--card-bg); color: var(--dark);
  border-radius: var(--radius-pill); padding: 10px 20px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; font-family: var(--font-body);
}
.pill-tab:hover { border-color: var(--dark); }
.pill-tab.active { background: var(--dark); color: var(--cream); border-color: var(--dark); }

.email-textarea { min-height: 340px; font-size: 14px; line-height: 1.6; }

.smtp-test-row { border-top: 1px solid var(--border); padding-top: 16px; }
.test-email-input { max-width: 280px; }
@media (max-width: 640px) { .test-email-input { max-width: 100%; } }

.readonly-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.readonly-summary-item { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.readonly-summary-item.form-full { grid-column: 1 / -1; }
.readonly-summary-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 4px; }
.readonly-summary-value { font-size: 14px; white-space: pre-wrap; }
@media (max-width: 640px) { .readonly-summary { grid-template-columns: 1fr; } }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card-bg); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
thead th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 16px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr.row-link { cursor: pointer; }
tbody tr.row-link:hover { background: rgba(196, 164, 74, 0.08); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { padding: 14px 16px; font-size: 14px; font-weight: 700; border-top: 1.5px solid var(--border); background: rgba(196, 164, 74, 0.07); }
.balance-positive { color: var(--danger); font-weight: 700; }
.balance-zero { color: var(--success); font-weight: 700; }
.balance-negative { color: var(--info); font-weight: 700; }
.rate-good { color: var(--success); font-weight: 700; }
.rate-bad { color: var(--danger); font-weight: 700; }

/* ============================================================
   "Sheet" table — a dense, gridlined data-grid look (Payment Logs) in the
   app's own branding rather than literal Google Sheets colors: every cell
   boxed, a sticky header row, tight rows, alternating stripes, a spreadsheet-
   style row-number column.
   ============================================================ */

.sheet-wrap {
  overflow: auto; max-height: calc(100vh - 340px); min-height: 320px;
  border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card-bg);
}
.sheet-table { width: 100%; border-collapse: collapse; min-width: 900px; font-size: 13px; }
.sheet-table thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--cream); color: var(--dark);
  font-family: var(--font-display); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 8px 10px; text-align: left; white-space: nowrap;
  border: 1px solid var(--border);
}
.sheet-table tbody td {
  padding: 6px 10px; border: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
}
.sheet-table tbody tr:nth-child(even) { background: rgba(61,12,12,0.025); }
.sheet-table tbody tr:hover { background: rgba(196,164,74,0.09); }
.sheet-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-table td.sheet-rownum {
  text-align: center; color: var(--text-muted); background: var(--cream);
  font-size: 11px; font-weight: 600; width: 1%;
}
.sheet-table td.sheet-ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.sheet-summary-bar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  padding: 10px 16px; border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); background: rgba(196,164,74,0.06);
  font-size: 12.5px; color: var(--text-muted);
}
.sheet-summary-bar strong { color: var(--dark); }

/* ============================================================
   Badges / status pills
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  white-space: nowrap;
}
.badge-neutral { background: rgba(61,12,12,0.08); color: var(--text-muted); }
.badge-gold { background: rgba(196,164,74,0.18); color: #8a6d1f; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-dark { background: var(--dark); color: var(--cream); }

/* Development phase progress (client detail + developer dashboard/project pages) */
.progress-bar { width: 100%; height: 8px; border-radius: var(--radius-pill); background: rgba(61,12,12,0.08); overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--gold); border-radius: var(--radius-pill); transition: width 0.3s ease; }
.dev-phase-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.dev-phase-row:last-child { border-bottom: none; }
.dev-phase-name { font-weight: 600; color: var(--dark); }
.dev-phase-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.dev-phase-status-select { min-width: 140px; }
.dev-phase-status-select.status-not_started { color: var(--text-muted); }
.dev-phase-status-select.status-in_progress { color: #8a6d1f; border-color: rgba(196,164,74,0.5); }
.dev-phase-status-select.status-done { color: var(--success); border-color: rgba(46,125,50,0.35); }

/* ============================================================
   Filters / toolbar
   ============================================================ */

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 20px; justify-content: space-between;
}
.toolbar-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; flex: 1; }
.toolbar-filters select, .toolbar-filters input { width: auto; min-width: 140px; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-box input { padding-left: 36px; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: 0.5; width: 15px; height: 15px; }

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(44, 26, 14, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  max-width: 640px; width: 100%; padding: 28px;
  box-shadow: var(--shadow-card-hover);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 760px; }

/* ============================================================
   Toasts
   ============================================================ */

.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--dark); color: var(--cream); padding: 14px 20px;
  border-radius: var(--radius-md); font-size: 13.5px; box-shadow: var(--shadow-card-hover);
  min-width: 220px; animation: toast-in 0.2s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Pipeline / Kanban
   ============================================================ */

.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  min-width: 260px; max-width: 260px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 220px);
}
.kanban-col-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.kanban-col-head h4 { margin: 0; font-size: 13px; }
.kanban-col-count {
  background: var(--dark); color: var(--cream); font-size: 11px; font-weight: 700;
  border-radius: var(--radius-pill); padding: 2px 9px;
}
.kanban-cards { padding: 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.kanban-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px; cursor: grab; box-shadow: 0 4px 10px rgba(61,12,12,0.06);
  transition: box-shadow 0.15s, transform 0.15s;
}
.kanban-card:hover { box-shadow: 0 8px 18px rgba(61,12,12,0.12); }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card .kc-name { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }
.kanban-card .kc-business { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.kanban-card .kc-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; }
.kanban-card .btn { padding: 4px 10px; }
.task-title-input { flex: 1; min-width: 180px; }
.duration-months-input { max-width: 120px; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: none; }
.task-row input[type="checkbox"] { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--gold); }
.task-row .task-title { flex: 1; font-size: 14px; }
.task-row.is-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-due { font-size: 11.5px; }
.task-due.overdue { color: var(--danger); font-weight: 700; }
.task-body { flex: 1; min-width: 0; }
.task-notes { font-size: 12px; margin-top: 2px; }
.kanban-card-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.kanban-empty { font-size: 12.5px; color: var(--text-muted); }
.kanban-col.drag-over { background: rgba(196,164,74,0.12); }

/* ============================================================
   Login page
   ============================================================ */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--dark); padding: 20px;
}
.login-card {
  background: var(--cream); border-radius: var(--radius-lg); box-shadow: var(--shadow-card-hover);
  padding: 40px; max-width: 380px; width: 100%; text-align: center;
}
.login-card img { width: 56px; height: 56px; border-radius: 12px; margin-bottom: 16px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card p.sub { margin-bottom: 24px; font-size: 13px; }
.login-card form { text-align: left; }
.login-card .btn { width: 100%; margin-top: 6px; padding: 14px; }

/* ============================================================
   Misc utilities
   ============================================================ */

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-dark { color: var(--dark); }
.flex { display: flex; }
/* wrap+gap by default so a title-plus-button header never forces its
   button past the card edge at narrow/in-between widths — it just drops
   to its own line instead of overflowing. */
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.relative { position: relative; }
.cursor-pointer { cursor: pointer; }
.fw-700 { font-weight: 700; }
.fs-12 { font-size: 12px; }
.fs-12-5 { font-size: 12.5px; }
.fs-13 { font-size: 13px; }
.shadow-none { box-shadow: none; }
.col-span-all { grid-column: 1 / -1; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { opacity: 0.35; margin-bottom: 12px; }
.loading-spinner {
  width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.7s linear infinite; margin: 30px auto; display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination button {
  border: 1px solid var(--border); background: var(--card-bg); border-radius: var(--radius-sm);
  padding: 7px 12px; cursor: pointer; font-size: 13px;
}
.pagination button.active { background: var(--dark); color: var(--cream); border-color: var(--dark); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.us-map-bars { display: flex; flex-direction: column; gap: 8px; }
.us-map-bar-row { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 10px; font-size: 13px; }
.us-map-bar-row--compact { grid-template-columns: 150px 1fr 50px; }
.us-map-bar-track { background: var(--border); border-radius: var(--radius-pill); height: 10px; overflow: hidden; }
.us-map-bar-fill { background: linear-gradient(90deg, var(--gold), var(--burgundy)); height: 100%; border-radius: var(--radius-pill); width: var(--pct, 0%); }

/* ============================================================
   Chart helpers (dashboard trend line)
   ============================================================ */

.chart-wrap { position: relative; }
.chart-svg { overflow: visible; }
.chart-tooltip {
  position: absolute; display: none; pointer-events: none; white-space: nowrap;
  transform: translate(-50%, -130%);
}
.trend-dot { cursor: pointer; }

/* ============================================================
   Attendance calendar
   ============================================================ */

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday {
  font-family: var(--font-display); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted);
  text-align: center; padding-bottom: 4px;
}
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card-bg); padding: 6px; display: flex; flex-direction: column;
  gap: 4px; position: relative;
}
.cal-cell.cal-empty { background: transparent; border: none; }
.cal-cell .cal-daynum { font-size: 12px; font-weight: 700; color: var(--dark); }
.cal-cell.cal-today { border-color: var(--gold); border-width: 2px; }
.cal-cell.cal-present { background: var(--success-bg); border-color: rgba(46,125,50,0.25); }
.cal-cell.cal-present .cal-daynum { color: var(--success); }
.cal-cell.cal-missed { background: var(--danger-bg); border-color: rgba(179,38,30,0.2); }
.cal-cell.cal-missed .cal-daynum { color: var(--danger); }
.cal-cell.cal-weekend { background: rgba(61,12,12,0.05); }
.cal-cell.cal-weekend .cal-daynum { color: var(--text-muted); }
.cal-cell .cal-time { font-size: 9.5px; color: var(--success); font-weight: 600; line-height: 1.2; }
.cal-cell .cal-mark { position: absolute; top: 4px; right: 5px; font-size: 11px; }
@media (max-width: 640px) {
  .cal-cell .cal-time { display: none; }
  .cal-grid { gap: 4px; }
}
.cal-legend-dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.cal-legend-dot.cal-present { background: var(--success-bg); border: 1px solid rgba(46,125,50,0.4); }
.cal-legend-dot.cal-missed { background: var(--danger-bg); border: 1px solid rgba(179,38,30,0.35); }
.cal-legend-dot.cal-weekend { background: rgba(61,12,12,0.08); border: 1px solid rgba(61,12,12,0.15); }

/* ============================================================
   Internal Chat
   ============================================================ */

.chat-shell {
  display: flex; gap: 20px;
  height: calc(100vh - var(--topbar-h) - 56px);
  min-height: 420px;
}

.chat-sidebar {
  width: 300px; flex-shrink: 0;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-conv-list { flex: 1; overflow-y: auto; padding: 8px; }

.chat-conv-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px; border-radius: var(--radius-md); border: none; background: none;
  cursor: pointer; margin-bottom: 2px;
}
.chat-conv-item:hover { background: rgba(61,12,12,0.05); }
.chat-conv-item.active { background: var(--burgundy); }
.chat-conv-item.active .chat-conv-title,
.chat-conv-item.active .chat-conv-preview,
.chat-conv-item.active .chat-conv-time { color: var(--cream); }
.chat-conv-item.active .chat-conv-preview { opacity: 0.75; }

.chat-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--gold); color: var(--dark);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 14px;
}
.chat-avatar.team { background: var(--burgundy); color: var(--cream); overflow: hidden; }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.chat-conv-body { flex: 1; min-width: 0; }
.chat-conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.chat-conv-title { font-weight: 700; font-size: 13.5px; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-time { font-size: 10.5px; color: var(--text-muted); flex-shrink: 0; }
.chat-conv-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.chat-conv-unread {
  background: var(--gold); color: var(--dark); font-size: 10.5px; font-weight: 800;
  min-width: 18px; height: 18px; border-radius: var(--radius-pill); padding: 0 5px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.chat-main {
  flex: 1; min-width: 0;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-thread-header { padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-thread-header h3 { margin: 0; }
.chat-back-btn { display: none; }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.chat-msg-row { display: flex; flex-direction: column; max-width: 62%; margin-bottom: 6px; }
.chat-msg-row.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg-sender { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 3px; padding: 0 4px; }
.chat-bubble {
  background: rgba(61,12,12,0.06); color: var(--dark);
  padding: 9px 13px; border-radius: 14px 14px 14px 4px;
  font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.chat-msg-row.mine .chat-bubble { background: var(--burgundy); color: var(--cream); border-radius: 14px 14px 4px 14px; }
.chat-msg-time { font-size: 10px; color: var(--text-muted); margin-top: 3px; padding: 0 4px; }

.chat-composer { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-composer textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 14px; font-family: inherit; font-size: 13.5px; line-height: 1.4; max-height: 120px;
  background: var(--white); color: var(--dark);
}
.chat-composer textarea:focus { outline: none; border-color: var(--gold); }

.chat-contact-list { max-height: 320px; overflow-y: auto; margin-top: 10px; }
.chat-contact-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 8px; border-radius: var(--radius-md); border: none; background: none; cursor: pointer;
}
.chat-contact-item:hover { background: rgba(61,12,12,0.05); }
.chat-contact-name { font-weight: 600; font-size: 13.5px; color: var(--dark); }
.chat-contact-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

@media (max-width: 760px) {
  .chat-shell { height: calc(100vh - var(--topbar-h) - 36px); gap: 0; position: relative; }
  .chat-sidebar { width: 100%; border-radius: var(--radius-lg); }
  .chat-main { position: absolute; inset: 0; }
  .chat-shell.thread-open .chat-sidebar { display: none; }
  .chat-shell:not(.thread-open) .chat-main { display: none; }
  .chat-msg-row { max-width: 85%; }
  .chat-back-btn { display: inline-flex; margin-bottom: 10px; }
}
