/* =========================================================================
   PIPELINE — design system
   "Editorial terminal": warm ink, a single lime signal, tabular numerals,
   grain, tinted shadows, spotlight surfaces. Light + dark.
   ========================================================================= */

:root {
  --font: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Inter Tight", sans-serif;
  --r-xl: 20px;
  --r-lg: 15px;
  --r-md: 11px;
  --r-sm: 8px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  /* the one brand fill — works with ink text in BOTH themes */
  --lime: #c8f04a;
  --lime-2: #b6de3c;
  --lime-ink: #14180a;
}

/* ---------- Dark (default) ---------- */
:root[data-theme="dark"], :root:not([data-theme]) {
  --bg: #0c0d0b;
  --panel: #141613;
  --panel-2: #1b1e19;
  --panel-3: #242822;
  --line: #2b2f28;
  --line-2: #383d34;
  --text: #eef0e9;
  --muted: #9ba095;
  --muted-2: #63685d;
  --accent: #c8f04a;          /* lime signal — readable on dark */
  --accent-2: #b6de3c;
  --accent-soft: rgba(200, 240, 74, 0.13);
  --green: #4bd486;           /* emerald — money positive */
  --green-soft: rgba(75, 212, 134, 0.14);
  --amber: #f5b544;
  --amber-soft: rgba(245, 181, 68, 0.15);
  --red: #ff6b6b;
  --red-bg: rgba(255, 107, 107, 0.12);
  --shadow: 0 20px 45px -18px rgba(0, 0, 0, 0.75), 0 2px 8px -4px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 6px 18px -10px rgba(0, 0, 0, 0.7);
  --glass: rgba(16, 18, 14, 0.72);
  --app-bg:
    radial-gradient(900px 500px at 88% -8%, rgba(200, 240, 74, 0.07), transparent 60%),
    radial-gradient(700px 500px at -5% 10%, rgba(75, 212, 134, 0.05), transparent 55%),
    #0c0d0b;
  --grain-opacity: 0.05;
  --hairline: rgba(255, 255, 255, 0.06);
  --inner-border: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ---------- Light ---------- */
:root[data-theme="light"] {
  --bg: #f4f3ee;
  --panel: #fffefb;
  --panel-2: #f6f5ef;
  --panel-3: #eceae1;
  --line: #e5e2d7;
  --line-2: #d8d4c6;
  --text: #1b1d16;
  --muted: #6a6d5f;
  --muted-2: #a2a597;
  --accent: #5f7d15;          /* deep olive-lime — readable on light */
  --accent-2: #4c6610;
  --accent-soft: rgba(95, 125, 21, 0.10);
  --green: #0b9d63;
  --green-soft: rgba(11, 157, 99, 0.10);
  --amber: #c07d0a;
  --amber-soft: rgba(192, 125, 10, 0.12);
  --red: #d64545;
  --red-bg: rgba(214, 69, 69, 0.09);
  --shadow: 0 22px 45px -22px rgba(50, 55, 30, 0.28), 0 2px 6px -3px rgba(50, 55, 30, 0.12);
  --shadow-sm: 0 8px 20px -12px rgba(50, 55, 30, 0.22);
  --glass: rgba(255, 254, 250, 0.78);
  --app-bg:
    radial-gradient(900px 500px at 88% -8%, rgba(150, 190, 40, 0.14), transparent 60%),
    radial-gradient(700px 500px at -5% 10%, rgba(11, 157, 99, 0.06), transparent 55%),
    #f4f3ee;
  --grain-opacity: 0.045;
  --hairline: rgba(20, 25, 10, 0.06);
  --inner-border: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--app-bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  font-feature-settings: "cv05" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); color: var(--text); }

/* tabular figures everywhere numbers matter */
.kpi-value, .card-value, .col-sum, .proj-num, .assume-val, .bar-val, .goal-text,
tbody td, .rep-table td, .calc-box .val, input, .status-pill {
  font-variant-numeric: tabular-nums;
}

