:root {
  /* Havorang + oq palitra */
  --bg: #f2f7fc;
  --surface: #ffffff;
  --surface-2: #f5f9fd;
  --border: #e2ebf4;
  --border-2: #cfe0ef;
  --text: #0f2a3d;
  --muted: #688399;
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-ink: #0c4a6e;
  --primary-2: #e0f2fe;
  --primary-3: #f0f9ff;
  --gold: #7dd3fc;             /* eski nom: hover chegarasi */
  --gold-light: #e0f2fe;
  --gold-dark: #0284c7;        /* eski nom: havolalar rangi */
  --ink: #0c4a6e;
  --serif: Inter, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --green: #059669;
  --green-bg: #d1fae5;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --blue: #0284c7;
  --blue-bg: #e0f2fe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(12, 74, 110, .04), 0 4px 16px rgba(12, 74, 110, .05);
  --shadow-lg: 0 12px 40px rgba(12, 74, 110, .14);
  --sidebar: 252px;
  --tabbar-h: 0px;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: lining-nums;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-family: Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; color: var(--text); }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-size: 15px; margin: 0 0 8px; }
[v-cloak] { display: none; }
::selection { background: var(--primary-2); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--surface); color: var(--text);
  border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  scrollbar-width: thin;
}
.sidebar .brand { padding: 20px 20px 16px; display: flex; align-items: center; }
.sidebar .brand .brand-logo { width: 176px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px 12px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; color: #3d5a70; font-size: 14px; font-weight: 500;
  border-radius: 10px; position: relative; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: var(--primary-3); color: var(--primary-ink); text-decoration: none; }
