:root {
  --bg: #0a1220; --bg2: #0f1a2e; --panel: #131f36; --panel2: #1a2a47; --line: #25395c;
  --text: #e8f1ff; --dim: #8fa4c7; --accent: #5ad1ff; --accent2: #9be7ff;
  --good: #4fe3a1; --warn: #ffc857; --bad: #ff6b6b; --hot: #ff8a3d;
  --r: 14px; --gut: 16px;
}
:root[data-theme="light"] {
  --bg: #eef4fc; --bg2: #e3edf9; --panel: #ffffff; --panel2: #f0f5fd; --line: #cbd9ee;
  --text: #0e1b33; --dim: #52678a; --accent: #0a84c6; --accent2: #0a6aa0;
  --good: #0f9d6a; --warn: #b87800; --bad: #c9332f; --hot: #c4560f;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef4fc; --bg2: #e3edf9; --panel: #ffffff; --panel2: #f0f5fd; --line: #cbd9ee;
    --text: #0e1b33; --dim: #52678a; --accent: #0a84c6; --accent2: #0a6aa0;
    --good: #0f9d6a; --warn: #b87800; --bad: #c9332f; --hot: #c4560f;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; }
body { min-height: 100dvh; }
#app { max-width: 560px; margin: 0 auto; padding: 0 var(--gut) calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
b { font-weight: 700; }
h2 { font-size: 17px; margin: 18px 0 8px; }
h3 { font-size: 15px; margin: 0 0 4px; }
small, .dim { color: var(--dim); }
.hide { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; padding: calc(12px + env(safe-area-inset-top)) 0 8px; position: relative; }
.brand { font-weight: 800; letter-spacing: .12em; font-size: 16px; }
.logo { color: var(--accent); }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--accent2); }

.aurora::before { content: ""; position: fixed; inset: 0 0 auto 0; height: 160px; pointer-events: none; z-index: 0;
  background: linear-gradient(100deg, transparent 5%, rgba(79,227,161,.28) 30%, rgba(90,209,255,.22) 55%, rgba(180,120,255,.2) 80%, transparent);
  filter: blur(26px); animation: aur 9s ease-in-out infinite alternate; }
@keyframes aur { from { transform: translateX(-8%); opacity: .55; } to { transform: translateX(8%); opacity: 1; } }
#app > * { position: relative; z-index: 1; }

.res { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 10px; }
.res > div { display: flex; flex-direction: column; min-width: 0; }
.res .lbl { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.res b { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res small { font-size: 11px; }
.res-main b { color: var(--accent2); font-size: 22px; }
@media (max-width: 380px) { .res { grid-template-columns: 1fr 1fr; } }

#banners { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.banner { border-radius: 12px; padding: 9px 12px; font-size: 13.5px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.banner b { display: block; }
.banner.bad { background: rgba(255,107,107,.12); border-color: rgba(255,107,107,.5); }
.banner.warn { background: rgba(255,200,87,.1); border-color: rgba(255,200,87,.45); }
.banner.good { background: rgba(79,227,161,.1); border-color: rgba(79,227,161,.45); }
.banner.info { background: rgba(90,209,255,.08); border-color: rgba(90,209,255,.35); }
.banner .ic { font-size: 18px; line-height: 1.1; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-top: 10px; }
.card.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13.5px; }
.kv span:nth-child(odd) { color: var(--dim); }
.kv span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }

/* шкалы */
.gauge { margin: 6px 0 2px; }
.gauge .top2 { display: flex; justify-content: space-between; font-size: 13px; }
.bar { position: relative; height: 12px; border-radius: 7px; background: var(--panel2); overflow: hidden; border: 1px solid var(--line); }
.bar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 7px; transition: width .6s; }
.bar.temp { background: linear-gradient(90deg, #2a6bff 0%, #2a6bff 12.5%, #35c28a 12.5%, #35c28a 50%, #ffc857 50%, #ffc857 68.75%, #ff8a3d 68.75%, #ff8a3d 87.5%, #ff4d4d 87.5%); }
.bar.temp .mark { position: absolute; top: -2px; bottom: -2px; width: 4px; margin-left: -2px; background: #fff; border-radius: 2px; box-shadow: 0 0 6px #000; transition: left .6s; }
.bar.pw i { background: var(--accent); }
.bar.pw.over i { background: var(--warn); }

/* ангар */
.hangar { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 5px; margin-top: 8px; }
.rig { aspect-ratio: 1; border-radius: 7px; border: 1px solid rgba(255,255,255,.12); position: relative; padding: 0; font-size: 11px; color: #fff; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; background: var(--panel2); }
.rig::before { content: ""; position: absolute; left: 4px; right: 4px; top: 5px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.25); box-shadow: 0 5px 0 rgba(255,255,255,.18), 0 10px 0 rgba(255,255,255,.12); }
.rig::after { content: ""; position: absolute; right: 3px; top: 3px; width: 5px; height: 5px; border-radius: 50%; background: #444; }
.rig.on::after { background: var(--good); animation: led 1.4s infinite; }
.rig.broken::after { background: var(--bad); animation: led .5s infinite; }
.rig.broken { outline: 2px solid rgba(255,107,107,.7); filter: saturate(.5); cursor: pointer; }
.rig.idle { opacity: .55; }
.rig.empty { background: transparent; border: 1px dashed var(--line); }
.rig.empty::before, .rig.empty::after { display: none; }
.rig.s9 { background: linear-gradient(160deg, #8a5a2b, #5b3a1a); }
.rig.t17 { background: linear-gradient(160deg, #5f7088, #3b4a63); }
.rig.pp { background: linear-gradient(160deg, #3d8fd1, #25588c); }
.rig.xl { background: linear-gradient(160deg, #7ee3ff, #2a9ec4); box-shadow: 0 0 8px rgba(126,227,255,.45); }
.rig.xl::before { background: rgba(0,40,70,.5); box-shadow: 0 5px 0 rgba(0,40,70,.4), 0 10px 0 rgba(0,40,70,.3); }
@keyframes led { 50% { opacity: .25; } }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--dim); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.btn { background: var(--accent); color: #06233a; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; min-height: 40px; }
.btn.sec { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.bad { background: var(--bad); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: 13px; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { background: transparent; border: 0; border-radius: 8px; padding: 8px 2px; font-size: 13px; color: var(--dim); min-height: 38px; }
.seg button.on { background: var(--accent); color: #06233a; font-weight: 700; }
.seg button small { display: block; font-size: 11px; opacity: .8; color: inherit; }

/* магазин */
.shop-h { display: flex; justify-content: space-between; align-items: baseline; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); }
.tag.dirty { color: #e6a15c; border-color: #8a5a2b; }
.tag.stable { color: var(--accent2); border-color: #2a6e92; }
.stats3 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; font-size: 12px; margin: 6px 0 8px; }
.stats3 div { background: var(--panel2); border-radius: 8px; padding: 4px 6px; }
.stats3 span { display: block; color: var(--dim); font-size: 11px; }
.price { font-weight: 700; color: var(--accent2); }
.need { color: var(--warn); font-size: 12px; margin-top: 4px; }

/* лента */
.feed { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.feed li { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; }
.feed li.bad { border-left-color: var(--bad); } .feed li.warn { border-left-color: var(--warn); } .feed li.good { border-left-color: var(--good); }
.feed .when { color: var(--dim); font-size: 11.5px; }

/* таблица */
table.lb { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lb td, table.lb th { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.lb th { color: var(--dim); font-weight: 500; font-size: 12px; }
table.lb td.n, table.lb th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.lb tr.me td { background: rgba(90,209,255,.12); font-weight: 700; }
table.lb tr.ghost td:nth-child(2) { color: var(--dim); }

.cos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cos > div { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.cos > div.off { opacity: .45; }
.cos b { display: block; }

input[type=text] { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 16px; width: 100%; }
.spark { width: 100%; height: 70px; display: block; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--bg2); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20; max-width: 560px; margin: 0 auto; }
.tabs button { background: transparent; border: 0; padding: 8px 2px 7px; font-size: 11.5px; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 56px; }
.tabs button i { font-style: normal; font-size: 19px; line-height: 1; }
.tabs button.on { color: var(--accent2); }
.tabs button .dot { position: absolute; margin: -2px 0 0 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

#toasts { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 50; pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: pop .25s; max-width: 92vw; }
.toast.bad { border-color: var(--bad); } .toast.good { border-color: var(--good); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden] { display: none; }
#modal .sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 16px var(--gut) calc(16px + env(safe-area-inset-bottom)); width: 100%; max-width: 560px; max-height: 85dvh; overflow: auto; }
.over-note { text-align: center; color: var(--dim); font-size: 13px; margin: 14px 0; }
.p { margin: 6px 0; } .p + .p { margin-top: 8px; }
ul.rules { padding-left: 18px; margin: 6px 0; } ul.rules li { margin: 4px 0; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
