:root {
  --bg: #070b14; --bg2: #0d1424; --card: #111a2e; --card2: #16223b; --line: #22304d;
  --text: #e4ecf7; --dim: #8b9ab3; --faint: #5b6a85;
  --accent: #3fd0c9; --accent2: #ffb547; --bad: #ff5d6c; --good: #5be08a; --warn: #ffcf5c;
  --m: #a9b8cc; --c: #6ec8ff; --g: #7fe3a4; --e: #ffd166;
  --r: 12px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { background: radial-gradient(1200px 600px at 80% -10%, #12204099, transparent), radial-gradient(800px 500px at -10% 110%, #2a184033, transparent), var(--bg); min-height: 100vh; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
input, select { font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); } .faint { color: var(--faint); } .bad { color: var(--bad); } .good { color: var(--good); } .warn { color: var(--warn); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.btn { border: 0; border-radius: 9px; padding: 10px 14px; background: var(--card2); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn.pri { background: linear-gradient(180deg, #4ee0d8, #2fb3ad); color: #04201f; }
.btn.amb { background: linear-gradient(180deg, #ffc56b, #f0a134); color: #2a1600; }
.btn.danger { background: #3a1820; color: #ffb3bb; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: .45; }
.btn:active:not(:disabled) { transform: translateY(1px); }

/* шапка */
#top { position: sticky; top: 0; z-index: 20; background: #070b14e8; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: calc(var(--safe-t) + 8px) 12px 8px; }
#top .planet { display: flex; align-items: center; gap: 8px; }
#top select { width: auto; flex: 1; padding: 6px 8px; background: var(--card); font-weight: 600; }
.res { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.res div { background: var(--card); border-radius: 8px; padding: 4px 6px; min-width: 0; }
.res b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res span { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.res .full b { color: var(--warn); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }

main { padding: 12px 12px calc(84px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
h2 { font-size: 18px; margin: 4px 0 12px; letter-spacing: .01em; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 10px; }
.card.alert { border-color: #ff5d6c88; background: linear-gradient(180deg, #2a121a, var(--card)); }
.card.locked { opacity: .62; }
.item { display: grid; grid-template-columns: 44px 1fr; gap: 10px; }
.icon { width: 44px; height: 44px; border-radius: 10px; background: var(--card2); display: grid; place-items: center; }
.icon svg { width: 28px; height: 28px; }
.item .title { font-weight: 650; }
.item .lvl { color: var(--accent); font-weight: 700; margin-left: 6px; }
.cost { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; margin: 6px 0; }
.cost .no { color: var(--bad); }
.bar { height: 5px; background: var(--bg2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7ff4ee); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.kv .k { color: var(--dim); }
.tabs2 { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs2 button { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.tabs2 button.on { border-color: var(--accent); color: var(--accent); }

/* нижняя панель */
#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(7, 1fr); background: #0a1020f2; backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
#nav button { background: none; border: 0; padding: 8px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--faint); cursor: pointer; position: relative; }
#nav button svg { width: 22px; height: 22px; }
#nav button.on { color: var(--accent); }
#nav .badge { position: absolute; top: 3px; right: calc(50% - 18px); background: var(--bad); color: #fff; font-size: 10px; border-radius: 9px; padding: 0 5px; min-width: 16px; }

/* галактика */
#map { width: 100%; aspect-ratio: 1; display: block; background: radial-gradient(circle at center, #16203a, #070b14 70%); border-radius: var(--r); border: 1px solid var(--line); touch-action: none; }
.sys td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sys { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sys .pos { width: 22px; color: var(--faint); text-align: center; }
.sys .me { color: var(--accent); }
.tag { display: inline-block; font-size: 10.5px; padding: 0 5px; border-radius: 4px; margin-left: 4px; background: var(--card2); color: var(--dim); }
.tag.i { background: #2b2b2b; color: #bbb; } .tag.n { background: #173a2a; color: var(--good); } .tag.v { background: #1d2a48; color: #9cb8ff; }
.acts { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }

/* отчёты */
.rep { display: flex; gap: 10px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.rep.unread .t { font-weight: 650; }
.rep .k { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.rep.unread .k { background: var(--accent); }
.rep .k.combat { background: var(--bad); } .rep .k.spy { background: var(--c); } .rep .k.msg { background: var(--accent2); }
table.units { width: 100%; border-collapse: collapse; font-size: 13px; }
table.units td, table.units th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.units td:first-child, table.units th:first-child { text-align: left; }
.msgtext { font-size: 16px; padding: 12px; background: var(--card2); border-radius: 10px; border-left: 3px solid var(--accent2); }

/* вход */
.auth { max-width: 380px; margin: 0 auto; padding: calc(var(--safe-t) + 40px) 20px 40px; }
.logo { text-align: center; margin-bottom: 28px; }
.logo svg { width: 92px; height: 92px; }
.logo h1 { margin: 10px 0 4px; font-size: 26px; letter-spacing: .04em; }
.auth label { display: block; font-size: 13px; color: var(--dim); margin: 12px 0 4px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + var(--safe-b)); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: #1d2a44; border: 1px solid var(--line); padding: 9px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 24px #0008; max-width: 90vw; animation: up .2s ease; }
#toast div.err { border-color: #ff5d6c88; color: #ffc3c9; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }
.fleet-row { display: grid; grid-template-columns: 1fr 96px; gap: 8px; align-items: center; margin-bottom: 6px; }
.fleet-row .row { gap: 4px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: var(--card2); color: var(--dim); }
.pill.attack { background: #3a1820; color: #ffb3bb; } .pill.spy { background: #13304a; color: var(--c); } .pill.transport, .pill.deploy { background: #173a2a; color: var(--good); } .pill.colonize { background: #3a2a10; color: var(--accent2); } .pill.recycle { background: #2a2a3a; color: #c9c9ff; }
.mt { margin-top: 10px; } .mb0 { margin-bottom: 0; }
.center { text-align: center; }
details summary { cursor: pointer; color: var(--dim); font-size: 13px; }
