/* Amir TIR Park — Operatsion panel dizayn tizimi */

:root {
  /* Fon va sirt - kontrast oshirilgan (quyosh nurida va qorong'ida ham o'qish oson bo'lishi uchun) */
  --bg: #0a0d12;
  --surface: #171e28;
  --surface-raised: #242e3d;
  --border: #3d4a5e;

  /* Matn - kontrast oshirilgan */
  --text: #f7f9fb;
  --text-muted: #aab3c5;
  --text-dim: #707a8f;

  /* Amal ranglari - kontrast/yorqinlik biroz oshirilgan */
  --accent: #34e6cd;
  --accent-dim: #1f9c8c;
  --danger: #ff5252;
  --warning: #ffb020;
  --success: #2fdb76;

  /* Tipografiya */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-data: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* Header: 3 ta FIKS ustun (chap: brend, markaz: soat, o'ng: rol) - ekran o'lchovi yoki
   qo'shimcha tugmalar bu 3 ustunning joyini hech qachon o'zgartirmaydi (5-band). */
.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  column-gap: 8px;
  row-gap: 6px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header .brand { font-size: clamp(15px, 1.2vw + 12px, 19px); font-weight: 700; justify-self: start; min-width: 0; }

/* Markaziy ustun: soat + (Bildirishnoma + Harajat) tugmalari pastda */
.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  justify-self: center;
}

/* Header soat (sana + vaqt) */
.header-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}
.header-clock .clock-date { font-size: 11px; color: var(--text-muted); font-family: var(--font-data); }
.header-clock .clock-time { font-size: 19px; font-weight: 700; color: var(--text); font-family: var(--font-data); letter-spacing: 0.5px; }

/* Soat ostidagi harakat tugmalari qatori (Bildirishnoma + Harajat) */
.header-action-row {
  display: flex;
  align-items: center;
  gap: 6px;
  /* Tugmalar ko'payganda (masalan Restoran panelida) tor ekranda chetga chiqib ketmasdan,
     keyingi qatorga tushadi. */
  flex-wrap: wrap;
  justify-content: center;
}
.header-expense-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 12px;
  min-height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.header-expense-btn:hover { border-color: var(--accent-dim); }

/* Restoran sarlavhasining yuqori qatori: [Harajat] [soat] [Oshpaz]. Uch uya QAT'IY kenglikda
   (chap/o'ng tugmalar bir xil, soat esa doim aynan o'rtada) - matn uzunligi yoki ekran kengligi
   tugmalarning joyini o'zgartirmaydi. Tor ekranda uyalar birdek ixchamlashadi. */
.header-top-row {
  display: grid;
  grid-template-columns: 66px auto 66px;
  align-items: center;
  justify-content: center;
  column-gap: 6px;
}
.header-top-row .header-flank-btn {
  width: 66px;
  min-width: 0;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
@media (max-width: 380px) {
  .header-top-row { grid-template-columns: 58px auto 58px; column-gap: 4px; }
  .header-top-row .header-flank-btn { width: 58px; font-size: 10.5px; padding: 0 2px; }
}
@media (max-width: 350px) {
  .header-top-row { grid-template-columns: 52px auto 52px; }
  .header-top-row .header-flank-btn { width: 52px; font-size: 10px; }
  .header-top-row .header-clock .clock-time { font-size: 16px; }
  .header-top-row .header-clock .clock-date { font-size: 10px; }
  .app-header { padding-left: 10px; padding-right: 10px; column-gap: 6px; }
}

/* Ikonkali, matnsiz header tugmasi (masalan Analitika) - Admin panelidagi Bildirishnoma
   tugmasi bilan bir xil o'lcham/ko'rinishda, boshqa panellarda ham qayta ishlatiladi. */
.header-icon-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.header-icon-btn:hover { border-color: var(--accent-dim); }
.header-icon-btn svg { width: 20px; height: 20px; }

/* O'ng ustun: rol/ism yuqorida, Chiqish tugmasi pastda */
.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  justify-self: end;
}

