:root {
  --bg: #001621;
  --bg-2: #00202f;
  --bg-3: #012a3d;
  --vulcano: #ff4103;
  --vulcano-soft: rgba(255, 65, 3, .14);
  --vulcano-line: rgba(255, 65, 3, .38);
  --text: #eaf1f5;
  --muted: #8ba2b0;
  --line: rgba(255, 255, 255, .09);
  --glass: rgba(255, 255, 255, .045);
  --ok: #34c38f;
  --bad: #f1605d;
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --dur: 220ms;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.4; }
body { min-height: 100vh; overscroll-behavior-y: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.lucide { width: 20px; height: 20px; stroke-width: 1.75; flex: none; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ---------- shell ---------- */
.screen { padding: calc(var(--safe-t) + 14px) 16px calc(92px + var(--safe-b)); animation: fade var(--dur) ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
}
.card { padding: 14px 16px; margin-bottom: 12px; }
.card.accent { border-color: var(--vulcano-line); background: linear-gradient(0deg, var(--vulcano-soft), var(--vulcano-soft)), var(--glass); }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.logo { font-weight: 700; letter-spacing: .28em; font-size: 20px; line-height: 1; }
.logo small { display: block; letter-spacing: .02em; font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 4px; }
.topbar .sp { flex: 1; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-3); border: 1px solid var(--vulcano-line); display: grid; place-items: center; font-weight: 600; font-size: 14px; color: var(--vulcano); }
.who { min-width: 0; }
.who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--vulcano-soft); color: var(--vulcano); border: 1px solid var(--vulcano-line); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--line); }
.icon-btn:active { background: var(--vulcano-soft); }

h1.page { font-size: 20px; margin: 0 0 14px; font-weight: 600; }
h2.sec { font-size: 15px; font-weight: 600; margin: 20px 2px 10px; display: flex; align-items: center; justify-content: space-between; }
h2.sec small { font-weight: 400; color: var(--muted); font-size: 12px; }

/* ---------- nav ---------- */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px; display: flex; padding: 8px 8px calc(8px + var(--safe-b)); background: rgba(0, 22, 33, .88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); z-index: 20; }
.nav button { flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; color: var(--muted); min-height: 48px; transition: color var(--dur); }
.nav button.on { color: var(--vulcano); }

/* ---------- controls ---------- */
.seg { display: flex; padding: 3px; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.seg button { flex: 1; background: none; border: 0; padding: 9px 4px; border-radius: 9px; color: var(--muted); font-size: 14px; min-height: 40px; transition: background var(--dur), color var(--dur); }
.seg button.on { background: var(--vulcano); color: #fff; font-weight: 600; }
.chips { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--muted); min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { color: var(--vulcano); border-color: var(--vulcano-line); background: var(--vulcano-soft); }

.btn { background: var(--vulcano); border: 0; color: #fff; font-weight: 600; border-radius: 12px; min-height: 48px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; transition: opacity var(--dur), transform 120ms; }
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; }
.btn.ghost { background: var(--glass); border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: rgba(241, 96, 93, .14); border: 1px solid rgba(241, 96, 93, .4); color: var(--bad); }
.btn.sm { min-height: 38px; font-size: 13px; padding: 0 12px; width: auto; border-radius: 10px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin: 0 2px 6px; }
.input { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); outline: none; color: var(--text); transition: border-color var(--dur); }
.input:focus { border-color: var(--vulcano); }
select.input { appearance: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 4px 2px 10px; }

/* ---------- numbers ---------- */
.lbl { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.big { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.01em; white-space: nowrap; }
.big small, .mid small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.mid { font-size: 18px; font-weight: 600; margin-top: 4px; white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.pct { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--vulcano-soft); color: var(--vulcano); }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin: 0; }
.ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--vulcano-soft); color: var(--vulcano); }

/* ---------- flow ---------- */
.flow { padding: 6px 16px; }
.flow .step { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px dashed var(--line); gap: 10px; }
.flow .step:last-child { border-bottom: 0; }
.flow .step b { font-weight: 600; white-space: nowrap; }
.flow .step span { color: var(--muted); font-size: 13px; }
.flow .step.strong b { color: var(--vulcano); }
.flow .indent { padding-left: 16px; }
.bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--vulcano); border-radius: inherit; transition: width 300ms ease; }

