:root {
  --bg: #0d1117; --bg2: #131a24; --bg3: #1b2433; --line: #263247; --text: #e6edf3; --muted: #8b98a9;
  --accent: #5b8def; --accent2: #7ee0c3; --danger: #ef5350; --warn: #ffb74d; --ok: #66bb6a;
  --radius: 8px; --side: 260px; --panel: 400px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .error { color: var(--danger); min-height: 1.2em; }
button, .button, select, input, textarea {
  font: inherit; color: var(--text); background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
button, .button { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.ok { background: transparent; border-color: var(--ok); color: var(--ok); }
button.ghost { background: transparent; }
button.small, .button.small { padding: 4px 8px; font-size: 12px; }
button.icon { background: transparent; border: none; font-size: 18px; padding: 4px 8px; }
input, textarea { width: 100%; } textarea { min-height: 90px; resize: vertical; }
label { display: block; margin: 6px 0; } label > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
label.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
label.row > span { margin: 0; } label.row select { width: 130px; }
label.check { justify-content: flex-start; } label.check input { width: auto; }

.login { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, #1b2a48, var(--bg) 60%); }
.login-card { width: min(360px, 92vw); background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login-card button { width: 100%; justify-content: center; margin-top: 10px; }
.brand { font-weight: 700; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand.big { font-size: 22px; } .brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 12px var(--accent), 0 0 24px var(--accent2); }

.app { display: grid; height: 100vh; grid-template-columns: var(--side) 1fr auto; grid-template-rows: auto 1fr;
  grid-template-areas: "top top top" "side main panel"; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg2);
  border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.search-wrap { position: relative; flex: 1; min-width: 160px; max-width: 460px; margin-left: auto; }
.search-results { position: absolute; top: 110%; left: 0; right: 0; z-index: 50; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); max-height: 60vh; overflow: auto; box-shadow: 0 10px 30px #0008; }
.search-results .hit { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.search-results .hit:hover, .search-results .hit:focus { background: var(--bg3); }
.search-results .hit .extrait { color: var(--muted); font-size: 12px; }

.sidebar { grid-area: side; overflow: auto; padding: 10px 12px; border-right: 1px solid var(--line); background: var(--bg2); }
.sidebar h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 6px; }
.sidebar section > input { margin: 4px 0; } .sidebar #btn-apply { width: 100%; justify-content: center; margin-top: 6px; }
.checklist label { display: flex; align-items: center; gap: 6px; margin: 2px 0; font-size: 13px; }
.checklist input { width: auto; } .checklist .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.checklist.scroll { max-height: 220px; overflow: auto; }
.legend { display: grid; gap: 2px; font-size: 12px; } .legend div { display: flex; gap: 6px; align-items: center; }

.main { grid-area: main; position: relative; overflow: hidden; }
.view { display: none; height: 100%; overflow: auto; padding: 10px 14px; } .view.active { display: block; }
#view-graph { padding: 0; display: none; flex-direction: column; } #view-graph.active { display: flex; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.cy { flex: 1; min-height: 300px; background: radial-gradient(circle at 50% 40%, #121c2c, var(--bg) 70%); }
.banner { padding: 6px 12px; background: #2a3550; color: var(--accent2); font-size: 13px; }
.small-input { width: 200px; }

.panel { grid-area: panel; width: var(--panel); overflow: auto; border-left: 1px solid var(--line); background: var(--bg2); padding: 10px 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head h2 { font-size: 16px; margin: 6px 0; word-break: break-word; }
.panel h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 2px 8px; font-size: 12px; }
.kv .k { color: var(--muted); } .kv .v { word-break: break-word; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; background: var(--bg3); border: 1px solid var(--line); font-size: 11px; margin: 1px; }
.st-validee { border-color: var(--ok); color: var(--ok); } .st-proposee { border-color: var(--warn); color: var(--warn); }
.st-contestee, .st-rejetee { border-color: var(--danger); color: var(--danger); } .st-obsolete { color: var(--muted); }
.rel { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.rel a, a.link { color: var(--accent); cursor: pointer; text-decoration: none; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.preview { margin: 6px 0 10px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #000; }
.preview img, .preview video { max-width: 100%; display: block; margin: auto; } .preview audio { width: 100%; }
.preview iframe { width: 100%; height: 360px; border: 0; background: #fff; }
.frames { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; } .frames img { width: 100%; }
.warn-box { border: 1px solid var(--warn); color: var(--warn); border-radius: 6px; padding: 6px 8px; font-size: 12px; margin: 6px 0; }
pre.text { white-space: pre-wrap; max-height: 260px; overflow: auto; background: var(--bg); padding: 8px; border-radius: 6px; font-size: 12px; }
.meta-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 4px; margin: 3px 0; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table tr:hover td { background: var(--bg3); cursor: pointer; }
.dropzone { margin: 10px 0; padding: 26px; border: 2px dashed var(--line); border-radius: 12px; text-align: center; color: var(--muted); }
.dropzone.over { border-color: var(--accent); color: var(--text); background: #5b8def14; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; }
.ask { display: flex; gap: 8px; margin-bottom: 10px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--accent);
  padding: 8px 14px; border-radius: 8px; z-index: 100; max-width: 90vw; }
dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: min(480px, 94vw); }
dialog::backdrop { background: #0009; } .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.only-mobile { display: none; }

@media (max-width: 1100px) { :root { --panel: 340px; --side: 220px; } .tabs button { padding: 6px; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
  .only-mobile { display: inline-flex; }
  .topbar { flex-wrap: wrap; } .tabs { order: 5; width: 100%; } .search-wrap { order: 4; max-width: none; flex-basis: 100%; margin-left: 0; min-width: 0; }
  html, body { overflow-x: hidden; }
  #whoami { display: none; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 82vw; max-width: 320px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px #000; }
  .panel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 62vh; z-index: 55; border-left: 0;
    border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -10px 30px #000a; }
  .small-input { width: 100%; }
}
