/* Tervo AI Control Panel: quiet neutrals, one accent, hairline borders. */
:root {
  --bg: #f5f6fa;
  --sidebar: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #f8f8f9;
  --hover: #f4f4f5;
  --border: #ececee;
  --border-strong: #dedee2;
  --text: #0b0b0f;
  --text-2: #5d5d68;
  --text-3: #9b9ba6;
  --ink: #111114;            /* primary buttons, active chips */
  --on-ink: #ffffff;
  --accent: #5b5bd6;         /* the one accent */
  --accent-soft: #f0f0fe;
  --accent-line: #c9c9f6;
  --accent-text: #3e3eb0;
  --green: #12805c;  --green-soft: #ecf8f3;
  --blue: #1e63d6;   --blue-soft: #edf3fd;
  --violet: #6e47d6; --violet-soft: #f3effd;
  --amber: #a85b05;  --amber-soft: #fff8eb; --amber-line: #f5d9a6;
  --gray: #5d5d68;   --gray-soft: #f2f2f4;
  --red: #c4320a;
  --imsg-blue: #0a84ff;
  --imsg-gray: #e9e9eb;
  --imsg-gray-text: #0b0b0f;
  --shadow-xs: 0 1px 2px rgba(16, 16, 20, .04);
  --shadow-sm: 0 1px 3px rgba(16, 16, 20, .06), 0 1px 2px rgba(16, 16, 20, .04);
  --shadow-lg: 0 24px 64px -16px rgba(16, 16, 20, .22), 0 2px 6px rgba(16, 16, 20, .05);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0e; --sidebar: #0f0f12; --surface: #141417; --surface-2: #18181c; --hover: #1c1c21;
    --border: #232328; --border-strong: #2e2e35;
    --text: #f4f4f6; --text-2: #a8a8b3; --text-3: #6c6c78;
    --ink: #f4f4f6; --on-ink: #0c0c0e;
    --accent: #8b8bff; --accent-soft: #1b1b33; --accent-line: #34345c; --accent-text: #c3c3ff;
    --green: #4cd3a0; --green-soft: #0d2620;
    --blue: #7db3ff; --blue-soft: #0f1f38;
    --violet: #b9a3ff; --violet-soft: #211a3a;
    --amber: #f5b85a; --amber-soft: #281d0a; --amber-line: #4d3712;
    --gray: #a8a8b3; --gray-soft: #1f1f24;
    --red: #ff8a6b;
    --imsg-gray: #26262a; --imsg-gray-text: #f4f4f6;
    --shadow-xs: none; --shadow-sm: none;
    --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5; letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.sub { color: var(--text-2); margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

/* ---------- Sidebar (always dark: gives the whole app depth) ---------- */
.sidebar {
  --s-bg: #0d0f17; --s-hover: #171a26; --s-active: #1e2233; --s-line: #1f2333;
  --s-text: #c9ccd8; --s-text-2: #8a8fa3; --s-text-3: #5b6075;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; background:
    radial-gradient(120% 50% at 0% 0%, rgba(91, 91, 214, .18), transparent 60%),
    var(--s-bg);
  border-right: 1px solid var(--s-line); color: var(--s-text); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; color: #fff; display: grid; place-items: center; font-size: 16px;
  background: linear-gradient(135deg, #6d6df5 0%, #8b5cf6 55%, #c026d3 100%); box-shadow: 0 6px 18px -6px rgba(139, 92, 246, .7); }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; color: #fff; }

.switcher { display: flex; flex-direction: column; gap: 6px; padding: 0 2px; }
.switcher-label, .nav-label { font-size: 10.5px; font-weight: 600; color: var(--s-text-3); text-transform: uppercase; letter-spacing: .08em; padding: 0 8px; }
.nav-label { margin: 12px 0 4px; }
.switcher-box { position: relative; display: flex; align-items: center; background: var(--s-hover);
  border: 1px solid var(--s-line); border-radius: 10px; }
.switcher-box select { appearance: none; width: 100%; border: 0; background: transparent; outline: none; color: #fff;
  padding: 9px 30px 9px 12px; font-weight: 500; font-size: 13.5px; cursor: pointer; text-overflow: ellipsis; }
.switcher-box select option { background: #171a26; color: #fff; }
.switcher-box .ti { position: absolute; right: 10px; color: var(--s-text-2); pointer-events: none; font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: none;
  padding: 8px 10px; border-radius: 9px; color: var(--s-text-2); font-weight: 500; font-size: 13.5px; cursor: pointer;
  text-align: left; transition: background .12s, color .12s; position: relative; }
.nav-item .ti { font-size: 17px; color: var(--s-text-3); transition: color .12s; }
.nav-item span:nth-of-type(1) { flex: 1; }
.nav-item:hover { background: var(--s-hover); color: #fff; }
.nav-item:hover .ti { color: var(--s-text); }
.nav-item.active { background: var(--s-active); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #8b8bff, #a855f7); }
.nav-item.active .ti { color: #a5a5ff; }
.count { font-size: 11.5px; font-weight: 500; color: var(--s-text-3); font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: var(--s-text-2); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 4px 0;
  border-top: 1px solid var(--s-line); }
.sim-launch { display: flex; align-items: center; justify-content: center; gap: 8px; height: 36px; border-radius: 10px; cursor: pointer;
  border: 1px solid #2c3048; background: linear-gradient(180deg, #1c2033, #161929); color: #fff; font-weight: 500; font-size: 13px;
  transition: border-color .15s; }
.sim-launch:hover { border-color: #5b5bd6; }
.sim-launch .ti { color: #a5a5ff; font-size: 16px; }
.sidebar .ai-status { color: var(--s-text-2); padding: 0 4px; }
.sidebar .local-note { color: var(--s-text-3); padding: 0 4px; }
.ai-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.ai-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.ai-status.on .dot { background: #17b26a; box-shadow: 0 0 0 3px color-mix(in srgb, #17b26a 22%, transparent); }
.ai-status.off .dot { background: #f79009; }
.local-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }

/* ---------- Main ---------- */
.main { min-width: 0; padding: 32px 36px 48px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.eyebrow { font-size: 11.5px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.028em; margin: 6px 0 4px; line-height: 1.15; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.012em; margin: 0; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--text-2);
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-xs); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: #17b26a; position: relative; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid #17b26a;
  opacity: 0; animation: ping 2.4s cubic-bezier(.2,.6,.3,1) infinite; }
@keyframes ping { 0% { transform: scale(.5); opacity: .8; } 100% { transform: scale(1.8); opacity: 0; } }

/* ---------- Metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; }
.metric { padding: 18px 22px; border-right: 1px solid var(--border); transition: background .2s; }
.metric:last-child { border-right: 0; }
.metric-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.metric-label .ti { font-size: 14px; }
.metric-value { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; margin-top: 6px; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.metric-foot { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.metric-warn .metric-label .ti { display: none; }
.metric-warn.active { background: var(--amber-soft); }
.metric-warn.active .metric-label, .metric-warn.active .metric-value { color: var(--amber); }
.metric-warn.active .metric-label .ti { display: inline; }

/* ---------- Workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); min-height: 640px; }
.tab-body { padding: 20px 22px 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-sub { font-size: 12px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em;
  margin: 28px 0 10px; }

/* Next up */
.next-up { display: flex; align-items: center; gap: 20px; padding: 16px 18px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 20px; cursor: pointer;
  position: relative; overflow: hidden; transition: border-color .15s, background .15s; }
.next-up::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.next-up:hover { border-color: var(--border-strong); background: var(--hover); }
.next-when { min-width: 132px; padding-right: 20px; border-right: 1px solid var(--border); }
.next-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); }
.next-day { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.next-time { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.next-who { flex: 1; min-width: 0; }
.next-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.next-addr { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.next-addr .ti { color: var(--text-3); }
.next-go { color: var(--text-3); font-size: 18px; transition: transform .15s, color .15s; }
.next-up:hover .next-go { color: var(--text); transform: translateX(2px); }
.next-up.next-empty { cursor: default; }
.next-up.next-empty::before { background: var(--border-strong); }
.next-up.next-empty:hover { background: var(--surface-2); border-color: var(--border); }
.next-up.next-empty > .ti { font-size: 24px; color: var(--text-3); }

/* Legend + week grid */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.booked { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent), inset 0 0 0 1px var(--accent-line); }
.sw.busy { background: var(--gray-soft); box-shadow: inset 0 0 0 1px var(--border-strong); }
.sw.open { box-shadow: inset 0 0 0 1px var(--border-strong); }
.week { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.day { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.day-head { font-size: 12.5px; font-weight: 600; letter-spacing: -0.01em; padding: 0 2px 4px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.cell { border-radius: 8px; padding: 7px 10px; font-size: 12px; min-height: 50px; transition: background .12s, border-color .12s; }
.cell-time { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-name { font-weight: 600; font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-addr { font-size: 11.5px; color: var(--text-2); line-height: 1.3; margin: 1px 0;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.cell-sub { font-size: 11.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.booked { background: var(--accent-soft); border: 1px solid var(--accent-line); box-shadow: inset 3px 0 0 var(--accent);
  cursor: pointer; }
.cell.booked:hover { border-color: var(--accent); }
.cell.booked .cell-time { color: var(--accent-text); }
.cell.busy { background: var(--gray-soft); border: 1px solid transparent; }
.cell.busy .cell-sub { color: var(--text-3); }
.cell.open { border: 1px solid var(--border); }
.cell.open .cell-sub { color: var(--text-3); }

/* ---------- Tables ---------- */
.table { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) 140px 84px; gap: 14px;
  align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.head { cursor: default; background: var(--surface-2); font-size: 11.5px; color: var(--text-3); font-weight: 500;
  text-transform: uppercase; letter-spacing: .05em; padding: 9px 16px; }
.row.head:hover { background: var(--surface-2); }
.row.booking { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1.3fr); }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gray-soft); color: var(--text-2);
  display: grid; place-items: center; font-weight: 600; font-size: 11.5px; flex-shrink: 0; letter-spacing: 0; }
.person-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-sub { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cell-muted { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.when { font-size: 12.5px; color: var(--text-3); text-align: right; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 9px;
  border-radius: 999px; white-space: nowrap; justify-self: start; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.new { background: var(--blue-soft); color: var(--blue); }
.pill.contacted { background: var(--violet-soft); color: var(--violet); }
.pill.booked, .pill.won { background: var(--green-soft); color: var(--green); }
.pill.lost { background: var(--gray-soft); color: var(--gray); }
.pill.owner { background: var(--amber-soft); color: var(--amber); }
.pills { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.empty { padding: 56px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty .ti { font-size: 26px; display: block; margin-bottom: 10px; }
.empty b { color: var(--text); font-weight: 500; display: block; margin-bottom: 2px; font-size: 14px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: all .12s; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

/* ---------- Phone simulator ---------- */
.rail { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 12px; }
.rail-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.rail-title { font-size: 13px; font-weight: 600; }
.rail-hint { font-size: 12px; color: var(--text-3); }
.device { background: #0b0b0d; border-radius: 48px; padding: 11px; box-shadow: var(--shadow-lg),
  inset 0 0 0 1.5px #2a2a2e; }
.device-screen { background: var(--surface); border-radius: 38px; overflow: hidden; height: 640px;
  display: flex; flex-direction: column; position: relative; }
.island { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 96px; height: 28px;
  border-radius: 20px; background: #0b0b0d; z-index: 2; }
.convo-head { padding: 50px 16px 12px; text-align: center; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent); }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; margin: 0 auto 6px; background: linear-gradient(180deg, #a1a1aa, #71717a);
  color: #fff; }
.phone-biz { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; }
.phone-num { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.thread { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px;
  scrollbar-width: thin; }
.thread-static { max-height: 360px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--border); padding: 14px; }
.thread-empty { margin: auto; text-align: center; color: var(--text-3); max-width: 210px; font-size: 13px; }
.thread-empty .ti { font-size: 26px; }
.bubble { max-width: 78%; padding: 7px 12px; border-radius: 18px; font-size: 14px; line-height: 1.38;
  white-space: pre-wrap; word-wrap: break-word; animation: rise .2s ease-out; margin-top: 4px; letter-spacing: -0.01em; }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.bubble.tervo { align-self: flex-start; background: var(--imsg-gray); color: var(--imsg-gray-text); border-bottom-left-radius: 6px; }
.bubble.customer { align-self: flex-end; background: var(--imsg-blue); color: #fff; border-bottom-right-radius: 6px; }
.thread-static .bubble { animation: none; }
.system-note { align-self: center; font-size: 11px; color: var(--text-3); display: inline-flex; align-items: center; gap: 5px; margin: 8px 0 4px; }
.actions-row { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.action-chip { font-size: 10.5px; font-weight: 500; color: var(--text-3); border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 7px; display: inline-flex; align-items: center; gap: 4px; background: var(--surface); }
.action-chip .ti { color: var(--accent); font-size: 11px; }
.typing { align-self: flex-start; background: var(--imsg-gray); border-radius: 18px; padding: 11px 14px; display: inline-flex; gap: 4px; margin-top: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* Tap-a-time picker */
.slot-picker { align-self: stretch; display: flex; flex-direction: column; gap: 6px; padding: 10px; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-sm); animation: rise .22s ease-out; }
.slot-title { font-size: 11px; font-weight: 500; color: var(--text-3); display: flex; align-items: center; gap: 6px; padding: 0 4px 2px; }
.slot { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 9px 12px;
  transition: border-color .15s, background .15s, transform .1s; }
.slot:hover:not(:disabled) { border-color: var(--imsg-blue); background: color-mix(in srgb, var(--imsg-blue) 6%, var(--surface)); }
.slot:active:not(:disabled) { transform: scale(.985); }
.slot > .ti { color: var(--imsg-blue); font-size: 17px; }
.slot-text { display: flex; flex-direction: column; flex: 1; line-height: 1.25; }
.slot-day { font-weight: 600; font-size: 13px; }
.slot-time { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.slot-go { color: var(--text-3) !important; font-size: 15px !important; }
.slot:disabled { cursor: default; opacity: .4; }
.slot.chosen { opacity: 1; border-color: var(--imsg-blue); background: color-mix(in srgb, var(--imsg-blue) 8%, var(--surface)); }
.slot.chosen .slot-go { color: var(--imsg-blue) !important; }

.composer { display: flex; align-items: center; gap: 8px; padding: 10px 12px 22px; border-top: 1px solid var(--border); }
.composer input { flex: 1; border: 1px solid var(--border-strong); border-radius: 999px; padding: 8px 14px;
  background: var(--surface); outline: none; font-size: 14px; }
.composer input:focus { border-color: var(--text-3); }
.send { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--imsg-blue); color: #fff;
  display: grid; place-items: center; cursor: pointer; font-size: 16px; flex-shrink: 0; transition: opacity .12s; }
.send:disabled { opacity: .35; cursor: default; }
.field-error { color: var(--red); font-size: 12px; }
.field-error:not(:empty) { padding: 0 14px 12px; }

.rail-actions { display: flex; gap: 8px; }
.btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-weight: 500; font-size: 13px; box-shadow: var(--shadow-xs); transition: background .12s, border-color .12s, opacity .12s; }
.btn .ti { font-size: 15px; }
.btn:hover { background: var(--hover); }
.btn-dark, .btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-dark:hover, .btn-primary:hover { background: var(--ink); opacity: .88; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Lead drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 14, .28); backdrop-filter: blur(2px); z-index: 20; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 10px; right: 10px; bottom: 10px; width: 480px; max-width: calc(100vw - 20px); z-index: 21;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  transform: translateX(calc(100% + 20px)); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto; padding: 24px 26px 40px; }
.drawer.open { transform: none; }
.drawer h2 { font-size: 20px; letter-spacing: -0.02em; margin-top: 4px; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; display: grid; place-items: center; font-size: 16px; color: var(--text-2); transition: background .12s; }
.icon-btn:hover { background: var(--hover); }
.drawer-status { display: flex; gap: 6px; margin: 14px 0 14px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-actions .btn { flex: 0 0 auto; }
.drawer-section { margin-top: 26px; }
.section-title { font-size: 11.5px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.details { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 9px 14px; margin: 0; font-size: 13.5px; }
.details dt { color: var(--text-3); }
.details dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 16px 20px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.timeline li::after { content: ""; position: absolute; left: 3px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li:first-child::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline .t { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ---------- Completed jobs in the schedule ---------- */
.cell.booked.done { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 35%, transparent);
  box-shadow: inset 3px 0 0 var(--green); }
.cell.booked.done .cell-time { color: var(--green); }
.cell.booked.done .cell-time::after { content: " · Done"; font-weight: 600; }

/* ---------- Sidebar notification badge ---------- */
.count.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; min-width: 18px;
  text-align: center; line-height: 18px; font-weight: 600; }
.nav-item.active .count.badge { color: #fff; }

/* ---------- Money ---------- */
.btn-inline { flex: 0 0 auto; }
.money-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.money-cell { padding: 14px 18px; border-right: 1px solid var(--border); }
.money-cell:last-child { border-right: 0; }
.money-value { font-size: 22px; font-weight: 600; letter-spacing: -0.025em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.money-cell.active { background: var(--amber-soft); }
.money-cell.active .metric-label, .money-cell.active .money-value { color: var(--amber); }
.money-tervo .metric-label .ti { color: var(--accent); font-size: 13px; }

.ready { border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: 12px; padding: 6px; margin-bottom: 18px; }
.ready-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; padding: 8px 10px 10px; color: var(--accent-text); }
.ready-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.ready-count { font-size: 12px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.ready-hint { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--text-2); }
.ready-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.ready-row + .ready-row { margin-top: 6px; }
.ready-when { font-size: 12.5px; color: var(--text-2); }

#invFilters { margin-bottom: 12px; }
.row.inv { grid-template-columns: 96px minmax(0, 1.6fr) 110px 100px 110px; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.pill.draft, .pill.void { background: var(--gray-soft); color: var(--gray); }
.pill.sent { background: var(--blue-soft); color: var(--blue); }
.pill.overdue { background: var(--amber-soft); color: var(--amber); }
.pill.paid { background: var(--green-soft); color: var(--green); }

/* ---------- Modal (invoice form + invoice view) ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(10, 10, 14, .32); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px; opacity: 0; transition: opacity .18s; }
.modal-wrap.open { opacity: 1; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(.99); transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.modal-wrap.open .modal { transform: none; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 22px 26px 14px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 20px; letter-spacing: -0.02em; margin-top: 4px; }
.modal-body { padding: 18px 26px 6px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 14px; padding: 14px 26px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.foot-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.foot-actions .btn { flex: 0 0 auto; }
.total-line { font-size: 13px; color: var(--text-2); }
.total-line span { font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; margin-left: 8px; font-variant-numeric: tabular-nums; }

.inv-section { margin-bottom: 20px; }
.inv-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.inv-section-head .hint { font-weight: 400; font-size: 12px; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field span { font-size: 12px; font-weight: 500; color: var(--text-2); }
.modal input, .modal textarea, .modal select { border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px 11px;
  background: var(--surface); font-size: 13.5px; outline: none; width: 100%; transition: border-color .12s, box-shadow .12s; }
.modal textarea { resize: vertical; line-height: 1.45; }
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mini-select { width: auto !important; font-size: 12.5px !important; padding: 5px 9px !important; height: 34px; }

.line { display: grid; grid-template-columns: minmax(0, 1fr) 70px 110px 90px 30px; gap: 8px; align-items: center; margin-bottom: 6px; }
.line-head { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.l-price-wrap { position: relative; }
.l-price-wrap span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; }
.l-price-wrap input { padding-left: 20px; }
.l-amt { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; font-size: 13px; }
.l-remove { width: 28px; height: 28px; font-size: 13px; border-color: transparent; color: var(--text-3); }
.add-line { border: 1px dashed var(--border-strong); background: none; border-radius: 9px; padding: 6px 12px; font-size: 12.5px;
  font-weight: 500; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.add-line:hover { border-color: var(--accent); color: var(--accent); }

/* The invoice "paper" */
.paper { border: 1px solid var(--border); border-radius: 14px; padding: 26px 28px; background: var(--surface); margin-bottom: 14px; }
.paper-top { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.paper-biz { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.paper-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.paper-dates { display: flex; gap: 22px; font-size: 13px; text-align: right; }
.paper-dates span, .paper-billto span, .paper-work span { display: block; font-size: 11px; font-weight: 500; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; }
.paper-billto { padding: 16px 0 4px; font-size: 13.5px; line-height: 1.5; }
.paper-work { padding: 10px 0 2px; font-size: 13.5px; }
.paper-work p { margin: 0; color: var(--text-2); }
.paper-lines { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 13.5px; }
.paper-lines th { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em;
  text-align: left; padding: 8px 0; border-bottom: 1px solid var(--border); }
.paper-lines td { padding: 9px 0; border-bottom: 1px solid var(--border); }
.paper-lines .num { text-align: right; font-variant-numeric: tabular-nums; width: 96px; }
.paper-lines tr.grp td { font-size: 11.5px; font-weight: 600; color: var(--text-2); padding-top: 14px; border-bottom: 0; }
.paper-total { display: flex; justify-content: flex-end; align-items: baseline; gap: 18px; padding-top: 14px; font-size: 13px; color: var(--text-2); }
.paper-total b { font-size: 24px; color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.paper-notes { margin-top: 12px; font-size: 13px; color: var(--text-2); }
.sms-preview { border: 1px solid var(--border); background: var(--surface-2); border-radius: 14px; padding: 12px 14px 14px; margin-bottom: 14px; }
.sms-label { font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.sms-note { width: 100%; font-weight: 400; color: var(--text-3); font-size: 12px; }
.paid-note { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 500; font-size: 13.5px; }
.paid-note.muted { color: var(--text-3); }

/* ---------- Toasts (pop-up notices) ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; gap: 12px; align-items: flex-start; width: 360px; padding: 14px 16px; border-radius: 14px;
  background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-lg); animation: toastIn .25s cubic-bezier(.2,.8,.2,1);
  transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast > .ti { font-size: 18px; margin-top: 1px; color: #a5a5ff; }
.toast-title { font-weight: 600; font-size: 13.5px; }
.toast-body { font-size: 13px; opacity: .85; margin-top: 2px; }
.toast-note { font-size: 11.5px; opacity: .6; margin-top: 6px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }   /* minmax lets the panel shrink instead of overflowing */
  .rail { position: static; max-width: 380px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .switcher { flex: 1; min-width: 180px; }
  .switcher-label { display: none; }
  .nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 16px 40px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .row { grid-template-columns: minmax(0, 1fr) 110px; }
  .row > :nth-child(2), .row > :nth-child(4) { display: none; }
  .drawer { top: 0; right: 0; bottom: 0; border-radius: 0; max-width: 100vw; }
  .next-when { min-width: 0; padding-right: 14px; }
  .money-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .money-cell:nth-child(2) { border-right: 0; }
  .money-cell:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .ready-row { grid-template-columns: minmax(0, 1fr); }
  .row.inv { grid-template-columns: 80px minmax(0, 1fr) 90px; }
  .row.inv > :nth-child(4), .row.inv > :nth-child(5) { display: none; }
  .line { grid-template-columns: minmax(0, 1fr) 56px 90px 28px; }
  .line .l-amt, .line-head > :nth-child(4) { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .toast { width: calc(100vw - 40px); }
}

/* Leads: search box beside the chips, and "Load more" under a page (Phase E step 5) */
.lead-search { margin-left: auto; position: relative; min-width: 220px; }
.lead-search input { width: 100%; border: 1px solid var(--border-strong); border-radius: 9px; padding: 6px 11px 6px 30px; background: var(--surface); color: var(--text); outline: none; font: inherit; font-size: 13px; }
.lead-search .ti { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.load-more { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; color: var(--text-3); font-size: 12.5px; }
@media (max-width: 700px) { .lead-search { margin-left: 0; flex: 1 1 100%; } }
