/* ============ Design tokens (Generations Energy brand) ============ */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f8ed;
  --surface-3: #eaf0df;
  --border: #dfe7d4;
  --text: #0e2410;
  --text-dim: #516159;
  --text-faint: #82927f;
  --accent: #2a7a38;
  --accent-strong: #1f5c2a;
  --accent-contrast: #ffffff;
  --focus: #2a7a38;

  --status-on_track: #1f8a5c;
  --status-waiting: #b07507;
  --status-blocked: #cc3b3b;
  --status-in_progress: #1f8a5c;
  --status-complete: #6b7280;
  --variation: #7550c9;

  --font-display: "Poppins", system-ui, -apple-system, sans-serif;
  --font-body: "Poppins", system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(14, 36, 16, 0.08);
  --shadow-md: 0 8px 24px rgba(14, 36, 16, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181a;
    --surface: #1d2022;
    --surface-2: #24282a;
    --surface-3: #2c3133;
    --border: #383d40;
    --text: #f1f2ef;
    --text-dim: #a3a9a5;
    --text-faint: #75797a;
    --accent: #74c24e;
    --accent-strong: #8ed967;
    --accent-contrast: #12160f;
    --focus: #74c24e;

    --status-on_track: #2f9461;
    --status-waiting: #d99524;
    --status-blocked: #d65151;
    --status-in_progress: #2f9461;
    --status-complete: #93a89c;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  --bg: #16181a;
  --surface: #1d2022;
  --surface-2: #24282a;
  --surface-3: #2c3133;
  --border: #383d40;
  --text: #f1f2ef;
  --text-dim: #a3a9a5;
  --text-faint: #75797a;
  --accent: #74c24e;
  --accent-strong: #8ed967;
  --accent-contrast: #12160f;
  --focus: #74c24e;

  --status-on_track: #2f9461;
  --status-waiting: #d99524;
  --status-blocked: #d65151;
  --status-in_progress: #2f9461;
  --status-complete: #93a89c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* ============ Reset & base ============ */
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
button { font-family: inherit; }
input, select { font-family: inherit; font-size: 14px; }
a { color: var(--accent); }
::selection { background: var(--accent); color: var(--accent-contrast); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.tabular { font-variant-numeric: tabular-nums; }

/* ============ Buttons & fields ============ */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 9px 18px;
  cursor: pointer;
  transition: filter 0.12s ease, background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(155deg, var(--accent-strong), var(--accent) 65%);
  color: var(--accent-contrast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 4px 12px color-mix(in srgb, var(--accent) 28%, transparent);
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.14), 0 8px 20px color-mix(in srgb, var(--accent) 36%, transparent); }
.btn-primary:active { transform: translateY(0); filter: brightness(0.98); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-faint); }
.btn-variation {
  background: linear-gradient(155deg, color-mix(in srgb, var(--variation) 80%, black), var(--variation) 65%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 4px 12px color-mix(in srgb, var(--variation) 28%, transparent);
}
.btn-variation:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-variation:active { transform: translateY(0); filter: brightness(0.98); }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-danger-text { background: transparent; color: var(--status-blocked); border: none; font-weight: 600; cursor: pointer; padding: 4px 8px; }
.btn-danger-outline { color: var(--status-blocked); border-color: color-mix(in srgb, var(--status-blocked) 45%, transparent); }
.btn-danger-outline:hover { background: color-mix(in srgb, var(--status-blocked) 12%, transparent); color: var(--status-blocked); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field input, .field select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 9px 11px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--focus); outline-offset: -1px; }

.form-error {
  background: color-mix(in srgb, var(--status-blocked) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-blocked) 40%, transparent);
  color: var(--status-blocked);
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px;
}

/* ============ Auth screens ============ */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 45%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 26px; box-shadow: var(--shadow-md);
}
.auth-brand { display: flex; flex-direction: column; gap: 5px; margin-bottom: 22px; }
.auth-mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--surface-2); border-radius: var(--radius-md); font-size: 18px; }
.auth-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.auth-sub { font-size: 12.5px; color: var(--text-dim); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }

#google-signin-wrap { margin-bottom: 18px; }
#google-signin-button { display: flex; justify-content: center; }
.auth-divider {
  display: flex; align-items: center; gap: 10px; margin: 16px 0 2px;
  font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.6px;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Generations Energy wordmark: swap the light/dark PNG variant per theme. */
.brand-logo img { display: block; height: auto; }
.brand-logo .logo-for-dark-bg { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo .logo-for-light-bg { display: none; }
  :root:not([data-theme="light"]) .brand-logo .logo-for-dark-bg { display: block; }
}
:root[data-theme="dark"] .brand-logo .logo-for-light-bg { display: none; }
:root[data-theme="dark"] .brand-logo .logo-for-dark-bg { display: block; }

.brand-logo-auth { height: 26px; margin-bottom: 10px; }
.brand-logo-auth img { height: 100%; width: auto; }
.brand-logo-topbar { height: 24px; margin-top: 4px; flex-shrink: 0; }
.brand-logo-topbar img { height: 100%; width: auto; }

/* ============ Top bar ============ */
.board-chrome { position: sticky; top: 0; z-index: 30; background: var(--bg); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 92%, var(--bg)));
  border-bottom: 2px solid var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.topbar-brand { display: flex; align-items: flex-start; gap: 12px; }
.topbar h1 { font-size: 21px; font-weight: 700; }
.topbar-hint { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.segmented button {
  border: none; background: transparent; color: var(--text-dim); font-weight: 600; font-size: 12.5px;
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
}
.segmented button.active { background: var(--accent); color: var(--accent-contrast); }

.user-menu { position: relative; }
.user-chip {
  width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 14px; cursor: pointer;
}
.user-dropdown {
  position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 10px; min-width: 190px; z-index: 40;
}
.user-dropdown-name { font-weight: 600; font-size: 13.5px; }
.user-dropdown-role { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.user-dropdown button {
  display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text);
  padding: 7px 6px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.user-dropdown button:hover { background: var(--surface-2); }
#logout-btn { color: var(--status-blocked); }

/* ============ Filter & report bars ============ */
.filterbar {
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.status-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); font-size: 12.5px;
  font-weight: 600; cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.pill:hover { border-color: var(--text-faint); transform: translateY(-1px); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-count {
  color: var(--text-faint); font-weight: 700; font-variant-numeric: tabular-nums;
}
.pill.active .pill-count { color: var(--text-dim); }
.pill.active { background: var(--surface-3); color: var(--text); border-color: var(--text-faint); box-shadow: var(--shadow-sm); }
.pill-label {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: none;
  padding: 0; color: inherit; font: inherit; cursor: pointer;
}
.pill-hide-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  padding: 0; border: none; border-radius: 50%; background: none; color: var(--text-faint); cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.pill-hide-btn:hover { background: color-mix(in srgb, currentColor 15%, transparent); color: var(--text); }
.pill.pill-hidden { opacity: 0.5; }
.pill.pill-hidden .pill-label { text-decoration: line-through; }

.filterbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.client-filter {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); font-size: 12.5px; font-weight: 600;
  cursor: pointer; max-width: 200px;
}
.client-filter:focus { outline: 2px solid var(--focus); outline-offset: -1px; }

.search-field {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-faint);
  flex: 0 1 260px;
}
.search-field:focus-within { border-color: var(--focus); color: var(--text-dim); }
.search-field input {
  border: none; background: none; color: var(--text); font-size: 13px; width: 100%; min-width: 0;
}
.search-field input:focus { outline: none; }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }

.reportbar {
  display: flex; align-items: center; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.reports-toggle {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.reports-toggle:hover { border-color: var(--text-faint); transform: translateY(-1px); }

.report-panel { padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.report-summary { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 14px; }
.report-stat { display: flex; flex-direction: column; gap: 2px; }
.report-stat span { font-size: 11.5px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.4px; }
.report-stat strong { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--text); }
.report-stat-pct { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.report-chart-title { font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 8px; }
.report-chart { width: 100%; }
.report-chart-empty { font-size: 12.5px; color: var(--text-faint); padding: 20px 0; }

/* ============ Board ============ */
.board-wrap { padding: 0 0 40px; }
.board-scroll { overflow-x: auto; max-width: 100%; }
.board-grid {
  display: grid;
  grid-template-columns: minmax(230px, 270px) repeat(var(--phase-count, 10), minmax(118px, 1fr));
  min-width: max-content;
}

/* The phase header row lives in its own horizontally-scrollable strip inside
   the already-sticky .board-chrome, with its scroll position mirrored (via JS)
   to .board-scroll — position:sticky can't keep a header pinned to the
   viewport from *inside* a horizontally-scrolling ancestor, since that
   ancestor's own overflow becomes the sticky containing block. */
.phase-header-scroll { overflow-x: hidden; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.grid-header {
  z-index: 20; background: var(--surface-2);
  padding: 10px 12px; font-family: var(--font-mono); text-align: center;
}
.grid-header.corner { position: sticky; left: 0; z-index: 21; text-align: left; font-family: var(--font-body); }
.phase-header-num { font-size: 18px; font-weight: 700; color: var(--text); }
.phase-header-label {
  font-family: var(--font-body); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--text-dim); margin-top: 3px;
}
.grid-header-title { font-family: var(--font-body); font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.6px; }

.row-cell {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.row-cell.zebra { background: var(--surface); }

.project-cell {
  position: sticky; left: 0; z-index: 10;
  background: color-mix(in srgb, var(--row-status-color, transparent) 8%, var(--surface));
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex; flex-direction: column;
  border-left: 4px solid var(--row-status-color, var(--border));
  transition: filter 0.12s ease;
}
.project-top { display: flex; gap: 12px; align-items: flex-start; }
.project-cell:hover { filter: brightness(1.04); }
:root[data-theme="dark"] .project-cell:hover { filter: brightness(1.12); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .project-cell:hover { filter: brightness(1.12); }
}
.project-cell .drag-handle {
  cursor: grab; color: var(--text-faint); font-size: 14px; line-height: 1; padding-top: 2px; user-select: none;
  touch-action: none;
}
.project-cell .drag-handle:active { cursor: grabbing; }

.row-drag-source { opacity: 0.35; }
.row-drag-ghost {
  position: fixed; z-index: 200; pointer-events: none;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  overflow: hidden;
}
.row-drag-ghost .project-cell { position: static !important; }
.row-drag-ghost .row-cell { border-bottom: none; }
body.row-dragging { cursor: grabbing; user-select: none; }

.claim-ring-btn { border: none; background: none; padding: 0; cursor: pointer; flex-shrink: 0; }
.claim-ring { display: block; }
.claim-ring text { font-family: var(--font-mono); }

.project-info { min-width: 0; flex: 1; }
.project-name { font-weight: 700; font-size: 16px; }
/* Read-only views only (share.js) — the main board shows the flag next to
   the edit pencil instead, where it can actually be toggled. */
.project-variation-flag {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--variation);
}
.project-client { font-weight: 700; font-size: 12.5px; color: var(--text); margin-top: 3px; }
.project-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.project-links { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.project-links button { background: none; border: none; padding: 0; font-size: 12px; font-weight: 600; color: var(--accent); cursor: pointer; text-decoration: underline; }
.project-links .project-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 999px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border); padding: 0;
  color: var(--text-faint); cursor: pointer; text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.project-links .project-icon-btn:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent); color: var(--accent); }
.project-links .project-delete-btn:hover { background: color-mix(in srgb, var(--status-blocked) 15%, transparent); border-color: var(--status-blocked); color: var(--status-blocked); }
/* Manual toggle, not hover-only — an active flag stays visibly purple so
   its state reads at a glance without needing to hover. */
.project-links .project-variation-btn:hover { background: color-mix(in srgb, var(--variation) 15%, transparent); border-color: var(--variation); color: var(--variation); }
.project-links .project-variation-btn.active {
  background: color-mix(in srgb, var(--variation) 18%, transparent); border-color: var(--variation); color: var(--variation);
}
.project-detail { margin-top: 10px; font-size: 12.5px; color: var(--text-dim); display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.project-detail dt { color: var(--text-faint); }
.project-detail dd { margin: 0; color: var(--text); }

.phase-cell {
  position: relative; display: flex; align-items: center; justify-content: center; min-height: 92px;
  background: color-mix(in srgb, var(--phase-color, transparent) 8%, var(--surface));
}
.phase-line {
  position: absolute; top: 50%; height: 2px; transform: translateY(-50%);
  background: var(--border);
}
.phase-line-left { left: 0; right: 50%; }
.phase-line-right { left: 50%; right: 0; }
.phase-line.filled { background: var(--phase-color, var(--accent)); }
.phase-dot {
  position: relative; z-index: 2; width: 15px; height: 15px; min-width: 0; border-radius: 50%;
  background: var(--surface); border: 2.5px solid var(--border); padding: 0; cursor: pointer;
}
.phase-dot.filled { background: var(--phase-color, var(--accent)); border-color: var(--phase-color, var(--accent)); }
.phase-dot.current {
  width: 22px; height: 22px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--phase-color, var(--accent)) 28%, transparent);
}
/* Phases 5-9: a solid dot in the status color with the typed-in % as white
   text on top, instead of the plain filled/hollow dot the earlier phases
   use — "done" isn't binary for these longer install stages, and any of
   phases 5-9 can carry its own % independent of which one is "current"
   (see buildPhaseCell). Only shown — and only ever at this larger size —
   while that phase's % is between 1 and 99; 100% drops back to a plain
   dot like any other completed phase. Hover to enter/update the %. */
