/* Aligné sur dashboard.css — thème analytique bleu ardoise */
:root {
  --bg: #1a2330;
  --panel: #243041;
  --text: #f1f5f9;
  --muted: #8fa3b8;
  --border: rgba(255, 255, 255, 0.09);
  --accent: #38bdf8;
  --chrome-topbar: #1e2938;
  --field-bg: #1a2433;
  --defcon-track: #1c2836;
  --font-sans: "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --naval: #f87171;
  --air: #38bdf8;
  --land: #4ade80;
  --action: #fbbf24;
  --other: #94a3b8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: var(--root-font-size, 13px);
}

html,
body {
  margin: 0;
  height: 100%;
  background: linear-gradient(180deg, var(--bg) 0%, #141c27 100%);
  color: var(--text);
  font-family: var(--font-sans);
}

body {
  font-size: 1rem;
}

.tactical-app {
  display: grid;
  grid-template-columns: 1fr 8px var(--tactical-sidebar-width, 280px);
  grid-template-rows: auto 1fr;
  height: 100vh;
  min-height: 0;
}

.tactical-top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #243044 0%, var(--chrome-topbar) 100%);
  flex-wrap: wrap;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tactical-top__prefs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.tactical-top__brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.tactical-top__brand a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  margin-left: 0.75rem;
  font-size: 0.72rem;
}

.tactical-top__brand a:hover {
  color: var(--accent);
}

.tactical-top__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.tactical-map-debug-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.7);
}

.tactical-map-debug-pill[data-state="ready"] {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.4);
}

.tactical-map-debug-pill[data-state="loading"] {
  color: #7dd3fc;
  border-color: rgba(125, 211, 252, 0.4);
}

.tactical-map-debug-pill[data-state="error"] {
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.4);
}

.tactical-overlays-wrap {
  position: relative;
}

.tactical-overlays-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.28rem;
  min-width: 11rem;
  padding: 0.45rem 0.55rem;
  background: var(--chrome-topbar, #1e2938);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.tactical-overlays-panel[hidden] {
  display: none !important;
}

.tactical-overlays-panel__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text);
  margin-bottom: 0.35rem;
  cursor: pointer;
}

.tactical-overlays-panel__row:last-child {
  margin-bottom: 0;
}

.tactical-overlays-panel__row--subtle {
  color: var(--muted);
}

.tactical-overlays-panel__row--disabled {
  opacity: 0.45;
}

.tactical-overlays-panel__row input {
  accent-color: var(--accent);
}

.tactical-overlays-panel__hint {
  flex-basis: 100%;
  margin-left: 1.35rem;
  font-size: 0.58rem;
  color: var(--muted);
  line-height: 1.25;
}

.tactical-top label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tactical-top select {
  background: var(--field-bg, #0a0a0a);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.tactical-btn {
  background: var(--defcon-track, #1a1a1a);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  cursor: pointer;
}

.tactical-btn--icon {
  padding: 0.18rem 0.38rem;
  min-width: 1.8rem;
  line-height: 1.1;
}

.tactical-btn:hover {
  border-color: var(--muted);
}

.tactical-btn--active {
  border-color: var(--accent);
  color: #dff6ff;
  background: rgba(56, 189, 248, 0.12);
}

.tactical-btn--danger {
  border-color: #5a2a2a;
  color: #d08080;
}

.tactical-btn--danger:hover {
  border-color: #c23b3b;
  color: #f0a0a0;
}

.tactical-btn--panel-action {
  width: 100%;
  text-align: center;
  padding: 0.28rem 0.42rem;
}

.tactical-board-wrap {
  min-height: 0;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
}

.tactical-timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.tactical-places-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 0.24rem;
}

.tactical-btn--places {
  padding: 0.24rem 0.42rem;
  font-size: 0.62rem;
}

.tactical-save-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
}

.tactical-save-overlay[hidden] {
  display: none !important;
}

.tactical-save-overlay__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(7, 10, 15, 0.66);
  margin: 0;
  padding: 0;
}

.tactical-save-overlay__panel {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 1.25rem));
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.tactical-save-overlay__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.tactical-save-overlay__head h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: #dbe7f4;
}

.tactical-save-overlay__body {
  padding: 0.75rem;
}

