/* Чеклист ОП — Bi Group */

:root,
[data-theme="light"] {
  --bi-violet: #2A22B8;
  --bi-violet-dark: #1E18A0;
  --bi-violet-soft: #EEEDF8;
  --bi-violet-muted: #6B63C9;
  --bi-text: #1C1C28;
  --bi-muted: #6E6E82;
  --bi-bg: #EDECEF;
  --bi-surface: #F8F7FA;
  --bi-surface-alt: #F2F1F5;
  --bi-border: #DDDCE4;
  --bi-border-strong: #C8C6D4;
  --bi-success: #0F7A55;
  --bi-success-bg: #E4F5EE;
  --bi-danger: #C42B2B;
  --bi-danger-bg: #FCEAEA;
  --bi-warning: #B45309;
  --bi-warning-bg: #FDF4E7;
  --bi-live-bg: #E8EEF9;
  --bi-live-text: #2E4A8C;
  --bi-shadow: 0 1px 2px rgba(28, 28, 40, 0.04), 0 6px 20px rgba(28, 28, 40, 0.05);
  --bi-header-bg: #F8F7FA;
  --bi-header-border: #DDDCE4;
  --bi-header-text: #1C1C28;
  --bi-header-muted: #6E6E82;
  --bi-nav-bg: #F2F1F5;
  --bi-nav-active: #2A22B8;
  --bi-input-bg: #FFFFFF;
  --bi-row-border: #E8E7EE;
  --bi-chip-hover: #EEEDF8;
  --bi-focus-ring: rgba(42, 34, 184, 0.14);
  --bi-login-grad-start: #2A22B8;
  --bi-login-grad-end: #1A1578;
  --bi-radius: 12px;
  --bi-radius-sm: 8px;
  --bi-radius-lg: 16px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bi-violet: #A89BFF;
  --bi-violet-dark: #8F7FFF;
  --bi-violet-soft: #252238;
  --bi-violet-muted: #8B82D4;
  --bi-text: #ECEAF4;
  --bi-muted: #9B99AD;
  --bi-bg: #0B0B10;
  --bi-surface: #14141C;
  --bi-surface-alt: #1A1A24;
  --bi-border: #2A2A38;
  --bi-border-strong: #3A3A4C;
  --bi-success: #4ADE9A;
  --bi-success-bg: #132A22;
  --bi-danger: #F07070;
  --bi-danger-bg: #2E1818;
  --bi-warning: #F5C26B;
  --bi-warning-bg: #2A2210;
  --bi-live-bg: #1A2840;
  --bi-live-text: #8CB4F0;
  --bi-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.28);
  --bi-header-bg: #101018;
  --bi-header-border: #2A2A38;
  --bi-header-text: #ECEAF4;
  --bi-header-muted: #9B99AD;
  --bi-nav-bg: #1A1A24;
  --bi-nav-active: #A89BFF;
  --bi-input-bg: #1A1A24;
  --bi-row-border: #242432;
  --bi-chip-hover: #222230;
  --bi-focus-ring: rgba(168, 155, 255, 0.22);
  --bi-login-grad-start: #1A1830;
  --bi-login-grad-end: #0B0B10;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bi-bg);
  color: var(--bi-text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: var(--bi-violet); text-decoration: none; }
a:hover { color: var(--bi-violet-dark); }

/* ── Header ── */
.header {
  background: var(--bi-header-bg);
  color: var(--bi-header-text);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--bi-header-border);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--bi-header-text);
}

