:root {
  color-scheme: dark;
  --bg: #0c0f0d;
  --panel: #141916;
  --panel-border: #232c26;
  --panel-active: #1d2520;
  --accent: #d8e994;
  --accent-cyan: #38bdf8;
  --accent-amber: #f59e0b;
  --accent-gold: #fbbf24;
  --accent-green: #4ade80;
  --accent-red: #ef4444;
  --text-primary: #edf0e9;
  --text-muted: #8e9c91;
  --text-dark: #536057;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-sans: system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font: 13px/1.4 var(--font-sans);
  overflow-x: hidden;
}

#app {
  max-width: 1720px;
  margin: 0 auto;
  padding: 0 24px 32px;
}

button, a { touch-action: manipulation; }
button {
  font: inherit;
  cursor: pointer;
  background: #1e2621;
  color: inherit;
  border: 1px solid var(--panel-border);
  padding: 8px 12px;
  border-radius: 3px;
  transition: all 0.15s ease;
}
button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #2a3528;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
a { color: var(--accent); text-decoration: none; }

/* HEADER */
header.base-header {
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--panel-border);
  padding: 16px 0;
}
.brand {
  font-weight: 800;
  letter-spacing: 2px;
  color: #edf0e9;
  font-size: 15px;
}
.brand span { color: var(--accent); }
.header-sub {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.funds-badge {
  margin-left: auto;
  font: 20px var(--font-mono);
  color: var(--accent-gold);
  background: #1c221a;
  padding: 6px 14px;
  border: 1px solid #3d4a2d;
  border-radius: 4px;
}

/* SQUAD SELECTOR BAR */
.squad-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0 12px;
}
.op-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  text-align: left;
}
.op-card.selected {
  border-color: var(--accent-gold) !important;
  background: #222a21 !important;
  box-shadow: inset 0 2px var(--accent-gold);
}
.op-callsign { font-weight: 700; font-size: 13px; }
.op-role { font-size: 10px; color: var(--text-muted); display: block; }
.op-badge {
  font: 10px var(--font-mono);
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 2px;
}
.op-badge.healthy { background: rgba(74, 222, 128, 0.15); color: var(--accent-green); }
.op-badge.wounded { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.op-badge.downed, .op-badge.dead { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

#message {
  color: var(--accent-cyan);
  min-height: 20px;
  font: 11px var(--font-mono);
  margin: 4px 0 12px;
}

/* 3-COLUMN TACTICAL INVENTORY LAYOUT */
.inventory-container {
  display: grid;
  grid-template-columns: 340px 420px 1fr;
  gap: 16px;
  align-items: start;
}

.t-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.panel-head h2 {
  font-size: 12px;
  letter-spacing: 1.5px;
  margin: 0;
  text-transform: uppercase;
  color: var(--text-primary);
}
.panel-cap {
  font: 11px var(--font-mono);
  color: var(--text-muted);
}

/* COLUMN 1: PAPERDOLL & ANATOMICAL HEALTH */
.doll-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.weight-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111813;
  padding: 8px 12px;
  border: 1px solid #233026;
  border-radius: 3px;
  font: 12px var(--font-mono);
}
.weight-banner b { color: var(--accent-gold); font-size: 14px; }
.weight-banner span { color: var(--text-muted); font-size: 10px; }

.paperdoll-box {
  position: relative;
  min-height: 380px;
  background: #0f1411;
  border: 1px solid #1a231d;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.paperdoll-silhouette {
  width: 140px;
  height: 280px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 200'><path d='M50 15 a12 12 0 1 0 0.1 0 Z M38 35 h24 l12 40 l-8 5 l-10 -25 v55 l12 70 l-12 5 l-6 -60 l-6 60 l-12 -5 l12 -70 v-55 l-10 25 l-8 -5 Z' fill='%23223026' stroke='%233a4c3f' stroke-width='2'/></svg>") center/contain no-repeat;
  opacity: 0.85;
}

/* LIMB HEALTH CARDS OVERLAID ON DOLL */
.limb-card {
  position: absolute;
  background: rgba(16, 22, 18, 0.92);
  border: 1px solid #2a382e;
  border-radius: 3px;
  padding: 4px 8px;
  font: 10px var(--font-mono);
  min-width: 95px;
  backdrop-filter: blur(4px);
}
.limb-card .limb-name { font-size: 9px; color: var(--text-muted); display: block; text-transform: uppercase; }
.limb-card .limb-hp { color: var(--accent-green); font-weight: 700; }
.limb-card .armor-hp { color: var(--accent-cyan); display: block; font-size: 9px; }