.sidebar nav a.active { background: var(--primary-2); color: var(--primary-ink); font-weight: 600; }
.sidebar nav .ico { width: 20px; height: 20px; display: inline-flex; color: #7f9bb0; flex-shrink: 0; }
.sidebar nav .ico svg { width: 20px; height: 20px; }
.sidebar nav a:hover .ico, .sidebar nav a.active .ico { color: var(--primary-dark); }
.sidebar nav .sep { height: 1px; background: var(--border); margin: 8px 12px; }
.sidebar .badge { margin-left: auto; background: var(--primary); color: #fff; }
.sidebar .user { padding: 14px 20px 18px; border-top: 1px solid var(--border); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.sidebar .user .av { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-2); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.sidebar .user .nm { flex: 1; min-width: 0; line-height: 1.3; }
.sidebar .user .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user a { color: var(--muted); font-size: 12.5px; }

.content { flex: 1; min-width: 0; }
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; max-width: 1480px; }
.topbar { display: none; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin-right: auto; }
.page-head .back {
  width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 18px; text-decoration: none;
}
.page-head .back:hover { color: var(--primary-dark); border-color: var(--border-2); }

/* Telefon uchun pastki menyu */
.tabbar { display: none; }

@media (max-width: 1100px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .22s ease; box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .backdrop { position: fixed; inset: 0; background: rgba(12, 42, 61, .32); z-index: 40; backdrop-filter: blur(2px); }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px); color: var(--text);
    padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); border-bottom: 1px solid var(--border);
  }
  .topbar .menu-btn { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-3); border: 1px solid var(--border); color: var(--primary-ink); font-size: 18px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
  .topbar .brand-logo { width: 32px; }
  .topbar .t { font-weight: 700; flex: 1; font-size: 17px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .main { padding: 16px 14px 80px; }
  h1 { font-size: 21px; }
}
@media (max-width: 760px) {
  :root { --tabbar-h: calc(62px + env(safe-area-inset-bottom)); }
  .main { padding: 14px 12px calc(var(--tabbar-h) + 24px); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: rgba(255, 255, 255, .96); backdrop-filter: saturate(1.4) blur(10px); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 20px rgba(12, 74, 110, .06);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px; border: 0; background: none; font: inherit;
    color: #7f9bb0; font-size: 11px; font-weight: 600; text-decoration: none; border-radius: 10px; position: relative; cursor: pointer;
  }
  .tabbar .ico { width: 24px; height: 24px; display: inline-flex; }
  .tabbar .ico svg { width: 24px; height: 24px; }
  .tabbar a.active { color: var(--primary-dark); }
  .tabbar a.active .ico { background: var(--primary-2); border-radius: 8px; box-shadow: 0 0 0 4px var(--primary-2); }
  .tabbar .badge { position: absolute; top: 0; right: 18%; background: var(--red); color: #fff; font-size: 10px; padding: 1px 5px; }
  h1 { font-size: 20px; }
}

/* ---------- Cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .row > .card + .card { margin-top: 0; }
.card.p0 { padding: 0; overflow-x: auto; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3 { grid-template-columns: 1fr; }
  .grid.c3 > * { grid-column: auto !important; }
}
@media (max-width: 700px) { .grid.c2, .grid.c3 { grid-template-columns: 1fr; } .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

.stat { padding: 16px 18px; position: relative; overflow: hidden; }
.stat .l { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 22px; font-weight: 800; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
@media (max-width: 700px) { .stat .v { font-size: 16px; } }

a.card.stat {
  text-decoration: none !important;
  color: inherit !important;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
a.card.stat:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(12, 74, 110, .10);
}
a.card.stat:active {
  transform: translateY(0);
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.bold { font-weight: 600; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); border-radius: 10px; padding: 9px 15px; font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none !important; line-height: 1.2;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--primary-3); border-color: var(--border-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--primary-2); outline-offset: 1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, #38bdf8, var(--primary-dark)); border-color: var(--primary-dark); color: #fff; box-shadow: 0 4px 14px rgba(14, 165, 233, .28); }
.btn.primary:hover { background: linear-gradient(135deg, var(--primary), #0369a1); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { background: #047857; }
.btn.red { background: var(--surface); border-color: #fecaca; color: var(--red); }
.btn.red:hover { background: var(--red-bg); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--primary-3); }
.btn.icon { padding: 6px 9px; }

input, select, textarea {
  font: inherit; color: inherit; border: 1px solid var(--border-2); border-radius: 10px; padding: 9px 12px;
  background: var(--surface); width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-2); }
input::placeholder, textarea::placeholder { color: #9fb4c5; }
textarea { min-height: 70px; resize: vertical; }
label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: auto; }

.search-big { position: relative; flex: 1; min-width: 220px; }
.search-big input { padding: 12px 14px 12px 42px; font-size: 15px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.search-big::before {
  content: ""; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; opacity: .7; pointer-events: none;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230284c7' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 13px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500; color: #3d5a70; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--border-2); background: var(--primary-3); }
.chip.active { background: var(--primary-2); border-color: #7dd3fc; color: var(--primary-ink); font-weight: 600; }
.chip .n { opacity: .7; margin-left: 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--primary-ink); border-bottom-color: var(--primary); font-weight: 600; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: #edf2f7; color: #4a6276; }
.badge.purple { background: var(--primary-2); color: var(--primary-ink); }

/* ---------- Tables (telefonda kartochkaga aylanadi) ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; font-weight: 700; color: #5f7b91; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--primary-3); text-transform: uppercase; letter-spacing: .04em; }
table.t td { padding: 12px 14px; border-bottom: 1px solid #edf3f8; vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f5faff; }
table.t tr.dim td { opacity: .55; }
table.t tfoot td { font-weight: 700; background: var(--surface-2); }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }

@media (max-width: 820px) {
  table.rt thead { display: none; }
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt tr { border-bottom: 1px solid var(--border); padding: 12px 14px; }
  table.rt td { border: 0; padding: 3px 0 3px 112px; position: relative; text-align: right; min-height: 24px; }
  table.rt td::before { content: attr(data-l); position: absolute; left: 0; top: 4px; max-width: 108px; color: var(--muted); font-size: 12px; text-align: left; }
  table.rt td[data-l=""], table.rt td:not([data-l]) { padding-left: 0; }
  table.rt td[data-l=""]::before, table.rt td:not([data-l])::before { content: none; }
  table.rt td.main-cell { font-size: 15px; text-align: left; padding-left: 0; }
  table.rt td.num { text-align: right; }
  table.rt tfoot { display: block; }
  table.rt tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 10px 12px; background: var(--surface-2); }
  table.rt tfoot td { display: block; padding: 0 !important; min-height: 0; text-align: left; background: none; }
  table.rt tfoot td:empty { display: none; }
  table.rt tfoot td::before { position: static; margin-right: 6px; }
}
/* Planshet: jadval kataklari ixchamroq */
@media (min-width: 821px) and (max-width: 1280px) {
  table.t th, table.t td { padding: 8px 8px; }
}

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(12, 42, 61, .38); backdrop-filter: blur(3px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: modalIn .18s ease-out; }
@keyframes modalIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.wide { max-width: 960px; }
.modal .mh { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal .mh h2 { margin: 0; flex: 1; }
.modal .mb { padding: 18px; }
.modal .mf { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 18px 18px; }
@media (max-width: 600px) {
  .modal-bg { padding: 0; align-items: stretch; }
  .modal { border-radius: 0; min-height: 100vh; display: flex; flex-direction: column; }
  .modal .mf { position: sticky; bottom: 0; margin-top: auto; border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 16px; bottom: calc(16px + var(--tabbar-h)); z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { background: var(--primary-ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; white-space: pre-line; }
.toast.error { background: #991b1b; }
.toast.ok { background: #065f46; }
.toast .act { margin-left: 10px; color: #bae6fd; cursor: pointer; font-weight: 600; text-decoration: underline; }
@media (max-width: 600px) { .toasts { left: 12px; right: 12px; } }

/* ---------- Autocomplete ---------- */
.ac { position: relative; }
.ac-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; }
.ac-item { padding: 9px 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.ac-item:hover, .ac-item.hl { background: var(--primary-2); }
.ac-item .sub { color: var(--muted); font-size: 12px; }

/* ---------- Items editor ---------- */
.items-ed .it { display: grid; grid-template-columns: minmax(180px, 2.4fr) 110px 80px 90px 130px 130px 34px; gap: 8px; align-items: end; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.items-ed .it .tot { font-weight: 600; text-align: right; padding: 9px 0; white-space: nowrap; }
.items-ed .hdr { font-size: 12px; color: var(--muted); padding-bottom: 0; border: 0; }
.items-ed .sub { font-size: 12px; color: var(--muted); grid-column: 1 / -1; margin-top: -4px; }
@media (max-width: 900px) {
  .items-ed .it { grid-template-columns: 1fr 1fr 1fr; }
  .items-ed .it .prod { grid-column: 1 / -1; }
  .items-ed .hdr { display: none; }
  .items-ed .it .tot { text-align: right; align-self: end; }
  .items-ed .it > div:last-of-type:not(.sub) { justify-self: end; }
}
.unit-toggle { display: flex; border: 1px solid var(--border-2); border-radius: 10px; overflow: hidden; }
.unit-toggle button { flex: 1; border: 0; background: var(--surface); padding: 8px 4px; font: inherit; font-size: 13px; cursor: pointer; }
.unit-toggle button.on { background: var(--primary); color: #fff; }
.mini-l { display: none; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
@media (max-width: 900px) { .mini-l { display: block; } }

.totals-box { margin-left: auto; max-width: 380px; }
.totals-box .tr { display: flex; justify-content: space-between; padding: 5px 0; gap: 12px; }
.totals-box .tr.big { font-size: 18px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }

.info-list { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; word-break: break-word; }

.balance-big { font-size: 28px; font-weight: 800; }
.result-box { border-radius: 12px; padding: 12px 14px; background: var(--primary-3); border: 1px solid var(--border); }
.result-box .tr { display: flex; justify-content: space-between; padding: 3px 0; }

.timeline-amt { font-weight: 600; white-space: nowrap; }
.prod-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--primary-3); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }

.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px 16px;
  background: radial-gradient(900px 500px at 15% 0%, #bae6fd 0%, transparent 60%), radial-gradient(800px 500px at 100% 100%, #e0f2fe 0%, transparent 60%), #f5fbff;
}
.login-wrap .card { width: 100%; max-width: 380px; padding: 28px; border-radius: 20px; box-shadow: var(--shadow-lg); border-color: #dbeafe; }

/* ---------- Hujjat (nakladnoy / KP) ---------- */
.doc-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.doc-scroll { overflow-x: auto; }
.doc {
  background: #fff; color: #000; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm 12mm;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .12); font-family: "Times New Roman", Times, serif; font-size: 12.5px; line-height: 1.35;
}
.doc h1 { font-size: 18px; text-align: center; margin: 4px 0 2px; text-transform: uppercase; letter-spacing: .02em; }
.doc .doc-sub { text-align: center; margin-bottom: 14px; }
.doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 12px; }
.doc .parties .p { border: 1px solid #000; padding: 6px 8px; }
.doc .parties .p b.h { display: block; text-transform: uppercase; font-size: 11px; margin-bottom: 3px; }
.doc table { width: 100%; border-collapse: collapse; }
.doc table th, .doc table td { border: 1px solid #000; padding: 4px 5px; }
.doc table th { background: #efefef; font-size: 11.5px; text-align: center; }
.doc table td.n { text-align: right; white-space: nowrap; }
.doc table td.c { text-align: center; }
.doc table tfoot td { font-weight: 700; }
.doc .words { margin: 8px 0; }
.doc .bal { margin-top: 10px; width: 60%; margin-left: auto; }
.doc .bal td { border: 1px solid #000; padding: 3px 6px; }
.doc .signs { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 34px; }
.doc .signs div { border-top: 1px solid #000; padding-top: 4px; font-size: 11.5px; }
.doc .note { margin-top: 12px; white-space: pre-line; }
.doc .stamp { margin-top: 6px; font-size: 11px; color: #444; }
@media (max-width: 900px) { .doc { transform-origin: top left; } }

@media print {
  /* Har sahifada hoshiya (2-sahifa ham qog'oz chetidan emas, 12 mm ichkaridan boshlanadi) */
  @page { size: A4; margin: 12mm 11mm 12mm 11mm; }
  html, body { background: #fff !important; }
  .sidebar, .topbar, .no-print, .doc-toolbar, .toasts, .backdrop, .page-head { display: none !important; }
  .main { padding: 0 !important; }
  .layout { display: block; }
  .doc-scroll { overflow: visible; }
  .doc { box-shadow: none; margin: 0; width: auto; min-height: auto; padding: 0; }
  .print-hide-others > *:not(.print-area) { display: none !important; }
}

/* ================= POS ================= */
.pos-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.pos-wrap > * { min-width: 0; }
.pos-tools { position: sticky; top: 0; z-index: 6; background: var(--bg); padding: 4px 0 10px; display: flex; flex-direction: column; gap: 8px; }
.pos-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.pos-btns .btn { padding: 7px 11px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.pos-tile {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px 10px 10px;
  cursor: pointer; user-select: none; transition: transform .06s, box-shadow .15s, border-color .15s; display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow);
}
.pos-tile:hover { border-color: #7dd3fc; box-shadow: 0 6px 18px rgba(14, 165, 233, .14); }
.pos-tile:active { transform: scale(.97); }
.pos-tile .img { aspect-ratio: 1.25; border-radius: 10px; background: var(--primary-3); display: flex; align-items: center; justify-content: center; font-size: 38px; overflow: hidden; margin-bottom: 4px; }
.pos-tile .img img { width: 100%; height: 100%; object-fit: cover; }
.pos-tile .nm { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.pos-tile .pr { font-size: 12px; color: var(--muted); }
.pos-tile .pr.sel { color: var(--text); }
.pos-tile .pr.sel b { color: var(--primary); }
.pos-info { position: absolute; top: 12px; right: 14px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: rgba(255,255,255,.95); font-weight: 700; font-style: italic; font-family: Georgia, serif; cursor: pointer; color: var(--primary); }
.pos-in { position: absolute; top: 12px; left: 14px; z-index: 2; background: var(--primary); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 2px 8px; }

.pos-cart { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; padding: 0; }
.pos-cart-in { display: flex; flex-direction: column; }
.pos-sec { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.pos-line { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.pos-line:last-of-type { border-bottom: 0; }
.pos-actions { padding: 12px 14px; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); }
.pos-go { width: 100%; padding: 14px; font-size: 16px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper input { width: 54px; text-align: center; padding: 6px 4px; }
.unit-toggle.sm button { padding: 5px 8px; font-size: 12px; }
.grow { flex: 1; min-width: 0; }

.pos-li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface); cursor: pointer; }
.pos-li:hover { border-color: #7dd3fc; background: var(--primary-3); }
.pos-li.dim { opacity: .55; }

.pos-drawer-bg { position: fixed; inset: 0; background: rgba(12, 42, 61, .32); z-index: 80; }
.pos-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); z-index: 81; overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.2); animation: posIn .16s ease-out; }
@keyframes posIn { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.pos-drawer .ph { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.pos-drawer .ph .pt { flex: 1; min-width: 0; }
.pos-drawer .ph .pt .bold { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-drawer .pb { padding: 14px; }
.pos-drawer .pos-cart-in .pos-sec { padding-left: 0; padding-right: 0; }
.pos-drawer .pos-actions { margin: 0 -14px -14px; }

.pos-bar { position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 46; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--primary); color: #fff; font-size: 15px; cursor: pointer; box-shadow: 0 -6px 20px rgba(0,0,0,.15); }

@media (max-width: 999px) {
  .pos-wrap { grid-template-columns: minmax(0, 1fr); padding-bottom: 76px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .pos-btns { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
}
@media (max-width: 1100px) {
  .pos-tools { top: 58px; }
  .pos-cart { top: 70px; max-height: calc(100vh - 82px); }
}
@media (max-width: 420px) {
  .pos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-tile .img { aspect-ratio: 1.6; font-size: 30px; }
}

/* POS ichidan chop etish: faqat hujjat chiqadi */
.print-portal { display: none; }
@media print {
  body.print-doc #app { display: none !important; }
  body.print-doc .print-portal { display: block; }
  body.print-doc .print-portal .doc { box-shadow: none; margin: 0; width: auto; min-height: auto; padding: 0; }
}
@media (max-width: 600px) {
  .pos-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; gap: 6px; }
  .pos-btns .btn { padding: 8px 4px; font-size: 12.5px; white-space: normal; line-height: 1.15; }
}
.unit-fixed { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); font-size: 13px; text-align: center; }
.lang-sw { display: flex; gap: 4px; padding: 10px 20px; }
.lang-sw button { flex: 1; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 9px; padding: 6px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.lang-sw button.on { background: var(--primary-2); border-color: #7dd3fc; color: var(--primary-ink); }
.lang-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--primary-ink); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.top-badge { display: inline-flex; align-items: center; gap: 4px; background: var(--red); color: #fff !important; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; text-decoration: none !important; }
.sidebar .lang-sw { margin-top: auto; }
.client-grid { grid-template-columns: minmax(240px, 290px) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .client-grid { grid-template-columns: minmax(0, 1fr); } }


/* ================= Dokon boshqaruvi — brend ================= */
.brand-logo { display: inline-flex; line-height: 0; }
.brand-logo svg { width: 100%; height: auto; display: block; }
.modal .mh h2 { font-size: 18px; }
/* Kirish sahifasi */
.login-wrap .login-logo { width: 220px; }
.login-wrap .card h2 { text-align: center; color: var(--text); margin-bottom: 18px; font-size: 20px; }
.login-wrap .btn.primary { padding: 12px; font-size: 15px; }
.login-wrap .lang-sw { padding: 0; }
.login-foot { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.red { background: var(--red); } .dot.green { background: var(--green); } .dot.amber { background: #d97706; }
/* Hujjatlar o'z klassik shriftida */
.doc h1 { font-family: "Times New Roman", Times, serif; font-size: 18px; font-weight: 700; letter-spacing: .02em; color: #000; }
.notice-gold { display: block; background: linear-gradient(90deg, var(--primary-3), var(--primary-2)); border-color: #bae6fd; color: var(--primary-ink); text-decoration: none !important; }
.notice-gold b { color: var(--primary-ink); }
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
.alert-warn b { color: #b45309; }
table.t th, table.t th.num { white-space: normal; line-height: 1.25; }
/* Kassalar */
.reg-grid { align-items: start; }
.reg-card h2 { font-size: 20px; }
.reg-cash { background: linear-gradient(135deg, #38bdf8, var(--primary-dark)); color: #fff; border-radius: 14px; padding: 14px 16px; box-shadow: 0 6px 18px rgba(14, 165, 233, .25); }
.reg-cash .muted { color: #e0f2fe; }
.reg-cash .v { font-size: 28px; font-weight: 800; letter-spacing: -.01em; }
.reg-cash small { font-size: 13px; color: #e0f2fe; }
.pos-reg { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.pos-reg select { padding: 7px 10px; font-weight: 600; border-color: #bae6fd; background: var(--primary-3); }
.pos-go:disabled { opacity: .45; }
.pos-bar { background: linear-gradient(135deg, #38bdf8, var(--primary-dark)); color: #fff; }
.pos-in { background: var(--primary-dark); color: #fff; }
.pos-info { color: var(--primary-dark); }
.pos-tile .pr.sel b { color: var(--primary-dark); }
@media (max-width: 1100px) { .reg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } .reg-grid > * { grid-column: auto !important; } }
@media (max-width: 700px) { .reg-grid { grid-template-columns: minmax(0, 1fr) !important; } }
@media (max-width: 600px) {
  .pos-tools > .row:first-child { flex-wrap: wrap !important; }
  .pos-tools > .row:first-child .search-big { flex-basis: 100%; }
  .pos-reg { margin-left: auto; }
}

/* ---- Sharhlar ---- */
.stars-mini { color: #b08a2e; white-space: nowrap; }
.stars-v { color: #b08a2e; }
.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-card { display: flex; gap: 12px; align-items: flex-start; margin: 0; }
.grid.rv-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 700px) { .grid.rv-stats .stat .v { font-size: 18px; } .grid.rv-stats .stat .l { font-size: 10px; } }
.review-card.dim { opacity: .55; }
.review-card .rc-body { flex: 1; min-width: 0; }
.review-card .rc-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.review-card .rc-head a { color: inherit; text-decoration: none; }
.review-card .rc-stars { color: #b08a2e; letter-spacing: 1px; margin-left: auto; white-space: nowrap; }
.review-card .rc-text { margin-top: 6px; white-space: pre-line; line-height: 1.45; overflow-wrap: anywhere; }
.review-card .rc-actions { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 640px) {
  .review-card { flex-wrap: wrap; }
  .review-card .rc-body { flex-basis: calc(100% - 64px); }
  .review-card .rc-actions { width: 100%; justify-content: flex-end; }
}

/* ---- Telegram (admin bot) ulanish ---- */
.tg-box .note { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tg-box .row.wrap { flex-wrap: wrap; }
.calc-box { padding: 9px 12px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); font-weight: 600; }
/* ---- Ranglar ---- */
.cchip { display: inline-block; padding: 1px 8px; margin: 1px 3px 1px 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; line-height: 1.6; }
.color-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -4px; }
.item-color { font-size: 12px; color: var(--muted); }
.color-sel { margin-top: 4px; font-size: 13px; padding: 4px 8px; }
.color-sel.need { border-color: var(--amber, #c98a1b); }
.amber-t { color: #b45309; }
.new-version { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000; background: var(--primary-ink); color: #fff; padding: 8px 10px 8px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px; font-size: 14px; }
.new-version .btn { background: #fff; color: var(--primary-ink); border-color: #fff; }
@media print { .new-version { display: none !important; } }
/* Kategoriya tanlash ro'yxati */
.cat-ac .cat-list { max-height: 320px; overflow-y: auto; }
.cat-ac .ac-item { display: flex; align-items: center; gap: 8px; }
.cat-ac .ac-item.on { font-weight: 600; }
/* Telefonda PDF yaratish uchun hujjat ekrandan tashqarida chiziladi */
body.pdf-render .print-portal { display: block; position: fixed; left: -10000px; top: 0; width: 210mm; background: #fff; }

/* Telefonda sahifa "kattalashib" ketmasin: iPhone (Safari va Telegram) shrifti 16px dan kichik maydonga bosilganda
   sahifani yaqinlashtiradi; ikki marta bosish ham. Faqat sensorli ekranlarda — kompyuterda o'lchamlar o'zgarmaydi. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}
/* PDF tayyor oynasi (telefon / Telegram) */
.pdf-sheet-bg { position: fixed; inset: 0; z-index: 2000; background: rgba(12, 42, 61, .38); display: flex; align-items: flex-end; justify-content: center; }
.pdf-sheet { width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.pdf-sheet .ps-head { display: flex; align-items: center; gap: 8px; } .pdf-sheet .ps-head b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-sheet .ps-big { width: 100%; padding: 14px; font-size: 16px; display: flex; flex-direction: column; gap: 2px; }
.pdf-sheet .ps-big small { font-size: 12px; font-weight: 400; opacity: .8; }
.pdf-sheet .ps-wait { padding: 22px 0; text-align: center; color: var(--muted); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media print { .pdf-sheet-bg { display: none !important; } }
/* Hujjat sahifalari: 25 qatordan keyin yangi sahifa; qator ikkiga bo'linmaydi */
.doc .page-break { page-break-before: always; break-before: page; height: 0; }
/* Ekranda: sahifa chegarasi — alohida varaq kabi bo'shliq (chop etish va PDF'da ko'rinmaydi) */
@media screen {
  .doc:not(.pdf-mode) .page-break { height: 34px; margin: 16mm -12mm 14mm; background: var(--bg); box-shadow: inset 0 8px 10px -8px rgba(0,0,0,.18), inset 0 -8px 10px -8px rgba(0,0,0,.18);
    display: flex; align-items: center; justify-content: center; }
  .doc:not(.pdf-mode) .page-break span { font: 600 11px Inter, sans-serif; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
}
.doc .page-break span { display: none; }
@media screen { .doc:not(.pdf-mode) .page-break span { display: inline; } }
.doc table.items { table-layout: fixed; }
.doc table.items td { overflow-wrap: anywhere; }
.doc table.items tr { page-break-inside: avoid; break-inside: avoid; }
.doc table.items thead { display: table-header-group; }
.doc .words, .doc table.bal, .doc .signs { page-break-inside: avoid; break-inside: avoid; }

/* POS: hamma yozuv qalin (bold) — kassada uzoqdan ham yaxshi o'qilsin */
.pos-wrap, .pos-wrap input, .pos-wrap select, .pos-wrap textarea, .pos-wrap button,
.pos-drawer, .pos-drawer input, .pos-drawer select, .pos-drawer textarea, .pos-drawer button { font-weight: 600; }
.pos-wrap .muted, .pos-wrap .small, .pos-drawer .muted, .pos-drawer .small { font-weight: 600; }
.pos-wrap b, .pos-wrap .bold, .pos-wrap .nm, .pos-drawer b, .pos-drawer .bold { font-weight: 800; }
.pos-wrap .muted { color: #4a6276; }
/* Telefonda bo'sh ustun qatorlari (masalan to'lov qatoridagi "Sotuv") ko'rsatilmaydi */
@media (max-width: 700px) { table.rt td.m-hide { display: none; } }

/* Telefon PDF'i (html2pdf): hoshiyani PDF o'zi beradi (12 mm), hujjatning ichki bo'sh joyi olib tashlanadi */
.doc.pdf-mode { padding: 0; width: 188mm; min-height: auto; box-shadow: none; }
/* 25 qator + "Jami" qatori bitta A4 sahifaga sig'ishi uchun jadval qatorlari ixchamroq */
.doc table.items th, .doc table.items td { padding: 3px 5px; line-height: 1.25; }
/* Belgi ustuni: har qatorda bo'sh katakcha — qog'ozda qo'lda ✓ qo'yish uchun */
.doc table.items th.chk-h { padding: 3px 0; font-size: 11px; }
.doc table.items td.chk { padding: 2px 0; text-align: center; }

/* ---------- Valyuta (so'm / dollar) ---------- */
.cur-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cur-bar .chips { margin: 0; }
.cur-rate { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cur-rate input { width: 120px; text-align: right; font-weight: 600; }
.stat .v2 { font-size: 15px; font-weight: 700; margin-top: 2px; }
.stat.usd { border-left: 3px solid var(--green); }
.chip-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 6px; }
.rate-card { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; }
.rate-card input { text-align: right; font-weight: 600; }
@media (max-width: 760px) { .cur-rate input { width: 100px; } }

/* ---------- Bosh sahifa: Mijozlar paneli ---------- */
.client-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.client-bar:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
}
.client-bar:active {
  transform: scale(0.995);
}
.client-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.client-bar-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary-2);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.client-bar-icon svg {
  width: 22px;
  height: 22px;
}
.client-bar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.client-bar-sub {
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.3;
}
.client-bar-val {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.client-bar-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.client-bar-arr {
  font-size: 18px;
  color: var(--muted);
}
@media (max-width: 700px) {
  .client-bar {
    padding: 12px 14px;
  }
  .client-bar-icon {
    width: 38px;
    height: 38px;
  }
  .client-bar-icon svg {
    width: 20px;
    height: 20px;
  }
  .client-bar-title {
    font-size: 14px;
  }
  .client-bar-sub {
    font-size: 12px;
  }
  .client-bar-num {
    font-size: 19px;
  }
}
