/* app.css — «Петербургский атлас»: тёмная графитовая оправа + карта-пергамент. */

:root {
  --ink: #15212c;
  --ink-1: #182835;
  --ink-2: #111d27;
  --surface: #1d2c39;
  --surface-2: #223444;
  --surface-hover: #243747;
  --line: rgba(150,172,192,0.14);
  --line-2: rgba(150,172,192,0.26);
  --text: #e9eff4;
  --muted: #8fa5b5;
  --gold: #e6b765;
  --green: #38ab8d;
  --green-deep: #1E6F5C;
  --ochre: #d8943c;
  --blue: #5b97d1;
  --loss: #e0655f;
  --gain: #57c08b;
  --paper: #f4ecd7;
  --paper-2: #ece2c6;
  --paper-line: #d8caa4;
  --ink-text: #2c2416;
  --font-display: Georgia, "Times New Roman", "PT Serif", serif;
  --font-ui: "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 6px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--ink-2);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- иконки ---------- */
.ic { width: 1.05em; height: 1.05em; vertical-align: -0.16em; flex: none; }
svg.ic { stroke-width: 1.7; }

/* ---------- HUD ---------- */
#hud {
  display: flex; align-items: center; gap: 20px;
  height: 60px; padding: 0 18px;
  background: linear-gradient(180deg, var(--ink-1), var(--ink-2));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(230,183,101,0.18), var(--shadow);
  z-index: 20; position: relative;
  animation: hud-in .5s ease both;
}
#hud::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(230,183,101,0.5), transparent);
}
.hud-brand { display: flex; align-items: center; gap: 11px; min-width: 218px; }
.hud-brand .logo { color: var(--gold); display: inline-flex; }
.hud-brand .logo .ic { width: 26px; height: 26px; }
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--gold); letter-spacing: .03em; }

.hud-stats { display: flex; gap: 28px; flex: 1; align-items: center; }
.stat { display: flex; flex-direction: column; gap: 1px; min-width: 116px; }
.stat-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat-val { font-size: 18px; font-weight: 700; }
#hud-profit { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat-goal { min-width: 170px; }
.goal { width: 170px; height: 6px; background: rgba(255,255,255,.08); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.goal-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .5s ease; }

.hud-controls { display: flex; align-items: center; gap: 6px; }
.ctl {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.03); color: var(--text);
  border-radius: 9px; height: 36px; min-width: 40px; padding: 0 10px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 700; cursor: pointer;
  transition: .14s ease;
}
.ctl:hover { background: rgba(255,255,255,.08); border-color: var(--gold); }
.ctl.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.ctl.pause.active { background: var(--ochre); border-color: var(--ochre); }
.icon-btn .ic, .ctl.pause .ic { width: 18px; height: 18px; }
.ctl-sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 5px; }

/* ---------- разметка ---------- */
#app { display: flex; flex: 1; min-height: 0; }
.panel {
  width: 304px; flex-shrink: 0; overflow-y: auto;
  background: linear-gradient(180deg, var(--ink-1), var(--ink-2));
  border-right: 1px solid var(--line); padding: 12px;
}
#right { border-right: none; border-left: 1px solid var(--line); }
#stage { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #0c141b; }
#map { position: absolute; inset: 0; background: #0c141b; }
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 650; }

/* ---------- панели ---------- */
.panel-sec { margin-bottom: 16px; }
.sec-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text);
  padding: 2px 2px 9px; margin-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.sec-head > span:first-child { display: inline-flex; align-items: center; gap: 7px; }
