:root {
  --bg: #f6f7f9; --panel: #fff; --fg: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --s1: #e8f1fd; --s2: #fff2d6; --s3: #ffe0dc; --accent: #2563eb; --zero: #7c3aed;
  --sn: #0e7490; --head: #eef1f6;
}
/* тёмная тема: по системе (если не выбрана светлая) или выбрана вручную */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --panel: #1a1e26; --fg: #e6e9ef; --muted: #8c94a6; --line: #2a303b;
    --s1: #1b2b42; --s2: #3a2f17; --s3: #44211f; --accent: #6ea0ff; --zero: #b794ff;
    --sn: #5fd0e6; --head: #212632;
  }
}
:root[data-theme="dark"] {
    --bg: #12151b; --panel: #1a1e26; --fg: #e6e9ef; --muted: #8c94a6; --line: #2a303b;
    --s1: #1b2b42; --s2: #3a2f17; --s3: #44211f; --accent: #6ea0ff; --zero: #b794ff;
    --sn: #5fd0e6; --head: #212632;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; }
header .home { font-weight: 700; color: var(--fg); }
.upd { color: var(--muted); font-size: 12px; margin-left: auto; }
#theme { border: 1px solid var(--line); background: none; padding: 2px 8px; font-size: 13px; color: var(--muted); }
main { padding: 12px 16px 24px; max-width: 1180px; margin: 0 auto; }
h1 { font-size: 20px; margin: 6px 0 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 16px; }
.n { color: var(--muted); font-weight: 400; margin-left: 4px; }
.muted { color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.legend { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.legend summary { cursor: pointer; color: var(--muted); }
.legend ul { margin: 8px 0 2px; padding-left: 18px; }

.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tools input[type=search] { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--fg); min-width: 200px; }
.tools label { font-size: 13px; color: var(--muted); }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel);
  color: var(--fg); border-radius: 6px; padding: 4px 10px; }

/* сетка: имя + 5 дней */
.grid { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.row { display: grid; grid-template-columns: minmax(190px, 1.4fr) repeat(5, minmax(112px, 1fr));
  border-bottom: 1px solid var(--line); min-width: 760px; }
.row > div { padding: 6px 8px; }
.gh { background: var(--head); font-size: 12px; position: sticky; top: 0; }
.gh .name { color: var(--muted); align-self: end; }
.dh { display: flex; flex-direction: column; }
.dh span { color: var(--muted); }
.name { position: sticky; left: 0; background: inherit; display: flex; align-items: flex-start;
  gap: 2px; flex-wrap: wrap; z-index: 1; }
.rh { background: var(--panel); }
.rh .name { background: var(--panel); font-weight: 600; font-size: 15px; }
.cr .name { background: var(--panel); padding-left: 30px; }
.tog { border: 0; padding: 0 6px 0 0; background: none; color: var(--muted); transition: transform .15s; }
.region.open .tog { transform: rotate(90deg); }
.cities { display: none; background: var(--bg); }
.region.open .cities { display: block; }
.region.open .rh { border-bottom: 2px solid var(--line); }

.cell { display: flex; flex-direction: column; gap: 1px; border-left: 1px solid var(--line);
  font-size: 13px; }
.cell.s1 { background: var(--s1); } .cell.s2 { background: var(--s2); } .cell.s3 { background: var(--s3); }
.cell.na { color: var(--muted); font-size: 12px; }
.ic { font-size: 16px; margin-right: 4px; }
.pop { font-weight: 700; }
.sn { color: var(--sn); font-weight: 600; }
.t { color: var(--muted); }
.zero { color: var(--zero); font-weight: 700; font-size: 12px; }
.an i { font-style: normal; margin-right: 3px; }
.an sub { font-size: 10px; color: var(--muted); }
.cnt { font-size: 11px; color: var(--muted); }
.inc { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 5px; margin-left: 4px; cursor: help; }

.share { display: inline-flex; gap: 2px; margin-left: auto; }
.share button { border: 0; background: none; padding: 0 3px; font-size: 13px; opacity: .55; }
.share button:hover { opacity: 1; }
h1 .share button { font-size: 16px; }

/* страница пункта */
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.card .dh { padding: 8px 10px 4px; }
.card .cell { border-left: 0; padding: 8px 10px; font-size: 14px; min-height: 96px; }
.card .wind { font-size: 12px; color: var(--muted); padding: 4px 10px 8px; }
.members { color: var(--muted); font-size: 13px; }
.steps { margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.steps summary { cursor: pointer; }
.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; margin-top: 8px; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }

#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #111;
  color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s;
  pointer-events: none; }
#toast.on { opacity: .92; }
.hidden { display: none !important; }

/* телефон: название строкой сверху, под ним 5 дней во всю ширину — без горизонтальной прокрутки */
@media (max-width: 700px) {
  main { padding: 10px 8px; }
  h1 { font-size: 18px; }
  .grid { overflow: visible; border-radius: 8px; }
  .row { grid-template-columns: repeat(5, minmax(0, 1fr)); min-width: 0; }
  .row > div { padding: 4px 3px; }
  .row > .name { grid-column: 1 / -1; position: static; padding: 7px 8px 3px; align-items: center; }
  .gh { top: 41px; z-index: 3; }
  .gh .name { display: none; }
  .dh { align-items: center; font-size: 11px; }
  .cell { font-size: 11px; line-height: 1.25; align-items: center; text-align: center;
    border-left: 0; border-right: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
  .cell:last-child { border-right: 0; }
  .ic { font-size: 18px; margin: 0; display: block; }
  .pop { display: block; }
  .cnt { display: none; }
  .mm .sn { display: block; }
  .sep { display: none; }
  .home { white-space: nowrap; }
  .upd { font-size: 11px; text-align: right; }
  #theme .tl { display: none; }
  th, td { padding: 4px 5px; }
  .rh .name { font-size: 15px; }
  .cr .name { padding-left: 10px; font-size: 14px; }
  .share { margin-left: auto; }
  .share button { font-size: 16px; padding: 2px 6px; opacity: .7; }
  .tools input[type=search] { flex: 1 1 100%; }
  .cards { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .card .dh { padding: 6px 2px 2px; }
  .card .cell { padding: 6px 2px; font-size: 11px; min-height: 0; }
  .card .wind { font-size: 10px; padding: 2px 3px 6px; text-align: center; }
  header { padding: 8px 10px; }
}
/* режим съёмки картинки — без прокрутки и кнопок */
/* html2canvas не умеет position: sticky — в снимке всё статично */
.shot .share, .shot .tog { display: none; }
.shot .row { min-width: 0; }
.shot .name, .shot .gh { position: static !important; }
.shot .cities { display: block; }
