:root {
  --bg: #15171a; --panel: #1e2126; --panel2: #262a31; --line: #363b44; --text: #e6e2d6; --muted: #9a9687;
  --accent: #c9a24a; --accent2: #8a6d2c; --danger: #c0453b; --ok: #4f9a5a; --blue: #4a7fc9;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1, h2, h3 { font-weight: 600; letter-spacing: .02em; margin: 0 0 12px; }
h1 { font-size: 22px; } h2 { font-size: 17px; color: var(--accent); } h3 { font-size: 15px; }

button, .btn {
  background: var(--accent2); color: #fff; border: 1px solid var(--accent); border-radius: 4px; padding: 6px 12px;
  cursor: pointer; font: inherit; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .45; cursor: default; filter: none; }
button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
button.danger { background: var(--danger); border-color: #e0685f; }
button.ok { background: var(--ok); border-color: #6cbd78; }
button.small { padding: 3px 8px; font-size: 12px; }
button.active { outline: 2px solid var(--accent); background: #3a3120; }
input, select, textarea {
  background: #111316; color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; font: inherit; max-width: 100%;
}
input[type=color] { padding: 0; width: 38px; height: 30px; }
input[type=checkbox] { width: auto; }
input.num { width: 80px; }
label { display: block; margin: 8px 0 3px; color: var(--muted); font-size: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 4px 12px 4px 0; color: var(--text); font-size: 13px; }

#topbar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: #0f1113; border-bottom: 1px solid var(--line); height: 48px; }
#topbar .brand { font-weight: 700; color: var(--accent); font-size: 16px; }
#topbar nav { display: flex; gap: 14px; }
#topbar .spacer { flex: 1; }
.badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; }
#app { min-height: calc(100% - 48px); }
.page { max-width: 1150px; margin: 0 auto; padding: 24px 16px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid #0006; vertical-align: middle; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 4px; color: var(--text); }
.tabs a.on { background: var(--accent2); border-color: var(--accent); }

/* connexion */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #2a2418, #0d0e10 70%); }
.login-box { width: 340px; background: var(--panel); border: 1px solid var(--accent2); border-radius: 8px; padding: 28px; }
.login-box h1 { text-align: center; color: var(--accent); }
.login-box input { width: 100%; }
.login-box button { width: 100%; justify-content: center; margin-top: 14px; }
.err { color: #ff8a80; min-height: 18px; margin-top: 8px; font-size: 13px; }

/* liste des théâtres */
.theater-item { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; margin-bottom: 8px; background: var(--panel2); }
.theater-item .t-name { font-weight: 600; font-size: 15px; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.pill.front { border-color: var(--blue); color: #9cc0f0; }
.pill.battle { border-color: var(--danger); color: #f0a39c; }
.pill.warn { border-color: var(--accent); color: var(--accent); }

/* notifications */
#notifPanel { position: fixed; right: 12px; top: 52px; width: 380px; max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; z-index: 50; box-shadow: 0 8px 30px #000a; }
.notif { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.notif.unread { background: #2b2618; }
.notif .when { color: var(--muted); font-size: 11px; }
.notif .row { margin-top: 6px; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; }
#toast div { background: #000d; border: 1px solid var(--accent2); padding: 8px 16px; border-radius: 5px; margin-top: 6px; }
#toast div.bad { border-color: var(--danger); }

/* carte */
.map-layout { display: flex; height: calc(100vh - 48px); }
.map-wrap { flex: 1; position: relative; overflow: hidden; background: #0b0c0e; }
.map-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sidebar { width: 320px; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 12px; }
.sidebar section { border-bottom: 1px solid var(--line); padding: 10px 0; }
.sidebar section:last-child { border-bottom: 0; }
.map-hud { position: absolute; left: 10px; top: 10px; background: #000b; border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; font-size: 13px; max-width: 60%; }
.map-help { position: absolute; left: 10px; bottom: 10px; background: #000a; border-radius: 5px; padding: 6px 10px; font-size: 12px; color: var(--muted); }
.popup { position: absolute; z-index: 20; background: var(--panel); border: 1px solid var(--accent2); border-radius: 6px; padding: 12px; min-width: 220px; max-width: 360px; box-shadow: 0 6px 24px #000c; }
.popup .close { position: absolute; right: 6px; top: 4px; cursor: pointer; color: var(--muted); }
.compo { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.compo img { width: 34px; height: 22px; object-fit: contain; background: #0005; border-radius: 3px; }
.events { font-size: 12px; max-height: 260px; overflow: auto; }
.events div { padding: 2px 0; border-bottom: 1px dotted #333; }
.banner { padding: 8px 10px; border-radius: 5px; margin-bottom: 8px; font-size: 13px; }
.banner.warn { background: #3a3120; border: 1px solid var(--accent); }
.banner.info { background: #1d2a3a; border: 1px solid var(--blue); }
.thumb { width: 64px; height: 42px; object-fit: contain; background: #0006; border: 1px solid var(--line); border-radius: 3px; }
.unit-card { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel2); cursor: pointer; }
.unit-card:hover { border-color: var(--accent); }
.report-table td, .report-table th { padding: 3px 4px; font-size: 11px; }
/* ---------- téléphone / petite tablette ---------- */
.side-toggle { display: none; }
.map-wrap canvas { touch-action: none; }
@media (max-width: 800px) {
  #topbar { gap: 8px; padding: 6px 8px; }
  #topbar .brand { font-size: 0; gap: 0; }
  #topbar .brand img { width: 30px; height: 30px; }
  #topbar nav { gap: 10px; font-size: 13px; }
  #topbar nav a { white-space: nowrap; }
  #meName { display: none; }
  #logoutBtn { padding: 4px 8px; font-size: 12px; }
  #bell { padding: 4px 8px; }
  #notifPanel { left: 8px; right: 8px; width: auto; }
  .page { padding: 14px 10px; }
  .card { padding: 12px; overflow-x: auto; }
  .grid2 { grid-template-columns: 1fr; }
  h1 { font-size: 19px; }
  input, select, textarea { font-size: 16px; } /* évite le zoom automatique de l'iPhone */
  button, .btn { padding: 8px 12px; }
  button.small { padding: 6px 10px; font-size: 13px; }
  .theater-item { gap: 8px; }
  .theater-item > div[style*="text-align:right"] { text-align: left !important; }
  .login-box { width: calc(100vw - 32px); }
  #toast { width: calc(100vw - 24px); bottom: 12px; text-align: center; }
  /* carte : plein écran, panneau en bas qu'on agrandit / réduit */
  .map-layout { flex-direction: column; height: calc(100vh - 48px); height: calc(100dvh - 48px); }
  .map-wrap { flex: 1 1 auto; min-height: 120px; }
  .side-toggle { display: block; width: 100%; border-radius: 0; border-left: 0; border-right: 0; background: var(--panel2); border-color: var(--line); color: var(--text); padding: 6px; font-size: 13px; justify-content: center; }
  .sidebar { width: 100%; height: 42%; flex: 0 0 auto; border-left: 0; border-top: 0; padding: 8px 10px; }
  .side-big .sidebar { height: 72%; }
  .side-min .sidebar { display: none; }
  .map-hud { font-size: 12px; max-width: calc(100% - 20px); padding: 5px 8px; }
  .map-help { font-size: 11px; right: 10px; }
  .popup { left: 8px !important; right: 8px; top: 8px !important; min-width: 0; max-width: none; max-height: calc(100% - 16px); overflow: auto; }
  .popup .close { font-size: 20px; padding: 4px 8px; right: 2px; top: 0; }
  table { font-size: 13px; }
  .tabs a { padding: 6px 10px; font-size: 13px; }
}

#topbar .brand { display: inline-flex; align-items: center; gap: 8px; }
#topbar .brand img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; }
.login-logo { display: block; width: 120px; height: 120px; margin: 0 auto 10px; border-radius: 8px; object-fit: cover; }

.paste-overlay { position: fixed; inset: 0; background: #000a; z-index: 200; display: grid; place-items: center; }
.paste-box { background: var(--panel); border: 1px solid var(--accent2); border-radius: 8px; padding: 20px; width: 380px; max-width: calc(100vw - 32px); outline: none; }
.paste-zone { border: 2px dashed var(--line); border-radius: 8px; padding: 28px 12px; text-align: center; display: grid; gap: 6px; }
.paste-zone.over { border-color: var(--accent); background: #2b2618; }

.paste-slot { border-radius: 6px; padding: 4px; margin: -4px; transition: background .15s; }
.paste-slot:hover { background: #2b261855; box-shadow: inset 0 0 0 1px var(--accent2); }
