/* Effort Estimation — internal tool styling.
 *
 * System fonts only, by necessity and by preference: the target environment has
 * no outbound network, so a webfont link would silently fall back anyway.
 *
 * Day counts use tabular figures throughout. A breakdown whose digits do not
 * line up is materially harder to scan, and scanning columns of numbers is the
 * main thing anyone does on this screen.
 */

:root {
  --bg:            #f6f7f9;
  --surface:       #ffffff;
  --surface-sunk:  #f1f3f6;
  --border:        #dfe3e9;
  --border-strong: #c3cad4;
  --text:          #161a20;
  --text-muted:    #5b636f;
  --text-faint:    #838b97;

  /* Accent is a deep slate-teal: technical without being cold, and it survives
   * both grounds. Used only for primary action and focus. */
  --accent:        #0f6b68;
  --accent-hover:  #0b5754;
  --accent-weak:   #e4f0ef;
  --on-accent:     #ffffff;

  /* Semantic colours for classification. Deliberately separate from the accent:
   * severity must never be confused with "this is the button". */
  --ok:            #1c6b45;
  --ok-weak:       #e6f4ec;
  --warn:          #8a5300;
  --warn-weak:     #fdf1de;
  --stop:          #9c2226;
  --stop-weak:     #fbeaea;

  --radius: 6px;
  --gap: 1.25rem;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #12151a;
    --surface:       #1a1e25;
    --surface-sunk:  #15181e;
    --border:        #2a303a;
    --border-strong: #3a4250;
    --text:          #e7eaef;
    --text-muted:    #9aa2ae;
    --text-faint:    #6f7783;

    --accent:        #3fada6;
    --accent-hover:  #55c1ba;
    --accent-weak:   #17302f;
    --on-accent:     #0a1211;

    --ok:            #59b784;
    --ok-weak:       #16291f;
    --warn:          #d9a24a;
    --warn-weak:     #2c2214;
    --stop:          #e2696d;
    --stop-weak:     #2e1618;
  }
}

* { box-sizing: border-box; }

/* The UA rule for [hidden] is display:none, but ANY author rule that sets
 * display beats it — and .view, .session and .choices all do. Without this,
 * toggling `hidden` in JavaScript silently does nothing and every view renders
 * at once. Scoped with !important because the whole point is to win over the
 * layout rules below. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap);
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 0.6rem; }
.brand-mark {
  width: 10px; height: 10px; border-radius: 2px;
  background: var(--accent);
  transform: translateY(-1px);
}
.brand-name { font-weight: 650; letter-spacing: -0.01em; }
.brand-sub {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint);
}
.session { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
.session-who { display: flex; align-items: center; gap: 0.5rem; }
.tag {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.1rem 0.4rem; border-radius: 3px;
  background: var(--surface-sunk); color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ---------------------------------------------------------------- layout */

main { max-width: 1080px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.view { display: flex; flex-direction: column; gap: var(--gap); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 0.9rem;
}
.card.narrow { max-width: 24rem; margin: 3rem auto 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }

h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.015em; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.lede { margin: 0; color: var(--text-muted); font-size: 0.9rem; max-width: 62ch; }
.hint { margin: 0; color: var(--text-faint); font-size: 0.825rem; max-width: 68ch; }
.optional { color: var(--text-faint); font-weight: 400; font-size: 0.8rem; }
.ref { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.result-grid { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 900px) { .result-grid { grid-template-columns: 1.05fr 1fr; } }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- steps */

.steps { display: flex; gap: 0.5rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.step {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint);
  padding: 0.3rem 0.7rem 0.3rem 0;
  display: flex; align-items: center; gap: 0.45rem;
}
.step::before {
  content: attr(data-step);
  display: grid; place-items: center;
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-size: 0.72rem; letter-spacing: 0;
}
.step-current { color: var(--text); font-weight: 600; }
.step-current::before { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.step-done { color: var(--text-muted); }
.step-done::before { content: "✓"; background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- forms */

label { display: block; font-size: 0.83rem; font-weight: 600; margin-bottom: 0.3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 0.5rem 0.6rem;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
select { appearance: none; padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 4rem; resize: vertical; }

:is(input, select, textarea, button, a):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

form { display: flex; flex-direction: column; gap: 0.75rem; }

fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.7rem; }
legend { font-size: 0.83rem; font-weight: 600; padding: 0; margin-bottom: 0.2rem; }

.service-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.4rem; }
.service {
  display: flex; align-items: flex-start; gap: 0.55rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface-sunk);
  cursor: pointer;
}
.service:hover { border-color: var(--border-strong); }
.service:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); }
.service input { margin-top: 0.2rem; accent-color: var(--accent); flex: none; }
.service-name { font-size: 0.875rem; font-weight: 500; }

