:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #17202a; --muted: #5f6b7a; --border: #dde2e8;
  --accent: #d97706; --accent-ink: #ffffff; --accent-soft: #fef3c7;
  --ok: #15803d; --bad: #b91c1c; --warn: #b45309; --info: #1d4ed8;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --surface: #171e26; --text: #e6eaef; --muted: #98a3b1; --border: #2a3440;
    --accent: #f59e0b; --accent-ink: #1a1203; --accent-soft: #3a2a08;
    --ok: #4ade80; --bad: #f87171; --warn: #fbbf24; --info: #93c5fd;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.7rem; line-height: 1.2; margin: .2em 0 .4em; }
h2 { font-size: 1.15rem; margin: 1.4em 0 .6em; }
h3 { font-size: 1rem; margin: 0 0 .4em; }
.card h2:first-child, section > h2:first-child { margin-top: 0; }
code { font-size: .85em; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 20px; padding-bottom: 40px; min-height: 70vh; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.wrap-any { word-break: break-all; }
.pre { white-space: pre-wrap; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 60ch; }
.crumbs { margin: 0; font-size: .85rem; }
.crumbs a { color: var(--muted); }
.narrow { max-width: 420px; margin: 40px auto; }

/* top bar */
.topbar { background: #111827; color: #f9fafb; border-bottom: 3px solid var(--accent); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: #fbbf24; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand span { color: #f9fafb; }
.nav { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; padding: 6px 0; }
.nav a { color: #d1d5db; text-decoration: none; font-size: .92rem; }
.nav a:hover { color: #fff; }
.nav a.btn { color: var(--accent-ink); }
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 18px 0 30px; }

/* buttons */
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: .87rem; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-block { display: block; width: 100%; text-align: center; margin: 12px 0 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.nav .linkish { color: #d1d5db; text-decoration: none; font-size: .92rem; }
form.inline { display: inline; }

/* layout */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center; padding: 12px 0 8px; }
.hero h1 { font-size: 2.2rem; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.map { height: 340px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 28px 0; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.step span { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.step p { margin: 0; color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search input { min-width: 260px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.pad { padding: 18px; }
.cam-card { text-decoration: none; color: inherit; overflow: hidden; display: flex; flex-direction: column; margin: 0; }
.cam-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #1f2933; display: block; }
.cam-card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.cam-card:hover { border-color: var(--accent); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.two-col.wide-left { grid-template-columns: 1.6fr 1fr; }
.player video, .player img, video.preview { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); display: block; }

/* forms */
.form label { display: block; margin-bottom: 12px; font-weight: 600; font-size: .9rem; }
.form fieldset { border: 0; padding: 0; margin: 0 0 14px; }
.form legend { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; font-weight: 400; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
.check { font-weight: 400 !important; display: flex !important; align-items: flex-start; gap: 4px; }
.check input { margin-top: 4px; }
.row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; align-items: end; }
.row4 label { display: block; margin-bottom: 12px; font-weight: 600; font-size: .9rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* feedback */
.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; border: 1px solid; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-ok { background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: var(--ok); }
.flash-err { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: var(--bad); }
.flash-warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: var(--warn); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-ok { background: var(--ok); } .dot-bad { background: var(--bad); }
.err-text { color: var(--bad); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--border); color: var(--text); vertical-align: middle; }
.badge-review { background: #dbeafe; color: #1e40af; }
.badge-awaiting_payment { background: #fef3c7; color: #92400e; }
.badge-paid, .badge-processing { background: #e0e7ff; color: #3730a3; }
.badge-ready { background: #dcfce7; color: #166534; }
.badge-failed, .badge-rejected { background: #fee2e2; color: #991b1b; }
.pill { display: inline-block; padding: 0 7px; border-radius: 99px; font-size: .75rem; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pill-bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }

/* admin */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.tile-warn { border-left-color: var(--warn); } .tile-bad { border-left-color: var(--bad); }
.tile-link { border-left-color: var(--info); }
.tile-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tile-value { font-size: 1.45rem; font-weight: 700; }
.tile-value.small-value { font-size: 1.05rem; padding: 4px 0; }
.tile-sub { font-size: .8rem; color: var(--muted); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.row-off { opacity: .55; }
img.mini { width: 88px; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; background: #1f2933; display: block; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.toolbar .check { margin: 0 8px 0 0; }
.list { list-style: none; padding: 0; margin: 0 0 16px; }
.list li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.ev-warning { color: var(--warn); } .ev-error { color: var(--bad); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 5px 11px; border-radius: 99px; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: .87rem; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 8px; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; }
.timeline { position: relative; height: 12px; background: color-mix(in srgb, var(--bad) 25%, transparent); border-radius: 6px; overflow: hidden; }
.timeline i { position: absolute; top: 0; bottom: 0; background: var(--ok); }
details.danger { margin-top: 24px; border: 1px solid var(--bad); border-radius: var(--radius); padding: 12px 16px; }
details.danger summary { cursor: pointer; color: var(--bad); font-weight: 600; }

@media (max-width: 860px) {
  .hero, .two-col, .two-col.wide-left, .steps { grid-template-columns: 1fr; }
  .row3, .row4 { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 1.7rem; }
}
@media (max-width: 560px) {
  .row2, .row3, .row4 { grid-template-columns: 1fr; }
  .search input { min-width: 0; }
  .search { width: 100%; }
}
