/* Codial ERP — prototip dizayni. Brend: qora, oq, to'q sariq */
:root {
  --brand: #f26a1b;
  --brand-600: #d9570c;
  --brand-50: #fff3eb;
  --ink: #17171a;
  --ink-2: #3a3a40;
  --muted: #6b6b73;
  --line: #e6e6ea;
  --bg: #f5f5f7;
  --card: #ffffff;
  --side: #141416;
  --side-2: #1f1f23;
  --green: #1e9e57;
  --green-50: #e7f6ee;
  --red: #d93b3b;
  --red-50: #fdeceb;
  --orange: #e07b00;
  --orange-50: #fff3e0;
  --blue: #2f73da;
  --blue-50: #eaf1fd;
  --pink: #d6418a;
  --gray-50: #f0f0f3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 2px 8px rgba(20, 20, 30, 0.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.no-scroll { overflow: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; margin-bottom: 10px; }
h3 { font-size: 15px; font-weight: 650; }
h4 { font-size: 13px; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code { background: var(--gray-50); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 12px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- Rang yordamchilari ---- */
.t-green { color: var(--green); } .t-red { color: var(--red); } .t-orange { color: var(--orange); }
.t-blue { color: var(--blue); } .t-pink { color: var(--pink); } .t-gray { color: var(--muted); }
.bg-green { background: var(--green); } .bg-red { background: var(--red); } .bg-orange { background: var(--orange); } .bg-blue { background: var(--blue); }

/* ---- Logo ---- */
.logo { font-weight: 800; font-size: 24px; letter-spacing: -0.04em; color: inherit; }
.logo i { color: var(--brand); font-style: normal; }

/* ================= Layout ================= */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--side); color: #d6d6dc; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.brand { padding: 18px 18px 8px; color: #fff; display: flex; flex-direction: column; }
.brand-sub { font-size: 11px; color: #8d8d96; text-transform: uppercase; letter-spacing: 0.08em; }
.branch-pill { margin: 6px 14px 10px; padding: 7px 10px; background: var(--side-2); border-radius: 8px; font-size: 12px; display: flex; gap: 6px; align-items: center; color: #b9b9c2; }
.branch-pill b { color: #fff; }
.nav { overflow-y: auto; padding: 4px 8px 12px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #c9c9d1; font-size: 13.5px; position: relative;
}
.nav a:hover { background: var(--side-2); text-decoration: none; color: #fff; }
.nav a.on { background: var(--brand); color: #fff; }
.nav a.soon:not(.on) { opacity: 0.45; }
.nav .dot, .bell .dot {
  margin-left: auto; background: var(--brand); color: #fff; font-style: normal; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 6px; min-width: 18px; text-align: center;
}
.nav a.on .dot { background: #fff; color: var(--brand); }
.side-foot { padding: 10px 16px 14px; font-size: 11px; color: #75757e; border-top: 1px solid #26262b; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 58px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 20px;
}
.top-title { font-weight: 650; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-pill { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.date-pill:hover { border-color: var(--brand); }
.icon-btn { border: 0; background: transparent; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); position: relative; font-size: 16px; }
.icon-btn:hover { background: var(--gray-50); text-decoration: none; }
.bell .dot { position: absolute; top: 2px; right: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 24px; padding: 3px 12px 3px 3px; cursor: pointer; font: inherit; text-align: left; }
.user-chip:hover { border-color: var(--brand); }
.uc-text { display: flex; flex-direction: column; line-height: 1.15; }
.uc-text b { font-size: 13px; } .uc-text small { font-size: 11px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.view { padding: 22px 24px 60px; max-width: 1280px; width: 100%; }
.only-mobile { display: none; }
.bottomnav { display: none; }
.scrim { display: none; }

/* ================= Sahifa elementlari ================= */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important; min-height: 38px;
}
.btn:hover { border-color: #cfcfd6; background: #fafafa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; vertical-align: middle; }
.badge.gray { background: var(--gray-50); color: var(--ink-2); }
.badge.green { background: var(--green-50); color: var(--green); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.orange { background: var(--orange-50); color: var(--orange); }
.badge.blue { background: var(--blue-50); color: var(--blue); }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; } .nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.narrow { max-width: 560px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + * { margin-top: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: inherit; box-shadow: var(--shadow); display: block; }
a.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 21px; font-weight: 700; margin-top: 4px; letter-spacing: -0.01em; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.danger { border-left: 3px solid var(--red); }
.stat.warn { border-left: 3px solid var(--orange); }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid; align-items: flex-start; }
.alert .ic { margin-top: 1px; }
.alert.warn { background: var(--orange-50); border-color: #f6d39a; color: #7a4a00; }
.alert.info { background: var(--blue-50); border-color: #c9dbf8; color: #1d4a8f; }
.alert.danger { background: var(--red-50); border-color: #f4c3c3; color: #8c1f1f; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); }
.tabs .cnt { background: var(--gray-50); border-radius: 10px; padding: 0 6px; font-size: 11px; margin-left: 2px; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.f-input, .field input, .field select, .field textarea {
  font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff; color: var(--ink); min-height: 38px; max-width: 100%;
}
.f-input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(242, 106, 27, 0.25); border-color: var(--brand); }
.f-input.sm { min-height: 30px; padding: 3px 6px; font-size: 12.5px; }
input[type="search"].f-input { min-width: 220px; }

/* ---- Jadval ---- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; background: #fafafb; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #f0f0f2; vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fcfcfd; }
.tbl tr.row-link { cursor: pointer; }
.tbl tr.row-link:hover td { background: var(--brand-50); }
.tbl tfoot td { border-top: 1px solid var(--line); background: #fafafb; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.money.neg { color: var(--red); font-weight: 600; } .money.pos { color: var(--green); }
.group-block { margin-bottom: 18px; }
.group-block h3 { margin-bottom: 8px; }
.day-h { display: flex; gap: 8px; align-items: baseline; margin: 10px 0 6px; font-weight: 600; font-size: 13px; }
.day-h b { margin-left: auto; }

/* ---- Bosh sahifa ---- */
.acc-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid #f0f0f2; color: inherit; }
.acc-row:last-child { border: 0; }
.acc-row span { display: flex; gap: 6px; align-items: center; }
.acc-row:hover { text-decoration: none; }
.fill-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.fill-row a { font-weight: 600; }
.bar { height: 8px; background: var(--gray-50); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.bar i { display: block; height: 100%; border-radius: 6px; }
.chart-box { position: relative; width: 100%; }
.lesson-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #f0f0f2; }
.lesson-row:last-child { border: 0; }

/* ---- Lidlar voronkasi ---- */
.conv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.conv > div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.conv b { font-size: 20px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: #ececf0; border-radius: 12px; padding: 8px; min-height: 120px; }
.kcol-h { font-size: 12.5px; font-weight: 600; padding: 4px 4px 8px; display: flex; gap: 6px; align-items: center; }
.kcol-h b { margin-left: auto; color: var(--muted); }
.kcard { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; margin-bottom: 6px; cursor: pointer; font: inherit; }
.kcard:hover { border-color: var(--brand); }

/* ---- Tafsilot ---- */
.detail-top { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; }
.calc { width: 100%; border-collapse: collapse; }
.calc td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.calc tr.tot td { font-weight: 700; border-bottom: 0; font-size: 15px; }
.comments { list-style: none; padding: 0; margin: 10px 0 0; }
.comments li { padding: 8px 0; border-bottom: 1px solid #f0f0f2; }
.comments p { margin: 0 0 2px; }

/* ---- Kartochkalar ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }
.gcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: inherit; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.gcard:hover { border-color: var(--brand); text-decoration: none; }
.gcard-h { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 15px; }
.big-num { font-size: 22px; font-weight: 700; margin: 4px 0; }
.big-num.sm { font-size: 17px; }
.price-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0f0f2; gap: 10px; }

/* ---- Jurnal ---- */
.journal { border-collapse: collapse; font-size: 12.5px; }
.journal th, .journal td { border-bottom: 1px solid #f0f0f2; padding: 6px 5px; text-align: center; }
.journal th:first-child, .journal td:first-child { text-align: left; position: sticky; left: 0; background: #fff; min-width: 180px; padding-left: 10px; }
.journal th { font-weight: 600; color: var(--muted); }
.att { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.att-1 { background: var(--green-50); color: var(--green); }
.att-0 { background: #fff7d6; color: #a07800; }
.att-X { background: var(--red-50); color: var(--red); }
.att-n { background: var(--gray-50); color: var(--muted); }
.att-empty { color: #c4c4cc; }

/* ---- Davomat olish ---- */
.take-head { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.att-card h2 { margin: 0; }
.att-list { list-style: none; padding: 0; margin: 8px 0 0; }
.att-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0f0f2; }
.att-list li.done .att-name b { opacity: 0.75; }
.att-name { display: flex; flex-direction: column; min-width: 0; }
.att-btns { display: flex; gap: 6px; flex: none; }
.abtn { border: 2px solid var(--line); background: #fff; border-radius: 10px; min-width: 84px; min-height: 44px; font: inherit; font-weight: 700; cursor: pointer; padding: 0 10px; }
.abtn.n { min-width: 44px; }
.abtn.g:hover { border-color: var(--green); color: var(--green); }
.abtn.y:hover { border-color: #e2b100; color: #8a6d00; }
.abtn.r:hover { border-color: var(--red); color: var(--red); }
.abtn.n:hover { border-color: #888; }
.abtn.g.on { border-color: var(--green); background: var(--green); color: #fff; }
.abtn.y.on { border-color: #e2b100; background: #f2c200; color: #3a2e00; }
.abtn.r.on { border-color: var(--red); background: var(--red); color: #fff; }
.abtn.n.on { border-color: #888; background: #888; color: #fff; }
.abtn:disabled { opacity: 0.4; cursor: not-allowed; }
.abtn:disabled.on { opacity: 0.85; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ---- Sozlamalar ---- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.side-tabs { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; position: sticky; top: 74px; }
.side-tabs a { padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.side-tabs a:hover { background: var(--gray-50); text-decoration: none; }
.side-tabs a.on { background: var(--brand-50); color: var(--brand-600); font-weight: 650; }
.settings-body { margin: 0; min-width: 0; }
.settings.tree-layout { grid-template-columns: 290px minmax(0, 1fr); }
.tree-n { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.tree-tw { width: 12px; flex: none; color: var(--ink-3, #8a8a94); font-size: 11px; }
.tree-l { flex: 1; min-width: 0; }
.tree-c { flex: none; background: var(--gray-50); border-radius: 6px; padding: 1px 7px; font-size: 12px; color: var(--ink-2); }
.tree-n.on .tree-c { background: #fff; }
.settings-body > .row:first-child { margin-bottom: 8px; }
.perm td.pc { white-space: nowrap; }
/* Rollar matritsasi: sarlavha (rollar) va birinchi ustun (bo'limlar) qotib turadi, faqat kataklar aylanadi */
.perm-wrap { max-height: calc(100vh - 200px); overflow: auto; }
.perm { border-collapse: separate; border-spacing: 0; }
.perm thead th { position: sticky; top: 0; z-index: 2; background: #fafafb; }
.perm tbody td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; font-weight: 500; min-width: 130px; box-shadow: 1px 0 0 var(--line); }
.perm thead th:first-child { left: 0; z-index: 3; box-shadow: 1px 0 0 var(--line); }
.perm tbody tr:hover td { background: #fff7f0; }
.pbit { border: 1px solid var(--line); background: #fff; color: #c4c4cc; width: 20px; height: 22px; border-radius: 5px; font: 600 11px/1 monospace; padding: 0; cursor: pointer; margin-right: 1px; }
.pbit.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pbit:disabled { cursor: default; }

/* ---- AI chat ---- */
.chat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-height: 260px; max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--gray-50); border-bottom-left-radius: 4px; width: 85%; }
.msg.bot .tbl-wrap { margin: 8px 0; }
.msg p { margin: 0 0 6px; }
.sql { background: var(--side); color: #f1f1f4; padding: 10px; border-radius: 8px; font-size: 12px; overflow-x: auto; }
.sugg { margin-bottom: 10px; }
.chat-input { display: flex; gap: 8px; }

/* ================= Modal va forma ================= */
.overlay { position: fixed; inset: 0; background: rgba(15, 15, 20, 0.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade 0.12s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); display: flex; flex-direction: column; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 10px; gap: 10px; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 4px 18px 16px; }
.modal-body h3 { margin: 18px 0 8px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: #fff; border-radius: 0 0 16px 16px; }
.form { display: flex; flex-wrap: wrap; gap: 0 12px; }
.field { width: 100%; margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.field.half { width: calc(50% - 6px); }
.field[hidden] { display: none; }
.field input, .field select, .field textarea { width: 100%; }
.field input[readonly], .field select:disabled, .field textarea[readonly] { background: var(--gray-50); color: var(--ink-2); }
.lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.req { color: var(--red); }
.help { font-size: 12px; color: var(--muted); }
.err { font-size: 12px; color: var(--red); font-weight: 600; }
.form-error { width: 100%; background: var(--red-50); color: var(--red); padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-weight: 600; }
.computed { padding: 8px 10px; background: var(--gray-50); border-radius: 9px; min-height: 38px; }
.note { padding: 9px 12px; border-radius: 9px; font-size: 13px; }
.note.info { background: var(--blue-50); color: #1d4a8f; }
.note.warn { background: var(--orange-50); color: #7a4a00; }
.note.danger { background: var(--red-50); color: #8c1f1f; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 12px; font: inherit; cursor: pointer; min-height: 38px; }
.seg button:hover { border-color: var(--brand); }
.seg button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg button:disabled { opacity: 0.5; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand-50); border-color: var(--brand); color: var(--brand-600); font-weight: 600; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); max-width: 92vw; transition: opacity 0.3s, transform 0.3s; }
.toast.warn { background: #8a4f00; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---- Login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 20% 0%, #2a2a30 0, var(--side) 55%); }
.login-card { background: #fff; border-radius: 20px; padding: 28px; width: 100%; max-width: 760px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); }
.login-card.narrow { max-width: 400px; }
.login-form input { width: 100%; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 6px 0; display: block; margin: 6px auto 0; text-align: center; }
.link-btn:hover { color: var(--brand); text-decoration: underline; }
.brand.big { padding: 0 0 18px; color: var(--ink); }
.brand.big .logo { font-size: 36px; }
.login-form { display: grid; gap: 6px; max-width: 360px; margin-bottom: 18px; }
.login-form input { font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; margin-bottom: 6px; background: var(--gray-50); }
.login-h { margin: 8px 0 10px; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.user-card { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; cursor: pointer; font: inherit; }
.user-card:hover { border-color: var(--brand); background: var(--brand-50); }
.user-card.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.user-card span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.user-card small { color: var(--muted); font-size: 12px; }

/* ---- Chek ---- */
.receipt { border: 1px dashed #c9c9d1; border-radius: 10px; padding: 18px; max-width: 380px; margin: 0 auto; font-size: 13px; }
.r-head { display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; font-size: 11px; color: var(--muted); }
.receipt h3 { text-align: center; margin: 6px 0 10px; font-size: 14px; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: 5px 0; border-bottom: 1px dotted var(--line); }
.receipt td:last-child { text-align: right; font-weight: 600; }
.receipt tr.big td { font-size: 17px; font-weight: 800; }
.r-warn { text-align: center; color: var(--red); font-weight: 800; letter-spacing: 0.1em; border: 2px solid var(--red); border-radius: 6px; padding: 4px; margin: 10px 0 0; }
.r-foot { text-align: center; color: var(--muted); font-size: 11px; margin: 12px 0 0; }

/* ================= Telefon ================= */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform 0.2s ease; height: 100%; }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 50; }
  .only-mobile { display: grid; }
  .topbar { padding: 0 10px; gap: 6px; }
  .uc-text, .date-pill span { display: none; }
  .date-pill { padding: 6px 9px; }
  .user-chip { padding: 3px; }
  .view { padding: 16px 16px 90px; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a, .bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; font-size: 11px; color: var(--muted); background: none; border: 0; padding: 4px 0; cursor: pointer; }
  .bottomnav a.on { color: var(--brand); }
  .bottomnav a:hover { text-decoration: none; }
  .bottomnav .ic { width: 22px; height: 22px; }
  .grid-2, .take-head, .settings { grid-template-columns: 1fr; }
  .side-tabs { position: static; flex-direction: row; overflow-x: auto; }
  .side-tabs a { white-space: nowrap; }
  .side-tabs.tree { flex-direction: column; max-height: 260px; overflow-y: auto; }
  .settings.tree-layout { grid-template-columns: 1fr; }
  .field.half { width: 100%; }
  h1 { font-size: 19px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 11px; }
  .stat-value { font-size: 17px; }
  .dl { grid-template-columns: 1fr; gap: 0; }
  .dl dt { margin-top: 8px; }
  input[type="search"].f-input { min-width: 0; width: 100%; }
  .filters > * { flex: 1 1 140px; }
  /* Jadvallar kartochkaga aylanadi */
  .tbl-wrap { border: 0; background: transparent; overflow: visible; }
  .tbl:not(.perm) thead { display: none; }
  .tbl:not(.perm), .tbl:not(.perm) tbody, .tbl:not(.perm) tr, .tbl:not(.perm) td, .tbl:not(.perm) tfoot { display: block; width: 100%; }
  .tbl:not(.perm) tr { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; padding: 6px 10px; }
  .tbl:not(.perm) td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl:not(.perm) td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; max-width: 45%; }
  .tbl:not(.perm) td[data-label=""]::before { content: none; }
  .tbl:not(.perm) td[data-label=""] { justify-content: flex-end; }
  .tbl:not(.perm) tfoot td::before { content: none; }
  .tbl:not(.perm) tfoot td:empty { display: none; }
  .perm { font-size: 12px; }
  .tbl-wrap:has(.perm) { overflow: auto; border: 1px solid var(--line); background: #fff; }
  .perm-wrap { max-height: calc(100vh - 150px); }
  .perm tbody td:first-child { min-width: 96px; }
  .journal td:first-child, .journal th:first-child { min-width: 130px; }
  .tbl-wrap:has(.journal) { overflow-x: auto; }
  .att-list li { flex-direction: column; align-items: stretch; }
  .att-btns { display: grid; grid-template-columns: 1fr 1fr 1fr auto; }
  .abtn { min-width: 0; min-height: 52px; font-size: 15px; }
  .kanban { grid-auto-columns: 78%; }
  .modal { border-radius: 16px; }
  .overlay { padding: 0; align-items: flex-end; }
  .overlay .modal { max-height: 94vh; overflow-y: auto; border-radius: 16px 16px 0 0; }
  .msg, .msg.bot { max-width: 100%; width: auto; }
}

/* ---- Chop etish (chek) ---- */
@media print {
  body.printing > *:not(#modal-root) { display: none !important; }
  body.printing #modal-root .overlay { position: static; background: none; padding: 0; }
  body.printing .modal { box-shadow: none; }
  body.printing .modal-head, body.printing .modal-foot { display: none; }
  body.printing .receipt { border: 0; }
}

/* ---- Server bilan ishlash (M1) ---- */
dl.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0 0 12px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; }
.pager { justify-content: center; margin-top: 12px; }
.nowrap-cell { white-space: nowrap; }
.empty .ic { width: 28px; height: 28px; opacity: 0.5; }
button[disabled] { cursor: not-allowed; }
.btn[data-submit][disabled] { opacity: 0.6; }
