/* =========================================================================
   Direction C — "Dense Pro"
   Information-dense, dark-first HVAC field-service CRM.
   Linear dense mode × trading terminal × Datadog. One CSS file, no build.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---------- Tokens: dark is the default ---------- */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;

  /* surface ladder — near-black up through elevated panels */
  --bg:        #0a0b0e;
  --bg-2:      #0d0f13;
  --surface:   #111319;
  --surface-2: #161922;
  --surface-3: #1c2029;
  --raised:    #20242f;
  --hover:     #1a1e27;

  --line:      #23262f;
  --line-2:    #2c3038;
  --line-strong:#383d49;

  --text:      #e7e9ee;
  --text-2:    #aeb4c0;
  --text-3:    #767d8c;
  --text-faint:#565d6b;

  /* electric accent ladder */
  --accent:    #4f7cff;
  --accent-2:  #6d92ff;
  --accent-bg: #161c33;
  --accent-line:#2c3a66;
  --accent-glow: rgba(79,124,255,.35);

  /* status hues */
  --ok:        #34d399;
  --ok-bg:     #0f2a22;
  --ok-line:   #1d4b3c;
  --info:      #4f9bff;
  --info-bg:   #12233d;
  --info-line: #214467;
  --warn:      #f5b042;
  --warn-bg:   #2e2410;
  --warn-line: #574213;
  --bad:       #f4607a;
  --bad-bg:    #2e1620;
  --bad-line:  #58263a;
  --brand:     #b07cff;
  --brand-bg:  #221636;
  --brand-line:#3c2a5e;

  --shadow:    0 1px 2px rgba(0,0,0,.5), 0 8px 24px -8px rgba(0,0,0,.6);
  --shadow-pop:0 12px 40px -8px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.5);

  --radius:   10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
}

:root[data-theme='light'] {
  color-scheme: light;

  /* warmer, friendlier neutrals than a clinical blue-gray — this is the
     default theme the owner hands to less-technical users */
  --bg:        #f7f7f6;
  --bg-2:      #f1f1ef;
  --surface:   #ffffff;
  --surface-2: #fafaf9;
  --surface-3: #f4f4f2;
  --raised:    #ffffff;
  --hover:     #f4f5f3;

  --line:      #e7e6e2;
  --line-2:    #ddddd8;
  --line-strong:#c9c9c2;

  --text:      #1a1a17;
  --text-2:    #4c4f55;
  --text-3:    #71757d;
  --text-faint:#9b9ea4;

  --accent:    #2f5fe0;
  --accent-2:  #244fc4;
  --accent-bg: #eaf0ff;
  --accent-line:#c6d6ff;
  --accent-glow: rgba(47,95,224,.22);

  --ok:        #0f8f5f;
  --ok-bg:     #e6f7ef;
  --ok-line:   #b6e6d1;
  --info:      #2f72d6;
  --info-bg:   #e7f0fd;
  --info-line: #bcd6f7;
  --warn:      #b97400;
  --warn-bg:   #fdf2dd;
  --warn-line: #f0dba6;
  --bad:       #d23054;
  --bad-bg:    #fdeaef;
  --bad-line:  #f5c6d2;
  --brand:     #7c45d6;
  --brand-bg:  #f2eafd;
  --brand-line:#ddc7f5;

  --shadow:    0 1px 2px rgba(16,24,40,.06), 0 6px 20px -8px rgba(16,24,40,.12);
  --shadow-pop:0 14px 40px -10px rgba(16,24,40,.22), 0 2px 6px rgba(16,24,40,.08);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
ul { list-style: none; }
svg { display: block; }
.mono { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

::selection { background: var(--accent-glow); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 9px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* =========================================================================
   LAYOUT SHELL
   ========================================================================= */
.app { min-height: 100vh; }

/* ---- Desktop sidebar (hidden on mobile) ---- */
.sidebar {
  display: none;
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  flex-direction: column;
  z-index: 40;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--accent) 0%, var(--brand) 130%);
  color: #fff; box-shadow: 0 2px 10px -2px var(--accent-glow);
}
.brand-mark svg { width: 17px; height: 17px; stroke-width: 2.1; }
.brand-name { font-weight: 650; font-size: 13.5px; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: var(--text-3); letter-spacing: .02em; }

.sb-search {
  margin: 12px 12px 6px;
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text-3); font-size: 12.5px;
}
.sb-search svg { width: 14px; height: 14px; flex: none; }
.sb-search .kbd { margin-left: auto; }