.limb-head { top: 12px; left: 10px; }
.limb-torso { top: 85px; right: 10px; }
.limb-arm-l { top: 110px; left: 10px; }
.limb-arm-r { top: 170px; right: 10px; }
.limb-leg-l { bottom: 20px; left: 10px; }
.limb-leg-r { bottom: 20px; right: 10px; }

.perks-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.perk-slot {
  flex: 1;
  background: #18201a;
  border: 1px solid #263329;
  padding: 6px;
  text-align: center;
  font: 9px var(--font-mono);
  color: var(--accent-cyan);
  border-radius: 2px;
}

/* COLUMN 2: LOADOUT, RIG & BACKPACK */
.loadout-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.weapons-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.weapon-card {
  background: #151c17;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.weapon-card.primary {
  border-color: var(--accent-gold);
  background: #1c241a;
}
.w-left { display: flex; flex-direction: column; gap: 2px; }
.w-title { font-weight: 700; font-size: 13px; color: var(--text-primary); }
.w-meta { font: 10px var(--font-mono); color: var(--text-muted); display: flex; gap: 8px; }
.w-badge { color: var(--accent-gold); }
.w-ammo { color: var(--accent-cyan); font-weight: 700; }
.w-icon { font-size: 18px; color: var(--text-muted); opacity: 0.7; }

/* RIG & POUCHES (Малые подсумки) */
.rig-box {
  background: #131915;
  border: 1px solid #243026;
  border-radius: 4px;
  padding: 10px;
}
.rig-title {
  display: flex;
  justify-content: space-between;
  font: 11px var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 8px;
}
.rig-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.pouch-cell {
  background: #1b231d;
  border: 1px solid #2c3a2f;
  border-radius: 3px;
  padding: 8px 6px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
}
.pouch-cell.active-hotkey { border-color: var(--accent-cyan); }
.pouch-hotkey { font: 9px var(--font-mono); color: var(--accent-gold); }
.pouch-name { font-size: 11px; font-weight: 600; }
.pouch-detail { font: 9px var(--font-mono); color: var(--text-muted); }

/* BACKPACK & SAFE CONTAINER */
.pack-box {
  background: #131915;
  border: 1px solid #243026;
  border-radius: 4px;
  padding: 10px;
}
.pack-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.safe-container-cell {
  border: 1px solid #c084fc !important;
  background: #1c1524 !important;
}

/* COLUMN 3: BASE STASH (Склад Базы) */
.stash-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stash-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.stash-filter-tabs button {
  padding: 5px 9px;
  font-size: 10px;
  font-family: var(--font-mono);
}
.stash-filter-tabs button.selected {
  border-color: var(--accent-gold);
  background: #2b3624;
  color: var(--accent);
}

.stash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}
.stash-item {
  background: #18201a;
  border: 1px solid #263329;
  border-radius: 3px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 85px;
  text-align: left;
}
.stash-item:hover:not(:disabled) {
  border-color: var(--accent);
  background: #232d25;
}
.stash-item .item-type {
  font: 9px var(--font-mono);
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}
.stash-item .item-qty { color: var(--accent-gold); font-weight: 700; }
.stash-item .item-name { font-size: 12px; font-weight: 600; margin: 4px 0; }
.stash-item .item-stat { font: 9px var(--font-mono); color: var(--accent-cyan); }

/* FOOTER & DEPLOY */
footer.base-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--panel-border);
  padding: 20px 0 0;
  margin-top: 24px;
}
.contract-summary h3 { margin: 0 0 4px; font-size: 16px; letter-spacing: 0.5px; }
.contract-summary p { margin: 0; color: var(--text-muted); font-size: 12px; }
.reward-block { text-align: right; }
.reward-block small { font-size: 10px; color: var(--text-muted); display: block; }
.reward-block strong { font: 22px var(--font-mono); color: var(--accent-gold); }
.deploy-btn {
  background: var(--accent);
  color: #121810;
  font-weight: 800;
  font-size: 14px;
  padding: 14px 28px;
  letter-spacing: 1px;
}
.deploy-btn:hover:not(:disabled) {
  background: #e8f4b9;
}

@media (max-width: 1200px) {
  .inventory-container { grid-template-columns: 1fr; }
  .squad-selector { grid-template-columns: repeat(2, 1fr); }
}
