/* =========================================================
   DeemedDone — app page styles
   Layered ON TOP of style.css. Reuses the same tokens
   (--green, --navy, --bg, --border, radii, shadows).
   Green is an accent only; surfaces are white / light-grey.
   ========================================================= */

:root {
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --coral-bg: #fef2f2;
  --coral: #dc2626;
  --amber-bg: #fdf6ec;
  --amber: #b4781a;
  --amber-text: #6b4810;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Intro / upload ── */
.app-intro {
  background-color: var(--bg-white);
  padding-block: 4rem 3rem;
  border-bottom: 1px solid var(--border);
}

.app-intro h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.75rem);
  margin-block: 0.25rem 1rem;
}

.app-intro__lede {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 60ch;
  margin-bottom: 2.25rem;
}

.app-intro__lede strong { color: var(--navy); font-weight: 600; }

/* Upload card — same white card language as step cards */
.upload-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
}

.upload-card__title { font-size: 1.2rem; margin-bottom: 0.4rem; }

.upload-card__sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  max-width: none;
}

.upload-card__sub code,
.dropzone__primary strong { font-weight: 600; }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background-color: var(--green-pale);
  color: var(--green);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

/* Dropzone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  padding: 2.25rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background-color: var(--bg);
  cursor: pointer;
  transition: border-color var(--transition), background-color var(--transition);
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-drag {
  border-color: var(--green);
  background-color: var(--green-pale);
  outline: none;
}

.dropzone__icon { color: var(--green); }
.dropzone__primary { font-size: 0.98rem; color: var(--text); }
.dropzone__secondary { font-size: 0.82rem; color: var(--text-muted); }

.upload-card__or {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-block: 1.25rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.upload-card__or::before,
.upload-card__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border);
}

.paste-area {
  display: block;
  width: 100%;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  resize: vertical;
}
.paste-area:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26, 92, 58, 0.15);
}

.upload-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.upload-card__fineprint {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Parser error (verbatim) — reuse the coral problem-icon treatment */
.app-error {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background-color: var(--coral-bg);
  border: 1px solid #f5c6c6;
  border-radius: var(--radius);
  color: #7a271a;
  font-size: 0.95rem;
}
.app-error svg { flex-shrink: 0; color: var(--coral); margin-top: 1px; }

/* ── Step rail ── */
.app-steps-bar {
  position: sticky;
  top: 64px;
  z-index: 50;
  background-color: rgba(248, 249, 250, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-block: 0.75rem;
}

.app-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  list-style: none;
}

.app-steps__item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition);
}

.app-steps__n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--border);
  color: var(--bg-white);
  font-size: 0.75rem;
  font-weight: 700;
  transition: background-color var(--transition);
}

.app-steps__item.is-active { color: var(--navy); }
.app-steps__item.is-active .app-steps__n { background-color: var(--green); }
.app-steps__item.is-skipped { opacity: 0.45; text-decoration: line-through; }

/* Sections sit below a sticky rail — keep headings clear of it on scroll */
.app-section { scroll-margin-top: 120px; }

