/* ==========================================================================
   admin.css — Cozart Consulting backend / members area
   Completely separate from style.css (public marketing site).
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */
:root {
  /* Sidebar */
  --sidebar-w:   240px;
  --sidebar-bg:  #0c1a3d;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active: rgba(255,255,255,0.12);
  --sidebar-text: rgba(255,255,255,0.6);
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255,255,255,0.08);

  /* Content */
  --bg:          #f0f3f9;
  --bg-alt:      #e6eaf3;
  --surface:     #ffffff;
  --border:      #d0d7e6;
  --text:        #0d1117;
  --muted:       #57606a;
  --accent:      #1e3a8a;
  --grad:        linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 4px rgba(0,0,0,0.07), 0 8px 24px rgba(0,0,0,0.05);
  --shadow-lg:   0 4px 16px rgba(0,0,0,0.1), 0 16px 48px rgba(0,0,0,0.08);

  /* Danger */
  --danger:      #991b1b;
  --danger-bg:   #fef2f2;
  --danger-bd:   #fca5a5;
}

/* --- Reset & base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; margin: 0; }

/* --- Sidebar layout ------------------------------------------------------- */
/* Fixed dark sidebar — authenticated pages only.
   body:has(.app-sidebar) offsets all content with no HTML structural changes. */

.app-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  border-right: 1px solid rgba(255,255,255,0.04);
}

/* Push all body content right when sidebar exists */
body:has(.app-sidebar) {
  padding-left: var(--sidebar-w);
}

/* Sidebar brand */
.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-brand-mark {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 2px;
}
.sidebar-brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

/* Sidebar nav sections */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sidebar-section-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: 14px 20px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px 9px 16px;
  margin: 1px 10px;
  border-radius: 9px;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); font-weight: 600; }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-user {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.45);
  margin-bottom: 10px;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-signout {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: rgba(255,255,255,0.6);
  font: inherit;
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sidebar-signout:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* --- Auth pages (login, unlock — no sidebar) ------------------------------ */
body:not(:has(.app-sidebar)) {
  display: flex;
  flex-direction: column;
}
.members-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 28px; }
.auth-card .btn-primary { width: 100%; justify-content: center; margin-top: 4px; }
.unlock-details { margin-top: 24px; }
.unlock-details summary { cursor: pointer; color: var(--muted); font-size: 0.875rem; }
.unlock-details summary:hover { color: var(--text); }

/* --- Page content wrappers ------------------------------------------------ */
/* Settings / setup (narrow, stacked cards) */
.setup-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}
.setup-wrap > h1 { font-size: 1.875rem; margin-bottom: 4px; }

/* List pages (clients, companies) — full available width */
.data-page {
  padding: 36px 40px 80px;
}

/* CRM record pages (client/company detail) — full available width */
.crm-layout {
  padding: 28px 40px 80px;
}

/* Dashboard */
.dashboard-page {
  padding: 40px 40px 80px;
}

