/* Dark is the default; [data-theme="light"] overrides the palette. */
:root,
:root[data-theme="dark"] {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232c;
  --text: #e7e9ee;
  --muted: #98a0b3;
  --accent: #4f8cff;
  --ok: #2fbf71;
  --warn: #e0a93b;
  --border: #272c37;
  --input-bg: #1f232c;
}

:root[data-theme="light"] {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --text: #1b2330;
  --muted: #5d6678;
  --accent: #2f6fed;
  --ok: #1b9e57;
  --warn: #b9791d;
  --border: #e2e6ee;
  --input-bg: #ffffff;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must always win. Components that set display
   (flex/grid/block) otherwise override the UA's [hidden]{display:none}, so
   toggling el.hidden silently fails. This global guard prevents that class of bug. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

/* App shell: sidebar + main */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand { padding: 6px 10px 4px; }
.side-brand .b { font-weight: 700; font-size: 22px; color: var(--accent); letter-spacing: 0.5px; }
.side-brand .s { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.3; }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.side-nav-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px;
  color: var(--text); text-decoration: none; font-size: 14px;
}
.nav-item .ico { width: 22px; height: 20px; display: inline-flex; align-items: center; justify-content: center; opacity: 0.7; }
.nav-item .ico svg { width: 19px; height: 19px; display: block; }
.nav-item:hover { background: var(--panel-2); }
.nav-item:hover .ico { opacity: 0.9; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active .ico { opacity: 1; }
/* Theme/Account/Sign out live in the bottom of the menu now. The theme toggle is
   a <button> styled as a nav row; its sun/moon glyph sits in the icon slot. */
button.nav-item { width: 100%; background: none; border: none; cursor: pointer; font: inherit; text-align: left; }
.nav-item .theme-icon { opacity: 1; }
.nav-item .theme-icon::before { font-size: 16px; line-height: 1; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

body.sidebar-collapsed .sidebar { display: none; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer; padding: 6px 10px; font-size: 15px;
}
.page-title { font-weight: 600; font-size: 17px; }
.store { color: var(--muted); }

/* ── Mobile nav: sidebar slides in over the page (desktop unchanged) ───────── */
@media (max-width: 768px) {
  /* Off-canvas by default; the hamburger (nav-open) slides it in. */
  .sidebar {
    position: fixed; top: 0; left: 0;
    height: 100vh; height: 100dvh;   /* dvh = visible viewport, excludes browser chrome */
    width: 78vw; max-width: 300px; z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    /* Clear the iOS home indicator + browser bottom bar so the last items show. */
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  /* Pack the bottom group right after the nav (don't pin it into the occluded
     zone); the sidebar scrolls if the whole list is taller than the screen. */
  .side-nav-bottom { margin-top: 20px; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 10px 40px rgba(0,0,0,0.35); }
  /* Neutralise the desktop collapse rule so a stale class can't hide it here. */
  body.sidebar-collapsed .sidebar { display: flex; }
  /* Dim backdrop behind the open nav; tap handled in shell.js. */
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; z-index: 50;
    background: rgba(0, 0, 0, 0.45);
  }
  /* Main content spans full width; the topbar keeps the hamburger reachable. */
  .topbar { padding: 12px 16px; }
}

.controls { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.range-select,
.custom-range input,
.custom-range button,
.theme-toggle {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
}
.range-select { cursor: pointer; }
.custom-range { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.custom-range button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent); }

.theme-toggle { cursor: pointer; width: 36px; height: 34px; display: grid; place-items: center; }
.theme-icon::before { content: "🌙"; }
:root[data-theme="light"] .theme-icon::before { content: "☀️"; }

.status { font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.status.ok { background: rgba(47,191,113,0.15); color: var(--ok); }
.status.warn { background: rgba(224,169,59,0.15); color: var(--warn); }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.banner {
  background: rgba(224,169,59,0.12);
  border: 1px solid rgba(224,169,59,0.4);
  color: var(--warn);
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.banner a { color: var(--accent); }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 5px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-window { opacity: 0.7; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; }

/* Goal bars */
.goals { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.goal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; }
.goal-title { font-size: 14px; font-weight: 600; }
.goal-pct { font-size: 18px; font-weight: 700; }
.goal-fig { color: var(--text); font-size: 15px; margin: 4px 0 10px; }
.goal-track { position: relative; height: 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.goal-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width 0.4s; }
.goal-marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: 0.55; }
.goal-sub { margin-top: 8px; }
@media (max-width: 820px) { .goals { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--text); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.path {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  counter-reset: path;
}
.path li {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  counter-increment: path;
}
.path li.now {
  border-color: var(--accent);
  color: var(--text);
}
.path-when {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.path-when::before { content: counter(path) ". "; }
.path-when .tag { margin-left: 4px; text-transform: none; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
td:nth-child(n+2), th:nth-child(n+2) { text-align: right; }
tbody tr:last-child td { border-bottom: none; }
.empty td { color: var(--muted); text-align: center; padding: 18px; }

.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.muted a { color: var(--accent); }

.apps-index h3 { font-size: 14px; margin: 22px 0 8px; }
.apps-list { margin: 0; }
.apps-list > div { padding: 10px 0; border-bottom: 1px solid var(--border); }
.apps-list > div:last-child { border-bottom: none; }
.apps-list dt { font-size: 13px; word-break: break-all; }
.apps-list dt a { color: var(--accent); }
.apps-list dd { margin: 4px 0 0; font-size: 14px; line-height: 1.45; color: var(--text); }
.apps-install { margin: 0; padding-left: 1.2em; font-size: 14px; line-height: 1.5; }

/* Kanban */
.board-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.board-tab {
  padding: 9px 16px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; font-size: 14px; user-select: none;
}
.board-tab:hover { color: var(--text); }
.board-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.kcol {
  flex: 1; min-width: 240px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px;
}
.kcol-head {
  font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.4px; padding: 4px 6px 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.kcol-count {
  background: var(--border); color: var(--text); border-radius: 999px;
  padding: 1px 8px; font-size: 12px; font-weight: 600;
}
.kcol-body { min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.kcol-body.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: 8px; }

.kcard {
  position: relative;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: grab; font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: 0.5; }
/* In edit mode the whole card is clickable (opens the editor); flag it on hover
   with a hyperlink-blue border. Locked boards are read-only, so no hover cue. */
#kanban:not([data-edit-mode="locked"]) .kcard:hover { border-color: var(--accent); }
.kc-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.kc-name { font-weight: 600; color: var(--text); }
.kc-inv { color: var(--muted); font-size: 12px; }
.kc-items { color: var(--text); font-size: 12px; line-height: 1.4; margin: 2px 0; white-space: pre-wrap; }
.kc-meta { margin: 4px 0; }
.kc-tag {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.kc-phone { color: var(--muted); font-size: 12px; }
.kc-note { color: var(--accent); font-size: 12px; margin-top: 4px; }
.board-tab.brand { color: var(--muted); font-size: 13px; }
.board-tab.brand.active { color: var(--accent); }
.board-empty { width: 100%; padding: 28px; text-align: center; }

/* Add-card button in a column head (edit mode only) */
.kcol-add {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 7px; width: 22px; height: 22px; line-height: 1; font-size: 16px;
  cursor: pointer; padding: 0; flex: none;
}
.kcol-add:hover { color: var(--accent); border-color: var(--accent); }

/* New-card modal */
.card-form {
  position: relative; z-index: 41; width: min(440px, 92vw);
  margin: 8vh auto 0; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px; box-shadow: 0 18px 50px rgba(0,0,0,0.35);
}
.cf-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cf-head h3 { margin: 0; font-size: 16px; }
/* Read-only "created" stamp next to the edit-card title (muted, uppercase). */
.cf-created { margin-right: auto; margin-left: 12px; color: var(--muted); font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase; white-space: nowrap; }

/* History button on the edit card + the history window it opens. */
/* Invoice-lookup status line on the delivery card. */
.cf-lookup { font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
.cf-lookup.warn { color: #dc2626; }
.cf-lookup.ok-note { color: #16a34a; }

.cf-history { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 8px 18px; cursor: pointer; font: inherit; font-size: 12px; letter-spacing: 0.4px; text-transform: uppercase; }
.cf-history:hover { border-color: var(--accent); color: var(--accent); }
.hist-head { justify-content: flex-start; gap: 10px; }
.hist-head .cf-close { margin-left: auto; }
.hist-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; font-size: 11px; letter-spacing: 0.3px; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.hist-list { display: flex; flex-direction: column; }
.hist-row { display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--border); }
.hist-label { text-transform: uppercase; letter-spacing: 0.3px; font-size: 13px; }
.hist-time, .hist-date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist-empty { padding: 20px 2px; }
.cf-close { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.cf-close:hover { color: var(--text); }
.cf-err {
  background: rgba(255,90,90,0.12); border: 1px solid rgba(255,90,90,0.4);
  color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 12px;
}
.cf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cf-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.cf-field:nth-child(3) { grid-column: 1 / -1; } /* Items spans full width */
.cf-field input, .cf-field textarea, .cf-field select {
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit; resize: vertical;
}
/* Reason-lost picker is a compact, non-grid card-form. */
.lost-form { max-width: 380px; }
.lost-form .cf-field { font-size: 12px; }
/* One clean right-aligned button bar: delete · history · [log contact] | cancel · save.
   Wraps as a whole if the modal is narrow; Save never separates from Cancel. */
.cf-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 18px; }
/* "Log contact" channel + button stay grouped, with a divider before Cancel/Save. */
.cf-logwrap { display: inline-flex; align-items: center; gap: 6px; padding-right: 10px; margin-right: 2px; border-right: 1px solid var(--border); }
/* Delete (edit mode only): quiet outline trash, reds up on hover — no loud filled block. */
.cf-delete {
  background: none; color: var(--muted); border: 1px solid var(--border); border-radius: 8px;
  width: 34px; height: 34px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cf-delete svg { width: 18px; height: 18px; display: block; }
.cf-delete:hover { border-color: #dc2626; color: #dc2626; background: rgba(220,38,38,0.08); }
.cf-cancel { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 14px; }
.cf-save { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 18px; cursor: pointer; font-size: 14px; }
.cf-save:disabled { opacity: 0.6; cursor: default; }

/* Reports sub-sections */
.report-section { display: none; }
.report-section.active { display: block; }

/* "See more" — sits at the foot of a report card, links to the full list. */
.card-more { margin: 14px 0 0; text-align: center; }
.see-more {
  display: inline-block; cursor: pointer;
  background: var(--accent); color: #fff; text-decoration: none;
  border-radius: 8px; padding: 8px 20px; font-size: 13px; font-weight: 500;
}
.see-more:hover { opacity: 0.9; }

/* Back link at the top of a full-list page. */
.list-back { margin: 0 0 14px; }
.list-back a { color: var(--muted); text-decoration: none; font-size: 13px; }
.list-back a:hover { color: var(--text); }

/* Marketing segments */
.seg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.seg-head h2 { margin: 0; }
.seg-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.seg-count { color: var(--muted); font-size: 13px; }
.seg-export { background: var(--accent); color: #fff; text-decoration: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; }
.seg-export:hover { opacity: 0.9; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: 0.2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }

/* Segmented control (Settings → edit mode) */
.seg { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 6px; }
.seg-btn {
  flex: 1; min-width: 200px; text-align: left; cursor: pointer;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  font-size: 14px; font-family: inherit; display: flex; flex-direction: column; gap: 3px;
}
.seg-btn small { color: var(--muted); font-size: 12px; font-weight: 400; }
.seg-btn.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.seg-btn.on small { color: var(--text); }

/* Compact inline segmented control (Preferences). */
.seg-inline { margin: 0; gap: 6px; flex-wrap: nowrap; }
.seg-inline .seg-btn { flex: 0 0 auto; min-width: 0; text-align: center; padding: 6px 16px; }

/* Settings → Preferences rows: label on the left, control on the right. */
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 4px; flex-wrap: wrap; }
.pref-label { font-size: 14px; }
.pref-row .range-select { min-width: 160px; }

.target-row { display: flex; gap: 8px; margin: 10px 0; }
.target-row input {
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; max-width: 180px;
}
.target-row button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 16px; cursor: pointer; font-size: 14px;
}

/* Accounts: expense form */
.exp-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.exp-form input[type="text"], .exp-form input[type="number"], .exp-form input[type="date"] {
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.exp-form input[type="text"] { min-width: 150px; }
.exp-lbl, .exp-check { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.exp-form button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-size: 14px; }

/* Deliveries table */
table.deliveries td { vertical-align: top; }
table.deliveries td, table.deliveries th { text-align: left; }
table.deliveries .items { max-width: 320px; font-size: 13px; }
table.deliveries .note { max-width: 240px; font-size: 13px; }
table.deliveries .muted { font-size: 12px; }
table.deliveries .tag {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); margin-left: 4px;
}

.tag {
  display: inline-block;
  font-size: 11px;
  text-transform: capitalize;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag-service { color: var(--accent); border-color: var(--accent); }
.tag-giftcard { color: var(--ok); border-color: var(--ok); }
.tag-discount { color: var(--warn); border-color: var(--warn); }
/* "Type" and "Revenue" columns: keep tag left-aligned, numbers right. */
#other td:nth-child(2), #other th:nth-child(2) { text-align: left; }

/* Clickable rows + drill-down drawer */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
.cell-link { color: var(--accent); cursor: pointer; }
.cell-link:hover { text-decoration: underline; }
.copy-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); border-radius: 6px; font-size: 11px; padding: 1px 7px; cursor: pointer; margin-left: 6px; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s; z-index: 40;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0;
  height: 100vh; width: 440px; max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 50; padding: 22px; overflow-y: auto;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-back {
  background: none; border: none; color: var(--accent);
  font-size: 13px; cursor: pointer; padding: 0; margin-bottom: 8px;
}
.drawer-back:hover { text-decoration: underline; }
.drawer-head h3 { margin: 0; font-size: 18px; }
.drawer-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.drawer-close {
  background: none; border: none; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.drawer-close:hover { color: var(--text); }
.drawer-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 18px 0;
}
.drawer-stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.ds-label { color: var(--muted); font-size: 12px; }
.ds-value { font-size: 16px; font-weight: 600; margin-top: 2px; word-break: break-word; }
.drawer-h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }

@media (max-width: 820px) {
  /* No sideways scroll → the topbar spans the full width instead of looking narrow. */
  body { overflow-x: hidden; }
  /* minmax(0,1fr) lets columns shrink below the long $ amounts (default 1fr can't),
     so the KPI grid stays within the screen instead of overflowing it. */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { min-width: 0; }
  .kpi-value { font-size: 22px; overflow-wrap: anywhere; }
  .grid { grid-template-columns: 1fr; }
  .path { grid-template-columns: 1fr 1fr; }
  /* Keep the period selector inline (same row as the hamburger + title),
     pushed to the right — not wrapped onto a second row. */
  .controls { margin-left: auto; gap: 8px; }
  .page-title { min-width: 0; }
  /* Wide tables scroll inside their own card rather than pushing the page wide. */
  .card { overflow-x: auto; }
  /* Sub-tab rows (Reports: Sales/Products/…/Segments) scroll sideways so every
     tab stays reachable instead of being clipped off-screen. */
  .board-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .board-tab { flex: 0 0 auto; white-space: nowrap; }
}

/* Counter pages */
.counter-section { display: none; }
.counter-section.active { display: block; }
.counter-stores { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.counter-store {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; font-size: 13px;
}
.counter-store.warn { color: var(--warn); }
.counter-store code { font-size: 12px; }
.counter-store .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.counter-store .dot.ok { background: var(--ok); }
.counter-store .dot.off { background: var(--muted); }
/* In-cell mini bar (busiest hours, zone dwell) */
.bar-cell { position: relative; display: flex; align-items: center; gap: 8px; }
.bar-cell .bar {
  display: inline-block; height: 8px; min-width: 2px; border-radius: 999px;
  background: var(--accent); opacity: 0.55;
}

/* ── Inbox ─────────────────────────────────────────────────────────────── */
/* Nav unread badge (Inbox sidebar item). nav-item is a flex row; push right. */
.nav-item .nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1;
  background: #dc2626; color: #fff;
}
/* Stay red (and pop) even when the Inbox item is the active, blue-highlighted row. */
.nav-item.active .nav-badge { background: #ef4444; }
/* Amber sibling badge (Follow Up: aged-1-day cards). Sits left of the red one. */
.nav-item .nav-badge-amber { background: #f59e0b; }
.nav-item.active .nav-badge-amber { background: #f59e0b; }
/* When two badges show, only the first is pushed right; the second hugs it. */
.nav-item .nav-badge:not([hidden]) ~ .nav-badge:not([hidden]) { margin-left: 4px; }

/* Two-pane layout: message list on the left, reader on the right. */
.inbox {
  display: grid; grid-template-columns: 340px 1fr; gap: 14px;
  margin-top: 14px; align-items: start;
}
.inbox-list {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--panel);
}
.inbox-row {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.inbox-row:last-child { border-bottom: 0; }
.inbox-row:hover { background: var(--panel-2); }
.inbox-row.selected { background: var(--panel-2); }
.inbox-row.unread .ir-from,
.inbox-row.unread .ir-subj { font-weight: 700; }
.inbox-row.unread { border-left: 3px solid var(--accent); padding-left: 9px; }
.ir-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ir-from { font-size: 13px; color: var(--text); }
.ir-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ir-subj { font-size: 13px; color: var(--text); margin-top: 2px; }
.ir-snip { font-size: 12px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ir-box { display: inline-block; margin-top: 4px; font-size: 10px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; }

.inbox-reader {
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel);
  min-height: 320px;
}
.inbox-empty { padding: 24px; }
.mail-head { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.mail-subj { font-size: 17px; font-weight: 700; color: var(--text); }
.mail-meta { display: flex; gap: 8px; align-items: baseline; margin-top: 6px; }
.mail-from { font-size: 13px; font-weight: 600; color: var(--text); }
.mail-addr { font-size: 12px; color: var(--muted); }
.mail-meta2 { display: flex; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--muted); margin-top: 3px; }
.mail-actions { display: flex; gap: 8px; margin-top: 10px; }
.mail-act {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.mail-act:hover { background: var(--panel-2); }
.mail-body { padding: 14px 16px; }
.mail-text { white-space: pre-wrap; word-break: break-word; font-size: 14px;
  line-height: 1.5; color: var(--text); }
/* Untrusted email HTML is isolated here (sandboxed iframe, no scripts). */
.mail-frame { width: 100%; min-height: 420px; border: 0; background: #fff; }

/* Inbox toolbar (tabs + compose) and storage indicator. */
.inbox-toolbar { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; }
.inbox-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.inbox-connect { margin-top: 48px; text-align: center; padding: 40px 16px; }
.inbox-connect .mail-act.primary { font-size: 14px; padding: 10px 18px; }
.inbox-connect .muted { margin: 12px 0 0; }
.mail-act.primary[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.mail-stays { margin: 8px 0 0; font-size: 12px; }

.gmail-accounts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 10px; }
.gmail-acct { display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px;
  font-size: 12px; background: var(--panel); }
.gmail-acct-addr { color: var(--text); }
.gmail-acct-err { color: var(--warn, #b45309); font-size: 11px; }
.gmail-acct-x { background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 0; }
.gmail-acct-x:hover { color: var(--text); text-decoration: underline; }
.gmail-flash { margin: 10px 0 0; }
.gmail-flash.ok { color: var(--ok, #15803d); }
.gmail-flash.warn { color: var(--warn, #b45309); }
a.mail-act { text-decoration: none; display: inline-block; line-height: 1.4; }

.mail-storage { margin-top: 12px; }
.mail-banner { border-radius: 10px; padding: 10px 12px; font-size: 13px;
  margin-bottom: 10px; border: 1px solid var(--border); }
.mail-banner.warn { background: rgba(204, 142, 0, 0.12); border-color: rgba(204, 142, 0, 0.4); }
.mail-banner.cap { background: rgba(204, 51, 51, 0.14); border-color: rgba(204, 51, 51, 0.5); }
.mail-store-list { display: grid; gap: 6px; }
.mail-store-row { display: grid; grid-template-columns: 1fr 160px 80px;
  gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.msr-addr { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msr-bar { height: 8px; border-radius: 6px; background: var(--panel-2);
  overflow: hidden; border: 1px solid var(--border); }
.msr-fill { display: block; height: 100%; background: var(--accent); }
.msr-fill.warn { background: #cc8e00; }
.msr-fill.cap { background: #cc3333; }
.msr-size { text-align: right; white-space: nowrap; }

/* Compose button + reader's Reply (accent), and the Cc/Bcc disclosure link. */
.mail-act.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.mail-act.primary:hover { background: var(--accent); opacity: 0.92; }
.linkish { background: none; border: none; color: var(--accent); font-size: 12px;
  cursor: pointer; padding: 0; }
.linkish:hover { text-decoration: underline; }

/* Compose + contacts modals reuse .overlay / .card-form / .cf-*. */
.compose-form, .contacts-form { width: 600px; max-width: 94vw; }
.compose-grid { display: grid; gap: 10px; }
.compose-grid .cf-field span { font-size: 12px; color: var(--muted); }
.compose-grid input, .compose-grid select, .compose-grid textarea {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 10px; font-size: 14px; width: 100%;
}
.compose-grid input[readonly] { color: var(--muted); }
.compose-grid textarea { resize: vertical; font-family: inherit; }
.cf-cc-toggle { margin-top: -4px; }

.contact-add { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 12px; }
.contact-add input { background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 8px 10px; font-size: 14px; }
.contacts-list { display: grid; gap: 4px; max-height: 360px; overflow-y: auto; }
.contact-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px;
  align-items: center; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; }
.cr-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Received-mail attachment strip, under the message header. */
.mail-attach { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mail-attach-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 10px; font-size: 13px;
  color: var(--accent); text-decoration: none;
}
a.mail-attach-chip:hover { border-color: var(--accent); }
.mail-attach-chip.stripped { color: var(--muted); cursor: default; }

.sig-help { margin: 0 0 8px; font-size: 12px; }

/* Settings · Data feeds status */
.feeds { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.feed-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.feed-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.feed-ok { background: #16a34a; }
.feed-lag { background: #d97706; }
.feed-stale, .feed-never { background: #dc2626; }
.feed-name { color: var(--text); }
.feed-when { margin-left: auto; white-space: nowrap; }

/* Users admin */
.users-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn-primary:hover { filter: brightness(1.05); }
.users-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.user-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg); }
.user-card.is-inactive { opacity: 0.6; }
.uc-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.user-card input[type="text"], .user-card input[type="email"] {
  flex: 1; min-width: 160px; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--panel); color: var(--text);
}
.uc-meta { font-size: 12px; white-space: nowrap; }
.uc-feats { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0; }
.feat { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); }
.uc-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.uc-active { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; margin-right: auto; }
.uc-status { font-size: 12px; }
.uc-status.bad { color: #dc2626; }
.user-inactive { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: #dc2626; border: 1px solid #dc2626; border-radius: 10px; padding: 1px 8px; }

/* Account self-service */
.acct-feats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.acct-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 3px 10px; font-size: 12px; }
.acct-form { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin-top: 8px; }
.acct-form input { padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); color: var(--text); }
.cf-ok { color: #16a34a; font-size: 13px; }

/* Retention rules banner — succinct, dismissible. */
.mail-retention {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 0 12px; padding: 8px 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; font-size: 12.5px; color: var(--muted);
}
.mail-retention .mr-icon { color: var(--accent); line-height: 1.5; }
.mail-retention .mr-text { flex: 1; line-height: 1.5; }
.mail-retention strong { color: var(--text); font-weight: 600; }
.mail-retention .mr-dismiss {
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1; padding: 0;
}
.mail-retention .mr-dismiss:hover { color: var(--text); }

/* Drag-a-file-anywhere overlay (page-level drop to attach). */
.drop-hint {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 17, 21, 0.45); pointer-events: none;
}
.drop-hint-box {
  background: var(--bg); color: var(--accent);
  border: 2px dashed var(--accent); border-radius: 14px;
  padding: 24px 40px; font-size: 18px; font-weight: 600;
}

/* Compose attachments — chosen files shown as removable chips. */
.cf-attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cf-attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 14px; padding: 3px 10px; font-size: 12px;
}
.cf-attach-sz { color: var(--muted); }
.cf-attach-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 0; }
.cf-attach-x:hover { color: #dc2626; }
.cf-attach-warn { flex-basis: 100%; color: #dc2626; font-size: 12px; }

@media (max-width: 720px) {
  .inbox { grid-template-columns: 1fr; }
  .mail-store-row { grid-template-columns: 1fr 100px 70px; }
  .contact-add, .contact-row { grid-template-columns: 1fr; }
}

/* --- Marketing: Links + Insights (PP/VidT-style table-first layout) ------- */
.mk-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px 0 6px; }
.mk-head h2 { margin: 0; font-size: 20px; font-weight: 700; color: var(--text); }
.mk-intro { color: var(--muted); font-size: 13.5px; line-height: 1.6; max-width: 70ch; margin: 0 0 18px; }
.mk-intro a { color: var(--accent); }
.mk-intro strong { color: var(--text); }
/* Honest "attribution gap / data note" callout — reuses the banner's amber. */
.mk-note { background: rgba(224,169,59,0.12); border: 1px solid rgba(224,169,59,0.4);
  color: var(--text); padding: 12px 16px; border-radius: 10px; margin: 0 0 18px; font-size: 13px; line-height: 1.55; }
.mk-note strong { color: var(--warn); }
.mk-note code { font-size: 12px; }
/* Inline create/edit form card, revealed by the New-link button. */
.mk-form { margin-bottom: 18px; }
.mk-form[hidden] { display: none; }
/* Compact monospace short-link cell with a copy affordance. */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; word-break: break-all; }
.trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0 6px 0 0; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--warn); }
/* ROAS / channel-health pills. */
.roas-good { color: var(--ok); font-weight: 600; }
.roas-mid  { color: var(--warn); font-weight: 600; }
.roas-bad  { color: var(--warn); font-weight: 600; opacity: 0.85; }
tfoot td { font-weight: 600; border-top: 2px solid var(--border); }
/* These tables are text-first; left-align everything, opt cells into .num. */
#links th, #links td, #insightsTbl th, #insightsTbl td { text-align: left; }
#links td.num, #links th.num, #insightsTbl td.num, #insightsTbl th.num { text-align: right; }

/* Bank-transaction filter pills + ignored rows (accounting suite). */
.bank-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.bank-counts .pill { display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--card-2, rgba(127,127,127,0.08)); border: 1px solid var(--border);
  color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; }
.bank-counts .pill b { color: var(--text); }
.bank-counts .pill.active { border-color: var(--accent); color: var(--text); }
.bank-counts .pill.warn b { color: var(--warn); }
#bank input, #rules input { background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 7px; font-size: 13px; }
tr.txn-ignored { opacity: 0.5; }
tr.txn-ignored td:nth-child(2) { text-decoration: line-through; }

/* Quote follow-up board: card footer (due date), overdue flag, contact controls. */
.kc-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.kc-due { font-size: 11.5px; color: var(--muted); }
.kc-due.overdue { color: var(--warn); font-weight: 600; }
.kcard.is-overdue { border-left: 3px solid var(--warn); }
/* Age colour — how long a card has sat untouched in its current column. Resets
   on a cross-column move, keeps ageing on a same-column reorder. Amber after 1
   day, red after 2. Tinted background + matching left border so it reads at a glance. */
.kcard.kc-age-amber { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.45); border-left: 3px solid #f59e0b; }
.kcard.kc-age-red   { background: rgba(220,38,38,0.13);  border-color: rgba(220,38,38,0.50);  border-left: 3px solid #dc2626; }
/* Follow Up board — floor-capture confirm queue panel. */
.floor-queue { margin: 12px 0; border: 1px solid rgba(245,158,11,0.45); background: rgba(245,158,11,0.07); border-radius: 10px; padding: 12px 14px; }
.fq-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.fq-item { border-top: 1px solid var(--border); padding: 8px 0; }
.fq-item:first-of-type { border-top: 0; }
.fq-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.fq-meta { color: var(--muted); font-size: 12px; }
.fq-cards { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.fq-sum { font-size: 12.5px; color: var(--text); margin: 4px 0 6px; }
.fq-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; position: relative; }
.fq-confirm, .fq-pick { background: var(--accent); color: #fff; border: 0; border-radius: 7px; padding: 6px 10px; font-size: 12px; cursor: pointer; }
.fq-confirm:hover, .fq-pick:hover { filter: brightness(1.08); }
.fq-search { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; font-size: 12.5px; min-width: 200px; }
.fq-results { display: flex; gap: 4px; flex-wrap: wrap; width: 100%; }
.fq-pick { background: var(--card-2, rgba(127,127,127,0.12)); color: var(--text); border: 1px solid var(--border); }
.fq-none { font-size: 12px; padding: 4px 0; }

/* My Reminders page. */
.rem-add { display: flex; gap: 8px; margin: 14px 0 16px; }
.rem-add input { flex: 1; background: var(--input-bg, var(--bg)); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.rem-add button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 0 18px; cursor: pointer; font-size: 14px; }
.rem-list { display: flex; flex-direction: column; gap: 6px; }
.rem-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); }
.rem-main { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; min-width: 0; }
.rem-check { width: 17px; height: 17px; flex: none; cursor: pointer; }
.rem-body { font-size: 14px; color: var(--text); }
.rem-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.rem-del { flex: none; background: none; border: none; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.rem-del svg { width: 17px; height: 17px; }
.rem-del:hover { color: #dc2626; background: rgba(220,38,38,0.08); }
.rem-item.is-done { opacity: 0.6; }
.rem-item.is-done .rem-body { text-decoration: line-through; color: var(--muted); }
.rem-h4 { margin: 22px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.rem-empty { padding: 14px 2px; }

/* Customer drawer — floor-capture "Conversations" section. */
.drawer-extra { margin-top: 8px; }
.dconv { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.dconv-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.dconv-when { font-weight: 600; font-size: 12.5px; color: var(--text); }
.dconv-sent { font-size: 11px; color: var(--muted); margin-left: auto; }
.dconv-sum { font-size: 12.5px; line-height: 1.4; color: var(--text); }
.dconv-tr { margin-top: 4px; }
.dconv-tr summary { font-size: 11.5px; color: var(--accent); cursor: pointer; }
.dconv-tr > div { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 4px; white-space: pre-wrap; }

/* Terminal stages: won = green (closed), lost = grey (dead). These never age. */
.kcard.kc-won  { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.45); border-left: 3px solid #22c55e; }
.kcard.kc-lost { background: rgba(120,120,120,0.10); border-color: rgba(120,120,120,0.40); border-left: 3px solid #9ca3af; opacity: 0.75; }
.cf-channel { background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.cf-contact { background: var(--card-2, rgba(127,127,127,0.10)); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 13px; }
.cf-contact:hover { border-color: var(--accent); }

/* Table wrapped in a card — let the card own the chrome; rows get a hover cue. */
.mk-table-card { padding: 4px 18px; }
.mk-table-card table { font-size: 13.5px; }
.mk-table-card tbody tr { transition: background 0.12s; }
.mk-table-card tbody tr:hover { background: var(--panel-2); }
.mk-table-card td { padding: 11px 10px; vertical-align: middle; }

/* Channel pill with a brand-coloured dot (fixed brand hex — readable in both themes). */
.chan { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); white-space: nowrap; }
.chan::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.chan-google::before { background: #4285f4; }
.chan-meta::before   { background: #0866ff; }
.chan-tiktok::before { background: #fe2c55; }
.chan-other::before  { background: var(--muted); }

/* One-line short-link chip + copy (replaces the 4-line wrap). */
.short { display: inline-flex; align-items: center; gap: 8px; max-width: 280px; }
.short .mono {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px;
  padding: 3px 9px; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; display: inline-block; word-break: normal;
}
/* Campaign-tag chip. */
#links td code, #insightsTbl td code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; }
/* Action cell: a little air between Edit and Delete. */
#links td.num .linkbtn { padding: 0 0 0 10px; }

/* ── Products + tear sheets ─────────────────────────────────────────────── */
.prod-kpis { grid-template-columns: repeat(3, 1fr); }
.kpi-link { text-decoration: none; color: inherit; display: block; }
.kpi-link:hover { border-color: var(--accent); }

.prod-search { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.prod-search input[type="search"] {
  flex: 1; padding: 9px 12px; font-size: 15px; border-radius: 8px;
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
}
.prod-table { width: 100%; border-collapse: collapse; }
.prod-table th, .prod-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.prod-table th { color: var(--muted); font-weight: 600; }
.prod-table tr.clickable { cursor: pointer; }
.prod-table tr.clickable:hover { background: var(--panel-2); }
.prod-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--muted); }
.prod-table tr.empty td { color: var(--muted); text-align: center; padding: 22px; }
.prod-title { font-weight: 600; }
.prod-meta { display: none; color: var(--muted); font-size: 13px; margin-top: 4px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); }
.pill-ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.pill-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }

button.ghost { background: none; color: var(--muted); border: 1px solid var(--border); }
button.ghost:hover { color: var(--text); }

/* Detail drawer (wider than the shared one to fit a PDF preview). */
.prod-drawer { width: min(560px, 94vw); }
.pd-specs { color: var(--muted); font-size: 14px; margin: 8px 0 4px; }
.pd-sheets { display: flex; flex-direction: column; gap: 14px; margin: 8px 0 18px; }
.pd-sheet { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.pd-sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel-2); flex-wrap: wrap; }
.pd-fname { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-open { font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap; }
.pd-open:hover { text-decoration: underline; }
.pd-dl { text-decoration: none; color: var(--muted); font-size: 16px; padding: 0 4px; }
.pd-dl:hover { color: var(--accent); }
.pd-pdf { width: 100%; height: 460px; border: 0; background: #fff; display: block; }
.pd-img { width: 100%; height: auto; display: block; background: #fff; }
.pd-noprev { padding: 14px; color: var(--muted); font-size: 13px; }
.pd-actions { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.pd-actions button { padding: 6px 12px; border-radius: 8px; cursor: pointer; }

.prod-unmatched h2 { margin-bottom: 6px; }
.um-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-top: 10px; background: var(--panel-2); }
.um-fname { font-weight: 600; color: var(--accent); text-decoration: none; word-break: break-all; }
.um-fname:hover { text-decoration: underline; }
.um-sub { margin-top: 4px; }
.um-q {
  width: 100%; margin-top: 10px; padding: 9px 12px; font-size: 15px; border-radius: 8px;
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
}
.um-hits { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.um-hit {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); font: inherit;
}
.um-hit:hover { border-color: var(--accent); }
.um-hit-name { font-weight: 600; }

.prod-floor-bar { margin: 0 0 16px; }
.prod-floor-bar h1 { margin: 0 0 6px; font-size: 1.7rem; }
.prod-floor-bar p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.4; }

#prodMoreBtn {
  font: inherit; cursor: pointer; padding: 10px 16px; border-radius: 8px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
}

/* Phone / iPad in the aisle: big type, tap a row, full-screen detail. */
@media (max-width: 768px) {
  .prod-kpis { grid-template-columns: 1fr; }
  .prod-search { flex-direction: column; align-items: stretch; gap: 8px; }
  .prod-search input[type="search"] { font-size: 18px; min-height: 48px; padding: 12px 14px; }
  .prod-table thead { display: none; }
  .prod-table .desk-only { display: none; }
  .prod-meta { display: block; font-size: 14px; }
  .prod-title { font-size: 18px; font-weight: 650; }
  .prod-table tr.clickable td { border-bottom: none; padding: 4px 0; }
  .prod-table tr.clickable {
    display: block; padding: 14px 12px; margin-bottom: 10px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--panel);
  }
  .prod-table tr.clickable:hover { background: var(--panel-2); }
  .prod-table tr.empty { display: block; padding: 18px 8px; }
  .prod-drawer {
    width: 100vw; max-width: 100vw; left: 0; right: 0;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .prod-drawer .drawer-head h3 { font-size: 22px; }
  .pd-pdf { height: min(70vh, 640px); }
  .pd-open { font-size: 16px; padding: 6px 0; }
  .pd-actions button { min-height: 44px; padding: 10px 14px; font-size: 15px; }
  #prodMoreBtn { min-height: 44px; width: 100%; font-size: 16px; }
}

/* Floor kiosk: always hide xappy chrome (same pattern as sofa-floor). */
body.products-floor .sidebar,
body.products-floor .topbar,
body.products-floor #sidebarToggle { display: none !important; }
body.products-floor .app { display: block; }
body.products-floor .main-wrap { min-height: 100dvh; }
body.products-floor main {
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  max-width: 720px;
}
body.products-floor .prod-search input[type="search"] { font-size: 18px; min-height: 48px; }

/* ── Calls log (public/calls.php) ─────────────────────────────────────────── */
.calls-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 16px; }
.calls-chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.calls-count { margin-left: auto; font-size: 13px; }
.calls-list { display: flex; flex-direction: column; gap: 10px; }
.calls-empty { padding: 28px 4px; }
.calls-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.calls-row { display: flex; gap: 14px; align-items: flex-start; }
.calls-when { flex: 0 0 auto; min-width: 84px; line-height: 1.3; }
.calls-date { display: block; font-size: 12px; color: var(--muted); }
.calls-time { display: block; font-size: 16px; font-weight: 600; }
.calls-main { flex: 1 1 auto; min-width: 0; }
.calls-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.calls-who { font-weight: 600; font-size: 15px; color: var(--text); }
.calls-who.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--accent); font: inherit; }
.calls-who.link:hover { text-decoration: underline; }
.calls-num { color: var(--muted); font-size: 12px; }
.calls-dir { color: var(--muted); font-size: 12px; }
.calls-intent { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.calls-intent-order { background: rgba(79,140,255,0.15); color: var(--accent); }
.calls-intent-quote { background: rgba(47,191,113,0.15); color: var(--ok); }
.calls-intent-sales { background: rgba(224,169,59,0.15); color: var(--warn); }
/* Placeholder state — dashed + muted so it reads as "slot reserved, not wired". */
.calls-intent-todo { color: var(--muted); border: 1px dashed var(--border); background: none; cursor: help; }
.calls-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.calls-pill-ok { background: rgba(47,191,113,0.15); color: var(--ok); }
.calls-pill-vm { background: rgba(79,140,255,0.15); color: var(--accent); }
.calls-pill-miss { background: rgba(224,169,59,0.15); color: var(--warn); }
.calls-pill-live { background: rgba(47,191,113,0.2); color: var(--ok); }
.calls-tr { font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-wrap; margin-top: 2px; }
.calls-tr-note { color: var(--muted); font-style: italic; }

/* Call transcript inside the customer drawer. */
.dcall-tr { white-space: pre-wrap; line-height: 1.45; }

/* Shared toast (sofa builder + floor phone). */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); z-index: 90;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 10px; font-size: 14px; opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Floor phone — one-thumb, mobile-first staff capture. */
.fp { max-width: 520px; margin: 0 auto; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
.fp-signage { font-size: 14px; line-height: 1.45; }
.fp-live-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.fp-live-title { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.fp-live-state { color: var(--muted); font-weight: 500; font-size: 13px; }
.fp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.fp-dot.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(47,191,113,0.18); }
.fp.is-muted .fp-dot { background: var(--warn); box-shadow: none; }
.fp-help { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 0 0 12px; }
.fp-caption {
  min-height: 7.5rem; max-height: 40vh; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; font-size: 17px; line-height: 1.4; margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.fp-caption-meta, .fp-note-meta, .fp-fg { font-size: 13px; color: var(--muted); line-height: 1.4; }
.fp-fg { margin: 8px 4px 0; }
.fp-nospeech {
  margin: 10px 0; padding: 10px 12px; border-radius: 10px;
  background: rgba(224,169,59,0.12); border: 1px solid rgba(224,169,59,0.4);
  color: var(--warn); font-size: 14px; line-height: 1.4;
}
.fp-mute, .fp-save, .fp-note-btn {
  font: inherit; cursor: pointer; border-radius: 14px; border: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.fp-mute {
  min-height: 44px; padding: 8px 16px; background: var(--panel-2); color: var(--text); font-weight: 600;
}
.fp-mute[aria-pressed="true"] { background: rgba(224,169,59,0.18); border-color: var(--warn); color: var(--warn); }
.fp-save {
  display: block; width: 100%; min-height: 72px; margin-top: 14px;
  background: var(--accent); color: #fff; border-color: var(--accent);
  font-size: 22px; font-weight: 700; letter-spacing: 0.01em;
}
.fp-save:disabled { opacity: 0.45; cursor: not-allowed; }
.fp-save:not(:disabled):active { filter: brightness(0.95); }
.fp-note h2 { margin: 0 0 8px; font-size: 18px; }
.fp-note-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.fp-note-btn {
  display: block; width: 100%; min-height: 56px; margin-top: 8px;
  background: var(--panel-2); color: var(--text); font-size: 17px; font-weight: 600;
}
.fp-note-btn[aria-pressed="true"] { background: rgba(79,140,255,0.16); border-color: var(--accent); color: var(--accent); }
.fp-note-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.fp-note-meta { margin-top: 8px; }
.fp-appbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.fp-a2hs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin: 0 0 12px;
}
.fp-install {
  font: inherit; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  min-height: 36px; padding: 6px 12px; font-size: 13px; font-weight: 600;
}
@media (max-width: 768px) {
  .fp .card { padding: 16px; }
  main:has(.fp) { padding: 16px 14px 28px; }
}

/* Floor PWA / native shell: hide xappy admin chrome. Mute + Save that stay on the page. */
html.is-standalone body.floor-phone .sidebar,
html.is-standalone body.floor-phone .topbar,
html.is-standalone body.floor-phone #sidebarToggle {
  display: none !important;
}
html.is-standalone body.floor-phone .app { display: block; }
html.is-standalone body.floor-phone .main-wrap { min-height: 100dvh; }
html.is-standalone body.floor-phone main {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
html.is-standalone body.floor-phone .fp-appbar { display: flex; }
html.is-standalone body.floor-phone .fp-a2hs { display: none !important; }

@media (display-mode: standalone) {
  body.floor-phone .sidebar,
  body.floor-phone .topbar,
  body.floor-phone #sidebarToggle { display: none !important; }
  body.floor-phone .app { display: block; }
  body.floor-phone .main-wrap { min-height: 100dvh; }
  body.floor-phone main { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  body.floor-phone .fp-appbar { display: flex; }
  body.floor-phone .fp-a2hs { display: none !important; }
}

/* Sofa floor kiosk: always hide xappy chrome (Safari tab or installed PWA).
   Header also skips rendering nav when $KIOSK; this is the CSS backup. */
body.sofa-floor .sidebar,
body.sofa-floor .topbar,
body.sofa-floor #sidebarToggle { display: none !important; }
body.sofa-floor .app { display: block; }
body.sofa-floor .main-wrap { min-height: 100dvh; }
body.sofa-floor main {
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  max-width: none;
}

.sofa-floor-spec { max-width: 42rem; }
.sofa-floor-spec__kicker {
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px;
}
.sofa-floor-spec h1 { font-size: 1.6rem; margin: 0 0 10px; }
.sofa-floor-spec h2 { font-size: 1.15rem; margin: 1.6em 0 .4em; }
.sofa-floor-spec h3 { font-size: 1rem; margin: 1.2em 0 .3em; }
.sofa-floor-spec__lede { color: var(--muted); line-height: 1.45; }
.sofa-floor-spec ul { margin: .3em 0 0; padding-left: 1.2em; line-height: 1.5; }
.sofa-floor-spec__back { margin-top: 2em; }
.sofa-floor-spec a { color: var(--accent); }
