:root {
  --primary: #1f4e78;
  --primary-dark: #17365d;
  --accent: #5b9bd5;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2b36;
  --muted: #6b7885;
  --border: #d9e2ea;
  --ok: #2e7d32;
  --ok-bg: #e2f0d9;
  --warn: #8a4b00;
  --warn-bg: #fff1d6;
  --danger: #b3261e;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--primary-dark);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  display: flex; align-items: center; gap: 10px;
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; font-weight: 600; }
.topbar button.back {
  background: none; border: none; color: #fff; font-size: 15px; padding: 6px 8px; cursor: pointer;
}

.screen { flex: 1; padding: 14px; padding-bottom: 32px; display: flex; flex-direction: column; gap: 12px; max-width: 720px; margin: 0 auto; width: 100%; }

h2 { font-size: 20px; margin: 4px 0; }
h3 { font-size: 16px; margin: 0 0 6px; }
p { line-height: 1.4; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.card + .card { margin-top: 0; }

button, .btn {
  font-size: 15px;
  border-radius: 10px;
  padding: 13px 16px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: filter .15s;
}
button:active, .btn:active { filter: brightness(0.92); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); width: 100%; }
.btn-outline.small, .btn-primary.small, .btn-danger.small { width: auto; padding: 9px 14px; font-size: 13.5px; }
.btn-danger { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-tall { padding: 20px; font-size: 17px; }
.btn-lap { background: var(--primary); color: #fff; font-size: 22px; padding: 26px; width: 100%; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input, select, textarea {
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 10px; }
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; }

.stepper { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 6px 0; }
.stepper .value { font-size: 26px; font-weight: 700; min-width: 46px; text-align: center; }
.stepper button { width: 46px; height: 46px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 20px; padding: 0; }
.stepper button.minus { background: #e3ebf1; color: var(--primary); }

.list-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }

.timer-display {
  font-size: 52px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
  padding: 18px 0 6px;
}
.progress-line { text-align: center; color: var(--muted); font-size: 14px; }

.message-banner {
  background: #fff7e0; border: 1px solid #f0d989; color: #6b5300;
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px;
}

.kpi {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border-radius: var(--radius); padding: 18px; text-align: center;
}
.kpi .kpi-value { font-size: 34px; font-weight: 800; }
.kpi .kpi-label { font-size: 12.5px; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: right; }
table.data-table th:first-child, table.data-table td:first-child { text-align: left; }
table.data-table tr.bottleneck-row { background: #fdece0; font-weight: 700; }

.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-chart .bar-item { display: grid; grid-template-columns: 110px 1fr 60px; gap: 8px; align-items: center; font-size: 12.5px; }
.bar-chart .bar-track { background: #e7edf2; border-radius: 6px; height: 16px; overflow: hidden; }
.bar-chart .bar-fill { background: var(--accent); height: 100%; border-radius: 6px; }
.bar-chart .bar-fill.bottleneck { background: #ed7d31; }

.help-search { position: sticky; top: 54px; background: var(--bg); padding-bottom: 4px; z-index: 5; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex: none; padding: 8px 13px; border-radius: 999px; background: #fff; border: 1.5px solid var(--border); color: var(--primary); font-weight: 600; font-size: 13px; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.help-topic .formula-box { background: #f3f4f6; border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 13px; white-space: pre-wrap; }
.help-topic .warning-box { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 13px; }
.help-topic .cat-label { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }

.video-frame { width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-frame video { width: 100%; display: block; max-height: 46vh; }
.video-placeholder { color: #fff; text-align: center; padding: 40px 10px; }

.step-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.step-card + .step-card { margin-top: 8px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

footer.note {
  text-align: center; color: var(--muted); font-size: 12px; padding: 18px 20px 8px;
}

@media (min-width: 640px) {
  .screen { padding: 20px; }
}