/* Rol nomi ismning ustida (yonida emas) */
.user-id-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
  gap: 1px;
}
.user-id-block .role-pill { margin-bottom: 1px; }
.user-id-block #userName, .user-id-block span[id$="userName"] { font-size: 12px; color: var(--text-muted); }
.app-header .brand .sub { color: var(--text-muted); font-weight: 400; font-size: 13px; display: block; }

.user-badge {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.user-badge .role-pill {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--accent);
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
}
.logout-btn:hover { color: var(--text); border-color: var(--text-dim); }

@media (max-width: 480px) {
  .header-expense-btn { font-size: 11px; padding: 4px 8px; }
  .logout-btn { font-size: 11px; padding: 4px 8px; min-height: 30px; }
}

main {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Status panellari */
.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.status-card .value {
  font-family: var(--font-data);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}
.status-card .label { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.status-card.free .value { color: var(--success); }
.status-card.busy .value { color: var(--text); }
.status-card.debt .value { color: var(--warning); }

/* Tugmalar */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  min-height: 48px;
  border-radius: var(--radius);
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #072623; }
.btn-primary:hover { background: #4ee0cc; }
.btn-secondary { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-dim); }
.btn-danger { background: var(--danger); color: #fff; }

/* Taom retsepti bor/yo'q holati - "Retseptlar" ro'yxatida (ikonka + rangli yozuv bilan
   ko'zga tashlanadigan qilib, o'z joyida - ON/OFF tumbler bilan slot nomi orasida) */
.recipe-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 999px;
}
.recipe-status.has-recipe { color: var(--success); background: rgba(52, 230, 205, 0.12); }
.recipe-status.no-recipe { color: var(--warning); background: rgba(255, 176, 32, 0.12); }

/* Oddiy ON/OFF tumbler (masalan: taomning menyuda mavjudligi) */
.avail-toggle {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.avail-toggle input { opacity: 0; width: 0; height: 0; }
.avail-toggle .avail-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s;
}
.avail-toggle .avail-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.avail-toggle input:checked + .avail-slider { background: var(--success); }
.avail-toggle input:checked + .avail-slider::before { transform: translateX(20px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tayyor taom nomini 20 soniya bosib turish orqali o'chirishga ruxsat berish -
   bosib turilgan davomida pill sekin-asta "xavf" rangiga o'tadi (progress signali),
   20 soniya to'lgach to'liq qizarib, pulsatsiya bilan yakuniy ogohlantirish beradi. */
.dish-hold-charging {
  transition: background 20s linear, border-color 20s linear, box-shadow 20s linear, color 20s linear;
}
.dish-hold-charging.dish-hold-charging-go {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 82, 82, 0.35);
}
.dish-hold-armed {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
  animation: dishHoldPulse 0.5s ease-in-out infinite alternate;
}
@keyframes dishHoldPulse {
  from { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.55); }
  to { box-shadow: 0 0 0 7px rgba(255, 82, 82, 0); }
}

/* Analitika oynasidagi taqsimot chiziqlari (davlat/transport turi bo'yicha foiz ko'rsatkichi) */
.stat-bar-row { margin-bottom: 12px; }
.stat-bar-row.stat-bar-clickable {
  cursor: pointer;
  padding: 6px;
  margin: -6px -6px 6px -6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.stat-bar-row.stat-bar-clickable:active { background: var(--surface-raised); }
.stat-bar-row .stat-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 5px;
  gap: 8px;
}
.stat-bar-row .stat-bar-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-bar-row .stat-bar-count { color: var(--text-muted); font-family: var(--font-data); flex-shrink: 0; }
.stat-bar-row .stat-bar-track { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.stat-bar-row .stat-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* Forma elementlari */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-data);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
}
.field input::placeholder { color: var(--text-dim); font-family: var(--font-ui); }

/* prompt() o'rnini bosuvchi kiritish oynasidagi maydon */
.prompt-modal-input {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-data);
  box-sizing: border-box;
}
.prompt-modal-input:focus { outline: none; border-color: var(--accent); }