.sb-section { padding: 10px 12px 2px; }
.sb-label { font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); padding: 0 8px 6px; }
.sb-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; flex: 1; overflow-y: auto; }
.sb-link {
  display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 9px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 12.5px; font-weight: 480;
  position: relative;
}
.sb-link svg { width: 16px; height: 16px; flex: none; color: var(--text-3); }
.sb-link:hover { background: var(--hover); color: var(--text); }
.sb-link:hover svg { color: var(--text-2); }
.sb-link.active { background: var(--accent-bg); color: var(--accent-2); font-weight: 550; }
.sb-link.active svg { color: var(--accent); }
.sb-link.active::before {
  content: ''; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 2.5px;
  background: var(--accent); border-radius: 2px;
}
.sb-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.sb-badge.hot { background: var(--bad-bg); color: var(--bad); }

.sb-foot { border-top: 1px solid var(--line); padding: 10px 12px; margin-top: auto; }
.sb-user { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: var(--radius-sm); }
.sb-user:hover { background: var(--hover); }
.sb-user .meta { line-height: 1.2; min-width: 0; }
.sb-user .nm { font-size: 12.5px; font-weight: 550; }
.sb-user .rl { font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 650;
  color: #fff; letter-spacing: .01em;
}
.avatar.sm { width: 20px; height: 20px; border-radius: 5px; font-size: 9px; }
.avatar.lg { width: 34px; height: 34px; border-radius: 9px; font-size: 12.5px; }

/* ---------- job/customer photo (face / house / monogram fallback) ---------- */
.jphoto {
  position: relative; flex: none; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px; overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--line-2);
}
.jphoto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jphoto.mono { color: #fff; font-weight: 700; letter-spacing: .02em; border: none; }
.jphoto.mono span { font-size: 14px; }
.jphoto.sm  { width: 32px; height: 32px; border-radius: 8px; }
.jphoto.sm.mono span { font-size: 12px; }
.jphoto.lg  { width: 52px; height: 52px; border-radius: 13px; }
.jphoto.lg.mono span { font-size: 18px; }
.jphoto.xl  { width: 72px; height: 72px; border-radius: 16px; }
.jphoto.xl.mono span { font-size: 25px; }
/* tiny corner badge telling face vs house apart */
.jphoto-kind {
  position: absolute; right: -2px; bottom: -2px;
  width: 16px; height: 16px; border-radius: 5px;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--line-2); box-shadow: var(--shadow);
}
.jphoto-kind svg { width: 9px; height: 9px; }
.jphoto.lg .jphoto-kind { width: 19px; height: 19px; border-radius: 6px; }
.jphoto.lg .jphoto-kind svg { width: 11px; height: 11px; }
.jphoto.xl .jphoto-kind { width: 24px; height: 24px; border-radius: 7px; }
.jphoto.xl .jphoto-kind svg { width: 13px; height: 13px; }

/* photo-source demo toggle (prototype only) */
.photo-toggle {
  display: inline-flex; align-items: center; gap: 0; padding: 2px;
  background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 8px;
}
.photo-toggle button {
  border: 0; background: transparent; color: var(--text-3); cursor: pointer;
  font: inherit; font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 5px;
}
.photo-toggle button svg { width: 12px; height: 12px; }
.photo-toggle button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 500;
  padding: 2px 5px; border-radius: 5px; line-height: 1;
  background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text-3);
}