/* fixed grain + ambient glow overlays */
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 13px 24px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40; flex-wrap: wrap;
  box-shadow: var(--inner-border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent); color: var(--lime-ink);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px var(--accent), var(--inner-border);
}
:root[data-theme="light"] .brand-mark { background: linear-gradient(150deg, #d7f24e, #b6de3c); color: #23300a; }
.brand-name { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.5px; font-size: 17px; line-height: 1; }
.brand-sub { font-size: 10.5px; color: var(--muted); font-weight: 500; letter-spacing: 0.3px; margin-top: 3px; }

.tabs { display: flex; gap: 2px; background: var(--panel-2); padding: 4px; border-radius: 13px; border: 1px solid var(--line); box-shadow: var(--inner-border); }
.tab {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 9px; font-weight: 600; font-size: 13px;
  cursor: pointer; font-family: var(--font); letter-spacing: -0.1px;
  transition: color .2s var(--ease), background .2s var(--ease); position: relative;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm), var(--inner-border); }
.tab.active::after {
  content: ""; position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
  width: 16px; height: 2.5px; border-radius: 2px; background: var(--accent);
}

.topbar-actions { display: flex; gap: 9px; margin-left: auto; align-items: center; }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
  font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--font);
  letter-spacing: -0.1px; white-space: nowrap;
  transition: transform .15s var(--spring), background .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease), color .18s var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--lime); color: var(--lime-ink); box-shadow: 0 8px 20px -10px var(--lime); }
.btn.primary:hover { background: var(--lime-2); box-shadow: 0 12px 26px -10px var(--lime); }
.btn.primary .plus { font-weight: 700; margin-right: 1px; }
.btn.ghost { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--panel-3); border-color: var(--line-2); }
.btn.danger { color: var(--red); }
.btn.danger.ghost:hover { background: var(--red-bg); border-color: var(--red); }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn:focus-visible, .tab:focus-visible, .theme-toggle:focus-visible, .icon-btn:focus-visible,
select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-btn { background: transparent; border: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 7px; border-radius: 9px; transition: background .18s, color .18s; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }

/* Theme toggle — refined segmented control (no sun/moon) */
.theme-toggle {
  position: relative; display: inline-flex; align-items: center; padding: 3px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px;
  cursor: pointer; box-shadow: var(--inner-border); overflow: hidden;
}
.theme-toggle .seg {
  position: relative; z-index: 2; width: 30px; text-align: center; padding: 5px 0; font-size: 14px; line-height: 1; font-weight: 600;
  color: var(--muted-2); transition: color .25s var(--ease); user-select: none;
}
.theme-toggle .seg-knob {
  position: absolute; z-index: 1; top: 3px; bottom: 3px; width: calc(50% - 3px);
  border-radius: 8px; background: var(--panel); box-shadow: var(--shadow-sm);
  transition: transform .3s var(--spring);
}
:root[data-theme="light"] .theme-toggle .seg-knob { transform: translateX(0); }
:root[data-theme="dark"] .theme-toggle .seg-knob, :root:not([data-theme]) .theme-toggle .seg-knob { transform: translateX(100%); }
:root[data-theme="light"] .theme-toggle .seg.light { color: var(--text); }
:root[data-theme="dark"] .theme-toggle .seg.dark, :root:not([data-theme]) .theme-toggle .seg.dark { color: var(--text); }

/* ---------- Filterbar ---------- */
.filterbar {
  display: flex; align-items: flex-end; gap: 14px; padding: 13px 24px;
  border-bottom: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(10px);
  flex-wrap: wrap;
}
.filterbar.hidden { display: none; }
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted-2); font-weight: 600; }
.filter-note { font-size: 12px; color: var(--accent); font-weight: 600; margin-left: auto; align-self: center; }

select, input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="time"], textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font-family: var(--font); font-size: 13px;
  outline: none; transition: border-color .18s, box-shadow .18s, background .18s;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted-2); }
::-webkit-calendar-picker-indicator { filter: var(--pick, none); opacity: .6; cursor: pointer; }
:root[data-theme="dark"] ::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.55); }

/* ---------- Layout ---------- */
main { padding: 26px 24px 60px; max-width: 1560px; margin: 0 auto; }
.view-title { font-family: var(--font-display); font-size: 27px; font-weight: 600; letter-spacing: -0.9px; margin-bottom: 5px; }
.view-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; max-width: 68ch; line-height: 1.5; text-wrap: pretty; }

@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ---------- Spotlight surfaces ---------- */
.spot { position: relative; }
.spot::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 0; pointer-events: none;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, -20%), var(--accent-soft), transparent 65%);
  opacity: 0; transition: opacity .35s var(--ease);
}
.spot:hover::before { opacity: 1; }
.spot > * { position: relative; z-index: 1; }

