/* =========================================================
   Mezon POS — interfeys uslublari (tashqi CDN'siz, oflayn)
   ========================================================= */
:root {
  --brand: #0f766e;
  --brand-600: #0d9488;
  --brand-50: #f0fdfa;
  --accent: #f59e0b;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warn: #d97706;
  --warn-50: #fffbeb;
  --ok: #059669;
  --ok-50: #ecfdf5;
  --info: #2563eb;
  --side: #0b1f1d;
  --side-text: #a7c4c0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 18px; } h3 { font-size: 15px; }
small, .muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: #fff; font-size: 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand:hover { text-decoration: none; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5f807b; margin: 14px 10px 6px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); margin: 1px 0; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot { padding: 12px 18px; font-size: 11px; color: #5f807b; border-top: 1px solid rgba(255,255,255,.06); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.content { padding: 20px; max-width: 1480px; width: 100%; }
.rate-box { display: flex; align-items: center; gap: 6px; background: var(--brand-50); border: 1px solid #ccfbf1; border-radius: 8px; padding: 3px 6px 3px 10px; font-size: 13px; margin: 0; }
.rate-box input { width: 72px; border: 0; background: transparent; font-weight: 600; text-align: right; padding: 3px; }
.store-box { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 2px 4px 2px 8px; font-size: 13px; margin: 0; background: #fff; }
.store-box select { border: 0; background: transparent; font-weight: 600; padding: 3px 2px; max-width: 180px; }
.store-card.muted { opacity: .6; }
.store-card details summary { cursor: pointer; color: var(--brand); font-size: 13px; margin-top: 4px; }
.bar-cell { position: relative; }
.bar-cell .bar { position: absolute; left: 0; top: 4px; bottom: 4px; background: var(--brand-50); border-radius: 4px; z-index: 0; }
.bar-cell span { position: relative; z-index: 1; }
.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-switch a { padding: 5px 8px; font-size: 12px; color: var(--muted); }
.lang-switch a.on { background: var(--brand); color: #fff; }
.lang-switch a:hover { text-decoration: none; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip small { display: block; font-size: 11px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; }
.icon-btn { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg); text-decoration: none; }
.only-mobile { display: none; }

/* ---------- Components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 14px 16px 0; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #115e59; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warn { background: var(--accent); border-color: var(--accent); color: #111; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }
.btn-lg { padding: 14px 20px; font-size: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

input, select, textarea { font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(13,148,136,.25); border-color: var(--brand-600); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input[type=color] { padding: 2px; height: 38px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; cursor: pointer; margin: 6px 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters > * { width: auto; }
.filters input, .filters select { min-width: 140px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: #f8fafc; position: sticky; top: 0; }
.table tr:hover td { background: #fafcfc; }
.table tfoot td { font-weight: 700; background: #f8fafc; }
.table .num { text-align: right; }
.table-sm th, .table-sm td { padding: 6px 8px; }
.row-muted td { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px !important; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #334155; white-space: nowrap; }
.b-ok { background: var(--ok-50); color: var(--ok); }
.b-warn { background: var(--warn-50); color: var(--warn); }
.b-danger { background: var(--danger-50); color: var(--danger); }
.b-info { background: #eff6ff; color: var(--info); }
.b-brand { background: var(--brand-50); color: var(--brand); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert-success { background: var(--ok-50); border-color: #a7f3d0; color: #065f46; }
.alert-error { background: var(--danger-50); border-color: #fecaca; color: #991b1b; }
.alert-warn { background: var(--warn-50); border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; margin-top: 4px; }
.kpi.accent { border-left: 4px solid var(--brand); }
.up { color: var(--ok); } .down { color: var(--danger); }

.pagination { display: flex; gap: 4px; justify-content: flex-end; padding: 12px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: #fff; }
.pagination .on { background: var(--brand); color: #fff; border-color: var(--brand); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on, .tabs a:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.tab-pane { display: none; } .tab-pane.on { display: block; }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bar-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-chart .bar { width: 100%; max-width: 34px; background: var(--brand-600); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bar-chart .bar .p { position: absolute; bottom: 0; left: 0; right: 0; background: var(--accent); border-radius: 0 0 0 0; opacity: .9; }
.bar-chart .lbl { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; max-width: 100%; }
.hbar { height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.hbar > i { display: block; height: 100%; background: var(--brand-600); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-bg.on { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(135deg, #0b1f1d, #0f766e); color: #d1fae5; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { color: #fff; font-size: 34px; margin-top: 40px; }
.auth-hero ul { padding-left: 18px; line-height: 2; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px; background: #fff; }
.auth-box { width: 100%; max-width: 360px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.pin-pad button { padding: 14px; font-size: 20px; border: 1px solid var(--line); background: #f8fafc; border-radius: 10px; cursor: pointer; }
.pin-pad button:active { background: var(--brand-50); }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots i.f { background: var(--brand); }

/* ---------- POS ---------- */
body.pos-body { overflow: hidden; background: #e9eef2; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 440px); grid-template-rows: 54px minmax(0, 1fr); height: 100vh; }
.pos > * { min-width: 0; }
.pos-top::-webkit-scrollbar { height: 0; }
.pos-top .chip, .pos-top a, .pos-top button.linkish, .pos-top form { flex-shrink: 0; }
.pos-top { overflow-x: auto; overflow-y: hidden; grid-column: 1 / -1; background: var(--side); color: #d1fae5; display: flex; align-items: center; gap: 14px; padding: 0 14px; }
.pos-top .brand { padding: 0; border: 0; font-size: 16px; }
.pos-top .chip { background: rgba(255,255,255,.08); padding: 5px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap; }
.pos-top .chip.ok { background: rgba(16,185,129,.2); color: #6ee7b7; }
.pos-top .chip.bad { background: rgba(239,68,68,.25); color: #fecaca; }
.pos-top .chip.warn { background: rgba(245,158,11,.25); color: #fde68a; border: 0; cursor: pointer; font: inherit; font-size: 13px; }
.pos-top a, .pos-top button.linkish { color: #d1fae5; background: none; border: 0; font: inherit; cursor: pointer; padding: 6px 8px; border-radius: 6px; }
.pos-top a:hover, .pos-top button.linkish:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.pos-left { display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 10px; }
.scan-bar { display: flex; gap: 8px; }
.scan-bar input { font-size: 18px; padding: 12px 14px; border: 2px solid var(--brand-600); }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; flex-shrink: 0; }
.cats button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; font: inherit; font-size: 13px; }
.cats button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tiles { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-content: start; }
.tile { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--c, var(--brand)); border-radius: 10px; padding: 10px; cursor: pointer; text-align: left; font: inherit; display: flex; flex-direction: column; gap: 4px; min-height: 92px; }
.tile:hover { border-color: var(--brand-600); box-shadow: var(--shadow); }
.tile .n { font-weight: 600; font-size: 13px; line-height: 1.25; flex: 1; }
.tile .pr { font-weight: 700; color: var(--brand); }
.tile .st { font-size: 11px; color: var(--muted); }
.tile .st.low { color: var(--danger); }
.tile .tags { display: flex; gap: 4px; }
.tile .tags span { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: #f1f5f9; }
.pos-right { background: #fff; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.cust-bar { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.cust-bar .who { flex: 1; min-width: 0; font-size: 13px; }
.cust-bar .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart { flex: 1; overflow-y: auto; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 9px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.cart-line.sel { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand); }
.cart-line .nm { font-weight: 600; font-size: 13px; }
.cart-line .sub { font-size: 12px; color: var(--muted); }
.cart-line .tt { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.cart-line .ctl { grid-column: 1 / -1; display: none; gap: 6px; align-items: center; }
.cart-line.sel .ctl { display: flex; }
.cart-line .ctl input { width: 90px; padding: 5px 8px; text-align: right; }
.cart-line .ctl button { padding: 5px 10px; }
.cart-line .mk { font-size: 10px; color: var(--ok); }
.cart-empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.totals { border-top: 1px solid var(--line); padding: 10px 14px; font-size: 14px; }
.totals .r { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 26px; font-weight: 800; color: var(--text); padding-top: 6px; }
.pos-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 0 12px 8px; }
.pos-actions .btn { padding: 7px 3px; font-size: 11.5px; flex-direction: column; gap: 1px; white-space: normal; line-height: 1.2; text-align: center; min-width: 0; overflow: hidden; }
.pos-actions kbd { font-size: 10px; color: var(--muted); font-family: inherit; }
.pay-btn { margin: 0 12px 12px; padding: 16px; font-size: 20px; font-weight: 700; border-radius: 12px; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-methods .pm { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.pay-methods .pm label { margin: 0 0 4px; }
.pay-methods .pm input { font-size: 16px; text-align: right; font-weight: 600; }
.pay-methods .pm.cash { grid-column: 1 / -1; background: var(--ok-50); border-color: #a7f3d0; }
.pay-methods .pm.cash input { font-size: 24px; }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.quick-cash button { flex: 1; min-width: 70px; }
.pay-summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 12px 0; text-align: center; }
.pay-summary div { background: #f8fafc; border-radius: 10px; padding: 10px; }
.pay-summary b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.pay-summary .change b { color: var(--ok); }
.pay-summary .debt b { color: var(--danger); }
.toast-stack { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; pointer-events: none; max-width: 90vw; }
.toast { background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 90vw; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
.list-pick { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.list-pick > div { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.list-pick > div:hover { background: var(--brand-50); }
.shift-lock { position: absolute; inset: 0; background: rgba(233,238,242,.94); display: flex; align-items: center; justify-content: center; z-index: 30; }

/* ---------- Doc editor (kirim, ko'chirish) ---------- */
.ac-wrap { position: relative; }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 50; max-height: 300px; overflow-y: auto; }
.ac-list div { padding: 8px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.ac-list div:hover, .ac-list div.on { background: var(--brand-50); }
.doc-table input { padding: 6px 8px; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .no-print, .btn, .filters, .pagination { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: 1fr; }
  .pos { grid-template-columns: minmax(0, 1fr) 360px; }
  .pos-top .brand span, .pos-top kbd { display: none; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .only-mobile { display: inline-block; }
  .hide-mobile { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .rate-box span { display: none; }
  .store-box select { max-width: 110px; }
  .pos { grid-template-columns: 1fr; grid-template-rows: 54px 45vh minmax(0, 1fr); }
  body.pos-body { overflow: auto; overflow-x: hidden; }

}