/* --- Form fields ---------------------------------------------------------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,58,138,0.12);
}
.field textarea { min-height: 110px; resize: vertical; }
.field .check { display: flex; align-items: center; gap: 10px; font-size: 0.92rem; cursor: pointer; }
.field .check input { width: auto; margin: 0; cursor: pointer; accent-color: var(--accent); }
.field .hint,
.hint,
.card-hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; line-height: 1.55; }
.field span[data-valmsg-for] { display: block; color: var(--danger); font-size: 0.83rem; margin-top: 4px; }

/* --- Buttons -------------------------------------------------------------- */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 22px;
  background: var(--grad); color: #fff; border: 0;
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.92rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: filter 0.15s, transform 0.1s;
}
.btn-primary:hover { filter: brightness(1.08); color: #fff; text-decoration: none; }
.btn-primary.inline { width: auto; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.92rem; font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s;
}
.btn-secondary:hover { border-color: var(--accent); text-decoration: none; }

.btn-small { padding: 6px 12px; font-size: 0.82rem; }

.btn-danger {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  background: var(--surface); color: var(--danger);
  border: 1px solid var(--danger-bd);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-danger:hover { background: var(--danger-bg); }

/* Toolbar / header action buttons */
.btn-new {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px;
  background: var(--grad); color: #fff; border: 0;
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.92rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: filter 0.15s;
}
.btn-new:hover { filter: brightness(1.08); }
.btn-save {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px;
  background: var(--grad); color: #fff; border: 0;
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-save:hover { filter: brightness(1.08); }
.btn-delete-rec {
  display: inline-flex; align-items: center;
  padding: 9px 16px;
  background: var(--surface); color: var(--danger);
  border: 1px solid var(--danger-bd);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-delete-rec:hover { background: var(--danger-bg); }
.btn-cancel {
  display: inline-flex; align-items: center;
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s;
}
.btn-cancel:hover { border-color: var(--muted); }

/* --- Alerts --------------------------------------------------------------- */
.alert { padding: 13px 18px; border-radius: var(--radius-sm); font-size: 0.92rem; margin-bottom: 20px; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-bd); }
.alert-info    { background: #eff6ff; color: var(--accent); border: 1px solid #bfdbfe; }

/* --- Pills ----------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; white-space: nowrap; }
.pill.ok,  .pill-green { background: #dcfce7; color: #15803d; }
.pill.off, .pill-grey  { background: #f1f5f9; color: var(--muted); }
.pill-blue             { background: #dbeafe; color: #1d4ed8; }
.pill-yellow           { background: #fef9c3; color: #a16207; }
.pill-red              { background: var(--danger-bg); color: var(--danger); }

/* --- Documents -------------------------------------------------------------- */
@font-face {
  font-family: "Dancing Script";
  src: url("/fonts/DancingScript-Regular.ttf") format("truetype");
  font-display: swap;
}
.doc-preview { line-height: 1.65; }
.doc-preview h1, .doc-preview h2, .doc-preview h3 { margin-top: 1.2em; }
.doc-preview-signature,
.doc-sign-box {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9rem;
}
.doc-sign-name-input {
  font-family: "Dancing Script", cursive;
  font-size: 2rem;
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--border);
  background: transparent;
  padding: 4px 2px;
}
.doc-sign-name-input:focus { outline: none; border-bottom-color: var(--accent); }
.doc-sign-preview-label { font-size: 0.75rem; color: var(--muted); margin-top: 6px; }

/* --- Cards ---------------------------------------------------------------- */
/* NO hover effect — that belongs to the marketing site */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin-bottom: 20px;
}
.card h2 { font-size: 1.05rem; margin-bottom: 6px; }
.card > .hint,
.card > .card-hint { margin-bottom: 20px; }

/* --- Stat grid ------------------------------------------------------------ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.stat .num { font-size: 2.25rem; font-weight: 800; line-height: 1; color: var(--accent); }
.stat .label { color: var(--muted); font-size: 0.82rem; margin-top: 6px; font-weight: 500; }

/* --- Code ----------------------------------------------------------------- */
code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.82em;
  background: var(--bg-alt);
  padding: 2px 6px;
  border-radius: 4px;
}
code.snippet {
  display: block;
  background: #0f172a;
  color: #e2e8f0;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.83rem;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.7;
}

/* --- Misc helpers --------------------------------------------------------- */
.sub, .page-sub { color: var(--muted); font-size: 0.92rem; margin: 0 0 24px; }
.muted-link { color: var(--muted); font-size: 0.88rem; }
.muted-link a { color: var(--muted); }
.muted-link a:hover { color: var(--text); }
.td-name  { font-weight: 600; }
.td-muted { color: var(--muted); }
.td-link  { color: var(--accent); }
.td-link:hover { text-decoration: underline; }

/* --- Setup tabs ----------------------------------------------------------- */
.setup-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin: 0 0 32px; }
.setup-tabs a {
  padding: 10px 18px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.92rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.setup-tabs a:hover { color: var(--text); text-decoration: none; }
.setup-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* --- Tables (settings / simple) ------------------------------------------ */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; padding: 11px 16px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  font-size: 0.76rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
table.data td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 0.93rem; }
table.data tbody tr:last-child td { border-bottom: 0; }

