/* =========================================================================
   Project Arsenal — Design System
   Apple-grade: restrained, spacious, premium. Light + dark parity.
   ========================================================================= */

/* ---- Design tokens (light) ---------------------------------------------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* SaaS blue + white palette (TalentLink-inspired).
     #FCFCFC Emptiness · #E3E4E6 Windswept Beach · #C3C3C5 Explosive Grey
     #8BCAF9 Drift on the Sea · #40AAF8 Adamantine Blue · #1297FD Blue Nebula */
  --canvas: #fcfcfc;           /* Emptiness */
  --card: #ffffff;
  --card-2: #f4f5f6;           /* tint toward Windswept Beach */
  --text: #1a2230;
  --text-2: #5b6470;
  --text-3: #8a929c;
  --hairline: #e3e4e6;         /* Windswept Beach — clear, solid borders */
  --hairline-strong: #c3c3c5;  /* Explosive Grey */

  /* Brand = blue (no red). Kept as brand vars so gradients still resolve. */
  --brand: #1297fd;            /* Blue Nebula */
  --brand-2: #40aaf8;          /* Adamantine Blue */
  --brand-soft: rgba(18, 151, 253, 0.10);

  --accent: #1297fd;           /* Blue Nebula — primary */
  --accent-hover: #40aaf8;     /* Adamantine Blue */
  --accent-press: #0c84e4;
  --accent-soft: rgba(18, 151, 253, 0.10);
  --accent-ring: rgba(18, 151, 253, 0.32);

  --green: #1d9e5e;
  --green-soft: rgba(29, 158, 94, 0.12);
  --amber: #b25f00;
  --amber-soft: rgba(214, 130, 0, 0.14);

  --shadow-sm: 0 1px 2px rgba(24, 39, 75, 0.04);
  --shadow: 0 1px 2px rgba(24, 39, 75, 0.04), 0 8px 24px rgba(24, 39, 75, 0.06);
  --shadow-lg: 0 1px 2px rgba(24, 39, 75, 0.05), 0 18px 48px rgba(24, 39, 75, 0.12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 18px;

  --sidebar-w: 240px;
  --maxw: 1200px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Design tokens (dark) ----------------------------------------------- */
/* Deep navy surfaces that complement the blue+white light palette. */
[data-theme="dark"] {
  --canvas: #0b1220;          /* deep navy */
  --card: #131c2e;
  --card-2: #1c2840;
  --text: #eef3fb;
  --text-2: #9fb0c9;
  --text-3: #74859e;
  --hairline: rgba(140, 170, 220, 0.16);
  --hairline-strong: rgba(150, 180, 230, 0.30);

  --brand: #40aaf8;           /* Adamantine Blue (lifted for dark) */
  --brand-2: #8bcaf9;         /* Drift on the Sea */
  --brand-soft: rgba(64, 170, 248, 0.16);

  --accent: #40aaf8;          /* Adamantine Blue — bright on navy */
  --accent-hover: #5cb6fa;
  --accent-press: #1297fd;
  --accent-soft: rgba(64, 170, 248, 0.18);
  --accent-ring: rgba(64, 170, 248, 0.45);

  --green: #4ade8a;
  --green-soft: rgba(74, 222, 138, 0.18);
  --amber: #ffc266;
  --amber-soft: rgba(255, 194, 102, 0.18);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.6), 0 18px 48px rgba(0, 0, 0, 0.7);
}

