/* ============================================================
   ТеремкиОблік — Головна таблиця стилів
   Версія: 1.1.0
   Дизайн: мінімалістичний, high-contrast, зелений/оливковий
   ============================================================ */

/* ─── ЗМІННІ ─────────────────────────────────────────────── */
:root {
  /* Фони */
  --bg:          #0f1510;
  --surface:     #182018;
  --surface-2:   #1e2a1e;
  --surface-3:   #253025;

  /* Межі */
  --border:      #2a3d2a;
  --border-2:    #344a34;

  /* Основний зелений */
  --primary:        #3a7050;
  --primary-hover:  #468a62;
  --primary-active: #2e5a40;
  --primary-dim:    #1e3828;

  /* Акцент зелений */
  --accent:      #6aaa7c;
  --accent-dim:  #4a7a58;

  /* Оливковий */
  --olive:       #7c8a48;
  --olive-light: #96a458;

  /* Текст */
  --text:        #d8ecd8;
  --text-muted:  #6e8e6e;
  --text-dim:    #3e5a3e;

  /* Стан */
  --danger:      #a03020;
  --danger-bg:   #1e0c08;
  --danger-dim:  #6a1a10;
  --warning:     #9a7818;
  --warning-bg:  #1c1808;
  --success:     #2a7040;
  --success-bg:  #0c1e10;
  --info:        #2a6080;

  /* Ролі */
  --role-admin:     #7aab87;
  --role-warehouse: #96a458;
  --role-kitchen:   #c8a030;
  --role-host:      #5a90b0;

  /* Layout */
  --header-h:    64px;
  --nav-h:       52px;
  --footer-h:    44px;
  --sidebar-w:   0px; /* немає sidebar, тільки top nav */

  /* Типографіка */
  --font-main:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'Roboto Mono', 'Courier New', monospace;

  /* Радіус */
  --r-sm: 3px;
  --r-md: 6px;
  --r-lg: 10px;

  /* Анімації */
  --transition: 150ms ease;
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-main);
  background:  var(--bg);
  color:       var(--text);
  line-height: 1.5;
  min-height:  100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
ul, ol { list-style: none; }

/* ─── LAYOUT — APP SHELL ─────────────────────────────────── */
.app-header {
  position:   fixed;
  top:        0;
  left:       0;
  right:      0;
  height:     var(--header-h);
  background: var(--surface);
  border-bottom: 2px solid var(--border-2);
  display:    flex;
  align-items: center;
  justify-content: space-between;
  padding:    0 1.5rem;
  z-index:    100;
  gap:        1rem;
}