/* ---- Main column ---- */
.main { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Mobile top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 12px;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  width: 38px; height: 38px; flex: none; border-radius: var(--radius-sm);
  display: grid; place-items: center; color: var(--text-2);
  border: 1px solid transparent;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover, .icon-btn:active { background: var(--hover); color: var(--text); }
.icon-btn.bordered { border-color: var(--line); background: var(--surface); }

.tb-brand { display: flex; align-items: center; gap: 9px; }
.tb-brand .brand-name { font-size: 14px; }
.tb-spacer { flex: 1; }
.tb-dot { position: relative; }
.tb-dot::after {
  content: ''; position: absolute; top: 7px; right: 8px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--bad); border: 1.5px solid var(--bg-2);
}

/* desktop header (top of content) */
.head {
  display: none;
  align-items: center; gap: 14px;
  padding: 0 24px; height: 56px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 25;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
}
.head h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.head .crumb { color: var(--text-3); font-size: 12.5px; }
.head .sp { flex: 1; }
.head-search {
  display: flex; align-items: center; gap: 8px; height: 32px; width: 220px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text-3); font-size: 12.5px;
}
.head-search svg { width: 14px; height: 14px; }
.head-search .kbd { margin-left: auto; }

/* page content wrapper.
   Mobile bottom clearance = tab bar (56px) + breathing room (24px) + notch inset,
   so the last row/card on every page fully clears the fixed bottom tab bar. */
.content { flex: 1; padding: 14px 12px calc(56px + 24px + env(safe-area-inset-bottom, 0px)); }
.page-head { margin-bottom: 12px; }
.page-title { font-size: 18px; font-weight: 680; letter-spacing: -0.03em; }
.page-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* =========================================================================
   MOBILE NAV — bottom tab bar + slide-in drawer
   ========================================================================= */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 35;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 56px; color: var(--text-3); font-size: 10px; font-weight: 500; position: relative;
}
.tab svg { width: 21px; height: 21px; stroke-width: 1.8; }
.tab.active { color: var(--accent-2); }
.tab.active svg { color: var(--accent); }
.tab.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 2.5px; background: var(--accent); border-radius: 0 0 3px 3px;
}
.tab .tdot {
  position: absolute; top: 9px; right: 50%; margin-right: -14px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--bad);
  border: 1.5px solid var(--bg-2);
}

/* drawer */
.scrim {
  position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.55);
  opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
  backdrop-filter: blur(2px);
}
.drawer {
  position: fixed; inset: 0 auto 0 0; z-index: 46; width: 268px; max-width: 84vw;
  background: var(--bg-2); border-right: 1px solid var(--line);
  transform: translateX(-102%); transition: transform .24s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop);
}
body.drawer-open .scrim { opacity: 1; visibility: visible; }
body.drawer-open .drawer { transform: translateX(0); }
.drawer .sb-brand, .drawer .sb-search, .drawer .sb-section,
.drawer .sb-nav, .drawer .sb-foot, .drawer .sb-label { display: flex; }
.drawer .sb-nav { display: flex; flex-direction: column; }
.drawer .sb-section { display: block; }
.drawer-close { margin-left: auto; }

/* =========================================================================
   CARDS / PANELS
   ========================================================================= */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 12.5px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head .ph-icon { width: 15px; height: 15px; color: var(--text-3); }
.panel-head .sp { flex: 1; }
.panel-head .count {
  font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.panel-foot {
  padding: 9px 14px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px;
}
.panel-foot:hover { color: var(--accent-2); }
.panel-foot svg { width: 13px; height: 13px; }
.link-mini { color: var(--accent-2); font-size: 12px; font-weight: 550; display: inline-flex; align-items: center; gap: 3px; }
.link-mini svg { width: 13px; height: 13px; }

/* =========================================================================
   BUTTONS / CHIPS / DOTS
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 550; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  transition: background .12s, border-color .12s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--hover); border-color: var(--line-strong); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 3px 12px -4px var(--accent-glow);
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn.block { width: 100%; }

/* status dot + chip */
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px transparent; }
.dot.ok   { background: var(--ok); }
.dot.info { background: var(--info); }
.dot.warn { background: var(--warn); }
.dot.bad  { background: var(--bad); }
.dot.brand{ background: var(--brand); }
.dot.live { box-shadow: 0 0 0 0 var(--accent-glow); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--info-bg); }
  70% { box-shadow: 0 0 0 5px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px 0 7px; border-radius: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent;
}
.chip .dot { width: 6px; height: 6px; }
.chip.ok    { background: var(--ok-bg);    color: var(--ok);    border-color: var(--ok-line); }
.chip.info  { background: var(--info-bg);  color: var(--info);  border-color: var(--info-line); }
.chip.warn  { background: var(--warn-bg);  color: var(--warn);  border-color: var(--warn-line); }
.chip.bad   { background: var(--bad-bg);   color: var(--bad);   border-color: var(--bad-line); }
.chip.brand { background: var(--brand-bg); color: var(--brand); border-color: var(--brand-line); }
.chip.muted { background: var(--surface-3); color: var(--text-2); border-color: var(--line-2); }
.chip.plain { background: transparent; color: var(--text-2); border-color: var(--line-2); }

