/* FfD — styles */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --card: #0f3460;
  --accent: #e94560;
  --text: #eee;
  --text-muted: #999;
  --success: #4ecca3;
  --warning: #f0a500;
  --danger: #e94560;
  --font: 'Segoe UI', system-ui, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', monospace;

  /* Category colours */
  --cat-admin: #3498db;
  --cat-research: #9b59b6;
  --cat-building: #2ecc71;
  --cat-marketing: #e67e22;
  --cat-finance: #f1c40f;
  --cat-hiring: #1abc9c;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-width: 1024px;
  overflow-x: auto;
}

.hidden { display: none !important; }

/* ── Top bar ─────────────────────────────────── */
#top-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Push the balance + menu cluster to the right; clock, speed and project
   buttons stay left-aligned with consistent gaps. */
#balance-display { margin-left: auto; }

#clock-display {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
  min-width: 220px;
}

/* ── Speed controls ──────────────────────────── */
#speed-controls {
  display: flex;
  gap: 0.25rem;
}

#speed-controls button {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

#speed-controls button:hover { background: var(--accent); color: var(--text); }
#speed-controls button.active { background: var(--accent); color: #fff; }

/* ── Balance display ─────────────────────────── */
#balance-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.account-badge {
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: background 0.15s;
}

.account-badge:hover { background: rgba(255, 255, 255, 0.06); }

.account-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-right: 0.3rem;
}

.account-amount { font-weight: 700; }
.account-amount.overdrawn { color: var(--danger); animation: pulse-danger 1.5s ease-in-out infinite; }

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Modal overlays (txn / projects / upcoming) ─ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 450;
}

.overlay-panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  max-width: 90%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#txn-panel      { width: 600px; }
#projects-panel { width: 550px; }
#upcoming-panel { width: 480px; }

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.overlay-header h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
}

.overlay-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
}

.overlay-close:hover { color: var(--text); }

.overlay-list {
  overflow-y: auto;
  padding: 0.75rem 1.25rem;
  flex: 1;
}
#upcoming-list { padding-bottom: 1rem; }

.txn-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.txn-date {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.txn-desc { color: var(--text); }
.txn-payee { color: var(--text-muted); font-size: 0.8rem; }
.txn-amount { text-align: right; font-family: var(--mono); white-space: nowrap; }
.txn-amount.debit { color: var(--danger); }
.txn-amount.credit { color: var(--success); }

/* ── Kanban board ────────────────────────────── */
#board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1rem 1.5rem;
  min-height: calc(100vh - 52px);
  align-content: start;
}

.column {
  background: var(--surface);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.column h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 40px;
}

/* ── Task cards ──────────────────────────────── */
.task-card {
  background: var(--card);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  border-left: 3px solid var(--text-muted);
  cursor: grab;
  transition: opacity 0.2s, box-shadow 0.2s;
}

.task-card:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }

/* Category colour-coding */
.task-card[data-category="admin"]     { border-left-color: var(--cat-admin); }
.task-card[data-category="research"]  { border-left-color: var(--cat-research); }
.task-card[data-category="building"]  { border-left-color: var(--cat-building); }
.task-card[data-category="marketing"] { border-left-color: var(--cat-marketing); }
.task-card[data-category="finance"]   { border-left-color: var(--cat-finance); }
.task-card[data-category="hiring"]    { border-left-color: var(--cat-hiring); }

/* Active card in Doing column — subtle glow */
.column:nth-child(3) .task-card:not(.blocked) {
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.25);
}

/* Done column — completed cards fade over time */
.column:nth-child(4) .task-card {
  opacity: 0.55;
  transition: opacity 0.2s;
}
.column:nth-child(4) .task-card:first-child {
  opacity: 1;
}
.column:nth-child(4) .task-card:nth-child(2) {
  opacity: 0.75;
}
.column:nth-child(4) .task-card:hover {
  opacity: 1;
}

#done-list .task-card {
  cursor: default;
}

/* Blocked card dimming */
.task-card.blocked {
  opacity: 0.45;
  cursor: not-allowed;
  border-left-style: dashed;
}

/* Paused (non-head) cards in the Doing column — sit beneath the active
   head, get a softer presentation, and lose the active-card glow. */
.task-card.card-paused {
  opacity: 0.6;
}
.column:nth-child(3) .task-card.card-paused {
  box-shadow: none;
}

.card-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: -0.15rem 0 0.3rem 0;
  line-height: 1.3;
}

.card-hours,
.card-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.card-result {
  font-size: 0.75rem;
  color: var(--success);
  margin-top: 0.25rem;
}