/* --- Page header (back link + large title + action buttons) --------------- */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-bottom: 20px; margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  gap: 20px; flex-wrap: wrap;
}
.page-header-left { display: flex; flex-direction: column; gap: 5px; }
.page-header h1 { font-size: 1.875rem; }
.page-back {
  color: var(--muted); font-size: 0.85rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
}
.page-back:hover { color: var(--text); text-decoration: none; }
.page-header-actions { display: flex; gap: 10px; align-items: center; padding-bottom: 4px; }

/* --- List page toolbar (search + new button) ------------------------------ */
.data-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.data-toolbar-left { display: flex; align-items: center; gap: 14px; }
.data-toolbar-left h1 { font-size: 1.875rem; }
.data-count {
  font-size: 0.8rem; color: var(--muted); font-weight: 600;
  background: var(--bg-alt); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 999px;
}
.data-toolbar-right { display: flex; align-items: center; gap: 10px; }

.search-box { position: relative; display: flex; align-items: center; }
.search-box-icon { position: absolute; left: 11px; pointer-events: none; color: var(--muted); width: 16px; height: 16px; }
.search-input {
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.92rem;
  background: var(--surface); color: var(--text);
  width: 260px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,58,138,0.12); }

/* --- Enterprise list table (clickable rows) ------------------------------- */
.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
table.data-ent { width: 100%; border-collapse: collapse; }
table.data-ent th {
  text-align: left; padding: 12px 20px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  font-size: 0.72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap;
}
table.data-ent td {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  font-size: 0.93rem; vertical-align: middle;
}
table.data-ent tbody tr:last-child td { border-bottom: 0; }
table.data-ent tbody tr { cursor: pointer; transition: background 0.1s; }
table.data-ent tbody tr:hover { background: #f8faff; }

.data-empty { padding: 64px 24px; text-align: center; color: var(--muted); }
.data-empty p { margin: 0 0 6px; font-size: 0.95rem; }
.data-empty .hint { font-size: 0.87rem; margin: 0; }

/* --- Modal/dialog --------------------------------------------------------- */
dialog.modal {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 480px; width: calc(100% - 40px);
}
dialog.modal::backdrop { background: rgba(8,12,22,0.5); backdrop-filter: blur(4px); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 1.1rem; }
.modal-close {
  background: none; border: 0;
  font-size: 1.5rem; line-height: 1; cursor: pointer;
  color: var(--muted); padding: 2px 8px; border-radius: 6px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px 24px; }
.modal-body .field { margin-bottom: 16px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* --- CRM record layout ---------------------------------------------------- */
.crm-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-bottom: 20px; margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  gap: 20px; flex-wrap: wrap;
}
.crm-back {
  color: var(--muted); font-size: 0.87rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 6px;
}
.crm-back:hover { color: var(--text); text-decoration: none; }
.crm-header-left { display: flex; flex-direction: column; }
.crm-header-title { font-size: 1.875rem; font-weight: 800; }
.crm-header-actions { display: flex; gap: 10px; align-items: center; padding-bottom: 4px; }

/* Two-column record body */
.crm-body {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  align-items: start;
}
/* Grid items refuse to shrink below their content's min size by default, so a wide
   table inside the tabs card would push the whole column (details card included) past
   the viewport instead of scrolling inside its .table-scroll wrapper. */
.crm-body > * { min-width: 0; }
.crm-sidebar {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 24px;
}

/* Identity card (gradient header + form) */
.crm-contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.crm-contact-head {
  background: var(--grad);
  padding: 24px 24px 20px;
  display: flex; align-items: center; gap: 18px;
}
.crm-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.18); border: 2px solid rgba(255,255,255,0.4);
  color: #fff; font-size: 1.4rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.crm-avatar.square { border-radius: 14px; }