.tactical-save-overlay__folders {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.tactical-save-overlay__folder {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  color: #dbe7f4;
  border: 1px solid var(--border);
  padding: 0.12rem 0.34rem;
  background: rgba(15, 23, 42, 0.55);
}

.tactical-save-overlay__field {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
}

.tactical-save-overlay__field input {
  background: var(--field-bg, #0a0a0a);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  padding: 0.35rem 0.45rem;
}

.tactical-save-overlay__field select {
  background: var(--field-bg, #0a0a0a);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  padding: 0.35rem 0.45rem;
}

.tactical-save-overlay__modes {
  border: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  margin: 0 0 0.7rem;
  display: grid;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.63rem;
}

.tactical-save-overlay__actions {
  display: flex;
  justify-content: flex-end;
}

.tactical-save-overlay__status {
  margin-top: 0.5rem;
  min-height: 1.05rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
}

.tactical-welcome__panel {
  width: min(34rem, 100%);
  max-height: none;
}

.tactical-welcome__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.95rem;
  padding: 1.35rem 1rem 1.5rem;
  text-align: center;
}

.tactical-welcome__title {
  margin: 0;
  color: #e2e8f0;
  font-size: clamp(1rem, 1.3vw, 1.2rem);
  letter-spacing: 0.02em;
}

.tactical-places-overlay__textarea {
  width: 100%;
  resize: vertical;
  min-height: 15rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.66);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  line-height: 1.35;
  padding: 0.42rem 0.5rem;
}

.scenario-form {
  border: 1px solid var(--border);
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.65rem;
  display: grid;
  gap: 0.44rem;
  background: rgba(15, 23, 42, 0.35);
}

.scenario-form__title {
  margin: 0.15rem 0 0.1rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  color: #dbe7f4;
  text-transform: uppercase;
}

.scenario-form__field {
  display: grid;
  gap: 0.22rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
}

.scenario-form__toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.scenario-form__toggle-btn {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  padding: 0.24rem 0.4rem;
  cursor: pointer;
}

.scenario-form__toggle-btn:hover {
  border-color: #5ea8cc;
  color: #dbe7f4;
}

.scenario-form__toggle-btn--active {
  border-color: var(--accent);
  color: #dff6ff;
  background: rgba(56, 189, 248, 0.16);
}

.scenario-form__scenario-description {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.45);
  color: #dbe7f4;
  padding: 0.45rem 0.55rem;
  line-height: 1.35;
  white-space: pre-line;
}

.scenario-form__timeline {
  margin-top: 0.45rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.scenario-form__timeline-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
}

.scenario-form__timeline input,
.scenario-form__timeline select {
  background: var(--field-bg, #0a0a0a);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 0.24rem 0.35rem;
}

.scenario-form__timeline input {
  width: 5rem;
}

#tactical-scenario-overlay-head {
  cursor: move;
  user-select: none;
}

#tactical-scenario-overlay .tactical-save-overlay__panel {
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}

#tactical-scenario-overlay .tactical-save-overlay__body {
  overflow-y: auto;
  overflow-x: hidden;
}

#tactical-scenario-overlay.scenario-overlay--collapsed .tactical-save-overlay__body {
  display: none;
}

#tactical-scenario-overlay.scenario-overlay--collapsed .tactical-save-overlay__backdrop {
  display: none;
}

#tactical-scenario-overlay.scenario-overlay--collapsed .tactical-save-overlay__panel {
  width: min(420px, calc(100vw - 0.75rem));
}

#tactical-scenario-overlay.scenario-overlay--collapsed {
  z-index: 1400;
}

.scenario-run-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  margin-right: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: #dbe7f4;
}

.scenario-run-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: scenarioPulse 1.2s infinite;
}

@keyframes scenarioPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }
  100% {
    box-shadow: 0 0 0 9px rgba(34, 197, 94, 0);
  }
}

.tactical-op-report__panel {
  width: min(700px, calc(100vw - 1rem));
  top: 6%;
}

#tactical-op-report-head {
  cursor: move;
  user-select: none;
}

#tactical-op-report-overlay {
  z-index: 1450;
}

.tactical-op-report__body {
  max-height: calc(100vh - 10rem);
  overflow-y: auto;
}

.tactical-op-report__p {
  margin: 0 0 0.55rem;
  padding: 0.42rem 0.5rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.38);
  white-space: pre-line;
  line-height: 1.3;
  font-size: 0.63rem;
}

.scenario-corps-strip {
  position: absolute;
  left: 0.4rem;
  top: 3.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.26rem;
  z-index: 8;
}