.header-brand {
  display:   flex;
  align-items: center;
  gap:       0.6rem;
  flex-shrink: 0;
}
.brand-icon   { font-size: 1.6rem; }
.brand-name   {
  font-size:   1.25rem;
  font-weight: 700;
  color:       var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.header-user {
  display:     flex;
  align-items: center;
  gap:         0.8rem;
  flex-shrink: 0;
}

.role-badge {
  font-size:    0.7rem;
  font-weight:  600;
  padding:      0.2em 0.6em;
  border:       1.5px solid var(--accent);
  color:        var(--accent);
  border-radius: var(--r-sm);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space:  nowrap;
}
/* Role badge colors — CSS класи (без inline styles, CSP-safe) */
.role-badge-admin     { border-color: var(--role-admin);     color: var(--role-admin); }
.role-badge-warehouse { border-color: var(--role-warehouse); color: var(--role-warehouse); }
.role-badge-kitchen   { border-color: var(--role-kitchen);   color: var(--role-kitchen); }
.role-badge-host      { border-color: var(--role-host);      color: var(--role-host); }

.user-name {
  font-size:   0.95rem;
  color:       var(--text-muted);
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
  max-width:   200px;
}

.btn-logout {
  display:     flex;
  align-items: center;
  gap:         0.4rem;
  padding:     0.4rem 0.9rem;
  border:      1.5px solid var(--border-2);
  color:       var(--text-muted);
  border-radius: var(--r-md);
  font-size:   0.85rem;
  transition:  var(--transition);
  white-space: nowrap;
}
.btn-logout:hover {
  border-color: var(--danger);
  color:        var(--danger);
}
.btn-logout svg { width: 16px; height: 16px; }

/* NAV */
.app-nav {
  position:   fixed;
  top:        var(--header-h);
  left:       0;
  right:      0;
  height:     var(--nav-h);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  z-index:    90;
  overflow-x: auto;
  overflow-y: hidden;
}
.app-nav::-webkit-scrollbar { height: 3px; }
.app-nav::-webkit-scrollbar-track { background: transparent; }
.app-nav::-webkit-scrollbar-thumb { background: var(--border-2); }

.nav-inner {
  display:     flex;
  align-items: stretch;
  height:      100%;
  min-width:   max-content;
  padding:     0 0.5rem;
}

.nav-item {
  display:     flex;
  align-items: center;
  gap:         0.5rem;
  padding:     0 1.2rem;
  color:       var(--text-muted);
  font-size:   0.9rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition:  var(--transition);
  white-space: nowrap;
  cursor:      pointer;
}
.nav-item:hover {
  color:        var(--accent);
  background:   var(--surface-3);
}
.nav-item.active {
  color:        var(--accent);
  border-bottom-color: var(--primary);
  background:   var(--primary-dim);
}
.nav-icon {
  width:  18px;
  height: 18px;
  flex-shrink: 0;
}
.nav-icon svg { width: 100%; height: 100%; }

/* MAIN CONTENT */
.app-main {
  margin-top:    calc(var(--header-h) + var(--nav-h));
  margin-bottom: var(--footer-h);
  padding:       1.5rem;
  min-height:    calc(100vh - var(--header-h) - var(--nav-h) - var(--footer-h));
  max-width:     1600px;
}

/* FOOTER CLOCK */
.app-footer {
  position:   fixed;
  bottom:     0;
  left:       0;
  right:      0;
  height:     var(--footer-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display:    flex;
  align-items: center;
  justify-content: center;
  gap:        1rem;
  z-index:    100;
  font-family: var(--font-mono);
}

.clock-date {
  font-size:   0.9rem;
  color:       var(--text-muted);
}
.clock-time {
  font-size:   1rem;
  font-weight: 500;
  color:       var(--accent);
  letter-spacing: 0.05em;
}
.clock-sep {
  color: var(--border-2);
}

/* ─── LOGIN PAGE ─────────────────────────────────────────── */
.login-body {
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  min-height:      100vh;
  padding:         1rem;
}

.login-wrap {
  width:      100%;
  max-width:  420px;
  display:    flex;
  flex-direction: column;
  gap:        1rem;
}

.login-card {
  background:   var(--surface);
  border:       1.5px solid var(--border-2);
  border-radius: var(--r-lg);
  padding:      2.5rem 2rem;
}

.login-brand {
  text-align:    center;
  margin-bottom: 2rem;
}
.login-icon  { font-size: 3rem; margin-bottom: 0.5rem; }
.login-title {
  font-size:   1.6rem;
  font-weight: 700;
  color:       var(--text);
  letter-spacing: -0.02em;
}
.login-sub {
  margin-top: 0.3rem;
  font-size:  0.85rem;
  color:      var(--text-muted);
}

.login-form { display: flex; flex-direction: column; gap: 1.2rem; }

.login-footer-clock {
  text-align: center;
  padding:    0.5rem;
  font-family: var(--font-mono);
  display:    flex;
  justify-content: center;
  align-items: center;
  gap:        0.8rem;
}

/* ─── ФОРМИ ──────────────────────────────────────────────── */
.form-group {
  display:        flex;
  flex-direction: column;
  gap:            0.4rem;
}

.form-label {
  font-size:   0.85rem;
  font-weight: 600;
  color:       var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  background:    var(--surface-2);
  border:        1.5px solid var(--border-2);
  color:         var(--text);
  padding:       0.75rem 1rem;
  border-radius: var(--r-md);
  font-size:     1rem;
  transition:    var(--transition);
  outline:       none;
  width:         100%;
}
.form-input::placeholder { color: var(--text-dim); }
.form-input:focus {
  border-color: var(--primary);
  background:   var(--surface-3);
}

select.form-input option {
  background-color: var(--surface-2);
  color: var(--text);
}

.form-input:hover:not(:focus) { border-color: var(--border-2); }

.form-input.error { border-color: var(--danger); }

/* ─── КНОПКИ ─────────────────────────────────────────────── */
.btn {
  display:       inline-flex;
  align-items:   center;
  justify-content: center;
  gap:           0.4rem;
  padding:       0.6rem 1.2rem;
  border:        1.5px solid transparent;
  border-radius: var(--r-md);
  font-size:     0.9rem;
  font-weight:   600;
  cursor:        pointer;
  transition:    var(--transition);
  text-decoration: none;
  white-space:   nowrap;
  line-height:   1.3;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text);
}
.btn-primary:hover:not(:disabled) {
  background:   var(--primary-hover);
  border-color: var(--primary-hover);
  color:        var(--text);
}

.btn-secondary {
  background:   transparent;
  border-color: var(--border-2);
  color:        var(--text-muted);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent-dim);
  color:        var(--accent);
}

