:root {
  color-scheme: dark;
  --bg: #04090c;
  --surface: #091217;
  --surface-2: #0d1b21;
  --surface-3: #10252d;
  --line: #17343e;
  --line-hot: #2dc8e6;
  --text: #e8f8fb;
  --muted: #82a3ad;
  --electric: #25d5f4;
  --electric-soft: #8cecff;
  --lime: #b8fb43;
  --amber: #ffce55;
  --danger: #ff6378;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(37, 213, 244, .13), transparent 30rem),
    linear-gradient(rgba(37, 213, 244, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 213, 244, .022) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 48px 48px, 48px 48px, auto;
}

button, input { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1780px, 100%); margin: 0 auto; padding: 0 24px 36px; }
main, .work-grid, .panel, .standings-panel, .summary-card { min-width: 0; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark, .login-bolt {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--electric);
  color: var(--lime);
  background: rgba(37, 213, 244, .08);
  box-shadow: inset 0 0 18px rgba(37, 213, 244, .09), 0 0 18px rgba(37, 213, 244, .08);
  font-size: 25px;
  font-weight: 900;
  transform: skew(-7deg);
}
.brand strong { display: block; letter-spacing: .13em; font-size: 15px; }
.brand span:not(.brand-mark) { color: var(--muted); font-size: 12px; letter-spacing: .17em; }

.topbar-status { display: flex; align-items: center; gap: 15px; color: var(--muted); font-size: 13px; font-weight: 700; }
.connection { display: inline-flex; align-items: center; gap: 7px; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px currentColor; }
.connection.live i { background: var(--lime); }
.connection.error i { background: var(--danger); }
.icon-button, .text-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  padding: 0 13px;
}
.icon-button { width: 38px; padding: 0; font-size: 19px; }
.icon-button:hover, .text-button:hover { border-color: var(--electric); color: var(--electric-soft); }

main { padding-top: 18px; }