/* ---------- Kanban ---------- */
.board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 22px; align-items: flex-start; scroll-snap-type: x proximity; }
.column {
  flex: 0 0 300px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-xl); display: flex; flex-direction: column;
  max-height: calc(100dvh - 210px); box-shadow: var(--shadow-sm), var(--inner-border); scroll-snap-align: start;
  transition: border-color .2s, box-shadow .2s;
}
.column.drop-hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 15px 13px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--panel); border-radius: var(--r-xl) var(--r-xl) 0 0; z-index: 2;
}
.col-title { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 13px; letter-spacing: -0.1px; }
.col-dot { width: 8px; height: 8px; border-radius: 3px; box-shadow: 0 0 10px 0 currentColor; }
.col-count { background: var(--panel-3); color: var(--muted); border-radius: 7px; padding: 2px 9px; font-size: 11px; font-weight: 700; min-width: 24px; text-align: center; }
.col-sum { font-size: 11.5px; color: var(--muted); font-weight: 600; font-family: var(--font-display); }
.col-body { padding: 11px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.col-body:empty::after { content: "Drop leads here"; color: var(--muted-2); font-size: 12px; text-align: center; padding: 26px 0; display: block; border: 1px dashed var(--line); border-radius: var(--r-md); }

.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px; cursor: grab; box-shadow: var(--inner-border);
  transition: transform .18s var(--spring), box-shadow .2s var(--ease), border-color .2s var(--ease);
  animation: riseIn .45s var(--ease) backwards;
}
.col-body .card:nth-child(1) { animation-delay: .02s } .col-body .card:nth-child(2) { animation-delay: .06s }
.col-body .card:nth-child(3) { animation-delay: .1s } .col-body .card:nth-child(4) { animation-delay: .14s }
.col-body .card:nth-child(n+5) { animation-delay: .18s }
.card:hover { border-color: var(--line-2); transform: translateY(-3px); box-shadow: var(--shadow); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: 0.35; transform: scale(.98) rotate(-1deg); }
.card.leak { border-left: 2.5px solid var(--red); }
.card-name { font-weight: 600; font-size: 14.5px; letter-spacing: -0.2px; margin-bottom: 2px; }
.card-company { color: var(--muted); font-size: 12px; margin-bottom: 11px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }
.chip { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 7px; background: var(--panel-3); color: var(--muted); letter-spacing: 0.1px; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.card-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }
.card-value { font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: -0.3px; }
.card-people { font-size: 11px; color: var(--muted); }
.card-flags { display: flex; gap: 5px; margin-top: 9px; flex-wrap: wrap; }
.flag { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 7px; background: var(--red-bg); color: var(--red); display: inline-flex; gap: 4px; align-items: center; letter-spacing: 0.1px; }

/* ---------- Table / Log ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--panel); box-shadow: var(--shadow-sm), var(--inner-border); }
table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 1120px; }
thead th {
  text-align: left; padding: 13px 14px; color: var(--muted-2); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.7px; border-bottom: 1px solid var(--line);
  cursor: pointer; white-space: nowrap; position: sticky; top: 0; background: var(--panel); user-select: none; transition: color .15s;
}
thead th:hover { color: var(--text); }
thead th .arrow { color: var(--accent); }
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.leak td:first-child { box-shadow: inset 2.5px 0 0 var(--red); }
.status-pill { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 7px; letter-spacing: 0.1px; }
.money-pos { color: var(--green); font-weight: 600; font-family: var(--font-display); }
.row-flags { display: inline-flex; gap: 4px; }

/* ---------- Dashboard ---------- */
.dash-section { margin-bottom: 34px; }
.dash-section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px; color: var(--muted); margin-bottom: 14px; display: flex; align-items: center; gap: 9px; }
.dash-section-title::before { content: ""; width: 14px; height: 2.5px; background: var(--accent); border-radius: 2px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(186px, 1fr)); gap: 13px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 17px 17px 16px; overflow: hidden; box-shadow: var(--shadow-sm), var(--inner-border);
  animation: riseIn .5s var(--ease) backwards;
}
.kpi::after { content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 2px; background: linear-gradient(90deg, var(--accent), transparent 70%); opacity: .5; z-index: 1; }
.kpi-grid .kpi:nth-child(1){animation-delay:.03s} .kpi-grid .kpi:nth-child(2){animation-delay:.06s}
.kpi-grid .kpi:nth-child(3){animation-delay:.09s} .kpi-grid .kpi:nth-child(4){animation-delay:.12s}
.kpi-grid .kpi:nth-child(5){animation-delay:.15s} .kpi-grid .kpi:nth-child(6){animation-delay:.18s}
.kpi-grid .kpi:nth-child(7){animation-delay:.21s} .kpi-grid .kpi:nth-child(n+8){animation-delay:.24s}
.kpi.leak { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); }
.kpi.leak::after { background: linear-gradient(90deg, var(--red), transparent 70%); opacity: .7; }
.kpi-label { font-size: 11px; color: var(--muted); font-weight: 500; margin-bottom: 9px; letter-spacing: 0.1px; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -1px; line-height: 1; }
.kpi-value.sm { font-size: 21px; }
.kpi-sub { font-size: 11px; color: var(--muted-2); margin-top: 7px; letter-spacing: 0.1px; }
.kpi-value.red { color: var(--red); }
.kpi-value.green { color: var(--green); }
.kpi-value.amber { color: var(--amber); }

.panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 20px; overflow: hidden; box-shadow: var(--shadow-sm), var(--inner-border); animation: riseIn .5s var(--ease) backwards; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* Bar chart */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label { width: 112px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--panel-3); border-radius: 7px; height: 24px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 7px; transition: width .6s var(--ease); min-width: 3px; }
.bar-val { width: 34px; text-align: right; font-size: 12.5px; font-weight: 700; flex-shrink: 0; font-family: var(--font-display); }

/* Goal */
.goal-track { background: var(--panel-3); border-radius: 12px; height: 34px; overflow: hidden; position: relative; box-shadow: var(--inner-border); }
.goal-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 12px; transition: width .7s var(--ease); box-shadow: 0 0 24px -4px var(--accent); }
.goal-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; letter-spacing: 0.2px; }
#goalInput { font-family: var(--font-display); font-weight: 600; }

.rep-table { width: 100%; min-width: unset; font-size: 12.5px; }
.rep-table th, .rep-table td { padding: 9px 10px; }
.rep-table th { position: static; }

/* ---------- Projection ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 22px; }
@media (max-width: 820px) { .proj-grid { grid-template-columns: 1fr; } }
.proj-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 24px 20px; text-align: center; overflow: hidden; box-shadow: var(--shadow-sm), var(--inner-border); animation: riseIn .5s var(--ease) backwards; }
.proj-card:nth-child(1){animation-delay:.04s} .proj-card:nth-child(2){animation-delay:.09s} .proj-card:nth-child(3){animation-delay:.14s}
.proj-card.expected { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.proj-tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.3px; margin-bottom: 12px; color: var(--muted); }
.proj-tag.worst { color: var(--red); } .proj-tag.expected { color: var(--accent); } .proj-tag.best { color: var(--green); }
.proj-num { font-family: var(--font-display); font-size: 32px; font-weight: 600; letter-spacing: -1.4px; line-height: 1; }
.proj-sub { font-size: 12px; color: var(--muted); margin-top: 8px; }
.proj-assumptions { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 13px; }
.assume { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; box-shadow: var(--inner-border); }
.assume-label { font-size: 11px; color: var(--muted); letter-spacing: 0.1px; }
.assume-val { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.5px; margin-top: 5px; }

/* ---------- Activity ---------- */
.activity-form { display: flex; gap: 13px; align-items: flex-end; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px; margin-bottom: 20px; box-shadow: var(--shadow-sm), var(--inner-border); }
.activity-form .filter-group { min-width: 120px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 7, 5, 0.62); backdrop-filter: blur(6px);
  z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 48px 20px; overflow-y: auto;
  animation: fadeIn .2s var(--ease);
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-xl); width: 100%; max-width: 780px; box-shadow: var(--shadow); animation: modalIn .28s var(--spring); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--glass); backdrop-filter: blur(12px); z-index: 2; }
.modal-head h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.4px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 15px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--glass); backdrop-filter: blur(12px); }
.modal-foot .spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-field input, .form-field select { width: 100%; }
.form-section-label { grid-column: 1/-1; font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin-top: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.form-section-label::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); }
.calc-box { grid-column: 1/-1; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: var(--r-md); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.calc-box .lbl { font-size: 12px; color: var(--muted); }
.calc-box .val { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--accent); letter-spacing: -0.5px; }
.hidden-field { display: none !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 200; animation: toastIn .28s var(--spring);
}
.toast::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 9px; vertical-align: middle; box-shadow: 0 0 10px 0 var(--accent); }
@keyframes toastIn { from { transform: translate(-50%, 14px); opacity: 0; } }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-icon { font-size: 34px; margin-bottom: 12px; opacity: 0.5; }

