/* ─────────────────────────────────────────────────────────────────
   Mission Control — Stylesheet
   Extends dashboard-builder design system
   Accent: indigo (not Upwork green)
───────────────────────────────────────────────────────────────── */

:root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f5;
  --border: #e5e5e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-dim: #52525b;
  --text-muted: #a1a1aa;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-bg: rgba(79, 70, 229, 0.08);
  --accent-contrast: #ffffff;
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.08);
  --blue: #2563eb;
  --orange: #ea580c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface-2: #17171f;
  --border: #1f1f2a;
  --border-strong: #2a2a36;
  --text: #f5f5f7;
  --text-dim: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-bg: rgba(99, 102, 241, 0.15);
  --accent-contrast: #ffffff;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --blue: #3b82f6;
  --orange: #f97316;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; min-width: 0; }

html, body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
  font-size: 13px;
  line-height: 1.5;
}

.mono, .num {
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 2000px; } }

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.logo-icon {
  width: 24px; height: 24px;
  background: var(--text);
  border-radius: 6px;
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.topbar-date {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Geist Mono', monospace;
  flex-shrink: 0;
}
.spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:hover { background: var(--surface); border-color: var(--border-strong); }
.btn.loading svg { animation: spin 1s linear infinite; }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { opacity: 0.85; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 4px 8px; font-size: 11px; border-radius: 5px; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); background: var(--surface); border-color: var(--border-strong); }

:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="dark"]  .icon-moon { display: none; }

/* ── Layout ──────────────────────────────────────────────────────── */
.content { padding: 24px 20px 80px; max-width: 1280px; margin: 0 auto; }

/* ── Loading + Error ─────────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  height: 300px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.error-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  background: var(--danger-bg);
  border-bottom: 1px solid var(--danger);
  font-size: 12px;
  color: var(--danger);
}
.error-retry {
  margin-left: auto;
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--danger);
  border-radius: 4px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

/* ── Hero block ──────────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.hero-cell {
  background: var(--bg);
  padding: 18px 20px;
}
.hero-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}
.hero-one-thing {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.hero-one-thing a { color: var(--accent); }
.hero-pulse {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hero-pulse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.hero-pulse-label { font-size: 12px; color: var(--text-dim); }
.hero-pulse-val {
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  font-feature-settings: "tnum";
}
.hero-pulse-val.danger { color: var(--danger); }
.hero-pulse-val.warning { color: var(--warning); }
.hero-pulse-val.ok { color: var(--success); }
.hero-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hero-stat-row { display: flex; align-items: center; gap: 8px; }
.hero-stat-num {
  font-family: 'Geist Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  font-feature-settings: "tnum";
}
.hero-stat-label { font-size: 11px; color: var(--text-muted); }

/* ── Section grid ────────────────────────────────────────────────── */
.sections-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Section card ────────────────────────────────────────────────── */
.section-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  transition: border-color 0.15s;
}
.section-card.done { opacity: 0.55; }
.section-card.done .section-header { background: var(--surface); }

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.section-header:hover { background: var(--surface); }

.section-emoji { font-size: 16px; flex-shrink: 0; }
.section-name { font-size: 13px; font-weight: 600; flex: 1; }
.section-progress {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  font-feature-settings: "tnum";
  flex-shrink: 0;
}
.section-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.section-badge.critical { background: var(--danger-bg); color: var(--danger); }
.section-badge.has-items { background: var(--accent-bg); color: var(--accent); }
.section-badge.done { background: var(--success-bg); color: var(--success); }
.section-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.section-card.open .section-chevron { transform: rotate(90deg); }

.section-body {
  display: none;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.15s ease;
}
.section-card.open .section-body { display: block; }

/* ── Item list ───────────────────────────────────────────────────── */
.item-list { padding: 0; }
.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--surface); }
.item-row.state-closed { opacity: 0.4; }
.item-row.state-acted .item-title { color: var(--success); }

.item-priority {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.priority-critical { background: var(--danger); }
.priority-high     { background: var(--warning); }
.priority-normal   { background: var(--border-strong); }

.item-text { flex: 1; min-width: 0; }
.item-title {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  font-family: 'Geist Mono', monospace;
  font-feature-settings: "tnum";
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s;
}
.item-row:hover .item-actions { opacity: 1; }
.item-row.state-closed .item-actions { opacity: 0; pointer-events: none; }

.item-check {
  width: 22px; height: 22px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.item-check:hover { border-color: var(--accent); background: var(--accent-bg); }
.item-row.state-seen .item-check,
.item-row.state-acted .item-check {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.item-check svg { display: none; color: var(--accent); }
.item-row.state-seen .item-check svg,
.item-row.state-acted .item-check svg { display: block; }

.action-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}
.action-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
.action-btn.draft-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.action-btn.close-btn:hover { color: var(--success); border-color: var(--success); background: var(--success-bg); }

/* ── Section footer ──────────────────────────────────────────────── */
.section-footer {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.section-footer-info {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Geist Mono', monospace;
  flex: 1;
}
.section-placeholder {
  padding: 20px 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.section-placeholder a { color: var(--accent); text-decoration: underline; }

/* ── Draft modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s;
  padding: 20px;
}
.modal {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.2s;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: 5px;
  transition: all 0.1s;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 16px 20px; flex: 1; overflow-y: auto; }
.modal-context {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
  line-height: 1.5;
}
.modal-draft-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}
.modal-draft-area {
  width: 100%;
  min-height: 160px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.modal-draft-area:focus { border-color: var(--accent); }
.modal-generating {
  display: flex; align-items: center; gap: 8px;
  padding: 20px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Progress bar (section completion) ──────────────────────────── */
.progress-bar {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.3s ease;
}
.progress-fill.done { background: var(--success); }

/* ── SSE live indicator ──────────────────────────────────────────── */
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.live-dot.disconnected { background: var(--text-muted); }

/* ── Day summary footer ──────────────────────────────────────────── */
.day-footer {
  margin-top: 32px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.day-footer-links { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.day-footer-links a { color: var(--accent); cursor: pointer; }
.day-footer-links a:hover { text-decoration: underline; }

/* ── Badge ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-new      { background: var(--accent-bg); color: var(--accent); }
.badge-overdue  { background: var(--danger-bg); color: var(--danger); }
.badge-done     { background: var(--success-bg); color: var(--success); }
.badge-disabled { background: var(--surface-2); color: var(--text-muted); }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 64px; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .item-actions { opacity: 1; }
}
