/* FoundersCore — design tokens & base styles */
:root {
  /* Brand */
  --navy-900: #161B26;
  --navy-800: #1F2636;
  --navy-700: #2A3346;
  --navy-600: #38425A;
  --navy-500: #5A6582;
  --yellow:   #2B7BF5;
  --yellow-2: #4F94FF;
  --yellow-soft: #E4EEFE;

  /* Neutrals (warm) */
  --bg:        #F4F6FA;
  --bg-2:      #EEF1F6;
  --card:      #FFFFFF;
  --line:      #E4E7EE;
  --line-2:    #EFF1F5;
  --text:      #0F172A;
  --text-2:    #475569;
  --muted:     #7B8699;
  --muted-2:   #99A2B3;

  /* Semantic */
  --success:   oklch(63% 0.14 152);
  --success-bg: oklch(95% 0.04 152);
  --warn:      oklch(72% 0.14 78);
  --warn-bg:   oklch(96% 0.06 90);
  --danger:    oklch(60% 0.18 25);
  --danger-bg: oklch(96% 0.04 25);
  --info:      oklch(60% 0.14 245);
  --info-bg:   oklch(96% 0.04 245);

  /* Spacing & radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl: 24px;

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 14px 40px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-pop: 0 20px 60px rgba(14, 26, 54, 0.22);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-feature-settings: "cv05", "cv11", "ss01";
  letter-spacing: -0.006em; /* Inter reads tighter/cleaner at UI sizes */
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden; /* app shell scrolls internally */
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D5DAE2; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #B7BFCD; }
::-webkit-scrollbar-track { background: transparent; }

/* App layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 248px) 1fr;
  height: 100vh;
  background: var(--bg);
}

.app.collapsed { --sidebar-w: 72px; }
.app.copilot-open { grid-template-columns: var(--sidebar-w, 248px) 1fr 380px; }

/* Sidebar */
.sidebar {
  background: var(--navy-900);
  color: #DDE3F0;
  padding: 18px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid rgba(255,255,255,0.04);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
}
.sidebar .brand img { width: 36px; height: 36px; border-radius: 8px; background: white; padding: 2px; object-fit: contain; }
.sidebar .brand .name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: #fff;
}
.sidebar .brand .sub {
  font-size: 11px;
  color: var(--yellow);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-section {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: #6B7795;
  text-transform: uppercase;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #B8C2D7;
  font-size: 14px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  position: relative;
  white-space: nowrap;
}
.nav-item .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active {
  background: rgba(242, 201, 76, 0.12);
  color: #fff;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--yellow);
}
.nav-item .badge {
  margin-left: auto;
  background: var(--yellow);
  color: var(--navy-900);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
}
.sidebar .footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: var(--navy-900);
  flex-shrink: 0;
}
.sidebar .footer .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--yellow), #1854B8);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.app.collapsed .nav-item span.label,
.app.collapsed .brand .name,
.app.collapsed .brand .sub,
.app.collapsed .nav-section,
.app.collapsed .footer .who { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.app.collapsed .brand { justify-content: center; padding: 6px 0 16px; }

.sidebar .footer .who { display: flex; flex-direction: column; min-width: 0; }
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  min-height: 64px;
}
.topbar .crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.topbar .crumbs .cur { color: var(--text); font-weight: 500; }
.topbar .search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 10px;
  width: 380px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s;
  white-space: nowrap;
}
.topbar .search span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; text-align: left; }
.topbar .search:hover { border-color: #CFD5E0; }
.topbar .search kbd {
  margin-left: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.topbar .icon-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.topbar .icon-btn:hover { background: var(--bg-2); }
.topbar .icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--yellow);
  border: 2px solid var(--card);
}
.topbar .copilot-cta {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--navy-800), var(--navy-700));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.topbar .copilot-cta:hover { background: linear-gradient(135deg, var(--navy-700), var(--navy-600)); }
.topbar .copilot-cta .spark { color: var(--yellow); }