.crm-contact-head-info h2 { color: #fff; font-size: 1.15rem; font-weight: 700; word-break: break-word; }
.crm-contact-head-info .crm-meta-pill { color: rgba(255,255,255,0.6); font-size: 0.82rem; margin-top: 4px; }

.crm-form-fields { padding: 20px 22px 0; }
.crm-field { margin-bottom: 14px; }
.crm-field:last-child { margin-bottom: 0; }
.crm-field label {
  display: block; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 5px;
}
.crm-field input,
.crm-field select,
.crm-field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.92rem; background: var(--bg); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.crm-field input:focus,
.crm-field select:focus,
.crm-field textarea:focus {
  outline: none; border-color: var(--accent);
  background: var(--surface); box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.crm-field textarea { min-height: 88px; resize: vertical; }
.crm-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.crm-form-footer { padding: 14px 22px 20px; }

/* Right column (activity / clients list) */
.crm-activity { display: flex; flex-direction: column; gap: 12px; }

/* Note composer */
.note-composer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.note-composer-body { padding: 16px 20px 0; }
.note-composer textarea {
  width: 100%; border: 0; padding: 0;
  font: inherit; font-size: 0.95rem; background: transparent; color: var(--text);
  resize: none; outline: none; min-height: 80px; line-height: 1.6; display: block;
}
.note-composer-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; border-top: 1px solid var(--border); margin-top: 12px; background: var(--bg);
}
.note-subject-inp {
  border: 0; background: transparent; font: inherit; font-size: 0.88rem;
  color: var(--text); outline: none; flex: 1; min-width: 0; padding: 0;
}
.note-subject-inp::placeholder { color: var(--border); }
.btn-add-note {
  padding: 7px 16px; background: var(--grad); color: #fff; border: 0;
  border-radius: var(--radius-sm); font: inherit; font-size: 0.87rem; font-weight: 600;
  cursor: pointer; flex-shrink: 0; transition: filter 0.15s;
}
.btn-add-note:hover { filter: brightness(1.08); }

/* Timeline */
.timeline-empty {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); font-size: 0.92rem;
}
.timeline-entry {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.timeline-entry-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.timeline-entry-left { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.timeline-icon { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.timeline-icon.t-note { background: #dbeafe; color: #1d4ed8; }
.timeline-icon.t-form { background: #dcfce7; color: #15803d; }
.timeline-icon.t-fail { background: #fee2e2; color: #b91c1c; }
.timeline-subject { font-weight: 600; font-size: 0.92rem; }
.timeline-time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; flex-shrink: 0; }
.timeline-body { color: var(--muted); font-size: 0.9rem; white-space: pre-wrap; line-height: 1.6; margin-top: 10px; }
.timeline-del {
  background: none; border: 1px solid transparent; border-radius: 6px;
  cursor: pointer; color: transparent; padding: 3px 8px; font: inherit; font-size: 0.82rem;
  transition: all 0.12s; flex-shrink: 0;
}
.timeline-entry:hover .timeline-del { color: var(--muted); border-color: var(--border); }
.timeline-del:hover { border-color: var(--danger-bd) !important; color: var(--danger) !important; background: var(--danger-bg); }

/* Company clients right-column list */
.crm-clients-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.crm-clients-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-size: 0.76rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); background: var(--bg);
}
.crm-client-row {
  display: flex; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s;
  text-decoration: none;
}
.crm-client-row:last-child { border-bottom: 0; }
.crm-client-row:hover { background: #f8faff; text-decoration: none; }
.crm-client-row-name { font-weight: 600; font-size: 0.93rem; color: var(--text); flex: 1; }
.crm-client-row-meta { color: var(--muted); font-size: 0.85rem; }
.crm-clients-empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 0.9rem; line-height: 1.6; }

/* --- Dashboard ------------------------------------------------------------ */
.dashboard-welcome { margin-bottom: 32px; }
.dashboard-welcome h1 { font-size: 2rem; font-weight: 800; margin-bottom: 6px; }
.dashboard-welcome p { color: var(--muted); font-size: 0.95rem; margin: 0; }

/* Two-column dashboard layout */
.dashboard-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

/* Quick-nav card column */
.dashboard-quicknav { display: flex; flex-direction: column; gap: 10px; }
.dash-nav-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
  text-decoration: none; color: var(--text);
}
.dash-nav-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(30,58,138,0.1);
  text-decoration: none; color: var(--text);
}
.dash-nav-card-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  background: rgba(30,58,138,0.08); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.dash-nav-card > div:nth-child(2) { flex: 1; min-width: 0; }
.dash-nav-card-title { font-size: 0.95rem; font-weight: 600; line-height: 1.3; }
.dash-nav-card-sub { font-size: 0.8rem; color: var(--muted); margin-top: 1px; }
.dash-nav-card-arrow { color: var(--border); flex-shrink: 0; transition: color 0.15s; }
.dash-nav-card:hover .dash-nav-card-arrow { color: var(--accent); }

/* Notification panel */
.notif-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.notif-panel-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
}
.notif-panel-viewall {
  font-size: 0.82rem; font-weight: 500; color: var(--accent);
}
.notif-panel-viewall:hover { text-decoration: underline; }

