/* ─── TOKENS ─────────────────────────────── */
:root {
  --bg:        #EEF3FA;
  --card:      #FFFFFF;
  --border:    #D8E3EF;
  --blue:      #3A6FC4;
  --blue-d:    #2A5099;
  --blue-lt:   #EBF1FB;
  --blue-mid:  #5B89D4;
  --teal:      #0EA5B4;
  --text:      #1B2B45;
  --muted:     #556B87;
  --light:     #8AA0B8;
  --green:     #1A8C5B;
  --green-lt:  #E8F8EF;
  --green-bd:  #A3DFBF;
  --amber:     #C07010;
  --amber-lt:  #FEF7E8;
  --amber-bd:  #F4C97A;
  --red:       #B93030;
  --red-lt:    #FDF0F0;
  --red-bd:    #F4AAAA;
  --orange:    #C05820;
  --orange-lt: #FEF3EC;
  --orange-bd: #F4BF9A;
  --shadow:    0 4px 24px rgba(30,60,120,0.08);
  --shadow-sm: 0 2px 8px rgba(30,60,120,0.06);
  --r:         16px;
  --r-sm:      10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  background: var(--bg);
  font-family: 'Nunito', 'Segoe UI', -apple-system, system-ui, sans-serif;
  color: var(--text);
  overscroll-behavior: none;
}
body {
  display: flex; align-items: flex-start; justify-content: center;
  min-height: 100vh; padding: 24px 16px 40px;
}
.app { width: 100%; max-width: 560px; }

/* ─── SCREEN TRANSITIONS ─────────────────── */
.screen { display: none; }
.screen.active { display: block; animation: rise .35s cubic-bezier(.22,1,.36,1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── CARD ───────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--r);
  padding: 36px 36px 32px;
  box-shadow: var(--shadow);
}
@media(max-width:480px) { .card { padding: 28px 22px 26px; } }

/* ─── TYPE ───────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--blue);
  background: var(--blue-lt); padding: 5px 12px;
  border-radius: 20px; margin-bottom: 18px;
}
h1 { font-size: 28px; font-weight: 800; line-height: 1.25; margin-bottom: 6px; }
h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.sub { font-size: 14px; color: var(--light); margin-bottom: 26px; font-weight: 500; }
p  { font-size: 15px; color: var(--muted); line-height: 1.7; margin-bottom: 10px; }
ul { padding-left: 22px; margin-bottom: 16px; }
li { font-size: 15px; color: var(--muted); line-height: 1.7; margin-bottom: 8px; }
li strong { color: var(--text); }
.divider { height: 1px; background: var(--border); margin: 22px 0; }

/* ─── FORM ───────────────────────────────── */
.fg { margin-bottom: 18px; }
label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=date] {
  width: 100%; padding: 13px 16px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: 16px; font-family: inherit; color: var(--text);
  background: #FAFBFD; outline: none;
  transition: border-color .2s, background .2s;
}
input:focus { border-color: var(--blue); background: #fff; }
input::placeholder { color: var(--light); }

/* ─── BUTTONS ────────────────────────────── */
.btn {
  display: block; width: 100%; padding: 15px 20px;
  font-size: 16px; font-weight: 700; font-family: inherit;
  border: none; border-radius: var(--r-sm); cursor: pointer;
  transition: all .18s; text-align: center;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-primary:disabled { background: #B0BFCC; cursor: not-allowed; }
.btn-ghost {
  background: transparent; border: 2px solid var(--border);
  color: var(--muted); margin-top: 10px;
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-lt); }
.btn-sm { padding: 10px 18px; font-size: 14px; width: auto; display: inline-block; margin: 0; }

/* ─── STEP DOTS ──────────────────────────── */
.dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #D8E3EF; transition: all .25s; }
.dot.active { background: var(--blue); transform: scale(1.25); }
.dot.done { background: var(--green); }

/* ─── PHASE LABEL ────────────────────────── */
.phase-lbl { font-size: 13px; font-weight: 600; color: var(--light); margin-bottom: 14px; }

/* ─── TARGET NUMBER ──────────────────────── */
.target-box { text-align: center; padding: 12px 0 20px; }
.target-hint { font-size: 14px; color: var(--light); font-weight: 500; margin-bottom: 4px; }
.target-num  { font-size: 88px; font-weight: 900; color: var(--text); line-height: 1; letter-spacing: -.02em; }
.target-unit { font-size: 22px; color: var(--muted); font-weight: 500; }
@media(max-width:480px) { .target-num { font-size: 68px; } }

/* ─── PROGRESS BAR (Calibration A) ──────── */
.prog-wrap {
  position: relative; height: 52px;
  background: #EEF3FA; border-radius: var(--r-sm);
  overflow: hidden; margin: 8px 0 20px;
  border: 1.5px solid var(--border);
}
.prog-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #6BAAD6, #3A6FC4);
  border-radius: var(--r-sm); transition: none;
}
.prog-txt {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--muted);
  pointer-events: none;
}