.btn-danger {
  background:   transparent;
  border-color: var(--danger-dim);
  color:        var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background:   var(--danger-bg);
  border-color: var(--danger);
}

.btn-full { width: 100%; }
.btn-lg   { padding: 0.85rem 1.5rem; font-size: 1rem; }
.btn-sm   { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

/* ─── TABS & LIST ITEMS ───────────────────────────────────────── */
.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border-2);
}
.tab-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.tab-btn.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--accent);
}

/* ─── BUILDER MODULE ─────────────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 768px) {
  .builder-layout { grid-template-columns: 1fr; }
  
  /* На мобільному панель рецепту стає повноекранним поп-апом */
  #recipePanel {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    overflow-y: auto;
    border-radius: 0 !important;
    background: var(--surface) !important;
    padding: 1.5rem !important;
  }
  #recipeTable {
    min-width: 100% !important;
  }
  .mobile-only { display: inline-flex !important; }
}

.mobile-only { display: none; }

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}
@media (max-width: 768px) {
  .schedule-grid {
    grid-template-columns: 1fr;
  }
}

.schedule-item {
  background: var(--surface-2);
  padding: 0.8rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  width: 100%;
  box-sizing: border-box;
}
.schedule-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.schedule-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}
.schedule-item-cat {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dish-item {
  padding: 0.8rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.dish-item:hover {
  background: var(--surface-2);
  border-left-color: var(--border-2);
}
.dish-item.active {
  background: var(--primary-dim);
  border-left-color: var(--primary);
}

/* ─── АЛЕРТИ ─────────────────────────────────────────────── */
.alert {
  padding:       0.8rem 1rem;
  border-radius: var(--r-md);
  border:        1.5px solid;
  font-size:     0.9rem;
  margin-bottom: 1rem;
}
.alert-error {
  background:   var(--danger-bg);
  border-color: var(--danger-dim);
  color:        #e06050;
}
.alert-success {
  background:   var(--success-bg);
  border-color: var(--success);
  color:        #50c070;
}
.alert-warning {
  background:   var(--warning-bg);
  border-color: var(--warning);
  color:        #c09030;
}

/* ─── КАРТКИ ─────────────────────────────────────────────── */
.card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--r-md);
  overflow:      hidden;
}
.card-header {
  padding:       0.8rem 1.2rem;
  font-weight:   600;
  font-size:     0.85rem;
  color:         var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background:    var(--surface-2);
}

