/* ============================================================================
   Components — cards, buttons, inputs, badges, toasts, panel, modal, skeletons
   ============================================================================ */

/* ---------------------------------------------------------------------------
   Card
--------------------------------------------------------------------------- */
.card {
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  box-shadow: var(--shadow-card);
  transition: border-color var(--dur-card-hover) var(--ease-out);
}
.card.is-interactive { cursor: pointer; }
.card.is-interactive:hover { border-color: var(--border-strong); }

.card__title {
  font-family: var(--font-sans);
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  font-weight: var(--fw-strong);
  color: var(--text-primary);
}
.card__meta {
  font-size: var(--fs-small);
  line-height: var(--lh-small);
  color: var(--text-tertiary);
}

/* ---------------------------------------------------------------------------
   Button
--------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out), border-color 140ms var(--ease-out);
  min-height: 40px;
}
.btn[disabled], .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; flex-shrink: 0; }

.btn--primary {
  background: var(--accent);
  color: #FFFFFF;
}
.btn--primary:hover { background: var(--accent-hover); }

.btn--secondary {
  background: transparent;
  border: var(--border-width) solid var(--border);
  color: var(--text-primary);
}
.btn--secondary:hover { border-color: var(--border-strong); background: var(--bg-tertiary); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn--ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn--destructive {
  background: transparent;
  border: var(--border-width) solid var(--danger);
  color: var(--danger);
}
.btn--destructive:hover { background: var(--danger); color: #FFFFFF; }

.btn--icon {
  padding: 0;
  width: 36px;
  height: 36px;
  min-height: 36px;
}

/* Compact icon button used in the topbar (theme toggle etc.) */
.btn--icon.btn--secondary { background: var(--bg-secondary); }
.btn--icon.btn--secondary:hover { background: var(--bg-tertiary); }

/* Mobile touch targets ≥ 44px */
@media (max-width: 768px) {
  .btn { min-height: 44px; }
  .btn--icon { width: 44px; height: 44px; min-height: 44px; }
}

