:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --primary: #3b82f6;
  --danger: #ef4444;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --shadow: 0 1px 3px rgba(15,23,42,.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}
/* Sticky footer: app grows, footer stays at bottom when content is short */
#appScreen {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  min-height: 0;
  width: 100%;
}
#appScreen > .container {
  flex: 1 0 auto;
}
#appScreen.hidden + .app-footer {
  display: none;
}
a { color: var(--primary); text-decoration: none; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #0f172a, #1e293b); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,.35); }
.login-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.login-card .subtitle { color: var(--muted); margin-bottom: 24px; font-size: 0.9rem; }
.header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 0; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.header-inner { width: 100%; max-width: none; margin: 0; padding: 0 5%; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; box-sizing: border-box; }
.logo { font-weight: 700; font-size: 1.1rem; }
.logo span { color: var(--accent); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav button { background: transparent; border: none; color: var(--muted); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 0.875rem; font-family: inherit; font-weight: 500; }
.nav button.active, .nav button:hover { background: #ecfdf5; color: #15803d; }
.user-info { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 8px; }
.container { width: 100%; max-width: none; margin: 0; padding: 20px 5%; box-sizing: border-box; }
.check-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .check-layout { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.card .card-desc { color: var(--muted); font-size: 0.85rem; margin-bottom: 16px; }
.section-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
label .req { color: var(--danger); }
input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  /* Safari: не даём системный стиль полей — рисуем как задумано */
  -webkit-appearance: none;
  appearance: none;
  color-scheme: inherit;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1.4 0L6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  padding-right: 32px;
}
input[type="number"] {
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #86efac; box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
input.invalid, select.invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.18) !important;
  background: #fef2f2;
}

/* Checkbox: глобальный appearance:none ломал нативный вид в Chrome/Firefox.
   Возвращаем системный чекбокс + accent-color под тему (light/dark/glass). */
input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 1.1em;
  height: 1.1em;
  min-width: 1.1em;
  max-width: 1.1em;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
  color-scheme: inherit;
  flex-shrink: 0;
}
input[type="checkbox"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
  border-color: transparent;
}
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) { .row-3 { grid-template-columns: 1fr; } }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 10px 18px; font-size: 0.9rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface2); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.items-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; }
.items-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 0.72rem; padding: 0 4px 8px; border-bottom: 1px solid var(--border); }
.items-table td { padding: 6px 3px; vertical-align: top; }
.items-table input, .items-table select { font-size: 0.82rem; padding: 7px 6px; }
.agent-row { display: flex; align-items: center; gap: 16px; margin-top: 12px; font-size: 0.9rem; flex-wrap: wrap; }
.radio-group { display: flex; gap: 16px; align-items: center; }
.radio-group label { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); font-size: 0.9rem; margin: 0; }
.radio-group input { width: auto; margin: 0; }
.pay-row { display: grid; grid-template-columns: 1fr 140px 40px; gap: 8px; align-items: end; margin-bottom: 8px; padding: 10px; background: var(--surface2); border-radius: 8px; border: 1px solid var(--border); }
.aside-card { position: sticky; top: 70px; }
.aside-card .kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 0.875rem; border-bottom: 1px solid var(--border); }
.aside-card .kv .k { color: var(--muted); }
.aside-card .kv .v { font-weight: 500; text-align: right; }
.aside-card .total-line { margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--border); display: flex; justify-content: space-between; font-weight: 700; font-size: 1.05rem; }
.warn-box { margin-top: 16px; padding: 12px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; font-size: 0.85rem; color: #166534; }
.warn-box.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.result-box { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 14px; font-family: ui-monospace, monospace; font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto; margin-top: 12px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-wait { background: #fef3c7; color: #b45309; }
.badge-done { background: #dcfce7; color: #15803d; }
.badge-fail { background: #fee2e2; color: #b91c1c; }
.badge-invoice { background: #dbeafe; color: #1d4ed8; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.hidden { display: none !important; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.link-pay { display: inline-block; margin-top: 8px; padding: 10px 16px; background: var(--accent); color: #fff !important; border-radius: 8px; font-weight: 600; }
.extra-buyer { margin-top: 12px; padding: 12px; background: var(--surface2); border-radius: 8px; border: 1px dashed var(--border); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.checkbox-row input[type="checkbox"] { width: 1.1em; height: 1.1em; }
.checkbox-row label { margin: 0; color: var(--text); cursor: pointer; }

/* Нет мигания логина при F5, если токен уже в localStorage (класс ставит inline-скрипт в <head>) */
html.eklk-authed #loginScreen { display: none !important; }
html.eklk-authed #appScreen { display: flex !important; }

/* Settings */
.settings-layout { max-width: none; width: 100%; }
.settings-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.settings-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}
.settings-tab.active, .settings-tab:hover {
  background: #ecfdf5;
  color: #15803d;
  border-color: #bbf7d0;
}
.settings-pane .kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.settings-pane .kv .k { color: var(--muted); }
.settings-pane .kv .v { font-weight: 500; text-align: right; word-break: break-all; }
.store-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--surface2);
}
.store-card.active {
  border-color: #86efac;
  background: #f0fdf4;
}
.store-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.store-card-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.hidden { display: none !important; }

/* Logo */



.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.logo:hover { opacity: 0.85; }
.header-logo { display: block; }

/* Orders list — список на всю высоту контента (без укорачивания и без скроллбара списка).
   Превью sticky справа: скролл чека при наведении / фокусе (см. app.js). */
.orders-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) {
  .orders-layout {
    grid-template-columns: 1fr;
  }
}
.orders-list-pane {
  min-width: 0;
}
.orders-filters { margin-bottom: 14px; }
.orders-table-wrap {
  overflow-x: auto; /* только горизонталь при узком экране */
}
.orders-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.orders-table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.orders-table th.sortable:hover { color: var(--text); }
.orders-table th.sort-asc::after { content: " ▲"; font-size: 0.65em; }
.orders-table th.sort-desc::after { content: " ▼"; font-size: 0.65em; }
.orders-table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.orders-table tr { cursor: pointer; transition: background .12s; }
.orders-table tr:hover { background: #f8fafc; }
.orders-table tr.active { background: #ecfdf5; }
.orders-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 8px;
}
/* Деталка: высота = весь чек, без внутреннего скролла (скроллится страница) */
/* Превью: блок «Состав чека» на всю высоту документа.
   Скролл — у внешней панели (sticky), не внутри .receipt-view.
   Список — страница; превью — отдельно при hover/клике. */
.orders-detail-pane {
  position: sticky;
  top: 70px;
  align-self: start;
  z-index: 5;
  max-height: calc(100vh - 90px);
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.orders-detail-pane::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}
.orders-detail-pane > .card {
  margin-bottom: 0;
  overflow: visible;
  /* карточка и чек — естественная высота всего документа */
  height: auto;
  max-height: none;
}
.orders-detail-pane .receipt-view {
  overflow: visible !important;
  max-height: none !important;
  height: auto !important;
  flex: none !important;
}
.orders-detail-pane.is-scroll-active {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary, #22c55e) 55%, transparent);
  border-radius: 12px;
}
@media (max-width: 960px) {
  .orders-detail-pane {
    position: static;
    max-height: none;
    overflow: visible;
  }
}
.receipt-view {
  font-size: 0.85rem;
  background: var(--surface2);
  color: var(--text);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
}
.receipt-view .r-section-title {
  margin: 14px 0 6px;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.receipt-view .r-link-row {
  margin: 6px 0;
  font-size: 0.85rem;
}
.receipt-view .r-link-row a {
  color: var(--primary);
  word-break: break-all;
}
.receipt-view .r-error span:last-child {
  color: var(--danger);
}
.receipt-view .r-json {
  margin-top: 14px;
}
.receipt-view .r-json summary {
  cursor: pointer;
}
.receipt-view .r-head {
  text-align: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.receipt-view .r-head .r-title { font-weight: 700; font-size: 1rem; }
.receipt-view .r-head .r-meta { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
.receipt-view .r-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0;
  font-size: 0.82rem;
}
.receipt-view .r-line > span:last-child {
  text-align: right;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 62%;
}
.receipt-view .r-item {
  padding: 8px 0;
  border-bottom: 1px dotted var(--border);
}
.receipt-view .r-item-name { font-weight: 500; }
.receipt-view .r-item-sub { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.receipt-view .r-total {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 2px solid var(--text);
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.05rem;
}
.receipt-view .r-pay {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
/* Статусы чеков в списке / деталке */
.badge-status-done { background: #dcfce7; color: #15803d; }       /* Завершён — зелёный */
.badge-status-paid { background: #dbeafe; color: #1d4ed8; }       /* Фискализация — синий */
.badge-status-wait { background: #fef3c7; color: #b45309; }       /* Ожидает / в обработке — жёлтый */
.badge-status-fail { background: #fee2e2; color: #b91c1c; }       /* Ошибка / отменён — красный */

/* Footer — прижат к низу при коротком контенте */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 28px 0 36px;
  flex-shrink: 0;
  width: 100%;
}
.footer-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 5%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 700px) {
  .footer-inner { grid-template-columns: 1fr; gap: 16px; }
}
.footer-col { font-size: 0.82rem; color: var(--muted); line-height: 1.6; }
.footer-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 8px;
}
.footer-col a { color: var(--primary); }
.footer-col a:hover { text-decoration: underline; }

/* —— Logo —— */
.login-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0 0 20px;
}
.login-logo {
  display: block;
  height: 48px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: center;
}
.header-logo {
  display: block;
  height: 28px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  object-position: left center;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-badge {
  font-size: 0.68rem;
  font-weight: 600;
  background: #00AEEF;
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.2;
}


/* Bitrix24 widget — always visible above app chrome */
.b24-widget-button-wrapper,
.b24-widget-button-position-bottom-right,
div[class*="b24-widget"] {
  z-index: 2147483000 !important;
  pointer-events: auto !important;
}
.b24-widget-button-shadow { z-index: 2147482990 !important; }

.clone-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.orders-table .o-edit-btn { white-space: nowrap; }
.r-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.r-head .r-title { font-weight: 700; margin-right: auto; }


/* ========== Темы: light (default) | dark | glass ========== */
/* data-theme на <body>; логотип инвертируется для dark/glass */

body[data-theme="dark"] {
  --bg: #0e1621;
  --surface: #17212b;
  --surface2: #232e3c;
  --border: #3d4f66;
  --text: #f5f7fa;
  --muted: #a0b0c0;
  --accent: #2ec27e;
  --accent-hover: #26a869;
  --primary: #6ab2f2;
  --danger: #e85d5d;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --input-bg: #242f3d;
  --input-border: #4a5d75;
  color-scheme: dark;
}

/* Glass ≈ Telegram: спокойный тёмный фон, лёгкая «стеклянность» карточек, без пёстрых градиентов */
body[data-theme="glass"] {
  --bg: #0b141a;
  --surface: rgba(23, 33, 43, 0.82);
  --surface2: rgba(35, 46, 60, 0.9);
  --border: rgba(120, 140, 160, 0.35);
  --text: #f0f4f8;
  --muted: #9aadc0;
  --accent: #2ec27e;
  --accent-hover: #26a869;
  --primary: #6ab2f2;
  --danger: #e85d5d;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --input-bg: rgba(15, 25, 35, 0.85);
  --input-border: rgba(140, 160, 180, 0.45);
  color-scheme: dark;
}

body[data-theme="glass"] {
  background: #0b141a;
  background-image:
    linear-gradient(180deg, #0f1a22 0%, #0b141a 40%, #0b141a 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

body[data-theme="dark"] .header,
body[data-theme="glass"] .header {
  background: var(--surface);
  border-bottom-color: var(--border);
}

body[data-theme="glass"] .header {
  background: rgba(23, 33, 43, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body[data-theme="dark"] .card,
body[data-theme="glass"] .card,
body[data-theme="dark"] .aside-card,
body[data-theme="glass"] .aside-card {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

body[data-theme="glass"] .card,
body[data-theme="glass"] .aside-card {
  background: rgba(23, 33, 43, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(120, 140, 160, 0.28);
}

/* Контрастные поля ввода / селекты (Safari: без системной отрисовки) */
body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="glass"] input,
body[data-theme="glass"] select,
body[data-theme="glass"] textarea {
  background: var(--input-bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--input-border) !important;
  color-scheme: dark;
  -webkit-appearance: none !important;
  appearance: none !important;
}
body[data-theme="dark"] select,
body[data-theme="glass"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239aadc0' d='M1.4 0L6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 12px 8px !important;
  padding-right: 32px !important;
}

body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder,
body[data-theme="glass"] input::placeholder,
body[data-theme="glass"] textarea::placeholder {
  color: #7a8fa3;
  opacity: 1;
}

body[data-theme="dark"] select option,
body[data-theme="glass"] select option {
  background: #17212b;
  color: #f5f7fa;
}

body[data-theme="dark"] input:focus,
body[data-theme="dark"] select:focus,
body[data-theme="dark"] textarea:focus,
body[data-theme="glass"] input:focus,
body[data-theme="glass"] select:focus,
body[data-theme="glass"] textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(46, 194, 126, 0.25);
}

body[data-theme="dark"] input.invalid,
body[data-theme="dark"] select.invalid,
body[data-theme="glass"] input.invalid,
body[data-theme="glass"] select.invalid {
  background: rgba(232, 93, 93, 0.12) !important;
  border-color: var(--danger) !important;
}

body[data-theme="dark"] .items-table input,
body[data-theme="dark"] .items-table select,
body[data-theme="glass"] .items-table input,
body[data-theme="glass"] .items-table select {
  background: var(--input-bg) !important;
  color: var(--text) !important;
  border-color: var(--input-border) !important;
}

body[data-theme="dark"] .nav button.active,
body[data-theme="dark"] .nav button:hover,
body[data-theme="glass"] .nav button.active,
body[data-theme="glass"] .nav button:hover {
  background: rgba(46, 194, 126, 0.18);
  color: #5ee9a8;
}

body[data-theme="dark"] .btn-secondary,
body[data-theme="glass"] .btn-secondary {
  background: var(--surface2);
  border-color: var(--input-border);
  color: var(--text);
}

body[data-theme="dark"] .btn-secondary:hover,
body[data-theme="glass"] .btn-secondary:hover {
  background: #2a3848;
}

body[data-theme="dark"] .orders-table tr:hover,
body[data-theme="glass"] .orders-table tr:hover {
  background: rgba(46, 194, 126, 0.08);
}

body[data-theme="dark"] .orders-table tr.active,
body[data-theme="glass"] .orders-table tr.active {
  background: rgba(46, 194, 126, 0.16);
}

body[data-theme="dark"] .orders-table th,
body[data-theme="glass"] .orders-table th {
  background: var(--surface2);
  color: var(--muted);
  border-color: var(--border);
}

body[data-theme="dark"] .orders-table td,
body[data-theme="glass"] .orders-table td {
  border-color: var(--border);
  color: var(--text);
}

body[data-theme="dark"] .app-footer,
body[data-theme="glass"] .app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
}

body[data-theme="glass"] .app-footer {
  background: rgba(23, 33, 43, 0.8);
  backdrop-filter: blur(12px);
}

body[data-theme="dark"] .pay-row,
body[data-theme="glass"] .pay-row {
  background: var(--surface2);
  border-color: var(--border);
}

body[data-theme="dark"] .clone-banner,
body[data-theme="glass"] .clone-banner {
  background: rgba(106, 178, 242, 0.12);
  border-color: rgba(106, 178, 242, 0.35);
  color: #c5dff8;
}

body[data-theme="dark"] .warn-box,
body[data-theme="glass"] .warn-box {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}

body[data-theme="dark"] .warn-box.error,
body[data-theme="glass"] .warn-box.error {
  background: rgba(232, 93, 93, 0.14);
  border-color: rgba(232, 93, 93, 0.4);
  color: #fecaca;
}

body[data-theme="dark"] .items-table th,
body[data-theme="glass"] .items-table th {
  color: var(--muted);
  border-bottom-color: var(--border);
}

body[data-theme="dark"] .result-box,
body[data-theme="glass"] .result-box {
  background: #0a1018;
  color: #e2e8f0;
}

body[data-theme="dark"] .settings-tab.active,
body[data-theme="glass"] .settings-tab.active {
  background: rgba(46, 194, 126, 0.18);
  color: #5ee9a8;
}

body[data-theme="dark"] .settings-tab,
body[data-theme="glass"] .settings-tab {
  color: var(--muted);
}

body[data-theme="dark"] .badge,
body[data-theme="glass"] .badge {
  border-color: var(--border);
}

body[data-theme="dark"] .aside-card .kv,
body[data-theme="glass"] .aside-card .kv {
  border-bottom-color: var(--border);
}

body[data-theme="dark"] .section-title,
body[data-theme="glass"] .section-title {
  border-bottom-color: var(--border);
  color: var(--text);
}

body[data-theme="dark"] code,
body[data-theme="glass"] code {
  background: var(--surface2);
  color: #c5dff8;
}


body[data-theme="dark"] .store-card.active,
body[data-theme="glass"] .store-card.active {
  border-color: rgba(46, 194, 126, 0.5);
  background: rgba(46, 194, 126, 0.12);
}
body[data-theme="dark"] .settings-tab.active,
body[data-theme="dark"] .settings-tab:hover,
body[data-theme="glass"] .settings-tab.active,
body[data-theme="glass"] .settings-tab:hover {
  background: rgba(46, 194, 126, 0.18);
  color: #5ee9a8;
  border-color: rgba(46, 194, 126, 0.4);
}
body[data-theme="dark"] .orders-table tr:hover,
body[data-theme="glass"] .orders-table tr:hover {
  background: rgba(46, 194, 126, 0.08);
}

/* Инверсия логотипа для тёмной и glass */
body[data-theme="dark"] .header-logo,
body[data-theme="dark"] .login-logo,
body[data-theme="glass"] .header-logo,
body[data-theme="glass"] .login-logo {
  filter: invert(1) hue-rotate(180deg);
}

body[data-theme="dark"] .login-card,
body[data-theme="glass"] .login-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

body[data-theme="glass"] .login-card {
  background: rgba(23, 33, 43, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

body[data-theme="dark"] .login-wrap,
body[data-theme="glass"] .login-wrap {
  background: linear-gradient(160deg, #0b141a, #17212b);
}

/* Theme picker UI */
.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  min-width: 100px;
  margin: 0 !important;
  transition: border-color .15s, box-shadow .15s;
}
.theme-option:hover {
  border-color: var(--accent);
}
.theme-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(46, 194, 126, 0.35);
}
.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.theme-swatch {
  width: 56px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.theme-swatch-light {
  background: linear-gradient(135deg, #f4f6f9 40%, #fff 40%);
}
.theme-swatch-dark {
  background: linear-gradient(135deg, #0e1621 40%, #17212b 40%);
}
.theme-swatch-glass {
  background: linear-gradient(160deg, #0b141a, #232e3c);
}
.theme-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}


/* Receipt panel + buttons on dark/glass */
body[data-theme="dark"] .receipt-view,
body[data-theme="glass"] .receipt-view {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}
body[data-theme="dark"] .receipt-view .r-item-sub,
body[data-theme="glass"] .receipt-view .r-item-sub,
body[data-theme="dark"] .receipt-view .r-meta,
body[data-theme="glass"] .receipt-view .r-meta,
body[data-theme="dark"] .receipt-view .r-pay,
body[data-theme="glass"] .receipt-view .r-pay,
body[data-theme="dark"] .receipt-view .r-section-title,
body[data-theme="glass"] .receipt-view .r-section-title {
  color: var(--muted);
}
body[data-theme="dark"] .receipt-view .result-box,
body[data-theme="glass"] .receipt-view .result-box {
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid var(--border);
}

/* Кнопки: менее «кислотные», спокойный контраст */
body[data-theme="dark"] .btn,
body[data-theme="glass"] .btn {
  background: #2f9e66;
  color: #f0fdf4;
}
body[data-theme="dark"] .btn:hover,
body[data-theme="glass"] .btn:hover {
  background: #278a58;
}
body[data-theme="dark"] .btn-secondary,
body[data-theme="glass"] .btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}
body[data-theme="dark"] .btn-secondary:hover,
body[data-theme="glass"] .btn-secondary:hover {
  background: rgba(120, 140, 160, 0.18);
  border-color: var(--input-border);
}
body[data-theme="dark"] .btn-danger,
body[data-theme="glass"] .btn-danger {
  background: #c45c5c;
}
body[data-theme="dark"] .link-pay,
body[data-theme="glass"] .link-pay {
  background: #2f9e66;
  color: #f0fdf4 !important;
}
body[data-theme="dark"] .badge-status-done,
body[data-theme="glass"] .badge-status-done {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}
body[data-theme="dark"] .badge-status-paid,
body[data-theme="glass"] .badge-status-paid {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
body[data-theme="dark"] .badge-status-wait,
body[data-theme="glass"] .badge-status-wait {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}
body[data-theme="dark"] .badge-status-fail,
body[data-theme="glass"] .badge-status-fail {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* === Receipt layout polish === */
.receipt-view .r-head-actions {
  margin-top: 10px;
}
.receipt-view .r-head-actions .btn {
  font-size: 0.8rem;
}
.receipt-view .r-line span:first-child {
  color: var(--muted);
  flex-shrink: 0;
  max-width: 48%;
}
.receipt-view .r-line span:last-child {
  text-align: right;
  word-break: break-word;
  color: var(--text);
}

/* Soft primary buttons on dark/glass (Telegram-like) */
body[data-theme="dark"] .btn:not(.btn-secondary):not(.btn-danger),
body[data-theme="glass"] .btn:not(.btn-secondary):not(.btn-danger) {
  background: #2a9d68;
  color: #ecfdf5;
  border: 1px solid transparent;
  box-shadow: none;
}
body[data-theme="dark"] .btn:not(.btn-secondary):not(.btn-danger):hover,
body[data-theme="glass"] .btn:not(.btn-secondary):not(.btn-danger):hover {
  background: #248f5c;
}
body[data-theme="dark"] .btn-secondary,
body[data-theme="glass"] .btn-secondary {
  background: transparent;
  border: 1px solid var(--input-border);
  color: var(--text);
}
body[data-theme="dark"] .btn-secondary:hover,
body[data-theme="glass"] .btn-secondary:hover {
  background: rgba(120, 140, 160, 0.12);
}

/* Receipt: never force white paper on dark themes */
body[data-theme="dark"] .receipt-view,
body[data-theme="glass"] .receipt-view {
  background: var(--surface2) !important;
  color: var(--text) !important;
  border: 1px dashed var(--border);
}
body[data-theme="dark"] .receipt-view .r-title,
body[data-theme="glass"] .receipt-view .r-title,
body[data-theme="dark"] .receipt-view .r-item-name,
body[data-theme="glass"] .receipt-view .r-item-name,
body[data-theme="dark"] .receipt-view .r-total,
body[data-theme="glass"] .receipt-view .r-total {
  color: var(--text) !important;
}
body[data-theme="dark"] .receipt-view .r-total,
body[data-theme="glass"] .receipt-view .r-total {
  border-top-color: var(--border);
}
body[data-theme="dark"] .receipt-view .r-link-row a,
body[data-theme="glass"] .receipt-view .r-link-row a {
  color: var(--primary);
}
body[data-theme="dark"] .receipt-view .badge,
body[data-theme="glass"] .receipt-view .badge {
  border: 1px solid transparent;
}

/* Table header sticky on dark */
body[data-theme="dark"] .orders-table thead th,
body[data-theme="glass"] .orders-table thead th {
  background: var(--surface);
  color: var(--muted);
  border-bottom-color: var(--border);
}
body[data-theme="dark"] .orders-table td,
body[data-theme="glass"] .orders-table td {
  border-bottom-color: var(--border);
  color: var(--text);
}

/* warn-box on dark */
body[data-theme="dark"] .warn-box,
body[data-theme="glass"] .warn-box {
  background: rgba(46, 194, 126, 0.12);
  border-color: rgba(46, 194, 126, 0.35);
  color: #86efac;
}
body[data-theme="dark"] .warn-box.error,
body[data-theme="glass"] .warn-box.error {
  background: rgba(232, 93, 93, 0.12);
  border-color: rgba(232, 93, 93, 0.35);
  color: #fca5a5;
}


/* === Payment link result: copy / share / QR === */
.pay-result-box { color: inherit; }
.pay-link-panel {
  margin-top: 14px;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.pay-link-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text);
}
.pay-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.pay-link-input {
  flex: 1;
  min-width: 160px;
  font-size: 0.85rem !important;
  cursor: text;
}
.pay-share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.pay-qr-wrap {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.pay-qr-wrap canvas,
.pay-qr-wrap img {
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  max-width: 100%;
  height: auto;
}
.pay-qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body[data-theme="dark"] .pay-link-panel,
body[data-theme="glass"] .pay-link-panel {
  background: var(--surface2);
  border-color: var(--border);
}
body[data-theme="dark"] .pay-link-input,
body[data-theme="glass"] .pay-link-input {
  background: var(--input-bg) !important;
  color: var(--text) !important;
  border-color: var(--input-border) !important;
}


/* === Modal: ссылка на оплату === */
body.modal-open { overflow: hidden; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.modal.hidden { display: none !important; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 0;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}
.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 16px;
}
.modal-body .pay-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.modal-body .pay-link-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  font-size: 0.85rem !important;
}
.modal-body .pay-share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.modal-body .pay-qr-wrap {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.modal-body .pay-qr-wrap canvas,
.modal-body .pay-qr-wrap img {
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
}
.modal-body .pay-qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.pay-modal-meta {
  margin-top: 12px;
  text-align: center;
  font-size: 0.78rem;
}
body[data-theme="dark"] .modal-dialog,
body[data-theme="glass"] .modal-dialog {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
body[data-theme="dark"] .modal-body .pay-link-input,
body[data-theme="glass"] .modal-body .pay-link-input {
  background: var(--input-bg) !important;
  color: var(--text) !important;
  border-color: var(--input-border) !important;
}


/* --- Модалка результата чека (как превью в списке) --- */
.modal-dialog.modal-dialog-receipt {
  width: min(420px, 96vw);
  max-height: min(92vh, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.modal-dialog.modal-dialog-receipt .modal-header,
.modal-dialog.modal-dialog-receipt .modal-footer {
  flex-shrink: 0;
}
.modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.modal-footer .btn {
  min-width: 110px;
}
#check_modal_body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 12px 16px;
  /* без видимого скроллбара — скролл колёсиком */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#check_modal_body::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}
#check_modal_body .receipt-view {
  margin: 0;
  /* тот же вид, что справа в списке чеков */
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow: visible;
}
#check_modal_body .r-json .result-box {
  max-height: 180px;
  overflow: auto;
  font-size: 0.72rem;
  word-break: break-all;
}
.receipt-view .r-line > span:first-child {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--muted);
}
.receipt-view .r-line > span:last-child {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.receipt-view .r-head-actions {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}
body[data-theme="dark"] .modal-footer,
body[data-theme="glass"] .modal-footer {
  border-color: var(--border);
}

/* === Mobile / tablet / landscape phone === */
@media (max-width: 960px) {
  .header-inner,
  .footer-inner,
  .container {
    width: 100%;
    padding-left: 4%;
    padding-right: 4%;
  }
  .header-logo {
    max-width: 120px;
    height: auto;
  }
  .nav {
    width: 100%;
    order: 3;
    display: flex;
    flex-wrap: wrap;
  }
  .nav button {
    flex: 1 1 auto;
    padding: 8px 10px;
    font-size: 0.8rem;
  }
  .user-info {
    font-size: 0.8rem;
  }
  .items-table {
    font-size: 0.78rem;
  }
  .check-layout {
    grid-template-columns: 1fr;
  }
  .aside-card,
  .orders-detail-pane {
    position: static;
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

@media (max-width: 700px) {
  .row-3 { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .header {
    padding: 8px 0;
  }
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .logo {
    justify-content: flex-start;
  }
  .header-logo {
    max-width: 110px;
  }
  .nav button {
    font-size: 0.75rem;
    padding: 8px 6px;
  }
  .user-info {
    justify-content: space-between;
  }
  .container {
    padding-top: 12px;
    padding-bottom: 20px;
  }
  .card {
    padding: 14px 12px;
  }
  .row,
  .row-3 {
    grid-template-columns: 1fr !important;
  }
  .app-footer {
    padding: 16px 0 24px;
  }
  .login-card {
    margin: 12px;
    padding: 24px 18px;
    max-width: calc(100% - 24px);
  }
  .modal {
    padding: 10px;
    align-items: flex-end;
  }
  .modal-dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: 14px 14px 10px 10px;
  }
}

/* Горизонтальный телефон */
@media (max-height: 480px) and (orientation: landscape) {
  .header {
    padding: 4px 0;
  }
  .header-inner {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
  }
  .header-logo {
    max-width: 90px;
  }
  .nav button {
    padding: 6px 8px;
    font-size: 0.72rem;
  }
  .container {
    padding-top: 8px;
    padding-bottom: 12px;
  }
  .card {
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  .app-footer {
    padding: 10px 0 14px;
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    font-size: 0.75rem;
  }
  .modal {
    align-items: center;
    padding: 8px;
  }
  .modal-dialog {
    max-height: 94vh;
    width: min(520px, 96%);
  }
  .modal-body {
    padding: 12px;
  }
  .pay-qr-wrap canvas,
  .pay-qr-wrap img {
    width: 120px !important;
    height: 120px !important;
  }
}

.header-inner,
.footer-inner,
.container {
  box-sizing: border-box;
}

/* ── Templates / reusable QR Pay ── */
.templates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tpl-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--card-bg, #fff);
}
.tpl-qr-cell .tpl-show-qr {
  white-space: normal;
  max-width: 120px;
  line-height: 1.25;
  text-align: center;
  padding: 8px 10px;
}
.tpl-qr-cell {
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  overflow: hidden;
}
.tpl-qr-cell canvas,
.tpl-qr-cell img {
  width: 96px;
  height: 96px;
  display: block;
}
.tpl-qr-empty {
  font-size: 0.75rem;
  color: var(--muted, #9ca3af);
  text-align: center;
  padding: 4px;
}
.tpl-card-body {
  flex: 1;
  min-width: 0;
}
.tpl-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.tpl-card-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.tpl-card-meta {
  font-size: 0.82rem;
  color: var(--muted, #6b7280);
  margin-top: 2px;
}
.tpl-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.tpl-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}
.tpl-link-row input {
  flex: 1;
  min-width: 160px;
  font-size: 0.8rem;
  padding: 6px 8px;
}
.tpl-providers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px 8px;
  max-height: 160px;
  overflow-y: auto;
  padding: 6px 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
}
.tpl-providers label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  line-height: 1.25;
  cursor: pointer;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tpl-providers input[type="checkbox"] {
  width: 1.1em;
  height: 1.1em;
  margin: 0;
  flex-shrink: 0;
}
.btn-link-subtle {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin-left: 8px;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-family: inherit;
}
.btn-link-subtle:hover { color: var(--primary); }
.modal-dialog-wide {
  width: min(50vw, 920px);
  max-width: min(50vw, 920px);
}
@media (max-width: 900px) {
  .modal-dialog-wide {
    width: 95vw;
    max-width: 95vw;
  }
  .tpl-card {
    flex-direction: column;
    align-items: stretch;
  }
  .tpl-qr-cell {
    margin: 0 auto;
  }
}
body[data-theme="dark"] .tpl-card,
body[data-theme="glass"] .tpl-card {
  background: var(--card-bg, #1f2937);
  border-color: var(--border, #374151);
}
body[data-theme="dark"] .tpl-qr-cell,
body[data-theme="glass"] .tpl-qr-cell {
  background: #fff;
}

.tpl-qr-img.tpl-qr-pending {
  opacity: 0.35;
  background: repeating-linear-gradient(
    45deg,
    #f3f4f6,
    #f3f4f6 4px,
    #e5e7eb 4px,
    #e5e7eb 8px
  );
}
.tpl-qr-img {
  width: 96px;
  height: 96px;
  display: block;
  object-fit: contain;
}


/* Reports charts */
.reports-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.rpt-chart-box {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 12px;
  min-height: 200px;
}
.rpt-chart-wide { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .reports-charts { grid-template-columns: 1fr; }
  .rpt-chart-wide { grid-column: auto; }
}

/* ===== Dashboard (home) — horizontal layout ===== */
/* Dashboard — full width like other sections */
.dash { max-width: none; width: 100%; }
.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.dash-title { font-size: 1.35rem; font-weight: 700; margin: 0 0 4px; }
.dash-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.dash-filters label { min-width: 120px; margin: 0; }
.dash-filters .btn { margin-bottom: 1px; }
.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.dash-side { display: flex; flex-direction: column; gap: 12px; }
.dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 4px;
}
.dash-metric-label { font-size: 0.8rem; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.dash-metric-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.dash-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dash-delta {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.dash-delta.up { color: #16a34a; }
.dash-delta.down { color: #dc2626; }
.dash-delta.flat { color: var(--muted); }
/* Полукруг: компактнее, подписи внутри дуги */
.dash-gauge-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 150px;
  max-width: 280px;
  margin: 0 auto;
  overflow: hidden;
}
.dash-gauge-wrap canvas {
  max-height: 150px;
  width: 100% !important;
  height: auto !important;
}
.dash-gauge-center {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  width: 70%;
  max-width: 160px;
  text-align: center;
  pointer-events: none;
  line-height: 1.2;
}
.dash-gauge-label {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-gauge-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-pay-types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px 16px;
}
.dash-pay-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 0.9rem;
}
.dash-pay-charts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}
@media (max-width: 700px) {
  .dash-pay-charts { grid-template-columns: repeat(2, 1fr); }
}
.dash-mini-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}
.dash-mini-chart canvas {
  max-width: 100px;
  max-height: 100px;
}
.dash-mini-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}
.dash-mini-value {
  font-size: 0.9rem;
  font-weight: 700;
}
.header .logo { cursor: pointer; user-select: none; }

.dash-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.dash-action {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.dash-action:hover {
  border-color: #86efac;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.12);
  transform: translateY(-1px);
}
.dash-action-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.dash-action-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