/* Standart <select>ni almashtiruvchi, saytning o'z uslubidagi "tanlash" tugmasi va
   pastdan chiquvchi ro'yxati (brauzerning tabiiy dropdown oynasi o'rniga). */
.custom-select-wrap { display: block; position: relative; }
.custom-select-native { display: none !important; }
.custom-select-trigger {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-data);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  min-height: unset;
}
.custom-select-trigger:active { border-color: var(--accent-dim); }
.custom-select-trigger.custom-select-disabled { opacity: 0.5; cursor: not-allowed; }
.custom-select-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.custom-select-trigger-caret { color: var(--text-dim); font-size: 11px; flex-shrink: 0; }

.custom-select-sheet-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  padding-right: 30px;
}
.custom-select-sheet-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 55vh;
  overflow-y: auto;
}
.custom-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-data);
  text-align: left;
  cursor: pointer;
  min-height: unset;
}
.custom-select-option.selected { border-color: var(--accent); color: var(--accent); }
.custom-select-option:disabled { opacity: 0.4; cursor: not-allowed; }
.custom-select-check { color: var(--accent); font-weight: 700; flex-shrink: 0; margin-left: 10px; }
/* Ro'yxat ostidagi "+ ... yaratish" tugmasi (data-add-label) - aylantiriladigan ro'yxatdan tashqarida, doim ko'rinadi */
.custom-select-sheet-footer { margin-top: 8px; }
.custom-select-option.custom-select-add {
  justify-content: center;
  border-style: dashed;
  border-color: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
}
.custom-select-option.custom-select-add:active { background: var(--border); }

/* Kartalar */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card h2 { font-size: 15px; margin-bottom: 14px; }

/* Faol transportlar ro'yxati */
.vehicle-list { display: flex; flex-direction: column; gap: 8px; }

.vehicle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
}
.vehicle-row:hover { border-color: var(--accent-dim); }

.vehicle-row .slot-code {
  font-family: var(--font-data);
  font-weight: 700;
  color: var(--accent);
  min-width: 52px;
}
.vehicle-row .plate {
  font-family: var(--font-data);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  /* Uzun mahsulot nomlari endi TUGMANI (masalan qty-pill) chetga surib chiqarib
     yubormaydi - o'rniga, kerak bo'lsa, nom o'zi ikki (yoki undan ko'p) qatorga
     bo'linadi. Tugma esa har doim o'ng chetda, o'z joyida qat'iy turadi. */
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  flex: 0 1 auto;
  min-width: 0;
}
/* Faqat haqiqiy davlat raqamlari (transport) uchun - "plate" nomiga mos, real
   avtomobil raqami ko'rinishidagi ramkali qutича. Boshqa barcha nomlar (mahsulot,
   xodim, taom va h.k.) endi ramkasiz, oddiy qalin matn sifatida ko'rinadi. */
.vehicle-row .plate.plate-vehicle {
  letter-spacing: 1.5px;
  background: var(--surface-raised);
  border: 1.5px solid var(--border);
  border-radius: 5px;
  padding: 3px 10px;
  /* DAVLAT RAQAMI HECH QACHON ikkinchi qatorga o'tmaydi va siqilib qolmaydi: yuqoridagi
     umumiy ".plate" qoidasi (white-space: normal; flex-shrink: 1) mahsulot/xodim nomlari
     uchun; haqiqiy raqamda esa ular bekor qilinadi. Joy yetmasa, raqamning O'ZI emas,
     uning yonidagi elementlar (davomiylik, summa) keyingi qatorga tushadi. */
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  flex: 0 0 auto;
  max-width: 100%;
  box-sizing: border-box;
}
/* Raqam bor qatorda joy yetmasa - qator ichidagi elementlar keyingi qatorga tushadi
   (gorizontal siljish/chetga chiqib ketish bo'lmasligi uchun). */
