:root {
  --bg: #07131c;
  --bg-2: #0a1822;
  --surface: #102231;
  --surface-2: #173044;
  --line: #234258;
  --text: #e7f4f8;
  --muted: #8eacbc;
  --accent: #2ad4e6;
  --purple: #7a3ff2;
  --ink: #042028;
  --danger: #ff5d73;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --font: "Outfit", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --side: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(720px 280px at 100% -8%, rgba(42, 212, 230, 0.14), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, .btn { cursor: pointer; }
a { color: inherit; }

.shell { display: flex; min-height: 100vh; }
.side {
  width: var(--side);
  flex: 0 0 var(--side);
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand-logo { height: 46px; width: auto; display: block; }
.login-card .brand-logo { height: 88px; margin-bottom: 18px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a, .nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--muted);
  background: transparent;
  border: 0;
  text-align: left;
  width: 100%;
}
.nav a.active, .nav a:hover, .nav button:hover {
  background: var(--surface);
  color: var(--text);
}
.side form { margin-top: auto; }
.main { flex: 1; padding: 32px 28px 64px; max-width: 1080px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0; }

h1 { font-size: 34px; line-height: 1.15; letter-spacing: -0.04em; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: -0.03em; }
.lead { color: var(--muted); margin: 0 0 24px; max-width: 62ch; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.mono, .lead { overflow-wrap: anywhere; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stat, .card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat { padding: 16px 18px; }
.stat b { display: block; font-size: 28px; letter-spacing: -0.04em; }
.stat span { color: var(--muted); font-size: 13px; }
.card { padding: 18px; }
.panel { padding: 18px; margin-bottom: 16px; }

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.num {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--ink); font-size: 13px; font-weight: 700;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.mono, code, .log { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid transparent; text-decoration: none; background: var(--surface-2); gap: 8px;
}
.btn.primary { background: var(--accent); color: var(--ink); font-weight: 650; }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(255, 93, 115, 0.5); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select {
  width: 100%; min-height: 44px; padding: 0 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label {
  margin: 0; color: var(--text); min-height: 44px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 999px; padding: 0 12px;
  background: var(--bg);
}
.checks input { width: auto; min-height: 0; accent-color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; letter-spacing: 0.04em;
  border: 1px solid var(--line); color: var(--muted); text-transform: uppercase;
}
.badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: block; }
.badge.ok { color: var(--ink); background: var(--accent); border-color: var(--accent); }
.badge.ok i { background: var(--ink); }
.badge.bad { color: var(--danger); border-color: rgba(255, 93, 115, 0.5); }
.badge.bad i { background: var(--danger); }
.badge.run { color: var(--text); }
.badge.run i { background: var(--accent); }

.flash {
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.flash.ok { border-color: var(--accent); }
.flash.bad { border-color: var(--danger); color: #ffd2c6; }

.log {
  margin: 0; max-height: 360px; overflow: auto; white-space: pre-wrap;
  background: #061018; color: #d5eef3; border-radius: 12px; padding: 14px;
  font-size: 12.5px; line-height: 1.45;
}
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.meter-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.meter-top b { color: var(--text); font-size: 18px; letter-spacing: -0.03em; }
.meter-track { height: 8px; border-radius: 99px; background: var(--bg); margin-top: 8px; overflow: hidden; }
.meter-track span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; }
.meter-track.alt span { background: var(--purple); }
textarea {
  width: 100%; min-height: 88px; padding: 10px 12px; resize: vertical;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.stat-note { min-height: 1.2em; }

.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 460px) 1fr;
}
.login-card { padding: 48px 36px; display: flex; flex-direction: column; justify-content: center; }
.login-aside {
  margin: 18px; border-radius: 24px; background: var(--surface);
  border: 1px solid var(--line); padding: 36px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 18px;
}
.flow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flow div {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 120px;
}
.flow b { display: block; }
.flow em { font-style: normal; color: var(--accent); font-family: var(--mono); font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  .shell { display: block; }
  .side {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    width: auto; height: auto;
    z-index: 20;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: rgba(10, 24, 34, 0.96);
  }
  .mark {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--line);
    z-index: 19;
  }
  .brand-logo { height: 36px; }
  .nav { flex-direction: row; flex: 1; gap: 2px; }
  .side form { margin: 0; flex: 1; display: flex; }
  .nav a, .nav button, .side form .btn {
    width: 100%;
    min-height: 52px;
    padding: 6px 2px;
    justify-content: center;
    text-align: center;
    font-size: 11px;
    line-height: 1.15;
    border-radius: 10px;
  }
  .main { padding: 72px 14px 108px; max-width: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .fields, .login-wrap, .meters { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .login-aside { display: none; }
  .login-card .btn { width: 100%; }
  .login-card .brand-logo { height: auto; width: min(220px, 100%); }
  h1 { font-size: 26px; }
  .page-head { align-items: stretch; }
  .page-head .btn, .actions form, .actions .btn, .actions button, td .btn { width: 100%; }
  .actions { flex-direction: column; }
  table, thead, tbody, tr, th, td { display: block; width: 100%; }
  thead { display: none; }
  tr {
    margin: 0 0 12px;
    padding: 8px 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg);
  }
  td { border: 0; padding: 8px; }
  td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  td[data-label=""]::before { content: none; }
  .meter-top { align-items: flex-start; flex-wrap: wrap; }
  .meter-top b { font-size: 16px; }
  input, select, textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