.card-unlocked {
  font-size: 0.7rem;
  color: var(--warning);
  margin-top: 0.3rem;
  font-style: italic;
}

/* ── Progress bar ────────────────────────────── */
.card-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin: 0.35rem 0;
  overflow: hidden;
}

.card-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.card-stop {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  cursor: pointer;
  margin-top: 0.3rem;
}

.card-stop:hover { opacity: 0.8; }

/* ── Drag-and-drop states ────────────────────── */
.drag-ghost {
  opacity: 0.4;
}

.drag-chosen {
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.3);
}

/* ── Modal ───────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

#modal {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 1.5rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#modal-body {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

#modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

#modal-actions button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: opacity 0.15s;
}

#modal-actions button:hover { opacity: 0.85; }

/* Win/lose game-over scorecard: label left, value right, no bullets. */
.game-over-stats {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.game-over-stats li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3rem 0;
}
.game-over-stat-label { color: var(--text-dim, rgba(255, 255, 255, 0.6)); }
.game-over-stat-value { font-weight: 600; }

/* ── Insight picker cards (in modal body) ────── */
.insight-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  max-height: 50vh;
  overflow-y: auto;
}

.insight-card {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: background 0.12s, border-color 0.12s;
}

.insight-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

.insight-card h4 { margin: 0 0 0.25rem; font-size: 1rem; }
.insight-card p  { margin: 0; opacity: 0.8; font-size: 0.9rem; }

.copy-target-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  max-height: 50vh;
  overflow-y: auto;
}

.copy-target-card {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: background 0.12s, border-color 0.12s;
}

.copy-target-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

.copy-target-card h4 { margin: 0 0 0.25rem; font-size: 1rem; }
.copy-target-card p  { margin: 0; opacity: 0.8; font-size: 0.9rem; }

.pricing-policy-preview {
  margin-top: 0.4rem !important;
  opacity: 1 !important;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* ── Toast notifications ─────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--card);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  border-left: 3px solid var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: translateX(120%);
  transition: transform 0.3s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast.show { transform: translateX(0); }

.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-danger  { border-left-color: var(--danger); }
.toast-info, .toast-event, .toast-completion { border-left-color: var(--accent); }

.toast-expandable { cursor: pointer; }
.toast-expandable .toast-message::after {
  content: " — click to read";
  opacity: 0.6;
  font-size: 0.85em;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}

.toast-close:hover { color: var(--text); }

/* ── Onboarding tooltip ─────────────────────── */
.onboarding-tooltip {
  position: absolute;
  top: -0.5rem;
  left: 50%;
  transform: translate(-50%, -100%);
  background: var(--accent);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 200;
  animation: tooltip-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

.onboarding-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--accent);
}

@keyframes tooltip-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
/* ── Projects overlay ───────────────────────── */
.segments-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.segment-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.segment-entry:last-child { border-bottom: none; }