.command-strip {
  display: grid;
  grid-template-columns: minmax(210px, 1.3fr) minmax(220px, 1fr) minmax(140px, .75fr) minmax(170px, .75fr);
  align-items: stretch;
  border: 1px solid var(--line-hot);
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(90deg, rgba(37, 213, 244, .1), rgba(9, 18, 23, .96) 34%);
  box-shadow: 0 0 32px rgba(37, 213, 244, .055);
}
.command-strip > div { min-height: 88px; padding: 16px 20px; display: flex; flex-direction: column; justify-content: center; }
.command-strip > div + div { border-left: 1px solid var(--line); }
.eyebrow { color: var(--electric); font-size: 12px; font-weight: 900; letter-spacing: .13em; }
.phase-block strong { margin-top: 6px; font-size: 17px; letter-spacing: .04em; }
.countdown { align-items: center; font: 800 clamp(28px, 3vw, 43px)/1 "Arial Narrow", Inter, sans-serif; color: var(--electric-soft); letter-spacing: .08em; }
.risk-block span { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .07em; }
.risk-block strong { margin-top: 5px; color: var(--lime); font-size: 27px; }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(135px, 1fr)); gap: 10px; margin-top: 12px; }
.summary-card {
  min-height: 108px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
}
.summary-card.primary { border-color: rgba(37, 213, 244, .65); background: linear-gradient(145deg, rgba(37, 213, 244, .13), var(--surface)); }
.summary-card.observed { border-style: dashed; }
.summary-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.summary-card strong { display: block; margin: 5px 0 4px; color: var(--text); font-size: 29px; line-height: 1; }
.summary-card.primary strong { color: var(--electric-soft); }
.summary-card small { color: #678791; font-size: 12px; }

.work-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 12px; margin-top: 12px; }
.rail { display: grid; gap: 12px; align-content: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(9, 18, 23, .95); overflow: hidden; }
.panel-heading { min-height: 77px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-heading.compact { min-height: 66px; }
h1, h2 { margin: 3px 0 0; line-height: 1.1; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
.legend { color: var(--muted); font-size: 12px; white-space: nowrap; }
.legend i, .legend b { display: inline-block; width: 8px; height: 8px; margin: 0 5px 0 10px; border-radius: 50%; background: var(--lime); }
.legend b { background: var(--electric); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 1000px; border-collapse: collapse; }
th, td { height: 52px; padding: 9px 13px; border-bottom: 1px solid rgba(23, 52, 62, .72); text-align: left; }
th { position: sticky; top: 0; z-index: 2; color: var(--muted); background: #081116; font-size: 12px; font-weight: 800; letter-spacing: .045em; }
th span { font-weight: 500; }
td { font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(37, 213, 244, .045); }
tbody tr.high-voltage td { background: rgba(37, 213, 244, .09); }
tbody tr.high-voltage td:first-child { box-shadow: inset 3px 0 var(--electric); }
.rank { width: 42px; color: var(--muted); }
.number { text-align: right; font-variant-numeric: tabular-nums; }
td.number { font-size: 15px; font-weight: 800; }
.team-name { display: flex; align-items: center; gap: 9px; font-weight: 800; white-space: nowrap; }
.team-dot { width: 8px; height: 8px; border-radius: 2px; background: #48616a; }
.high-voltage .team-dot { background: var(--electric); box-shadow: 0 0 11px rgba(37, 213, 244, .8); }
.target-cell { color: #c8e4ea; white-space: nowrap; }
.target-cell strong { color: var(--electric-soft); }
.coverage-meter { min-width: 86px; }
.coverage-meter span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.coverage-track { height: 4px; border-radius: 99px; background: #163039; overflow: hidden; }
.coverage-track i { display: block; height: 100%; background: var(--electric); }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.target-bars { padding: 17px; }
.target-bar + .target-bar { margin-top: 15px; }
.target-meta { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 13px; font-weight: 700; }
.target-meta span:last-child { color: var(--electric-soft); font-variant-numeric: tabular-nums; }
.bar-track { height: 7px; border-radius: 99px; overflow: hidden; background: #142b33; }
.bar-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #168eab, var(--electric)); }

.integrity-panel { padding: 18px; }
.integrity-panel h2 { margin-bottom: 16px; }
.integrity-panel dl { margin: 0; }
.integrity-panel dl div { display: flex; justify-content: space-between; gap: 15px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.integrity-panel dt { color: var(--muted); }
.integrity-panel dd { margin: 0; font-weight: 800; }
.integrity-panel .official { color: var(--lime); }
.integrity-panel .observed-label { color: var(--electric); }
.integrity-panel p { margin: 15px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.recent-panel { margin-top: 12px; }
.feed-count { color: var(--muted); font-size: 12px; font-weight: 800; }
.recent-feed { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
.recent-event { min-height: 82px; padding: 14px 17px; background: var(--surface); }
.recent-event time { color: var(--muted); font-size: 11px; }
.recent-event p { margin: 7px 0 0; font-size: 13px; line-height: 1.4; }
.recent-event strong { color: var(--electric-soft); }

.collector-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 12px;
  padding: 18px;
  border: 1px dashed rgba(37, 213, 244, .55);
  border-radius: var(--radius);
  background: rgba(37, 213, 244, .04);
}
.collector-card h2 { margin-top: 4px; }
.collector-card p { max-width: 820px; margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.collector-card a { flex: none; padding: 11px 15px; border-radius: 8px; color: #031013; background: var(--electric); font-size: 13px; font-weight: 900; text-decoration: none; }

.login-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line-hot);
  border-radius: 14px;
  color: var(--text);
  background: #071014;
  box-shadow: 0 30px 100px #000, 0 0 55px rgba(37, 213, 244, .1);
}
.login-dialog::backdrop { background: rgba(0, 5, 8, .86); backdrop-filter: blur(8px); }
.login-dialog form { padding: 28px; }
.login-dialog .login-bolt { margin-bottom: 22px; }
.login-dialog h2 { margin-top: 6px; font-size: 29px; }
.login-dialog p { color: var(--muted); line-height: 1.5; }
.login-dialog label { display: block; margin: 20px 0 7px; color: #bed2d7; font-size: 13px; font-weight: 800; }
.key-row { display: flex; gap: 8px; }
.key-row input { min-width: 0; flex: 1; height: 46px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; color: var(--text); background: #03090c; outline: none; }
.key-row input:focus { border-color: var(--electric); box-shadow: 0 0 0 3px rgba(37, 213, 244, .11); }
.key-row button { height: 46px; border: 0; border-radius: 8px; padding: 0 16px; color: #031013; background: var(--electric); font-weight: 900; }
.login-message { min-height: 20px; margin: 10px 0 0 !important; color: var(--danger) !important; font-size: 13px; }
.demo-button { border: 0; padding: 4px 0; color: var(--muted); background: transparent; text-decoration: underline; font-size: 12px; }

@media (max-width: 1120px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .work-grid { grid-template-columns: 1fr; }
  .rail { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .shell { padding: 0 10px 24px; }
  .topbar { min-height: 68px; }
  .topbar-status .connection, .topbar-status time { display: none; }
  .topbar-status { gap: 7px; }
  .command-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .command-strip > div { min-height: 78px; padding: 13px 15px; }
  .command-strip > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .command-strip > div:nth-child(4) { border-top: 1px solid var(--line); }
  .countdown { overflow: hidden; font-size: clamp(22px, 7vw, 27px); letter-spacing: .03em; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card { min-height: 97px; }
  .summary-card span { overflow-wrap: anywhere; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .legend { white-space: normal; }
  .rail { grid-template-columns: 1fr; }
  .recent-feed { grid-template-columns: 1fr; }
  .key-row { flex-direction: column; }
  .key-row button { width: 100%; }
  .collector-card { align-items: stretch; flex-direction: column; }
  .collector-card a { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
