/*
 * Place Scout Control Center.
 *
 * Russian interface, Hebrew and Arabic venue names inside it. Those names must read
 * right-to-left without dragging the surrounding Russian layout with them — hence
 * `unicode-bidi: isolate` on the cells that carry them rather than `dir="rtl"` on anything
 * structural. Setting direction on a row would flip the column order of the whole table.
 */

:root {
  --ink: #16191c;
  --muted: #5d6a72;
  --paper: #f4f6f7;
  --surface: #fff;
  --rule: #dde3e7;
  --accent: #6b2440;
  --ok: #1c6b51;
  --warn: #8a5a12;
  --bad: #93303a;
  --ok-bg: #e7f1ed;
  --warn-bg: #f7efdc;
  --bad-bg: #f8e8ea;
  --side: 15rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8ebed; --muted: #9aa5ac; --paper: #121517; --surface: #191d20;
    --rule: #2b3236; --accent: #d98ba6; --ok: #55b894; --warn: #d6a24a; --bad: #e2868f;
    --ok-bg: #15291f; --warn-bg: #2a2314; --bad-bg: #2c1a1c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---- navigation ---- */
.side {
  width: var(--side); flex: none;
  background: var(--surface); border-inline-end: 1px solid var(--rule);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px; border-bottom: 1px solid var(--rule); }
.brand strong { display: block; font-size: 1.05rem; }
.brand small { color: var(--muted); }
#nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; overflow-y: auto; }
#nav button {
  text-align: start; padding: 9px 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink); font: inherit; cursor: pointer;
}
#nav button:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#nav button.on { background: var(--accent); color: #fff; }
.side-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--rule); display: grid; gap: 6px; }
.side-foot small { color: var(--muted); }

main { flex: 1; padding: 26px 30px 70px; min-width: 0; }
h1 { font-size: 1.6rem; margin: 0 0 18px; }
h2 { font-size: 1.1rem; margin: 30px 0 10px; }
h3 { font-size: .98rem; margin: 22px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: .9rem; }
.screen { display: none; }
.screen.on { display: block; }

/* ---- cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 16px; }
.card b { display: block; font-size: 1.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.card span { display: block; margin-top: 5px; font-size: .8rem; color: var(--muted); }
.card.ok b { color: var(--ok); } .card.warn b { color: var(--warn); } .card.bad b { color: var(--bad); }

/* ---- tables ---- */
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; border-bottom: 2px solid var(--rule); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
td.num { text-align: end; font-variant-numeric: tabular-nums; }

/* Venue names: isolate the bidi run so Hebrew does not reorder the Russian around it. */
.name { unicode-bidi: isolate; }

/* ---- chips ---- */
.pill {
  display: inline-block; white-space: nowrap; font-size: .72rem; padding: 2px 7px;
  border-radius: 4px; border: 1px solid var(--rule); color: var(--muted);
}
.pill.ok { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.pill.warn { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.pill.bad { color: var(--bad); background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }

/* ---- controls ---- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.sep { flex: 1 0 0; }
input, select, button, textarea {
  font: inherit; padding: 7px 10px; border-radius: 6px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
}
button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent); }
button.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
button.danger { background: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .45; cursor: not-allowed; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 20px; }

.note { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; font-size: .9rem; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.info { background: var(--ok-bg); color: var(--ok); }

/* ---- drawer ---- */
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(44rem, 100%);
  background: var(--surface); border-inline-start: 1px solid var(--rule);
  overflow-y: auto; padding: 22px 26px 60px; z-index: 20;
  box-shadow: -10px 0 40px rgba(0,0,0,.18);
}
.drawer-head { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.drawer h2 { margin: 0; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }

.kv { display: grid; grid-template-columns: minmax(8rem, auto) 1fr; gap: 6px 14px; margin: 10px 0 18px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; unicode-bidi: isolate; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.ev { border-inline-start: 3px solid var(--rule); padding: 6px 0 6px 12px; margin-bottom: 10px; font-size: .88rem; }
.ev a { color: var(--accent); word-break: break-all; }

/* The daily round: a numbered step that reads as done or as work, at a glance. */
.step { display: grid; grid-template-columns: 2.2rem 1fr; gap: 12px; align-items: start;
  border: 1px solid var(--rule); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px;
  background: var(--surface); }
.step-n { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  font-weight: 600; font-variant-numeric: tabular-nums; }
.step.ok .step-n { background: var(--ok-bg); color: var(--ok); }
.step.todo .step-n { background: var(--warn-bg); color: var(--warn); }
.step.todo { border-inline-start: 3px solid var(--warn); }

/* Blockers read as a checklist of work, so each item carries its own next step. */
.blockers { list-style: none; padding: 0; margin: 10px 0 18px; display: grid; gap: 10px; font-size: .88rem; }
.blockers li { border-inline-start: 3px solid var(--warn); padding: 6px 0 6px 12px; unicode-bidi: isolate; }

/* The queue tabs are this screen's only navigation; the counts must read at a glance. */
#q-tabs { gap: 6px; }
#q-tabs button { font-size: .88rem; }
#geo-tabs { gap: 6px; }
#geo-tabs button { font-size: .88rem; }

/* Row actions sit inside a table cell and must not outweigh the data beside them. */
button.tiny { font-size: .76rem; padding: 4px 8px; }

#map-wrap { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 10px; overflow: auto; }
canvas { max-width: 100%; height: auto; display: block; }

.toast {
  position: fixed; inset-block-end: 20px; inset-inline-start: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 6px; z-index: 40;
}

/* ---- phone ---- */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav button { white-space: nowrap; }
  main { padding: 18px 14px 60px; }
  /* Cards rather than a table that scrolls the whole page sideways. */
  .scroll table, .scroll thead, .scroll tbody, .scroll th, .scroll td, .scroll tr { display: block; }
  .scroll thead { display: none; }
  .scroll tr { border-bottom: 1px solid var(--rule); padding: 8px 4px; }
  .scroll td { border: 0; padding: 3px 8px; }
  .scroll td::before { content: attr(data-label) ": "; color: var(--muted); font-size: .78rem; }
}
