@import url("/static/brand-fonts.css?v=373");
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* TREFF8 Admin v2.8+ — light workspace & mobile-ready responsive layout */
:root {
  color-scheme: light;
  --accent: #FFCC00;
  --card: #FFFFFF;
  --border: #E3E5E9;
  --muted: #686D77;
  color: #24262C;
  background: #F4F5F7;
}

html, body { 
  background: #F4F5F7; 
  color: #24262C; 
  margin: 0;
  padding: 0;
}

body { 
  font-size: 14px; 
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell { background: #F4F5F7; }

/* ==================== ЛЕВОЕ МЕНЮ (SIDEBAR) ==================== */
.sidebar {
  background: #FFFFFF !important;
  border-right: 1px solid #E3E5E9 !important;
  box-shadow: 2px 0 16px rgba(16, 20, 34, .025);
  display: flex;
  flex-direction: column;
  padding: 22px 14px !important;
  box-sizing: border-box;
}

/* Кликабельный логотип */
.sidebar .brand { 
  display: flex !important;
  align-items: baseline !important;
  gap: 8px !important; 
  padding: 0 10px 18px !important;
  margin: 0 0 6px 0 !important;
  border-bottom: 1px solid #F0F2F5;
  cursor: pointer; 
  user-select: none;
  transition: opacity 0.15s ease;
}
.sidebar .brand:hover { opacity: 0.8; }
.sidebar .brand .brand-mark { width: 140px; max-width: 100%; height: auto; object-fit: contain; display: block; }
.sidebar .brand small { color: #383D46; font-size: 10px; font-weight: 800; letter-spacing: 1.7px; }

/* Заголовки разделов в меню (УПРАВЛЕНИЕ, КОНТРОЛЬ ДОСТУПА) */
.sidebar .side-caption { 
  color: #858B95 !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.8px !important;
  padding: 0 12px !important;
  margin: 14px 0 6px 0 !important;
  display: block !important;
}

.sidebar .side-caption.separated { 
  border-top: 1px solid #E7E9EC !important; 
  padding-top: 16px !important;
  margin-top: 16px !important;
}

/* Контейнер навигации */
.sidebar nav {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Идеально ровные пункты меню */
.sidebar .nav { 
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100% !important;
  min-height: 42px !important;
  padding: 9px 12px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  color: #404650 !important; 
  font-size: 14px !important;
  font-weight: 600 !important; 
  line-height: 1.25 !important;
  text-align: left !important;
  text-decoration: none !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 10px !important;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

/* Иконка и подпись — раздельные flex-элементы. Важное: не назначать
   иконочную ширину первому span — это подпись в старой разметке. */
.sidebar .nav .nav-icon {
  flex: 0 0 20px;
  width: 20px;
  min-width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
}
.sidebar .nav .nav-label {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  display: block;
  text-align: left;
  overflow-wrap: anywhere;
}
.sidebar .nav .mail-count { flex: 0 0 auto; }

.sidebar .nav:hover { 
  background: #FFF6D6 !important; 
  color: #181B20 !important; 
}

/* Активный пункт без сдвига текста (используем внутреннюю тень вместо border-left) */
.sidebar .nav.active, 
.sidebar .nav.active:hover {
  background: #FFCC00 !important;
  color: #161616 !important;
  font-weight: 700 !important;
  box-shadow: inset 3px 0 0 #B48500, 0 2px 6px rgba(255, 204, 0, 0.25) !important;
}

/* Подвал левого меню (почта и кнопка Выйти) */
.sidebar .side-footer { 
  margin-top: auto !important;
  padding: 16px 6px 0 !important;
  border-top: 1px solid #E7E9EC !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}
.sidebar .side-footer .secondary {
  width: 100% !important;
  justify-content: center !important;
}

.inactive-menu { color: #8B929D; }
.tiny { color: #69707B; font-size: 12px; word-break: break-all; }
.overline, .work-menu-group { color: #858B95; }

/* ==================== ОСНОВНАЯ ОБЛАСТЬ (MAIN) ==================== */
/* Скрываем верхнюю полосу с крошками (.topbar) везде и поднимаем контент */
.topbar, .main > .topbar { 
  display: none !important; 
}

.main { 
  color: #252830; 
  padding: 28px 32px 40px !important; 
  box-sizing: border-box;
  min-width: 0;
}

.page, .event-workspace { 
  color: #252830; 
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.title-row, .workspace-head {
  margin-top: 0 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pill, .topbar .pill {
  background: #FFF4CC; border: 1px solid #F0D57B; color: #715400;
  border-radius: 6px;
}

.title-row h1, .workspace-heading h1, .work-title h2 { 
  color: #181B20; 
  font-weight: 700; 
  letter-spacing: -0.4px; 
  margin-top: 0; 
}
.muted, .event-sub, .hint, .table-caption { color: #68717D; }

/* ==================== КНОПКИ И ПОЛЯ ВВОДА ==================== */
.primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.18s ease;
}

.primary {
  background: #FFCC00; color: #1C1D20; border: 1px solid #EFBF00;
  box-shadow: 0 2px 0 rgba(120, 90, 0, .09);
  font-weight: 600;
}
.primary:hover:not(:disabled) { 
  background: #F5C100; border-color: #E5B500; 
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 204, 0, 0.25);
}
.primary:active:not(:disabled) { transform: translateY(0); box-shadow: none; }

.secondary { 
  background: #FFFFFF; border: 1px solid #CED3DA; color: #343943; 
  font-weight: 500;
}
.secondary:hover:not(:disabled) { 
  background: #F1F2F4; border-color: #ADB4BF; 
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.primary:focus-visible, .secondary:focus-visible, .nav:focus-visible,
.work-nav:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible { outline: 2px solid #CB9800; outline-offset: 2px; }

input:not([type=checkbox]):not([type=radio]), select, textarea {
  color: #22262E; background: #FFFFFF; border: 1px solid #CED4DC;
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 40px;
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus {
  border-color: #FFCC00; box-shadow: 0 0 0 3px rgba(255,204,0,.15);
  outline: none;
}
input::placeholder, textarea::placeholder { color: #949AA4; }
input[type=checkbox], input[type=radio] { accent-color: #D9A600; }

/* ==================== КАРТОЧКИ И ТАБЛИЦЫ ==================== */
.stat, .stat.offline, .work-stat, .ticket-quota-card, .login-card, .workspace-content {
  background: #FFFFFF; 
  border: 1px solid #E3E5EA; 
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat:hover, .work-stat:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.stat span, .work-stat span { color: #707783; font-weight: 500; font-size: 13px; }
.stat strong, .stat.offline strong, .work-stat strong { color: #1F2329; font-weight: 700; letter-spacing: -0.5px; }

.info, .work-info, .work-stat-inline, .ticket-limit-panel {
  background: #FFFBED; border: 1px solid #F0E0AA; color: #373327;
  border-radius: 12px;
}
.info p, .work-info p, .ticket-limit-panel .hint { color: #5D615D; }

.filters input, .filters select { background: #FFFFFF; }
.event-item, .empty, .audit-item, .category-line, .work-category {
  background: #FFFFFF; border: 1px solid #E1E4E9;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.event-name { color: #202329; font-weight: 600; }
.event-item:hover { 
  border-color: #D1B049; 
  box-shadow: 0 4px 12px rgba(23, 27, 35, .06); 
  transform: translateY(-1px);
}

.tag { border-radius: 6px; font-weight: 500; }
.tag.draft { color: #666A73; background: #F0F2F5; border-color: #DDE1E6; }
.tag.published, .tag.on_sale,
.tag:not(.cancelled):not(.draft):not(.completed):not(.sales_closed) {
  background: #FFF1BF; color: #795B00; border-color: #EACB70;
}
.tag.cancelled { background: #FFF0F0; border-color: #FFC5C5; color: #B63A3A; }
.tag.completed, .tag.sales_closed { background: #F0F2F6; border-color: #D6DCE5; color: #4E5D70; }

.shade { background: rgba(28, 30, 39, .46); backdrop-filter: blur(2px); }
.dialog { background: #FFFFFF; color: #23262D; box-shadow: -20px 0 55px rgba(23, 24, 34, .15); border-radius: 16px; }
.dialog-head { border-color: #E3E5E9; }
.dialog-head .overline { color: #8B6900; }
.dialog-head h2, .section-header { color: #202329; font-weight: 700; }
.icon-close { color: #474C56; border-radius: 8px; transition: background 0.2s; }
.icon-close:hover { color: #12151A; background: #F1F2F4; }

.category-line .muted, .work-category .muted { color: #6F7680; }
.separator, .question-field { border-color: #E4E6EB; }
.error { color: #B62D38; font-weight: 500; }

.login-screen { background: #F4F5F7; }
.login-card { box-shadow: 0 15px 45px rgba(19,26,36,.07); padding: 32px; }
.login-card .brand { margin-bottom: 24px; }

.toast { background: #FFFFFF; color: #252830; border: 1px solid #D5D9DF; box-shadow: 0 8px 28px rgba(0,0,0,.13); border-radius: 8px; font-weight: 500; }
.audit-item span { color: #737986; }

a, .link-button { color: #906B00; transition: color 0.2s; }
a:hover, .link-button:hover { color: #B78800; }
#scan-status { color: #31363C; }

.table-shell { 
  background: #FFFFFF; 
  border: 1px solid #DEE1E6; 
  border-radius: 12px; 
  overflow-x: auto; 
  -webkit-overflow-scrolling: touch;
}
.admin-table th { color: #555C67; background: #F8F9FA; border-color: #DEE1E6; font-weight: 600; white-space: nowrap; }
.admin-table td { border-color: #E7E9ED; color: #242830; }
.admin-table tbody tr { transition: background 0.15s; }
.admin-table tbody tr:hover { background: #FFF9E6; }
.cell-sub { color: #757D89; }
.table-empty { color: #727986; }

.label-pill { background: #FFF3CE; border: 1px solid #E9D489; color: #715300; border-radius: 6px; }
.label-pill.used { background: #F0F2F5; border-color: #D5D9DF; color: #66707B; }
.label-pill.partial { background: #FFF2DA; border-color: #E6C88E; color: #8B6000; }

.section-title, .detail-grid strong { color: #252930; }
.detail-grid span { color: #69717B; }

/* Внутреннее меню мероприятия */
.workspace-menu { background: #FFFFFF; border: 1px solid #E1E4E9; border-radius: 12px; padding: 10px; }
.work-menu-group { color: #777F8C; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; margin: 14px 8px 6px; }
.work-nav { 
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  box-sizing: border-box;
  color: #333943; 
  background: transparent; 
  border-radius: 8px; 
  transition: all 0.15s; 
  font-weight: 500; 
  text-align: left;
}
.work-nav:hover { background: #FFF4CF; color: #1F2329; }
.work-nav.active, .work-nav.active:hover { background: #FFCC00; color: #1A1C20; font-weight: 600; }

.work-stat-inline { color: #433A23; }
.work-category { box-shadow: 0 2px 7px rgba(0,0,0,.018); }
.question-field strong, .event-amount { color: #7F5E00; font-weight: 600; }

.export-menu-options {
  background: #FFFFFF; border: 1px solid #D5D9DF;
  box-shadow: 0 14px 34px rgba(20,25,35,.14);
  border-radius: 12px;
}
.export-menu-options a { color: #353B44; border-radius: 6px; margin: 2px; }
.export-menu-options a:hover { color: #242830; background: #FFF2C7; }
.event-thumbnail { border-color: #DEE1E6; border-radius: 8px; }

/* Ticket workspace v3.1 */
.ticket-quota-card { margin: 15px 0; padding: 20px; background: #FFFDF3; border: 1px solid #E9D78C; border-radius: 12px; }
.ticket-quota-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center; }
.ticket-quota-head strong { font-size: 15px; font-weight: 700; }
.ticket-quota-head span, .ticket-quota-grid span { color: #626872; font-size: 12px; font-weight: 500; }
.ticket-quota-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.ticket-quota-grid > div { background: white; border: 1px solid #E2E4E8; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 5px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
#ticket-workspace .filters { display: flex; gap: 10px; flex-wrap: wrap; }
#ticket-workspace .filters input { flex: 2; min-width: 170px; }
#ticket-workspace .filters select { flex: 1; min-width: 150px; }
#ticket-qr-preview img { image-rendering: auto; border: 1px solid #E2E4E8; padding: 8px; background: white; border-radius: 10px; }

/* ==================== МОБИЛЬНАЯ ВЕРСИЯ (ДО 700px) ==================== */
/* На десктопе мобильная шапка и крестик строго скрыты */
.mobile-topbar,
.mobile-menu-backdrop,
.mobile-menu-close {
  display: none !important;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.mobile-brand .brand-mark {
  width: 112px;
  max-width: 112px;
  height: auto;
  object-fit: contain;
}
.mobile-brand small {
  color: #383D46;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.4px;
}

.mobile-menu-toggle,
.mobile-menu-close {
  appearance: none;
  border: 1px solid #D7DCE4;
  background: #FFFFFF;
  color: #23272F;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(14, 18, 27, .05);
  transition: background 0.2s;
}
.mobile-menu-toggle:hover,
.mobile-menu-close:hover {
  background: #F6F7F9;
}

.workspace-mobile-checkout { display: none; }

@media (max-width: 700px) {
  body.mobile-menu-open {
    overflow: hidden;
  }
  .shell {
    display: block !important;
    min-height: 100vh;
  }

  /* Верхняя панель смартфона */
  .mobile-topbar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 25;
    padding: 12px 16px;
    background: rgba(244, 245, 247, .96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #E2E6EB;
  }
  .mobile-menu-toggle {
    display: inline-flex !important;
  }

  /* Затемнение фона при открытии меню */
  .mobile-menu-backdrop {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 29;
    border: 0;
    background: rgba(17, 20, 26, .42);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  body.mobile-menu-open .mobile-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Выезжающая шторка меню на телефоне */
  .sidebar {
    position: fixed !important;
    top: 0;
    right: 0;
    left: auto;
    width: min(84vw, 320px) !important;
    max-width: 320px !important;
    height: 100dvh !important;
    z-index: 30;
    padding: 16px !important;
    border-right: 0 !important;
    border-left: 1px solid #E4E6EA !important;
    box-shadow: -18px 0 42px rgba(13, 17, 24, .16) !important;
    transform: translateX(105%);
    transition: transform .24s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    background: #FFFFFF !important;
  }
  body.mobile-menu-open .sidebar {
    transform: translateX(0);
  }

  /* Возвращаем кнопку закрытия (крестик) ТОЛЬКО внутри мобильной шторки */
  .sidebar .mobile-menu-close {
    display: inline-flex !important;
    align-self: flex-end;
    margin-bottom: 8px;
  }

  .sidebar .brand {
    padding: 0 4px 14px !important;
    margin-bottom: 6px !important;
  }
  .sidebar .brand .brand-mark {
    width: 120px;
  }

  .sidebar .side-caption,
  .sidebar .side-caption.separated {
    margin: 14px 4px 6px !important;
    padding: 0 6px !important;
    border-top: 0 !important;
  }

  .sidebar nav {
    gap: 6px !important;
  }

  .sidebar .nav {
    min-height: 44px !important;
    padding: 11px 14px !important;
    border: 1px solid #E5E7EA !important;
    border-radius: 10px !important;
    font-size: 14px !important;
  }
  .sidebar .nav.active {
    border-color: #D6A600 !important;
    box-shadow: none !important;
  }

  /* Контентная часть на мобильном */
  .main {
    padding: 16px 14px 32px !important;
  }

  .title-row {
    gap: 10px;
    margin-bottom: 14px !important;
  }
  .title-row h1 {
    font-size: 22px;
    margin: 0;
  }
  .title-row .primary {
    width: 100%;
    min-height: 44px;
  }

  /* Компактная сетка карточек метрик (по 2 в ряд на смартфоне) */
  .stats, .work-stats {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .stat, .work-stat {
    padding: 14px !important;
    border-radius: 10px !important;
  }
  .stat strong, .work-stat strong {
    font-size: 22px !important;
  }

  /* Фильтры и формы на мобильном */
  .filters, #ticket-workspace .filters, .form-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .filters input, .filters select, .filters button,
  #ticket-workspace .filters input, #ticket-workspace .filters select,
  .form-actions button, .form-actions a, .form-actions select {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 42px !important;
    margin: 0 !important;
  }

  /* Карточки мероприятий в списке */
  .event-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 14px !important;
  }
  .event-item button, .event-item .secondary, .event-item .primary {
    width: 100%;
  }

  /* Шапка и навигация внутри мероприятия на телефоне */
  .workspace-head {
    display: flex;
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0 0 14px !important;
  }
  #workspace-back {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
  }
  .workspace-heading { flex: 1 1 0; min-width: 0; }
  .workspace-heading h1 {
    margin: 0 0 4px;
    font-size: 18px;
    line-height: 1.25;
    letter-spacing: -.3px;
    overflow-wrap: anywhere;
  }
  #workspace-meta {
    font-size: 11px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
  #workspace-checkout { display: none; }
  .workspace-mobile-checkout {
    display: flex;
    justify-content: center;
    margin: 16px 0 24px;
  }
  #workspace-checkout-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    text-decoration: none;
  }

  .workspace-layout { display: block; }
  .workspace-menu {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    white-space: normal;
    margin: 0 0 14px;
    padding: 8px;
  }
  .workspace-menu .work-menu-group { display: none; }
  .workspace-menu .work-nav {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 8px 6px;
    border-radius: 8px;
    border: 1px solid #DEE2E8;
    justify-content: center;
    text-align: center;
    font-size: 12px;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .workspace-content { min-width: 0; padding: 14px; }

  /* Модальные окна на весь экран телефона */
  .dialog {
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
}

/* На очень узких экранах (меньше 360px) карточки метрик встают в 1 колонку */
@media (max-width: 360px) {
  .stats, .work-stats, .workspace-menu {
    grid-template-columns: 1fr !important;
  }
}
/* TREFF8 3.9.6: dashboard metrics navigate to their corresponding sections. */
.stat-link {
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.stat-link:hover { border-color: #E4BA24; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.09); }
.stat-link:focus-visible { outline: 3px solid #D29D00; outline-offset: 2px; }