.header .sub {
  font-size: 11px;
  color: var(--bi-header-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--bi-border);
  border-radius: var(--bi-radius-sm);
  background: var(--bi-surface-alt);
  color: var(--bi-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  border-color: var(--bi-border-strong);
  background: var(--bi-chip-hover);
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.nav a,
.nav button {
  color: var(--bi-muted);
  background: transparent;
  border: none;
  padding: 7px 12px;
  border-radius: var(--bi-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.nav a:hover,
.nav button:hover {
  color: var(--bi-text);
  background: var(--bi-nav-bg);
  text-decoration: none;
}

.nav a.active {
  color: var(--bi-nav-active);
  background: var(--bi-violet-soft);
  font-weight: 600;
}

[data-theme="dark"] .nav a.active {
  color: var(--bi-violet);
}

/* ── Layout ── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  width: 100%;
}

/* ── Cards ── */
.card {
  background: var(--bi-surface);
  color: var(--bi-text);
  border-radius: var(--bi-radius-lg);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--bi-shadow);
  border: 1px solid var(--bi-border);
  min-width: 0;
  overflow-wrap: anywhere;
}

.card h2,
.card h3 {
  color: var(--bi-text);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.card-meta {
  font-size: 13px;
  color: var(--bi-muted);
  margin-bottom: 8px;
  line-height: 1.45;
}

.card strong { color: var(--bi-text); font-weight: 600; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--bi-login-grad-start) 0%, var(--bi-login-grad-end) 100%);
}

.login-top {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}

.login-top .theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.login-box {
  background: var(--bi-surface);
  color: var(--bi-text);
  border-radius: var(--bi-radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--bi-border);
}

.login-box h2 {
  color: var(--bi-text);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.login-box p { color: var(--bi-muted); font-size: 14px; margin-bottom: 24px; }

/* ── Form controls ── */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--bi-border);
  border-radius: var(--bi-radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  color: var(--bi-text);
  background: var(--bi-input-bg);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--bi-violet-muted);
  box-shadow: 0 0 0 3px var(--bi-focus-ring);
}

.filter-grid input,
.filter-grid select,
.system-form input,
.compact-row input,
.inline-row input {
  margin-bottom: 0;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236E6E82' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
}

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%239B99AD' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

input[type="file"] {
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px dashed var(--bi-border-strong);
  border-radius: var(--bi-radius);
  background: var(--bi-surface-alt);
  cursor: pointer;
  font-size: 13px;
  color: var(--bi-muted);
}

.form-stack input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form-stack select,
.form-stack textarea {
  margin-bottom: 12px;
}

.form-stack input[type="file"] {
  margin-bottom: 16px;
}

.form-stack .btn,
.form-stack button.btn {
  margin-bottom: 0;
  margin-top: 4px;
}

.form-stack label.card-meta {
  display: block;
  margin-bottom: 6px;
  margin-top: 4px;
}

.form-stack label.card-meta:first-of-type {
  margin-top: 0;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--bi-radius-sm);
  background: var(--bi-violet);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

[data-theme="light"] input[type="file"]::file-selector-button {
  background: var(--bi-violet);
}

[data-theme="dark"] input[type="file"]::file-selector-button {
  background: var(--bi-violet-dark);
  color: #14141C;
}

input[type="file"]::file-selector-button:hover {
  filter: brightness(1.08);
}

/* ── Custom checkboxes ── */
.checkline,
.chip-check {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-height: 36px;
  padding-left: 30px;
  color: var(--bi-text);
  font-size: 13px;
  font-weight: 500;
}

.checkline input[type="checkbox"],
.chip-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  cursor: pointer;
  z-index: 1;
}

.checkline input[type="checkbox"] {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.checkline::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--bi-border-strong);
  background: var(--bi-input-bg);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  pointer-events: none;
}

.checkline::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 5px;
  height: 9px;
  margin-top: -6px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.12s ease;
  pointer-events: none;
}

[data-theme="dark"] .checkline::after {
  border-color: #14141C;
}

.checkline:has(input:checked)::before {
  background: var(--bi-violet);
  border-color: var(--bi-violet);
  box-shadow: 0 1px 3px rgba(42, 34, 184, 0.25);
}

[data-theme="dark"] .checkline:has(input:checked)::before {
  background: var(--bi-violet-dark);
  border-color: var(--bi-violet-dark);
}

.checkline:has(input:checked)::after {
  transform: rotate(45deg) scale(1);
}

.checkline:has(input:focus-visible)::before {
  box-shadow: 0 0 0 3px var(--bi-focus-ring);
}

/* Chip toggles (scope cities/offices) */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-grid-title {
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--bi-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 8px 14px 8px 36px;
  border-radius: 999px;
  border: 1px solid var(--bi-border);
  background: var(--bi-surface-alt);
  color: var(--bi-text);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.chip-check:hover {
  border-color: var(--bi-border-strong);
  background: var(--bi-chip-hover);
}

.chip-check input[type="checkbox"] {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.chip-check::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--bi-border-strong);
  background: var(--bi-input-bg);
  transition: border-color 0.15s, background 0.15s;
  pointer-events: none;
}