.phase-dot.phase-dot-progress {
  width: 44px; height: 44px; background: none; border: none; padding: 0; box-shadow: none;
  display: flex; align-items: center; justify-content: center;
}
.phase-dot.phase-dot-progress.filled { background: none; border-color: transparent; }
.phase-dot-progress svg { display: block; }

.status-chip {
  position: absolute; top: calc(50% + 15px); left: 50%; transform: translateX(-50%);
  font-family: var(--font-body); font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  color: #fff; background: var(--phase-color, var(--accent)); border: none; cursor: pointer; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: filter 0.12s ease;
}
.status-chip:hover { filter: brightness(1.08); }

/* A flag planted into the current-phase dot, flagging that this project has
   a variation — always purple, independent of the phase's own status color.
   The dot itself stays in its normal status color; this flag is the only
   thing that goes purple. Positioned so the pole's base sits at the dot's
   own center and the flag reads above it, rather than floating separately. */
.variation-chip {
  position: absolute; bottom: 50%; left: 50%; transform: translateX(-50%);
  pointer-events: none;
}

.status-dropdown {
  position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 6px; min-width: 150px;
}
.status-dropdown button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px;
}
.status-dropdown button:hover { background: var(--surface-2); }
.status-dropdown .dot { width: 8px; height: 8px; border-radius: 50%; }

.claim-popover {
  position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 14px; width: 240px;
}
.claim-popover h4 { font-size: 13px; margin-bottom: 8px; }
.claim-popover .hint { font-size: 11px; color: var(--text-faint); margin-top: 8px; }
.phase-progress-form { display: flex; align-items: center; gap: 6px; }
.phase-progress-form input {
  width: 70px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 5px 6px; font-size: 13px;
}
.phase-progress-form span { color: var(--text-faint); font-size: 13px; }
.phase-progress-form .btn-sm { margin-left: auto; padding: 5px 10px; font-size: 12px; }
.phase-progress-popover .phase-progress-error { margin-top: 8px; padding: 6px 8px; font-size: 11.5px; }

.chart-hover-target { cursor: pointer; }
.chart-tooltip {
  position: fixed; z-index: 80; background: var(--text); color: var(--bg);
  padding: 6px 9px; border-radius: var(--radius-sm); font-size: 11px; line-height: 1.4;
  box-shadow: var(--shadow-md); pointer-events: none; white-space: pre-line; max-width: 220px;
}
.claim-history-list {
  list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--border);
  max-height: 120px; overflow-y: auto;
}
.claim-history-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 0; font-size: 12px; color: var(--text-dim); border-bottom: 1px solid var(--border);
}
.claim-history-list li:last-child { border-bottom: none; }
.claim-history-value { font-family: var(--font-mono); font-weight: 600; color: var(--text); }
.claim-history-right { display: flex; align-items: center; gap: 6px; }
.claim-history-left { display: flex; align-items: center; gap: 7px; }
.claim-history-type-dot { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; background: var(--accent); }
.claim-history-list li.claim-history-variation .claim-history-type-dot { background: var(--variation); }
.claim-history-list li.claim-history-variation .claim-history-value { color: var(--variation); }
.claim-history-list .project-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 999px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border); padding: 0;
  color: var(--text-faint); cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.claim-history-list .project-icon-btn:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent); color: var(--accent); }