/* Feed items */
.notif-feed { display: flex; flex-direction: column; }
.notif-empty {
  padding: 48px 24px;
  text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center;
}
.notif-empty p { margin: 0 0 4px; font-size: 0.92rem; }
.notif-empty .hint { font-size: 0.84rem; margin: 0; }

.notif-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: #f8faff; }

.notif-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  background: #dbeafe; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #1d4ed8;
}
.notif-content { flex: 1; min-width: 0; }
.notif-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 3px; flex-wrap: wrap;
}
.notif-form-name { font-weight: 600; font-size: 0.92rem; }
.notif-new-pill {
  font-size: 0.68rem; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; background: #dbeafe; color: #1d4ed8;
  text-transform: uppercase; letter-spacing: 0.06em; flex-shrink: 0;
}
.notif-time { font-size: 0.8rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.notif-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.notif-client-link { font-size: 0.87rem; font-weight: 500; color: var(--accent); }
.notif-client-link:hover { text-decoration: underline; }
.notif-submitter { font-size: 0.87rem; color: var(--text); font-weight: 500; }
.notif-email { font-size: 0.87rem; color: var(--muted); }
.notif-anon { font-size: 0.87rem; color: var(--muted); font-style: italic; }
.notif-sep { color: var(--border); font-size: 0.9rem; }
.notif-open {
  flex-shrink: 0; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--border);
  transition: background 0.12s, color 0.12s;
}
.notif-item:hover .notif-open { color: var(--muted); background: var(--bg-alt); }
.notif-open:hover { color: var(--accent) !important; background: #dbeafe !important; }

/* Failed payments panel — sits above the two-column layout, full width */
.failed-payments-panel { margin-bottom: 24px; }
.failed-payment-icon { background: #fee2e2; color: #dc2626; }
.failed-pill-warn { background: #fef3c7; color: #b45309; }
.failed-pill { background: #fee2e2; color: #dc2626; }
.failed-payment-item.threshold-reached { background: #fef2f2; }
.failed-payment-item.threshold-reached:hover { background: #fee2e2; }
.billing-off-pill { flex-shrink: 0; }

/* --- Mobile top nav (shown ≤900px, replaces sidebar) ---------------------- */
/* Hamburger + dropdown menu. CSS-only via hidden checkbox; the menu closes
   automatically because every link is a full page navigation. */
.mobile-nav {
  display: none;
  background: var(--sidebar-bg);
  position: sticky;
  top: 0;
  z-index: 200;
}
.mobile-menu-cb { position: absolute; opacity: 0; pointer-events: none; }
.mobile-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 8px 0 16px;
}
.mobile-nav-brand {
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  white-space: nowrap;
}
.mobile-menu-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.85);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.12s;
}
.mobile-menu-btn:active { background: var(--sidebar-hover); }
.mobile-menu-btn .icon-close { display: none; }
.mobile-menu-cb:checked ~ .mobile-nav-bar .icon-burger { display: none; }
.mobile-menu-cb:checked ~ .mobile-nav-bar .icon-close { display: block; }

/* Tap anywhere outside the open menu to close it */
.mobile-menu-backdrop { display: none; }
.mobile-menu-cb:checked ~ .mobile-menu-backdrop {
  display: block;
  position: fixed;
  inset: 54px 0 0 0;
  background: rgba(8,12,22,0.4);
}

.mobile-menu {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--sidebar-border);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  padding: 8px 10px 14px;
  max-height: calc(100vh - 54px);
  overflow-y: auto;
}
.mobile-menu-cb:checked ~ .mobile-menu { display: block; }
.mobile-menu a {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 14px;
  border-radius: 9px;
  color: var(--sidebar-text);
  font-size: 0.95rem;
  font-weight: 500;
}
.mobile-menu a:hover { text-decoration: none; color: var(--sidebar-text-active); }
.mobile-menu a.active { background: var(--sidebar-active); color: var(--sidebar-text-active); font-weight: 600; }
.mobile-menu .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.mobile-menu-section {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: 14px 14px 5px;
}
.mobile-menu-signout {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 9px;
  color: rgba(255,255,255,0.6);
  font: inherit;
  font-size: 0.9rem;
  text-align: center;
  cursor: pointer;
}
.mobile-menu-user {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  padding: 12px 14px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Reports --------------------------------------------------------------- */
.report-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
}
.report-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.12s;
  white-space: nowrap;
}
.report-tabs a:hover { color: var(--text); text-decoration: none; }
.report-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Revenue stat cards */
.report-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.report-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.report-stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 8px;
}
.report-stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}
.report-stat-sub { font-size: 0.82rem; color: var(--muted); }
.report-yoy { font-weight: 600; }
.report-yoy.up   { color: #15803d; }
.report-yoy.down { color: var(--danger); }

/* Report sections */
.report-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.report-section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.report-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.report-section-sub { font-size: 0.82rem; color: var(--muted); }
.report-empty { padding: 32px 24px; text-align: center; color: var(--muted); font-size: 0.9rem; }

/* Bar chart */
.bar-chart { padding: 20px 24px; display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 120px; align-items: center; gap: 14px; }
.bar-label { font-size: 0.8rem; color: var(--muted); text-align: right; white-space: nowrap; }
.bar-track { background: var(--bg-alt); border-radius: 6px; height: 32px; overflow: hidden; }
.bar-fill { background: var(--grad); height: 100%; border-radius: 6px; min-width: 3px; transition: width 0.4s ease; }
.bar-meta { display: flex; flex-direction: column; gap: 1px; }
.bar-value { font-size: 0.88rem; font-weight: 700; }
.bar-count { font-size: 0.75rem; color: var(--muted); }

/* Export bar */
.report-export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

/* Report date-range filter bar */
.report-filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.report-filter-field { display: flex; flex-direction: column; gap: 6px; }
.report-filter-field label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}
.report-filter-field input[type="date"] {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.report-filter-field input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,58,138,0.12);
}
.report-filter-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.report-filter-actions .btn-cancel,
.report-filter-actions .btn-new { margin: 0; }