.chip-check::after {
  content: "";
  position: absolute;
  left: 17px;
  top: 50%;
  width: 4px;
  height: 8px;
  margin-top: -5px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.12s ease;
  pointer-events: none;
}

[data-theme="dark"] .chip-check::after {
  border-color: #14141C;
}

.chip-check:has(input:checked) {
  border-color: var(--bi-violet-muted);
  background: var(--bi-violet-soft);
  color: var(--bi-violet);
  box-shadow: 0 0 0 1px rgba(42, 34, 184, 0.08);
}

[data-theme="dark"] .chip-check:has(input:checked) {
  color: var(--bi-violet);
  border-color: var(--bi-violet-muted);
}

.chip-check:has(input:checked)::before {
  background: var(--bi-violet);
  border-color: var(--bi-violet);
}

[data-theme="dark"] .chip-check:has(input:checked)::before {
  background: var(--bi-violet-dark);
  border-color: var(--bi-violet-dark);
}

.chip-check:has(input:checked)::after {
  transform: rotate(45deg) scale(1);
}

.chip-check:has(input:focus-visible) {
  box-shadow: 0 0 0 3px var(--bi-focus-ring);
}

/* ── Buttons ── */
button.btn {
  width: 100%;
  padding: 10px 16px;
  margin-bottom: 12px;
  border: none;
  border-radius: var(--bi-radius);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

button.btn:active { transform: scale(0.98); }

.btn {
  background: var(--bi-violet);
  color: #FFFFFF;
  margin-bottom: 0;
}

[data-theme="dark"] .btn {
  background: var(--bi-violet-dark);
  color: #14141C;
}

.btn:hover { filter: brightness(1.06); }

.btn-outline {
  background: transparent;
  color: var(--bi-violet);
  border: 1px solid var(--bi-border-strong);
}

.btn-outline:hover {
  background: var(--bi-violet-soft);
  border-color: var(--bi-violet-muted);
}

.btn-danger { background: var(--bi-danger); color: #FFFFFF; }
.btn-danger:hover { filter: brightness(1.05); }

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
  width: auto;
  display: inline-block;
  margin-bottom: 0;
}

a.btn {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  line-height: 1.35;
}

.bulk-save-bar {
  position: sticky;
  bottom: 0;
  margin-top: 20px;
  margin-bottom: -4px;
  padding: 14px 0 4px;
  background: var(--bi-surface);
  border-top: 1px solid var(--bi-border);
  z-index: 5;
}

.bulk-save-bar .btn {
  width: auto;
  min-width: 200px;
  margin: 0;
}

.settings-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
  box-shadow: var(--bi-shadow);
  border: 1px solid var(--bi-border);
}

.settings-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.settings-toast.ok {
  background: var(--bi-success-bg);
  color: var(--bi-success);
  border-color: transparent;
}

.settings-toast.err {
  background: var(--bi-danger-bg);
  color: var(--bi-danger);
  border-color: transparent;
}

.error {
  background: var(--bi-danger-bg);
  color: var(--bi-danger);
  padding: 10px 14px;
  border-radius: var(--bi-radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

/* ── Reports ── */
.report-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--bi-row-border);
  position: relative;
}

.report-item:last-child { border-bottom: none; }

.report-main { flex: 1; min-width: 0; }