/* ---------- Sync status ---------- */
.sync-status { font-size: 11.5px; font-weight: 600; padding: 5px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.sync-status[data-tone="green"] { color: var(--green); } .sync-status[data-tone="amber"] { color: var(--amber); }
.sync-status[data-tone="red"] { color: var(--red); } .sync-status[data-tone="muted"] { color: var(--muted-2); }

/* ---------- AI trigger button ---------- */
.ai-btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--accent); }
.ai-btn:hover { background: var(--accent-soft); }
.ai-spark { color: var(--accent); font-weight: 700; }

/* ---------- Tags / notes on cards ---------- */
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 11px; }
.tag { font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 6px; }
.note-dot { font-size: 11px; opacity: .8; }

/* textarea */
textarea { resize: vertical; min-height: 62px; line-height: 1.5; width: 100%; }

/* table footer totals */
tfoot td { padding: 12px 14px; border-top: 1px solid var(--line-2); color: var(--text); background: var(--panel-2); }

/* ---------- Bulk select / delete (Lead Log) ---------- */
.bulk-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 14px; font-size: 13px; }
.bulk-bar .spacer { flex: 1; }
.chk-col { width: 34px; }
.chk-col input, .row-check { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
tr.row-selected { background: var(--accent-soft); }

/* ---------- AI panel (slide-over) ---------- */
.ai-panel {
  position: fixed; top: 0; right: 0; height: 100dvh; width: 420px; max-width: 92vw; z-index: 120;
  background: var(--panel); border-left: 1px solid var(--line-2);
  box-shadow: -30px 0 60px -30px rgba(0,0,0,.5); display: flex; flex-direction: column;
  animation: slideIn .3s var(--ease);
}
.ai-panel[hidden] { display: none; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); position: relative; }
.ai-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: -0.3px; }
/* iridescent "alive" ring — the AI signature */
.ai-dot { width: 17px; height: 17px; border-radius: 50%; position: relative; }
.ai-dot::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, #c8f04a, #4bd486, #4cc6c0, #6aa9ff, #b58cff, #ff7a9c, #c8f04a);
  animation: spin 4.5s linear infinite; box-shadow: 0 0 12px -1px rgba(120, 170, 255, .55); }
.ai-dot::after { content: ""; position: absolute; inset: 4.5px; border-radius: 50%; background: var(--panel); }
/* header "lights up" while the AI is thinking */
.ai-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; opacity: 0;
  background: linear-gradient(90deg, #c8f04a, #4cc6c0, #6aa9ff, #b58cff, #ff7a9c, #c8f04a); background-size: 220% 100%;
  transition: opacity .4s; }