.scenario-corps-badge {
  width: 34px;
  height: 34px;
  border: 1px solid #5ea8cc;
  background: rgba(2, 6, 23, 0.9);
  color: #dff6ff;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scenario-corps-badge__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: rgba(2, 6, 23, 0.9);
}

.tactical-files-columns {
  margin-top: 0.55rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.tactical-files-column {
  border: 1px solid var(--border);
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  padding: 0.4rem;
}

.tactical-files-column h4 {
  margin: 0 0 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.tactical-file-row {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.45);
  padding: 0.3rem;
  margin-bottom: 0.3rem;
}

.tactical-file-row__title {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: #dbe7f4;
  margin-bottom: 0.24rem;
}

.tactical-file-row__meta {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  color: var(--muted);
  margin-bottom: 0.24rem;
}

.tactical-file-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.22rem;
}

.tactical-file-row__actions .tactical-btn {
  padding: 0.2rem 0.35rem;
  font-size: 0.54rem;
}

.tactical-file-row__url {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  color: var(--accent);
  word-break: break-all;
  text-decoration: none;
}

.tactical-timeline-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
}

.tactical-timeline-toggle__btn {
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  padding: 0.26rem 0.5rem;
  cursor: pointer;
}

.tactical-timeline-toggle__btn:last-child {
  border-right: none;
}

.tactical-timeline-toggle__btn--active {
  color: #dff6ff;
  background: rgba(56, 189, 248, 0.15);
}

.tactical-timeline-range {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.tactical-timeline-range[hidden] {
  display: none !important;
}

.tactical-timeline-range__input,
.tactical-timeline-range__unit {
  background: var(--field-bg, #0a0a0a);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  padding: 0.24rem 0.36rem;
}

.tactical-timeline-range__input {
  width: 4.2rem;
}

.tactical-board {
  flex: 1;
  min-height: 200px;
  position: relative;
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: crosshair;
  background-color: #0f172a;
  background-size: cover;
  background-position: center;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Live satellite basemap (MapLibre); tactical tokens stack above (higher z-index) */
.tactical-board--map {
  background-image: none;
  background-color: #0a0f18;
}

.tactical-map-host {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  /* Let MapLibre receive wheel/touch for zoom & pan; tokens still capture hits on top */
  pointer-events: auto;
  display: none;
}

.tactical-map-host .maplibregl-map {
  width: 100%;
  height: 100%;
}

/* Allow provider attribution control to receive clicks */
.tactical-map-host .maplibregl-ctrl {
  pointer-events: auto;
}

.tactical-places-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.tactical-places-layer[hidden] {
  display: none !important;
}

.tactical-place {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 0.92rem;
  height: 0.92rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  font-family: var(--font-mono);
  font-size: 0.5rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 0 0 1px rgba(2, 6, 23, 0.65);
  pointer-events: auto;
}

.tactical-place--base {
  background: rgba(234, 179, 8, 0.42);
  border-color: rgba(253, 224, 71, 0.95);
}

.tactical-place--airport {
  background: rgba(56, 189, 248, 0.4);
  border-color: rgba(125, 211, 252, 0.95);
}

.tactical-place--port {
  background: rgba(74, 222, 128, 0.38);
  border-color: rgba(134, 239, 172, 0.95);
}

.tactical-place--refinery {
  background: rgba(251, 146, 60, 0.42);
  border-color: rgba(254, 215, 170, 0.95);
}

.tactical-place--oil_complex {
  background: rgba(217, 119, 6, 0.42);
  border-color: rgba(253, 186, 116, 0.95);
}

.tactical-place--desalination {
  background: rgba(6, 182, 212, 0.42);
  border-color: rgba(103, 232, 249, 0.95);
}

.tactical-places-popup {
  position: absolute;
  min-width: 190px;
  max-width: 240px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.97);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  z-index: 12;
  pointer-events: auto;
}

.tactical-places-popup[hidden] {
  display: none !important;
}

.tactical-places-popup__head {
  padding: 0.3rem 0.4rem 0.22rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  font-family: var(--font-mono);
  font-size: 0.57rem;
  color: #e2e8f0;
}

.tactical-places-popup__meta {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.54rem;
}

.tactical-places-popup__img {
  width: 100%;
  height: 88px;
  object-fit: cover;
  display: block;
  background: rgba(2, 6, 23, 0.6);
}

.tactical-places-popup__status {
  padding: 0.35rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--muted);
}

.tactical-places-popup__wiki {
  display: inline-flex;
  margin: 0.2rem 0.4rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: #7dd3fc;
  text-decoration: none;
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 0.24rem;
  padding: 0.1rem 0.28rem;
}

.tactical-places-popup__wiki:hover {
  color: #dff6ff;
  border-color: rgba(125, 211, 252, 0.7);
  background: rgba(56, 189, 248, 0.16);
}

.timeline-ruler {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.1rem;
  z-index: 1;
  pointer-events: none;
  border-top: 1px solid rgba(143, 163, 184, 0.45);
  background: linear-gradient(
    to top,
    rgba(8, 12, 20, 0.78) 0%,
    rgba(8, 12, 20, 0.5) 60%,
    rgba(8, 12, 20, 0) 100%
  );
}

.timeline-ruler[hidden] {
  display: none !important;
}

.timeline-ruler__tick {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 0.45rem;
  background: rgba(226, 232, 240, 0.58);
}

.timeline-ruler__tick--major {
  height: 0.95rem;
  background: rgba(226, 232, 240, 0.82);
}

.timeline-ruler__label {
  position: absolute;
  bottom: 1.04rem;
  transform: translateX(-50%);
  color: #dbe7f4;
  font-family: var(--font-mono);
  font-size: 0.52rem;
  white-space: nowrap;
  opacity: 0.9;
}

.tactical-board--hormuz {
  background-image: url("assets/hormuz-satellite.png");
}

.tactical-board--grid {
  background-image: none;
  background-color: #0f172a;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
}

.tactical-board--dark {
  background-image: none;
  background: radial-gradient(ellipse at center, #1e3a5f 0%, #0f172a 100%);
}

.tactical-board.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sidebar-panels {
  display: flex;
  min-height: 0;
  border-left: 1px solid var(--border);
}

.units-resizer {
  cursor: col-resize;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0.02) 0%,
    rgba(143, 163, 184, 0.22) 50%,
    rgba(255, 255, 255, 0.02) 100%
  );
  border-left: 1px solid rgba(143, 163, 184, 0.16);
  border-right: 1px solid rgba(143, 163, 184, 0.16);
}

