:root {
  --bg: #f2f2f7;
  --cell: #ffffff;
  --label: #000000;
  --label2: rgba(60, 60, 67, 0.62);
  --label3: rgba(60, 60, 67, 0.34);
  --sep: rgba(60, 60, 67, 0.22);
  --fill: rgba(120, 120, 128, 0.12);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --green-t: #1f7a37;
  --orange-t: #a85a00;
  --red-t: #c4271c;
  --bar: rgba(242, 242, 247, 0.86);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --cell: #1c1c1e; --label: #ffffff; --label2: rgba(235, 235, 245, 0.62); --label3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.65); --fill: rgba(120, 120, 128, 0.24); --blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --red: #ff453a;
    --green-t: #32d74b; --orange-t: #ffb340; --red-t: #ff6961; --bar: rgba(28, 28, 30, 0.86);
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --cell: #1c1c1e; --label: #ffffff; --label2: rgba(235, 235, 245, 0.62); --label3: rgba(235, 235, 245, 0.3);
  --sep: rgba(84, 84, 88, 0.65); --fill: rgba(120, 120, 128, 0.24); --blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --red: #ff453a;
  --green-t: #32d74b; --orange-t: #ffb340; --red-t: #ff6961; --bar: rgba(28, 28, 30, 0.86);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font: 17px/1.35 var(--font); letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
.muted { color: var(--label2); }

#app { max-width: 780px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
main { display: block; padding-top: max(12px, env(safe-area-inset-top)); }

/* navigation: bottom tab bar on phones, segmented control on wide screens */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 44px; justify-content: center; color: var(--label2); font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em; }
.tabs a svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--blue); }
.tabs a:focus-visible, button:focus-visible, .row-link:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
@media (min-width: 760px) {
  #app { padding-bottom: 48px; display: flex; flex-direction: column; }
  .tabs { position: static; order: -1; align-self: center; width: 360px; margin-top: 20px; padding: 2px; border: 0; border-radius: 9px; background: var(--fill); -webkit-backdrop-filter: none; backdrop-filter: none; gap: 2px; justify-content: stretch; }
  .tabs a { flex-direction: row; min-height: 32px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--label); }
  .tabs a svg { display: none; }
  .tabs a[aria-current="page"] { background: var(--cell); color: var(--label); box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.18); }
}

/* titles */
.title-block { padding: 16px 4px 8px; }
.title-block h1 { margin: 0; font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: 0.01em; }
.sub { display: flex; align-items: center; gap: 10px; margin-top: 4px; color: var(--label2); font-size: 15px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin-left: -4px; font-size: 17px; }
.back svg { width: 12px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.linkbtn { background: none; border: 0; padding: 6px 8px; margin: -6px -8px; color: var(--blue); cursor: pointer; min-height: 32px; border-radius: 8px; }
.linkbtn[disabled] { color: var(--label2); cursor: default; }

/* grouped inset lists */
.section-title { margin: 24px 16px 6px; font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.02em; color: var(--label2); }
.group { background: var(--cell); border-radius: 12px; overflow: hidden; }
.row { position: relative; display: block; padding: 12px 16px; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.row-link { color: inherit; }
.row-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-title { font-size: 17px; font-weight: 600; }
.row-detail { margin-top: 2px; font-size: 15px; color: var(--label2); }
.row-value { font-size: 17px; font-weight: 600; text-align: right; white-space: nowrap; }
.chev { width: 8px; height: 14px; fill: none; stroke: var(--label3); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.footnote { margin: 8px 16px 0; font-size: 13px; color: var(--label2); }

/* status */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--fill); color: var(--label2); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--green-t); background: color-mix(in srgb, var(--green) 16%, transparent); }
.pill.warn { color: var(--orange-t); background: color-mix(in srgb, var(--orange) 18%, transparent); }
.pill.crit { color: var(--red-t); background: color-mix(in srgb, var(--red) 16%, transparent); }
.pill.info { color: var(--blue); background: color-mix(in srgb, var(--blue) 14%, transparent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--label3); margin-right: 6px; }
.dot.ok { background: var(--green); } .dot.warn { background: var(--orange); } .dot.crit { background: var(--red); }

.rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.rate { background: var(--fill); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.rate .k { font-size: 12px; color: var(--label2); display: flex; align-items: center; }
.rate .v { font-size: 20px; font-weight: 600; margin-top: 2px; }
.rate .n { font-size: 12px; color: var(--label2); }

.action { padding-left: 16px; }
.action .row-main { align-items: flex-start; }
.action .t { font-weight: 600; }
.action .next { margin-top: 6px; font-size: 15px; }
.action .next b { font-weight: 600; }
.empty { text-align: center; padding: 22px 16px; color: var(--label2); }
.empty strong { display: block; color: var(--label); font-size: 17px; margin-top: 6px; }
.empty svg { width: 28px; height: 28px; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* sequences */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; margin-top: 10px; }
.stat .v { font-size: 20px; font-weight: 600; line-height: 1.15; }
.stat .k { font-size: 12px; color: var(--label2); }
.big { font-size: 28px; font-weight: 700; line-height: 1; }
.big small { display: block; font-size: 12px; font-weight: 400; color: var(--label2); text-align: right; margin-top: 3px; }

.funnel { background: var(--cell); border-radius: 12px; padding: 4px 0 8px; }
.fgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0 2px; padding: 0 12px; }
.fhead { position: sticky; top: 0; background: var(--cell); z-index: 2; padding-top: 10px; padding-bottom: 6px; border-bottom: 0.5px solid var(--sep); font-size: 11px; color: var(--label2); text-align: right; border-radius: 12px 12px 0 0; }
.fhead > div:first-child, .fhead > div { text-align: right; }
.fcap { padding: 10px 12px 2px; font-size: 13px; color: var(--label2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcap b { color: var(--label); font-weight: 600; margin-right: 6px; }
.fnum { text-align: right; font-size: 16px; font-weight: 500; padding-bottom: 2px; }
.fnum.zero { color: var(--label3); font-weight: 400; }
.fnum.muted { color: var(--label2); font-size: 14px; font-weight: 400; }

/* tests */
.arms { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .arms { grid-template-columns: 1fr; } }
.arm { background: var(--cell); border-radius: 12px; padding: 14px 16px; }
.arm .name { font-size: 15px; color: var(--label2); }
.arm .rate-big { font-size: 34px; font-weight: 700; line-height: 1.1; margin-top: 2px; }
.arm .meta { font-size: 13px; color: var(--label2); margin-top: 2px; }
.ci { position: relative; height: 6px; border-radius: 3px; background: var(--fill); margin: 12px 0 6px; }
.ci i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: var(--blue); opacity: 0.45; }
.ci b { position: absolute; top: -3px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--blue); border: 2px solid var(--cell); }
.kv { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.kv .r { text-align: right; }

/* login */
.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 34px; margin: 0 0 4px; font-weight: 700; letter-spacing: 0.01em; }
.login-card .group { margin-top: 20px; }
.field { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 48px; position: relative; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.field span { width: 84px; flex: none; }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; height: 46px; font-size: 17px; }
.form-error { margin: 0; padding: 10px 16px; color: var(--red-t); font-size: 15px; border-top: 0.5px solid var(--sep); }
.primary { display: block; width: 100%; min-height: 50px; border: 0; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; border-top: 0.5px solid var(--sep); }
.signout { margin-top: 28px; text-align: center; font-size: 15px; color: var(--label2); }
.signout form { display: inline; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
