/* ============================================================
   polish.css — additive polish layer
   - Dark mode theming via [data-theme="dark"]
   - Command palette / shortcuts overlay
   - Floating bulk-action bar
   - Small interactions: top progress bar, focus rings, kbd hints
   - Drag-and-drop kanban affordances
   ============================================================ */

/* ---------- DARK MODE ----------
   The base styles.css uses CSS variables for surfaces — we override them
   for dark mode here so the whole app re-themes without touching layout. */
html[data-theme="dark"]{
  --bg:#0e1116;
  --card:#161a22;
  --text:#e7e9ec;
  --muted:#9aa3ad;
  --border:#252a33;
  --orange-soft:#3a2a05;
  --master-bg:#241a3a;
  --warn-bg:#3a2a05;
  color-scheme:dark;
}
html[data-theme="dark"] body{background:var(--bg);color:var(--text)}
html[data-theme="dark"] .card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .lead-card,
html[data-theme="dark"] .kanban-card,
html[data-theme="dark"] .setting-block,
html[data-theme="dark"] .insight-card,
html[data-theme="dark"] .compact-stats .stat,
html[data-theme="dark"] .funnel-row{background:#1a1f29;color:var(--text);border-color:var(--border)}
html[data-theme="dark"] table{background:#161a22;color:var(--text)}
html[data-theme="dark"] th{background:#1f2530;color:#c8cdd6}
html[data-theme="dark"] tr:hover td{background:#1c2230}
html[data-theme="dark"] tr.stale td{background:#2a2415}
html[data-theme="dark"] tr.group-row td{background:#22272f;color:#e4b75b}
html[data-theme="dark"] .topbar{background:rgba(14,17,22,.85);border-bottom:1px solid #1f2530}
html[data-theme="dark"] .sidebar{background:#11151c;border-right:1px solid #1f2530}
html[data-theme="dark"] .sidebar-head,
html[data-theme="dark"] .sidebar-foot{border-color:#1f2530}
html[data-theme="dark"] .nav-item{color:#c5cad3}
html[data-theme="dark"] .nav-item:hover{background:#1c2230;color:#ffd078}
html[data-theme="dark"] .nav-item.active{background:#2c1e08;color:#ffc56e}
html[data-theme="dark"] .input,
html[data-theme="dark"] .select,
html[data-theme="dark"] .textarea,
html[data-theme="dark"] .ms-trigger,
html[data-theme="dark"] .ms-panel,
html[data-theme="dark"] .ms-search,
html[data-theme="dark"] .ms-option,
html[data-theme="dark"] .small-btn,
html[data-theme="dark"] .filter-collapse-toggle,
html[data-theme="dark"] .qchip,
html[data-theme="dark"] .seg-tabs,
html[data-theme="dark"] .view-tabs,
html[data-theme="dark"] .link-btn,
html[data-theme="dark"] .stat,
html[data-theme="dark"] .btn.secondary,
html[data-theme="dark"] .modal-tab,
html[data-theme="dark"] .checkbox-row label,
html[data-theme="dark"] .service-item,
html[data-theme="dark"] .service-chip,
html[data-theme="dark"] .radio-row label,
html[data-theme="dark"] .proposal-uploader,
html[data-theme="dark"] .proposal-uploader .preview,
html[data-theme="dark"] .proposal-link{background:#11151c;color:var(--text);border-color:#252a33}
html[data-theme="dark"] .filter-panel{background:#161a22;border-bottom-color:#1f2530}
html[data-theme="dark"] .qchip:hover{border-color:var(--orange)}
html[data-theme="dark"] .qchip.active{background:var(--orange);color:#fff}
html[data-theme="dark"] .modal-head{background:#1d2230}
html[data-theme="dark"] .modal-tabs{background:#161a22;border-bottom-color:#1f2530}
html[data-theme="dark"] .modal-tab.active{background:#2c1e08;color:#ffc56e;border-color:#5b3a0c}
html[data-theme="dark"] .form-callout,
html[data-theme="dark"] .otp-dev,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .subline{background:transparent;color:var(--muted)}
html[data-theme="dark"] .badge{background:#2a3140;color:#cfd6e1}
html[data-theme="dark"] .badge.orange{background:#3a2a05;color:#ffce6b}
html[data-theme="dark"] .badge.green{background:#0e2c1c;color:#86efac}
html[data-theme="dark"] .badge.red{background:#3a1419;color:#fca5a5}
html[data-theme="dark"] .badge.blue{background:#102844;color:#93c5fd}
html[data-theme="dark"] .badge.warn{background:#3a2a05;color:#ffce6b}
html[data-theme="dark"] .pill{background:#3a2a05;color:#ffce6b}
html[data-theme="dark"] .pill.master{background:#241a3a;color:#c4b5fd}
html[data-theme="dark"] .user-chip{background:#11151c;border-color:#252a33}
html[data-theme="dark"] .kanban-col{background:#11151c;border-color:#252a33}
html[data-theme="dark"] th .sort-ind{color:#3a4250}
html[data-theme="dark"] a{color:#ffb554}
html[data-theme="dark"] .chip{background:#15225a;color:#a5b4fc}
html[data-theme="dark"] .chip.off{background:#1f2530;color:#5e6776}
html[data-theme="dark"] .priv-tag{background:#241a3a;color:#c4b5fd}
html[data-theme="dark"] .err-tag{background:#3a1419;color:#fca5a5}
html[data-theme="dark"] .dash-card{background:#1a1f29;border-color:#252a33}
html[data-theme="dark"] .dash-card .v{color:var(--text)}
html[data-theme="dark"] .toast{background:#1f2530;color:#e7e9ec}
html[data-theme="dark"] .toast.error{background:#5b1413;color:#fff}
html[data-theme="dark"] .toast.success{background:#0e3c22;color:#dcfce7}

/* ---------- KBD HINT chips ---------- */
kbd, .kbd-hint{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:18px;padding:1px 6px;
  font-family:ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size:11px;font-weight:600;
  color:#525a66;background:#f3f4f6;border:1px solid #e5e7eb;
  border-bottom-width:2px;border-radius:6px;
}
html[data-theme="dark"] kbd, html[data-theme="dark"] .kbd-hint{
  background:#11151c;border-color:#2a3140;color:#cfd6e1;
}
.nav-item .kbd-hint{margin-left:auto;font-size:10px;opacity:.7}
.sidebar.collapsed .kbd-hint{display:none}

.btn .kbd-hint{margin-left:6px}
.btn.secondary.icon-only{padding:7px 10px}
.hide-sm{display:inline}
@media(max-width:640px){ .hide-sm{display:none} }

/* ---------- TOPBAR SLIM PROGRESS BAR ---------- */
.topbar-progress{
  position:absolute;left:0;right:0;bottom:0;height:2px;
  background:linear-gradient(90deg,transparent 0%,var(--orange) 50%,transparent 100%);
  background-size:200% 100%;background-position:200% 0;
  opacity:0;transition:opacity .2s;
}
.topbar-progress.loading{opacity:1;animation:bcProgress 1.2s linear infinite}
@keyframes bcProgress{ to{ background-position:-200% 0 } }

/* ---------- COMMAND PALETTE ---------- */
.palette-overlay{
  position:fixed;inset:0;background:rgba(0,0,0,.45);
  display:none;align-items:flex-start;justify-content:center;
  padding:80px 20px 20px;z-index:120;backdrop-filter:blur(4px);
}
.palette-overlay.open{display:flex}
.palette{
  width:min(100%,620px);background:var(--card);
  border:1px solid var(--border);border-radius:16px;
  box-shadow:0 30px 80px rgba(0,0,0,.35);
  overflow:hidden;display:flex;flex-direction:column;max-height:70vh;
  animation:bcPaletteIn .14s ease-out;
}
@keyframes bcPaletteIn{ from{ transform:translateY(-8px);opacity:.7 } to{ transform:translateY(0);opacity:1 } }
.palette-search{
  display:flex;align-items:center;gap:10px;
  padding:14px 16px;border-bottom:1px solid var(--border);
  color:var(--muted);font-size:15px;
}
.palette-search i{font-size:18px;color:var(--orange-dark)}
.palette-search input{
  flex:1;border:none;outline:none;background:transparent;
  color:var(--text);font-size:15px;
}
.palette-results{flex:1;overflow-y:auto;padding:6px}
.palette-section{
  font-size:10px;text-transform:uppercase;letter-spacing:.08em;
  color:var(--muted);font-weight:700;padding:10px 12px 4px;
}
.palette-item{
  display:flex;align-items:center;gap:10px;
  padding:10px 12px;border-radius:10px;
  font-size:14px;color:var(--text);cursor:pointer;
}
.palette-item .ico{
  width:30px;height:30px;border-radius:8px;
  background:var(--orange-soft);color:var(--orange-dark);
  display:inline-flex;align-items:center;justify-content:center;
  flex:0 0 30px;
}
.palette-item .main{flex:1;min-width:0}
.palette-item .ttl{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.palette-item .sub{font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.palette-item .arrow{color:var(--muted);font-size:14px}
.palette-item:hover,
.palette-item.focused{background:var(--orange-soft);color:#7a5200}
html[data-theme="dark"] .palette-item:hover,
html[data-theme="dark"] .palette-item.focused{background:#2c1e08;color:#ffc56e}
.palette-item.focused .arrow{color:var(--orange-dark)}
.palette-empty{padding:30px 16px;text-align:center;color:var(--muted);font-size:13px}
.palette-foot{
  display:flex;justify-content:flex-start;gap:14px;
  padding:8px 14px;border-top:1px solid var(--border);
  font-size:11px;color:var(--muted);
}

/* ---------- SHORTCUTS HELP OVERLAY ---------- */
.shortcuts-grid{
  display:grid;grid-template-columns:auto 1fr;gap:10px 18px;
  align-items:center;padding:18px 22px;
}
.shortcuts-grid > div:nth-child(odd){white-space:nowrap;text-align:right;color:var(--muted)}
.shortcuts-grid > div:nth-child(even){font-size:14px}

/* ---------- BULK ACTION BAR ---------- */
.bulk-bar{
  position:fixed;left:50%;bottom:24px;transform:translate(-50%,140%);
  background:#0f1218;color:#fff;border-radius:14px;
  padding:10px 14px;display:flex;gap:8px;align-items:center;
  box-shadow:0 16px 36px rgba(0,0,0,.4);z-index:90;
  transition:transform .22s cubic-bezier(.32,1.4,.42,1);
  border:1px solid #1f2530;
}
.bulk-bar.show{transform:translate(-50%,0)}
.bulk-bar .bulk-count{font-size:13px;font-weight:600;margin-right:6px}
.bulk-bar .btn.secondary{background:#1c2230;color:#fff;border-color:#2a3140}
.bulk-bar .btn.secondary:hover{border-color:var(--orange)}
.bulk-bar .btn.danger{background:#7f1d1d}
.row-check{width:18px;height:18px;accent-color:var(--orange);cursor:pointer}
tr.row-selected td{background:#fff4dc !important}
html[data-theme="dark"] tr.row-selected td{background:#2c1e08 !important}

/* ---------- KANBAN DRAG AFFORDANCES ---------- */
.kanban-card{cursor:grab;transition:transform .12s ease, box-shadow .12s ease}
.kanban-card.dragging{opacity:.4}
.kanban-card.saving{outline:2px dashed var(--orange);outline-offset:-2px}
.kanban-col.drop-target{box-shadow:inset 0 0 0 2px var(--orange);background:#fffbf0}
html[data-theme="dark"] .kanban-col.drop-target{background:#2c1e08}
.kanban-col{transition:box-shadow .15s, background .15s}

/* ---------- FOCUS RINGS (accessibility) ---------- */
.btn:focus-visible,
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.qchip:focus-visible,
.nav-item:focus-visible,
.view-tab:focus-visible,
.seg-tab:focus-visible,
.modal-tab:focus-visible,
.ms-trigger:focus-visible,
.link-btn:focus-visible{outline:3px solid rgba(255,163,0,.45);outline-offset:2px}

/* ---------- LOADING SKELETON ---------- */
.skeleton{
  background:linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%);
  background-size:400% 100%;animation:bcSkel 1.4s ease infinite;
  border-radius:8px;height:14px;
}
html[data-theme="dark"] .skeleton{background:linear-gradient(90deg,#1f2530 25%,#252b37 37%,#1f2530 63%);background-size:400% 100%}
@keyframes bcSkel{ from{ background-position:100% 0 } to{ background-position:-100% 0 } }

/* ---------- SCROLL-TO-TOP ---------- */
.scroll-top{
  position:fixed;right:18px;bottom:18px;
  width:42px;height:42px;border-radius:50%;
  background:var(--orange);color:#fff;border:none;
  box-shadow:0 8px 24px rgba(0,0,0,.18);
  font-size:18px;display:none;align-items:center;justify-content:center;
  z-index:60;cursor:pointer;
}
.scroll-top.show{display:inline-flex}
.scroll-top:hover{background:var(--orange-dark)}
@media(max-width:640px){.scroll-top{right:12px;bottom:78px}}

/* ---------- DRAG-OVER row highlight (for future drag-rows feature) ---------- */
tr.drop-hint td{box-shadow:inset 0 2px 0 var(--orange)}

/* ---------- Slight refinements ---------- */
.btn{transition:background .12s ease, transform .08s ease, box-shadow .12s ease}
.btn:active{transform:translateY(1px)}
.qchip,.view-tab,.seg-tab,.nav-item,.modal-tab{transition:background .15s, color .15s, border-color .15s}
.dash-card,.lead-card,.kanban-card,.insight-card,.stat,.compact-stats .stat,.setting-block{transition:border-color .15s, transform .15s, box-shadow .15s}
.dash-card:hover,.insight-card:hover{transform:translateY(-1px);box-shadow:0 12px 28px rgba(0,0,0,.06)}
html[data-theme="dark"] .dash-card:hover,
html[data-theme="dark"] .insight-card:hover{box-shadow:0 12px 28px rgba(0,0,0,.4)}

/* ============================================================
   FIT-WINDOW TABLE LAYOUT + EXPANDABLE ROWS
   Replaces the previous wide table that horizontally scrolled.
   Columns: Lead, Stage, Contact, Deal, Last contact, Actions.
   ============================================================ */
.table-wrap.fit-window{overflow-x:visible}
table.table-fit{
  table-layout:fixed;width:100%;min-width:0;
  border-collapse:separate;border-spacing:0;
}
table.table-fit th,
table.table-fit td{
  padding:10px 12px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  vertical-align:middle;
  border-bottom:1px solid var(--border);
}
table.table-fit th{
  font-size:11px;text-transform:uppercase;letter-spacing:.04em;
  color:#555;background:#fff8e8;position:sticky;top:0;z-index:1;
  cursor:pointer;user-select:none;
}
html[data-theme="dark"] table.table-fit th{background:#1f2530;color:#c8cdd6}
table.table-fit th .sort-ind{color:#bbb;font-size:10px;margin-left:4px}
table.table-fit th.sorted .sort-ind{color:var(--orange)}

/* Column widths — total = 100%. Tweak only here. */
table.table-fit th.col-lead,    table.table-fit td.col-lead    { width:24% }
table.table-fit th.col-stage,   table.table-fit td.col-stage   { width:11% }
table.table-fit th.col-contact, table.table-fit td.col-contact { width:18% }
table.table-fit th.col-deal,    table.table-fit td.col-deal    { width:9%; text-align:right; font-variant-numeric:tabular-nums; font-weight:600 }
table.table-fit th.col-created, table.table-fit td.col-created { width:10%; font-variant-numeric:tabular-nums; color:var(--muted); font-size:12px }
table.table-fit th.col-last,    table.table-fit td.col-last    { width:12%; font-variant-numeric:tabular-nums }
table.table-fit th.col-actions, table.table-fit td.col-actions { width:16%; text-align:right }
@media(max-width:1200px){
  table.table-fit th.col-lead,    table.table-fit td.col-lead    { width:28% }
  table.table-fit th.col-contact, table.table-fit td.col-contact { width:18% }
  table.table-fit th.col-created, table.table-fit td.col-created { display:none }
}
@media(max-width:980px){
  table.table-fit th.col-contact, table.table-fit td.col-contact { display:none }
  table.table-fit th.col-lead,    table.table-fit td.col-lead    { width:40% }
}

/* Bulk-injected checkbox column should be exactly 36px and centered. */
table.table-fit th.row-check-th{width:36px !important;padding:8px 4px 8px 12px}
table.table-fit td.row-check-td{width:36px !important;padding:8px 4px 8px 12px;text-align:center;overflow:visible}

/* Lead cell — expand chevron + name block */
.cell-lead{display:flex;align-items:center;gap:8px;min-width:0}
.row-expand{
  flex:0 0 22px;width:22px;height:22px;border:1px solid var(--border);
  background:transparent;border-radius:6px;color:var(--muted);font-size:11px;
  display:inline-flex;align-items:center;justify-content:center;cursor:pointer;
  transition:background .15s, border-color .15s, color .15s, transform .15s;
}
.row-expand:hover{border-color:var(--orange);color:var(--orange-dark)}
.row-main.expanded .row-expand{background:var(--orange-soft);border-color:var(--orange);color:var(--orange-dark);transform:rotate(0)}
.lead-name-wrap{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}
.lead-name-wrap .company-line{display:flex;align-items:center;gap:6px;min-width:0;overflow:hidden;text-overflow:ellipsis}
.lead-name-wrap .company{font-weight:600;overflow:hidden;text-overflow:ellipsis;display:inline-block;max-width:100%}
.lead-name-wrap .subtext{font-size:11px;color:var(--muted);overflow:hidden;text-overflow:ellipsis}
.badge.mini{padding:1px 6px;font-size:9px}

/* Make rows visibly clickable (without being noisy) */
table.table-fit tr.row-main{cursor:pointer;transition:background .12s}
table.table-fit tr.row-main:hover td{background:#fffcf4}
html[data-theme="dark"] table.table-fit tr.row-main:hover td{background:#1c2230}
table.table-fit tr.row-main.expanded td{background:#fff8e8 !important}
html[data-theme="dark"] table.table-fit tr.row-main.expanded td{background:#2c1e08 !important}

/* Stale row rail — keep the existing left stripe, but on table-fit */
table.table-fit tr.row-main.stale td:first-child{box-shadow:inset 3px 0 0 var(--orange)}
html[data-theme="dark"] table.table-fit tr.row-main.stale td{background:#1d1a13}

/* Contact column */
.contact-compact{display:flex;align-items:center;gap:5px;min-width:0}
.contact-poc{font-size:13px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
/* has-poc: show name by default, swap to detail on hover */
.contact-compact.has-poc .contact-detail{display:none}
.contact-compact.has-poc:hover .contact-poc{display:none}
.contact-compact.has-poc:hover .contact-detail{display:flex;align-items:center;gap:5px;min-width:0}
.contact-primary{
  display:inline-flex;align-items:center;gap:5px;min-width:0;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;
}
.contact-primary i{flex:0 0 14px;font-size:12px;color:var(--muted)}
.contact-more{font-size:11px;color:var(--muted);background:#f3f4f6;padding:1px 6px;border-radius:999px;font-weight:600;flex:0 0 auto}
html[data-theme="dark"] .contact-more{background:#1f2530;color:#9aa3ad}
.contact-copy{background:none;border:none;padding:2px 3px;color:var(--muted);font-size:11px;flex:0 0 auto;line-height:1}
html[data-theme="dark"] .contact-copy{color:#9aa3ad}

/* Last contact column */
.col-last .stale-mark{margin-left:6px;color:var(--orange);font-size:11px;vertical-align:-1px}

/* Important / watchlist */
tr.important-row{background:linear-gradient(90deg,#fffbeb 0,transparent 6px)!important;border-left:3px solid #f5a800}
html[data-theme="dark"] tr.important-row{background:linear-gradient(90deg,#2a2010 0,transparent 6px)!important;border-left-color:#f5a800}
.imp-star{color:#f5a800;font-size:13px;margin-left:3px;vertical-align:-1px}
/* inactive star: faint so it doesn't add visual noise */
[data-action="toggle-important"]{color:#ccc;transition:color .15s}
[data-action="toggle-important"]:hover{color:#f5a800}
/* active star: gold fill */
.link-btn.imp-active,[data-action="toggle-important"].imp-active{color:#f5a800}
.link-btn.imp-active i{color:#f5a800;filter:drop-shadow(0 0 2px rgba(245,168,0,.35))}
html[data-theme="dark"] [data-action="toggle-important"]{color:#444}
.qchip.qchip-important{border-color:var(--orange);color:var(--orange-dark)}
.qchip.qchip-important.active{background:var(--orange);color:#fff;border-color:var(--orange)}
.qchip.qchip-important i{color:inherit}

/* Actions column — compact icon-only buttons */
.col-actions .actions{display:inline-flex;gap:4px;justify-content:flex-end}
.col-actions .link-btn{padding:5px 8px;font-size:12px}

/* Group row sits across the full width even in fit-window mode */
table.table-fit tr.group-row td{
  background:#faf7ee;font-weight:700;color:#6b4d00;font-size:12px;
  text-transform:uppercase;letter-spacing:.05em;padding:9px 14px;
  white-space:normal;
}
html[data-theme="dark"] table.table-fit tr.group-row td{background:#22272f;color:#e4b75b}

/* ---------- EXPANSION DETAIL PANEL ---------- */
table.table-fit tr.row-expansion td{
  padding:0;background:#fbf8f0;border-bottom:2px solid var(--orange-soft);
  white-space:normal;
}
html[data-theme="dark"] table.table-fit tr.row-expansion td{
  background:#181d27;border-bottom-color:#252a33;
}
.row-expansion-inner{padding:16px 18px 18px 50px;display:flex;flex-direction:column;gap:14px;animation:bcExpand .14s ease-out}
@keyframes bcExpand{ from{ opacity:0; transform:translateY(-4px) } to{ opacity:1; transform:translateY(0) } }
.exp-grid{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:12px 18px;
}
@media(max-width:1100px){ .exp-grid{grid-template-columns:repeat(2, minmax(0,1fr))} }
@media(max-width:640px){ .exp-grid{grid-template-columns:1fr} }
.exp-section{display:flex;flex-direction:column;gap:2px;min-width:0}
.exp-section .exp-label{
  font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;
  color:var(--muted);
}
.exp-section .exp-value{font-size:13px;color:var(--text);overflow:hidden;text-overflow:ellipsis;word-break:break-word}
.exp-section.exp-full{grid-column:1/-1}
.exp-section .exp-note{
  background:#fff;border:1px solid var(--border);border-radius:10px;
  padding:10px 12px;line-height:1.5;white-space:pre-wrap;
}
html[data-theme="dark"] .exp-section .exp-note{background:#11151c;border-color:#252a33}
.exp-actions{display:flex;gap:8px;flex-wrap:wrap;padding-top:6px;border-top:1px dashed var(--border)}
html[data-theme="dark"] .exp-actions{border-top-color:#252a33}

/* The old density-compact rule force-set `td { max-width:240px; white-space:nowrap }`.
   With table-layout:fixed our column widths already enforce that, so the
   max-width is harmless. But the `body.density-very-compact td .subtext{display:none}`
   rule hides the secondary line under the Lead column. Re-show it in very-
   compact only if there's room — handled by users via Settings. */

/* ============================================================
   STAGE BADGE AS CLICKABLE BUTTON (inline-stage edit trigger)
   ============================================================ */
.stage-badge{
  border:1px solid transparent;background:#fff1d3;color:#9a6200;
  padding:3px 9px;border-radius:999px;font-size:11px;font-weight:700;
  display:inline-flex;align-items:center;gap:4px;cursor:pointer;
  transition:background .12s, border-color .12s, transform .08s;
}
.stage-badge.blue{background:#dbeafe;color:#1d4ed8}
.stage-badge.green{background:#dcfce7;color:#166534}
.stage-badge.red{background:#fee2e2;color:#991b1b}
.stage-badge.orange{background:#fff1d3;color:#9a6200}
.stage-badge .stage-caret{font-size:9px;opacity:.5;transition:transform .12s}
.stage-badge:hover{transform:translateY(-1px);border-color:rgba(0,0,0,.08)}
.stage-badge:hover .stage-caret{opacity:1}
html[data-theme="dark"] .stage-badge.orange{background:#3a2a05;color:#ffce6b}
html[data-theme="dark"] .stage-badge.blue{background:#102844;color:#93c5fd}
html[data-theme="dark"] .stage-badge.green{background:#0e2c1c;color:#86efac}
html[data-theme="dark"] .stage-badge.red{background:#3a1419;color:#fca5a5}

/* ============================================================
   INLINE POPOVERS — quick note + stage change.
   ============================================================ */
.inline-popover{
  position:absolute;z-index:120;
  width:320px;max-width:calc(100vw - 24px);
  background:var(--card);border:1px solid var(--border);
  border-radius:14px;box-shadow:0 28px 60px rgba(0,0,0,.22);
  padding:12px;display:flex;flex-direction:column;gap:10px;
  animation:bcPopIn .12s ease-out;
}
html[data-theme="dark"] .inline-popover{background:#1a1f29;border-color:#252a33}
@keyframes bcPopIn{ from{ opacity:0; transform:translateY(-4px) scale(.98) } to{ opacity:1; transform:translateY(0) scale(1) } }
.inline-pop-head{font-size:12px;font-weight:700;color:var(--text);display:flex;align-items:center;gap:6px}
.inline-pop-head .muted{font-weight:500;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.inline-pop-foot{display:flex;justify-content:flex-end;gap:8px}
.inline-note-input{min-height:90px;font-size:13px;resize:vertical}
.note-popover{width:380px}

/* Stage popover options */
.stage-popover{width:300px}
.stage-options{display:flex;flex-direction:column;gap:4px;max-height:280px;overflow-y:auto}
.stage-opt{
  border:none;background:transparent;text-align:left;
  padding:6px 8px;border-radius:8px;cursor:pointer;
  display:flex;align-items:center;justify-content:space-between;gap:8px;
}
.stage-opt:hover{background:var(--orange-soft)}
html[data-theme="dark"] .stage-opt:hover{background:#2c1e08}
.stage-opt.current{background:var(--orange-soft);font-weight:700}
.stage-opt.current i{color:var(--orange-dark);font-size:14px}

/* ============================================================
   UNDO TOAST — slides in after a soft-delete.
   ============================================================ */
.undo-toast{
  position:fixed;left:50%;bottom:24px;transform:translate(-50%,140%);
  background:#0f1218;color:#fff;border:1px solid #1f2530;border-radius:14px;
  padding:10px 14px;display:flex;align-items:center;gap:14px;
  box-shadow:0 16px 36px rgba(0,0,0,.4);z-index:95;
  transition:transform .22s cubic-bezier(.32,1.4,.42,1);
  font-size:13px;
}
.undo-toast.show{transform:translate(-50%,0)}
.undo-toast .msg{font-weight:600}
.undo-toast .btn{background:var(--orange);border:none}
.undo-toast .btn:hover{background:var(--orange-dark)}

/* ============================================================
   SAVED VIEWS toolbar (lives inside .filter-primary)
   ============================================================ */
.views-toolbar{position:relative}
.views-trigger{
  display:inline-flex;align-items:center;gap:6px;
  padding:7px 11px;border:1px solid var(--border);background:#fff;
  border-radius:9px;font-weight:600;font-size:12px;color:#555;
  white-space:nowrap;cursor:pointer;
}
.views-trigger:hover{border-color:var(--orange);color:var(--orange-dark)}
html[data-theme="dark"] .views-trigger{background:#11151c;color:#cfd6e1;border-color:#252a33}
.views-panel{
  position:absolute;right:0;top:calc(100% + 6px);
  width:300px;background:var(--card);border:1px solid var(--border);
  border-radius:12px;box-shadow:0 18px 40px rgba(0,0,0,.18);
  padding:10px;z-index:50;display:none;
}
html[data-theme="dark"] .views-panel{background:#1a1f29;border-color:#252a33}
.views-toolbar.open .views-panel{display:block}
.views-panel-head{display:flex;gap:8px;margin-bottom:8px}
.views-panel-head .input{font-size:13px;padding:8px 10px}
.views-panel-list{display:flex;flex-direction:column;gap:4px;max-height:240px;overflow-y:auto}
.view-row{display:flex;align-items:center;gap:4px}
.view-apply{
  flex:1;text-align:left;background:transparent;border:none;
  padding:7px 9px;border-radius:8px;cursor:pointer;font-size:13px;color:var(--text);
  display:flex;align-items:center;gap:8px;
}
.view-apply:hover{background:var(--orange-soft);color:var(--orange-dark)}
html[data-theme="dark"] .view-apply:hover{background:#2c1e08;color:#ffc56e}
.view-apply i{color:var(--orange-dark);font-size:11px}
.view-del{
  background:transparent;border:none;color:var(--muted);cursor:pointer;
  width:26px;height:26px;border-radius:6px;
}
.view-del:hover{color:var(--danger);background:#fee2e2}
html[data-theme="dark"] .view-del:hover{background:#3a1419;color:#fca5a5}
.views-empty{font-size:12px;color:var(--muted);padding:14px;text-align:center}

/* ============================================================
   KEYBOARD-NAV FOCUSED ROW
   ============================================================ */
tr.row-main.row-focused td{
  box-shadow:inset 0 0 0 2px var(--orange) !important;
  background:#fffbf0 !important;
}
html[data-theme="dark"] tr.row-main.row-focused td{
  box-shadow:inset 0 0 0 2px var(--orange) !important;
  background:#2c1e08 !important;
}

/* ============================================================
   STAGE PROBABILITIES SETTINGS LIST
   ============================================================ */
#stageProbsList{display:flex;flex-direction:column;gap:6px}
.prob-row{
  display:grid;grid-template-columns:1fr 80px auto;gap:10px;align-items:center;
  padding:6px 8px;background:#fff;border:1px solid var(--border);border-radius:10px;
}
html[data-theme="dark"] .prob-row{background:#11151c;border-color:#252a33}
.prob-name{font-size:13px}
.prob-input{padding:6px 8px;font-size:13px;text-align:right;font-variant-numeric:tabular-nums}

/* ============================================================
   DASHBOARD FORECAST CARD highlight
   ============================================================ */
#dashForecastCard{
  border:1px solid rgba(255,163,0,.35);
  background:linear-gradient(135deg, #fff8e8 0%, #fff 100%);
}
html[data-theme="dark"] #dashForecastCard{
  background:linear-gradient(135deg, #2c1e08 0%, #1a1f29 100%);
  border-color:rgba(255,163,0,.3);
}

/* ---------- DARK MODE — round-2 refinements ---------- */
/* Custom selection so highlighted text doesn't look like a Chrome
   selection (the bluish-purple in the screenshot). */
html[data-theme="dark"] ::selection{ background:#3a2a05; color:#ffce6b }
html[data-theme="dark"] ::-moz-selection{ background:#3a2a05; color:#ffce6b }

/* Compact stat tiles — flatter, calmer surface, brighter numbers, dim labels.
   In the previous drop these inherited an off-tone background that looked
   purple-tinted next to the orange stale-rail. */
html[data-theme="dark"] .compact-stats .stat{
  background:#11151c;border:1px solid #1f2530;border-radius:12px;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.015);
}
html[data-theme="dark"] .compact-stats .stat .l{color:#7f8a99;letter-spacing:.06em}
html[data-theme="dark"] .compact-stats .stat .v{color:#f3f5f8;font-variant-numeric:tabular-nums}

/* Stale-row left rail: was too saturated against the warm row background
   for compact mode. Soften to a thinner, lower-saturation stripe. */
html[data-theme="dark"] tr.stale td{background:#1d1a13}
html[data-theme="dark"] tr.stale td:first-child{box-shadow:inset 3px 0 0 #b45309}
html[data-theme="dark"] body.density-compact tr.stale td:first-child,
html[data-theme="dark"] body.density-very-compact tr.stale td:first-child{box-shadow:inset 2px 0 0 #b45309}

/* "61 stale (20+d)" pill in the subline — make the dark-mode version
   read as a calm warning chip not a glowing block. */
html[data-theme="dark"] .badge.warn{
  background:rgba(180,83,9,.18);color:#fbbf24;
  border:1px solid rgba(251,191,36,.18);
}

/* Subline + summary text in dark mode */
html[data-theme="dark"] .subline{
  background:#11151c;color:#9aa3ad;border-bottom-color:#1f2530;
}

/* Filter panel surface in dark mode — was bleeding into the page bg.
   Anchor it visually as a card so the search row reads as a toolbar. */
html[data-theme="dark"] .filter-panel{
  background:#161a22;border-top:1px solid #1f2530;
}
html[data-theme="dark"] .filter-secondary{border-top-color:#1f2530}

/* Dropdown carets / placeholders */
html[data-theme="dark"] .select option{background:#161a22;color:#e7e9ec}
html[data-theme="dark"] .input::placeholder{color:#5e6776}

/* Scrollbar styling (Chrome/Edge) — visible but not flashy */
html[data-theme="dark"] *::-webkit-scrollbar{width:10px;height:10px}
html[data-theme="dark"] *::-webkit-scrollbar-thumb{background:#252a33;border-radius:6px;border:2px solid #11151c}
html[data-theme="dark"] *::-webkit-scrollbar-thumb:hover{background:#3a4250}
html[data-theme="dark"] *::-webkit-scrollbar-track{background:transparent}

/* Topbar pills (vineet@bytescare.com, Master) — flatten the orange-soft
   pill so it doesn't compete with the primary "Add lead" CTA */
html[data-theme="dark"] .pill{
  background:#1c2230;color:#cfd6e1;border:1px solid #252a33;
}
html[data-theme="dark"] .pill.master{
  background:rgba(124,58,237,.14);color:#c4b5fd;border-color:rgba(124,58,237,.25);
}

/* "Master" sidebar item: the M dot was high-contrast purple — tone down */
html[data-theme="dark"] .nav-item .badge-dot{
  background:rgba(124,58,237,.18);color:#c4b5fd;
}

/* The Add lead CTA should pop — keep orange but add depth in dark mode */
html[data-theme="dark"] .btn:not(.secondary):not(.danger){
  box-shadow:0 1px 0 rgba(0,0,0,.4), 0 4px 12px rgba(255,163,0,.12);
}

/* Bulk modal selects in dark mode (was using light-mode .select rules) */
html[data-theme="dark"] #bulkStageSelect,
html[data-theme="dark"] #bulkReassignSelect,
html[data-theme="dark"] #bulkReassignInput{background:#11151c;color:var(--text)}

/* ============================================================
   ACTIVITY TIMELINE — used inside the Edit Lead modal AND inside
   the row-expansion panel. Append-only log of [stamp · author]
   blocks with optional free-form note + bullet-style field changes.
   ============================================================ */
.activity-timeline-mini{
  display:flex;flex-direction:column;gap:8px;
  max-height:280px;overflow-y:auto;
  padding:8px;border:1px solid var(--border);border-radius:10px;
  background:#fff;
}
html[data-theme="dark"] .activity-timeline-mini{background:#11151c;border-color:#252a33}
.exp-section .activity-timeline-mini{max-height:380px}
.ti-entry{
  position:relative;padding:9px 12px 9px 14px;
  background:#fafafa;border:1px solid var(--border);border-radius:10px;
  font-size:13px;line-height:1.45;
}
.ti-entry::before{
  content:"";position:absolute;left:0;top:9px;bottom:9px;width:3px;
  background:var(--orange);border-radius:0 3px 3px 0;
}
html[data-theme="dark"] .ti-entry{background:#161a22;border-color:#252a33}
.ti-head{
  display:flex;flex-wrap:wrap;gap:8px;align-items:center;
  margin-bottom:5px;
}
.ti-stamp{
  font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums;
  display:inline-flex;align-items:center;gap:4px;
}
.ti-author{
  font-size:11px;font-weight:700;color:var(--orange-dark);
  background:var(--orange-soft);padding:1px 8px;border-radius:999px;
}
html[data-theme="dark"] .ti-author{background:#2c1e08;color:#ffc56e}
.ti-note{white-space:pre-wrap;color:var(--text);margin-bottom:4px}
.ti-changes{margin:4px 0 0;padding:0 0 0 4px;list-style:none;display:flex;flex-direction:column;gap:2px}
.ti-changes li{
  font-size:12px;color:var(--text);
  padding:2px 8px;background:#fff;border:1px solid var(--border);border-radius:6px;
  font-family:inherit;
}
html[data-theme="dark"] .ti-changes li{background:#1f2530;border-color:#2a3140;color:#cfd6e1}
.ti-empty{padding:14px;text-align:center;color:var(--muted);font-size:12px}

/* Read-only datetime field that's bumped server-side */
input[type="datetime-local"][readonly]{
  background:#fafafa;color:var(--muted);cursor:not-allowed;
}
html[data-theme="dark"] input[type="datetime-local"][readonly]{
  background:#0e1116;color:#7f8a99;
}

/* ---------- Empty state hero ---------- */
.empty-hero{
  display:flex;flex-direction:column;align-items:center;gap:10px;
  padding:50px 20px;text-align:center;color:var(--muted);
}
.empty-hero i{font-size:38px;color:var(--orange)}
.empty-hero h3{margin:0;color:var(--text);font-size:18px}
.empty-hero p{margin:0;max-width:380px;font-size:13.5px;line-height:1.5}
.empty-hero .btn{margin-top:6px}