/* --- Company record tabs -------------------------------------------------- */
.crm-tabs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.crm-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  padding: 0 20px;
  background: var(--bg);
}
.crm-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 13px 16px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.12s;
  white-space: nowrap;
}
.crm-tabs a:hover { color: var(--text); text-decoration: none; }
.crm-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.crm-tab-badge {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  color: var(--muted);
}
.crm-tabs a.active .crm-tab-badge { background: rgba(30,58,138,0.1); border-color: rgba(30,58,138,0.2); color: var(--accent); }
.crm-tab-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.crm-tab-empty p { margin: 0 0 4px; font-size: 0.92rem; }
.crm-tab-empty .hint { font-size: 0.84rem; margin: 0; }

/* Assign-product bar (products tab) */
.crm-tab-assign-bar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.crm-assign-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.crm-assign-select {
  flex: 1;
  min-width: 200px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
}
.crm-assign-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,58,138,0.1); }
.crm-assign-qty {
  width: 70px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}
.crm-assign-qty:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,58,138,0.1); }
.crm-assign-price {
  width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
}
.crm-assign-price:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,58,138,0.1); }

/* Products table inside company record */
.crm-products-table { width: 100%; border-collapse: collapse; }
.crm-products-table th {
  text-align: left;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}
.crm-products-table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}
.crm-products-table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.crm-products-total td {
  padding: 12px 20px;
  background: var(--bg);
  font-size: 0.92rem;
}