.report-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.report-score {
  font-size: 16px;
  font-weight: 700;
  color: var(--bi-violet);
  white-space: nowrap;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.menu-trigger {
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--bi-border);
  border-radius: var(--bi-radius-sm);
  background: var(--bi-surface-alt);
  color: var(--bi-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.menu-trigger:hover,
.menu-trigger[aria-expanded="true"] {
  border-color: var(--bi-violet-muted);
  color: var(--bi-violet);
  background: var(--bi-violet-soft);
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 176px;
  background: var(--bi-surface);
  border: 1px solid var(--bi-border);
  border-radius: var(--bi-radius);
  box-shadow: var(--bi-shadow);
  z-index: 50;
  overflow: hidden;
  padding: 4px;
}

.menu-dropdown[hidden] { display: none; }

.menu-dropdown a,
.menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  border-radius: var(--bi-radius-sm);
  background: transparent;
  color: var(--bi-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}

.menu-dropdown a:hover,
.menu-dropdown button:hover {
  background: var(--bi-surface-alt);
  text-decoration: none;
}

.menu-dropdown .menu-danger { color: var(--bi-danger); }
.menu-dropdown .menu-danger:hover { background: var(--bi-danger-bg); }
.menu-dropdown form { margin: 0; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-warn { background: var(--bi-warning-bg); color: var(--bi-warning); }
.badge-ok { background: var(--bi-success-bg); color: var(--bi-success); }
.badge-block { background: var(--bi-danger-bg); color: var(--bi-danger); }
.badge-live {
  background: var(--bi-live-bg);
  color: var(--bi-live-text);
}
.badge-archive {
  background: #E5E7EB;
  color: #4B5563;
}
[data-theme="dark"] .badge-archive {
  background: #374151;
  color: #D1D5DB;
}

.progress-bar {
  height: 4px;
  background: var(--bi-border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
  max-width: 200px;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--bi-violet);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ── Audit detail ── */
.zone-block {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bi-row-border);
}

.zone-block:last-child { border-bottom: none; }

.zone-title {
  font-weight: 650;
  color: var(--bi-text);
  font-size: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.item-row {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--bi-row-border);
  align-items: flex-start;
  justify-content: space-between;
}

.item-question { display: flex; gap: 8px; flex: 1; min-width: 0; }
.item-num { color: var(--bi-muted); min-width: 20px; flex-shrink: 0; font-size: 12px; }
.item-text { flex: 1; line-height: 1.5; word-break: break-word; }
.item-answer { flex-shrink: 0; white-space: nowrap; padding-left: 8px; font-size: 13px; }

.answer-yes { color: var(--bi-success); font-weight: 600; }
.answer-no { color: var(--bi-danger); font-weight: 600; }

.comment-box {
  background: var(--bi-surface-alt);
  padding: 12px;
  border-radius: var(--bi-radius);
  font-size: 13px;
  margin: 10px 0;
  color: var(--bi-text);
  border: 1px solid var(--bi-border);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--bi-radius);
  border: 1px solid var(--bi-border);
}

.photo-grid a { display: block; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat-box {
  background: var(--bi-surface);
  padding: 14px 10px;
  border-radius: var(--bi-radius);
  text-align: center;
  border: 1px solid var(--bi-border);
}

.stat-box .val {
  font-size: 20px;
  font-weight: 700;
  color: var(--bi-violet);
  letter-spacing: -0.03em;
}

.stat-box .lbl { font-size: 11px; color: var(--bi-muted); margin-top: 2px; }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto; }

.table th {
  text-align: left;
  padding: 10px 8px;
  color: var(--bi-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--bi-border);
}

.table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--bi-row-border);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.inline-form { display: inline; }
.ref-preview { max-width: 120px; border-radius: var(--bi-radius-sm); margin-top: 8px; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  align-items: center;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.compact-list { display: grid; gap: 6px; margin-top: 12px; }

.compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--bi-row-border);
}

.compact-zone {
  padding: 14px;
  border-radius: var(--bi-radius);
  background: var(--bi-surface-alt);
  border: 1px solid var(--bi-border);
  margin-bottom: 12px;
}

.inline-row,
.zone-edit,
.item-edit,
.item-add {
  display: grid;
  gap: 10px;
  align-items: start;
}

.inline-row { grid-template-columns: minmax(0, 1fr) auto; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.filter-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--bi-muted);
  font-weight: 500;
}

.scope-box {
  margin-top: 8px;
  padding: 14px;
  background: var(--bi-surface-alt);
  border: 1px solid var(--bi-border);
  border-radius: var(--bi-radius);
}

.scope-box summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--bi-text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.scope-box summary::-webkit-details-marker { display: none; }

