:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --sidebar: #101a2b;
  --sidebar-hover: #1b273c;
  --sidebar-ink: #aab4c5;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #eef1f5;
  --brand: #0f6b4c;
  --brand-dark: #0b5339;
  --brand-soft: #e7f4ee;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn: #b54708;
  --warn-soft: #fdf0e4;
  --info: #175cd3;
  --info-soft: #eaf1fd;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.07);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
/* hidden atributi flex/grid display'dan ustun turishi uchun */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
.ico { flex: none; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 282px;
  flex: none;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  flex: none;
  display: block;
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.brand-text strong {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.brand-text span {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(150deg, #17936a, var(--brand-dark));
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
}
.side-nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.side-group {
  padding: 12px 12px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #67748c;
  font-weight: 700;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 11px;
  color: var(--sidebar-ink);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
  transition: background 0.12s ease, color 0.12s ease;
}
.side-link:hover { background: var(--sidebar-hover); color: #fff; }
.side-link.active { background: var(--brand); color: #fff; }
.side-link .count {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.8rem;
  font-weight: 700;
}
.side-link.active .count { background: rgba(255, 255, 255, 0.24); }
.side-link .count.alert { background: #e5573f; color: #fff; }
.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title {
  margin: 0;
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.page-sub { margin: 3px 0 0; color: var(--muted); font-size: 0.85rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.content { padding: 22px 26px 44px; max-width: 1360px; width: 100%; }

/* ---------- Cards ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-2);
}
.panel-head h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-head .muted { margin: 2px 0 0; }
.panel-body { padding: 18px; }
.panel-body > :first-child { margin-top: 0; }
.panel-body > :last-child { margin-bottom: 0; }
.muted { color: var(--muted); font-size: 0.88rem; }

/* Panel ichida dropdown (yopiq tursin) */
.panel-fold { margin: 0; }
.panel-fold > .panel-fold-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.panel-fold > .panel-fold-summary::-webkit-details-marker { display: none; }
.panel-fold > .panel-fold-summary:hover { background: var(--surface-2); }
.panel-fold-caret {
  display: inline-flex;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.panel-fold[open] > .panel-fold-summary {
  border-bottom: 1px solid var(--line-2);
}
.panel-fold[open] .panel-fold-caret { transform: rotate(90deg); }

/* ---------- Stats ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(188px, 1fr));
  gap: 13px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.stat > div:last-child { min-width: 0; }
.stat-ico {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--brand-soft);
  color: var(--brand);
}
.stat-ico.warn { background: var(--warn-soft); color: var(--warn); }
.stat-ico.danger { background: var(--danger-soft); color: var(--danger); }
.stat-ico.info { background: var(--info-soft); color: var(--info); }
.stat-ico.neutral { background: var(--surface-2); color: var(--muted); }
.stat .n {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
/* Telefon raqami / summa kabi uzun qiymatlar karta ichida sinmasligi uchun */
.stat .n.long {
  font-size: 0.98rem;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .l { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 13px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.86rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger {
  background: var(--surface);
  border-color: #f1c9c5;
  color: var(--danger);
}
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.sm { padding: 6px 10px; font-size: 0.8rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.86rem;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.tabs .count {
  background: var(--line-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 0.76rem;
  font-weight: 700;
}
.tabs a.active .count { background: var(--brand-soft); color: var(--brand); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
th, td {
  text-align: left;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.right, th.right { text-align: right; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 0.81rem; margin-top: 2px; }
code {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.84em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ---------- Forms ---------- */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
label { display: block; font-size: 0.82rem; color: var(--ink); font-weight: 600; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.qty-input { max-width: 92px; }

/* ---------- Do'kon filtri (dashboard) ---------- */
.store-filter { padding: 4px 0 2px; }
.store-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.store-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 550;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}
.store-check:hover { border-color: var(--brand); background: #fff; }
.store-check.all { background: var(--brand-soft); border-color: #c7e5d7; }
.store-check input { margin: 0; flex: none; }
.store-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  border: 1px solid rgba(0,0,0,.08);
}
.empty-inline { padding: 8px 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 650;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.new { background: var(--warn-soft); color: var(--warn); border-color: #f6ddc2; }
.badge.done, .badge.linked { background: var(--brand-soft); color: var(--brand); border-color: #c7e5d7; }
.badge.open { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #f4cdc9; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: #cfdffb; }

/* ---------- Flash ---------- */
.flash {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 15px;
  border-radius: 10px;
  margin-bottom: 16px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid #c7e5d7;
  font-weight: 550;
  transition: opacity 0.35s ease, transform 0.35s ease, margin 0.35s ease, padding 0.35s ease, max-height 0.35s ease;
}
.flash.err {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f4cdc9;
}
.flash.is-hiding {
  opacity: 0;
  transform: translateY(-6px);
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  max-height: 0;
  overflow: hidden;
  border-width: 0;
  pointer-events: none;
}

/* ---------- Live toast (shikoyat / xabar) ---------- */
.live-toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 28px));
  pointer-events: none;
}
.live-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 12px 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  animation: liveToastIn 0.28s ease;
  cursor: pointer;
}
.live-toast.is-out {
  animation: liveToastOut 0.25s ease forwards;
}
.live-toast-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--warn-soft);
  color: var(--warn);
  flex: none;
}
.live-toast-body { min-width: 0; }
.live-toast-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}
.live-toast-text {
  margin: 3px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  word-break: break-word;
}
.live-toast-meta {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.live-toast-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.live-toast-x:hover { background: var(--surface-2); color: var(--ink); }
@keyframes liveToastIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes liveToastOut {
  to { opacity: 0; transform: translateX(18px); }
}
.side-link .count.pulse {
  animation: countPulse 0.7s ease;
}
@keyframes countPulse {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.25); }
}

/* ---------- Empty state ---------- */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .empty-ico {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  color: var(--muted);
}
.empty b { display: block; color: var(--ink); margin-bottom: 4px; font-size: 0.95rem; }

/* ---------- Complaints (dropdown) ---------- */
.complaint-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 10px;
  scroll-margin-top: 90px;
}
.complaint-card:last-child { margin-bottom: 0; }
.complaint-card:target { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12); }
.complaint-card-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--surface);
}
.complaint-card-head::-webkit-details-marker { display: none; }
.complaint-card-head:hover { background: var(--surface-2); }
.complaint-card[open] .complaint-card-head {
  border-bottom: 1px solid var(--line-2);
  background: var(--surface-2);
}
.complaint-card-head .caret { color: var(--muted); transition: transform 0.15s ease; }
.complaint-card[open] .complaint-card-head .caret { transform: rotate(90deg); }
.complaint-title { display: flex; flex-direction: column; gap: 2px; margin-right: auto; min-width: 0; }
.complaint-title b { font-size: 0.9rem; }
.complaint-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 15px;
  border-top: 1px solid var(--line-2);
  background: var(--surface-2);
}
.complaint-card th, .complaint-card td { padding-left: 15px; padding-right: 15px; }

/* ---------- Receipt ---------- */
.receipt-print {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 20px;
  align-items: start;
}
.kv { display: grid; gap: 9px; margin-bottom: 16px; }
.kv div { display: flex; align-items: center; gap: 8px; font-size: 0.89rem; }
.kv span.k { color: var(--muted); min-width: 74px; }
.qr-box {
  text-align: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}
.qr-box img {
  width: 210px;
  height: 210px;
  object-fit: contain;
  background: #fff;
  padding: 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
}
.qr-box code { display: block; margin-top: 10px; white-space: normal; word-break: break-all; }
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 18px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  font-weight: 700;
}

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(800px 400px at 50% 0%, #e8f1ec 0%, transparent 60%), var(--bg);
}
.login-box {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 26px;
}
.login-box .brand-mark { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 14px; }
.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  margin-bottom: 14px;
  display: block;
  box-shadow: var(--shadow-sm);
}
.login-box h1 { margin: 0 0 4px; font-size: 1.2rem; }
.login-box .btn { width: 100%; }

ol.steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 0.89rem; }
ol.steps li { margin-bottom: 7px; }
ol.steps li:last-child { margin-bottom: 0; }

/* ---------- Confirm modal ---------- */
body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.48);
  backdrop-filter: blur(2px);
}
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.22);
  padding: 22px;
  text-align: center;
  animation: modal-in 0.16s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal-ico {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f4cdc9;
}
.modal h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
}
.modal p {
  margin: 0 0 18px;
  line-height: 1.45;
}
.modal-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-actions .btn { min-width: 120px; }
#confirm-ok .confirm-ok-ico {
  display: inline-flex;
  vertical-align: middle;
  margin-right: 2px;
}
#confirm-ok .confirm-ok-ico[hidden] { display: none; }

