/* Админка «Найди чудо»: светлая, читаемая, сначала телефон. Без внешних шрифтов. */
:root {
  --bg: #f4f5f7; --card: #fff; --ink: #17202e; --muted: #667085; --line: #e3e6ec;
  --brand: #8a1f2a; --ok: #157347; --warn: #9a5b00; --err: #b42318; --play: #1d4ed8;
  --ok-bg: #e8f5ee; --warn-bg: #fff4e0; --err-bg: #fdecea; --info-bg: #eef2ff;
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; padding-bottom: 72px; }
a { color: var(--play); }
code { font: 14px ui-monospace, Menlo, Consolas, monospace; background: #f1f3f6; padding: 1px 4px; border-radius: 4px; word-break: break-all; }
h1 { font-size: 22px; margin: 6px 0 12px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 10px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
main { max-width: 980px; margin: 0 auto; padding: 8px 12px 24px; }
.muted { color: var(--muted); font-weight: normal; }
.err { color: var(--err); } .warn { color: var(--warn); } .ok { color: var(--ok); }
.offscreen { position: fixed; left: -9999px; top: 0; }

.top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 8px 12px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 8; }
.brand { color: #fff; text-decoration: none; font-weight: 700; white-space: nowrap; font-size: 15px; }
.top .search { flex: 1 1 220px; min-width: 0; margin: 0; }
.sbox { position: relative; flex: 1; min-width: 0; }
.search input { min-width: 0; }
html, body { overflow-x: hidden; }
.top .search input { background: #fff; }
.top .search .btn { display: none; }

.nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); z-index: 6;
  padding-bottom: env(safe-area-inset-bottom); overflow-x: auto; }
.nav a { flex: 1; text-align: center; padding: 12px 8px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.nav a[aria-current] { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .nav { position: sticky; top: 52px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; }
  .nav a { flex: 0 0 auto; padding: 10px 18px; }
  .nav a[aria-current] { box-shadow: inset 0 -3px 0 var(--brand); }
  .top .search .btn { display: inline-block; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 0 0 12px; }
.search { display: flex; gap: 8px; margin: 0 0 12px; }
input, textarea, select { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid #c9ced8; border-radius: 10px; background: #fff; color: var(--ink); }
input[type=checkbox], input[type=radio] { width: auto; }
label { display: block; margin: 0 0 12px; font-weight: 600; }
label input, label textarea, label select { margin-top: 4px; font-weight: normal; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: normal; }

.btn { display: inline-block; font: inherit; font-weight: 600; font-size: 15px; padding: 10px 14px; border-radius: 10px; border: 1px solid #c9ced8;
  background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; line-height: 1.2; min-height: 42px; }
.btn:hover { border-color: var(--ink); }
.btn.small { font-size: 14px; padding: 7px 10px; min-height: 34px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn:disabled { opacity: .6; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
form.inline { display: inline; margin: 0; }
form.stack { max-width: 520px; }
form.login { max-width: 380px; margin: 20px auto; background: var(--card); padding: 18px; border-radius: var(--r); border: 1px solid var(--line); }
form.login .btn { width: 100%; }

.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 12px; font-weight: 600; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.info { background: var(--info-bg); color: var(--play); }
.explain { background: var(--warn-bg); padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; }
.problems { background: var(--err-bg); color: var(--err); border-radius: 10px; padding: 6px 12px; margin: 0 0 10px; }
.problems p { margin: 6px 0; }
.lead { margin: 0 0 12px; }

.reply { background: var(--ok-bg); border: 1px solid #b7dfc6; border-radius: var(--r); padding: 12px; margin: 0 0 12px; }
.reply-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.reply textarea { min-height: 90px; resize: vertical; background: #fff; }

.kv { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; } }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; margin-top: 8px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; background: #f7f8fa; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.tile.warn { background: var(--warn-bg); }
.t-v { font-size: 24px; font-weight: 700; }
.t-l { font-weight: 600; }
.t-s { color: var(--muted); font-size: 13px; }

.attention { list-style: none; padding: 0; margin: 0; }
.att { padding: 8px 10px; border-left: 4px solid var(--warn); background: var(--warn-bg); border-radius: 6px; margin: 0 0 6px; }
.att.err { border-color: var(--err); background: var(--err-bg); }
.empty { color: var(--muted); margin: 4px 0; }
div.empty { padding: 14px; border: 1px dashed var(--line); border-radius: 10px; background: var(--card); }
div.empty p { margin: 0 0 4px; color: var(--ink); font-weight: 600; }
.empty-hint { display: block; font-size: 14px; margin-bottom: 6px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: 0 0 10px; }
.chip { white-space: nowrap; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 14px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.orow { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  margin: 0 0 8px; text-decoration: none; color: var(--ink); }
.orow .l2 { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
/* статус заказа — чип: один вид = один цвет везде (список, карточка, подсказки поиска) */
.st { display: inline-block; font-weight: 600; font-size: 13px; line-height: 1.35; padding: 1px 9px; border-radius: 999px;
  background: #eceff3; color: var(--muted); }
.st.ok { color: var(--ok); background: var(--ok-bg); } .st.warn { color: var(--warn); background: var(--warn-bg); }
.st.play { color: var(--play); background: var(--info-bg); } .st.muted { color: var(--muted); background: #eceff3; }
.st.err { color: var(--err); background: var(--err-bg); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: #eceff3; color: var(--muted); }
.badge.test { background: #5b6475; color: #fff; text-transform: lowercase; }
.badge.err { background: var(--err-bg); color: var(--err); } .badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.agroup + .agroup { margin-top: 6px; }

.timeline, .mini { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.timeline li, .mini li { padding: 5px 0 5px 10px; border-left: 3px solid var(--line); margin-left: 2px; }
.timeline time, .mini time { color: var(--muted); margin-right: 6px; white-space: nowrap; }
.ev.err { border-color: var(--err); color: var(--err); } .ev.ok { border-color: var(--ok); } .ev.pay { border-color: #7c3aed; }
.ev.game { border-color: var(--play); } .ev.support { border-color: var(--brand); font-weight: 600; } .ev.mail { border-color: #0e7490; }
.js.failed { color: var(--err); font-weight: 700; } .js.pending { color: var(--warn); } .js.done { color: var(--ok); }
audio { width: 100%; max-width: 320px; height: 36px; margin-top: 4px; }

/* тестовые заказы: серые, с чипом «тест» */
.orow.is-test, .att.is-test, .recent li.is-test, .sg.is-test { opacity: .6; }
.orow.is-test { border-style: dashed; background: #f7f8fa; }
.card.head.is-test { border-style: dashed; background: #fafbfc; }
.testnote { background: #eef0f4; border-radius: 10px; padding: 8px 12px; margin: 0 0 10px; font-weight: 600; }
.testbar { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; background: #eef0f4;
  border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; font-size: 14px; }
.olist-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink);
  background: none; border: 0; padding: 6px 0; cursor: pointer; min-height: 34px; }
.switch i { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #c9ced8; flex: none; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on i { background: var(--ink); }
.switch.on i::after { left: 19px; }
.switch:focus-visible { outline: 2px solid var(--play); outline-offset: 2px; border-radius: 6px; }

/* подсказки поиска */
.sugg { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 24, 40, .18); z-index: 20; max-height: 70vh; overflow-y: auto; }
.sg { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.sg[aria-selected="true"], .sg:hover { background: var(--info-bg); }
.sg2 { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.sg-empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }
.sg-all { display: block; padding: 9px 12px; font-size: 14px; font-weight: 600; text-decoration: none; }

/* относительное время: точное — в подсказке, по нажатию */
time.rel { white-space: nowrap; }
:not(a) > time.rel, dd time.rel { cursor: pointer; border-bottom: 1px dotted currentColor; }
.orow time.rel { border: 0; }

/* «Недавно открытые» */
.since { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 15px; }
.since a { text-decoration: none; }
.since b { font-variant-numeric: tabular-nums; }
.since .zero { color: var(--muted, #888); }
.since .ok b { color: var(--ok, inherit); }
.since .warn b { color: var(--warn, inherit); }
.since .err b { color: var(--err, inherit); }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.recent li:last-child { border-bottom: 0; }
.recent a { text-decoration: none; }

.more { text-align: center; margin: 12px 0; }
.refreshed { font-size: 12px; text-align: center; }

/* карточка на телефоне: панель быстрых действий над нижним меню */
.abar { display: none; }
@media (max-width: 899px) {
  body.has-abar { padding-bottom: calc(124px + env(safe-area-inset-bottom)); }
  .abar { display: flex; gap: 6px; position: fixed; left: 0; right: 0; bottom: calc(44px + env(safe-area-inset-bottom)); z-index: 6;
    background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px; overflow-x: auto; box-shadow: 0 -4px 12px rgba(16, 24, 40, .06); }
  .abar .btn { flex: 1 0 auto; text-align: center; }
}

/* подсказка «Скопировано» */
.toast { position: fixed; left: 50%; bottom: calc(132px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); background: var(--ink);
  color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s; z-index: 50; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* подтверждение в окне страницы (вместо confirm()) */
.sheet-bg { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet-text { margin: 0 0 14px; font-size: 16px; font-weight: 600; white-space: pre-wrap; }
.sheet .row-btns .btn { flex: 1; }
@media (min-width: 900px) { .sheet-bg { align-items: center; } .sheet { border-radius: 16px; } }
