/* Two deliberate looks from one token set:
   - the dispatcher board is dark and dense (indoor screen, all day, lots of rows)
   - the crew view is high-contrast light (a phone in direct sun, wearing gloves) */

:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel-2: #1d2331;
  --line: #2a3242;
  --text: #e6ebf4;
  --muted: #8b97ad;
  --accent: #5b8def;
  --ok: #3fb27f;
  --warn: #e0a53c;
  --bad: #e2604a;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

body.crew-mode {
  --bg: #ffffff;
  --panel: #f4f6fa;
  --panel-2: #ffffff;
  --line: #c3ccdb;
  --text: #10151f;
  --muted: #4d5769;
  --accent: #1f5fd0;
  --ok: #14794f;
  --warn: #8a5a00;
  --bad: #b3261e;
  --shadow: 0 2px 10px rgba(16, 21, 31, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }

input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.chip.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.chip.neutral { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ----------------------------------------------------------- app skeleton */

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.brand .mark { width: 9px; height: 18px; border-radius: 3px; background: linear-gradient(180deg, var(--accent), var(--ok)); }

.layout { display: grid; grid-template-columns: 210px 1fr 300px; gap: 14px; padding: 14px; align-items: start; }
@media (max-width: 1200px) { .layout { grid-template-columns: 1fr; } .side, .feed { order: 2; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.panel h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.side .group { margin-bottom: 14px; }
.side .opt { display: flex; align-items: center; gap: 7px; padding: 4px 0; cursor: pointer; font-size: 13px; }

/* ------------------------------------------------------------------ board */

.daygroup { margin-bottom: 18px; }
.dayhead { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.dayhead .muted { font-weight: 400; }

.job {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color .12s, transform .06s;
}
.job:hover { border-color: var(--accent); }
.job:active { transform: scale(.997); }
.job.risk-unworkable { border-left-color: var(--bad); }
.job.risk-at_risk { border-left-color: var(--warn); }
.job.risk-ok { border-left-color: var(--ok); }
.job .time { font-weight: 700; font-size: 13px; }
.job .ref { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; }
.job .title { font-weight: 600; }
.job .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.job .tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.counts { display: flex; gap: 8px; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------- feed */

.feed .item { padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.feed .item:last-child { border-bottom: 0; }
.feed .when { color: var(--muted); font-size: 11px; }
.live { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live .dot { background: var(--muted); }
.live.on .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

/* ----------------------------------------------------------------- drawer */

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(720px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--line);
  z-index: 41;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.drawer header {
  position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 12px 16px; display: flex; align-items: center; gap: 10px; z-index: 2;
}
.drawer .body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl { display: grid; grid-template-columns: 62px 1fr; gap: 10px; font-size: 13px; }
.tl .t { color: var(--muted); font-size: 11px; padding-top: 2px; }
.tl .c { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.photos figcaption { font-size: 11px; color: var(--muted); margin-top: 3px; }

.forecast { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.fc { min-width: 74px; text-align: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 4px; font-size: 11px; }
.fc .tmp { font-size: 15px; font-weight: 700; }

.reasons { margin: 6px 0 0; padding-left: 18px; }
.reasons li { margin: 2px 0; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  color: var(--text); padding: 0; max-width: min(680px, 94vw); width: 100%; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog .dlg-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; align-items: center; }
dialog .dlg-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow-y: auto; }
dialog .dlg-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; z-index: 90; box-shadow: var(--shadow); max-width: 90vw;
}
.toast.bad { border-color: var(--bad); color: var(--bad); }
.toast.ok { border-color: var(--ok); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- crew view */

body.crew-mode { font-size: 16px; }
.crew-wrap { max-width: 640px; margin: 0 auto; padding: 12px 12px 90px; }
.crew-top { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--panel); border-bottom: 2px solid var(--line); position: sticky; top: 0; z-index: 10; }

.jobcard {
  background: var(--panel-2); border: 2px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px; cursor: pointer;
}
.jobcard.risk-unworkable { border-color: var(--bad); }
.jobcard.risk-at_risk { border-color: var(--warn); }
.jobcard h2 { margin: 0 0 2px; font-size: 19px; }
.jobcard .addr { color: var(--muted); font-size: 15px; }

.bigbtn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 62px; border-radius: 14px; font-size: 18px; font-weight: 700;
  border: 2px solid var(--line); background: var(--panel-2); cursor: pointer; margin-bottom: 10px;
  -webkit-tap-highlight-color: transparent;
}
.bigbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.bigbtn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
.bigbtn:disabled { opacity: .55; }
.bigbtn.done { background: var(--ok); border-color: var(--ok); color: #fff; }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; border: 2px solid; font-weight: 600; }
.banner.ok { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.banner.warn { border-color: var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.banner.bad { border-color: var(--bad); color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }

.notelist { display: flex; flex-direction: column; gap: 10px; }
.notelist .n { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }

.reclabel { text-align: center; font-size: 15px; color: var(--muted); margin-bottom: 10px; min-height: 22px; }

.login {
  max-width: 380px; margin: 14vh auto; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px 26px;
}
.login h1 { margin: 0 0 6px; font-size: 22px; }
.login p { color: var(--muted); margin: 0 0 20px; }

#video-stage { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
#video-stage .vbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); }
#video-stage rtk-meeting { flex: 1; min-height: 0; }