/* ─── ЗАГОЛОВОК СТОРІНКИ ─────────────────────────────────── */
.page-header {
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap:           1rem;
  flex-wrap:     wrap;
}
.page-title {
  display:     flex;
  align-items: center;
  gap:         0.6rem;
  font-size:   1.5rem;
  font-weight: 700;
  color:       var(--text);
}
.page-icon {
  width:   28px;
  height:  28px;
  color:   var(--primary);
}
.page-icon svg { width: 100%; height: 100%; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ─── PLACEHOLDER (МОДУЛЬ В РОЗРОБЦІ) ───────────────────── */
.placeholder-card {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  justify-content: center;
  text-align:     center;
  padding:        4rem 2rem;
  background:     var(--surface);
  border:         1px solid var(--border);
  border-radius:  var(--r-lg);
  gap:            1rem;
}
.placeholder-icon {
  width:  64px;
  height: 64px;
  color:  var(--text-dim);
}
.placeholder-icon svg { width: 100%; height: 100%; }
.placeholder-title {
  font-size:   1.6rem;
  font-weight: 700;
  color:       var(--text);
}
.placeholder-text {
  max-width:   500px;
  color:       var(--text-muted);
  font-size:   1rem;
  line-height: 1.6;
}
.placeholder-badge {
  padding:       0.4em 1em;
  border:        1.5px solid var(--olive);
  color:         var(--olive-light);
  border-radius: var(--r-md);
  font-size:     0.8rem;
  font-weight:   600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── ТАБЛИЦІ ─────────────────────────────────────────────── */
.data-table {
  width:           100%;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  padding:     0.4rem 0.6rem;
  text-align:  left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background:    var(--surface-2);
  font-size:     0.78rem;
  font-weight:   600;
  color:         var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space:   nowrap;
}
.data-table td { font-size: 0.92rem; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .btn { min-height: auto; }


/* ─── БЕЙДЖІ ─────────────────────────────────────────────── */
.badge {
  display:       inline-block;
  padding:       0.2em 0.6em;
  border:        1px solid;
  border-radius: var(--r-sm);
  font-size:     0.75rem;
  font-weight:   600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space:   nowrap;
}
.badge-success { color: #50c070; border-color: var(--success); background: var(--success-bg); }
.badge-danger  { color: #e06050; border-color: var(--danger-dim); background: var(--danger-bg); }
.badge-warning { color: #c09030; border-color: var(--warning); background: var(--warning-bg); }
.badge-info    { color: #5090c0; border-color: var(--info); }

.badge-role { border-color: transparent; background: var(--surface-3); }
.badge-admin     { color: var(--role-admin); }
.badge-warehouse { color: var(--role-warehouse); }
.badge-kitchen   { color: var(--role-kitchen); }
.badge-host      { color: var(--role-host); }

/* ─── SETTINGS LIST ──────────────────────────────────────── */
.settings-list { padding: 0.5rem 0; }
.setting-row {
  display:    grid;
  grid-template-columns: 220px 1fr;
  gap:        1rem;
  padding:    0.75rem 1.2rem;
  border-bottom: 1px solid var(--border);
  align-items: start;
  font-size:  0.9rem;
}
.setting-row:last-child { border-bottom: none; }
.setting-key  { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.82rem; }
.setting-value { color: var(--text); word-break: break-all; }
.setting-desc { display: none; } /* буде показано на мобільному або в тултіпі */

/* ─── УТИЛІТИ ─────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

.link { color: var(--accent); }
.link:hover { color: var(--text); text-decoration: underline; }

/* ─── TOUCHSCREEN OPTIMIZATIONS ─────────────────────────── */
/* Мінімальний розмір tap target 44px (Apple HIG / Google Material) */
@media (hover: none) {
  .nav-item       { min-height: 54px; }
  .btn            { min-height: 48px; padding: 0.8rem 1.4rem; }
  .form-input     { min-height: 54px; font-size: 1.1rem; }
  .data-table th,
  .data-table td  { padding: 0.6rem 0.8rem; }
  .btn-logout     { min-width: 44px; min-height: 44px; justify-content: center; }
}

/* ─── RESPONSIVE: MOBILE ─────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --header-h: 56px;
    --nav-h:    62px;  /* icon 20px + gap + label 10px + padding */
  }

  /* Header */
  .brand-name      { font-size: 1.05rem; }
  .user-name       { display: none; }
  .btn-logout span { display: none; }
  .btn-logout      { padding: 0.5rem; border: none; min-width: 40px; justify-content: center; }

  /* Nav — icon + label (label скорочено, nav scrollable) */
  .nav-item {
    padding:         0 0.75rem;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             0.1rem;
    min-width:       52px;
    font-size:       0.82rem;
  }
  .nav-label {
    display:    block;          /* Показуємо label на мобільному */
    font-size:  0.6rem;
    line-height: 1;
    opacity:    0.85;
  }
  .nav-item.active .nav-label { opacity: 1; }
  .nav-icon { width: 20px; height: 20px; }

  /* Main content */
  .app-main   { padding: 0.875rem; }
  .page-title { font-size: 1.15rem; }

  /* Placeholder */
  .placeholder-card { padding: 2.5rem 1.25rem; }
  .placeholder-icon { width: 48px; height: 48px; }
  .placeholder-title { font-size: 1.3rem; }

  /* Tables — горизонтальний scroll */
  .card         { overflow-x: auto; }
  .data-table   { min-width: 440px; }
  .data-table th,
  .data-table td { padding: 0.7rem 0.8rem; font-size: 0.82rem; }

  /* Settings */
  .setting-row  { grid-template-columns: 1fr; gap: 0.15rem; padding: 0.6rem 0.8rem; }

  /* Login */
  .login-card   { padding: 1.5rem 1.1rem; border-radius: var(--r-md); }
  .login-icon   { font-size: 2.5rem; }
  .login-title  { font-size: 1.4rem; }

  /* Page header стекується на мобільному */
  .page-header  { flex-direction: column; align-items: flex-start; margin-bottom: 1rem; }
  .page-actions { width: 100%; flex-direction: column; gap: 0.5rem; }
  .page-actions .form-input { width: 100%; min-width: unset; }
  .page-actions .btn { width: 100%; justify-content: center; }

  /* Склад — таби */
  .tab-btn { flex: 1; text-align: center; font-size: 0.85rem; padding: 0.6rem 0.5rem; }

  /* Склад — панель замовлення */
  #btnLowStockToggle { font-size: 0.88rem; padding: 0.8rem 1rem; }
  #lowStockLabel { font-size: 0.88rem; }
}

/* ─── RESPONSIVE: GREAT (1920x1200 TOUCHSCREEN / KIOSK) ─── */
/* Raspberry Pi 5 + 10.1" 1920×1200 LCD, Chromium kiosk mode  */
/* Touch targets мінімум 56px для кухні ("жирні" пальці)       */
@media (min-width: 1400px) {
  :root {
    --header-h: 72px;
    --nav-h:    62px;
    --footer-h: 50px;
  }
  body           { font-size: 17px; }
  .brand-name    { font-size: 1.4rem; }
  .brand-icon    { font-size: 1.9rem; }

  /* Nav — великі кнопки для touch */
  .nav-item {
    padding:   0 1.6rem;
    font-size: 0.97rem;
    gap:       0.55rem;
    min-height: var(--nav-h); /* повна висота = touch target */
  }
  .nav-icon      { width: 22px; height: 22px; }

  /* Header */
  .role-badge    { font-size: 0.75rem; padding: 0.25em 0.7em; }
  .user-name     { font-size: 1rem; max-width: 240px; }
  .btn-logout    { padding: 0.5rem 1.1rem; font-size: 0.9rem; min-height: 44px; }

  /* Контент */
  .page-title    { font-size: 1.8rem; }
  .page-icon     { width: 32px; height: 32px; }

  /* Clock */
  .clock-time    { font-size: 1.15rem; }
  .clock-date    { font-size: 0.95rem; }

  /* Tables */
  .data-table th,
  .data-table td { padding: 1.05rem 1.25rem; font-size: 0.97rem; }

  /* Buttons — більші для touch */
  .btn           { padding: 0.75rem 1.5rem; font-size: 0.97rem; min-height: 48px; }
  .btn-lg        { padding: 1rem 2rem; font-size: 1.05rem; min-height: 56px; }

  /* Forms */
  .form-input    { padding: 0.9rem 1.15rem; font-size: 1.1rem; min-height: 56px; }
  .form-label    { font-size: 0.88rem; }

  /* Placeholder */
  .placeholder-card  { padding: 5rem 3rem; }
  .placeholder-icon  { width: 80px; height: 80px; }
  .placeholder-title { font-size: 2rem; }
  .placeholder-text  { font-size: 1.05rem; }
}

/* ─── PRINT ───────────────────────────────────────────────── */
@media print {
  .app-header,
  .app-nav,
  .app-footer { display: none !important; }
  .app-main { padding: 0 !important; margin: 0 !important; }
  .card { border: none !important; box-shadow: none !important; }
  body { background: white !important; color: black !important; }
  * { color: black !important; }
  .no-print { display: none !important; }
}

/* ─── PRINT ORDER MODE — показуємо тільки список замовлення ── */
body.print-order-mode .app-header,
body.print-order-mode .app-nav,
body.print-order-mode .app-footer,
body.print-order-mode .app-main > *:not(#printOrderArea),
body.print-order-mode #lowStockPanel,
body.print-order-mode #viewRaw,
body.print-order-mode #viewSecondary {
  display: none !important;
}
body.print-order-mode #printOrderArea {
  display: block !important;
  background: white;
  color: #000;
  padding: 2rem;
  font-family: sans-serif;
}
@media print {
  body.print-order-mode .app-header,
  body.print-order-mode .app-nav,
  body.print-order-mode .app-footer { display: none !important; }
  body.print-order-mode #printOrderArea { display: block !important; }
  body.print-order-mode * { color: #000 !important; background: transparent !important; }
}

/* ─── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--surface); 
}
::-webkit-scrollbar-thumb {
  background: var(--border-2); 
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary); 
}

/* ─── SETTINGS MODULE ─────────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
@media (max-width: 768px) {
  .settings-layout { grid-template-columns: 1fr; }
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .settings-sidebar {
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }
  .settings-tab {
    flex-shrink: 0;
  }
}

.settings-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  text-align: left;
  padding: 0.8rem 1rem;
  border-radius: var(--r-md);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.settings-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}
.settings-tab.active {
  background: var(--primary-dark);
  color: var(--text);
  font-weight: 600;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface-2);
  padding: 1rem;
  border-radius: var(--r-md);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

/* Checkbox as Toggle */
.module-toggle, #userIsActive {
  appearance: none;
  width: 40px;
  height: 20px;
  background: var(--surface-3);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background 0.3s;
}
.module-toggle::after, #userIsActive::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.module-toggle:checked, #userIsActive:checked {
  background: var(--olive);
}
.module-toggle:checked::after, #userIsActive:checked::after {
  transform: translateX(20px);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: var(--r-md);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 10000;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ─── MODAL ──────────────────────────────────────────────── */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal.active .modal-content {
  transform: translateY(0) scale(1);
}

/* ─── MOBILE RESPONSIVE (SETTINGS) ───────────────────────── */
@media (max-width: 768px) {
  .settings-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .settings-sidebar {
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }
  .settings-tab {
    text-align: center;
    padding: 0.8rem 1.2rem;
  }
  .settings-content {
    padding: 1.5rem 1rem !important;
  }
  .modal-content {
    margin: 1rem;
    padding: 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* ─── FORMS & INPUTS ──────────────────────────────────────── */
.form-group {
  margin-bottom: 1.75rem; /* Збільшено відстань між полями */
  display: flex;
  flex-direction: column;
  gap: 0.6rem; /* Збільшено відстань між заголовком та полем */
}
.form-group label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.2rem;
}
.form-group small.text-muted {
  font-size: 0.85rem;
  margin-top: 0.4rem;
  display: block;
}

/* ─── ANALYTICS MODULE ──────────────────────────────────────── */
.analytics-container {
  max-width: 1200px;
  margin: 0 auto;
}
.analytics-header {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}
.analytics-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}
.date-filters {
  display: flex;
  gap: 0.5rem;
}
.date-custom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.analytics-section {
  margin-bottom: 3rem;
}
.section-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border-2);
  padding-bottom: 0.5rem;
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 1.5rem;
  text-align: center;
}
.metric-title {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.metric-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace;
  color: var(--text);
}
.tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 900px) {
  .tables-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  .analytics-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .date-filters {
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }
  .btn {
    width: 100%;
  }
  #btnExportPdf {
    margin-left: 0 !important;
  }
}