.claim-history-list .project-delete-btn:hover { background: color-mix(in srgb, var(--status-blocked) 15%, transparent); border-color: var(--status-blocked); color: var(--status-blocked); }
.claim-add-form { display: flex; gap: 6px; margin-top: 10px; }
.claim-add-form input[type="date"] { flex: 1.3; min-width: 0; }
.claim-add-form input[type="number"] { flex: 0.7; min-width: 0; }
.claim-add-form input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 5px 6px; font-size: 12px;
}
.claim-add-form .btn-sm { padding: 5px 10px; font-size: 12px; }
.claim-popover .claim-form-error { margin-top: 8px; padding: 6px 8px; font-size: 11.5px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state p { margin-bottom: 14px; font-size: 15px; }

/* ============ Modals ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 8, 2, 0.55); display: grid; place-items: center;
  padding: 20px; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 620px;
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow-md); border: 1px solid var(--border);
}
.modal-narrow { max-width: 380px; }
.modal-wide { max-width: 760px; }
.team-table-wrap { overflow-x: auto; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; padding: 18px 22px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-head h2 { font-size: 19px; }
.modal-close { background: none; border: none; font-size: 22px; line-height: 1; color: var(--text-dim); cursor: pointer; }
.modal-body { padding: 20px 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.claim-tracking {
  margin-top: 18px; padding: 14px 16px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.claim-tracking-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.claim-tracking-head h3 { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.claim-tracking-current { font-size: 13px; color: var(--text-dim); text-align: right; display: flex; flex-direction: column; gap: 2px; }
.claim-tracking-current strong { color: var(--text); }
.claim-tracking-current-sub { font-size: 12px; color: var(--variation); }
.claim-tracking-current-sub strong { color: var(--variation); }
#claim-tracking-chart { margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; }
.claim-tracking .claim-history-list { margin-top: 10px; max-height: 150px; }
.claim-history-empty { padding: 5px 0; font-size: 12px; color: var(--text-faint); }
.claim-history-more { padding: 5px 0; font-size: 11px; color: var(--text-faint); font-style: italic; }
.claim-log-row { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.claim-log-row .field { flex: 1 1 140px; }
.claim-log-row .btn { flex: 0 0 auto; }
.claim-tracking .form-error { margin-top: 10px; }

.share-hint { font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px; line-height: 1.5; }
.share-current-summary {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-dim);
}
.share-current-summary strong { color: var(--text); }
.share-new-link { display: flex; gap: 8px; margin-top: 10px; }
.share-new-link input {
  flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 8px 10px; font-size: 12.5px; font-family: var(--font-mono);
}
.share-links-title {
  font-size: 12px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.4px;
  margin: 20px 0 8px;
}
.share-links-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.share-link-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.share-link-row-main { min-width: 0; }
.share-link-row-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.share-link-row-meta { font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.share-link-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.share-links-empty { font-size: 12px; color: var(--text-faint); padding: 6px 0; }

.team-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.team-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-faint); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.team-table td { padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.team-table select { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: 4px 6px; font-size: 12.5px; }
.team-email-input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 4px 6px; font-size: 12.5px; width: 170px;
}
.team-email-input:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.badge-inactive { color: var(--status-blocked); font-size: 11px; font-weight: 600; }
.badge-active { color: var(--status-on_track); font-size: 11px; font-weight: 600; }

.add-user-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-user-form input, .add-user-form select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 8px 10px; font-size: 13px;
}
.add-user-form input[name="name"] { flex: 1 1 140px; }
.add-user-form input[name="username"] { flex: 1 1 120px; }

.team-reveal {
  background: color-mix(in srgb, var(--status-on_track) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-on_track) 35%, transparent);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; font-size: 13px;
}
.team-reveal strong { font-family: var(--font-mono); font-size: 14px; }

.catalog-import {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px;
}
.catalog-import-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.catalog-file-btn { cursor: pointer; }
.catalog-import-row input[type="text"] {
  flex: 1 1 260px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 12.5px; color: var(--text);
}
.catalog-file-name { font-size: 12.5px; color: var(--text-dim); }
.catalog-import-result {
  background: color-mix(in srgb, var(--status-on_track) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-on_track) 35%, transparent);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md); z-index: 200;
}

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; }
}