.scope-box summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--bi-muted);
  border-bottom: 1.5px solid var(--bi-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.scope-box[open] summary::before {
  transform: rotate(45deg);
}

.zone-edit-head {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.item-edit-num {
  font-weight: 600;
  color: var(--bi-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.flash {
  padding: 11px 14px;
  border-radius: var(--bi-radius);
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid transparent;
}

.flash-ok { background: var(--bi-success-bg); color: var(--bi-success); }
.flash-err { background: var(--bi-danger-bg); color: var(--bi-danger); }

/* ── Settings tabs & pickers ── */
.settings-tabs {
  display: flex;
  gap: 6px;
  margin: 14px 0;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--bi-surface-alt);
  border-radius: var(--bi-radius);
  border: 1px solid var(--bi-border);
  width: fit-content;
  max-width: 100%;
}

.tab-link {
  background: transparent;
  padding: 8px 14px;
  border-radius: var(--bi-radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--bi-muted);
  border: none;
  transition: color 0.15s, background 0.15s;
}

.tab-link:hover {
  color: var(--bi-text);
  background: var(--bi-surface);
  text-decoration: none;
}

.tab-link.active {
  background: var(--bi-surface);
  color: var(--bi-violet);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .tab-link.active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.settings-panel { display: none; }
.settings-panel.active { display: block; }

.city-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.city-pick a {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bi-surface-alt);
  border: 1px solid var(--bi-border);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--bi-muted);
  line-height: 1.3;
  transition: all 0.15s;
}

.city-pick a.active,
.city-pick a:hover {
  background: var(--bi-violet-soft);
  border-color: var(--bi-violet-muted);
  color: var(--bi-violet);
  text-decoration: none;
  font-weight: 600;
}

.zone-pick {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.zone-pick a {
  padding: 9px 12px;
  border-radius: var(--bi-radius-sm);
  background: transparent;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--bi-muted);
  line-height: 1.35;
  transition: all 0.15s;
}

.zone-pick a.active {
  border-color: var(--bi-border);
  background: var(--bi-violet-soft);
  color: var(--bi-violet);
  font-weight: 600;
}

.zone-pick a:hover {
  background: var(--bi-surface-alt);
  color: var(--bi-text);
  text-decoration: none;
}

.questions-layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.questions-editor .item-edit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0;
  border-bottom: 1px solid var(--bi-row-border);
}

.questions-editor .item-add,
.questions-editor .zone-edit {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.system-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.system-form .btn { width: auto; justify-self: start; }

.zone-add-form {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--bi-surface-alt);
  border-radius: var(--bi-radius);
  border: 1px dashed var(--bi-border-strong);
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.ref-card {
  border: 1px solid var(--bi-border);
  border-radius: var(--bi-radius);
  padding: 12px;
  background: var(--bi-surface-alt);
}

.ref-card-head { margin-bottom: 8px; font-size: 13px; }

.ref-preview-lg {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--bi-radius-sm);
  margin-bottom: 10px;
  border: 1px solid var(--bi-border);
}

.ref-edit-form { display: grid; gap: 8px; margin-bottom: 8px; }
.ref-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.selector-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.selector-row select { margin-bottom: 0; flex: 1; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .report-item { flex-direction: column; }
  .report-side {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

@media (max-width: 760px) {
  .header { padding: 12px 14px; }
  .header-inner { gap: 10px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
  .nav a, .nav button {
    width: 100%;
    text-align: center;
    padding: 8px 6px;
    font-size: 12px;
  }
  .nav form { display: block !important; }
  .container { padding: 14px 10px 32px; }
  .card { padding: 14px; border-radius: var(--bi-radius); }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-box { padding: 10px 6px; }
  .stat-box .val { font-size: 16px; }
  .zone-title { align-items: flex-start; flex-direction: column; }
  .item-row { flex-direction: column; gap: 6px; }
  .item-answer { padding-left: 28px; }
  .table, .table thead, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { padding: 12px 0; border-bottom: 1px solid var(--bi-border); }
  .table td {
    border-bottom: 0;
    padding: 6px 0;
    display: grid;
    grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
  }
  .table td::before {
    content: attr(data-label);
    color: var(--bi-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .table td.action-cell { display: block; padding-top: 10px; }
  .table td.action-cell::before { content: ""; }
  .action-cell .btn { width: 100%; text-align: center; }
  .actions .btn { flex: 1 1 140px; text-align: center; }
  .questions-layout, .compact-row { grid-template-columns: 1fr; }
  .compact-row .btn, .inline-row .btn { width: 100%; }
  .inline-row, .zone-edit, .item-edit, .item-add { grid-template-columns: 1fr; }
  .zone-edit-head { display: grid; grid-template-columns: 1fr; gap: 6px; }
  .settings-tabs { width: 100%; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* ── Telegram Mini App ── */
html.tg-mini-app body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

html.tg-mini-app .header {
  padding-top: calc(14px + env(safe-area-inset-top));
}

html.tg-mini-app .nav {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

html.tg-mini-app .login-wrap {
  min-height: 100dvh;
}