.content {
  flex: 1;
  overflow: auto;
  padding: 28px;
}
.content.tight { padding: 0; }

/* Customer portal runs outside the app shell, so it needs page-level scroll.
   The main FoundersCore app keeps body overflow hidden and scrolls .content. */
body.contact-portal-page {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 100vh;
  /* The portal's inline styles use var(--accent); without these it resolves to
     transparent (e.g. the customer's own message bubbles render white-on-blank).
     Match the brand blue used by .btn.accent / login.html. */
  --accent: #2B7BF5;
  --accent-2: #4F94FF;
  --accent-soft: #E4EEFE;
  --success-soft: #ECFDF3;
}
body.contact-portal-page #root {
  height: auto;
  min-height: 100vh;
}
body.contact-portal-page .portal-shell {
  min-height: 100vh;
  overflow-x: hidden;
}
body.contact-portal-page .portal-main {
  min-height: 0;
}
body.contact-portal-page .portal-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* The property/unit tab strip is one swipeable row of pills: no wrapping and
   no visible scrollbar — a half-visible pill at the edge reads as "more tabs
   this way". */
.portal-tab-strip {
  display: flex;
  gap: 6px;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px;
}
.portal-tab-strip::-webkit-scrollbar { display: none; }
.portal-tab-strip .portal-tab {
  flex-shrink: 0;
  white-space: nowrap;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.portal-tab-strip .portal-tab.active {
  background: var(--navy-800);
  color: #fff;
}
.portal-tab-strip .portal-tab:not(.active):hover {
  background: var(--bg-2);
  color: var(--text);
}
body.contact-portal-page .portal-table-scroll {
  overflow-y: auto;
}
body.contact-portal-page .portal-table-scroll .tbl {
  min-width: 760px;
}
body.contact-portal-page .portal-modal-card {
  max-height: min(860px, calc(100vh - 72px));
}
body.contact-portal-page .portal-modal-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---- Customer-portal visual refresh (scoped, so the staff app is untouched).
   Softer borders, gentler shadows, larger radii, calmer typography. ---- */
body.contact-portal-page { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body.contact-portal-page .card {
  border-color: #ECEFF4;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
body.contact-portal-page .card-pad { padding: 18px; }
body.contact-portal-page .kpi {
  border-color: #ECEFF4;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
body.contact-portal-page .kpi .label { font-size: 11px; letter-spacing: 0.05em; }
body.contact-portal-page .btn { border-radius: 11px; }
body.contact-portal-page .btn.sm { border-radius: 9px; }
/* Roomier, lighter table cells read less like a spreadsheet. */
body.contact-portal-page .tbl th { font-size: 11px; letter-spacing: 0.05em; padding: 11px 14px; }
body.contact-portal-page .tbl td { padding: 13px 14px; }
body.contact-portal-page .tbl th, body.contact-portal-page .tbl td { border-color: var(--line-2); }
body.contact-portal-page h1 { letter-spacing: -0.025em; }

/* Two columns on desktop, one stacked column on a phone. Used by the portal
   detail modals (past/future visits, totals + payments, visit who/when) so
   content never gets squeezed into unreadably narrow columns. */
.portal-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Phone widths: tighten card padding so cards aren't mostly whitespace. (Grid
   column counts are handled inline via auto-fit, so cards wrap on narrow
   screens instead of squeezing their contents off-screen.) */
@media (max-width: 640px) {
  body.contact-portal-page .card-pad { padding: 15px; }
  .portal-two-col { grid-template-columns: 1fr; }
}

/* Common UI */
.h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.h3 { font-size: 14px; font-weight: 600; margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-2);
}
.card-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.card-head .meta { color: var(--muted); font-size: 13px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  transition: all .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-2); }
.btn.primary {
  background: var(--navy-800); color: white; border-color: var(--navy-800);
}
.btn.primary:hover { background: var(--navy-700); }
.btn.accent {
  background: var(--yellow); color: white; border-color: var(--yellow);
  font-weight: 600;
}
.btn.accent:hover { background: var(--yellow-2); border-color: var(--yellow-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-2); color: var(--text); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 8px; }
/* Visit popover action buttons: uniform auto-fit grid → center each button. */
.visit-action-grid .btn { justify-content: center; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warn    { background: var(--warn-bg);    color: var(--warn); }
.badge.danger  { background: var(--danger-bg);  color: var(--danger); }
.badge.info    { background: var(--info-bg);    color: var(--info); }
.badge.navy    { background: rgba(30,47,85,0.08); color: var(--navy-800); }
.badge.yellow  { background: var(--yellow-soft); color: #1854B8; }

/* Grids used across modules */
.grid { display: grid; gap: 18px; }
.row  { display: flex; gap: 18px; }
.row.tight { gap: 12px; }
.col  { display: flex; flex-direction: column; gap: 12px; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td {
  text-align: left;
  padding: 14px 18px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line-2);
}
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.row-link:hover { background: var(--bg-2); cursor: pointer; }
.tbl .num { font-family: var(--font-mono); text-align: right; font-feature-settings: "tnum"; }

/* Avatars */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 12px; font-weight: 600;
  background: var(--navy-800); color: white;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; }
.avatar.lg { width: 44px; height: 44px; font-size: 14px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--card); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* KPI cards */
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .value { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; font-family: var(--font-sans); font-feature-settings: "tnum"; }
.kpi .trend { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; margin-top: 8px; }
.kpi .trend.up { color: var(--success); }
.kpi .trend.down { color: var(--danger); }
.kpi .sparkline { position: absolute; right: 14px; bottom: 14px; opacity: 0.9; }

/* Forms */
/* min-width:0 lets a .field shrink inside a grid/flex row — without it, date &
   number inputs keep their large intrinsic width and overflow the container. */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.input, .select, .textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(30,47,85,0.10);
}
.textarea { resize: vertical; min-height: 80px; font-family: inherit; }

/* Input with a prefix/suffix affix ($, /hr, etc.). The BORDER + focus ring live
   on the wrapper; the inner input is borderless so there's no box-in-a-box. */
.input-affix {
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card);
  transition: border-color .12s, box-shadow .12s;
}
.input-affix:focus-within { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(30,47,85,0.10); }
.input-affix > input { flex: 1; min-width: 0; border: none; background: transparent; padding: 10px 0; font: inherit; font-size: 13.5px; color: var(--text); outline: none; }
.input-affix > .affix { color: var(--muted); font-size: 13px; white-space: nowrap; }
/* No native number spinner in a currency-style affix field — type the value. */
.input-affix > input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.input-affix > input[type=number]::-webkit-outer-spin-button,
.input-affix > input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Cmd K modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(14, 26, 54, 0.35);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  /* 4vh top + 4vh bottom so modals up to 92vh tall fit on screen without
     clipping their footers. The previous 12vh top combined with modals'
     maxHeight: 92vh pushed the footer 4vh below the viewport. */
  padding: 4vh 16px;
  overflow-y: auto;
}

