:root {
  color-scheme: dark;
  --bg: #071016;
  --panel: rgba(15, 29, 38, 0.92);
  --panel-2: #122632;
  --line: rgba(151, 191, 207, 0.16);
  --text: #edf8f8;
  --muted: #91a9b2;
  --cyan: #58e6d2;
  --blue: #70a7ff;
  --green: #69e19c;
  --red: #ff7f86;
  --amber: #ffc970;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% -10%, rgba(58, 208, 190, 0.20), transparent 34rem),
    radial-gradient(circle at 100% 35%, rgba(79, 121, 230, 0.13), transparent 28rem);
}

.shell { width: min(980px, 100%); margin: 0 auto; padding: 22px 16px 56px; position: relative; }
.topbar, .section-head, .safety-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 46px; height: 46px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 1.35rem; margin-bottom: 0; }
h2 { font-size: 1.25rem; margin-bottom: 0; }
h3 { font-size: 1rem; margin-bottom: 14px; }
.eyebrow { color: var(--cyan); text-transform: uppercase; letter-spacing: .12em; font-size: .68rem; font-weight: 800; margin-bottom: 4px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.panel, .safety-card {
  background: linear-gradient(145deg, rgba(18, 38, 50, .96), rgba(10, 23, 31, .96));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 16px 55px rgba(0, 0, 0, .22);
  padding: 20px;
  margin-bottom: 16px;
}

.safety-card { justify-content: flex-start; }
.safety-card p { color: var(--muted); margin: 4px 0 0; font-size: .88rem; }
.safety-card .pill { margin-left: auto; white-space: nowrap; }
.shield { display: grid; place-items: center; min-width: 42px; height: 42px; border-radius: 14px; color: #071b17; background: var(--green); font-weight: 900; }
.pill, .number-pill { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; font-size: .78rem; font-weight: 800; }
.pill.good { background: rgba(68, 204, 139, .14); color: var(--green); }
.pill.bad { background: rgba(255, 100, 110, .12); color: var(--red); }
.pill.neutral { color: var(--muted); }
.number-pill { color: var(--cyan); font-variant-numeric: tabular-nums; }

form { margin-top: 20px; }
label, legend { color: #c8d8dc; font-size: .82rem; font-weight: 700; }
input, select, button { font: inherit; }
input[type="date"], input[type="number"], input[type="password"] {
  width: 100%; margin-top: 7px; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; background: #09171f; color: var(--text); outline: none;
}
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(88, 230, 210, .10); }
.date-grid, .parameter-grid, .mode-grid, .split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
fieldset { border: 0; padding: 0; margin: 20px 0; }
legend { margin-bottom: 10px; }
.chip-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.symbol-chip { position: relative; }
.symbol-chip input { position: absolute; opacity: 0; pointer-events: none; }
.symbol-chip span { display: block; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.symbol-chip input:checked + span { color: #071815; background: var(--cyan); border-color: var(--cyan); font-weight: 900; }
.mode-card { position: relative; }
.mode-card input { position: absolute; opacity: 0; }
.mode-card span { display: flex; height: 100%; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(4, 13, 18, .35); }
.mode-card small { color: var(--muted); font-weight: 500; line-height: 1.35; }
.mode-card input:checked + span { border-color: var(--cyan); background: rgba(88, 230, 210, .08); }
.mode-card.disabled { opacity: .45; }
details { border-top: 1px solid var(--line); padding-top: 14px; }
summary { cursor: pointer; color: #c9dadd; font-weight: 800; }
.parameter-grid { margin-top: 14px; }
.notice, .warning { border-radius: 13px; padding: 12px 14px; font-size: .84rem; line-height: 1.45; }
.notice { background: rgba(112, 167, 255, .10); color: #bcd4ff; }
.warning { background: rgba(255, 201, 112, .10); color: #ffe0aa; margin: 16px 0; }

button { border: 0; cursor: pointer; }
.primary { width: 100%; padding: 14px 18px; border-radius: 14px; color: #061714; background: linear-gradient(135deg, var(--cyan), #7af2a9); font-weight: 900; }
.primary:disabled { opacity: .5; cursor: wait; }
.secondary, .ghost { padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); color: var(--text); background: rgba(9, 23, 31, .75); font-weight: 750; }
.danger-text, .link-button { color: var(--red); background: transparent; padding: 8px 0; }
.link-button { color: var(--muted); }

.progress-track { height: 10px; background: #071219; border-radius: 99px; overflow: hidden; margin: 18px 0 12px; }
.progress-track div { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .35s ease; }
.inline-stats { display: flex; gap: 20px; color: var(--muted); font-size: .83rem; margin: 14px 0; }
.inline-stats strong { color: var(--text); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.metric-grid article, .subpanel { background: rgba(5, 16, 22, .55); border: 1px solid var(--line); border-radius: 15px; padding: 14px; }
.metric-grid span, .metric-grid small, .subpanel span, .ab-grid small { display: block; color: var(--muted); font-size: .74rem; }
.metric-grid strong { display: block; font-size: 1.35rem; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.subpanel p { display: flex; justify-content: space-between; gap: 10px; margin: 9px 0 0; }
.ab-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ab-grid strong { display: block; margin: 5px 0; font-size: 1.05rem; }
.limits { margin-top: 16px; }
.limits ul { color: var(--muted); padding-left: 20px; line-height: 1.55; font-size: .83rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 700px; font-size: .8rem; }
th, td { padding: 11px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:last-child td { border-bottom: 0; }

footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: .76rem; padding: 12px 4px; }
footer p { margin: 0; text-align: right; }
dialog { width: min(430px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: #0d202a; padding: 22px; }
dialog::backdrop { background: rgba(0, 6, 9, .78); backdrop-filter: blur(8px); }
dialog p { color: var(--muted); line-height: 1.5; }
.check-row { display: flex; gap: 8px; align-items: center; margin: 14px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 130%); opacity: 0; background: #e9ffff; color: #081316; border-radius: 12px; padding: 11px 15px; font-weight: 800; transition: .25s ease; z-index: 20; max-width: calc(100% - 30px); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 680px) {
  .shell { padding: 15px 12px 44px; }
  .panel, .safety-card { padding: 16px; border-radius: 17px; }
  .safety-card { align-items: flex-start; }
  .safety-card .pill { display: none; }
  .date-grid, .parameter-grid, .mode-grid, .split-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ab-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
  footer p { text-align: center; }
}