/* ── Generic app section spacing ── */
.app-section__actions {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.app-section__actions--split { justify-content: space-between; }

/* ── Step 1 · Review — holdings ── */
.holdings {
  margin-top: 2rem;
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.holding {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
}
.holding:last-child { border-bottom: none; }

.holding__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.holding__isin { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

.holding__facts {
  text-align: right;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.holding__facts strong { color: var(--navy); font-size: 0.92rem; }

/* Regime badges — green accent for exit-tax, neutral for others */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge--exit { background-color: var(--green-pale); color: var(--green); }
.badge--cgt { background-color: #eef0f3; color: var(--charcoal); }
.badge--ambiguous { background-color: var(--amber-bg); color: var(--amber-text); }

/* Notices — reuse coral/neutral treatments */
.notice {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-top: 1rem;
  font-size: 0.92rem;
  line-height: 1.55;
}
.notice strong { color: var(--navy); }
.notice__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.notice--flag { background-color: var(--amber-bg); color: var(--amber-text); }
.notice--flag .notice__icon { background-color: var(--amber); color: #fff; }
.notice--info { background-color: var(--bg); border: 1px solid var(--border); color: var(--text); }
.notice--info .notice__icon { background-color: var(--charcoal); color: #fff; font-style: italic; }

/* ── Step 2 · Values ── */
.valuations {
  margin-top: 2rem;
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.valuation {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
}
.valuation:last-child { border-bottom: none; }

.valuation__name { font-weight: 600; color: var(--navy); }
.valuation__meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

.valuation__input {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.valuation__cur { color: var(--text-muted); font-family: var(--mono); }
.valuation__field {
  width: 130px;
  text-align: right;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg-white);
}
.valuation__field:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26, 92, 58, 0.15);
}

/* ── Step 3 · Results ── */
.headline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  margin-bottom: 1.5rem;
}

.stat {
  flex: 1;
  min-width: 200px;
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}
.stat__k {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat__v { font-size: 1.9rem; font-weight: 700; color: var(--navy); margin-top: 0.35rem; }

/* The headline "tax to settle" stat is the one place green leads */
.stat--primary { background-color: var(--green); border-color: var(--green); }
.stat--primary .stat__k { color: rgba(255, 255, 255, 0.7); }
.stat--primary .stat__v { color: #fff; }

.stat--pending { background-color: var(--amber-bg); border-color: #f0e0c4; }
.stat--pending .stat__k { color: var(--amber-text); }
.stat--pending .stat__v { color: var(--amber-text); }

/* Overdue stat (Fix 2) — coral treatment, distinct from the green primary */
.stat--overdue { background-color: var(--coral-bg); border-color: #f5c6c6; }
.stat--overdue .stat__k { color: var(--coral); }
.stat--overdue .stat__v { color: var(--coral); }
.stat__sub { margin-top: 0.25rem; font-size: 0.72rem; color: var(--text-muted); }
.stat--overdue .stat__sub { color: #a3322a; }

/* Engine ERROR banner + lines (Fix 3) — never silently dropped */
.app-error--banner { margin-top: 0; margin-bottom: 1rem; font-weight: 600; }
.error-line {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
  padding: 0.85rem 1rem;
  background-color: var(--coral-bg);
  border: 1px solid #f5c6c6;
  border-left: 4px solid var(--coral);
  border-radius: var(--radius);
}
.error-line__icon {
  flex-shrink: 0;
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background-color: var(--coral); color: #fff;
  font-weight: 700; font-size: 0.8rem; line-height: 1;
}
.error-line__where { font-size: 0.78rem; color: #a3322a; margin-bottom: 0.15rem; }
.error-line__note { color: #7a271a; font-size: 0.95rem; line-height: 1.5; }

.years {
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.year { padding: 1.25rem 1.4rem; border-bottom: 1px solid var(--border); }
.year:last-child { border-bottom: none; }

.year__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
}
.year__title { font-size: 1.1rem; font-weight: 700; color: var(--navy); }
.year__due { font-size: 0.82rem; color: var(--text-muted); }
.year__amt { font-size: 1.05rem; font-weight: 700; color: var(--navy); }

.year--pending .year__title { color: var(--amber-text); }

.event {
  margin-top: 0.85rem;
  border-left: 2px solid var(--green-pale);
  padding-left: 0.9rem;
}
.event summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.65rem;
  font-size: 0.86rem;
  color: var(--text);
}
.event summary::-webkit-details-marker { display: none; }
.event__kind { font-weight: 700; color: var(--green); }
.event__rules { font-size: 0.72rem; color: var(--text-muted); }
.event__amt { margin-left: auto; font-weight: 700; color: var(--navy); }
.event__body {
  padding: 0.6rem 0 0.2rem;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.event__body code {
  background: none;
  color: var(--text);
  padding: 0;
  font-size: 0.82rem;
}
.event--static { padding: 0.4rem 0 0.4rem 0.9rem; }

/* ── Step 4 · Timeline ── */
.timeline-card {
  margin-top: 2rem;
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.timeline__scale {
  position: relative;
  height: 22px;
  margin-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}
.timeline__yr {
  position: absolute;
  transform: translateX(-50%);
  top: 2px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.timeline__body { position: relative; }

.trow { position: relative; height: 78px; border-bottom: 1px solid var(--border); }
.trow:last-child { border-bottom: none; }
.trow--closed { opacity: 0.5; }
.trow--closed .trow__name { color: var(--text-muted); }
.trow__meta { position: absolute; top: 8px; left: 0; }
.trow__name { font-weight: 600; color: var(--navy); font-size: 0.9rem; }
.trow__q { font-size: 0.74rem; color: var(--text-muted); margin-left: 0.4rem; }

.ttrack { position: absolute; left: 0; right: 0; top: 58px; height: 2px; background-color: var(--border); }
.tseg { position: absolute; top: 0; height: 2px; background-color: var(--green); }

.tnode {
  position: absolute;
  top: 0;
  transform: translate(-50%, -50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--bg-white);
}
.tnode--buy { background-color: var(--green); width: 10px; height: 10px; }
.tnode--due { background-color: var(--coral); box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.16); }
.tnode--upcoming { background-color: var(--bg-white); border: 2px solid var(--text-muted); }

.tnode__tip {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.68rem;
  color: var(--text);
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}
.tnode:hover .tnode__tip,
.tnode:focus .tnode__tip { opacity: 1; }

/* Vertical "today" line runs through the body; its label now lives on the
   scale axis (.timeline__today-lab) so it never overlaps row 1 (Fix 1). */
.ttoday { position: absolute; top: 0; bottom: 8px; width: 2px; background-color: var(--coral); opacity: 0.55; z-index: 0; }
.timeline__today-lab {
  position: absolute;
  transform: translateX(-50%);
  top: -1px;
  font-size: 0.66rem;
  font-weight: 700;
  color: #fff;
  background-color: var(--coral);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 3;
}

.timeline__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.timeline__legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot--buy { background-color: var(--green); }
.dot--due { background-color: var(--coral); }
.dot--upcoming { background-color: var(--bg-white); border: 2px solid var(--text-muted); }

.timeline__empty { color: var(--text-muted); font-size: 0.95rem; padding: 0.5rem; }

/* ── Responsive ── */
@media (max-width: 560px) {
  .holding, .valuation { flex-direction: column; align-items: flex-start; }
  .holding__facts { text-align: left; }
  .valuation__field { width: 100%; }
  .stat__v { font-size: 1.5rem; }
  .app-steps { gap: 0.4rem 1rem; }
  .app-steps__item { font-size: 0.78rem; }
  .event__amt { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* =========================================================
   Auth gate — sign-in / create-account card.
   Reuses the shared tokens (--green, --navy, --border, radii,
   shadows) so the wall sits inside the same design system.
   ========================================================= */
.auth-gate {
  background-color: var(--bg-white);
  padding-block: 4.5rem 4rem;
  border-bottom: 1px solid var(--border);
}

.auth-card {
  max-width: 30rem;
  margin: 0 auto;
  background-color: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2.25rem;
}

.auth-card__title {
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  color: var(--navy);
  margin-block: 0.5rem 0.75rem;
}

.auth-card__lede {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 1.75rem;
}

/* Inline message banner (errors + confirmations) */
.auth-msg {
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
  line-height: 1.4;
}
.auth-msg--error {
  background-color: var(--coral-bg);
  color: var(--coral);
  border: 1px solid #f5c2c2;
}
.auth-msg--ok {
  background-color: var(--green-pale);
  color: var(--green);
  border: 1px solid #bfe0cd;
}
.auth-msg--info {
  background-color: #fff8e6;
  color: #8a6100;
  border: 1px solid #f3dca0;
}

/* Fields */
.auth-field { display: block; margin-bottom: 1.1rem; }
.auth-field__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.4rem;
}
.auth-field__input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.7rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg-white);
  color: var(--navy);
  transition: border-color .15s ease;
}
.auth-field__input:focus {
  outline: none;
  border-color: var(--green);
}
.auth-field__input::placeholder { color: #9aa0ab; }

/* Forgot link row */
.auth-card__forgot {
  text-align: right;
  margin: -0.4rem 0 1.25rem;
}

.auth-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--green);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.auth-link:hover { color: var(--green-light); }

.auth-card__submit {
  width: 100%;
  justify-content: center;
  margin-top: 0.25rem;
}

/* Divider */
.auth-card__divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 1.75rem 0 1.25rem;
}
.auth-card__divider::before,
.auth-card__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border);
}
.auth-card__divider span { padding: 0 0.85rem; }

/* OAuth placeholder buttons (not wired this pass) */
.auth-card__oauth {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.auth-oauth {
  justify-content: center;
  position: relative;
  opacity: 0.6;
  cursor: not-allowed;
}
.auth-oauth__icon {
  font-weight: 700;
  margin-right: 0.15rem;
}
.auth-oauth__soon {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-left: 0.35rem;
}

/* Toggle sign-in / create-account */
.auth-card__toggle {
  text-align: center;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}
.auth-card__toggle .auth-link { margin-left: 0.35rem; }

.auth-card__fineprint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0;
}

/* Header sign-out button sizing tweak */
.nav__signout { margin-left: 0.5rem; }

@media (max-width: 480px) {
  .auth-card { padding: 1.75rem 1.4rem; }
  .auth-card__oauth { grid-template-columns: 1fr; }
}

/* Tool banner — shown above the intro after an email-confirmation redirect */
.tool-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 720px;
  margin: 1.5rem auto 0;
  padding: 0.7rem 1rem;
  background-color: var(--green-pale);
  color: var(--green);
  border: 1px solid #bfe0cd;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
}
.tool-banner svg { flex: 0 0 auto; }
.tool-banner span { flex: 1 1 auto; }
.tool-banner__close {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
  padding: 0 0.15rem;
}
.tool-banner__close:hover { opacity: 1; }

/* Set-a-new-password (recovery) form — inherits the auth-field styling, just
   ensure consistent spacing between the two stacked fields. */
#resetForm .auth-field + .auth-field { margin-top: 0.9rem; }
#resetForm .auth-card__submit { margin-top: 1.1rem; }
