/* OPAL - interface. Light and dark themes share the same tokens; team colours stay constant. */
:root {
  --bg: #eef1f6; --panel: #ffffff; --panel-2: #f5f7fb; --panel-3: #e9edf4; --line: #dde2ec; --line-soft: #ebeef4;
  --ink: #161d2b; --muted: #667085; --accent: #1f3a6e; --accent-2: #2a4d91; --on-accent: #ffffff;
  --top: #121a2c; --top-ink: #ffffff; --top-muted: #96a3bd; --top-line: rgba(255,255,255,.12);
  --blue: #2f6fd6; --blue-bg: #e3edfc; --blue-ink: #1d4ea8;
  --red: #d23b3b; --red-bg: #fbe4e2; --red-ink: #8b1c1c;
  --green: #2f8a55; --green-bg: #e2f3e8; --green-ink: #14532d;
  --amber: #b7791f; --amber-bg: #fdf1dc; --amber-ink: #7a4b07;
  --mark: #fff2cc; --mark-ink: #9c0006; --mark-line: #e6d28f;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 40px rgba(10,16,30,.28);
  --glass: rgba(255,255,255,.92); --glass-line: rgba(16,24,40,.10);
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --bar: 22px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b101b; --panel: #121927; --panel-2: #172032; --panel-3: #1e293d; --line: #26324a; --line-soft: #1d2739;
  --ink: #e8edf6; --muted: #93a0b8; --accent: #4f8cf7; --accent-2: #6ea1ff; --on-accent: #08101f;
  --top: #0a0f1a; --top-ink: #ffffff; --top-muted: #8492ad; --top-line: rgba(255,255,255,.09);
  --blue-bg: #14294d; --blue-ink: #9cc0ff; --red-bg: #45191b; --red-ink: #ffb1ab;
  --green-bg: #123524; --green-ink: #9be0b8; --amber-bg: #3d2c0d; --amber-ink: #f5cf86;
  --mark: #3a300f; --mark-ink: #ffd666; --mark-line: #5a4a17;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
  --glass: rgba(18,25,39,.92); --glass-line: rgba(255,255,255,.10);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 13px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; border: 2px solid transparent; }