/* Google Places autocomplete dropdown — Google appends .pac-container to
   <body> with z-index: 1000. Some of our modals run hotter than that, so
   force the dropdown above anything we throw at it. */
.pac-container {
  z-index: 10000 !important;
}
.cmdk {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(640px, 92vw);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.cmdk .input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}
.cmdk input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; color: var(--text);
}
.cmdk .results { max-height: 50vh; overflow: auto; padding: 8px; }
.cmdk .group-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 10px 12px 4px; }
.cmdk .result {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
}
.cmdk .result:hover, .cmdk .result.sel { background: var(--bg-2); }
.cmdk .result .kbd { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.cmdk .result .ico { color: var(--muted); display: flex; }

/* Copilot drawer */
.copilot {
  background: var(--card);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.copilot .head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-2);
}
.copilot .head .av {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--navy-800), var(--navy-600));
  color: var(--yellow);
  display: flex; align-items: center; justify-content: center;
}
.copilot .body {
  flex: 1; overflow: auto; padding: 18px;
  display: flex; flex-direction: column; gap: 16px;
}
.copilot .compose {
  border-top: 1px solid var(--line-2);
  padding: 14px;
}
.copilot .bubble {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg-2);
  color: var(--text);
}
.copilot .bubble.me {
  background: var(--navy-800);
  color: #E8ECF6;
  align-self: flex-end;
  max-width: 80%;
}
.copilot .bubble.ai { background: var(--bg-2); }
.copilot .bubble.ai .src { font-size: 11px; color: var(--muted); margin-top: 8px; }
.copilot .suggest {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.copilot .suggest button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 12px;
  padding: 6px 11px;
  color: var(--text-2);
}
.copilot .suggest button:hover { background: var(--bg-2); color: var(--text); }
.copilot .compose .input-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  display: flex; align-items: end; gap: 6px;
}
.copilot .compose textarea {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  font-size: 13.5px; padding: 6px 0; min-height: 24px;
  font-family: inherit;
}

