/* KDO Ops - phone-first operator console. Tokens first; dark by default (night venue), light when asked. */
:root {
  --bg: #101318; --panel: #181c23; --panel2: #1f242d; --line: #2c333e; --text: #eef1f5; --muted: #9aa4b2;
  --test: #1fa596; --test-bg: #0f2e2b; --live: #e5484d; --live-bg: #3a1214; --ok: #30a46c; --ok-bg: #12301f;
  --warn: #f5a524; --warn-bg: #36280c; --bad: #e5484d; --bad-bg: #3a1214; --sold: #5b8def; --unsold: #f5a524;
  --chip: #262c36; --shadow: 0 10px 30px rgba(0,0,0,.45); --r: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7; --panel: #ffffff; --panel2: #f0f2f5; --line: #d9dde3; --text: #14181f; --muted: #5d6673;
    --test-bg: #dff4f1; --live-bg: #fde4e4; --ok-bg: #dff3e7; --warn-bg: #fdf0d5; --bad-bg: #fde4e4; --chip: #e9ecf0;
    --shadow: 0 10px 30px rgba(0,0,0,.18); color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; overflow-x: hidden;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { padding: 40vh 16px 0; text-align: center; font-weight: 700; font-size: 22px; color: var(--muted); }

/* ---------- header */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: env(safe-area-inset-top) 0 0; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 6px; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .2px; flex: 0 0 auto; }
.spacer { flex: 1 1 auto; }
.pill { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 2px solid transparent; font-weight: 800;
  display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.pill.test { background: var(--test-bg); color: var(--test); border-color: var(--test); }
.pill.live { background: var(--live); color: #fff; border-color: var(--live); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.6); } 50% { box-shadow: 0 0 0 6px rgba(229,72,77,0); } }
.iconbtn { min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  font-size: 20px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.modebar { padding: 7px 12px; font-size: 13.5px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.modebar.test { background: var(--test-bg); color: var(--test); }
.modebar.live { background: var(--live); color: #fff; }
.modebar .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbline { padding: 2px 14px 4px; font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.dbline .grow { flex: 1; min-width: 0; }
.dbline.bad { color: var(--bad); }
.dbline button { min-height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; }

/* ---------- search + chips */
.searchwrap { padding: 8px 12px 8px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 4px 0 12px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; min-height: 46px; outline: none; font-size: 16px; }
.search button { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 18px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .65; font-weight: 500; margin-left: 4px; }
.countline { display: flex; align-items: center; gap: 8px; padding: 2px 14px 6px; color: var(--muted); font-size: 12.5px; }
.countline .grow { flex: 1; }

/* ---------- list */
.list { padding: 0 8px 120px; }
.row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 6px 10px 8px; border-radius: var(--r); margin: 6px 0;
  background: var(--panel); border: 1px solid var(--line); user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; touch-action: pan-y; position: relative; }
.row.pressing { background: var(--panel2); transform: scale(.985); transition: transform .15s; }
.row.removed { opacity: .55; }
.ava { flex: 0 0 52px; width: 52px; height: 52px; border-radius: 12px; overflow: hidden; background: var(--chip);
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); font-size: 18px; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.rmain { flex: 1 1 auto; min-width: 0; }
.rname { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.rsub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; margin-top: 1px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag { font-size: 11.5px; font-weight: 700; padding: 3px 7px; border-radius: 7px; background: var(--chip); color: var(--text);
  letter-spacing: .2px; max-width: 100%; overflow-wrap: anywhere; }
.tag.AVAILABLE { background: var(--ok-bg); color: var(--ok); }
.tag.SOLD { background: rgba(91,141,239,.18); color: var(--sold); }
.tag.UNSOLD { background: var(--warn-bg); color: var(--warn); }
.tag.OPEN { background: var(--live); color: #fff; }
.tag.cap { background: #3b2f0a; color: #ffd166; }
.tag.smoke { opacity: .6; }
.tag.removed { background: var(--bad-bg); color: var(--bad); }
.tag.nopool { background: var(--warn-bg); color: var(--warn); }
.more { flex: 0 0 44px; min-height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 22px; border-radius: 10px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.fab { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 20px;
  border: 0; font-size: 30px; font-weight: 700; color: #fff; background: var(--test); box-shadow: var(--shadow); z-index: 25; }
.fab.live { background: var(--live); }

/* ---------- sheets / modals */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; background: var(--panel); border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; border-top: 4px solid var(--test); }
.sheet.live { border-top-color: var(--live); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 2px; flex: 0 0 auto; }
.sheet .head { padding: 6px 16px 10px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); }
.sheet .head .t { font-weight: 800; font-size: 17px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sheet .body { padding: 12px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet .foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.btn { min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2);
  font-weight: 700; font-size: 15.5px; flex: 1 1 0; }
.btn.primary { background: var(--test); border-color: var(--test); color: #fff; }
.btn.danger { background: var(--live); border-color: var(--live); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn:disabled { opacity: .45; }
.btn.block { width: 100%; display: block; margin: 8px 0; }
.alist { display: flex; flex-direction: column; gap: 8px; }
.abtn { text-align: left; min-height: 52px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2);
  font-weight: 700; font-size: 15.5px; }
.abtn small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.abtn:disabled { opacity: .55; }
.abtn.danger { color: var(--bad); }
.sect { margin: 14px 0 6px; font-size: 12px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; gap: 6px 10px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.kv div { overflow-wrap: anywhere; }
.note { font-size: 13px; color: var(--muted); }
.box { border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.box.warn { background: var(--warn-bg); color: var(--warn); }
.box.bad { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.box.ok { background: var(--ok-bg); color: var(--ok); }
.box.test { background: var(--test-bg); color: var(--test); font-weight: 700; }
.box.live { background: var(--live); color: #fff; font-weight: 800; }
.box ul { margin: 4px 0 0; padding-left: 18px; }
.ba { width: 100%; border-collapse: collapse; font-size: 14px; }
.ba th { text-align: left; color: var(--muted); font-weight: 700; font-size: 12px; padding: 4px 4px; }
.ba td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.ba td.pl { font-weight: 700; width: 26%; }
.ba tr.smoke td { color: var(--muted); font-size: 12.5px; }
.ba .gone { color: var(--bad); text-decoration: line-through; }
.ba .new { color: var(--ok); font-weight: 700; }
.ba .same { color: var(--muted); }
.ba tr.changed td.pl { color: var(--text); }
details.sql { margin-top: 10px; }
details.sql summary { min-height: 44px; display: flex; align-items: center; color: var(--muted); font-weight: 700; }
details.sql pre { white-space: pre-wrap; word-break: break-word; font-size: 11px; background: var(--bg); padding: 10px; border-radius: 10px;
  max-height: 40vh; overflow: auto; }
label.f { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
input.in, select.in, textarea.in { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  padding: 0 12px; font-size: 16px; }
textarea.in { padding: 10px 12px; min-height: 70px; }
.rolechips { display: flex; flex-wrap: wrap; gap: 8px; }
.rolechips .chip { min-height: 44px; }
.photoprev { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.photoprev img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.mcard { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; background: var(--panel); border-radius: 18px; box-shadow: var(--shadow);
  padding: 18px 16px 14px; border-top: 6px solid var(--line); }
.mcard.done { border-top-color: var(--ok); }
.mcard.not_changed, .mcard.unknown { border-top-color: var(--bad); }
.mcard.stale, .mcard.check { border-top-color: var(--warn); }
.mcard .icon { font-size: 34px; font-weight: 900; }
.mcard.done .icon { color: var(--ok); }
.mcard.not_changed .icon, .mcard.unknown .icon { color: var(--bad); }
.mcard.stale .icon, .mcard.check .icon { color: var(--warn); }
.mcard h2 { margin: 4px 0 6px; font-size: 20px; }
.mcard .msg { font-size: 15.5px; overflow-wrap: anywhere; }
.mcard .modetag { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 6px; margin-left: 6px; vertical-align: middle; }
.modetag.TEST { background: var(--test-bg); color: var(--test); }
.modetag.LIVE { background: var(--live); color: #fff; }
.checklist label { display: flex; gap: 10px; align-items: center; min-height: 44px; font-size: 14.5px; }
.checklist input { width: 22px; height: 22px; flex: 0 0 auto; }
.mbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.mbtns .btn { flex: 1 1 140px; }
.busy { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; }
.busy .card { background: var(--panel); border-radius: 16px; padding: 18px 22px; display: flex; gap: 12px; align-items: center; font-weight: 700; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--test); animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 95; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow); }

/* ---------- login */
.login { max-width: 420px; margin: 0 auto; padding: calc(12vh + env(safe-area-inset-top)) 20px 40px; }
.login h1 { font-size: 30px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.login .btn { width: 100%; display: block; margin: 10px 0; min-height: 54px; font-size: 17px; }
.login input.code { letter-spacing: 8px; text-align: center; font-size: 26px; min-height: 60px; font-weight: 800; }
.msgline { min-height: 22px; font-size: 14.5px; margin: 6px 0; }
.msgline.bad { color: var(--bad); font-weight: 700; }
.msgline.ok { color: var(--ok); font-weight: 700; }
.fakebanner { background: var(--live); color: #fff; font-weight: 800; padding: 8px 12px; border-radius: 10px; margin-bottom: 14px; text-align: center; }
.hist { border-top: 1px solid var(--line); padding: 10px 0; }
.hist .l1 { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.hist .l2 { font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.hist .l3 { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.hist .st-done { color: var(--ok); } .hist .st-not_changed, .hist .st-unknown { color: var(--bad); } .hist .st-check, .hist .st-stale { color: var(--warn); }
@media (min-width: 700px) { .list { max-width: 760px; margin: 0 auto; } .chips, .searchwrap { max-width: 760px; margin: 0 auto; } }