/* Invoice placeholder */
.crm-invoice-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
  max-width: 380px;
}
.crm-invoice-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  color: var(--muted);
}

/* --- Billing tab (company record) ----------------------------------------- */
.billing-pane { display: flex; flex-direction: column; }
.billing-banner {
  background: #fef9e7;
  border: 1px solid #f6e3a1;
  color: #8a6d1a;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  margin: 16px 20px 0;
  line-height: 1.5;
}
.billing-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.billing-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}
.billing-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.billing-card-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}
.billing-card-info svg { color: var(--muted); }

/* --- Payment result card (checkout return) -------------------------------- */
.payment-result-card {
  max-width: 460px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  text-align: center;
}
.payment-result-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.payment-result-card.ok .payment-result-icon   { background: #dcfce7; color: #15803d; }
.payment-result-card.fail .payment-result-icon { background: var(--danger-bg); color: var(--danger); }
.payment-result-card h1 { font-size: 1.4rem; margin-bottom: 8px; }
.payment-result-card p { color: var(--muted); font-size: 0.95rem; margin: 0 0 24px; }
.payment-result-card .btn-primary { display: inline-flex; }

/* --- Responsive ----------------------------------------------------------- */

/* Horizontal-scroll wrapper for wide tables inside cards/tabs (the parent
   card has overflow:hidden, which would otherwise clip them). */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Mobile toggle that collapses the CRM details form (hidden on desktop) */
.crm-details-cb { position: absolute; opacity: 0; pointer-events: none; }
.crm-details-toggle { display: none; }

@media (max-width: 900px) {
  /* Sidebar → mobile nav */
  :root { --sidebar-w: 0px; }
  .app-sidebar { display: none; }
  .mobile-nav { display: flex; }
  body:has(.app-sidebar) { padding-left: 0; }

  /* Layout adjustments */
  .crm-body { grid-template-columns: 1fr; }
  .crm-sidebar { position: static; }
  .crm-field-row { grid-template-columns: 1fr; }
  .crm-header { flex-direction: column; align-items: flex-start; }
  .crm-header-actions { width: 100%; justify-content: flex-end; }

  /* Collapse the details form behind a toggle so tabs/activity are reachable
     without scrolling past the whole form */
  .crm-details-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 22px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
  }
  .crm-details-toggle::after {
    content: "▾";
    color: var(--muted);
    transition: transform 0.15s;
  }
  .crm-details-cb:checked ~ .crm-details-toggle { border-bottom: 1px solid var(--border); }
  .crm-details-cb:checked ~ .crm-details-toggle::after { transform: rotate(180deg); }
  .crm-details-cb:not(:checked) ~ form { display: none; }
  .crm-contact-head { padding: 18px 20px 16px; }

  /* Tab strip scrolls instead of wrapping/overflowing */
  .crm-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .crm-tabs::-webkit-scrollbar { display: none; }

  /* Prevent iOS zoom-on-focus (fires when inputs are under 16px) */
  .field input, .field select, .field textarea,
  .crm-field input, .crm-field select, .crm-field textarea,
  .crm-assign-select, .crm-assign-qty, .crm-assign-price,
  .search-input, .note-composer textarea, .note-subject-inp {
    font-size: 16px;
  }

  /* Touch devices have no hover — keep row delete buttons visible */
  .timeline-del { color: var(--muted); border-color: var(--border); }

  /* Wide tables inside tabs scroll rather than squish */
  .table-scroll > table { min-width: 560px; }

  /* Settings tables scroll inside their card */
  table.data { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Timeline / people rows wrap instead of overflowing */
  .timeline-entry-top { flex-wrap: wrap; }
  .crm-client-row { flex-wrap: wrap; }

  /* Padding scale-down */
  .setup-wrap  { padding: 20px 16px 48px; }
  .data-page   { padding: 20px 16px 48px; }
  .crm-layout  { padding: 16px 16px 48px; }
  .dashboard-page { padding: 20px 16px 48px; }

  /* Dashboard */
  .dashboard-layout { grid-template-columns: 1fr; }

  /* Reports */
  .report-stats { grid-template-columns: 1fr 1fr; }
  .report-tabs  { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .report-tabs a { padding: 10px 14px; font-size: 0.84rem; }
  .bar-row { grid-template-columns: 70px 1fr 90px; gap: 8px; }

  /* Tables — horizontal scroll on small screens */
  .data-table-wrap { overflow-x: auto; }
  .report-section  { overflow-x: auto; }

  /* List toolbar stack */
  .data-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .data-toolbar-left h1 { font-size: 1.5rem; }
  .data-toolbar-right { justify-content: space-between; }
  .search-input { flex: 1; width: auto; min-width: 0; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header-actions { width: 100%; justify-content: flex-end; }

  /* Cards */
  .card { padding: 18px 18px; }

  /* Assign bar */
  .crm-assign-form { flex-direction: column; align-items: stretch; }
  .crm-assign-select, .crm-assign-qty, .crm-assign-price { width: 100%; }
}

/* List tables (opted in with .data-ent--cards) become stacked cards on
   phones: each row is one tappable card, cells get their column label. */
@media (max-width: 700px) {
  .data-table-wrap:has(.data-ent--cards) {
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }
  table.data-ent--cards,
  table.data-ent--cards tbody,
  table.data-ent--cards tr,
  table.data-ent--cards td { display: block; }
  table.data-ent--cards thead { display: none; }
  table.data-ent--cards tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    padding: 6px 0 12px;
  }
  table.data-ent--cards td {
    border-bottom: 0;
    padding: 4px 16px;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
  }
  table.data-ent--cards td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
  }
  table.data-ent--cards td.td-name {
    display: block;
    font-size: 1.02rem;
    padding: 12px 16px 6px;
  }
  table.data-ent--cards td.td-name::before { content: none; }
}

@media (max-width: 540px) {
  .report-stats { grid-template-columns: 1fr; }
  .report-stat-value { font-size: 1.6rem; }
  .crm-tabs { padding: 0 12px; }
  .modal-body, .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .auth-card { padding: 24px 20px; }
  .bar-row { grid-template-columns: 60px 1fr; }
  .bar-meta { display: none; }
  .dashboard-quicknav .dash-nav-card-sub { display: none; }
}
@media (max-width: 600px) {
  .data-toolbar { flex-direction: column; align-items: stretch; }
  .data-toolbar-right { justify-content: space-between; }
  .search-input { flex: 1; width: auto; }
  .data-toolbar-left h1 { font-size: 1.5rem; }
  .crm-header-title { font-size: 1.4rem; }
}
