:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7688;
  --line: #dde2ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e8efff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --ok: #16a34a;
  --ok-soft: #e7f6ec;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --dim: #9aa4b4;
  --track: #eef1f6;
  --shadow: 0 6px 24px rgba(24, 39, 75, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
}
input, select, textarea, button { font-family: inherit; }

.hidden { display: none !important; }

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

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.iconbtn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  font-size: 18px; display: inline-flex; align-items: center; justify-content: center;
  transition: .15s;
}
.iconbtn:hover { background: #f3f5f9; }
.badge {
  background: var(--primary-soft); color: var(--primary-dark);
  font-weight: 700; padding: 6px 12px; border-radius: 999px; font-size: 14px;
  white-space: nowrap;
}

/* ---------- Home ---------- */
#home { align-items: center; justify-content: center; }
.home-wrap { text-align: center; max-width: 720px; width: 100%; padding: 30px; }
.home-logo {
  width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff; display: grid; place-items: center; font-size: 42px; font-weight: 800;
  box-shadow: var(--shadow);
}
.home-title { font-size: 26px; font-weight: 800; margin: 0 0 6px; }
.home-sub { color: var(--muted); margin: 0 0 34px; }
.home-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.home-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 22px; cursor: pointer; text-align: center;
  box-shadow: var(--shadow); transition: .18s;
}
.home-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.home-card .ico { font-size: 46px; }
.home-card .t { font-size: 19px; font-weight: 700; margin-top: 12px; }
.home-card .d { color: var(--muted); font-size: 13px; margin-top: 6px; }
.home-foot { margin-top: 26px; }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline; }

/* ---------- Form ---------- */
.form-body { flex: 1; overflow-y: auto; padding: 20px; }
.form-inner { max-width: 1040px; margin: 0 auto; }
.group {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: #f7f9fc; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 15px;
}
.group-head .gi { font-size: 18px; }
.group-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; padding: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field input, .field select {
  height: 42px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; font-size: 15px; background: #fff; color: var(--ink);
  outline: none; transition: .15s; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input::-webkit-calendar-picker-indicator { cursor: pointer; }

/* day/night toggle */
.daynight { display: flex; gap: 8px; }
.daynight button {
  flex: 1; height: 42px; border: 1px solid var(--line); background: #fff; border-radius: 10px;
  cursor: pointer; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: .15s;
}
.daynight button.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }

/* defect selector */
.defect-btn {
  height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  cursor: pointer; padding: 0 12px; display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
}
.defect-btn:hover { border-color: var(--primary); }
.defect-btn .swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.defect-btn .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.defect-btn .txt.placeholder { color: #9aa4b4; }
.defect-btn .clear { color: var(--muted); font-size: 18px; padding: 0 2px; }

/* bir nechta brak + har biriga soni */
.defects { display: flex; flex-direction: column; gap: 8px; }
.dsel {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 6px 8px 6px 10px;
}
.dsel .swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.dsel .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.dsel .qty { width: 104px; height: 34px; flex: none; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font-size: 14px; outline: none; }
.dsel .qty:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.dsel .rm { border: none; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 4px; }
.dsel .rm:hover { color: var(--danger); }
.defect-add {
  height: 40px; border: 1px dashed var(--primary); background: var(--primary-soft); color: var(--primary);
  border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.defect-add:hover { background: #dbe6ff; }
.defects-total { color: var(--muted); font-size: 12.5px; }
.defects-total.warn { color: var(--danger); font-weight: 600; }

/* tanlash ro'yxatlari (spravochniklar) */
.list-card { margin-bottom: 16px; }
.list-head { display: flex; align-items: baseline; gap: 10px; }
.list-head h3 { margin: 0; }
.list-head .cnt {
  margin-left: auto; font-size: 12px; font-weight: 700; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px;
}
.list-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.list-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.list-foot .add-defect { margin: 0; }
.list-foot .btn { margin-left: auto; height: 38px; padding: 0 18px; font-size: 14px; }
.lists-note { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field-hint { font-size: 11.5px; color: var(--danger); margin-top: 4px; }
.dsel .qty.need { border-color: var(--danger); background: var(--danger-soft); }

/* avto hisoblanadigan maydonlar */
.calc-field input { background: #fbfcfe; }
.calc-field.manual input { background: #fffdf5; border-color: #e6c77a; }
.calc-hint { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); min-height: 18px; }
.calc-hint .a, .calc-hint .calc-reset { display: none; }
.calc-field.manual .calc-hint .f { display: none; }
.calc-field.manual .calc-hint .a { display: inline; color: #a4761a; font-weight: 600; }
.calc-field.manual .calc-hint .calc-reset {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--primary);
  border-radius: 6px; font-size: 11.5px; padding: 2px 7px; cursor: pointer;
}
.calc-hint .calc-reset:hover { background: var(--primary-soft); }

/* maydon xatosi (masalan, takrorlangan zakaz raqami) */
.field-err { color: var(--danger); font-size: 11.5px; min-height: 14px; }
.field.has-err input { border-color: var(--danger); background: var(--danger-soft); }

/* autocomplete + defect dropdown panel — body ga qo'yiladi, JS joylashtiradi */
.ac-panel, .defect-panel {
  position: fixed; z-index: 200;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 300px; overflow-y: auto;
}
.ac-item { padding: 9px 12px; cursor: pointer; font-size: 14px; }
.ac-item:hover, .ac-item.active { background: var(--primary-soft); }
.ac-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

.defect-item {
  padding: 9px 12px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 9px;
  border-bottom: 1px solid #f0f2f6;
}
.defect-item:hover { filter: brightness(.94); }
.defect-item .sw { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.defect-clear-row { padding: 9px 12px; cursor: pointer; color: var(--danger); font-size: 14px; }
.defect-clear-row:hover { background: var(--danger-soft); }

/* bottom bar */
.bottombar {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 20px; background: var(--card); border-top: 1px solid var(--line);
}
.bottombar .spacer { flex: 1; }
.btn {
  height: 46px; padding: 0 22px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: .15s;
}
.btn:hover { background: #f3f5f9; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.ghost-danger { color: var(--danger); border-color: #f2c9c9; }
.btn.ghost-danger:hover { background: var(--danger-soft); }

/* ---------- List ---------- */
.list-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.list-inner { max-width: 900px; margin: 0 auto; }
.search {
  width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px;
  padding: 0 44px; font-size: 15px; background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="none" stroke="%236b7688" stroke-width="2" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/></svg>') no-repeat 14px center;
  outline: none; margin-bottom: 16px;
}
.search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
/* davr bo'yicha eksport paneli */
.exportbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.exportbar .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.exportbar .dash { color: var(--dim); }
.exportbar input[type=date] {
  height: 38px; border: 1px solid var(--line); border-radius: 9px;
  padding: 0 10px; font-size: 14px; background: #fff; color: var(--ink); outline: none;
}
.exportbar input[type=date]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.exportbar .btn { height: 38px; padding: 0 16px; font-size: 14px; margin-left: auto; }
.exportbar .quick {
  height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.exportbar .quick:hover { border-color: var(--primary); color: var(--primary); }

.order-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 12px; cursor: pointer; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); transition: .15s;
}
.order-card:hover { border-color: var(--primary); transform: translateX(2px); }
.order-num {
  min-width: 76px; height: 52px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 20px; padding: 0 8px;
}
.order-meta { flex: 1; overflow: hidden; }
.order-meta .l1 { font-weight: 700; font-size: 15px; }
.order-meta .l2 { color: var(--muted); font-size: 13px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-card .chev { color: var(--muted); font-size: 22px; }
.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-state .big { font-size: 46px; }

/* ---------- Detail ---------- */
.detail-body { flex: 1; overflow-y: auto; padding: 20px; }
.detail-inner { max-width: 1040px; margin: 0 auto; }
.detail-group {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.dcell { padding: 12px 16px; border-bottom: 1px solid #f0f2f6; border-right: 1px solid #f0f2f6; }
.dcell .k { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.dcell .v { font-size: 15px; word-break: break-word; min-height: 20px; }
.dcell .v .empty { color: #c2c9d4; }
.dcell.wide { grid-column: 1 / -1; }
.dcell .v .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); margin-right: 6px; vertical-align: -1px; }
.dchips { display: flex; flex-wrap: wrap; gap: 6px; }
.dchip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; background: #fff;
}

/* ---------- Settings (defects) ---------- */
.settings-body { flex: 1; overflow-y: auto; padding: 20px; }
.settings-inner { max-width: 760px; margin: 0 auto; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.defect-row {
  display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 8px;
}
.defect-row input[type=text] {
  flex: 1; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font-size: 14px;
}
.defect-row input[type=color] { width: 42px; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; cursor: pointer; background: #fff; }
.defect-row .del { color: var(--danger); cursor: pointer; border: none; background: none; font-size: 20px; padding: 0 6px; }
.add-defect { color: var(--primary); cursor: pointer; border: 1px dashed var(--primary); background: var(--primary-soft);
  border-radius: 10px; padding: 10px; text-align: center; font-weight: 600; margin-top: 6px; }

/* ---------- Аналитика ---------- */
.an-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.an-inner { max-width: 1180px; margin: 0 auto; }

.an-filters {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.an-filters .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.an-filters .dash { color: var(--dim); }
.an-filters input[type=date], .an-filters select {
  height: 38px; border: 1px solid var(--line); border-radius: 9px;
  padding: 0 10px; font-size: 14px; background: #fff; color: var(--ink); outline: none;
}
.an-filters input[type=date]:focus, .an-filters select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}

.an-warn {
  background: var(--warn-soft); border: 1px solid #f3d9a8; border-radius: 12px;
  padding: 12px 15px; margin-bottom: 16px; font-size: 13.5px; color: var(--ink);
}
.an-warn b { color: var(--warn); }
.an-none { text-align: center; color: var(--muted); padding: 60px 20px; }
.an-none .big { font-size: 46px; }

.an-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.an-kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow);
}
.an-kpi .k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.an-kpi .v { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin-top: 3px; }
.an-kpi .u { font-size: 11.5px; color: var(--dim); }

.an-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.an-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 17px 19px 0; display: flex; flex-direction: column;
}
.an-panel.wide { grid-column: 1 / -1; }
.an-phead { display: flex; align-items: baseline; gap: 12px; }
.an-phead h3 { margin: 0; font-size: 16px; font-weight: 700; }
.an-phead .sub { font-size: 11.5px; color: var(--dim); margin-left: auto; text-align: right; }
.an-pbody { flex: 1; padding: 12px 0 4px; }
.an-cap { font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.an-empty { color: var(--dim); font-size: 13px; padding: 22px 0; text-align: center; }

.an-src {
  margin-top: auto; padding: 11px 0 14px; border-top: 1px dashed var(--line);
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
  font-size: 11.5px; color: var(--dim);
}
.an-src code { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--muted); }
.an-tag { border-radius: 6px; padding: 2px 8px; font-size: 10.5px; font-weight: 700; }
.an-tag.ready { background: var(--ok-soft); color: var(--ok); }
.an-tag.needs { background: var(--warn-soft); color: var(--warn); }
.an-tag.dev { background: var(--primary-soft); color: var(--primary-dark); }

.an-chart svg { display: block; width: 100%; height: auto; }

.an-row { display: grid; grid-template-columns: 150px 1fr 48px; align-items: center; gap: 10px; margin-bottom: 8px; }
.an-row .nm { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-track { background: var(--track); border-radius: 5px; height: 17px; overflow: hidden; }
.an-fill { height: 100%; border-radius: 5px; }
.an-row .q { font-size: 12.5px; font-weight: 700; text-align: right; }

.an-donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.an-donut { flex: none; position: relative; width: 160px; height: 160px; }
.an-donut svg { transform: rotate(-90deg); }
.an-donut .mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.an-donut .mid b { font-size: 23px; font-weight: 800; line-height: 1.1; }
.an-donut .mid span { font-size: 11px; color: var(--muted); }
.an-cats { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: 6px; }
.an-cat { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.an-cat i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); flex: none; }
.an-cat .n { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-cat .q { font-weight: 700; }

.an-scroll { overflow-x: auto; }
.an-tbl { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 400px; }
.an-tbl th {
  text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--dim); font-weight: 700; padding: 0 10px 8px 0; border-bottom: 1px solid var(--line);
}
.an-tbl th.r, .an-tbl td.r { text-align: right; padding-right: 0; }
.an-tbl td { padding: 10px 10px 10px 0; border-bottom: 1px solid #f0f2f6; }
.an-tbl tr:last-child td { border-bottom: 0; }
.an-pill { border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; background: var(--track); color: var(--muted); }
.an-pill.good { background: var(--ok-soft); color: var(--ok); }
.an-pill.mid { background: var(--warn-soft); color: var(--warn); }
.an-pill.bad { background: var(--danger-soft); color: var(--danger); }

.an-heat { display: grid; gap: 5px; }
.an-heat .hh { font-size: 10.5px; font-weight: 700; color: var(--dim); text-transform: uppercase; text-align: center; }
.an-heat .rh { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; }
.an-heat .c { border-radius: 6px; height: 36px; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: #1f2733; }
.an-heat .c.g1 { background: #8fdcae; }
.an-heat .c.y2 { background: #f5c877; }
.an-heat .c.r2 { background: #ef8272; }
.an-heat .c.none { background: var(--track); color: var(--dim); font-weight: 400; }
.an-scale { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--dim); margin-top: 12px; flex-wrap: wrap; }
.an-scale i { width: 20px; height: 11px; border-radius: 3px; }

.an-mx { border-collapse: separate; border-spacing: 5px; width: 100%; font-size: 12.5px; min-width: 380px; }
.an-mx th { border: 0; padding: 0 0 4px; font-size: 10.5px; text-align: center; color: var(--dim); font-weight: 700; }
.an-mx th.l { text-align: left; }
.an-mx td { border: 0; padding: 0; }
.an-mx td.l { color: var(--muted); font-size: 12.5px; padding-right: 6px; white-space: nowrap; }
.an-mx .cell { border-radius: 6px; height: 34px; display: grid; place-items: center; font-weight: 700; color: #1f2733; }

@media (max-width: 1000px) {
  .an-kpis { grid-template-columns: repeat(3, 1fr); }
  .an-grid { grid-template-columns: 1fr; }
  .home-cards { grid-template-columns: 1fr; }
}

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(30px);
  background: #1f2733; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ KIRISH OYNASI ============ */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px; gap: 6px;
}
.login-title { font-size: 26px; font-weight: 800; margin: 12px 0 2px; color: var(--ink); }
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-box {
  width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.login-box label { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-top: 6px; }
.login-box input {
  height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink); outline: none;
}
.login-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-box .btn { margin-top: 16px; height: 46px; justify-content: center; }
.login-box .linkbtn { margin-top: 10px; }
.login-err { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 18px; margin-top: 8px; }
.login-note { color: var(--dim); font-size: 11.5px; text-align: center; word-break: break-all; }

/* ============ FOYDALANUVCHI YO'LAGI ============ */
.userbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--card); font-size: 13px;
}
.userbar .who { font-weight: 700; color: var(--ink); }
.userbar .role { color: var(--muted); font-weight: 400; }
.syncbox { font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.syncbox.ok      { background: #e7f6ec; color: #16a34a; }
.syncbox.wait    { background: #fdf3e3; color: #d97706; }
.syncbox.offline { background: #fdecec; color: #dc2626; }
.syncbox.busy    { background: var(--primary-soft); color: var(--primary); }

/* ============ FOYDALANUVCHILAR RO'YXATI ============ */
.urow {
  display: grid; grid-template-columns: 1fr 150px 130px auto; gap: 10px;
  align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.urow:last-child { border-bottom: 0; }
.urow .un { font-weight: 700; color: var(--ink); }
.urow .uf { font-size: 12.5px; color: var(--muted); }
.urow select {
  height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 0 8px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--ink);
}
.urow .off { color: var(--danger); font-size: 12px; font-weight: 700; }
.urow .acts { display: flex; gap: 6px; }
.urow .mini {
  height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--muted); font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.urow .mini:hover { border-color: var(--primary); color: var(--primary); }
@media (max-width: 700px) { .urow { grid-template-columns: 1fr; gap: 6px; } }

/* ============ NIZO (ikki kompyuterda o'zgargan) ============ */
.cflag { color: var(--warn, #d97706); font-size: 17px; margin-right: 8px; }
.conflict-note {
  background: #fdf3e3; border: 1px solid #f0c274; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px;
}
.conflict-note .ct { font-weight: 800; color: #b45309; font-size: 14.5px; }
.conflict-note .cs { color: #92400e; font-size: 13px; margin-top: 4px; }
.conflict-note .cd { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.conflict-note .cr {
  display: grid; grid-template-columns: 1fr auto 18px auto; gap: 8px;
  align-items: baseline; font-size: 13px;
}
.conflict-note .cn { color: #92400e; }
.conflict-note .co { color: #b45309; text-decoration: line-through; }
.conflict-note .ca { color: #b45309; text-align: center; }
.conflict-note .cw { font-weight: 700; color: #7c2d12; }

/* ============ UMUMIY DIALOG ============ */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 300;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--card); border-radius: 16px; padding: 24px;
  width: 100%; max-width: 380px; box-shadow: 0 18px 50px rgba(15, 23, 42, .28);
  max-height: 90vh; overflow-y: auto;
}
.modal-box h3 { margin: 0; font-size: 18px; font-weight: 800; color: var(--ink); }
.modal-sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.modal-sub:empty { display: none; }
#modal-fields { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
#modal-fields label { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-top: 8px; }
#modal-fields input, #modal-fields select {
  height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink); outline: none;
}
#modal-fields input:focus, #modal-fields select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.modal-err { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 18px; margin-top: 10px; }
.modal-acts { display: flex; gap: 10px; margin-top: 6px; }
.modal-acts .btn { flex: 1; justify-content: center; height: 44px; }