.tag {
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; font-weight: 500;
  color: var(--text-3); padding: 1px 5px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--line);
}

.pill-toggle {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px;
  background: var(--surface-3); border: 1px solid var(--line);
}
.pill-toggle button {
  height: 26px; padding: 0 11px; border-radius: 6px; font-size: 12px; font-weight: 550;
  color: var(--text-3);
}
.pill-toggle button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* =========================================================================
   KPI STRIP
   ========================================================================= */
.kpi-strip {
  display: grid; gap: 8px; margin-bottom: 12px;
  grid-template-columns: repeat(2, 1fr);
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 12px 10px; position: relative; overflow: hidden;
}
.kpi:hover { border-color: var(--line-2); }
.kpi-top { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.kpi-label { font-size: 11px; font-weight: 550; color: var(--text-3); letter-spacing: .005em; }
.kpi-trend {
  margin-left: auto; display: inline-flex; align-items: center; gap: 2px;
  font-size: 10.5px; font-weight: 650; padding: 1px 5px; border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.kpi-trend.up { color: var(--ok); background: var(--ok-bg); }
.kpi-trend.down { color: var(--bad); background: var(--bad-bg); }
.kpi-trend svg { width: 10px; height: 10px; }
.kpi-value { font-size: 22px; font-weight: 680; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.kpi-spark { position: absolute; right: 10px; bottom: 9px; width: 56px; height: 22px; opacity: .85; }
.kpi-spark svg { width: 100%; height: 100%; overflow: visible; }

/* =========================================================================
   ATTENTION QUEUE
   ========================================================================= */
.att-list { display: flex; flex-direction: column; }
.att {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); position: relative;
}
.att:last-child { border-bottom: none; }
.att:hover { background: var(--hover); }
.att-ico {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  display: grid; place-items: center; border: 1px solid transparent;
}
.att-ico svg { width: 15px; height: 15px; }
.att-ico.bad   { background: var(--bad-bg);   color: var(--bad);   border-color: var(--bad-line); }
.att-ico.warn  { background: var(--warn-bg);  color: var(--warn);  border-color: var(--warn-line); }
.att-ico.brand { background: var(--brand-bg); color: var(--brand); border-color: var(--brand-line); }
.att-ico.info  { background: var(--info-bg);  color: var(--info);  border-color: var(--info-line); }
.att-body { flex: 1; min-width: 0; }
.att-title { font-size: 12.5px; font-weight: 550; line-height: 1.3; }
.att-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.3; }
.att-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.att-amt { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.att-amt.bad { color: var(--bad); }

/* =========================================================================
   AGENDA
   ========================================================================= */
.agenda { display: flex; flex-direction: column; }
.ag-row {
  display: flex; gap: 11px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  position: relative; align-items: center;
}
.ag-row:last-child { border-bottom: none; }
.ag-row:hover { background: var(--hover); }
.ag-row.now { background: var(--info-bg); }
.ag-row.now::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2.5px; background: var(--info);
}
.ag-time {
  flex: none; width: 46px; text-align: right; padding-top: 1px;
  font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums;
}
.ag-time .t { font-size: 12.5px; font-weight: 600; }
.ag-time .d { font-size: 10px; color: var(--text-faint); }
.ag-line { flex: none; width: 2px; align-self: stretch; background: var(--line-2); border-radius: 2px; }
.ag-body { flex: 1; min-width: 0; }
.ag-cust { font-size: 12.5px; font-weight: 600; }
.ag-desc { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* =========================================================================
   ACTIVITY
   ========================================================================= */
.act { display: flex; align-items: flex-start; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: none; }
.act-ico { width: 24px; height: 24px; flex: none; border-radius: 7px; display: grid; place-items: center; }
.act-ico svg { width: 13px; height: 13px; }
.act-ico.ok { background: var(--ok-bg); color: var(--ok); }
.act-ico.info { background: var(--info-bg); color: var(--info); }
.act-ico.brand { background: var(--brand-bg); color: var(--brand); }
.act-body { flex: 1; min-width: 0; }
.act-title { font-size: 12px; font-weight: 500; line-height: 1.3; }
.act-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* =========================================================================
   DATA TABLE
   ========================================================================= */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data thead th {
  text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint); padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 2;
  user-select: none;
}
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable:hover { color: var(--text-2); }
table.data thead th .sort { display: inline-flex; align-items: center; gap: 3px; }
table.data thead th .caret { width: 10px; height: 10px; opacity: .55; }
table.data thead th.r, table.data td.r { text-align: right; }
table.data tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--hover); cursor: pointer; }
td .money { font-variant-numeric: tabular-nums; font-weight: 600; }
td .mono-id { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text-2); }
.cell-stack { line-height: 1.25; display: flex; flex-direction: column; min-width: 0; }
.cell-stack .a { font-weight: 550; }
.cell-stack .b { font-size: 11px; color: var(--text-3); }
/* Day-of-week pill in the Schedule column so a multi-day job list is legible at a
   glance (the clock time alone doesn't say which day). Neutral, compact. */