.modal-ico.brand {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #c7e5d7;
}
.modal.form-modal {
  max-width: 460px;
  text-align: left;
}
.modal.form-modal .modal-ico { margin: 0 0 12px; }
.modal.form-modal h3 { margin-bottom: 4px; }
.modal.form-modal p { margin-bottom: 16px; }
.modal.form-modal .modal-actions { justify-content: flex-end; margin-top: 18px; }

/* ---------- Sotuv (POS) ---------- */
.pos {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 16px;
  align-items: start;
}
.pos .panel { margin-bottom: 0; }
.pos-cart { position: sticky; top: 84px; }
input.pos-search { width: 220px; padding: 8px 12px; }

.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
  padding: 16px;
}
.pos-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
  text-align: left;
  font: inherit;
  min-height: 82px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}
.pos-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.pos-item:active { transform: scale(0.98); }
.pos-item.active { border-color: var(--brand); background: var(--brand-soft); }
.pos-item .nm { font-weight: 650; font-size: 0.88rem; line-height: 1.3; color: var(--ink); }
.pos-item .pr { margin-top: auto; font-weight: 700; font-size: 0.85rem; color: var(--brand); }
.pos-item .qty-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.pos-empty { padding: 26px 20px; }

.cart-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  max-height: 44vh;
  overflow-y: auto;
}
.cart-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
}
.cart-row .info { flex: 1; min-width: 0; }
.cart-row .nm {
  font-weight: 600;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-row .sub { color: var(--muted); font-size: 0.76rem; margin-top: 2px; }
.qty-ctl { display: flex; align-items: center; gap: 3px; flex: none; }
.qty-ctl button {
  width: 25px;
  height: 25px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.qty-ctl button:hover { background: var(--surface-2); border-color: var(--brand); }
.qty-ctl .q { min-width: 20px; text-align: center; font-weight: 700; font-size: 0.84rem; }
.cart-row .rm {
  flex: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.cart-row .rm:hover { background: var(--danger-soft); color: var(--danger); }

.cart-empty { padding: 30px 18px; text-align: center; color: var(--muted); }
.cart-empty .empty-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
}
.cart-empty b { display: block; color: var(--ink); margin-bottom: 3px; font-size: 0.93rem; }

.cart-foot {
  display: grid;
  gap: 9px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.cart-total { display: flex; align-items: center; justify-content: space-between; }
.cart-total b { font-size: 1.15rem; letter-spacing: -0.02em; }
.cart-foot .btn { width: 100%; }

/* ---------- Chat ---------- */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: 62vh;
  scroll-margin-top: 90px;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, #f7f9fc, #fff);
  border-bottom: 1px solid var(--line-2);
}
.chat-empty { text-align: center; margin: auto; padding: 24px; }
.chat-bubble {
  max-width: min(78%, 520px);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
  align-self: flex-start;
}
.chat-bubble.admin {
  align-self: flex-end;
  background: var(--brand-soft);
  border-color: #c7e5d7;
}
.chat-bubble .meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 650;
}
.chat-bubble .txt {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
  font-size: 0.92rem;
}
.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  align-items: end;
}
.chat-compose textarea {
  resize: none;
  min-height: 44px;
  max-height: 120px;
}
.chat-hint { margin: 0; padding: 0 14px 12px; font-size: 0.8rem; }