/* Schedule */
.schedule {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.schedule .hd, .schedule .rw {
  display: grid;
  grid-template-columns: 160px repeat(7, 1fr);
}
.schedule .hd {
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.schedule .hd > div {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-right: 1px solid var(--line-2);
}
.schedule .hd > div:last-child { border-right: none; }
.schedule .hd .day-num { font-size: 16px; color: var(--text); font-weight: 600; letter-spacing: 0; text-transform: none; }
.schedule .rw {
  border-bottom: 1px solid var(--line-2);
  min-height: 90px;
}
.schedule .rw:last-child { border-bottom: none; }
.schedule .crew-cell {
  padding: 14px;
  border-right: 1px solid var(--line-2);
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg);
}
.schedule .crew-cell .name { font-weight: 600; font-size: 13.5px; }
.schedule .crew-cell .sub { font-size: 12px; color: var(--muted); }
.schedule .day-cell {
  border-right: 1px solid var(--line-2);
  padding: 6px;
  display: flex; flex-direction: column; gap: 5px;
  min-height: 90px;
}
.schedule .day-cell:last-child { border-right: none; }
.schedule .day-cell.drag-over { background: var(--yellow-soft); }
.job-chip {
  background: var(--navy-800);
  color: white;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12px;
  border-left: 3px solid var(--yellow);
  cursor: grab;
  display: flex; flex-direction: column; gap: 2px;
}
.job-chip:active { cursor: grabbing; }
.job-chip .who { color: rgba(255,255,255,0.7); font-size: 10.5px; }
.job-chip.water  { background: #194b6e; border-left-color: #46BCE6; }
.job-chip.fire   { background: #6b2e16; border-left-color: #FF8C42; }
.job-chip.mold   { background: #2c5a3a; border-left-color: #4FCB81; }
.job-chip.recon  { background: #4b3e6e; border-left-color: #B084EB; }
.job-chip.maint  { background: var(--navy-800); border-left-color: var(--yellow); }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.kanban-col {
  background: var(--bg-2);
  border-radius: 14px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 200px;
}
.kanban-col .col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 6px; }
.kanban-col .col-head .count {
  background: var(--card); color: var(--muted); padding: 2px 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 500; margin-left: auto;
}
.kanban-card {
  background: var(--card);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.kanban-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kanban-card .title { font-weight: 600; font-size: 13.5px; margin: 6px 0 4px; }
.kanban-card .meta { font-size: 12px; color: var(--muted); }
.kanban-card .row { margin-top: 10px; align-items: center; justify-content: space-between; }

/* Chat */
.chat { display: grid; grid-template-columns: 240px 1fr 280px; height: 100%; }
.chat .channels {
  background: var(--card); border-right: 1px solid var(--line);
  padding: 12px; display: flex; flex-direction: column; gap: 2px; overflow: auto;
}
.chat .channels .ch-section { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 14px 10px 4px; }
.chat .channels .ch {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-2); cursor: pointer;
}
.chat .channels .ch:hover { background: var(--bg-2); color: var(--text); }
.chat .channels .ch.active { background: var(--navy-800); color: white; }
.chat .channels .ch .unread { margin-left: auto; background: var(--yellow); color: var(--navy-900); font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; }
.chat .panel { display: flex; flex-direction: column; min-width: 0; }
.chat .panel .hd {
  padding: 14px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px;
}
.chat .stream { flex: 1; overflow: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.chat .msg { display: flex; gap: 12px; }
.chat .msg .body { flex: 1; min-width: 0; }
.chat .msg .who { font-weight: 600; font-size: 13.5px; }
.chat .msg .ts  { font-size: 11.5px; color: var(--muted); margin-left: 8px; }
.chat .msg .txt { font-size: 13.5px; line-height: 1.55; margin-top: 2px; }
.chat .msg .attach {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); padding: 8px 12px; border-radius: 8px; font-size: 12.5px;
  background: var(--bg);
}
.chat .compose {
  border-top: 1px solid var(--line);
  padding: 12px 22px 18px;
}
.chat .compose .wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card);
}
.chat .compose textarea {
  border: none; outline: none; resize: none; min-height: 44px;
  font-size: 13.5px; background: transparent;
  font-family: inherit;
}
.chat .compose .actions { display: flex; align-items: center; gap: 6px; }
.chat .info {
  background: var(--card); border-left: 1px solid var(--line);
  padding: 18px; display: flex; flex-direction: column; gap: 18px; overflow: auto;
}

/* Detail panes */
.split { display: grid; grid-template-columns: 1fr 380px; gap: 18px; }
.split .side { display: flex; flex-direction: column; gap: 14px; }

.timeline { display: flex; flex-direction: column; gap: 14px; position: relative; }
.timeline .t-item { display: flex; gap: 12px; }
.timeline .t-item .ico {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.timeline .t-item .ico.ai { background: var(--navy-800); color: var(--yellow); }
.timeline .t-item .ico.green { background: var(--success-bg); color: var(--success); }
.timeline .t-item .ico.yel { background: var(--yellow-soft); color: #1854B8; }
.timeline .t-item .info .who { font-weight: 600; font-size: 13px; }
.timeline .t-item .info .what { font-size: 13px; color: var(--text-2); }
.timeline .t-item .info .ts { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Image placeholders */
.ph {
  background: repeating-linear-gradient(135deg, #EEF1F6 0 8px, #E4E8F0 8px 16px);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Empty / overlay */
.empty {
  padding: 60px 28px;
  text-align: center;
  color: var(--muted);
}

/* AI accent */
.ai-bg {
  background:
    radial-gradient(circle at 12% 18%, rgba(43,123,245,0.22) 0%, transparent 42%),
    radial-gradient(circle at 85% 80%, rgba(43,123,245,0.10) 0%, transparent 45%),
    linear-gradient(135deg, var(--navy-900), var(--navy-700));
  color: white;
}

.notif-pop {
  position: absolute;
  top: 56px;
  right: 28px;
  width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  z-index: 50;
  overflow: hidden;
}
.notif-pop .head { padding: 14px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.notif-pop .list { max-height: 70vh; overflow: auto; }
.notif-pop .n {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line-2); align-items: flex-start;
}
.notif-pop .n:last-child { border-bottom: none; }
.notif-pop .n .ico {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* Document signing */
.doc-pane {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 36px 44px;
  line-height: 1.55;
  font-size: 13.5px;
  color: var(--text-2);
}
.doc-pane h2.doc-title { font-family: var(--font-sans); font-size: 22px; font-weight: 600; color: var(--text); margin: 0 0 4px; }
.doc-pane h3.doc-sec { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--navy-800); margin: 22px 0 6px; }
.sig-field {
  margin-top: 30px;
  border-top: 1px dashed var(--muted-2);
  padding-top: 10px;
  display: flex; align-items: center; gap: 14px;
}
.sig-field .label { font-size: 12px; color: var(--muted); }
.sig-area {
  min-width: 220px; height: 56px; border: 2px dashed var(--yellow); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--yellow-soft);
  color: #1854B8; font-size: 12.5px; font-weight: 500;
  cursor: pointer;
}
.sig-area.signed {
  background: white;
  border-style: solid;
  border-color: var(--success);
  color: var(--text);
  font-family: "Caveat", "Brush Script MT", cursive;
  font-size: 28px;
  font-weight: 400;
}

/* Approve bar */
.approve-bar {
  background: var(--navy-800);
  color: white;
  padding: 14px 22px;
  border-radius: 12px;
  display: flex; align-items: center; gap: 14px;
}
.approve-bar .who { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.approve-bar .actions { margin-left: auto; display: flex; gap: 8px; }

/* utility */
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line-2); margin: 6px 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 99px;
  background: var(--bg-2); font-size: 11.5px; color: var(--text-2);
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs .tab {
  padding: 10px 14px; font-size: 13.5px; color: var(--muted);
  background: transparent; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs .tab.active { color: var(--navy-800); border-bottom-color: var(--navy-800); font-weight: 600; }
.tabs .tab:hover { color: var(--text); }

/* Equipment cards */
.eq-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; display: flex; gap: 14px; align-items: center;
}
.eq-card .img {
  width: 64px; height: 64px; border-radius: 10px;
  background: var(--bg-2); display: flex; align-items: center; justify-content: center;
  color: var(--navy-800);
}

/* charts */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding: 8px 0; }
.bars .bar {
  flex: 1; background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  border-radius: 6px 6px 2px 2px;
  position: relative;
}
.bars .bar.accent { background: linear-gradient(180deg, var(--yellow), #d6a82c); }
.bars .bar .lbl { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }

.ring {
  --p: 0.65;
  --c: var(--navy-800);
  --bg: var(--bg-2);
  width: 120px; height: 120px;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 360deg), var(--bg) 0);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.ring::after {
  content: ""; position: absolute; inset: 12px; background: var(--card); border-radius: 50%;
}
.ring .v { position: relative; z-index: 1; font-size: 22px; font-weight: 600; font-family: var(--font-sans); font-feature-settings: "tnum"; }

/* Marketing */
.brand-tone { background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); color: white; }

/* Sub-portal tab strip — horizontally scrollable on a phone, no visible scrollbar */
.fc-tabstrip::-webkit-scrollbar { display: none; }

/* Skeleton loading — shimmer placeholders shown while a list/detail is fetching.
   Reads as "loading" instead of an empty state. Respects reduced-motion. */
.skln {
  display: inline-block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--border) 37%, var(--bg-2) 63%);
  background-size: 400% 100%;
  animation: skln-shimmer 1.4s ease infinite;
}
@keyframes skln-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skln { animation: none; } }

/* Full-page list tables — the app scrolls .content, so lists that drop their
   fixed-height inner scrollbox now flow down the page with a single scrollbar.
   Pin the column headers so they stay visible while scrolling (Jobber-style).
   box-shadow draws the header divider because a border on a sticky, collapsed
   cell drops out while pinned. */
.tbl thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
  box-shadow: inset 0 -1px 0 var(--line-2);
}

/* Small inline spinner for "loading more" (infinite scroll). */
.fc-spin {
  display: inline-block; width: 13px; height: 13px; vertical-align: -2px; margin-right: 6px;
  border: 2px solid var(--line-2); border-top-color: var(--navy-800); border-radius: 50%;
  animation: fc-spin 0.7s linear infinite;
}
@keyframes fc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .fc-spin { animation: none; } }