.units-resizer:hover {
  background: linear-gradient(
    to right,
    rgba(56, 189, 248, 0.08) 0%,
    rgba(56, 189, 248, 0.28) 50%,
    rgba(56, 189, 248, 0.08) 100%
  );
}

.palette {
  border-left: none;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.palette__head {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.palette__filter {
  width: min(12.5rem, 58%);
  min-width: 7.5rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  color: #dff6ff;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  padding: 0.24rem 0.4rem;
}

.palette__filter::placeholder {
  color: var(--muted);
}

.palette__filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.2);
}

.palette__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.65rem;
}

.tactical-btn--catalog {
  padding: 0.28rem 0.45rem;
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.tactical-btn--catalog[aria-expanded="true"] {
  border-color: var(--accent);
  color: #dff6ff;
}

.catalog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.catalog-overlay[hidden] {
  display: none !important;
}

.catalog-overlay__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  margin: 0;
  padding: 0;
  background: rgba(7, 10, 15, 0.64);
  cursor: pointer;
}

.catalog-overlay__panel {
  position: absolute;
  top: 3.25rem;
  right: 1rem;
  bottom: 1rem;
  width: min(680px, calc(100vw - 2rem));
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.icon-catalog__head {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.icon-catalog__tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.42rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.icon-catalog__tab {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  padding: 0.22rem 0.52rem;
  cursor: pointer;
}

.icon-catalog__tab--active {
  color: #dff6ff;
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
}

.icon-catalog__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.55rem 0.65rem;
}

.icon-catalog__pane[hidden] {
  display: none !important;
}

.icon-catalog__section {
  margin: 0.1rem 0 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.icon-catalog__group-trash {
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.22);
  color: #fecaca;
  border-radius: 0.2rem;
  padding: 0.02rem 0.2rem;
  line-height: 1;
  margin-right: 0.36rem;
  cursor: pointer;
  vertical-align: baseline;
}

.icon-catalog__group-trash:hover {
  border-color: rgba(248, 113, 113, 0.8);
  color: #fff1f2;
}

.catalog-overlay__close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.38rem;
  cursor: pointer;
}