/* Alohida chat sahifasi balandroq bo'ladi */
.chat.chat-page {
  min-height: 60vh;
  max-height: calc(100vh - 250px);
}

/* Javob kutayotgan chat qatori */
tr.row-unread { background: var(--warn-soft); }
tr.row-unread:hover { background: var(--warn-soft); }

/* ---------- Telegram-style chat list ---------- */
.tg-chats {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  width: 100%;
  max-width: none;
}
.tg-chats-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-2);
}
.tg-chats-title {
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tg-chats-head .muted { margin: 4px 0 0; }
.tg-chat-list {
  display: flex;
  flex-direction: column;
  max-height: min(72vh, 680px);
  overflow: auto;
}
.tg-chat-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}
.tg-chat-empty .empty-ico {
  margin: 0 auto 12px;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
}
.tg-chat-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line-2);
  transition: background 0.15s ease;
}
.tg-chat-item:last-child { border-bottom: 0; }
.tg-chat-item:hover { background: var(--surface-2); }
.tg-chat-item.is-unread { background: rgba(15, 107, 76, 0.04); }
.tg-chat-item.is-unread:hover { background: rgba(15, 107, 76, 0.07); }
.tg-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1a8f66, #0f6b4c);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.05rem;
  flex: none;
}
.tg-chat-main { min-width: 0; }
.tg-chat-top,
.tg-chat-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tg-chat-name {
  font-weight: 650;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-chat-item.is-unread .tg-chat-name { font-weight: 750; }
.tg-chat-time {
  flex: none;
  font-size: 0.75rem;
  color: var(--muted);
}
.tg-chat-item.is-unread .tg-chat-time { color: var(--brand); font-weight: 600; }
.tg-chat-bottom { margin-top: 3px; }
.tg-chat-preview {
  font-size: 0.86rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.tg-chat-item.is-unread .tg-chat-preview { color: var(--ink); font-weight: 550; }
.tg-unread {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}
.btn.primary .btn-count { background: rgba(255, 255, 255, 0.28); }

/* ---------- Dashboard KPIs ---------- */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.dash-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
a.dash-stat:hover {
  border-color: #c7e5d7;
  box-shadow: var(--shadow);
  color: inherit;
}
.dash-stat.is-alert {
  border-color: #f6ddc2;
  background: linear-gradient(180deg, #fffaf5 0%, #fff 70%);
}
.dash-stat-ico {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--warn-soft);
  color: var(--warn);
}
.dash-stat-ico.tone-ok {
  background: var(--brand-soft);
  color: var(--brand);
}
.dash-stat-ico.tone-info {
  background: var(--info-soft);
  color: var(--info);
}
.dash-stat-ico.tone-muted {
  background: var(--surface-2);
  color: var(--muted);
}
.dash-stat-n {
  font-size: 1.75rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.dash-stat-l {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 550;
}

@media (max-width: 900px) {
  .dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .dash-stats { grid-template-columns: 1fr; }
}

.dash-shops {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.dash-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 550;
  box-shadow: var(--shadow-sm);
}
.dash-chip:hover { border-color: var(--brand); color: var(--brand-dark); }
.dash-chip.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.dash-chip.is-on:hover { color: #fff; background: var(--brand-dark); }

.dash-feed { margin-bottom: 16px; }
.dash-feed-list { display: flex; flex-direction: column; }
.dash-feed-item {
  display: grid;
  grid-template-columns: 44px 1fr 28px;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line-2);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
.dash-feed-item:first-child { border-top: 0; }
.dash-feed-item:hover { background: var(--surface-2); }
.dash-feed-ava {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--warn-soft);
  color: var(--warn);
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 1rem;
}
.dash-feed-body { min-width: 0; }
.dash-feed-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.dash-feed-top strong {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-feed-top span { flex: none; font-size: 0.78rem; color: var(--muted); }
.dash-feed-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
.dash-feed-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.dash-feed-go { color: var(--muted); display: grid; place-items: center; }

.dash-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.dash-bottom > .panel { margin-bottom: 0; min-width: 0; }

.dash-bars { display: flex; flex-direction: column; gap: 12px; }
.dash-bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 0.88rem;
}
.dash-bar-label b { color: var(--warn); font-variant-numeric: tabular-nums; }
.dash-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  overflow: hidden;
}
.dash-bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e8a35a, var(--warn));
  min-width: 4px;
}