.choices { display: flex; flex-direction: column; gap: 0.3rem; }
.choice { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; font-weight: 400; }
.choice input { accent-color: var(--accent); }

/* Question blocks */
.svc-block { display: flex; flex-direction: column; gap: 0.9rem; }
.svc-block + .svc-block { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.svc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.svc-title { font-size: 1rem; font-weight: 650; }
.svc-version { font-family: var(--mono); font-size: 0.75rem; color: var(--text-faint); }
.q { display: flex; flex-direction: column; gap: 0.35rem; }
.q-required::after { content: " *"; color: var(--stop); }
.q-help { font-size: 0.8rem; color: var(--text-faint); margin: 0; }
.q-invalid input, .q-invalid select { border-color: var(--stop); }

/* ---------------------------------------------------------------- buttons */

.btn {
  font: inherit; font-weight: 550; font-size: 0.875rem;
  padding: 0.5rem 0.95rem;
  border-radius: 4px; border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-quiet { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-quiet:hover { border-color: var(--text-faint); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.actions-note { font-size: 0.82rem; color: var(--text-faint); }

/* ---------------------------------------------------------------- tables */

.breakdown, .trace { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.breakdown th, .breakdown td, .trace th, .trace td {
  text-align: left; padding: 0.4rem 0; border-bottom: 1px solid var(--border);
  vertical-align: baseline;
}
.num {
  text-align: right; font-family: var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.breakdown .sub { color: var(--text-muted); padding-left: 1rem; }
.breakdown .basis { font-size: 0.78rem; color: var(--text-faint); }
.total-row th, .total-row td {
  border-top: 2px solid var(--border-strong); border-bottom: 0;
  padding-top: 0.55rem; font-size: 1rem; font-weight: 680;
}
.trace td:first-child { color: var(--text-muted); }
.trace .delta { color: var(--text); }
.trace .internal td { color: var(--text-faint); }
.trace-scope {
  font-family: var(--mono); font-size: 0.72rem;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em;
  padding-top: 0.8rem;
}

.meta { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0.25rem 0 0; font-size: 0.875rem; }
.meta dt { color: var(--text-muted); }
.meta dd { margin: 0; font-variant-numeric: tabular-nums; }
.caveat { font-size: 0.8rem; color: var(--text-faint); margin: 0.25rem 0 0; max-width: 60ch; }

/* ---------------------------------------------------------- classification */

.banner {
  border: 1px solid; border-left-width: 4px; border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.banner-title { font-weight: 680; font-size: 0.95rem; }
.banner-reasons { margin: 0; padding-left: 1.1rem; font-size: 0.86rem; }
.banner-standard { background: var(--ok-weak);   border-color: var(--ok);   color: var(--ok); }
.banner-review   { background: var(--warn-weak); border-color: var(--warn); color: var(--warn); }
.banner-stop     { background: var(--stop-weak); border-color: var(--stop); color: var(--stop); }
.banner-title, .banner-reasons { color: var(--text); }
.banner-standard .banner-title { color: var(--ok); }
.banner-review .banner-title   { color: var(--warn); }
.banner-stop .banner-title     { color: var(--stop); }

/* ---------------------------------------------------------------- misc */

.alert { padding: 0.6rem 0.8rem; border-radius: 4px; font-size: 0.86rem; border: 1px solid; }
.alert-error { background: var(--stop-weak); border-color: var(--stop); color: var(--text); }
.alert-error strong { color: var(--stop); }

.trace-note {
  font-size: 0.8rem; color: var(--text-muted);
  background: var(--surface-sunk); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.45rem 0.6rem;
}

.scope-text {
  font-family: var(--font); font-size: 0.9rem; line-height: 1.6;
  white-space: pre-wrap; margin: 0;
  background: var(--surface-sunk); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.9rem 1rem;
  max-width: 74ch;
}

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 0.55rem 1rem; border-radius: 4px; font-size: 0.86rem;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.18);
}

.busy { opacity: 0.55; pointer-events: none; }

/* Wide content must scroll in its own box, never the page body. */
.table-scroll { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
