:root {
  --outcome-open: #6b7280;
  --outcome-won: #059669;
  --outcome-lost: #dc2626;
  --outcome-non_revenue: #9ca3af;
  --bg: #fafafa;
  --card: #fff;
  --border: #e5e7eb;
  --text: #111;
  --text-muted: #6b7280;
  --bar: #3b82f6;
  --bar-muted: #93c5fd;
}
* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  margin: 0;
  padding: 1rem 1.5rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
h1 { margin: 0; font-size: 1.25rem; font-weight: 600; }
nav a { font-size: 0.875rem; color: var(--text-muted); text-decoration: none; }
nav a:hover { text-decoration: underline; }
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.filters label { font-size: 0.875rem; color: var(--text-muted); }
.filters select {
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
}
tr.detail-row.hidden { display: none; }
main { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover { color: var(--text); }
th.sort-asc::after { content: ' \2191'; font-size: 0.7em; }
th.sort-desc::after { content: ' \2193'; font-size: 0.7em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
tr.expanded td { background: #f0f9ff; }
tr[data-outcome="open"] .pill-outcome { background: var(--outcome-open); color: #fff; }
tr[data-outcome="won"] .pill-outcome { background: var(--outcome-won); color: #fff; }
tr[data-outcome="lost"] .pill-outcome { background: var(--outcome-lost); color: #fff; }
tr[data-outcome="non_revenue"] .pill-outcome { background: var(--outcome-non_revenue); color: #fff; }
.pill-outcome, .pill-stage {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  font-weight: 500;
}
.pill-stage { background: var(--border); color: var(--text); }
.detail-row td {
  padding: 0.75rem 1rem 1rem;
  vertical-align: top;
  border-top: none;
  background: #f8fafc;
}
.detail-row td { border-bottom: 1px solid var(--border); }
.detail-content { font-size: 0.875rem; }
.detail-content section { margin-bottom: 0.75rem; }
.detail-content section:last-child { margin-bottom: 0; }
.detail-content strong { color: var(--text-muted); font-weight: 600; }
.detail-content ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.touches-section .touch-type-btns { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.35rem 0 0.5rem 0; }
.touches-section .touch-type-btn {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
}
.touches-section .touch-type-btn:hover { background: var(--bg); }
.touches-section .touch-type-btn.saving { opacity: 0.7; pointer-events: none; }
.touches-section .touch-feedback { color: var(--outcome-won); font-size: 0.875rem; margin-top: 0.35rem; font-weight: 500; }
.touches-section .touch-error { color: var(--outcome-lost); font-size: 0.875rem; margin-top: 0.35rem; }
.milestones-section .funnel-event-btns { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.35rem 0 0.5rem 0; }
.milestones-section .funnel-event-btn {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
}
.milestones-section .funnel-event-btn:hover { background: var(--bg); }
.milestones-section .funnel-event-btn.saving { opacity: 0.7; pointer-events: none; }
.milestones-section .milestone-feedback { color: var(--outcome-won); font-size: 0.875rem; margin-top: 0.35rem; font-weight: 500; }
.milestones-section .milestone-error { color: var(--outcome-lost); font-size: 0.875rem; margin-top: 0.35rem; }
.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--card);
  border-radius: 8px;
}
.cursor-pointer { cursor: pointer; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* Funnel page */
.funnel-viz { max-width: 100%; width: 56rem; margin-bottom: 2.5rem; }
.funnel-stage { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 0.625rem; }
.funnel-bar-wrap { flex: 1; min-width: 20rem; display: flex; justify-content: flex-end; }
.funnel-bar { height: 2.5rem; min-width: 0; background: var(--bar); border-radius: 6px; transition: width 0.2s ease; }
.funnel-bar.zero { background: var(--bar-muted); min-width: 2px; }
.funnel-stage-label { width: 12rem; flex-shrink: 0; font-size: 0.9375rem; font-weight: 500; }
.funnel-stage-meta { width: 11rem; flex-shrink: 0; font-size: 0.8125rem; color: var(--text-muted); text-align: right; }
.funnel-stage-meta .num { font-variant-numeric: tabular-nums; }
.stage-table { width: 100%; max-width: 56rem; border-collapse: collapse; font-size: 0.875rem; }
.stage-table th, .stage-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.stage-table th { font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stage-table td:nth-child(2), .stage-table td:nth-child(3), .stage-table td:nth-child(4) { text-align: right; }
.stage-table .num { font-variant-numeric: tabular-nums; }

/* Weekly Numbers page */
.weekly-numbers-wrap { overflow-x: auto; }
.weekly-numbers-table .metric-col { min-width: 12rem; font-weight: 500; }
.weekly-numbers-table .week-col { min-width: 5rem; text-align: right; font-variant-numeric: tabular-nums; }
.weekly-numbers-table .editable-cell:hover { background: #f0f9ff; }
.add-week-btn, .add-week-submit, .add-week-cancel {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
}
.add-week-btn:hover, .add-week-submit:hover { background: var(--bg); }
.add-week-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-left: 0.5rem; }
.add-week-form.hidden { display: none; }
.add-week-form input[type="date"] {
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.add-week-feedback { font-size: 0.875rem; }
.hidden { display: none !important; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none !important; }
.modal-content {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 20rem;
}
.modal-content h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.modal-content .modal-metric, .modal-content .modal-week {
  margin: 0 0 0.5rem; font-size: 0.875rem; color: var(--text-muted);
}
.modal-content label { display: block; font-size: 0.875rem; margin-bottom: 0.25rem; }
.modal-content input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1rem;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.modal-save, .modal-clear, .modal-close {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
}
.modal-save:hover, .modal-clear:hover, .modal-close:hover { background: var(--bg); }
.modal-feedback { color: var(--outcome-won); font-size: 0.875rem; margin-top: 0.5rem; font-weight: 500; }
.modal-error { color: var(--outcome-lost); font-size: 0.875rem; margin-top: 0.5rem; }
.modal-compute-wrap { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.modal-compute-toggle {
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
}
.modal-compute-toggle:hover { background: var(--bg); }
.modal-compute-panel { margin-top: 0.75rem; }
.modal-compute-panel label { display: block; font-size: 0.875rem; margin-bottom: 0.25rem; color: var(--text-muted); }
.modal-compute-panel textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  font-family: inherit;
  resize: vertical;
}
.modal-compute-apply {
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
}
.modal-compute-apply:hover { background: var(--bg); }
.modal-compute-hint { display: block; font-size: 0.8125rem; margin-top: 0.35rem; }

/* Parse deal modal (Cmd+K) */
.parse-deal-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.parse-deal-modal.hidden { display: none !important; }
.parse-deal-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.parse-deal-dialog {
  position: relative;
  background: var(--card);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 28rem;
  max-width: 90vw;
}
.parse-deal-dialog h2 { margin: 0 0 0.5rem; font-size: 1.125rem; }
.parse-deal-hint { margin: 0 0 0.75rem; font-size: 0.8125rem; color: var(--text-muted); }
.parse-deal-hint kbd {
  padding: 0.1rem 0.35rem;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
}
.parse-deal-dialog textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1rem;
  font-family: inherit;
  resize: vertical;
}
.parse-deal-actions { display: flex; gap: 0.5rem; }
.parse-deal-cancel, .parse-deal-submit {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
}
.parse-deal-cancel:hover, .parse-deal-submit:hover { background: var(--bg); }
.parse-deal-submit { background: #2563eb; color: #fff; border-color: #2563eb; }
.parse-deal-submit:hover { background: #1d4ed8; }
.parse-deal-submit.saving { opacity: 0.7; pointer-events: none; }
.parse-deal-feedback { margin-top: 0.75rem; font-size: 0.875rem; }
.parse-deal-feedback.hidden { display: none !important; }
.parse-deal-feedback.error { color: var(--outcome-lost); }
.parse-deal-feedback.success { color: var(--outcome-won); }
