:root {
  --bg: #0e1512; --panel: #16201c; --line: #243029; --text: #eaf3ef;
  --muted: #8fa89f; --accent: #1aa179; --danger: #e0584b; --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }

.btn { border: 1px solid var(--line); background: #1d2823; color: var(--text);
  padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #3a2421; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login[hidden] { display: none; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: 360px; max-width: 100%; text-align: center; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card .btn { width: 100%; margin-top: 14px; }

/* app */
.adminbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.adminbar .spacer { flex: 1 1 auto; min-width: 0; }
.adminbar .venue-sel { max-width: 140px; }

/* Tooltip при hover */
.adminbar [title] { position: relative; }
.adminbar [title]::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0c1510;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity .15s .1s;
}
.adminbar [title]:hover::after { opacity: 1; }
/* На мобилни — скрий рядко ползваните бутони */
@media (max-width: 600px) {
  .adminbar { gap: 6px; padding: 8px 10px; }
  #who { display: none; }
  .venue-sel { max-width: 110px; font-size: 13px; }
  .btn { padding: 7px 10px; font-size: 13px; }
  /* ⚙ бутон — по-голям touch target */
  #venueSettingsBtn { min-width: 38px; min-height: 38px; padding: 0; font-size: 20px; display: flex; align-items: center; justify-content: center; }

  /* Скрий вторичните езици и описание — само BG + превод с 🌐 */
  .name-line.secondary { display: none !important; }
  .names input.desc-in { display: none; }

  /* Продуктов ред: 2-редов layout
     ред 1: thumb | name  | actions
     ред 2: thumb | price | actions        */
  .item-row {
    grid-template-columns: 14px 40px minmax(0, 1fr) auto;
    grid-template-areas: "drag thumb names actions" "drag thumb price actions";
    gap: 3px 8px;
    align-items: start;
  }
  .item-drag   { grid-area: drag; align-self: center; }
  .thumb       { grid-area: thumb; align-self: center; }
  .names       { grid-area: names; min-width: 0; }
  .names input { min-width: 0; }
  .price-cell  { grid-area: price; justify-self: end; margin-top: 2px; }
  .row-actions { grid-area: actions; align-self: center; flex-direction: column; gap: 4px; }
  .item-row .price-in { width: 72px; font-size: 13px; padding: 6px; }
  .item-row .size-lbl-in { width: 58px; }
  .item-row .size-price-in { width: 52px; }

  /* Алергени — да не разпъват реда */
  .al-chip { overflow: hidden; min-width: 0; }
  .al-chip .al-lbl { overflow: hidden; text-overflow: ellipsis; }

  /* Категорийно заглавие — пренася се на 2 реда вместо да разпъва страницата */
  .cat-head { flex-wrap: wrap; gap: 6px; padding: 10px; }
  .cat-head input.cat-name { flex: 1 1 100px; width: auto; min-width: 0; font-size: 15px; }
  .cat-head .spacer { display: none; }
}
.editor { max-width: 880px; margin: 0 auto; padding: 16px; }

.cat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #18231e; }
.cat-img-thumb {
  width: 40px; height: 40px; border-radius: 8px; flex: 0 0 auto;
  background: #0f1714; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 16px;
  cursor: pointer; overflow: hidden;
}
.cat-img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cat-img-thumb:hover { border-color: var(--accent); }
.cat-head input.cat-name { background: transparent; border: 0; color: var(--text); font-size: 17px; font-weight: 700; width: 220px; }
.cat-head .icon-in { width: 44px; text-align: center; background: #0f1714; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 18px; padding: 6px 0; }
.cat-body { padding: 8px 14px 14px; }

.drag-handle { cursor: grab; color: rgba(255,255,255,.25); font-size: 16px; padding: 0 2px; user-select: none; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
.drag-ghost { opacity: .35; background: rgba(255,255,255,.04) !important; border-radius: var(--radius); }
.cat-drag { font-size: 18px; }
.disp-sel { background: #0f1714; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 5px 6px; font-size: 12px; cursor: pointer; }

.item-row { display: grid; grid-template-columns: 18px 44px 1fr auto auto; gap: 10px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line); }
.item-row:first-child { border-top: 0; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #0f1714; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 20px; cursor: pointer; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.names { display: flex; flex-direction: column; gap: 4px; }
.names .name-line { display: flex; align-items: center; gap: 6px; }
.names .lang-tag { width: 26px; font-size: 11px; color: var(--muted); font-weight: 700; }
.names input { flex: 1; background: #0f1714; border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 6px 8px; font-size: 13px; }
.names input.primary-name { font-size: 14px; font-weight: 600; }
.names input.desc-in { font-size: 12px; color: var(--muted); margin-top: 2px; }
.names input.emoji-in { max-width: 90px; font-size: 16px; }
.price-in { width: 84px; background: #0f1714; border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 8px; font-size: 14px; text-align: right; }
.row-actions { display: flex; gap: 6px; }
.icon-btn { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.tr:hover { color: var(--accent); }
.icon-btn.del:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn.ok { color: var(--accent); border-color: rgba(26,161,121,.3); }
.item-row.item-sold-out .names input { text-decoration: line-through; opacity: .5; }
.allergen-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; margin-top: 6px; }
.al-chip { display: flex; align-items: center; gap: 5px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 6px; font-size: 12px; padding: 5px 8px; cursor: pointer; color: rgba(255,255,255,.45); transition: all .15s; white-space: nowrap; text-align: left; }
.al-chip .al-n { font-size: 10px; opacity: .6; min-width: 16px; }
.al-chip.on { color: #e07b30; border-color: rgba(224,123,48,.7); background: rgba(224,123,48,.12); }
.al-chip.on .al-n { opacity: 1; }
.al-chip:hover:not(.on) { background: rgba(255,255,255,.11); color: rgba(255,255,255,.75); }

.cat-hidden-admin { opacity: .45; }
.cat-hidden-admin .cat-head { border-left: 3px solid var(--danger); }
.item-hidden-admin { opacity: .35; }
.item-hidden-admin .names input { text-decoration: line-through; }
.vm-sep { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.time-row { display: flex; align-items: center; gap: 8px; }
.time-row input[type=time] { background: #0f1714; border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 9px 10px; font-size: 14px; }
.time-dash { color: var(--muted); }
.cat-foot { display: flex; gap: 8px; margin-top: 10px; }

/* Цена — единична или с размери */
.price-cell { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.size-line { display: flex; gap: 4px; align-items: center; }
.size-lbl-in { width: 64px; background: #0f1714; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); padding: 6px; font-size: 12px; text-align: center; }
.size-price-in { width: 58px; background: #0f1714; border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 6px; font-size: 13px; text-align: right; }
.size-rm { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px; }
.size-rm:hover { color: var(--danger); }
.sizes-toggle { border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 8px; padding: 4px 8px; font-size: 11px; cursor: pointer; white-space: nowrap; }
.sizes-toggle:hover { color: var(--accent); border-color: var(--accent); }

.venue-sel { background: #0f1714; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 8px 10px; font-size: 14px; font-weight: 600; max-width: 200px; }

/* modal */
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; width: 460px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal-card h2 { margin: 0 0 14px; font-size: 19px; }
.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.fld > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.fld input:not([type=color]):not([type=checkbox]), .fld select {
  background: #0f1714; border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 10px; font-size: 14px; }
.fld input[type=color] { width: 56px; height: 36px; background: #0f1714; border: 1px solid var(--line); border-radius: 9px; }
.fld.chk { flex-direction: row; align-items: center; gap: 8px; }
.fld.chk span { font-size: 14px; color: var(--text); }
.logo-row { display: flex; align-items: center; gap: 8px; }
.logo-row input { flex: 1; }
.logo-prev { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line);
  background: #0f1714; display: grid; place-items: center; font-size: 10px; color: var(--muted);
  overflow: hidden; flex: 0 0 auto; }
.logo-prev img { width: 100%; height: 100%; object-fit: contain; }
.langs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.langs-grid label { display: flex; align-items: center; gap: 6px; font-size: 13px; background: #0f1714;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

input[type=range] { width: 100%; accent-color: var(--accent); margin-top: 4px; }

.hero-preview {
  width: 100%; height: 110px; border-radius: 12px;
  overflow: hidden; border: 1px solid var(--line);
  background: var(--accent); background-size: cover; background-position: center;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 10px; position: relative;
  transition: background-position .15s;
}
.hero-preview-logo {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.7);
  background: rgba(255,255,255,.15);
  overflow: hidden; display: grid; place-items: center;
  font-size: 18px; flex-shrink: 0;
}
.hero-preview-logo img { width: 100%; height: 100%; object-fit: cover; }

/* ── СТАТИСТИКА ── */
.stats-panel { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }
.stats-topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.stats-title { font-size: 18px; font-weight: 700; flex: 1; }
.period-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.period-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; }
.period-btn:hover { border-color: var(--accent); color: var(--text); }
.period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 600px) { .kpi-row { grid-template-columns: 1fr 1fr; } }
.kpi-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 16px; }
.kpi-num { font-size: 36px; font-weight: 900; color: var(--accent); display: block; line-height: 1; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 6px; display: block; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 640px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.chart-card h3 { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 14px; }
.chart-wide { grid-column: 1 / -1; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.bar-label { font-size: 13px; color: var(--text); min-width: 120px; flex: 0 0 auto; }
.bar-track { flex: 1; background: #1d2823; border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .6s cubic-bezier(.22,.61,.36,1); min-width: 2px; }
.bar-num { font-size: 13px; color: var(--muted); min-width: 32px; text-align: right; }
.hour-chart { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.hour-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; cursor: default; }
.hour-fill { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; transition: height .5s ease; opacity: .8; }
.hour-label { font-size: 9px; color: var(--muted); }
.table-qr-section { margin-top: 14px; }
.tbl-qr-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.tbl-in { width: 80px; background: #0f1714; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.stats-empty { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 15px; }
.adminbar button.active { background: rgba(26,161,121,.15); border-color: var(--accent); color: var(--accent); }

/* ── ПЕРИОД / СРАВНЕНИЕ ── */
.period-section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 20px; }
.period-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.period-row:last-child { margin-bottom: 0; }
.plbl { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; min-width: 70px; }
.compare-lbl { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); min-width: 70px; }
.compare-lbl input { accent-color: var(--accent); cursor: pointer; }
.custom-sel { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.period-sel { background: #0f1714; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.period-apply { padding: 6px 12px; font-size: 12px; font-weight: 700; }
.period-labels { margin-top: 6px; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-a { color: var(--accent); font-weight: 700; }
.pl-b { color: #5b9af5; font-weight: 700; }
.pl-vs { color: var(--muted); font-size: 12px; }

/* KPI delta */
.kpi-delta { font-size: 12px; font-weight: 700; margin: 4px 0 2px; display: flex; align-items: center; gap: 5px; }
.kpi-delta.pos { color: #4caf82; }
.kpi-delta.neg { color: var(--danger); }
.kpi-delta.neu { color: var(--muted); }
.kpi-b-val { color: var(--muted); font-weight: 400; font-size: 11px; }

/* Comparison bars */
.bar-col { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.bar-b-track { background: #1a2535; }
.bar-fill-b { height: 100%; background: #5b9af5; border-radius: 4px; transition: width .6s cubic-bezier(.22,.61,.36,1); min-width: 2px; opacity: .75; }
.num-b { color: #5b9af5; font-size: 11px; }

/* Hour chart comparison */
.hour-fill-b { width: 100%; background: #5b9af5; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .5s ease; opacity: .55; }

/* ── STATION selector ── */
.station-sel { background: #0f1714; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 8px; font-size: 12px; cursor: pointer; }

/* ── ORDERS панел ── */
.orders-panel { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
.ord-section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 20px 0 10px; }
.ord-section-done { opacity: .5; }
.ord-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.ord-card.ord-done { opacity: .45; }
.ord-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ord-table { font-size: 16px; font-weight: 800; color: var(--text); }
.ord-time { font-size: 12px; color: var(--muted); flex: 1; }
.ord-badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.ord-badge.done { background: rgba(26,161,121,.15); color: var(--accent); }
.ord-done-btn { padding: 5px 14px; font-size: 13px; background: var(--accent); border-color: var(--accent); color: #fff; }
.ord-note { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.ord-items { display: flex; flex-wrap: wrap; gap: 6px; }
.ord-item { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.ord-bar { background: rgba(26,161,121,.12); color: var(--accent); }
.ord-kitchen { background: rgba(240,130,60,.12); color: #f0823c; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; z-index: 50; }
.toast.err { background: var(--danger); }
.spin { opacity: .5; pointer-events: none; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .btn { margin-top: 12px; }