/* ---------------------------------------------------------------------------
   Form input
--------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field__label {
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}
.input,
.textarea,
.select {
  width: 100%;
  padding: 12px var(--space-3);
  background: var(--bg-tertiary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-body);
  color: var(--text-primary);
  transition: border-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}
html[data-theme="light"] .input,
html[data-theme="light"] .textarea,
html[data-theme="light"] .select {
  background: var(--bg-secondary);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-tertiary); }
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.textarea { min-height: 96px; resize: vertical; line-height: var(--lh-body); }

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23A0A0A0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-7);
}

/* ---------------------------------------------------------------------------
   Tier badge
--------------------------------------------------------------------------- */
.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: var(--fw-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 16px;
}
.tier-badge--A { background: var(--accent); color: #FFFFFF; }
.tier-badge--B { background: var(--accent-glow); color: var(--accent); border: 1px solid var(--accent-glow); }
html[data-theme="light"] .tier-badge--B { background: rgba(31, 75, 82, 0.12); color: var(--accent); }
.tier-badge--C { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ---------------------------------------------------------------------------
   Stage badge
--------------------------------------------------------------------------- */
.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: var(--fw-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 14px;
  white-space: nowrap;
}
.stage-badge--researched         { background: var(--bg-tertiary); color: var(--text-secondary); }
.stage-badge--mockup_created     { background: rgba(99, 102, 241, 0.12); color: var(--info); }
.stage-badge--outreach_sent      { background: rgba(31, 75, 82, 0.18); color: var(--accent); }
.stage-badge--replied_interested { background: rgba(31, 75, 82, 0.32); color: #FFFFFF; }
.stage-badge--call_booked        { background: rgba(245, 158, 11, 0.16); color: var(--warning); }
.stage-badge--proposal_sent      { background: rgba(245, 158, 11, 0.28); color: var(--warning); }
.stage-badge--won                { background: rgba(16, 185, 129, 0.16); color: var(--success); }
.stage-badge--in_build           { background: rgba(16, 185, 129, 0.28); color: var(--success); }
.stage-badge--live_hosting       { background: var(--success); color: #00231A; } /* goal state — strongest */
.stage-badge--lost               { background: rgba(239, 68, 68, 0.14); color: var(--danger); }
.stage-badge--churned            { background: rgba(239, 68, 68, 0.20); color: var(--danger); }

html[data-theme="light"] .stage-badge--replied_interested { color: #FFFFFF; }
html[data-theme="light"] .stage-badge--live_hosting { color: #FFFFFF; }

/* ---------------------------------------------------------------------------
   Toast
--------------------------------------------------------------------------- */
.toast-host {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-panel);
  min-width: 240px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.toast--success { border-left: 3px solid var(--success); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--danger  { border-left: 3px solid var(--danger); }
.toast--info    { border-left: 3px solid var(--info); }

/* ---------------------------------------------------------------------------
   Modal / detail panel
--------------------------------------------------------------------------- */
.backdrop {
  position: fixed; inset: 0;
  background: var(--backdrop);
  z-index: var(--z-backdrop);
  opacity: 0;
  pointer-events: none;
}
.backdrop.is-open { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  height: 100dvh;
  width: var(--panel-width);
  max-width: 100vw;
  background: var(--bg-secondary);
  border-left: var(--border-width) solid var(--border);
  box-shadow: var(--shadow-panel);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
}
.panel.is-open { transform: translateX(0); }
.panel__header {
  padding: var(--space-5);
  border-bottom: var(--border-width) solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.panel__footer {
  padding: var(--space-4) var(--space-5);
  border-top: var(--border-width) solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  position: sticky;
  bottom: 0;
}

@media (max-width: 768px) {
  .panel { width: 100vw; }
}

/* ---------------------------------------------------------------------------
   Modal overlay (used to centre the prospect detail modal)
   The wrapper handles positioning + scroll trapping; the inner .panel handles
   its own size + chrome. Animating the inner .panel doesn't fight the
   wrapper's centering because there's no transform on the wrapper.
--------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: var(--z-panel);
  padding: var(--space-4);
  pointer-events: none;
  overflow-y: auto;
}
.modal-overlay.is-open { pointer-events: auto; }

/* Detail-panel variant: become a centered modal at 800px instead of
   the default right-edge slide-in. The base .panel rules above set
   position:fixed, full height, and a translate transform — everything below
   here cancels those for the detail variant only. */
.modal-overlay > .panel--detail {
  position: relative;
  top: auto; right: auto; left: auto;
  width: min(800px, 100%);
  max-width: 800px;
  height: auto;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  border-left: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transform: none;
  /* The .panel--detail.is-open transform from .panel.is-open above is
     irrelevant when nested in the overlay — overridden by transform: none. */
}
.modal-overlay > .panel--detail.is-open { transform: none; }

/* Phone: full-screen modal so every form field has room. */
@media (max-width: 768px) {
  .modal-overlay { padding: 0; }
  .modal-overlay > .panel--detail {
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }
}

/* New-prospect quick-add modal — narrower than the detail modal */
.modal-overlay > .panel--new-prospect {
  position: relative;
  top: auto; right: auto; left: auto;
  width: min(480px, 100%);
  max-width: 480px;
  height: auto;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  border-left: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transform: none;
}
.modal-overlay > .panel--new-prospect.is-open { transform: none; }

@media (max-width: 540px) {
  .modal-overlay > .panel--new-prospect {
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }
}

.new-prospect-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.new-prospect__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  margin-top: var(--space-2);
}

/* Tier segmented inside the new-prospect form: each button takes equal width
   so 3 buttons fit cleanly inside the 2-col grid cell (was overflowing because
   the default segmented buttons have a min-width of 80px). */
.new-prospect-form .segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
}
.new-prospect-form .segmented__btn {
  min-width: 0;
  padding: 8px 4px;
}

/* ---------------------------------------------------------------------------
   Stat card
--------------------------------------------------------------------------- */
.stat {
  background: var(--bg-secondary);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-shadow: var(--shadow-card);
}
.stat__label {
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  color: var(--text-secondary);
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
}
.stat__num {
  font-family: var(--font-sans);
  font-size: var(--fs-stat-num);
  line-height: var(--lh-stat-num);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}
.stat__trend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-small);
  color: var(--text-tertiary);
}
.stat__trend--up { color: var(--success); }
.stat__trend--down { color: var(--danger); }

/* MRR hero stat — the headline number of the app */
.stat--hero {
  grid-column: span 2;
  padding: var(--space-6) var(--space-6) var(--space-5);
  position: relative;
  overflow: hidden;
}
.stat--hero .stat__num {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: var(--fw-display);
  letter-spacing: -0.025em;
  display: inline-block;
  position: relative;
}
.stat--hero .stat__num::after {
  content: "";
  position: absolute;
  left: 0; bottom: 4px;
  width: 56px;
  height: 2px;
  background: var(--accent);
  border-radius: 999px;
}
@media (max-width: 768px) {
  .stat--hero { grid-column: 1 / -1; }
}

/* ---------------------------------------------------------------------------
   Empty state
--------------------------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-7) var(--space-5);
  gap: var(--space-3);
  color: var(--text-secondary);
}
.empty__icon {
  width: 32px;
  height: 32px;
  color: var(--text-tertiary);
}
.empty__title {
  font-size: var(--fs-h3);
  font-weight: var(--fw-strong);
  color: var(--text-primary);
}
.empty__msg { color: var(--text-secondary); max-width: 36ch; }

/* ---------------------------------------------------------------------------
   Pain dots (10-dot row, filled to score)
--------------------------------------------------------------------------- */
.pain-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.pain-dots__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}
.pain-dots__dot.is-on { background: var(--accent); border-color: var(--accent); }
.pain-dots__dot.is-hot { background: var(--danger); border-color: var(--danger); }

/* ---------------------------------------------------------------------------
   Divider
--------------------------------------------------------------------------- */
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }

/* ---------------------------------------------------------------------------
   Command palette / search dialog
--------------------------------------------------------------------------- */
.cmdk-backdrop {
  position: fixed; inset: 0;
  background: var(--backdrop);
  z-index: var(--z-backdrop);
}
.cmdk {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  max-height: 70vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  z-index: var(--z-command);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cmdk__input-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.cmdk__input-row .icon { color: var(--text-tertiary); flex-shrink: 0; }
.cmdk__input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  padding: 4px 0;
  min-width: 0;
}
.cmdk__input::placeholder { color: var(--text-tertiary); }
.cmdk__kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}
/* Close button — replaces the static Esc kbd so it's tappable on mobile.
   Desktop hides the kbd hint anyway via the bottom hint row. */
.cmdk__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  background: transparent;
  flex-shrink: 0;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.cmdk__close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
@media (max-width: 540px) {
  .cmdk__close { width: 36px; height: 36px; }
}

.cmdk__results {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
  min-height: 80px;
}
.cmdk__result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
}
.cmdk__result:hover,
.cmdk__result.is-active {
  background: var(--bg-tertiary);
}
.cmdk__result-name {
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}
.cmdk__result-meta {
  color: var(--text-secondary);
  font-size: var(--fs-small);
}
.cmdk__empty {
  padding: var(--space-7) var(--space-4);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--fs-small);
}