/* ---- Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--canvas);
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
:focus-visible { outline: none; }

/* ---- Layout shell -------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: var(--card);
  border-right: 1px solid var(--hairline);
  z-index: 40;
  transition: transform 0.28s var(--ease);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
/* ACE logo: animated hypotrochoid above the wordmark */
.brand-ace {
  flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 10px 18px;
}
.brand-ace .brand-word {
  font-size: 26px; font-weight: 800; letter-spacing: 0.06em; line-height: 1;
  background: linear-gradient(135deg, var(--brand-2) 0%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.brand-ace .brand-full {
  display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3); text-align: center;
}

/* --- Animated hypotrochoid mark --- */
.hypo-logo { display: block; overflow: visible; }
.hypo-sm { width: 46px; height: 46px; }
.hypo-lg { width: 96px; height: 96px; margin: 0 auto 6px; }
.hypo-path {
  stroke-dasharray: 432;
  stroke-dashoffset: 432;
  filter: drop-shadow(0 1px 5px var(--brand-soft));
  animation: hypoDraw 5.5s ease-in-out infinite;
}
@keyframes hypoDraw {
  0%   { stroke-dashoffset: 432; opacity: 0.25; }
  10%  { opacity: 1; }
  55%  { stroke-dashoffset: 0;   opacity: 1; }
  72%  { stroke-dashoffset: 0;   opacity: 1; }
  100% { stroke-dashoffset: -432; opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
  .hypo-path { animation: none; stroke-dashoffset: 0; }
}
.brand .dot {
  width: 20px; height: 20px; border-radius: 6px;
  background: linear-gradient(135deg, var(--brand-2) 0%, var(--accent) 100%);
  box-shadow: 0 2px 10px var(--brand-soft);
  flex: none;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.nav a:hover { background: var(--card-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .ic { width: 17px; height: 17px; opacity: 0.9; flex: none; }
.nav a.active .ic { opacity: 1; }

.sidebar-foot {
  margin-top: auto;
  padding: 12px 12px 2px;
  font-size: 12px;
  color: var(--text-3);
  border-top: 1px solid var(--hairline);
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Top bar ------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 40px 18px;
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.topbar .title { font-size: 30px; line-height: 1.1; }
.topbar .subtitle { margin-top: 6px; color: var(--text-2); font-size: 14.5px; font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; width: 100%; }

.content {
  width: 100%;
  margin: 0;
  padding: 28px 40px 80px;   /* full-bleed: fills the area next to the sidebar */
}

/* ---- Cards --------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
.card-head { margin-bottom: 16px; }
.card-head h3 { font-size: 17px; }
.card-head .hint { margin-top: 4px; color: var(--text-2); font-size: 13px; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: -0.01em; }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    transform 0.08s var(--ease), box-shadow 0.18s var(--ease), opacity 0.18s var(--ease);
}
.btn:hover { background: var(--card-2); }
.btn:active { transform: translateY(0.5px) scale(0.985); }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 4px 14px var(--accent-ring);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--card-2); color: var(--text); }

.btn-danger { color: #d4373b; border-color: var(--hairline-strong); }
.btn-danger:hover { background: rgba(212, 55, 59, 0.08); }

.btn-lg { height: 46px; padding: 0 26px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 32px; padding: 0 13px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }

/* ---- Form controls ------------------------------------------------------- */
.input, .select, textarea.input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
  width: 100%;
}
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236e6e73' d='M6 8 0 2l1.4-1.4L6 5.2 10.6.6 12 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
textarea.input { height: auto; min-height: 78px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input::placeholder { color: var(--text-3); }
.input-sm { height: 32px; font-size: 13px; border-radius: 8px; }

/* ---- Segmented control --------------------------------------------------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--card-2);
  border: 1px solid var(--hairline);
  border-radius: 11px;
}
.segmented button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 7px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.segmented button.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---- Range slider + value bubble ---------------------------------------- */
.slider-field { gap: 10px; }
.slider-top { display: flex; align-items: baseline; justify-content: space-between; }
.slider-top .bubble {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
}
.slider-row { display: flex; align-items: center; gap: 14px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--hairline-strong);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 0.5px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.02);
  transition: transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.08); }
input[type="range"]:active::-webkit-slider-thumb { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 6px var(--accent-ring); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--hairline-strong); }
.slider-row .num { width: 84px; flex: none; }

/* ---- Chips --------------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 12px;
  background: var(--card-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.chip button {
  appearance: none; border: none; background: transparent;
  color: var(--text-3); cursor: pointer; font-size: 15px; line-height: 1;
  padding: 0; width: 16px; height: 16px; border-radius: 50%;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.chip button:hover { background: var(--hairline-strong); color: var(--text); }

.warn-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--amber-soft); color: var(--amber);
  font-size: 12.5px; font-weight: 600;
}

/* ---- Status pills -------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
  text-transform: uppercase;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.sold { background: var(--green-soft); color: var(--green); }
.pill.forsale { background: var(--accent-soft); color: var(--accent); }

/* ---- Stat band ----------------------------------------------------------- */
.stat-band { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.stat-card .label {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.stat-card .value {
  margin-top: 8px; font-size: 30px; font-weight: 600; letter-spacing: -0.02em;
  line-height: 1.05;
}
.stat-card.hero { background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%); border-color: transparent; box-shadow: var(--shadow-lg); }
.stat-card.hero .label, .stat-card.hero .value { color: #fff; }
.stat-card.hero .label { opacity: 0.85; }

/* ---- Stats strip (inline) ----------------------------------------------- */
.stats-strip { display: flex; gap: 26px; flex-wrap: wrap; }
.stats-strip .item { display: flex; flex-direction: column; }
.stats-strip .item .n { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
.stats-strip .item .k { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; }

/* ---- Data table ---------------------------------------------------------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: auto;
}
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: color-mix(in srgb, var(--card) 92%, var(--canvas));
  backdrop-filter: blur(8px);
  text-align: left;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  letter-spacing: 0.01em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--text); }
table.data thead th .arrow { opacity: 0; margin-left: 5px; font-size: 10px; transition: opacity 0.15s var(--ease); }
table.data thead th.sorted .arrow { opacity: 1; }
table.data tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  white-space: nowrap;
}
table.data tbody td.num { font-variant-numeric: tabular-nums; }
table.data tbody td .addr-main { font-weight: 500; }
table.data tbody tr { transition: background 0.12s var(--ease); }
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--card-2) 40%, transparent); }
table.data tbody tr:hover { background: var(--accent-soft); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-muted { color: var(--text-3); }

/* ---- Pagination ---------------------------------------------------------- */
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  padding: 14px 4px 0; font-size: 13px; color: var(--text-2);
}

/* ---- Toolbar (sticky filter) -------------------------------------------- */
.toolbar {
  position: sticky; top: 92px; z-index: 20;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.toolbar .input, .toolbar .select { height: 36px; width: auto; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar .spacer { flex: 1; }

/* ---- Empty state --------------------------------------------------------- */
.empty {
  text-align: center; padding: 64px 24px; color: var(--text-2);
}
.empty .big { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 6px; letter-spacing: -0.01em; }

/* ---- Progress panel ------------------------------------------------------ */
.progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.progress-status { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14.5px; }
.progress-status .led { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.progress-status.running .led { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.progress-meta { display: flex; gap: 22px; flex-wrap: wrap; }
.progress-meta .m { display: flex; flex-direction: column; }
.progress-meta .m .n { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.progress-meta .m .k { font-size: 11.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; }

.bar { height: 8px; border-radius: 999px; background: var(--card-2); overflow: hidden; margin: 14px 0; }
.bar > span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
  transition: width 0.4s var(--ease);
}

.log {
  font-family: var(--font-mono);
  font-size: 12px; line-height: 1.55;
  background: var(--card-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 260px; overflow: auto;
  color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
}
/* Inside the harvest two-column layout the log fills the remaining height
   of its sticky card and scrolls within its own box. */
.harvest-progress .log { flex: 1; max-height: none; min-height: 0; margin-top: 8px; }
.log-head {
  margin-top: 18px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3);
  display: flex; align-items: center; justify-content: space-between;
}
.log-head .log-note {
  text-transform: none; letter-spacing: 0; font-weight: 500;
  color: var(--green); font-size: 11px; margin-left: 6px;
}
.log .ts { color: var(--text-3); }
.log .logjob { color: var(--accent); font-weight: 600; opacity: 0.8; }

/* ---- Skeleton shimmer ---------------------------------------------------- */
.skel {
  position: relative; overflow: hidden;
  background: var(--card-2); border-radius: 6px; height: 12px;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 8%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel-row td { padding: 11px 14px; border-bottom: 1px solid var(--hairline); }

/* ---- Toasts -------------------------------------------------------------- */
.toasts {
  position: fixed; top: 18px; right: 18px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 360px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500;
  pointer-events: auto;
  animation: toast-in 0.28s var(--ease);
}
.toast.out { animation: toast-out 0.25s var(--ease) forwards; }
.toast .tdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); }
.toast.success .tdot { background: var(--green); }
.toast.error .tdot { background: #d4373b; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px) translateY(-4px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---- Theme toggle -------------------------------------------------------- */
.theme-toggle .ic-sun { display: none; }
[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
[data-theme="dark"] .theme-toggle .ic-sun { display: block; }

/* ---- Hamburger ----------------------------------------------------------- */
.hamburger { display: none; }
.scrim { display: none; }

/* ---- Helpers ------------------------------------------------------------- */
.muted { color: var(--text-2); }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.hidden { display: none !important; }
.note {
  font-size: 13px; color: var(--text-2);
  background: var(--card-2); border: 1px solid var(--hairline);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.note strong { color: var(--text-1); font-weight: 600; }

.price-note {
  font-size: 12.5px; color: var(--text-2);
  margin: 12px 2px 0; line-height: 1.5;
}
.price-note strong { color: var(--text-1); font-weight: 600; }

/* ---- Harvest two-column layout ------------------------------------------ */
.harvest-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);  /* controls | progress+log */
  gap: 22px;
  align-items: start;
}
.harvest-controls { min-width: 0; }
/* Right card is sticky and tall enough that the log scrolls inside it — no page scroll. */
.harvest-progress {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 150px);   /* viewport minus topbar + padding */
  min-height: 360px;
}
.mt-18 { margin-top: 18px; }

/* ---- BULK comp layout --------------------------------------------------- */
.bulk-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px; align-items: start;
}
.bulk-controls { position: sticky; top: 16px; }
.bulk-toolbar { display: flex; align-items: center; gap: 10px; }
.bulk-toolbar .spacer { flex: 1; }
.bulk-summary { font-size: 13px; color: var(--text-2); }
/* No-comp-data warning banner */
.nodata-banner {
  display: flex; align-items: center; gap: 14px;
  background: rgba(227, 0, 27, 0.08);
  border: 1px solid rgba(227, 0, 27, 0.30);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px;
}
.nodata-text { flex: 1; font-size: 13.5px; color: #c1121f; }
[data-theme="dark"] .nodata-text { color: #ff6b7a; }
.nodata-text strong { font-weight: 700; }
.nodata-actions { display: flex; gap: 8px; flex: none; }
.btn.btn-danger-solid {
  background: #e3001b; color: #fff; border: none; font-weight: 600;
}
.btn.btn-danger-solid:hover { background: #c1121f; }

/* Comp Listings filter bar */
.cl-filters {
  display: flex; align-items: flex-end; gap: 24px; flex-wrap: wrap;
  margin-top: 14px; padding: 12px 16px;
  background: var(--card-2); border: 1px solid var(--hairline); border-radius: var(--radius);
}
.cl-filter { display: flex; flex-direction: column; gap: 6px; }
.cl-filter label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.cl-filter input[type="range"] { width: 200px; }
.cl-fval { color: var(--accent); font-weight: 700; }

.range-row { display: flex; align-items: center; gap: 8px; }
.range-row .input { width: 100%; min-width: 0; }
.range-row .range-dash { color: var(--text-3); flex: none; }
.th-tip { cursor: help; opacity: 0.6; font-size: 11px; font-weight: 400; }
.cell-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.offer-cell { font-weight: 700; color: var(--accent); }
.diff-pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums;
  background: var(--card-2); color: var(--text-2);
}
.diff-pill.diff-good { background: var(--green-soft); color: var(--green); }
.diff-pill.diff-bad { background: rgba(227,0,27,0.12); color: #e3001b; }
@media (max-width: 1040px) {
  .bulk-layout { grid-template-columns: 1fr; }
  .bulk-controls { position: static; }
}

/* ---- Comps two-column layout -------------------------------------------- */
.comps-layout {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);  /* inputs left, results right */
  gap: 22px;
  align-items: start;
}
.comps-input { position: sticky; top: 16px; }   /* keep inputs in view while scrolling results */

/* Narrow numeric inputs (ZIP, beds, baths, …) so they're not too wide. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.input.narrow { max-width: 140px; }
.field-grid .input.narrow { max-width: 100%; }   /* fill its grid cell */

.filter-stack { display: flex; flex-direction: column; gap: 16px; }

/* Comps empty state (before first run) */
.comps-empty {
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-lg);
  background: var(--card-2);
  min-height: 320px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}
.comps-empty-inner { color: var(--text-2); font-size: 14px; line-height: 1.6; }
.comps-empty-icon { font-size: 34px; margin-bottom: 10px; opacity: 0.8; }
.comps-empty strong { color: var(--text); font-weight: 600; }

/* ---- Address links ------------------------------------------------------- */
.addr-link { color: var(--accent); font-weight: 500; text-decoration: none; }
.addr-link:hover { text-decoration: underline; }
.arv-link { color: var(--accent); font-weight: 700; text-decoration: none; cursor: pointer; }
.arv-link:hover { text-decoration: underline; }

/* ---- Comp exclude control + excluded row -------------------------------- */
.col-ex { width: 34px; text-align: center; padding-left: 8px !important; padding-right: 4px !important; }
.ex-btn {
  width: 22px; height: 22px; line-height: 1; padding: 0;
  border: 1px solid var(--hairline-strong); border-radius: 6px;
  background: var(--card); color: var(--text-2);
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.ex-btn:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
tr.comp-excluded td { opacity: 0.4; }
tr.comp-excluded td.col-ex { opacity: 1; }   /* keep the toggle clickable */
tr.comp-excluded .ex-btn { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

/* ---- Run status panel (auto-harvest + comp progress) -------------------- */
.run-status {
  margin-top: 14px; padding: 12px 14px;
  background: var(--card-2); border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}
.run-status-head { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; }
.run-status .led { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.run-status .led.running { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); animation: pulse 1.5s var(--ease) infinite; }
.run-status .led.ok { background: var(--green); }
.run-status .led.err { background: #e3001b; }
.run-status .bar { margin: 10px 0 8px; }
.run-log {
  font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
  color: var(--text-2); max-height: 120px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* ---- History drawer ------------------------------------------------------ */
/* z-index above Leaflet (its controls reach ~1000), so the map can't bleed through. */
.hist-scrim { position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,0.35); backdrop-filter: blur(2px); }
.hist-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1101;
  width: 420px; max-width: 92vw;
  background: var(--card); border-left: 1px solid var(--hairline);
  box-shadow: var(--shadow-lg); padding: 22px;
  display: flex; flex-direction: column;
  animation: slideIn 0.22s var(--ease);
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.hist-head { display: flex; align-items: center; justify-content: space-between; }
.hist-head h3 { font-size: 18px; }
.hist-sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.hist-actions { margin: 12px 0; }
.hist-list { flex: 1; overflow: auto; margin-top: 6px; }
.hist-empty { color: var(--text-3); font-size: 14px; padding: 30px 0; text-align: center; }
.hist-group { margin-bottom: 18px; }
.hist-addr { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.hist-addr .hist-loc { display: block; font-weight: 400; font-size: 12px; color: var(--text-2); }
.hist-item {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: 9px 12px; margin-bottom: 6px; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--hairline);
  border-radius: var(--radius-sm); transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.hist-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.hist-when { font-size: 12px; font-weight: 600; }
.hist-vals { font-size: 11.5px; color: var(--text-2); }

/* ---- Comp map + toolbar -------------------------------------------------- */
.map-card { padding: 0; overflow: hidden; }
/* z-index:0 + isolation keeps the map's whole stacking context BELOW the History
   drawer (z-index 1100) without touching Leaflet's internal pane z-indexes —
   overriding those collapses the tile/marker layering and grays the map out. */
.comp-map { width: 100%; height: 320px; border-radius: var(--radius-lg); position: relative; z-index: 0; isolation: isolate; }
.comp-map .leaflet-popup-content { font: 12px var(--font-sans); }
.comp-map .leaflet-popup-content a { color: var(--accent); font-weight: 600; text-decoration: none; }
.comp-map .leaflet-popup-content a:hover { text-decoration: underline; }
.comps-toolbar { display: flex; align-items: center; gap: 10px; }
.comps-toolbar .spacer { flex: 1; }

/* ---- Comp score badges + outlier ---------------------------------------- */
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; padding: 2px 7px; border-radius: 6px;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.score-badge.sc-hi { background: var(--green-soft); color: var(--green); }
.score-badge.sc-mid { background: var(--amber-soft); color: var(--amber); }
.score-badge.sc-lo { background: var(--card-2); color: var(--text-3); }
.outlier-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--amber); background: var(--amber-soft);
  padding: 1px 5px; border-radius: 4px; margin-left: 4px;
}
tr.comp-outlier td { background: color-mix(in srgb, var(--amber-soft) 40%, transparent); }

/* ---- Stat card footnote + ARV override ---------------------------------- */
.stat-foot { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.stat-card.hero .stat-foot { color: rgba(255,255,255,0.8); }
/* Listing price inside the ARV hero card — distinct amber so it stands out vs ARV. */
.stat-listprice {
  display: inline-flex; align-items: baseline; gap: 6px;
  margin-top: 8px; font-size: 18px; font-weight: 700;
  color: #ffd966; font-variant-numeric: tabular-nums;
}
.stat-listprice .lp-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.18); padding: 1px 6px; border-radius: 4px;
}
.stat-tip { cursor: help; opacity: 0.7; font-size: 11px; }
.arv-edit {
  float: right; border: none; background: rgba(255,255,255,0.18); color: #fff;
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; font-size: 12px;
  line-height: 1; transition: background 0.15s var(--ease);
}
.arv-edit:hover { background: rgba(255,255,255,0.32); }
.arv-override {
  display: flex; align-items: center; gap: 6px; margin-top: 10px;
}
.arv-override .prefix { color: #fff; opacity: 0.9; font-weight: 600; }
.arv-override .input { max-width: 130px; }
.stat-card.hero .arv-override .btn { background: rgba(255,255,255,0.92); color: var(--accent); border: none; }
.stat-card.hero .arv-override .btn.btn-ghost { background: transparent; color: rgba(255,255,255,0.9); }

/* Address being comped, shown under the Wholesale Offer header */
.offer-subject { margin: -4px 0 14px; font-size: 14px; }
.offer-subject:empty { display: none; }
.offer-subject-label { color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; margin-right: 4px; }
.addr-google { margin-left: 8px; font-size: 12px; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.addr-google:hover { color: var(--accent); text-decoration: underline; }

/* ---- Wholesale offer card ----------------------------------------------- */
.offer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
  gap: 20px;
  align-items: stretch;
}
.offer-result {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  color: #fff; border-radius: var(--radius); padding: 20px 22px;
  display: flex; flex-direction: column;
}
.offer-amount { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.offer-sub { font-size: 12px; opacity: 0.85; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.offer-math {
  margin-top: 16px; font-size: 12.5px;
  border-top: 1px solid rgba(255,255,255,0.25); padding-top: 14px;
}
.offer-math .mrow { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; }
.offer-math .mrow span:first-child { opacity: 0.9; }
.offer-math .mrow span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.offer-math .mrow.total {
  margin-top: 8px; padding-top: 10px; font-weight: 700; font-size: 15px;
  border-top: 1px solid rgba(255,255,255,0.35);
}
.offer-inputs { display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.offer-inputs .field { margin: 0; }
.suffix-input { display: flex; align-items: center; gap: 7px; }
.suffix-input .prefix, .suffix-input > span { color: var(--text-2); font-size: 14px; }
.suffix-input .input.narrow { max-width: 110px; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1040px) {
  .comps-layout { grid-template-columns: 1fr; }
  .comps-input { position: static; }
  .input.narrow { max-width: 160px; }
  .harvest-layout { grid-template-columns: 1fr; }
  .harvest-progress { position: static; height: auto; }
  .harvest-progress .log { max-height: 300px; flex: none; }
  .offer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(0, 0, 0, 0.3); backdrop-filter: blur(2px);
  }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .topbar { padding: 18px 20px 14px; }
  .content { padding: 20px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .stat-band { grid-template-columns: 1fr 1fr; }
  .toolbar { top: 0; }
}
@media (max-width: 520px) {
  .stat-band { grid-template-columns: 1fr; }
  .topbar .title { font-size: 24px; }
}

/* ── Sidebar account block (added with login support) ───────────────── */
.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--hairline);
}
.sidebar-user + .sidebar-foot { margin-top: 0; border-top: none; }
.su-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-2) 0%, var(--accent) 100%);
}
.su-meta { min-width: 0; line-height: 1.25; }
.su-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.su-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--accent);
  background: var(--accent-soft); padding: 1px 5px; border-radius: 6px;
  vertical-align: middle;
}
.su-logout { font-size: 11px; color: var(--text-3); }
.su-logout:hover { color: var(--accent); }
.mb-16 { margin-bottom: 16px; }
.err-text { color: #b3261e; }

/* ── Harvest per-ZIP breakdown: Pending / Completed boxes + table ─────── */
.harvest-breakdown { margin: 14px 0 6px; }
.hb-boxes { display: flex; gap: 12px; margin-bottom: 12px; }
.hb-box {
  flex: 1; min-width: 0;
  border: 1px solid var(--hairline); border-radius: 12px;
  padding: 12px 14px; background: var(--card-2);
}
.hb-box .hb-n { font-size: 26px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hb-box .hb-k { font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-3); margin-top: 5px; }
.hb-pending .hb-n { color: var(--accent); }
.hb-completed .hb-n { color: var(--green); }
.hb-sub { margin-top: 8px; font-size: 12px; color: var(--text-2); }
.hb-sub .hb-new { color: var(--green); font-weight: 700; }
.hb-sub .hb-existing { color: var(--text); font-weight: 700; }

.hb-table-wrap { max-height: 240px; overflow-y: auto; border: 1px solid var(--hairline);
  border-radius: 10px; }
.hb-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.hb-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--card-2); text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  color: var(--text-3); padding: 8px 12px; border-bottom: 1px solid var(--hairline);
}
.hb-table th.num, .hb-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.hb-table tbody td { padding: 7px 12px; border-bottom: 1px solid var(--hairline); }
.hb-table tbody tr:last-child td { border-bottom: none; }
.hb-table .hb-new-cell { color: var(--green); font-weight: 600; }
.hb-table .hb-existing-cell { color: var(--text-2); }
.hb-row-running { background: var(--accent-soft); }
.hb-row-error { background: rgba(179, 38, 30, 0.08); }
.hb-tag { font-size: 11px; font-weight: 700; }
.hb-tag.ok { color: var(--green); }
.hb-tag.run { color: var(--accent); }
.hb-tag.err { color: #b3261e; }