/* ---------- stakeholders ---------- */
.sh { padding: 14px 16px; margin-bottom: 12px; }
.sh-head { display: flex; align-items: center; gap: 12px; }
.sh-head .avatar { width: 42px; height: 42px; }
.sh-head .nm { flex: 1; min-width: 0; }
.sh-head .nm b { display: block; font-weight: 600; }
.sh-head .nm span { color: var(--muted); font-size: 12px; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; border-top: 1px solid var(--line); }
.kv:first-of-type { margin-top: 10px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; white-space: nowrap; }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .tip { position: absolute; top: 0; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); min-height: 18px; }
.chart .tip b { color: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut-wrap svg { width: 132px; height: 132px; flex: none; }
.donut-legend { flex: 1; min-width: 0; font-size: 13px; }
.donut-legend div { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; }
.donut-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; }
.donut-legend small { color: var(--muted); }

/* ---------- lists / tables ---------- */
.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.list-row:last-child { border-bottom: 0; }
.list-row .t { flex: 1; min-width: 0; }
.list-row .t b { display: block; font-weight: 500; }
.list-row .t span { color: var(--muted); font-size: 12px; }
.list-row.red .t b, .list-row.red .ico { color: var(--bad); }
.hist { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.hist th { color: var(--muted); font-weight: 500; text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.hist td { text-align: right; padding: 9px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist th:first-child, .hist td:first-child { text-align: left; }
.scroll-x { overflow-x: auto; margin: 0 -4px; }
.urow { padding: 14px 16px; margin-bottom: 10px; }
.urow .top { display: flex; align-items: center; gap: 12px; }
.urow .top .nm { flex: 1; min-width: 0; }
.urow .top .nm b { display: block; font-weight: 600; }
.urow .top .nm span { color: var(--muted); font-size: 12px; }
.status { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.status.on { background: rgba(52, 195, 143, .14); color: var(--ok); }
.status.off { background: rgba(241, 96, 93, .14); color: var(--bad); }
.urow .meta { color: var(--muted); font-size: 12px; margin: 10px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.urow .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.audit { padding: 12px 16px; margin-bottom: 10px; font-size: 13px; }
.audit .h { display: flex; justify-content: space-between; gap: 10px; }
.audit .h b { font-weight: 600; }
.audit .h span { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.audit pre { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); color: var(--muted); font: 11.5px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.audit pre b { color: var(--vulcano); font-weight: 600; }

/* ---------- pct editor ---------- */
.pe { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.pe:last-of-type { border-bottom: 0; }
.pe .t { flex: 1; min-width: 0; } .pe .t b { display: block; font-weight: 500; } .pe .t span { color: var(--muted); font-size: 12px; }
.pe .input { width: 88px; text-align: right; min-height: 44px; }
.sumbox { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; margin: 10px 0 14px; border: 1px solid rgba(52, 195, 143, .4); background: rgba(52, 195, 143, .1); color: var(--ok); }
.sumbox.bad { border-color: rgba(241, 96, 93, .4); background: rgba(241, 96, 93, .1); color: var(--bad); }

/* ---------- states ---------- */
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px; gap: 14px; }
.center p { color: var(--muted); margin: 0; max-width: 300px; }
.center .ico-big { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--vulcano-soft); color: var(--vulcano); border: 1px solid var(--vulcano-line); }
.center .ico-big svg { width: 30px; height: 30px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--vulcano); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); font-size: 13.5px; }
.login { width: 100%; max-width: 360px; text-align: left; padding: 20px; }
.login h2 { margin: 0 0 14px; font-size: 18px; }
.brand-big { font-size: 34px; font-weight: 700; letter-spacing: .3em; margin-right: -.3em; }
.brand-sub { font-size: 18px; font-weight: 600; margin-top: -6px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 8, 12, .65); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fadeo var(--dur) ease both; }
@keyframes fadeo { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); animation: up var(--dur) ease both; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 14px; font-size: 17px; }
.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translate(-50%, 10px); background: var(--bg-3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity var(--dur), transform var(--dur); z-index: 60; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(241, 96, 93, .5); color: var(--bad); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (min-width: 700px) { body { background: radial-gradient(circle at 50% 0, var(--bg-3), var(--bg) 60%); } #app { border-inline: 1px solid var(--line); } }

.grid2 > * { min-width: 0; }
.grid2 .card { padding: 12px 14px; }
.grid2 .mid { font-size: 16px; }