.sec-head .ic { width: 16px; height: 16px; color: var(--gold); }
.muted { color: var(--muted); font-weight: 500; }
.bad { color: var(--loss); font-weight: 700; }
.risk { color: var(--loss); font-size: 11px; display: flex; align-items: center; gap: 4px; margin-top: 3px; line-height: 1.3; }
.risk .ic { width: 13px; height: 13px; color: var(--loss); flex: none; }
.risk-box { background: rgba(198,40,40,.08); border: 1px solid rgba(198,40,40,.3); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.risk-box .risk { font-size: 12px; }
.empty { color: var(--muted); font-size: 12px; padding: 8px 4px; font-style: italic; opacity: .85; }

.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 11px; margin-bottom: 8px; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-1px); border-color: var(--line-2); background: var(--surface-hover); box-shadow: var(--shadow); }
.card.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(91,151,209,.3); }
.card.offer { background: linear-gradient(180deg, rgba(230,183,101,.12), rgba(230,183,101,.05)); border-color: rgba(230,183,101,.35); }
.card.offer::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--ochre); }
.card.incident { background: rgba(224,101,95,.08); border-color: rgba(224,101,95,.28); }
.card.incident.breached { background: rgba(224,101,95,.16); border-color: rgba(224,101,95,.5); }
.card-title { font-weight: 700; font-size: 13px; margin-bottom: 3px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.card-title .ic { width: 15px; height: 15px; color: var(--muted); }
.card-sub { font-size: 12px; line-height: 1.45; color: #cdd9e2; }
.card-sub b { color: var(--gain); font-weight: 700; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.chip {
  display: inline-block; font-size: 10px; background: rgba(56,171,141,.18); color: var(--green);
  padding: 1px 7px; border-radius: 10px; font-weight: 800; letter-spacing: .02em;
}

/* ---------- кнопки ---------- */
.btn {
  border: 1px solid var(--line-2); background: rgba(255,255,255,.04); color: var(--text);
  border-radius: 9px; padding: 8px 13px; font-family: var(--font-ui); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: .14s ease; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn:hover { border-color: var(--gold); background: rgba(255,255,255,.09); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; margin-top: 5px; }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn.primary { background: var(--green-deep); color: #fff; border-color: var(--green-deep); }
.btn.primary:hover { background: #18604f; border-color: var(--green); }
.btn.ghost { background: transparent; }

/* ---------- баннер ---------- */
.banner {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: rgba(21,33,44,.95); color: #fff; padding: 10px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 600; border: 1px solid rgba(230,183,101,.4);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .3s ease;
  max-width: 80%; text-align: center; z-index: 1200;
}
.banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.banner.bad { border-color: var(--loss); background: rgba(120,30,28,.96); }

/* ---------- модалки (бумага) ---------- */
#modal-root { position: fixed; inset: 0; z-index: 3000; }
#modal-root.hidden { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,18,25,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 3000;
  animation: fade-in .2s ease;
}
.modal {
  background: var(--paper); color: var(--ink-text);
  border-radius: 14px; width: 470px; max-width: 92vw; max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--paper-line);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  animation: pop-in .26s cubic-bezier(.2,.8,.2,1);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-display); font-size: 19px; font-weight: 700; color: #3a2f1c;
  padding: 15px 18px; border-bottom: 1px solid var(--paper-line);
  background: linear-gradient(180deg, rgba(255,255,255,.4), transparent);
}
.modal-head .x { border: none; background: none; font-size: 18px; cursor: pointer; color: #8a795a; line-height: 1; }
.modal-head .x:hover { color: var(--loss); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-body .ic { color: #6a5a38; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 13px 18px; border-top: 1px solid var(--paper-line);
  background: rgba(0,0,0,.02);
}
.modal-foot .btn { background: rgba(0,0,0,.04); border-color: var(--paper-line); color: var(--ink-text); }
.modal-foot .btn:hover { border-color: var(--ochre); background: rgba(0,0,0,.07); }
.modal-foot .btn.primary { background: var(--green-deep); color: #fff; border-color: var(--green-deep); }
.modal-foot .btn.primary:hover { background: #18604f; }
.kv { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.kv span { color: #7a6a48; }
.kv b { font-weight: 700; }
.sep { height: 1px; background: var(--paper-line); margin: 11px 0; }
.row { padding: 7px 0; border-bottom: 1px dashed var(--paper-line); }
.row-t { font-weight: 700; font-size: 13px; }
.row-s { font-size: 12px; color: #6a5a40; }
.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 12px; color: #7a6a48; margin-bottom: 5px; font-weight: 700; }
.field select {
  width: 100%; padding: 9px; border: 1px solid var(--paper-line); border-radius: 9px;
  font-size: 13px; font-family: inherit; background: #fbf6e8; color: var(--ink-text);
}
.radios { display: flex; flex-direction: column; gap: 8px; }
.radio { display: block; font-size: 13px; padding: 9px 10px; border: 1px solid var(--paper-line); border-radius: 9px; cursor: pointer; background: #fbf6e8; transition: .12s; }
.radio:hover { border-color: var(--ochre); }
.radio:has(input:checked) { border-color: var(--green-deep); box-shadow: 0 0 0 2px rgba(30,111,92,.15); }
.radio input { margin-right: 6px; }
.radio .ic { width: 15px; height: 15px; vertical-align: -3px; color: var(--ink-text); }
.modal-body p { line-height: 1.55; }

/* ---------- скроллбары ---------- */
.panel::-webkit-scrollbar, .modal-body::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb { background: rgba(150,172,192,.25); border-radius: 5px; }
.panel::-webkit-scrollbar-thumb:hover { background: rgba(150,172,192,.4); }
.modal-body::-webkit-scrollbar-thumb { background: var(--paper-line); border-radius: 5px; }

/* ---------- анимации ---------- */
@keyframes hud-in { from { opacity: 0; transform: translateY(-100%); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- Leaflet ---------- */
.game-tiles { filter: saturate(0.9) brightness(1.02) contrast(1.02); }
.leaflet-container { background: #0c141b; font-family: var(--font-ui); }
.leaflet-control-zoom a {
  background: rgba(21,33,44,.92) !important; color: var(--text) !important;
  border-color: var(--line-2) !important;
}
.leaflet-control-zoom a:hover { background: rgba(34,52,68,.95) !important; color: var(--gold) !important; }
.leaflet-control-attribution {
  background: rgba(21,33,44,.7) !important; color: #9fb2c0 !important; font-size: 10px;
}
.leaflet-control-attribution a { color: var(--gold) !important; }
.leaflet-control-scale-line {
  background: rgba(21,33,44,.7); color: #dfe8ef; border-color: rgba(230,183,101,.5);
}

/* подписи районов */
.distlabel-wrap { background: transparent !important; border: none !important; width: auto !important; height: auto !important; }
.distlabel {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  transform: translate(-50%, -50%);
  font-family: var(--font-display); font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; pointer-events: none;
}
.distlabel .dl-name { text-shadow: 0 1px 2px rgba(255,255,255,.85), 0 0 2px rgba(255,255,255,.9); }
.distlabel.unlocked .dl-name { color: #14503f; font-size: 14px; }
.distlabel.locked .dl-name { color: #4a5a66; font-size: 12px; opacity: .9; }
.distlabel .dl-lock { display: inline-flex; color: #5a6b77; }
.distlabel .dl-lock .ic { width: 12px; height: 12px; }

@media (max-width: 980px) {
  .panel { width: 250px; }
  .hud-stats { gap: 16px; }
  .stat { min-width: 88px; }
  .stat-goal { min-width: 120px; } .goal { width: 120px; }
}