.ai-panel.busy .ai-head::after { opacity: 1; animation: flow 2s linear infinite; }
.ai-panel.busy .ai-dot::before { animation-duration: 1.4s; }
@keyframes flow { to { background-position: -220% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-head-actions { display: flex; gap: 4px; }

.ai-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ai-empty { margin: auto; text-align: center; padding: 20px; max-width: 280px; }
.ai-empty-mark { font-size: 30px; color: var(--accent); }
.ai-empty-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin-top: 10px; }
.ai-empty-sub { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.5; }

.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble { max-width: 88%; padding: 11px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; word-wrap: break-word; }
.ai-msg.user .ai-bubble { background: var(--accent); color: var(--lime-ink); border-bottom-right-radius: 5px; font-weight: 500; }
.ai-msg.bot .ai-bubble { background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.ai-bubble code { background: var(--panel-3); padding: 1px 5px; border-radius: 5px; font-size: 12px; font-family: var(--font-display); }
.ai-actions { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.ai-action { font-size: 11.5px; font-weight: 600; color: var(--green); }
.ai-thinking { display: flex; gap: 5px; align-items: center; }
.ai-thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.ai-thinking span:nth-child(2) { animation-delay: .2s; } .ai-thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.ai-suggests { display: flex; flex-direction: column; gap: 7px; padding: 0 18px 12px; }
.ai-sug { text-align: left; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 9px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 500; cursor: pointer; font-family: var(--font); transition: background .15s, border-color .15s; }
.ai-sug:hover { background: var(--panel-3); border-color: var(--accent); }

.ai-input { display: flex; gap: 9px; align-items: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(10px); }
.ai-input textarea { flex: 1; min-height: 42px; max-height: 120px; border-radius: 12px; padding: 11px 13px; }
.ai-input .btn { padding: 0; width: 42px; height: 42px; border-radius: 12px; font-size: 18px; flex-shrink: 0; display: grid; place-items: center; }
@media (min-width: 1100px) { body.ai-open main, body.ai-open .topbar, body.ai-open .filterbar { padding-right: 440px; } }
@media (max-width: 520px) { .ai-panel { width: 100vw; } }

/* ---------- Floating AI dock (Siri / Gemini glow) ---------- */
.ai-dock {
  position: fixed; right: 26px; bottom: 26px; z-index: 90;
  width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--panel); box-shadow: var(--shadow);
  display: grid; place-items: center; isolation: isolate;
  transition: transform .35s var(--spring), opacity .3s var(--ease);
}
.ai-dock:hover { transform: scale(1.07); }
.ai-dock:active { transform: scale(.93); }
/* soft blurred aura */
.ai-dock-halo {
  position: absolute; inset: -6px; border-radius: 50%; z-index: -2;
  background: conic-gradient(from 0deg, #c8f04a, #4bd486, #4cc6c0, #6aa9ff, #b58cff, #ff7a9c, #c8f04a);
  filter: blur(11px); opacity: .8; animation: spin 6s linear infinite;
}
/* crisp gradient ring */
.ai-dock::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; padding: 2px; z-index: -1;
  background: conic-gradient(from 0deg, #c8f04a, #4bd486, #4cc6c0, #6aa9ff, #b58cff, #ff7a9c, #c8f04a);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; animation: spin 6s linear infinite;
}
.ai-dock-core { position: relative; z-index: 1; font-size: 23px; font-weight: 700;
  background: conic-gradient(from 0deg, #a9d63a, #4bd486, #4cc6c0, #6aa9ff, #b58cff, #ff7a9c);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  animation: pulse-soft 3s var(--ease) infinite; }
@keyframes pulse-soft { 50% { transform: scale(1.12); } }
/* hide the dock while the panel is open */
body.ai-open .ai-dock { opacity: 0; transform: scale(.55); pointer-events: none; }
@media (max-width: 520px) { .ai-dock { right: 18px; bottom: 18px; width: 56px; height: 56px; } }

/* ---------- Login gate ---------- */
.login-gate { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px; background: var(--app-bg); background-attachment: fixed; }
.login-gate[hidden] { display: none; }
.login-card { width: 100%; max-width: 350px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 32px 28px; display: flex; flex-direction: column; gap: 12px; text-align: center; animation: riseIn .5s var(--ease); }
.login-mark { width: 50px; height: 50px; border-radius: 14px; background: var(--accent); color: var(--lime-ink); display: grid; place-items: center; margin: 0 auto 2px; box-shadow: 0 10px 24px -8px var(--accent); }
.login-title { font-family: var(--font-display); font-weight: 600; font-size: 23px; letter-spacing: -0.6px; }
.login-sub { color: var(--muted); font-size: 13px; margin-top: -8px; margin-bottom: 8px; }
.login-card input { text-align: left; padding: 11px 13px; }
.login-card .btn { margin-top: 6px; padding: 11px; }
.login-error { color: var(--red); font-size: 12.5px; font-weight: 600; min-height: 15px; }

/* ---------- Reminders ---------- */
.notif-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.rem-item { display: flex; align-items: center; gap: 11px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.rem-item:last-child { border-bottom: none; }
.rem-item[data-lead] { cursor: pointer; border-radius: 8px; padding: 11px 8px; }
.rem-item[data-lead]:hover { background: var(--panel-2); }
.rem-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; box-shadow: 0 0 8px 0 currentColor; }
.rem-body { flex: 1; min-width: 0; }
.rem-title { font-weight: 600; font-size: 13.5px; }
.rem-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.rem-meta.overdue { color: var(--red); font-weight: 600; }
.rem-done .rem-title { text-decoration: line-through; color: var(--muted); }
.rem-check { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line-2); background: var(--panel-2); cursor: pointer; flex-shrink: 0; color: var(--lime-ink); font-weight: 700; font-size: 12px; display: grid; place-items: center; transition: background .15s, border-color .15s; }
.rem-check.on { background: var(--accent); border-color: var(--accent); }

/* ---------- Mobile ---------- */
.only-wide { display: inline-flex; }
@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 12px 16px; }
  .tabs { order: 4; width: 100%; overflow-x: auto; }
  .topbar-actions { margin-left: 0; gap: 7px; }
  .only-wide { display: none; }
  main { padding: 18px 16px 50px; }
  .view-title { font-size: 23px; }
  .kpi-value { font-size: 23px; }
  .proj-card.expected { transform: none; }
}
