:root {
  --ground: #EAE5DE;
  --card: #FBF9F6;
  --card-line: #CFC5B9;
  --ink: #1A1410;
  --muted: #5E554C;
  --side: #2A1A10;
  --side-ink: #F3E3D0;
  --side-muted: #D8C3AE;
  --side-card: #3A2517;
  --accent: #8A4F22;
  --accent-ink: #4A2610;
  --hot: #B8531F;
  --danger: #8F2A1B;
  --ok-bg: #DDEBDD; --ok-fg: #1F4D2B; --ok-line: #9CC3A3;
  --info-bg: #DCE8F7; --info-fg: #0F2F57; --info-line: #9DB9DE;
  --warn-bg: #F6E3CF; --warn-fg: #5A2E0C; --warn-line: #D9A877;
  --off-bg: #E4E4E1; --off-fg: #2B2B2B; --off-line: #A8A8A4;
  --input-line: #8A7B6B;
  --focus: #1D5FD1;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
button:disabled { opacity: .45; cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.tap:active { transform: scale(.98); }
.boot { padding: 40px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; display: flex; }
.side {
  flex: 0 0 264px; background: var(--side); color: var(--side-ink);
  padding: 28px 16px; display: flex; flex-direction: column; gap: 28px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: inherit; text-decoration: none; }
.brand b { display: block; font-size: 18px; }
.brand small { display: block; font-size: 13px; color: var(--side-muted); }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px;
  border-radius: 14px; color: var(--side-ink); font-weight: 700; font-size: 16px; text-decoration: none;
}
.nav a:hover { background: var(--side-card); }
.nav a[aria-current="page"] { background: #F3E3D0; color: var(--side); }
.nav a span { flex: 1; }
.badge {
  min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px; background: var(--hot);
  color: #fff; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.who { margin-top: auto; padding: 14px; border-radius: 14px; background: var(--side-card); font-size: 13px; color: var(--side-muted); }
.who strong { color: var(--side-ink); }
.who .row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.who a, .who button { color: var(--side-ink); font-weight: 700; text-decoration: underline; font-size: 13px; }
.menu-btn { display: none; }

main { flex: 1; min-width: 0; padding: 32px 40px 48px; display: flex; flex-direction: column; gap: 18px; max-width: 1500px; }
.head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.head > div { flex: 1; min-width: 240px; }
h1 { margin: 0; font-size: 32px; font-weight: 700; }
h2 { margin: 0; font-size: 20px; font-weight: 700; }
h3 { margin: 0; font-size: 17px; font-weight: 700; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 16px; }
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--card-line); border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card.tight { padding: 16px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); align-items: start; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); }
.stat { background: #fff; border: 1px solid #E3DBD0; border-radius: 16px; padding: 14px 16px; }
.stat .l { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 30px; font-weight: 700; line-height: 1.15; }
.stat .n { font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { padding: 14px; border-radius: 14px; border: 1px dashed #A99B8B; color: var(--muted); }
.alert { padding: 14px 18px; border-radius: 14px; border: 2px solid var(--danger); background: #fff; color: var(--danger); font-weight: 700; }
.note { padding: 14px 18px; border-radius: 14px; background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); }

/* ---------- controls ---------- */
.btn {
  min-height: 44px; padding: 0 18px; border-radius: 22px; background: var(--accent); color: #fff;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn.line { background: transparent; border: 1px solid var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn.big { min-height: 52px; padding: 0 24px; border-radius: 26px; font-size: 16px; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }
label.f .hint { font-weight: 400; color: var(--muted); }
input.i, select.i, textarea.i {
  min-height: 48px; border-radius: 14px; border: 1px solid var(--input-line); background: #fff; padding: 0 14px; font-size: 16px; width: 100%;
}
textarea.i { padding: 12px 14px; min-height: 96px; resize: vertical; }
.form { display: flex; flex-direction: column; gap: 12px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices label { position: relative; }
.choices input { position: absolute; opacity: 0; inset: 0; }
.choices span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--card-line); background: #fff; font-weight: 700; cursor: pointer; }
.choices input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.choices input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- chips and lists ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: 13px; font-size: 13px; font-weight: 700; border: 1px solid; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line); }
.chip.info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }
.chip.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }
.chip.off { background: var(--off-bg); color: var(--off-fg); border-color: var(--off-line); }
.chip.hot { background: var(--accent); color: #fff; border-color: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.green { background: #2E7D45; } .dot.yellow { background: #C99A14; } .dot.red { background: #B0301E; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 16px;
  background: #fff; border: 1px solid #E3DBD0; color: inherit; text-decoration: none; min-width: 0; flex-wrap: wrap;
}
a.item:hover { border-color: var(--accent); }
.item .t { font-weight: 700; font-size: 16px; }
.item .m { font-size: 13px; color: var(--muted); }
.table-wrap { overflow-x: auto; border-radius: 16px; border: 1px solid #E3DBD0; background: #fff; }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #EEE7DD; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #F6F2EC; }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 700; }

/* ---------- map ---------- */
.map { position: relative; width: 100%; background: #F1ECE4; border-radius: 14px; overflow: hidden; }
.map svg { display: block; width: 100%; height: auto; max-height: 72vh; }
.map .region { cursor: pointer; transition: fill-opacity .15s; }
.map .region:hover, .map .region:focus { fill-opacity: .7; outline: none; }
.map .lbl { font: 700 15px 'DM Sans', system-ui, sans-serif; fill: #2A1A10; paint-order: stroke; stroke: #F1ECE4; stroke-width: 4px; pointer-events: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 22px; padding: 0; max-width: min(560px, calc(100vw - 32px)); width: 100%; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(26, 20, 16, .45); }
dialog .card { border: 0; }
.qr { width: 260px; height: 260px; image-rendering: pixelated; background: #fff; border-radius: 12px; border: 1px solid var(--card-line); align-self: center; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--side); color: var(--side-ink); padding: 12px 20px; border-radius: 14px; font-weight: 700; transition: .2s; max-width: calc(100vw - 32px); z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); color: #fff; }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--side); }
.signin .card { width: min(420px, 100%); gap: 16px; }
.signin .brand { color: var(--ink); padding: 0; }
.signin .brand small { color: var(--muted); }

/* ---------- phone width ---------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { position: static; height: auto; flex: none; padding: 14px 16px; gap: 14px; }
  .side .top { display: flex; align-items: center; justify-content: space-between; }
  .menu-btn { display: inline-flex; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--side-muted); color: var(--side-ink); font-weight: 700; align-items: center; }
  .side:not(.open) .nav, .side:not(.open) .who { display: none; }
  main { padding: 20px 16px 40px; }
  h1 { font-size: 26px; }
  .card { padding: 16px; }
}