/* ─── HOLD BUTTON ────────────────────────── */
.hold-btn {
  width: 100%; min-height: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(160deg, #3A6FC4, #2A5099);
  color: #fff; border: none; border-radius: 14px;
  font-size: 20px; font-weight: 800; font-family: inherit;
  letter-spacing: .02em; cursor: pointer;
  box-shadow: 0 8px 28px rgba(42, 80, 153, 0.28);
  touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform .12s, box-shadow .12s;
}
.hold-btn .hint { font-size: 13px; font-weight: 500; opacity: .72; }
.hold-btn.pressing {
  background: linear-gradient(160deg, #2A5099, #1B3570);
  transform: scale(0.975);
  box-shadow: 0 3px 10px rgba(42,80,153,.18);
}
.hold-btn.pressing .btn-label::after { content: ''; animation: pulse 1s infinite; }

/* ─── FEEDBACK CARD ──────────────────────── */
.fb-card {
  border-radius: var(--r-sm); padding: 18px 20px;
  margin-top: 16px; display: none;
}
.fb-green  { background: var(--green-lt); border: 1.5px solid var(--green-bd); }
.fb-amber  { background: var(--amber-lt); border: 1.5px solid var(--amber-bd); }
.fb-orange { background: var(--orange-lt); border: 1.5px solid var(--orange-bd); }
.fb-yellow { background: var(--amber-lt);  border: 1.5px solid var(--amber-bd); }

.fb-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid rgba(0,0,0,.06);
  font-size: 14px;
}
.fb-row:last-of-type { border-bottom: none; }
.fb-lbl { color: var(--muted); }
.fb-val { font-weight: 700; color: var(--text); }
.fb-note { font-size: 12px; color: var(--light); font-style: italic; margin-top: 12px; }

/* ─── RESULTS ────────────────────────────── */
.res-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.res-brand { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--light); }
.res-date  { font-size: 12px; color: var(--light); }

.alert-box {
  border-radius: var(--r-sm); padding: 13px 16px;
  font-size: 14px; font-weight: 600; margin-bottom: 14px;
  display: none;
}
.alert-red    { background: var(--red-lt);    border-left: 4px solid #E07070; color: var(--red);    }
.alert-amber  { background: var(--amber-lt);  border-left: 4px solid #E0A030; color: var(--amber);  }

/* τ scale */
.tau-wrap { background: var(--bg); border-radius: var(--r-sm); padding: 16px 18px; margin: 14px 0 0; border: 1px solid var(--border); }
.tau-bar {
  height: 16px; border-radius: 8px;
  background: linear-gradient(90deg, #FC9090, #F9C06A, #6DD4A0, #6ABAED, #B09AE8);
  position: relative; margin: 12px 0 6px;
}
.tau-pin {
  position: absolute; top: -6px;
  width: 5px; height: 28px; background: var(--text);
  border-radius: 3px; transform: translateX(-50%);
  transition: left .6s cubic-bezier(.34,1.56,.64,1);
}
.tau-zone-lbl {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--light); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase;
}

/* Metric grid */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.metric {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 16px;
}
.metric.full { grid-column: 1/-1; }
.m-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--light); margin-bottom: 6px; }
.m-val { font-size: 30px; font-weight: 900; color: var(--blue); line-height: 1; }
.m-sub { font-size: 13px; color: var(--muted); margin-top: 5px; }
@media(max-width:480px) {
  .metrics { grid-template-columns: 1fr; }
  .metric.full { grid-column: 1; }
}

/* σ badge */
.sbadge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.sb-green  { background: var(--green-lt);  color: var(--green); }
.sb-amber  { background: var(--amber-lt);  color: var(--amber); }
.sb-red    { background: var(--red-lt);    color: var(--red); }

/* Crisis table */
.crisis-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.crisis-tbl th {
  text-align: left; padding: 8px 10px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--light); border-bottom: 1.5px solid var(--border);
}
.crisis-tbl td { padding: 9px 10px; border-bottom: 1px solid #F0F5FA; color: var(--muted); }
.crisis-tbl tr:last-child td { border-bottom: none; }
.crisis-tbl td:first-child { font-weight: 700; color: var(--text); width: 34px; }
.cr-passed td { color: #B0BFCC !important; }
.cr-zone { background: var(--amber-lt) !important; }
.cr-zone td { color: var(--amber) !important; font-weight: 700 !important; }

/* KPM block */
.kpm-blk {
  background: #F7FAFE; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: 16px 18px;
  font-family: 'Courier New', Courier, monospace; font-size: 12px;
  color: var(--muted); line-height: 1.65; white-space: pre-wrap;
  word-break: break-word; max-height: 220px; overflow-y: auto;
  margin-bottom: 12px;
}

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; margin: 0; }

/* Info box */
.info-box {
  background: var(--blue-lt); border: 1.5px solid #C0D4F0;
  border-radius: var(--r-sm); padding: 14px 16px;
  font-size: 14px; color: #3A6FC4; margin-bottom: 24px;
  line-height: 1.6;
}
