/* Paleta: stonowana zieleń/grafit zamiast pomaranczowego. Kolory tylko przez zmienne,
       zeby ewentualna korekta byla w jednym miejscu. Kontrasty sprawdzone pod WCAG AA. */
    :root {
      --bg: #F4F6F5;
      --surface: #FFFFFF;
      --text: #1F2933;
      --muted: #66727A;
      --accent: #2E5D50;
      --accent-2: #385C74;
      --price: #8A5A44;
      --border: #D9E0DE;
      --cat-bg: #E8EFEC;
      --shadow: 0 1px 2px rgba(31,41,51,.05), 0 8px 24px rgba(31,41,51,.05);
      --radius: 14px;
      --maxw: 1120px;
      /* Pasek koszyka jest przyklejony na dole — trzymamy jego wysokosc,
         zeby tresc nigdy nie chowala sie pod nim. */
      --bar-h: 76px;
    }

    * { box-sizing: border-box; }
    html { -webkit-text-size-adjust: 100%; }

    body {
      margin: 0;
      background: var(--bg);
      color: var(--text);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
                   "Noto Sans", "Liberation Sans", sans-serif;
      font-size: 16px;
      line-height: 1.5;
      /* Bez zewnetrznego fontu: menu nie moze zalezec od CDN-u, ktory moze nie odpowiedziec. */
      -webkit-font-smoothing: antialiased;
      padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 12px);
    }

    [hidden] { display: none !important; }

    /* ---------- Wejscie po zeskanowaniu QR ---------- */
    .language-gate {
      min-height: 100dvh;
      display: grid;
      place-items: center;
      padding: 28px 16px;
      background: var(--bg);
    }
    .language-gate-inner {
      width: min(100%, 760px);
      text-align: center;
    }
    .language-mark {
      width: 54px;
      height: 54px;
      margin: 0 auto 18px;
      display: grid;
      place-items: center;
      color: #fff;
      background: var(--accent);
      border-radius: 8px;
      font-size: 25px;
      font-weight: 800;
    }
    .language-gate h1 {
      margin: 0;
      font-size: 30px;
      line-height: 1.2;
      overflow-wrap: anywhere;
    }
    .language-gate-meta { margin: 8px 0 0; color: var(--muted); }
    .language-table {
      display: inline-flex;
      align-items: center;
      gap: 9px;
      margin: 18px 0 22px;
      padding: 8px 14px;
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--accent);
      background: var(--surface);
    }
    .language-gate h2 { margin: 0 0 16px; font-size: 18px; font-weight: 650; }
    .language-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .language-choice {
      min-height: 76px;
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 14px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface);
      color: var(--text);
      font: inherit;
      font-weight: 650;
      text-align: left;
      cursor: pointer;
    }
    .language-choice:hover { border-color: var(--accent); background: var(--cat-bg); }
    .language-choice:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
    .language-choice:disabled { opacity: .45; }
    .language-flag { font-size: 29px; line-height: 1; }
    .language-native { min-width: 0; overflow-wrap: anywhere; }
    .language-gate-error {
      margin: 16px 0 0;
      padding: 10px;
      border-left: 3px solid #9b3b3b;
      background: #fff;
      color: #7b2929;
      text-align: left;
    }

    /* ---------- Naglowek ---------- */
    .header {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      padding: 22px 18px 18px;
    }
    .header-inner { max-width: var(--maxw); margin: 0 auto; }
    .venue-name {
      margin: 0 0 6px;
      font-size: 28px;
      font-weight: 650;
      letter-spacing: 0;
      line-height: 1.2;
    }
    .venue-info { margin: 2px 0; color: var(--muted); font-size: 14px; }
    .table-badge {
      display: inline-flex; align-items: center; gap: 8px;
      margin-top: 12px; padding: 7px 14px;
      background: var(--cat-bg); color: var(--accent);
      border: 1px solid var(--border); border-radius: 999px;
      font-size: 14px; font-weight: 650;
    }

    /* ---------- Nawigacja kategorii ---------- */
    .cat-nav {
      position: sticky; top: 0; z-index: 20;
      background: rgba(244,246,245,.94);
      backdrop-filter: saturate(180%) blur(8px);
      border-bottom: 1px solid var(--border);
    }
    .cat-nav-inner {
      max-width: var(--maxw); margin: 0 auto;
      display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px;
      scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .cat-nav-inner::-webkit-scrollbar { display: none; }
    .cat-chip {
      flex: 0 0 auto;
      padding: 9px 14px; min-height: 40px;
      display: inline-flex; align-items: center;
      background: var(--surface); color: var(--text);
      border: 1px solid var(--border); border-radius: 999px;
      font-size: 14px; font-weight: 600; text-decoration: none;
      white-space: nowrap; cursor: pointer;
    }
    .cat-chip:hover { border-color: var(--accent); color: var(--accent); }
    .cat-chip:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

    /* ---------- Menu ---------- */
    .menu-container { max-width: var(--maxw); margin: 0 auto; padding: 18px 14px 8px; }

    .category {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      margin-bottom: 18px;
      overflow: hidden;
      /* Kotwica pod przyklejona nawigacja, zeby naglowek nie chowal sie pod paskiem. */
      scroll-margin-top: 68px;
    }
    .category-header {
      background: var(--cat-bg);
      border-bottom: 1px solid var(--border);
      padding: 13px 18px;
    }
    .category-name {
      margin: 0;
      font-size: 17px; font-weight: 700;
      letter-spacing: 0;
      color: var(--accent);
    }

    .menu-item {
      display: grid;
      /* Telefon: nazwa+opis | cena | kompaktowy przycisk. Kolumna przycisku ma stala
         szerokosc 44 px (minimalne pole dotyku), wiec cena nigdy nie wpada pod nazwe. */
      grid-template-columns: minmax(0, 1fr) auto 44px;
      grid-template-areas: "info price action";
      gap: 4px 12px;
      align-items: center;
      padding: 13px 16px;
      border-top: 1px solid var(--border);
    }
    .menu-item:first-of-type { border-top: 0; }

    .item-info { grid-area: info; min-width: 0; }
    .item-name {
      font-size: 16px; font-weight: 650; line-height: 1.35;
      /* Dlugie nazwy zawijaja sie miedzy wyrazami; dzielenie w srodku slowa tylko wtedy,
         gdy pojedynczy wyraz nie miesci sie w kolumnie. Zadnego automatycznego
         przenoszenia z myslnikiem — psulo nazwy typu "kwaśni-ca". */
      overflow-wrap: break-word; word-break: normal; hyphens: manual;
    }
    .item-description {
      margin-top: 3px; color: var(--muted); font-size: 13.5px; line-height: 1.45;
      overflow-wrap: break-word; hyphens: manual;
    }
    .item-portion {
      display: inline-block; margin-top: 6px;
      padding: 3px 9px;
      background: var(--cat-bg); color: var(--accent);
      border-radius: 6px;
      font-size: 12px; font-weight: 650; letter-spacing: 0;
      white-space: nowrap;
    }
    .item-price {
      grid-area: price;
      color: var(--price);
      font-size: 16px; font-weight: 700;
      white-space: nowrap;      /* cena nigdy sie nie lamie ani nie nachodzi na nazwe */
      text-align: right;
      padding-top: 1px;
      font-variant-numeric: tabular-nums;
    }
    .add-button {
      grid-area: action;
      justify-self: end;
      width: 44px; height: 44px;   /* pelne pole dotyku takze na telefonie */
      display: inline-flex; align-items: center; justify-content: center;
      padding: 0;
      background: var(--accent); color: #fff;
      border: 0; border-radius: 12px;
      font-size: 22px; font-weight: 600; font-family: inherit; line-height: 1;
      cursor: pointer;
    }
    .add-button .add-label { display: none; }
    .add-button:hover { background: #264d43; }
    .add-button:active { transform: translateY(1px); }
    .add-button:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
    .add-button[disabled] { background: var(--muted); cursor: not-allowed; }

    .loading, .empty-box, .error-box {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted);
    }
    .error-box { border-color: #E0B4B4; color: #8A3A3A; }

    /* ---------- Pasek koszyka ---------- */
    .cart-bar {
      position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
      background: var(--surface);
      border-top: 1px solid var(--border);
      box-shadow: 0 -6px 24px rgba(31,41,51,.08);
      padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    }
    .cart-bar-inner {
      max-width: var(--maxw); margin: 0 auto;
      display: flex; align-items: center; justify-content: space-between; gap: 14px;
    }
    .cart-summary { min-width: 0; }
    .cart-summary .label { color: var(--muted); font-size: 13px; }
    .cart-summary .value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
    .cart-icon {
      display: inline-flex; align-items: center; gap: 10px;
      min-height: 48px; padding: 12px 20px;
      background: var(--accent); color: #fff;
      border: 0; border-radius: 12px;
      font-size: 15px; font-weight: 650; font-family: inherit;
      cursor: pointer; white-space: nowrap;
    }
    .cart-icon:hover { background: #264d43; }
    .cart-icon:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
    .cart-count {
      display: none;
      min-width: 24px; height: 24px; padding: 0 7px;
      align-items: center; justify-content: center;
      background: #fff; color: var(--accent);
      border-radius: 999px; font-size: 13px; font-weight: 800;
    }

    /* ---------- Koszyk (modal) ---------- */
    .modal {
      display: none; position: fixed; inset: 0; z-index: 60;
      background: rgba(31,41,51,.5);
      padding: 16px;
      overflow-y: auto;
    }
    .modal-content {
      background: var(--surface);
      max-width: 560px; margin: 5vh auto;
      border-radius: var(--radius); border: 1px solid var(--border);
      padding: 22px 20px 24px;
      position: relative;
      box-shadow: 0 20px 60px rgba(31,41,51,.2);
    }
    .modal-content h2 { margin: 0 0 14px; font-size: 20px; }
    .close {
      position: absolute; top: 10px; right: 12px;
      width: 44px; height: 44px;
      display: flex; align-items: center; justify-content: center;
      font-size: 28px; line-height: 1; color: var(--muted);
      cursor: pointer; border-radius: 10px; background: none; border: 0;
    }
    .close:hover { color: var(--text); background: var(--cat-bg); }
    .close:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

    .cart-item {
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
      padding: 12px 0; border-bottom: 1px solid var(--border);
    }
    .cart-item-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
    .cart-item-price { color: var(--price); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .quantity-controls { display: flex; align-items: center; gap: 8px; }
    .quantity-btn {
      width: 44px; height: 44px;
      background: var(--cat-bg); color: var(--accent);
      border: 1px solid var(--border); border-radius: 10px;
      font-size: 20px; font-weight: 700; line-height: 1; cursor: pointer; font-family: inherit;
    }
    .quantity-btn:hover { border-color: var(--accent); }
    .quantity-btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
    .quantity-value { min-width: 28px; text-align: center; font-weight: 700; }

    .cart-total {
      display: flex; justify-content: space-between; align-items: baseline;
      margin-top: 16px; padding-top: 14px; border-top: 2px solid var(--border);
      font-size: 18px; font-weight: 700;
    }
    .checkout-btn {
      width: 100%; margin-top: 16px; min-height: 52px;
      background: var(--accent); color: #fff;
      border: 0; border-radius: 12px;
      font-size: 16px; font-weight: 700; font-family: inherit; cursor: pointer;
    }
    .checkout-btn:hover { background: #264d43; }
    .checkout-btn:disabled { background: var(--muted); cursor: wait; }
    .checkout-btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
    .button-row { display: flex; gap: 10px; flex-wrap: wrap; }
    .button-row .checkout-btn { flex: 1 1 160px; width: auto; }
    .button-success { background: var(--accent-2); }
    .button-success:hover { background: #2f4e62; }
    .button-secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--border); }
    .button-secondary:hover { background: var(--cat-bg); }

    /* ---------- Wieksze ekrany ---------- */
    @media (min-width: 700px) {
      .header { padding: 30px 24px 24px; }
      .menu-container { padding: 24px 20px 12px; }
      .menu-item { gap: 20px; padding: 15px 22px; grid-template-columns: minmax(0, 1fr) auto auto; }
      /* Od tabletu wraca pelny, opisany przycisk — jest miejsce i czyta sie lepiej. */
      .add-button { width: auto; height: auto; min-height: 44px; padding: 11px 18px; font-size: 15px; font-weight: 650; }
      .add-button .add-plus { display: none; }
      .add-button .add-label { display: inline; }
      .category-header { padding: 15px 22px; }
    }

    @media (min-width: 1100px) {
      /* Na duzym ekranie dwie kolumny kart kategorii — bez rozciagania tekstu
         na cala szerokosc monitora i bez powiekszania fontu do rozmiarow plakatu. */
      .menu-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 20px;
        align-items: start;
      }
      .category { break-inside: avoid; }
    }

    @media (prefers-reduced-motion: reduce) {
      * { animation: none !important; transition: none !important; }
    }

    .header-controls { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 12px; }
    .table-badge { margin-top: 0; }
    .language-control { display: flex; gap: 8px; align-items: center; max-width: 100%; font-size: 14px; }
    .language-control select { min-height: 44px; max-width: 100%; padding: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font: inherit; }
    .venue-name, .venue-info, .category-name, .checkout-btn, #notice, #cartNotice { overflow-wrap: anywhere; }
    .category { border-radius: 0; box-shadow: none; border-left: 0; border-right: 0; background: transparent; }
    .menu-item { background: var(--surface); }
    .add-button { border-radius: 8px; }
    .cat-chip { min-height: 44px; }
    .cart-bar-inner > * { min-width: 0; }
    .cart-icon { white-space: normal; overflow-wrap: anywhere; max-width: 55%; border-radius: 8px; }
    .cart-summary { flex: 1; }
    .cart-item { flex-wrap: wrap; }
    .cart-item-info { flex: 1 1 150px; min-width: 0; overflow-wrap: anywhere; }
    .quantity-controls { flex: 0 0 auto; }
    .modal-content h2 { padding-right: 40px; }
    .checkout-btn { padding: 12px; border-radius: 8px; }
    .button-row { display: grid; grid-template-columns: minmax(0, 1fr); }
    .button-row .checkout-btn { width: 100%; margin: 0; }
    .button-success { background: var(--accent-2); }
    .confirmation-note, .bill-hint { color: var(--muted); font-size: 14px; }
    .confirmation h3 { color: var(--accent); font-size: 20px; }
    .summary-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding: 10px 0; }
    .summary-row > :first-child { min-width: 0; overflow-wrap: anywhere; }
    .summary-row > :last-child { white-space: nowrap; }
    .item-code { display: inline-block; margin-right: 7px; color: var(--accent-2); font-size: 12px; font-weight: 750; }
    .bill-total-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--text); font-size: 18px; font-weight: 750; }
    .bill-total-row > :last-child { white-space: nowrap; }
    .bill-status { padding: 10px 12px; border-left: 3px solid var(--accent-2); background: var(--cat-bg); }
    .visit-closed { padding: 18px 0; }
    .visit-closed h3 { color: #7b2929; }
    #notice, #cartNotice { border-left: 3px solid var(--accent-2); padding: 8px 12px; background: var(--surface); }
    button:disabled { opacity: .65; cursor: not-allowed; }
    select:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
    @media (max-width: 380px) {
      .venue-name { font-size: 24px; }
      .menu-item { grid-template-columns: minmax(0, 1fr) 44px; grid-template-areas: "info action" "price action"; gap: 6px 10px; padding: 14px; }
      .item-price { text-align: left; }
      .modal { padding: 8px; }
      .modal-content { padding: 18px 14px; }
    }
    @media (min-width: 700px) {
      .language-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
      .language-choice { min-height: 82px; padding: 14px 18px; }
    }
    @media (min-width: 1100px) {
      .menu-item { grid-template-columns: minmax(0, 1fr) auto 44px; gap: 12px; }
      .add-button { width: 44px; height: 44px; padding: 0; font-size: 22px; }
      .add-button .add-plus { display: inline; }
      .add-button .add-label { display: none; }
    }
    @media print {
      .cat-nav, .cart-bar, .add-button, .modal { display: none !important; }
      body { background: #fff; padding-bottom: 0; }
      .category { box-shadow: none; break-inside: avoid; }
    }

/* Jezyki od prawej do lewej (arabski). Uklad siatki i flex odwraca sie sam przez dir="rtl";
   tu poprawiamy tylko jawne strony, marginesy i obramowania. */
[dir="rtl"] body { font-family: "Noto Naskh Arabic", "Geeza Pro", "Segoe UI", Tahoma, sans-serif; }
[dir="rtl"] .language-choice, [dir="rtl"] .language-gate-error { text-align: right; }
[dir="rtl"] .language-gate-error, [dir="rtl"] .bill-status, [dir="rtl"] #notice, [dir="rtl"] #cartNotice { border-left: 0; border-right: 3px solid var(--accent-2); }
[dir="rtl"] .language-gate-error { border-right-color: #9b3b3b; }
[dir="rtl"] .item-price { text-align: left; }
[dir="rtl"] .close { right: auto; left: 12px; }
[dir="rtl"] .modal-content h2 { padding-right: 0; padding-left: 40px; }
[dir="rtl"] .item-code { margin-right: 0; margin-left: 7px; direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .item-price, [dir="rtl"] .quantity-value, [dir="rtl"] .bill-total-row span:last-child { direction: ltr; unicode-bidi: isolate; }
@media (max-width: 380px) { [dir="rtl"] .item-price { text-align: right; } }

/* Suma i przycisk wysylania zawsze widoczne na dole koszyka (dluga lista przewija sie nad nimi). */
.cart-footer { position: sticky; bottom: -1px; background: var(--surface, #fff); padding: 10px 0 4px; margin-top: 4px; box-shadow: 0 -10px 14px -12px rgba(31, 41, 51, .35); z-index: 2; }
.cart-footer:has(#checkoutButton[hidden]):has(#cartTotal:empty) { padding: 0; box-shadow: none; }

/* Przywolanie kelnera: wyrazny przycisk obok numeru stolika (min. 44 px do dotyku). */
.call-waiter { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--accent, #2e5d4f); background: var(--surface, #fff); color: var(--accent, #2e5d4f); font: inherit; font-weight: 700; cursor: pointer; }
.call-waiter:disabled { opacity: .55; cursor: default; }
.call-waiter:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ---------- Etap 0A: status zamowienia dla goscia ---------- */
.order-status { margin: 12px 0; padding: 12px 14px; background: var(--cat-bg); border-radius: 12px; }
.order-status h4 { margin: 0 0 8px; font-size: 15px; }
/* Telefon: kroki jedna pod druga — dlugie slowa (de, hu, uk) nigdy nie lamia sie w srodku. */
.order-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.order-steps li { display: flex; align-items: center; gap: 10px; min-height: 30px; font-size: 15px; color: var(--muted); }
.order-steps .step-dot { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); }
.order-steps li.done { color: var(--accent); }
.order-steps li.done .step-dot { background: var(--accent); border-color: var(--accent); }
.order-steps li.current { color: var(--text); font-weight: 700; }
.order-steps li.current .step-dot { background: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 0 0 4px rgba(56, 92, 116, .18); }
@media (min-width: 520px) {
  .order-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .order-steps li { flex-direction: column; text-align: center; font-size: 13px; }
}
.status-note { margin: 10px 0 0; font-weight: 650; }
.status-auto { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.item-status { display: inline-block; margin-inline-start: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--cat-bg); color: var(--muted); }
.item-status.s1 { background: #e6eef4; color: var(--accent-2); }
.item-status.s2 { background: #e3f3e8; color: #276749; }
/* Belka statusu przyklejona nad paskiem koszyka (nie zaslania kart dan). */
.order-status-bar {
  position: fixed; z-index: 30; left: 0; right: 0;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
  min-height: 44px; padding: 10px 16px; margin: 0;
  border: 0; border-top: 1px solid var(--border); border-radius: 0;
  background: var(--cat-bg); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 650; text-align: start; cursor: pointer;
}
.order-status-bar[hidden] { display: none; }
.order-status-bar::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-inline-end: 8px; border-radius: 50%; background: var(--accent-2); vertical-align: middle; }
.order-status-bar::after { content: "›"; float: inline-end; color: var(--muted); font-weight: 700; }
.order-status-bar[data-stage="2"]::before { background: #2f855a; }
.order-status-bar[data-stage="3"]::before { background: var(--muted); }
.order-status-bar:focus-visible { outline: 3px solid var(--accent-2); outline-offset: -3px; }
body.has-order-status { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 56px); }
@media print { .order-status-bar { display: none; } }

/* Etap 0A: alergeny */
.item-allergens { margin-top: 4px; font-size: 13px; color: var(--muted); }
.item-allergens .allergens-label { font-weight: 650; color: var(--text); }
.allergen-note { margin: 4px 2px 18px; padding: 10px 12px; border-left: 3px solid var(--accent-2); background: var(--surface); color: var(--text); font-size: 14px; }
[dir="rtl"] .allergen-note { border-left: 0; border-right: 3px solid var(--accent-2); }
