:root {
  --bg: #0a0f11;
  --panel: rgba(10, 16, 18, 0.9);
  --line: #24343a;
  --text: #d6e2e5;
  --dim: #74898f;
  --accent: #f2a33a;
  --cyan: #7fe3ff;
  --danger: #ff5a4f;
  --ok: #8fe388;
  --r-water: #6fd3ff;
  --r-food: #f2c94e;
  --r-parts: #a9b7bc;
  --r-medicine: #ff7a7a;
  --r-battery: #b493ff;
  --r-filter: #7fe0b0;
  --r-antirad: #c6ff4f;
  --r-chip: #f07cf5;
  --r-fuel: #ff8a3d;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --head: "Rajdhani", system-ui, sans-serif;
  --cut: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--mono); font-size: 13px; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

#map { position: fixed; inset: 0; }
.scan {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    repeating-linear-gradient(0deg, rgba(127, 227, 255, 0.02) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.6));
}

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 0;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-left, .hud-right { display: flex; align-items: center; gap: 10px; background: var(--panel); padding: 8px 10px; clip-path: var(--cut); border-left: 2px solid var(--cyan); }
.hud-right { border-left: none; border-right: 2px solid var(--accent); }
.hp { display: flex; gap: 3px; align-items: center; }
.hp i { width: 14px; height: 8px; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); transform: skewX(-20deg); }
.hp i.empty { background: transparent; box-shadow: inset 0 0 0 1px #3c5158; }
.hp .shield { margin-left: 6px; font-size: 10px; color: var(--accent); border: 1px solid var(--accent); padding: 0 4px; letter-spacing: 0.1em; }
.day { font-family: var(--head); font-weight: 700; letter-spacing: 0.15em; font-size: 14px; }
.deadline { flex-basis: 100%; margin-top: 6px; font-size: 11px; color: var(--dim); letter-spacing: 0.12em; padding-left: 2px; text-shadow: 0 1px 2px #000; }
.deadline b { color: var(--text); font-weight: 600; }
.badge { font-size: 10px; letter-spacing: 0.15em; padding: 3px 6px; border: 1px solid var(--line); color: var(--dim); }
.badge.gps { color: var(--ok); border-color: var(--ok); }
.badge.sim { color: var(--accent); border-color: var(--accent); }
.icon-btn { font-size: 20px; line-height: 1; padding: 0 2px; color: var(--accent); }

/* ---------- Нижняя панель ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 520px; margin: 0 auto;
  background: var(--panel); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  clip-path: polygon(0 14px, 14px 0, 100% 0, 100% 100%, 0 100%);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; flex-direction: column; max-height: 52vh;
}
.sheet-head { display: flex; justify-content: space-between; width: 100%; padding: 12px 16px 6px; font-family: var(--head); font-weight: 700; font-size: 13px; letter-spacing: 0.2em; color: var(--accent); }
.sheet .chev { transition: transform 0.2s; }
.sheet.collapsed .chev { transform: rotate(180deg); }
.sheet.collapsed .sheet-body { display: none; }
.sheet-body { overflow-y: auto; padding: 0 16px; }

.manifest { list-style: none; margin: 4px 0 0; padding: 0; }
.m-tier { display: flex; justify-content: space-between; margin-top: 8px; padding: 2px 0; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.m-tier span { letter-spacing: 0.05em; text-transform: none; }
.m-tier.t3 { color: var(--accent); }
.m-row { display: grid; grid-template-columns: 40px 1fr auto 44px; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #1c282c; }
.m-row .code { font-weight: 600; color: var(--c); }
.m-row .m-name { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-row .m-num { text-align: right; }
.m-row.done .m-num { color: var(--ok); }
.cells { display: flex; gap: 3px; }
.cells i { width: 12px; height: 12px; border: 1px solid #3c5158; transform: skewX(-15deg); }
.cells i.full { background: var(--c); border-color: var(--c); box-shadow: 0 0 6px var(--c); }
.cells i.carried { border-color: var(--c); background: repeating-linear-gradient(45deg, var(--c) 0 2px, transparent 2px 4px); }
.cells i.extra { border-style: dashed; border-color: var(--c); background: var(--c); opacity: 0.5; }
.m-foot { padding: 6px 0 2px; font-size: 11px; color: var(--dim); }
.m-foot b { color: var(--accent); font-weight: 600; }

.route { padding: 8px 0 10px; font-size: 12px; color: var(--dim); }
.route .r-main { color: var(--text); }
.route .r-main b { color: var(--accent); }
.route .warn { color: var(--danger); }
.route .ok { color: var(--ok); }
.route .r-btns { display: flex; gap: 8px; margin-top: 6px; }

.actions { padding: 8px 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.hint { font-size: 11px; color: var(--dim); text-align: center; letter-spacing: 0.05em; }

.btn {
  display: block; width: 100%; padding: 12px; text-align: center;
  font-family: var(--head); font-weight: 700; font-size: 15px; letter-spacing: 0.2em; text-transform: uppercase;
  background: var(--accent); color: #140c02; clip-path: var(--cut);
}
.btn.cyan { background: var(--cyan); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.btn.small { display: inline-block; width: auto; padding: 6px 10px; font-size: 12px; }

/* ---------- Карточка точки ---------- */
.card { margin: 6px 0 8px; padding: 10px 12px; background: #0f181b; border-left: 2px solid var(--accent); clip-path: var(--cut); }
.card-title { font-family: var(--head); font-weight: 700; font-size: 16px; letter-spacing: 0.05em; }
.card-sub { font-size: 11px; color: var(--dim); margin: 2px 0 8px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 11px; font-weight: 600; padding: 2px 6px; color: var(--c); border: 1px solid var(--c); }
.chip.need { background: var(--c); color: #071012; }

/* ---------- Маркеры ---------- */
.pt { display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: opacity 0.2s, transform 0.15s; }
.pt-body { display: flex; gap: 4px; padding: 2px 5px; background: rgba(8, 12, 14, 0.92); border: 1px solid #3c5158; font: 600 10px var(--mono); position: relative; }
.pt-body i { font-style: normal; color: var(--c); }
.pt::after { content: ""; width: 1px; height: 7px; background: #3c5158; }
.pt.needed .pt-body { border-color: var(--accent); box-shadow: 0 0 10px rgba(242, 163, 58, 0.35); }
.pt.needed::after { background: var(--accent); }
.pt.cache .pt-body { border-style: dashed; }
.pt.scatter .pt-body { font-size: 9px; padding: 1px 4px; opacity: 0.85; }
.pt.scatter:not(.needed) .pt-body { border-color: #2b3a40; }
.pt.selected { transform: scale(1.18); z-index: 5; }
.pt.selected .pt-body { border-color: #fff; }
.pt.collected { opacity: 0.25; filter: grayscale(1); }
.pt-ord { position: absolute; top: -9px; right: -9px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; background: var(--accent); color: #140c02; font-size: 10px; line-height: 16px; text-align: center; display: none; }
.pt.planned .pt-ord { display: block; }

.player { width: 16px; height: 16px; border-radius: 50%; background: var(--cyan); border: 2px solid #e9fbff; box-shadow: 0 0 14px var(--cyan); position: relative; }
.player::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 1px solid var(--cyan); animation: ping 2s infinite; }
@keyframes ping { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

.base { display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.base-hex { width: 34px; height: 30px; background: var(--accent); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); display: grid; place-items: center; }
.base-hex::before { content: ""; width: 26px; height: 22px; background: #140c02; clip-path: inherit; }
.base-label { margin-top: 3px; font: 600 9px var(--mono); letter-spacing: 0.2em; color: var(--accent); text-shadow: 0 0 4px #000; }

/* ---------- Тост и модалка ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 92px); z-index: 30; transform: translate(-50%, -10px);
  padding: 8px 14px; background: var(--panel); border: 1px solid var(--accent); color: var(--accent);
  font-weight: 600; letter-spacing: 0.1em; opacity: 0; pointer-events: none; transition: 0.25s; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; padding: 16px; }
.modal.hidden { display: none; }
.modal-box { width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; background: #0d1517; border-top: 2px solid var(--accent); clip-path: var(--cut); padding: 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.modal-box h2 { margin: 0 0 4px; font-family: var(--head); letter-spacing: 0.2em; font-size: 20px; }
.modal-box h2.fail { color: var(--danger); }
.modal-box h2.ok { color: var(--ok); }
.modal-box p { margin: 0; color: var(--dim); line-height: 1.5; }
.modal-box .stat { display: flex; justify-content: space-between; border-bottom: 1px dashed #1c282c; padding: 4px 0; }
.modal-box .stat b { font-weight: 600; }
.modal-box .sep { height: 6px; }
.seg { display: flex; gap: 6px; }
.seg .btn { flex: 1; }
.seg .btn:not(.on) { background: transparent; color: var(--dim); box-shadow: inset 0 0 0 1px var(--line); }

.maplibregl-ctrl-attrib { background: rgba(10, 15, 17, 0.7) !important; color: var(--dim); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--dim) !important; }
.maplibregl-ctrl-bottom-right { bottom: auto; top: calc(env(safe-area-inset-top) + 86px); }