/* ─── ТАБЛИЦІ ────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-2);
}
.table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  background-color: var(--bg-card);
}
.table tbody tr {
  transition: var(--transition);
}
.table tbody tr:hover {
  background-color: var(--surface-2);
}

/* ─── АНАЛІТИКА — LAYOUT КОНТРОЛІВ ──────────────────────────── */
.analytics-container {
  padding-bottom: 3rem;
}
.analytics-header {
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.analytics-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.analytics-row-dates {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-2);
}
.date-quick-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.date-quick-group .btn {
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
}
.date-custom-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.date-custom-group .date-inp {
  max-width: 140px;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
}
.date-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.analytics-selects {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  flex: 1;
}
.analytics-selects .form-input {
  flex: 1;
  min-width: 130px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}
.analytics-btns {
  display: flex;
  gap: 0.6rem;
  margin-left: auto;
}
.btn-generate {
  white-space: nowrap;
  font-size: 0.95rem;
  padding: 0.6rem 1.2rem;
}
.btn-export {
  white-space: nowrap;
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
}

/* ─── АНАЛІТИКА — МЕТРИКИ ────────────────────────────────────── */
.metrics-list-card {
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 0.25rem 0;
  margin-bottom: 1.25rem;
}
.metric-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-2);
}
.metric-row:last-child { border-bottom: none; }
.metric-label {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.metric-value-lg {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1;
}
.metric-unit {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ─── ПІДКАЗКИ ? ─────────────────────────────────────────────── */
.tooltip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  padding: 0;
}
.tooltip-btn:hover, .tooltip-btn:focus {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  outline: none;
}

/* ─── ТАБЛИЦІ СТРАВ (2-колонкова сітка) ─────────────────────── */
.dishes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

/* ─── СЕКЦІЯ АНАЛІТИКИ ───────────────────────────────────────── */
.analytics-section {
  margin-bottom: 2rem;
}
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── МОБІЛЬНА АДАПТАЦІЯ АНАЛІТИКИ ──────────────────────────── */
@media (max-width: 700px) {
  .analytics-header {
    padding: 0.85rem;
  }
  .analytics-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .analytics-row-dates {
    margin-bottom: 0.6rem;
    padding-bottom: 0.6rem;
  }
  .date-quick-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .date-quick-group .btn {
    width: 100%;
    text-align: center;
    padding: 0.65rem 0.5rem;
    font-size: 0.9rem;
  }
  .date-custom-group {
    margin-left: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.8rem 0.5rem;
    align-items: center;
  }
  .date-custom-group .date-inp {
    max-width: 100%;
    width: 100%;
  }
  .analytics-selects {
    flex-direction: column;
    gap: 0.4rem;
  }
  .analytics-selects .form-input {
    min-width: unset;
    width: 100%;
  }
  .analytics-btns {
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
  }
  .btn-generate {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
  }
  .btn-export {
    padding: 0.85rem 1rem;
  }

  /* Метрики на мобільному */
  .metric-row {
    padding: 0.75rem 0.9rem;
    flex-wrap: wrap;
  }
  .metric-label {
    font-size: 0.88rem;
    flex: 0 0 100%;
    margin-bottom: 0.2rem;
  }
  .metric-value-lg {
    font-size: 1.6rem;
  }

  /* Таблиці страв — 1 колонка */
  .dishes-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Таблиці — менший padding */
  .table th, .table td {
    padding: 0.6rem 0.65rem;
    font-size: 0.83rem;
  }
  .table th {
    font-size: 0.72rem;
  }
  .section-title {
    font-size: 1rem;
  }
}

/* ─── PRINT CSS (FOR PDF EXPORT) ────────────────────────────── */
.print-only { display: none; }

@media print {
  body {
    background: #fff;
    color: #000;
    margin: 0;
    padding: 0;
  }
  .sidebar, .top-nav, .no-print {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  .print-only {
    display: block !important;
  }
  .metric-card, .card, .analytics-header {
    border: 1px solid #ccc;
    box-shadow: none;
    break-inside: avoid;
    background: #fff;
  }
  .metric-value { color: #000 !important; }
  .section-title { color: #000; border-bottom: 2px solid #ccc; }
  .table th { background: #f0f0f0; color: #000; border-color:#ccc; }
  .table td { border-color:#ccc; color:#000; }
  .table-responsive { overflow: visible !important; }
  * { text-shadow: none !important; box-shadow: none !important; }
  @page { margin: 1cm; }
}

@media print {
  body.print-order-mode * { visibility: hidden; }
  body.print-order-mode .print-only-order, body.print-order-mode .print-only-order * { visibility: visible; }
  body.print-order-mode .print-only-order { position: absolute; left: 0; top: 0; width: 100%; }
}