.segment-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.segment-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.segment-tam {
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

.segment-tam-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

.segment-insights {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.segment-insight {
  font-size: 0.8rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--cat-research);
}

.segment-insight strong {
  display: block;
  color: var(--text);
  font-size: 0.8rem;
}

.segment-insight span {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ── Upcoming expenses ─────────────────────── */
.upcoming-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-left: 0.5rem;
}
.upcoming-toggle:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.upcoming-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.upcoming-group-heading {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0.7rem 0 0.3rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.upcoming-group-heading:first-child { margin-top: 0; }

.upcoming-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.35rem 0;
  font-size: 0.85rem;
}

.upcoming-label { color: var(--text); }
.upcoming-kind {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.upcoming-amount {
  font-family: var(--mono);
  color: var(--danger);
  white-space: nowrap;
}

.card-result-pending { color: var(--text-muted); font-style: italic; }

/* ── Projects panel tiles ───────────────────── */
.project-tile {
  border: 1px solid var(--border, #444);
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  background: var(--surface, #1a1a1a);
}
.project-tile-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}
.project-tile-header .project-name { font-weight: bold; font-size: 1.1em; }
.project-tile-header .project-status {
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #999);
}
.project-tile-active .project-status { color: var(--accent, #4a9eff); }
.project-tile-complete .project-status { color: var(--success, #4caf50); }
.project-summary p { margin: 0 0 0.25rem 0; }
.project-inflight {
  margin: 0.75rem 0;
  padding: 0.5rem;
  background: var(--bg-subtle, rgba(255,255,255,0.04));
  border-left: 3px solid var(--accent, #4a9eff);
}
.project-inflight h4 { margin: 0 0 0.25rem 0; font-size: 0.9em; }
.project-inflight ul { margin: 0; padding-left: 1rem; }
.project-inflight-eta { color: var(--text-muted, #999); font-style: italic; }
.project-body { margin-top: 0.75rem; }
.project-section { margin-top: 0.75rem; }
.project-section h4 { margin: 0.5rem 0 0.25rem 0; }
.project-section-caption { margin: 0.5rem 0 0.25rem 0; font-size: 0.9em; color: var(--text-muted, #999); }
.project-empty-caption { margin: 0.25rem 0; font-size: 0.85em; font-style: italic; color: var(--text-muted, #999); }
.project-list { margin: 0.25rem 0; padding-left: 1.25rem; }
.project-list li { margin: 0.15rem 0; }

.finance-mrr { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0.5rem; }
.finance-mrr span { font-size: 1.2em; font-weight: 600; }

.project-buttons { display: inline-flex; gap: 0.5em; }
.project-btn { padding: 0.4em 0.8em; }

/* === Marketing project — channel rating chips === */
.channel-rating { display: inline-block; padding: 0.1em 0.6em; border-radius: 0.4em; font-size: 0.85em; }
.channel-rating-fresh    { background: rgba(78, 204, 163, 0.2); color: var(--success); }
.channel-rating-stale    { background: rgba(240, 165, 0, 0.2);  color: var(--warning); }
.channel-rating-outdated { background: rgba(233, 69, 96, 0.2);  color: var(--danger); }
.channel-row { display: flex; flex-direction: column; gap: 0.2em; }
.channel-meta { color: var(--text-muted); font-size: 0.85em; }

/* === Funnel sparkline === */
.funnel-sparkline { font-family: monospace; font-size: 1.2em; margin: 0.4em 0; }

/* === Funnel new-vs-returning rows === */
.funnel-newret { display: flex; flex-direction: column; gap: 0.3em; }
.newret-row { display: grid; grid-template-columns: 1fr auto auto; gap: 1em; }
.newret-pct { color: var(--text-muted); }

/* === Tier 2 stage bars === */
.funnel-stage { margin: 0.6em 0; }
.funnel-stage-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.funnel-stage-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 0.2em 0; background: rgba(255, 255, 255, 0.06); }
.funnel-stage-bar > span { display: block; }
/* Channel-specific brand-style hues kept as deliberate distinct palette */
.ch-ads      { background: #5b8def; }
.ch-blog     { background: #6fbf73; }
.ch-social   { background: #c87cd1; }
.ch-organic  { background: #f0a04b; }
.ch-referral { background: #e6c84a; }
.funnel-stage-legend { font-size: 0.85em; display: flex; flex-wrap: wrap; gap: 0.6em; }
.ch-legend.ch-ads      { color: #5b8def; background: transparent; }
.ch-legend.ch-blog     { color: #6fbf73; background: transparent; }
.ch-legend.ch-social   { color: #c87cd1; background: transparent; }
.ch-legend.ch-organic  { color: #f0a04b; background: transparent; }
.ch-legend.ch-referral { color: #e6c84a; background: transparent; }

/* === Broadcast channel colors (HN/Reddit/Press) === */
.ch-hn      { background: #ff6600; }
.ch-reddit  { background: #ff4500; }
.ch-press   { background: #9d6dd9; }
.ch-legend.ch-hn      { color: #ff6600; background: transparent; }
.ch-legend.ch-reddit  { color: #ff4500; background: transparent; }
.ch-legend.ch-press   { color: #9d6dd9; background: transparent; }
.funnel-arrow { color: var(--text-muted); font-size: 0.9em; padding: 0.1em 0 0.1em 1em; }
.funnel-divider { border: 0; border-top: 1px solid rgba(255, 255, 255, 0.1); margin: 0.6em 0; }

/* === Delta badges === */
.delta { font-size: 0.85em; padding: 0 0.4em; border-radius: 0.3em; }
.delta.pos { color: var(--success); }
.delta.neg { color: var(--danger); }

/* === Burger menu (top-right) === */
.menu-container { position: relative; }

.menu-toggle {
  padding: 0.3em 0.6em;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.3em;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.menu-toggle:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  display: flex;
  flex-direction: column;
  min-width: 190px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.4em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  z-index: 200;
}
.menu-dropdown.hidden { display: none; }

.menu-item {
  padding: 0.6em 0.9em;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.06); }

.menu-item-danger { color: var(--text-muted); }
.menu-item-danger:hover { background: rgba(233, 69, 96, 0.15); color: var(--danger); }