.day-chip { display: inline-block; font-size: 10.5px; font-weight: 650; letter-spacing: .01em;
  color: var(--text-2); background: var(--surface-3); border: 1px solid var(--line);
  border-radius: 5px; padding: 0 5px; margin-right: 2px; vertical-align: 1px; }
.tech-cell { display: inline-flex; align-items: center; gap: 7px; }

/* desktop toolbar above tables.
   `row-gap` on the base .toolbar means ANY toolbar that wraps to a second row gets
   vertical breathing room automatically — so a wrapped action row never collides
   with row 1. This is deliberately NOT dependent on a per-page class: jobs.html's
   padding regressed once precisely because a regenerated toolbar dropped the old
   `.toolbar-wrap` class. Standard spacing now lives on `.toolbar` itself, so every
   page (Jobs/Invoices/Estimates/Customers/…) is padded consistently and can't drift.
   column-gap 10px = horizontal button spacing; row-gap 12px = wrapped-row spacing. */
.toolbar { display: flex; align-items: center; column-gap: 10px; row-gap: 12px;
  margin-bottom: 10px; flex-wrap: wrap; }
.toolbar .sp { flex: 1; }
/* .toolbar-wrap (opt-in): force the actions onto their OWN full-width second row via
   a full-width spacer, for pages like Jobs where a wide inline search should push all
   actions below rather than wrap mid-cluster. The row-gap above supplies the spacing;
   no per-button margin needed. Pages without the class simply wrap inline, still padded. */
