:root {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1c1f24;
  --border: #2e333b;
  --text: #e6e8eb;
  --muted: #8b929c;
  --accent: #ffd60a;
  --danger: #ff6b6b;
  --ok: #4cc38a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 12px; }

.container { max-width: 1280px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 360px; margin: 48px auto; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.admin-nav a { color: var(--text); text-decoration: none; }
.admin-nav a:hover { color: var(--accent); }

.flash { padding: 8px 12px; border-radius: 6px; margin: 0 0 12px; list-style: none; }
.flash.notice { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.flash.alert { background: color-mix(in srgb, var(--danger) 18%, transparent); }

/* Кнопки и поля */
input, select, button, .button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}
input[type="submit"], button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
input[type="submit"], .button:hover, button:hover { border-color: var(--accent); }
input[type="color"] { padding: 2px; width: 48px; height: 34px; }
button.link { background: none; border: none; padding: 0; color: var(--accent); }
button.link.danger { color: var(--danger); }
form.button_to { display: inline; }

.form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; max-width: 480px; }
.form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; }

.date-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.date-nav form { margin: 0; }
.weekday { text-transform: capitalize; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: normal; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * { margin-left: 12px; }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--color);
}

/* Карта: маркеры позиционируются в процентах от размеров картинки */
.schedule { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .schedule { grid-template-columns: 1fr; } }

.map { position: relative; line-height: 0; border-radius: 8px; overflow: hidden; }
.map img { width: 100%; height: auto; display: block; }
.map.picker { cursor: crosshair; max-width: 900px; }

.marker {
  position: absolute;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 3px solid var(--color);
  border-radius: 50%;
  box-shadow: 0 0 0 2px #000a, 0 0 14px var(--color);
  pointer-events: none;
  display: grid;
  place-items: center;
  line-height: 1;
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 3px #000;
  background: var(--color);
  z-index: 1;
}
/* Метка с подписью КП поверх остальных, чтобы подпись не перекрывалась */
.marker.labeled { z-index: 2; }
/* Свободный спот: только номер в тёмном кружке, под занятыми */
.marker.free { --color: #c8ccd2; border-width: 2px; background: #0009; box-shadow: none; z-index: 0; }
.marker.numbered {
  display: grid;
  place-items: center;
  line-height: 1;
  font-weight: bold;
  color: #000;
  text-shadow: none;
  background: var(--color);
  text-decoration: none;
  font-size: 13px;
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
}
.marker-label {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 6px;
  border-left: 3px solid var(--color);
  border-radius: 4px;
  background: #000c;
  font-size: 12px;
  font-weight: normal;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--text);
  text-shadow: none;
}

/* У краёв карты подпись выравнивается внутрь, чтобы не обрезалась */
.marker.edge-left .marker-label { left: 0; transform: none; }
.marker.edge-right .marker-label { left: auto; right: 0; transform: none; }

@media (max-width: 600px) {
  .marker { width: 24px; height: 24px; border-width: 2px; font-size: 11px; }
  .marker-label { font-size: 10px; padding: 2px 4px; }
}

.tg-preview { max-width: 480px; margin-bottom: 16px; background: var(--surface); border-radius: 10px; overflow: hidden; }
.tg-album { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 2px; }
.tg-album img { width: 100%; display: block; }

.location { margin-bottom: 32px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
.badge { font-size: 0.8rem; font-weight: normal; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; vertical-align: middle; }
.form label.checkbox { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; color: var(--text); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card.inactive { opacity: 0.5; }
.card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
.card-body { display: flex; flex-direction: column; padding: 8px 12px; }
.tg-text { padding: 10px 12px; white-space: pre-wrap; }