.cmdk__hint {
  border-top: 1px solid var(--border);
  padding: var(--space-2) var(--space-4);
  color: var(--text-tertiary);
  font-size: 11px;
  display: flex;
  gap: var(--space-4);
  background: var(--bg-primary);
}

/* On phones the dialog drops to the top edge with a bit more breathing room.
   Use left/right pinning instead of width + translateX(-50%) so iOS Safari's
   100vw quirks (URL bar collapse, scrollbar gutter) can't push the dialog
   off-screen. */
@media (max-width: 540px) {
  .cmdk {
    top: 12px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: none;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
  .cmdk__input { font-size: var(--fs-body); }
  .cmdk__input-row { padding: var(--space-3); }
  .cmdk__hint { display: none; }
}

/* ---------------------------------------------------------------------------
   Detail panel — Step 7
--------------------------------------------------------------------------- */
.panel--detail .panel__body {
  gap: var(--space-7);
}

.panel__header--detail {
  align-items: flex-start;
}
.panel__header-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  flex: 1;
}
.panel__title {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 32px;
  font-weight: var(--fw-display-strong);
  letter-spacing: -0.015em;
  color: var(--text-primary);
  word-break: break-word;
}
.panel__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.panel__meta-text {
  color: var(--text-secondary);
  font-size: var(--fs-small);
}
.panel__links {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-1);
}
.panel__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  height: 28px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: border-color 140ms var(--ease-out), color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
.panel__link:hover {
  border-color: var(--border-strong);
  color: var(--accent);
  background: var(--bg-tertiary);
}
.panel__link-tag {
  font-size: 11px;
  font-weight: var(--fw-strong);
  letter-spacing: 0.04em;
  line-height: 1;
}

/* Section divider blocks */
.panel__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.panel__section-head {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: var(--fw-strong);
}

/* 2-col grid of fields, single-column on narrow */
.panel__field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.panel__field-grid > .field--full { grid-column: span 2; }