.marking { position: fixed; top: 0; left: 0; right: 0; height: var(--bar); line-height: var(--bar); text-align: center;
  background: var(--mark); color: var(--mark-ink); font-weight: 700; font-size: 10.5px; letter-spacing: .1em; z-index: 3000;
  border-bottom: 1px solid var(--mark-line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px; }

/* ---------- join ---------- */
.join { position: fixed; inset: var(--bar) 0 0 0; display: grid; place-items: center; overflow: auto; padding: 24px 16px;
  background: radial-gradient(1200px 700px at 18% 12%, #27407a 0%, rgba(39,64,122,0) 60%), radial-gradient(900px 600px at 85% 90%, #123b4a 0%, rgba(18,59,74,0) 60%), #0b1220; }
.join-art { position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(closest-side, #000 30%, transparent 100%); -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 100%); }
.join-card { position: relative; width: min(430px, 100%); background: var(--panel); border-radius: 16px; padding: 30px 30px 22px;
  box-shadow: var(--shadow-lg); display: grid; gap: 14px; border: 1px solid var(--glass-line); }
.join-card label { display: grid; gap: 6px; font-weight: 600; font-size: 12px; color: var(--muted); }
.join-card input { padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; color: var(--ink); background: var(--panel-2); transition: border-color .15s, box-shadow .15s; }
.join-card input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 22%, transparent); }
.code-input { font-family: var(--mono); letter-spacing: .34em; text-transform: uppercase; text-align: center; font-weight: 700; }
.join-session { font-size: 12px; color: var(--muted); min-height: 1.2em; }
.join-error { color: var(--red); min-height: 1.2em; font-weight: 600; }
.join-teams { display: flex; gap: 6px; justify-content: center; }
.team-dot { box-shadow: 0 0 0 1px var(--line); font-size: 10px; font-weight: 800; letter-spacing: .08em; padding: 3px 9px; border-radius: 999px; }
.join-hint { text-align: center; color: var(--muted); font-size: 12px; line-height: 1.45; }
.join-foot { text-align: center; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; background: #16213a url("/static/favicon.svg") center/100% no-repeat; }
.brand-mark { display: block; font-weight: 800; letter-spacing: .14em; font-size: 24px; color: var(--ink); line-height: 1.1; }
.brand-sub { color: var(--muted); font-size: 12px; }
.brand.small { gap: 8px; }
.brand.small .brand-logo { width: 24px; height: 24px; border-radius: 6px; }
.brand.small .brand-mark { font-size: 15px; color: var(--top-ink); }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.big { padding: 12px 14px; font-size: 14px; border-radius: 10px; }
.btn.ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red-bg); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--accent-2); cursor: pointer; padding: 0; font-weight: 600; }
.linkbtn:hover { text-decoration: underline; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--top-muted); cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: rgba(255,255,255,.08); color: var(--top-ink); }
.icon-btn.active { color: var(--top-ink); }
.icon-btn.text { font-weight: 700; font-size: 11px; letter-spacing: .04em; }
.icon-btn svg, .tool svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.app { position: fixed; inset: var(--bar) 0 0 0; display: grid; grid-template-rows: 50px 1fr; }
.topbar { background: var(--top); color: var(--top-ink); display: flex; align-items: center; gap: 14px; padding: 0 10px; border-bottom: 1px solid var(--top-line); min-width: 0; }
.topbar .btn.ghost { color: var(--top-ink); border-color: rgba(255,255,255,.22); white-space: nowrap; }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.08); }
.tb-sep { width: 1px; height: 24px; background: var(--top-line); }
.tb-item { display: grid; line-height: 1.2; min-width: 0; }
.tb-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--top-muted); }
.tb-value { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-phase { flex-shrink: 1; }
.tb-spacer { flex: 1; }
.tb-online { font-size: 11px; color: var(--top-muted); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.tb-online::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ecf7a; box-shadow: 0 0 0 3px rgba(62,207,122,.18); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.12); color: var(--top-ink); white-space: nowrap; }
.chip.open { background: #1f7a48; color: #fff; }
.chip.closed { background: rgba(255,255,255,.12); color: #cdd5e4; }
.role-badge { padding: 4px 10px; border-radius: 7px; font-weight: 800; letter-spacing: .06em; font-size: 11.5px; white-space: nowrap; }
.role-WHITE { background: #ffffff; color: #1f2a44; }
.role-BLUE { background: var(--blue); color: #fff; }
.role-RED { background: var(--red); color: #fff; }
.role-GREEN { background: var(--green); color: #fff; }

.main { display: grid; grid-template-columns: 372px minmax(0, 1fr) 316px; min-height: 0; }
.main.no-left { grid-template-columns: 0 minmax(0, 1fr) 316px; }
.main.no-right { grid-template-columns: 372px minmax(0, 1fr) 0; }
.main.no-left.no-right { grid-template-columns: 0 minmax(0, 1fr) 0; }
.main.no-left .left, .main.no-right .right { display: none; }
.left, .right { background: var(--panel); min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.left { border-right: 1px solid var(--line); grid-column: 1; }
.right { border-left: 1px solid var(--line); grid-column: 3; }
.mapwrap { position: relative; min-height: 0; min-width: 0; grid-column: 2; overflow: hidden; background: #a9c7dc; }
#map { position: absolute; inset: 0; }
.map-fail { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; color: #1d2433; font-weight: 600; }

.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--panel-2); flex-shrink: 0; padding: 0 6px; gap: 2px; }
.tabs button { flex: 1; border: 0; background: none; padding: 11px 6px 9px; cursor: pointer; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; font-size: 12px; position: relative; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent-2); }
.tabs .badge { position: absolute; top: 5px; right: 4px; background: var(--red); color: #fff; border-radius: 999px; font-size: 10px; padding: 0 5px; min-width: 16px; line-height: 16px; }
.tabpane { flex: 1; overflow: auto; padding: 14px; min-height: 0; }
#pane-msgs { display: flex; flex-direction: column; padding: 0; }
#pane-msgs.hidden { display: none; }

/* ---------- panels ---------- */
.sec { margin-bottom: 18px; }
.sec h3 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.sec h3 > span { background: var(--panel-3); color: var(--ink); border-radius: 999px; padding: 1px 8px; font-size: 10.5px; letter-spacing: 0; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px; background: var(--panel); margin-bottom: 8px; }
.card.sel { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2) inset; }
.card.BLUE { border-left: 4px solid var(--blue); }
.card.RED { border-left: 4px solid var(--red); }
.card.GREEN { border-left: 4px solid var(--green); }
.card.WHITE { border-left: 4px solid #8a94a8; }
.card .title { font-weight: 700; margin-bottom: 4px; }
.card .meta { color: var(--muted); font-size: 12px; }
.field { display: grid; gap: 4px; margin: 7px 0; }
.field > span { font-size: 11px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea, .msg-form select, .msg-form input { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; background: var(--panel-2); width: 100%; color: var(--ink); }
.field input:focus, .field select:focus, .field textarea:focus, .msg-form input:focus { outline: none; border-color: var(--accent-2); }
.field input[type="file"] { padding: 5px; font-size: 12px; }
.field textarea { min-height: 56px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.alert { border-radius: 7px; padding: 6px 9px; font-size: 12px; margin: 5px 0; }
.alert.rule { background: var(--red-bg); color: var(--red-ink); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); }
.alert.warn { background: var(--amber-bg); color: var(--amber-ink); border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); }
.status { display: inline-block; font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 6px; border-radius: 5px; background: var(--panel-3); color: var(--muted); vertical-align: 1px; }
.status.proposed { background: var(--amber-bg); color: var(--amber-ink); }
.status.accepted, .status.in_progress { background: var(--blue-bg); color: var(--blue-ink); }
.status.done, .status.validated { background: var(--green-bg); color: var(--green-ink); }
.status.refused, .status.lapsed, .status.cancelled { background: var(--red-bg); color: var(--red-ink); }
.empty { color: var(--muted); font-style: italic; padding: 6px 0; }
table.inv { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 14px; }
table.inv th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; border-bottom: 1px solid var(--line); padding: 5px 4px; }
table.inv td { border-bottom: 1px solid var(--line-soft); padding: 5px 4px; vertical-align: middle; }
table.inv td.num, table.inv th.num { text-align: right; font-family: var(--mono); }
.unit-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-bottom: 1px solid var(--line-soft); cursor: pointer; border-radius: 7px; }
.unit-row:hover { background: var(--panel-2); }
.unit-row img, .unit-row .sym { width: 30px; flex-shrink: 0; display: grid; place-items: center; }
.unit-row .nm { flex: 1; min-width: 0; }
.unit-row .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 4px; background: var(--panel-3); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; background: var(--green); }
.codes { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-family: var(--mono); font-size: 15px; align-items: center; letter-spacing: .12em; user-select: all; }
.codes span:nth-child(odd) { font-family: var(--font); font-weight: 800; font-size: 11px; letter-spacing: .06em; user-select: none; }
.ready-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 14px; }

/* ---------- feed / messages ---------- */
.feed, .msgs { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 12px; line-height: 1.4; }
.feed li .w { display: block; color: var(--muted); font-family: var(--mono); font-size: 10.5px; }
.feed li.turn { font-weight: 700; color: var(--ink); }
.feed li.combat { color: var(--red-ink); }
.feed li.decision { color: var(--blue-ink); }
.feed li.lesson { color: var(--green-ink); }
.msgs { flex: 1; overflow: auto; padding: 14px; }
.msgs li { margin-bottom: 9px; }
.msgs li .who { font-size: 11px; font-weight: 700; }
.msgs li .txt { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px; margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-form { display: flex; gap: 6px; padding: 9px; border-top: 1px solid var(--line); }
.msg-form select { width: 86px; }
.msg-form input { flex: 1; min-width: 0; }
:root { --navy: var(--ink); }

/* ---------- map: overlays ---------- */
.pick-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #121a2c; color: #fff; max-width: calc(100% - 140px);
  padding: 8px 8px 8px 16px; border-radius: 999px; z-index: 900; font-weight: 600; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; }
.pick-hint button { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 600; }
.replay-banner { position: absolute; top: 44px; left: 12px; background: #7c2d12; color: #fff; padding: 8px 14px; border-radius: 9px; z-index: 900; font-weight: 700; box-shadow: var(--shadow); }
.map-picking .maplibregl-canvas-container, .map-picking .unit-icon, .map-measuring .maplibregl-canvas-container { cursor: crosshair !important; }

.map-legend { position: absolute; right: 10px; top: 118px; background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--glass-line); border-radius: var(--radius); z-index: 5; font-size: 11px; box-shadow: var(--shadow); max-width: 200px; overflow: hidden; }
.map-legend .lg-head { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; border: 0; background: none; padding: 7px 10px; cursor: pointer; font-weight: 700; font-size: 11px; }
.map-legend .chev { width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-135deg); margin-top: 3px; }
.map-legend.collapsed .chev { transform: rotate(45deg); margin-top: -3px; }
.map-legend .lg-body { padding: 0 10px 8px; }
.map-legend.collapsed .lg-body { display: none; }
.map-legend .lg { display: flex; align-items: center; gap: 7px; margin: 3px 0; }
.map-legend .lg.muted { margin-top: 6px; }
.map-legend .sw { width: 14px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,.25); flex-shrink: 0; }

.country-label { pointer-events: none; font-weight: 800; letter-spacing: .22em; color: rgba(22,29,43,.62); font-size: 13px; text-transform: uppercase; white-space: nowrap;
  text-shadow: 0 0 3px rgba(255,255,255,.9), 0 0 8px rgba(255,255,255,.7); }
.map-dark .country-label { color: rgba(255,255,255,.88); text-shadow: 0 0 3px rgba(0,0,0,.95), 0 0 9px rgba(0,0,0,.8); }
.node-label { pointer-events: none; background: rgba(255,255,255,.9); border-radius: 4px; padding: 1px 5px; font-size: 10.5px; font-weight: 600; color: #161d2b; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.map-dark .node-label { background: rgba(12,18,30,.82); color: #fff; }
.hide-node-labels .node-label, .hide-country-labels .country-label { display: none; }

.unit-icon { position: relative; cursor: pointer; line-height: 0; transition: transform .12s; }
.unit-icon svg { display: block; overflow: visible; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.unit-icon:hover { transform: scale(1.12); z-index: 5; }
.unit-icon.detected svg { opacity: .82; }
.unit-icon.destroyed svg { opacity: .4; filter: grayscale(1); }
.unit-icon.selected svg { filter: drop-shadow(0 0 3px #ffd400) drop-shadow(0 0 6px #ffd400) drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.unit-icon::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); background: #121a2c; color: #fff; font: 600 11px/1.3 var(--font);
  padding: 4px 8px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; box-shadow: var(--shadow); }
.unit-icon:hover::after { opacity: 1; }
.maplibregl-marker:has(.unit-icon:hover), .maplibregl-marker:has(.unit-icon.selected) { z-index: 4; }

/* ---------- map: view switcher, tools, layer panel ---------- */
.mapui { position: absolute; left: 12px; bottom: 12px; z-index: 6; display: grid; gap: 8px; justify-items: start; max-width: calc(100% - 24px); }
.mapui-views { display: flex; gap: 6px; padding: 6px; background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--glass-line); border-radius: 14px; box-shadow: var(--shadow); }
.view-card { border: 0; background: none; padding: 0; cursor: pointer; display: grid; gap: 4px; justify-items: center; width: 62px; color: var(--ink); }
.view-card .thumb { width: 62px; height: 46px; border-radius: 9px; border: 2px solid transparent; box-shadow: 0 0 0 1px var(--glass-line); background-size: cover; transition: transform .12s, border-color .12s; position: relative; overflow: hidden; }
.view-card:hover:not(:disabled) .thumb { transform: translateY(-1px); }
.view-card.active .thumb { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); }
.view-card .lbl { font-size: 10.5px; font-weight: 600; color: var(--muted); }
.view-card.active .lbl { color: var(--ink); font-weight: 700; }
.view-card:disabled { cursor: not-allowed; opacity: .42; filter: grayscale(1); }
.v-terrain .thumb { background: radial-gradient(18px 14px at 70% 34%, #c9a878 0%, rgba(201,168,120,0) 100%), radial-gradient(26px 18px at 62% 44%, #e6d9a6 0%, rgba(230,217,166,0) 100%), linear-gradient(118deg, #c3deaa 0 56%, #a8d2ee 56% 70%, #5a9bcf 70% 100%); }
.v-satellite .thumb { background: radial-gradient(20px 16px at 30% 40%, #5f7a3f 0%, rgba(95,122,63,0) 100%), radial-gradient(18px 12px at 62% 30%, #8a7a5a 0%, rgba(138,122,90,0) 100%), linear-gradient(118deg, #2f4a2c 0 56%, #123a5c 56% 100%); }
.v-relief3d .thumb { background: linear-gradient(#7fb2e5 0 34%, transparent 34%), linear-gradient(118deg, #3c5a34 0 100%); }
.v-relief3d .thumb::before { content: ""; position: absolute; left: -6px; right: -6px; bottom: 0; height: 34px; background: linear-gradient(135deg, #6b8a4a 0 50%, #2f4526 50%); clip-path: polygon(0 100%, 0 62%, 16% 30%, 30% 58%, 46% 8%, 62% 52%, 76% 28%, 100% 66%, 100% 100%); }
.v-relief3d .thumb::after { content: "3D"; position: absolute; right: 4px; top: 3px; font: 800 9px var(--font); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.v-plan .thumb { background: linear-gradient(118deg, #f2d64b 0 30%, #efe9d8 30% 52%, #d9473b 52% 62%, #a9c7dc 62% 100%); }
.mapui-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tool { display: flex; align-items: center; gap: 6px; border: 1px solid var(--glass-line); background: var(--glass); backdrop-filter: blur(8px); color: var(--ink); border-radius: 999px; padding: 6px 12px 6px 10px; cursor: pointer; font-weight: 600; font-size: 12px; box-shadow: var(--shadow); }
.tool:hover { border-color: var(--muted); }
.tool.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.measure-out { background: #121a2c; color: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 12px; box-shadow: var(--shadow); }
.mapui-panel { order: -1; width: 252px; background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--glass-line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 12px 14px; }
.panel-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; margin: 2px 0 8px; }
.panel-title:not(:first-child) { margin-top: 14px; }
.layer-row { display: flex; align-items: center; gap: 9px; padding: 4px 0; cursor: pointer; font-size: 12.5px; }
.layer-row.off { opacity: .45; cursor: not-allowed; }
.layer-row input { width: 15px; height: 15px; accent-color: var(--accent-2); margin: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel-3); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; border-radius: 7px; padding: 5px 4px; cursor: pointer; font-weight: 600; font-size: 11.5px; color: var(--muted); }
.seg button.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.panel-note { margin-top: 12px; font-size: 11.5px; color: var(--amber-ink); background: var(--amber-bg); border-radius: 8px; padding: 7px 9px; line-height: 1.4; }
.mapui-coords { position: absolute; left: 12px; top: 12px; z-index: 4; font: 600 11px var(--mono); color: #161d2b; background: rgba(255,255,255,.82); border-radius: 6px; padding: 3px 9px; pointer-events: none; white-space: nowrap; }
.mapui-coords:empty { display: none; }
.map-dark .mapui-coords { background: rgba(12,18,30,.72); color: #fff; }

/* ---------- map: MapLibre controls ---------- */
.maplibregl-map { font-family: var(--font); }
.maplibregl-ctrl-group { background: var(--glass); backdrop-filter: blur(8px); border-radius: 10px; box-shadow: var(--shadow) !important; border: 1px solid var(--glass-line); overflow: hidden; }
.maplibregl-ctrl-group button { width: 32px; height: 32px; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--glass-line); }
:root[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(180deg); }
.maplibregl-ctrl-scale { background: rgba(255,255,255,.8); border: 2px solid #161d2b; border-top: 0; color: #161d2b; font: 600 10.5px var(--mono); border-radius: 0 0 4px 4px; }
.maplibregl-ctrl-attrib { font-size: 10px; background: rgba(255,255,255,.72) !important; }
.maplibregl-popup-content { background: var(--panel); color: var(--ink); border-radius: 12px; padding: 12px 30px 12px 14px; font-size: 12px; line-height: 1.5; box-shadow: var(--shadow-lg); border: 1px solid var(--glass-line); }
.maplibregl-popup-content b { font-size: 13px; }
.maplibregl-popup-close-button { font-size: 18px; color: var(--muted); right: 4px; top: 2px; border-radius: 6px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--panel); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--panel); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--panel); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--panel); }

/* ---------- overlay / matrix ---------- */
.overlay { position: fixed; inset: var(--bar) 0 0 0; background: rgba(8,12,22,.6); backdrop-filter: blur(3px); z-index: 2000; display: grid; place-items: center; }
.overlay-card { background: var(--panel); border-radius: 14px; width: min(1400px, calc(100vw - 32px)); height: calc(100vh - 80px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--glass-line); }
.ov-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ov-head h2 { margin: 0; font-size: 16px; }
.mx-scroll { flex: 1; overflow: auto; }
table.mx { border-collapse: separate; border-spacing: 0; font-size: 11.5px; min-width: 100%; }
table.mx th, table.mx td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
table.mx thead th { position: sticky; top: 0; background: var(--top); color: #fff; z-index: 2; min-width: 220px; text-align: left; font-weight: 600; }
table.mx th.rowh { position: sticky; left: 0; background: var(--panel-2); z-index: 1; min-width: 190px; text-align: left; }
table.mx thead th.rowh { z-index: 3; background: var(--top); }
table.mx tr.BLUE th.rowh { border-left: 4px solid var(--blue); }
table.mx tr.RED th.rowh { border-left: 4px solid var(--red); }
table.mx tr.LESSON th.rowh { border-left: 4px solid var(--green); }
table.mx td .e { border-radius: 6px; padding: 3px 6px; margin-bottom: 3px; }
table.mx tr.BLUE td .e { background: var(--blue-bg); }
table.mx tr.RED td .e { background: var(--red-bg); }
table.mx tr.LESSON td .e { background: var(--green-bg); }
table.mx td .e.refused, table.mx td .e.lapsed { background: var(--panel-3) !important; color: var(--muted); text-decoration: line-through; }
table.mx td .e.proposed { outline: 1px dashed var(--amber); }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 4000; }
.toast { background: #121a2c; color: #fff; padding: 10px 14px; border-radius: 10px; max-width: 380px; box-shadow: var(--shadow-lg); font-weight: 500; animation: toast-in .18s ease-out; }
.toast.err { background: #8b1c1c; }
.toast.ok { background: #14532d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1180px) {
  .main, .main.no-right { grid-template-columns: 340px minmax(0, 1fr) 0; }
  .main.no-left, .main.no-left.no-right { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .right { display: none; }
  #btn-right, .tb-phase { display: none; }
}
@media (max-width: 760px) {
  .main, .main.no-right { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 46%; }
  .main.no-left, .main.no-left.no-right { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .mapwrap { grid-column: 1; grid-row: 1; }
  .left { grid-column: 1; grid-row: 2; border-right: 0; border-top: 1px solid var(--line); }
  .tb-online, .tb-sep, #btn-matrix, .tb-label, .brand.small .brand-mark, .tb-item:has(#tb-session), .tb-item:has(#tb-phase) { display: none; }
  .tb-value { font-size: 11.5px; }
  .role-badge { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .topbar { gap: 8px; }
  .view-card, .view-card .thumb { width: 50px; }
  .view-card .thumb { height: 38px; }
  .tool span { display: none; }
  .tool { padding: 7px; }
  .mapui-coords { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