.toolbar-wrap .sp { flex-basis: 100%; height: 0; }
.seg {
  display: inline-flex; background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 2px; gap: 2px; overflow-x: auto;
}
.seg button {
  height: 27px; padding: 0 11px; border-radius: 6px; font-size: 12px; font-weight: 550;
  color: var(--text-3); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.seg button .n { font-variant-numeric: tabular-nums; font-size: 10.5px; color: var(--text-faint); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button.on .n { color: var(--text-2); }

/* =========================================================================
   MOBILE DENSE ROWS (jobs / invoices / customers collapse to these)
   ========================================================================= */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  border-bottom: 1px solid var(--line); position: relative;
}
.row:last-child { border-bottom: none; }
.row:active { background: var(--hover); }
.row-lead { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 44px; }
.row-time { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-2); text-align: center; font-variant-numeric: tabular-nums; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: center; gap: 7px; }
.row-id { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--text-faint); }
.row-cust { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-trail { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.row-amt { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* =========================================================================
   JOB DETAIL
   ========================================================================= */
.detail-grid { display: flex; flex-direction: column; gap: 12px; }
.kv { display: flex; padding: 9px 14px; border-bottom: 1px solid var(--line); gap: 12px; align-items: baseline; }
.kv:last-child { border-bottom: none; }
.kv .k { font-size: 11.5px; color: var(--text-3); width: 88px; flex: none; }
.kv .v { font-size: 12.5px; font-weight: 500; flex: 1; }
.kv .v.mono { font-family: 'JetBrains Mono', monospace; }

.li-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.li-row:last-child { border-bottom: none; }
.li-main { flex: 1; min-width: 0; }
.li-name { font-size: 12.5px; font-weight: 550; }
.li-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.li-amt { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.li-total {
  display: flex; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line-2);
  background: var(--surface-2);
}
.li-total .lbl { font-size: 12px; font-weight: 600; }
.li-total .amt { margin-left: auto; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px; }
.photo {
  aspect-ratio: 1; border-radius: 8px; border: 1px dashed var(--line-strong);
  background: var(--surface-2); display: grid; place-items: center; color: var(--text-faint);
}
.photo svg { width: 20px; height: 20px; }
.photo.add { border-style: solid; border-color: var(--line-2); color: var(--text-3); cursor: pointer; }
.photo.add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

.status-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 14px; }
.status-actions .btn.block { grid-column: span 1; }
.status-actions .btn.wide { grid-column: 1 / -1; }

.stepper { display: flex; padding: 14px; gap: 0; }
.step { flex: 1; display: flex; flex-direction: column; gap: 6px; position: relative; }
.step .bar { height: 3px; border-radius: 3px; background: var(--line-2); }
.step.done .bar { background: var(--ok); }
.step.curr .bar { background: var(--info); }
.step .lab { font-size: 10.5px; color: var(--text-3); font-weight: 550; }
.step.done .lab { color: var(--ok); }
.step.curr .lab { color: var(--info); }
/* 'Invoiced' is display-only (set only by creating an invoice), so it reads as a
   quieter, non-interactive terminal marker — no hover/pointer affordance. */
.step.locked .lab { color: var(--text-faint); }
.step.locked.done .lab, .step.locked.curr .lab { color: var(--ok); }
.step + .step { margin-left: 6px; }

.map-mini {
  height: 130px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--surface-2);
  position: relative; display: grid; place-items: center;
}
.map-pin { color: var(--accent); display: grid; place-items: center; gap: 4px; }
.map-pin svg { width: 24px; height: 24px; filter: drop-shadow(0 4px 8px var(--accent-glow)); }
.map-pin .lab { font-size: 11px; font-weight: 600; color: var(--text-2); }

/* =========================================================================
   MISC HELPERS
   ========================================================================= */
.stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 12px; }
.stat-mini {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.stat-mini .lab { font-size: 10.5px; color: var(--text-3); font-weight: 550; }
.stat-mini .val { font-size: 16px; font-weight: 680; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-mini .val.ok { color: var(--ok); }
.stat-mini .val.bad { color: var(--bad); }

.section-gap { height: 12px; }

.empty { padding: 28px 14px; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* Theme toggle on mobile lives in the top app bar (next to search/bell) — see
   .tb-theme below. The legacy floating FAB is fully removed so it can never
   overlap the bottom tab bar or its labels. */
.theme-fab { display: none !important; }

/* top-bar theme toggle (mobile) — swaps sun/moon glyph like the desktop one */
.tb-theme .moon { display: none; }
:root[data-theme='dark'] .tb-theme .moon { display: block; }
:root[data-theme='dark'] .tb-theme .sun { display: none; }

/* fade-in */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .32s cubic-bezier(.2,.7,.3,1) both; }

/* =========================================================================
   RESPONSIVE — desktop
   ========================================================================= */
@media (min-width: 880px) {
  body { font-size: 13px; }
  .topbar, .tabbar, .theme-fab { display: none; }
  .sidebar { display: flex; }
  .main { margin-left: 232px; }
  .head { display: flex; }
  /* Fluid: fill the viewport minus the sidebar. No hard cap — the app should use
     the whole browser width on any monitor. Gutters scale up a touch on wide screens. */
  .content { padding: 20px clamp(20px, 2.4vw, 56px) 48px; max-width: none; width: 100%; }
  .head { padding-left: clamp(20px, 2.4vw, 56px); padding-right: clamp(20px, 2.4vw, 56px); }

  .page-head { display: none; } /* title lives in header on desktop */

  .kpi-strip { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .kpi { padding: 14px 15px 13px; }
  .kpi-value { font-size: 25px; }
  .kpi-spark { width: 64px; height: 26px; }

  /* dashboard 2-col layout */
  .dash-grid { display: grid; grid-template-columns: 1fr 360px; gap: 14px; align-items: start; }
  .dash-main { display: flex; flex-direction: column; gap: 14px; }
  .dash-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 72px; }

  /* tables visible, mobile rows hidden */
  .only-mobile { display: none !important; }
  /* `display:block` reveals desktop-only blocks — but must NOT clobber the flex
     layout of buttons/segmented controls that are ALSO tagged .only-desktop (a
     toolbar's Filter/Export/New). Excluding them keeps icon+label centered and
     removed the per-page `!important` hacks that estimates/invoices/analytics
     previously needed. */
  .only-desktop:not(.btn):not(.seg) { display: block; }
  .btn.only-desktop { display: inline-flex; }
  .seg.only-desktop { display: inline-flex; }
  .stat-row { grid-template-columns: repeat(4, 1fr); }

  /* job detail two-column */
  .detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }
  .detail-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
  .detail-side { display: flex; flex-direction: column; gap: 14px; }

  .theme-desk {
    display: inline-grid; place-items: center; width: 32px; height: 32px;
    border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
    color: var(--text-2);
  }
  .theme-desk:hover { color: var(--text); border-color: var(--line-strong); }
  .theme-desk svg { width: 16px; height: 16px; }
  .theme-desk .moon { display: none; }
  :root[data-theme='dark'] .theme-desk .moon { display: block; }
  :root[data-theme='dark'] .theme-desk .sun { display: none; }
}

@media (max-width: 879px) {
  .only-desktop { display: none !important; }
  .theme-desk { display: none; }
  .head { display: none; }
  .dash-side, .dash-main { display: flex; flex-direction: column; gap: 12px; }
  .dash-grid { display: flex; flex-direction: column; gap: 12px; }
  .detail-grid { display: flex; flex-direction: column; gap: 12px; }
}

@media (min-width: 560px) and (max-width: 879px) {
  .kpi-strip { grid-template-columns: repeat(4, 1fr); }
  .content { padding: 16px 16px calc(72px + env(safe-area-inset-bottom, 0px)); }
}

/* Wide screens: use the space well. KPI strip can spread, side columns widen a touch,
   and the dashboard/detail main columns get more room without an awkward hard cap. */
@media (min-width: 1500px) {
  .content { padding-top: 24px; }
  .kpi-strip { gap: 16px; }
  .dash-grid { grid-template-columns: 1fr 400px; gap: 18px; }
  .detail-grid { grid-template-columns: 1fr 380px; gap: 18px; }
}
@media (min-width: 1900px) {
  .kpi-strip { grid-template-columns: repeat(4, 1fr); }
  .dash-grid { grid-template-columns: 1fr 440px; gap: 20px; }
  /* keep ultra-wide reading comfortable: very wide single-column pages get a soft cap */
  .content > .panel:only-child,
  .content > .stack-narrow { max-width: 1600px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- merged: customer photo cell + meta line ---------- */
.cust-cell { display: inline-flex; align-items: center; gap: 11px; }
.row-meta2 { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.row-meta2 .avatar.sm { width: 16px; height: 16px; border-radius: 4px; font-size: 8px; }
.photo-hint { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
/* mobile row lead now holds a 40px photo */
.row-lead { display: inline-flex; align-items: center; }

/* defensive: any inline icon svg without an explicit size defaults to 1em-ish
   (prevents stray ${ic()} calls from expanding to fill their flex container) */
:where(.add-line, .li-row, .kv, .chip, .tag, .seg button, .link-mini, .photo-toggle button, .att-row) svg {
  width: 15px; height: 15px; flex: none;
}

/* ---------- job-detail notes (F2) ---------- */
.notes-list { display:flex; flex-direction:column; }
.note-item { padding:12px 16px; border-bottom:1px solid var(--line); }
.note-item:last-child { border-bottom:none; }
.note-meta { display:flex; align-items:baseline; gap:8px; margin-bottom:3px; }
.note-meta b { font-size:12.5px; font-weight:600; }
.note-meta span { font-size:11px; color:var(--text-3); }
.note-text { font-size:13px; color:var(--text-2); line-height:1.5; }

/* ---------- customer properties / multi-address (F5) ---------- */
.prop-list { display:flex; flex-direction:column; }
.prop-item { padding:13px 16px; border-bottom:1px solid var(--line); }
.prop-item:last-child { border-bottom:none; }
.prop-top { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:5px; }
.prop-name { font-size:13.5px; font-weight:650; display:flex; align-items:center; }
.prop-actions { display:flex; align-items:center; gap:8px; }
.prop-addr { font-size:12.5px; color:var(--text-2); display:flex; align-items:center; gap:6px; margin-bottom:6px; }
.prop-meta { display:flex; align-items:center; gap:8px; font-size:11.5px; color:var(--text-3); flex-wrap:wrap; }
.prop-meta a { color:var(--accent-2); font-weight:550; }
.prop-meta .dotsep { color:var(--text-faint); }
.prop-note { display:flex; align-items:center; gap:8px; padding:11px 16px; font-size:11.5px; color:var(--text-3);
  background:var(--surface-2); border-top:1px solid var(--line); border-radius:0 0 var(--radius-lg) var(--radius-lg); }
.prop-note svg { width:14px; height:14px; flex:none; color:var(--text-faint); }

/* =========================================================================
   UI polish pass — accessibility + feedback improvements (shared, no build)
   ========================================================================= */

/* (1) Keyboard focus ring. There was NO visible focus indicator anywhere, so a
   keyboard/switch user couldn't tell which control was active. :focus-visible
   only shows for keyboard nav (not mouse clicks), so it doesn't add ring noise
   for pointer users. Applies to every interactive element the app renders. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.sb-link:focus-visible,
.tab:focus-visible,
.seg button:focus-visible,
.icon-btn:focus-visible,
.chip[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
/* Don't let the outline get clipped by a focused row inside a scroll container. */
.cmdk-row:focus-visible, .notif-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* (2) Loading skeleton shimmer — a reusable placeholder for content that hasn't
   hydrated yet (boot.js background refresh). Pages can drop <div class="skel">
   blocks in and they animate a subtle sweep instead of showing a blank panel. */
.skel {
  position: relative; overflow: hidden;
  background: var(--surface-2); border-radius: var(--radius-sm);
  min-height: 12px;
}
.skel::after {
  content: ''; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--hover), transparent);
  animation: skelSweep 1.25s ease-in-out infinite;
}
@keyframes skelSweep { 100% { transform: translateX(100%); } }
.skel.line { height: 12px; margin: 7px 0; }
.skel.line.short { width: 40%; }
.skel.line.med { width: 65%; }

/* (3) Copy-on-click affordance for contact chips (phone/email). Gives a pointer
   cursor + a subtle hover so users learn these are actionable. */
.copyable { cursor: pointer; border-radius: 5px; transition: background .12s ease; }
.copyable:hover { background: var(--accent-bg); }

/* (4) Sidebar badge readability — a hair more contrast + tabular digits so the
   nav counts don't shift width as they change. */
.sb-badge { font-variant-numeric: tabular-nums; }

/* (5) Respect reduced-motion for the new shimmer too. */
@media (prefers-reduced-motion: reduce) {
  .skel::after { animation: none; }
}

/* (6) Bigger tap targets on the mobile bottom tab bar for thumb reach. */
@media (max-width: 879px) {
  .tabbar .tab { min-height: 52px; }
}