.catalog-overlay__close:hover {
  border-color: var(--accent);
  color: #dff6ff;
}

.icon-row {
  display: grid;
  grid-template-columns: 6px 14px 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.32rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.45);
  margin-bottom: 0.26rem;
}

.icon-row[hidden],
.icon-catalog__section[hidden] {
  display: none !important;
}

.icon-row__wiki {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: #7dd3fc;
  text-decoration: none;
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 0.24rem;
  padding: 0.1rem 0.28rem;
  white-space: nowrap;
}

.icon-row__wiki:hover {
  color: #dff6ff;
  border-color: rgba(125, 211, 252, 0.7);
  background: rgba(56, 189, 248, 0.16);
}

.icon-row__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
}

.icon-row__trash {
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.22);
  color: #fecaca;
  border-radius: 0.24rem;
  padding: 0.08rem 0.22rem;
  line-height: 1;
  cursor: pointer;
}

.icon-row__trash:hover {
  border-color: rgba(248, 113, 113, 0.8);
  color: #fff1f2;
}

.icon-row[draggable="true"] {
  cursor: grab;
}

.icon-row[draggable="true"]:active {
  cursor: grabbing;
}

.icon-row__chip {
  width: 4px;
  height: 100%;
  min-height: 18px;
  border-radius: 999px;
  background: var(--other);
}

.icon-row__glyph {
  font-size: 0.72rem;
  line-height: 1;
  text-align: center;
  opacity: 0.95;
}

.icon-row__badge {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(2, 6, 23, 0.7);
}

.icon-row__code {
  font-family: var(--font-mono);
  font-size: 0.53rem;
  letter-spacing: 0.03em;
  color: #e2e8f0;
  text-transform: uppercase;
  text-align: center;
}

.icon-row__desc {
  font-size: 0.59rem;
  line-height: 1.3;
  color: #d1dbe8;
}

.icon-row--air .icon-row__chip {
  background: var(--air);
}

.icon-row--land .icon-row__chip {
  background: var(--land);
}

.icon-row--naval .icon-row__chip {
  background: var(--naval);
}

.palette__section {
  margin-bottom: 1rem;
}

.palette__title {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 0.4rem;
  text-transform: uppercase;
}

.palette-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  margin: 0.2rem 0.25rem 0.2rem 0;
  border: 1px solid var(--border);
  background: var(--panel);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: grab;
  border-left-width: 3px;
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item--naval {
  border-left-color: var(--naval);
}

.palette-item--air {
  border-left-color: var(--air);
}

.palette-item--land {
  border-left-color: var(--land);
}

.palette-item--action {
  border-left-color: var(--action);
}

.palette-item--other {
  border-left-color: var(--other);
}

.token {
  position: absolute;
  left: 0;
  top: 0;
  min-width: 52px;
  max-width: 160px;
  padding: 0.35rem 1.4rem 0.35rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 10, 12, 0.88);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.25;
  transform: translate(-50%, -50%);
  cursor: grab;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.token--selected {
  border-color: rgba(125, 211, 252, 0.95);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5), 0 2px 10px rgba(0, 0, 0, 0.5);
}

.token--menu-open {
  border-color: rgba(250, 204, 21, 0.8);
}

.token:active {
  cursor: grabbing;
  z-index: 10;
}

.token--naval {
  border-left: 3px solid var(--naval);
}

.token--air {
  border-left: 3px solid var(--air);
}

.token--land {
  border-left: 3px solid var(--land);
}

.token--action {
  border-left: 3px solid var(--action);
}

.token--other {
  border-left: 3px solid var(--other);
}

.token__label {
  outline: none;
  word-break: break-word;
  display: block;
}

.token__compact {
  display: none;
  font-size: 0.9rem;
  line-height: 1;
  font-weight: 600;
}

.token__label:focus {
  color: #fff;
}

.token__emblem {
  display: none;
}