@media (max-width: 540px) {
  .panel__field-grid { grid-template-columns: 1fr; }
  .panel__field-grid > .field--full { grid-column: span 1; }
}

.field__hint {
  margin-top: var(--space-1);
  color: var(--text-tertiary);
}

/* Brief "saved" pulse on input border */
.input--saved,
.textarea.input--saved,
.select.input--saved {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18) !important;
  transition: border-color 360ms var(--ease-out), box-shadow 360ms var(--ease-out);
}

/* Disabled inputs (e.g. build fee when tier is a standard package, not Custom).
   Use bg-tertiary so it's visible against any card background in either theme:
   slightly lighter than the card in dark mode, slightly darker in light mode. */
.input:disabled,
.select:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Pricing summary inside the Pricing & deal section */
.pricing-summary {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.pricing-summary__num {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 28px;
  font-weight: var(--fw-display-strong);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.pricing-summary__sold {
  color: var(--text-tertiary);
}

/* Pain score visual */
.pain-score {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.pain-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.pain-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--border-strong);
  padding: 0;
  cursor: pointer;
  transition: background-color 120ms var(--ease-out), border-color 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.pain-dot:hover { transform: scale(1.15); border-color: var(--accent); }
.pain-dot.is-on { background: var(--accent); border-color: var(--accent); }
.pain-score__value {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
}

/* Vertical timeline shared between stage history + activity notes */
.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}
.timeline__row {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  position: relative;
}
.timeline__row:first-child { padding-top: 0; }
.timeline__row:last-child  { padding-bottom: 0; }
.timeline__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--accent);
  margin-top: 4px;
  z-index: 1;
}
.timeline__dot--note {
  border-color: var(--text-tertiary);
}
.timeline__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}
.timeline__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.timeline__time {
  color: var(--text-tertiary);
  font-size: var(--fs-small);
  font-variant-numeric: tabular-nums;
}
.timeline__note {
  color: var(--text-secondary);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  white-space: pre-wrap;
}

/* Note input row */
.note-input-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: stretch;
}
.note-input-row .btn {
  align-self: flex-end;
}

/* Footer action row + inline forms */
.panel__footer--detail {
  background: var(--bg-secondary);
}
.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.action-row .btn--primary { flex: 1 1 auto; min-width: 200px; }
.action-row__divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0 var(--space-1);
}

/* Stage dropdown selector — compact labelled select inside the action row */
.stage-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 220px;
  padding: 4px 6px 4px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  transition: border-color 140ms var(--ease-out);
}
.stage-selector:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.stage-selector__label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: var(--fw-strong);
  white-space: nowrap;
}
.stage-selector__select {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 28px 8px 0;
  color: var(--text-primary);
  font-weight: var(--fw-medium);
  cursor: pointer;
}
.stage-selector__select:focus { box-shadow: none; }

/* Inline-form grid (Won form: two side-by-side selects + summary) */
.inline-form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--space-3);
  align-items: stretch;
}
.inline-form__grid > .inline-form__summary {
  border-left: 1px solid var(--border);
  padding-left: var(--space-3);
  min-width: 160px;
}
@media (max-width: 720px) {
  .inline-form__grid {
    grid-template-columns: 1fr 1fr;
  }
  .inline-form__grid > .inline-form__summary {
    grid-column: span 2;
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: var(--space-3);
  }
}
@media (max-width: 540px) {
  .action-row { flex-direction: column; align-items: stretch; }
  .action-row__divider { display: none; }
  .action-row .btn { width: 100%; min-width: 0; }
  .stage-selector { min-width: 0; }
  .inline-form__grid { grid-template-columns: 1fr; }
  .inline-form__grid > .inline-form__summary { grid-column: span 1; }
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}
.inline-form__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.inline-form__row {
  display: flex;
  align-items: stretch;
  gap: var(--space-3);
}
.inline-form__summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-1);
  padding: 0 var(--space-3);
  border-left: 1px solid var(--border);
  min-width: 180px;
}
.inline-form__num {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: var(--fw-display-strong);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.inline-form__num span { font-family: var(--font-sans); color: var(--text-tertiary); font-weight: 400; font-size: 14px; }
.inline-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}
@media (max-width: 540px) {
  .inline-form__row { flex-direction: column; gap: var(--space-3); }
  .inline-form__summary { border-left: 0; padding: 0; min-width: 0; }
}