.vehicle-row:has(.plate-vehicle) {
  flex-wrap: wrap;
  column-gap: 8px;
  row-gap: 4px;
}
/* Faol/qarzdor transport kartalarining yuqori qatori: [slot + pin] [raqam] [davomiylik + summa].
   Joy yetmasa, o'ng ustun keyingi qatorga tushadi va o'ng chetda qoladi. */
.vehicle-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 8px;
  width: 100%;
}
.vehicle-row-top > :last-child { margin-left: auto; }
.vehicle-row-top .duration { white-space: nowrap; }
.vehicle-row .duration { color: var(--text-muted); font-size: 13px; flex-shrink: 0; }
.vehicle-row .debt-flag {
  background: rgba(255, 176, 32, 0.18);
  color: var(--warning);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
/* − / + , ON|OFF, HA|YO'Q kabi barcha "tugma guruhlari" - yonidagi yozuv
   qanchalik uzun/kengroq bo'lishidan qat'iy nazar, hech qachon siqilib yoki
   chetga surilib qolmasligi uchun. */
.vehicle-row .qty-pill,
.vehicle-row .qty-badge,
.vehicle-row .amount,
.vehicle-row .slot-code,
.vehicle-row .avail-toggle,
.vehicle-row .recipe-status,
.vehicle-row .row-actions {
  flex-shrink: 0;
}

/* Ixcham amal tugmalari (tahrirlash/o'chirish va sh.k.) - matnsiz, faqat ikonka */
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-height: unset;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn-lg svg { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(0.92); }
.icon-btn-edit:hover { border-color: var(--accent-dim); color: var(--text); }
.icon-btn-danger { background: rgba(255, 82, 82, 0.1); border-color: rgba(255, 82, 82, 0.4); color: var(--danger); }
.icon-btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* "Eslatma" (📌) tugmasi - Admin har qanday transport yozuviga qisqa eslatma
   biriktirishi mumkin. Eslatma yo'q bo'lsa xira (faded), bo'lsa - to'liq rangli va
   sariq halqa bilan ajralib turadi. Bosib turilsa (uzoq bosish) "ko'chirish rejimi"
   yoqiladi - shu payt pin biroz kattalashib, tebranib turadi (vizual signal). */
.pin-note-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-height: unset;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  font-size: 14px;
  opacity: 0.35;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.05s ease, border-color 0.15s ease;
  touch-action: manipulation;
}
.pin-note-btn:active { transform: scale(0.9); }
.pin-note-btn.has-note { opacity: 1; border-color: #ffd84d; background: rgba(255, 216, 77, 0.12); }
.pin-note-btn.pin-move-active { animation: pinMovePulse 0.6s ease-in-out infinite; border-color: var(--accent); }
@keyframes pinMovePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.pin-note-line {
  width: 100%;
  font-size: 11px;
  color: #3a2e00;
  background: #ffd84d;
  border-radius: 6px;
  padding: 4px 8px;
  margin-top: 4px;
  word-break: break-word;
}

/* Oddiy miqdor belgisi (faqat ma'lumot uchun, bosilmaydi, +/- belgisiz) -
   masalan sotuv ro'yxatida qoldiq miqdorini ko'rsatish uchun. */
.qty-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* "- miqdor +" ko'rinishidagi belgi - dumaloq qizil/yashil halqalar orasida, tagiga
   chiziqcha tortilgan miqdor. Ramkasiz. Miqdor (qty-value) bosilganda qo'lda kiritish
   oynasi ochiladi (masalliq/tovar tanlanadi va olinadigan miqdor to'g'ridan-to'g'ri
   kiritiladi) - Ombordan masalliq/tovar olish ro'yxatlarida ishlatiladi. */
.qty-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.qty-pill .qty-sign {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.qty-pill .qty-sign.qty-sign-minus { border: 1.5px solid var(--danger); color: var(--danger); }
.qty-pill .qty-sign.qty-sign-plus { border: 1.5px solid var(--success); color: var(--success); }
.qty-pill .qty-value {
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px dashed var(--border);
  padding-bottom: 2px;
  white-space: nowrap;
  cursor: pointer;
}
.qty-pill .qty-value:hover { color: var(--accent); border-bottom-color: var(--accent-dim); }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 10px;
  font-size: 14px;
}

/* Kichik ekranlarda jadvallarni gorizontal skroll qilish */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Tezkor tanlov / toifa kvadrat ramkalari */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.quick-card {
  position: relative;
  aspect-ratio: 1;
  min-height: 44px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 6px;
  cursor: pointer;
  gap: 4px;
  /* Mobil brauzerning o'z "bosib turish" xatti-harakati (matn belgilash pufakchasi,
     kontekst menyu) 10/20 soniyalik maxsus bosib turish funksiyasini "o'g'irlab ketmasligi"
     uchun - aks holda bu native gest tugmani bosishni muddatidan oldin bekor qilib yuboradi. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* 6 nuqtali tutqich - toifa/tugma kartasini surib, o'rnini almashtirish uchun. Kartaning
   yuqori-o'ng burchagida joylashadi, bosilgan zahoti (kutmasdan) surish rejimini yoqadi. */
.reorder-handle {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  grid-template-columns: repeat(2, 3.5px);
  grid-template-rows: repeat(3, 3.5px);
  gap: 2.5px;
  padding: 5px;
  cursor: grab;
  touch-action: none;
  z-index: 2;
}
.reorder-handle span {
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: var(--text-dim);
}
.reorder-handle:active { cursor: grabbing; }
.reorder-handle:active span { background: var(--accent); }

/* Vertikal ro'yxatlardagi (tugma/oynalar) tartibni 6 nuqtali tutqich orqali almashtirish -
   masalan "Bozor ro'yxati", "Tekin tovar berish", "Kirim tarixi" kabi bo'limlar ro'yxati. */
.reorder-section { position: relative; }
.section-reorder-handle {
  position: absolute;
  top: 12px;
  right: 8px;
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 3px;
  padding: 8px;
  cursor: grab;
  touch-action: none;
  z-index: 5;
}
.section-reorder-handle span { width: 4px; height: 4px; border-radius: 50%; background: var(--text-dim); }
.section-reorder-handle:active { cursor: grabbing; }
.section-reorder-handle:active span { background: var(--accent); }
.reorder-section.section-dragging {
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Toifalar to'ri ustidagi "Tahrirlash / O'chirish" boshqaruv tugmalari - bosilgach, 3 soniya
   ichida bosiladigan toifaga nisbatan amal bajaradi (nomini o'zgartirish yoki o'chirish). */
.category-toolbar {
  display: flex;
  gap: 8px;
  margin: 8px 0 4px;
}
.category-edit-btn, .category-delete-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-dim);
  cursor: pointer;
}
.category-edit-btn.armed {
  border-color: var(--accent);
  background: rgba(52, 230, 205, 0.15);
  color: var(--accent);
}
.category-delete-btn.armed {
  border-color: var(--danger);
  background: rgba(255, 82, 82, 0.15);
  color: var(--danger);
}
.quick-card:hover, .quick-card.active { border-color: var(--accent); background: rgba(52, 230, 205, 0.1); }
/* Faol surish paytida: karta barmoq/kursorni kuzatib, boshqa kartalar ustidan o'tadi */
.quick-card.dragging {
  border-color: var(--accent);
  background: var(--surface-raised);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  opacity: 0.92;
  z-index: 50;
  position: relative;
  cursor: grabbing;
}
.quick-card .quick-label { font-size: 11.5px; line-height: 1.2; color: var(--text); }
.quick-card .quick-sub { font-size: 10px; color: var(--text-muted); font-family: var(--font-data); }

/* Kichikroq ko'rinish - masalan "eng ko'p sotilganlar" uchun (Restoran paneli, 5-band: yanada kichikroq shkala) */
.quick-grid.compact { grid-template-columns: repeat(auto-fit, minmax(50px, 1fr)); gap: 5px; }
.quick-grid.compact .quick-card { aspect-ratio: auto; min-height: 34px; padding: 4px 3px; gap: 1px; }

/* Kirim qilish kartasi: har bir mahsulot uchun "− (qoldiq) +" stepper (Restoran paneli, 2-band) */
/* Ombor/Restoran "Kirim qilish" ro'yxatidagi mahsulot qatori. Har bir qator UCH qismdan iborat va
   tugmalar joyi QAT'IY (miqdor/narx/nom matni uzunligiga yoki ekran kengligiga qarab siljimaydi).
   Uchala amal tugmasi qatorning O'NG chetidagi bitta ustunda, bir-birining tagida turadi:
     1) sarlavha : ⠿ tutqich + nom / tan narx                    [✏️ tahrirlash]  - yuqorida
     2) asosiy   : [− miqdor +]  narx                             [⚙ belgilar (sinflash)]  - o'rtada
     3) amallar  : (📦 kirim - ixtiyoriy, chapda)                 [🗑 o'chirish]  - pastda */
.stock-stepper-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  margin-bottom: 8px;
}
.stock-row-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 44px;
  align-items: start;
  column-gap: 8px;
}
.stock-row-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 44px;
  align-items: center;
  column-gap: 10px;
}
.stock-row-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  column-gap: 10px;
}
.stock-row-actions-mid { display: flex; justify-content: flex-start; min-width: 0; }
/* Uchala amal tugmasi (⚙️ ✏️ 🗑) bir xil o'lchamda - shakli ham joyi ham o'zgarmaydi */
.stock-stepper-row .stock-action-btn {
  width: 44px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
}
.stock-stepper-row .stock-action-btn.stock-action-danger { border-color: var(--danger); color: var(--danger); }
.stock-stepper-row .stock-action-btn:active { transform: scale(0.94); }
.stock-stepper-row .stock-bulk-kirim {
  width: auto;
  height: 34px;
  padding: 0 10px;
  font-size: 12px;
  max-width: 100%;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
}
.stock-stepper-row .stock-bulk-kirim:active { transform: scale(0.96); }
.stock-stepper-row .drag-handle {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: grab;
  user-select: none;
  touch-action: none;
  padding: 4px 2px;
}
.stock-stepper-row.row-dragging {
  opacity: 0.85;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  cursor: grabbing;
}
.stock-stepper-row .stock-info { min-width: 0; flex: 1 1 auto; }
.stock-stepper-row .stock-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  /* Uzun mahsulot nomi endi "..." bilan kesilmaydi - kerak bo'lsa bir necha
     qatorga bo'linadi, stepper ("− qty +") esa o'ng tomonda o'z joyida qoladi. */
  white-space: normal;
  overflow-wrap: break-word;
  display: block;
}
.stock-stepper-row .stock-cost { font-size: 11px; color: var(--text-muted); }
/* Sotuv narxi - zumrad rangda, kattaroq shriftda, stepper va tugmalar orasida ko'zga
   yaqqol tashlanadigan joyda ko'rsatiladi. */