.token__menu-btn {
  position: absolute;
  top: 0.34rem;
  right: 0.12rem;
  width: 0.98rem;
  height: 0.86rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.2rem;
  background: rgba(15, 23, 42, 0.45);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.token__flag {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.8rem;
  line-height: 1;
  pointer-events: none;
  opacity: 0.95;
  z-index: 3;
}

.token__menu-btn:hover,
.token__menu-btn[aria-expanded="true"] {
  color: #f8fafc;
  border-color: rgba(250, 204, 21, 0.7);
}

.token__menu {
  position: absolute;
  top: 1.4rem;
  right: 0.15rem;
  min-width: 8rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

.token__sector-layer {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  transform: translate(-50%, -50%);
}

.token__sector-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.token__sector-path {
  fill: rgba(148, 163, 184, 0.1);
  stroke: rgba(148, 163, 184, 1);
}

.token__sector-km {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  border: none;
  padding: 0;
  white-space: nowrap;
  pointer-events: none;
}

.token__sector-gizmo {
  position: absolute;
  pointer-events: none;
  border: 1px dashed rgba(148, 163, 184, 0.55);
  border-radius: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
}

.token__sector-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(241, 245, 249, 0.85);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
  cursor: grab;
  z-index: 2;
  padding: 0;
  transform: translate(-50%, -50%);
}

.token__sector-handle:active {
  cursor: grabbing;
}

.token__menu[hidden] {
  display: none !important;
}

.token__menu-image-wrap {
  margin: 0.25rem 0.25rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.45);
}

.token__menu-image {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: cover;
}

.token__menu-image-status {
  padding: 0.4rem 0.5rem;
  font-size: 0.62rem;
  color: var(--muted);
}

.token__menu-item {
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid rgba(143, 163, 184, 0.2);
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 0.3rem 0.45rem;
  cursor: pointer;
}

.token__menu-item--coords {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.token__coords-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token__copy-icon {
  font-size: 0.76rem;
  opacity: 0.9;
}

.token__menu-item:last-child {
  border-bottom: none;
}

.token__menu-item:hover {
  background: rgba(56, 189, 248, 0.16);
}

.token--reduced {
  width: 2rem;
  min-width: 2rem;
  max-width: 2rem;
  height: 2rem;
  padding: 0;
  border-left-width: 1px;
  border-radius: 999px;
  background: #020617;
  display: flex;
  align-items: center;
  justify-content: center;
}

.token--reduced .token__label,
.token--reduced .token__menu-btn {
  display: none;
}

.token--reduced .token__compact {
  display: block;
}

.token--emblem {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
  height: 100px;
  padding: 0.12rem 0.16rem 0.12rem;
  border-left-width: 1px;
}

.token--emblem .token__emblem {
  display: block;
  width: 100%;
  height: 78px;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.25rem;
  background: rgba(2, 6, 23, 0.85);
  margin-bottom: 0.08rem;
}

.token--emblem .token__label {
  font-size: 0.48rem;
  line-height: 1.1;
  text-align: center;
}

.token--emblem .token__menu-btn {
  top: 0.12rem;
  right: 0.12rem;
}

.token--emblem .token__flag {
  top: 0.18rem;
  left: 0.18rem;
  right: auto;
}

.token--reduced.token--naval {
  border-color: var(--naval);
}

.token--reduced.token--air {
  border-color: var(--air);
}

.token--reduced.token--land {
  border-color: var(--land);
}

.token--reduced.token--action {
  border-color: var(--action);
}

.token--reduced.token--other {
  border-color: var(--other);
}

.token__range {
  --range-px: 36px;
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--range-px) * 2);
  height: calc(var(--range-px) * 2);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: -1;
}

.token__range-circle {
  position: absolute;
  inset: 0;
  border: 1px dashed rgba(125, 211, 252, 0.55);
  border-radius: 999px;
  background: radial-gradient(
    circle,
    rgba(56, 189, 248, 0.09) 0%,
    rgba(56, 189, 248, 0.02) 55%,
    rgba(56, 189, 248, 0) 100%
  );
}

.token__range-line {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--range-px);
  height: 1px;
  background: rgba(186, 230, 253, 0.8);
  transform: translateY(-50%);
}

@media (max-width: 800px) {
  .tactical-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .units-resizer {
    display: none;
  }

  .sidebar-panels {
    display: block;
    border-left: none;
  }

  .palette {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 40vh;
  }

  .catalog-overlay__panel {
    top: 0.75rem;
    right: 0.5rem;
    left: 0.5rem;
    bottom: 0.5rem;
    width: auto;
  }
}

/* Même logique contraste élevé que le monitor : couleurs wargame un peu plus lisibles */
html.high-contrast {
  --naval: #ff8a7d;
  --air: #7ad8f0;
  --land: #a8e074;
  --action: #ffe875;
  --other: #c8c8c8;
}

html.high-contrast .tactical-board--grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
}