.dash-prod-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-prod-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
}
.dash-prod-name {
  font-size: 0.88rem;
  font-weight: 550;
  line-height: 1.35;
  word-break: break-word;
}

@media (max-width: 900px) {
  .dash-bottom { grid-template-columns: 1fr; }
}

/* ---------- Settings: 2 cards side by side ---------- */
.content-settings {
  max-width: none;
  padding-left: 22px;
  padding-right: 22px;
}
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}
.settings-grid > .panel {
  margin-bottom: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-grid .panel-head {
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
}
.settings-grid .panel-head h2 {
  font-size: 0.95rem;
  min-width: 0;
}
.settings-panel-body {
  padding: 16px;
  min-width: 0;
}
.settings-lead {
  margin: 0 0 14px;
  font-size: 0.88rem;
  line-height: 1.45;
}
.settings-flash {
  margin-bottom: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}
.settings-bot-name {
  word-break: break-all;
}
.settings-form label,
.settings-webhook-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--ink);
}
.settings-form label:not(:first-of-type),
.settings-webhook-label {
  margin-top: 12px;
}
.settings-form--tight {
  margin-top: 10px;
}
.settings-mono,
.settings-webhook-field {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.45;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.settings-webhook-field {
  resize: none;
  background: var(--surface-2);
  color: var(--muted);
  margin: 0;
}
.settings-interval {
  width: 100%;
  max-width: 140px;
}
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.settings-actions .btn {
  width: 100%;
  justify-content: center;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  padding: 10px 12px;
}
.settings-actions--row .btn {
  width: auto;
  min-width: 120px;
}
.settings-shops-meta {
  margin: 14px 0 8px;
  font-size: 0.85rem;
}
.settings-shops {
  max-height: 200px;
  overflow: auto;
  margin: 0 -4px;
}
.settings-shops table {
  font-size: 0.85rem;
}
.settings-shops .cell-main {
  word-break: break-word;
  padding-right: 8px;
}
.settings-shop-badge {
  width: 1%;
  white-space: nowrap;
  vertical-align: top;
}

@media (max-width: 1100px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .pos { grid-template-columns: 1fr; }
  .pos-cart { position: static; }
  input.pos-search { width: 100%; }
  .chat-compose { grid-template-columns: 1fr; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-right: 8px;
  }
  .sidebar-brand { border-bottom: none; padding: 12px 14px; white-space: nowrap; }
  .side-nav { display: flex; gap: 6px; padding: 8px; overflow-x: auto; flex: 1; }
  .side-group { display: none; }
  .side-link { margin-bottom: 0; white-space: nowrap; }
  .sidebar-foot { border-top: none; padding: 8px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 16px 14px 36px; }
  .receipt-print { grid-template-columns: 1fr; }
  .chip { display: none; }
}

/* ---------- Ommaviy xabar (mijozlar) ---------- */
.broadcast-panel {
  width: 100%;
  box-sizing: border-box;
}
.broadcast-form {
  width: 100%;
  max-width: none;
}
.broadcast-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--ink);
}
.broadcast-form label:not(:first-of-type) {
  margin-top: 14px;
}
.broadcast-form textarea,
.broadcast-form input[type="text"],
.broadcast-form input[type="url"],
.broadcast-form input[type="file"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.broadcast-form textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}
.broadcast-hint {
  margin: 6px 0 0;
  font-size: 0.8rem;
}
.broadcast-link-row {
  margin-top: 14px;
  margin-bottom: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.broadcast-form input[type="file"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--surface-2);
}
.broadcast-actions {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line-2);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