.stock-stepper-row .stock-sale-price {
  font-family: var(--font-data);
  font-size: 17px;
  font-weight: 800;
  color: var(--accent);
  min-width: 0;
  text-align: right; /* narx ⚙ tugmasi yonida (o'ng tomonda) turadi, uzun bo'lsa o'z ustunida qatorlanadi */
}
@media (max-width: 400px) {
  .stock-stepper-row .stock-sale-price { font-size: 15px; line-height: 1.15; }
}
.test-data-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--warning);
  background: rgba(255, 176, 32, 0.15);
  border-radius: 999px;
  padding: 2px 7px;
  margin-left: 4px;
  vertical-align: middle;
}
.stock-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.stock-stepper button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.stock-stepper button.stock-minus { color: var(--danger); border-color: var(--danger); }
.stock-stepper button.stock-plus { color: var(--success); border-color: var(--success); }
.stock-stepper button:active { transform: scale(0.92); }
.stock-stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stock-stepper .stock-qty-value {
  min-width: 78px;
  text-align: center;
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px dashed var(--text-dim);
  padding-bottom: 1px;
}
.quick-grid.compact .quick-label { font-size: 10px; }
.quick-grid.compact .quick-sub { font-size: 8.5px; }

/* Xabarlar */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 14px;
}
.alert-error { background: rgba(255, 82, 82, 0.15); color: #ffb3b3; border: 1px solid rgba(255, 82, 82, 0.35); }
.alert-success { background: rgba(47, 219, 118, 0.15); color: #9ff5c0; border: 1px solid rgba(47, 219, 118, 0.35); }

/* Modal (chek/bill ko'rinishi) */
.modal-overlay {
  position: fixed;
  inset: 0;
  /* Ekran klaviaturasi ochilganda uning balandligiga qisqaradi (--kb-inset ni api.js dagi
     "klaviaturaga moslashuvchi oynalar" kodi yangilab turadi). Shu tufayli oyna ekranning
     KLAVIATURADAN YUQORI qismida qoladi va tasdiqlash tugmalari (OK / Saqlash / Ha) klaviatura
     ostida qolib ketmaydi. Klaviatura yo'q paytda qiymat 0 - hech narsa o'zgarmaydi. */
  bottom: var(--kb-inset, 0px);
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-sheet {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 22px 20px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  /* Oyna hech qachon ko'rinadigan maydondan (klaviatura ochiq bo'lsa - qisqargan maydondan)
     baland bo'lmaydi; ichi esa aylantiriladi. (min() qo'llanmasa, yuqoridagi 85vh ishlaydi.) */
  max-height: min(85vh, 100%);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
}
/* Klaviatura ochiq: "min-height: 60vh" kabi minimal balandliklar bekor qilinadi (aks holda oyna
   qisqargan maydondan chiqib, yuqori qismi/yopish tugmasi ekrandan tashqarida qolardi) va
   pastki xavfsiz-zona bo'shlig'i (klaviatura ostida qolgan) kamaytiriladi. */
html.kb-open .modal-sheet {
  min-height: 0 !important;
  padding-bottom: 16px;
}
.modal-close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  border: none;
  background: var(--surface-raised);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close-x:hover { color: var(--text); background: var(--border); }
.bill-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.bill-row.total {
  font-size: 18px;
  font-weight: 700;
  border-bottom: none;
  padding-top: 14px;
}
.bill-row .amount { font-family: var(--font-data); }

/* Slot cheki oynasidagi "ochilgan / hozir / yopilgan" vaqt satri - ko'zga yaqqol tashlanishi uchun */
.receipt-timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 17px;
  font-weight: 700;
  font-family: var(--font-data);
  color: var(--text);
  letter-spacing: 0.2px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.receipt-timeline .rt-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.receipt-timeline .rt-label {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.receipt-timeline .rt-sep { color: var(--text-dim); font-weight: 400; }
.receipt-timeline .rt-live { color: var(--accent); }
.receipt-timeline .rt-closed { color: var(--warning); }

/* Login sahifasi */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 26px;
}
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

@media (max-width: 420px) {
  .status-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .status-card .value { font-size: 22px; }
  .app-header .brand { font-size: 15px; }
  .btn { padding: 12px 16px; font-size: 15px; }
}

/* Planshet (iPad va shunga o'xshash, portret/landshaft) */
@media (min-width: 641px) {
  main { max-width: 760px; padding: 24px; }
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-sheet {
    border-radius: 16px;
    max-height: 88vh;
    max-height: min(88vh, 100%);
  }
  .quick-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .app-header { padding: 16px 24px; }
}

/* Kompyuter / Windows brauzer (kengroq ekranlar) */
@media (min-width: 1000px) {
  main { max-width: 880px; }
  .card { padding: 20px 26px; }
  .login-box { max-width: 420px; }
}

/* Tor ekranlarda (telefon) raqam qutisi ixchamroq bo'ladi - shunda uzunroq raqamlar ham
   bir qatorga sig'adi (raqam qatordan oshib ketmaydi, "nowrap" saqlanadi). */
@media (max-width: 420px) {
  .vehicle-row .plate.plate-vehicle {
    font-size: 14px;
    letter-spacing: 0.5px;
    padding: 3px 7px;
  }
}

/* ===== 📷 Kamera orqali davlat raqamini o'qish ===== */
.scan-row { display: flex; gap: 8px; align-items: stretch; }
.scan-row > input { flex: 1; min-width: 0; }
.scan-btn {
  flex-shrink: 0; width: 52px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1; cursor: pointer;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
}
.scan-btn:active { transform: scale(0.94); }
.scan-note { font-size: 12px; margin-top: 6px; color: var(--text-muted); line-height: 1.45; }
.scan-note.ok { color: var(--success); }
.scan-note.warn { color: var(--warning); }
.scan-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.scan-chip {
  padding: 8px 12px; min-height: 40px; font-size: 13px; cursor: pointer;
  background: var(--surface-raised); border: 1px solid var(--accent-dim); border-radius: var(--radius-sm); color: var(--text);
}
.scan-chip.similar { border-style: dashed; }

.ps-overlay {
  position: fixed; inset: 0; z-index: 400; background: #000; color: #fff;
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top);
}
.ps-topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.ps-title { font-size: 15px; font-weight: 600; }
.ps-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,0.14); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.ps-stage { flex: 1; position: relative; overflow: hidden; background: #111; min-height: 0; }
.ps-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ps-frame {
  position: absolute; left: 50%; top: 42%; width: 80%; height: 20%; transform: translate(-50%, -50%);
  border: 3px solid var(--accent); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45); pointer-events: none;
}
.ps-hint { position: absolute; left: 0; right: 0; bottom: 14px; padding: 0 18px; text-align: center; font-size: 13px; color: #fff; text-shadow: 0 1px 3px #000; line-height: 1.4; }
.ps-status { min-height: 44px; padding: 10px 16px 2px; text-align: center; font-size: 14px; font-weight: 600; line-height: 1.4; }
.ps-status.ps-ok { color: #4ade80; }
.ps-status.ps-warn { color: #fbbf24; }
.ps-status.ps-error { color: #f87171; }
.ps-status.ps-busy { color: #93c5fd; }
.ps-usage { text-align: center; font-size: 11px; color: rgba(255,255,255,0.55); padding-bottom: 6px; }
.ps-actions { display: flex; gap: 8px; padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; justify-content: center; }
.ps-btn { flex: 1 1 120px; min-height: 46px; padding: 0 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); color: #fff; font-size: 14px; cursor: pointer; align-items: center; justify-content: center; }
.ps-btn-main { background: var(--accent); border-color: var(--accent); color: #062b25; font-weight: 700; }

/* Davlat raqami alifbosi izohi (ruxsat etilmagan harf bosilganda / mustasno davlat yoqilganda) */
.plate-script-hint { font-size: 12px; line-height: 1.45; margin-top: 6px; padding: 6px 10px; border-radius: 8px; }
.plate-script-hint.warn { color: var(--warning); background: rgba(251, 191, 36, 0.10); }
.plate-script-hint.info { color: var(--success); background: rgba(74, 222, 128, 0.10); }

