/* ===================== Dizayn tizimi ===================== */
:root {
  --font: "Inter", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e8ecf4;
  --border: #e3e8f0;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef2ff;
  --primary-text: #4338ca;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --success-text: #15803d;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --warning-text: #b45309;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-text: #b91c1c;
  --info-soft: #e0f2fe;
  --info-text: #0369a1;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  --radius: 16px;
  --radius-sm: 10px;
  --overlay: rgba(15, 23, 42, .45);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #131a2e;
    --surface-2: #1a2239;
    --surface-3: #232d4a;
    --border: #253050;
    --text: #e8ebf4;
    --text-2: #c3c9da;
    --muted: #8b95b0;
    --primary: #6366f1;
    --primary-2: #818cf8;
    --primary-soft: rgba(99, 102, 241, .16);
    --primary-text: #a5b4fc;
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, .15);
    --success-text: #4ade80;
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, .15);
    --warning-text: #fbbf24;
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, .15);
    --danger-text: #f87171;
    --info-soft: rgba(14, 165, 233, .15);
    --info-text: #38bdf8;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, .02);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
    --overlay: rgba(2, 6, 23, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary-text); }

.i {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.i.sm { width: 16px; height: 16px; }
.i.lg { width: 28px; height: 28px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.spacer { flex: 1; }

/* ===================== Tugmalar ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: 600 .9rem var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, .25); }
.btn.primary:hover:not(:disabled) { background: var(--primary-2); }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-text); }
.btn.soft:hover:not(:disabled) { filter: brightness(.97); background: var(--primary-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger-text); }
.btn.sm { height: 34px; padding: 0 12px; font-size: .85rem; }
.btn.lg { height: 50px; padding: 0 22px; font-size: 1rem; border-radius: 12px; }
.btn.block { width: 100%; }
.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger-text); }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary-text); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }

/* ===================== Formalar ===================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span, .field-label { font-size: .83rem; font-weight: 600; color: var(--text-2); }
.field small { color: var(--muted); font-size: .8rem; }
.input, .field input, .field select, select.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: 400 .95rem var(--font);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .field input:focus, .field select:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.field input[type="range"] { height: auto; padding: 0; border: 0; box-shadow: none; accent-color: var(--primary); }
.input-icon { position: relative; }
.input-icon .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 42px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; margin-bottom: 14px; font-weight: 500; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .2s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--primary-soft); }

.chips-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { position: relative; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: .88rem;
  font-weight: 500;
  transition: all .15s;
}
.chip-check input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); }
.chip-check input:focus-visible + span { box-shadow: 0 0 0 4px var(--primary-soft); }

.msg { min-height: 1.2em; font-size: .88rem; margin-top: 10px; }
.msg:empty { display: none; }
.msg.ok { color: var(--success-text); }
.msg.err { color: var(--danger-text); }
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: .9rem;
  margin-top: 12px;
}
.alert.info { background: var(--info-soft); color: var(--info-text); }

/* ===================== Kartalar, belgilar ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 20px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head h2 { flex: 1; font-size: 1rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.plain::before { display: none; }
.pill.success { background: var(--success-soft); color: var(--success-text); }
.pill.warning { background: var(--warning-soft); color: var(--warning-text); }
.pill.danger { background: var(--danger-soft); color: var(--danger-text); }
.pill.info { background: var(--info-soft); color: var(--info-text); }
.pill.primary { background: var(--primary-soft); color: var(--primary-text); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .76rem;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  background: var(--primary) center / cover no-repeat;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.2rem; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty .i { width: 40px; height: 40px; stroke-width: 1.5; margin-bottom: 8px; opacity: .6; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { padding: 18px; display: flex; gap: 14px; align-items: center; }
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary-text);
  flex-shrink: 0;
}
.stat-icon.success { background: var(--success-soft); color: var(--success-text); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning-text); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger-text); }
.stat-icon.info { background: var(--info-soft); color: var(--info-text); }
.stat b { display: block; font-size: 1.45rem; line-height: 1.15; font-weight: 700; }
.stat span { color: var(--muted); font-size: .83rem; }

/* ===================== Jadval ===================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left;
  padding: 11px 16px;
  font-size: .74rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
td { padding: 12px 16px; border-top: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tr.dim td { opacity: .65; }
td.empty-cell { text-align: center; color: var(--muted); padding: 36px; white-space: normal; }
.person { display: flex; align-items: center; gap: 12px; }
.person b { display: block; font-weight: 600; }
.person small { display: block; color: var(--muted); font-size: .8rem; }
.actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ===================== Bildirishnoma, oynalar ===================== */
.toasts {
  position: fixed;
  z-index: 3000;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: .92rem;
  animation: toast-in .25s ease-out;
  pointer-events: auto;
}
.toast.ok .i { color: #4ade80; }
.toast.err .i { color: #f87171; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  animation: fade-in .2s;
}
@keyframes fade-in { from { opacity: 0; } }

.dialog {
  position: fixed;
  z-index: 2000;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: pop-in .2s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
.dialog .dialog-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--danger-soft);
  color: var(--danger-text);
  margin-bottom: 14px;
}
.dialog h3 { font-size: 1.1rem; margin-bottom: 6px; }
.dialog p { color: var(--muted); font-size: .92rem; white-space: pre-line; }
.dialog .row { justify-content: flex-end; margin-top: 22px; }

.drawer {
  position: fixed;
  z-index: 1600;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-in .25s ease-out;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.section { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px dashed var(--border); }
.section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-title .step {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-text);
  display: grid;
  place-items: center;
  font-size: .8rem;
  font-weight: 700;
}
.section-title h3 { flex: 1; }

/* ===================== Kamera ===================== */
.camera {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
}
.camera video, .camera canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera.mirror video { transform: scaleX(-1); }
.camera .cam-switch {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: rgba(15, 23, 42, .55);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #94a3b8;
  font-size: .9rem;
  background: var(--surface-2);
}
.camera-placeholder { padding: 16px; text-align: center; transition: opacity .4s; }
.camera-placeholder .spinner { display: none; width: 34px; height: 34px; }
.camera-placeholder.loading .i { display: none; }
.camera-placeholder.loading .spinner { display: block; }
.camera video { transition: opacity .4s; }
.camera.loading video { opacity: 0; }
.samples { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.sample {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  border: 2px dashed var(--border);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: .8rem;
  overflow: hidden;
}
.sample img { width: 100%; height: 100%; object-fit: cover; }
.sample.filled { border: 2px solid var(--success); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--success); border-radius: inherit; transition: width .3s; }

/* ===================== Kirish ekrani ===================== */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(99, 102, 241, .18), transparent 60%),
    radial-gradient(700px 400px at 110% 110%, rgba(34, 197, 94, .12), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 32px 28px; }
.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5 50%, #7c3aed);
  box-shadow: 0 10px 30px rgba(79, 70, 229, .35);
}
.auth-logo .i { width: 32px; height: 32px; }
.auth h1 { text-align: center; }
.auth .lead { text-align: center; color: var(--muted); margin: 6px 0 24px; }
.auth-foot { text-align: center; margin-top: 18px; }

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5 50%, #7c3aed);
  flex-shrink: 0;
}
.logo-mark .i { width: 20px; height: 20px; }

/* ===================== Admin: joylashuv ===================== */
.layout { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; font-weight: 700; }
.sidebar .brand small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: 500 .92rem var(--font);
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item .i { color: var(--muted); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav-item.active .i { color: var(--primary-text); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { flex: 1; min-width: 0; font-size: .88rem; }
.sidebar-foot .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who small { color: var(--muted); }

.content { min-width: 0; padding: 28px 32px 48px; }
.page { display: none; max-width: 1280px; margin: 0 auto; }
.page.active { display: block; animation: fade-in .2s; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 200px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page > * + * { margin-top: 18px; }
.page > .page-head + * { margin-top: 0; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.toolbar .field { margin: 0; min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.toolbar .field.grow { max-width: none; flex: 2 1 220px; }

.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.branch-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; transition: box-shadow .15s, transform .15s; }
.branch-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.branch-card .top { display: flex; gap: 12px; align-items: flex-start; }
.branch-card .pin-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary-text);
  flex-shrink: 0;
}
.branch-card .name { flex: 1; min-width: 0; }
.branch-card .name b { display: block; font-size: 1rem; }
.branch-card .name small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-card .meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.branch-card .meta div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.branch-card .meta b { display: block; font-size: .95rem; }
.branch-card .meta span { font-size: .74rem; color: var(--muted); }
.branch-card.inactive { opacity: .6; }

.map { height: 300px; border-radius: 12px; border: 1px solid var(--border); z-index: 0; margin-bottom: 8px; }
.map-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.map-tools .muted { font-size: .82rem; flex: 1; }

.photo-view { text-align: center; }
.photo-view img { width: 100%; max-width: 320px; border-radius: 16px; display: block; margin: 0 auto 12px; }

/* ===================== Xodim ilovasi ===================== */
.worker { background: var(--bg); }
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}
.w-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.w-header .hello { flex: 1; min-width: 0; }
.w-header .hello small { color: var(--muted); display: block; font-size: .85rem; }
.w-header .hello b { font-size: 1.2rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-page { display: none; }
.tab-page.active { display: flex; flex-direction: column; gap: 16px; animation: fade-in .2s; }

.hero { padding: 22px 20px 24px; text-align: center; overflow: hidden; position: relative; }
.status-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-2);
}
.status-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-line.on { background: var(--success-soft); color: var(--success-text); }
.status-line.on .dot { background: var(--success); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.work-timer { font-size: 2.3rem; font-weight: 700; letter-spacing: -.02em; margin: 14px 0 2px; font-variant-numeric: tabular-nums; }
.work-sub { color: var(--muted); font-size: .9rem; }

.check-wrap { display: grid; place-items: center; margin: 22px 0 14px; }
.check-btn {
  position: relative;
  width: 176px;
  height: 176px;
  border-radius: 50%;
  border: 0;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: 700 1.15rem var(--font);
  background: linear-gradient(145deg, #22c55e, #16a34a);
  box-shadow: 0 14px 34px rgba(22, 163, 74, .35), inset 0 -4px 10px rgba(0, 0, 0, .12);
  transition: transform .1s, box-shadow .2s, filter .2s;
}
.check-btn .i { width: 44px; height: 44px; stroke-width: 2.2; }
.check-btn small { font-size: .78rem; font-weight: 500; opacity: .9; }
.check-btn::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  color: rgba(34, 197, 94, .35);
  animation: ring 2.2s ease-out infinite;
}
.check-btn.out { background: linear-gradient(145deg, #f97316, #ea580c); box-shadow: 0 14px 34px rgba(234, 88, 12, .35), inset 0 -4px 10px rgba(0, 0, 0, .12); }
.check-btn.out::before { color: rgba(249, 115, 22, .35); }
.check-btn:active:not(:disabled) { transform: scale(.97); }
.check-btn:disabled {
  cursor: not-allowed;
  background: var(--surface-3);
  color: var(--muted);
  box-shadow: none;
}
.check-btn:disabled::before { display: none; }
@keyframes ring { from { transform: scale(.92); opacity: 1; } to { transform: scale(1.12); opacity: 0; } }
.check-hint { color: var(--muted); font-size: .9rem; min-height: 1.4em; padding: 0 12px; }
.check-hint.warn { color: var(--warning-text); }

.loc-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.loc-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  flex-shrink: 0;
}
.loc-icon.inside { background: var(--success-soft); color: var(--success-text); }
.loc-icon.outside { background: var(--warning-soft); color: var(--warning-text); }
.loc-card .info { flex: 1; min-width: 0; }
.loc-card .info b { display: block; }
.loc-card .info small { color: var(--muted); font-size: .83rem; }

.section-label { font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 4px -6px; }

.timeline { list-style: none; margin: 0; padding: 6px 18px; }
.timeline li { display: flex; gap: 14px; align-items: center; padding: 12px 0; position: relative; }
.timeline li + li { border-top: 1px solid var(--border); }
.timeline .t-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--success-soft);
  color: var(--success-text);
}
.timeline .t-icon.out { background: var(--warning-soft); color: var(--warning-text); }
.timeline .t-body { flex: 1; min-width: 0; }
.timeline .t-body b { display: block; font-size: .95rem; }
.timeline .t-body small { color: var(--muted); }
.timeline .t-time { font-weight: 700; font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 4px 16px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.list li + li { border-top: 1px solid var(--border); }
.list .info { flex: 1; min-width: 0; }
.list .info b { display: block; font-weight: 600; }
.list .info small { color: var(--muted); font-size: .83rem; }

.month-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.month-stats > div { padding: 14px; text-align: center; }
.month-stats b { display: block; font-size: 1.3rem; }
.month-stats span { font-size: .78rem; color: var(--muted); }
.day-card { padding: 14px 16px; display: flex; gap: 14px; align-items: center; }
.day-date {
  width: 50px;
  height: 54px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1.1;
}
.day-date b { font-size: 1.2rem; }
.day-date small { font-size: .7rem; font-weight: 600; text-transform: uppercase; }
.day-card .info { flex: 1; min-width: 0; }
.day-card .info b { display: block; font-variant-numeric: tabular-nums; }
.day-card .info small { color: var(--muted); font-size: .83rem; }
.day-card .worked { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.day-card .worked small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; }

.profile-card { padding: 22px; display: flex; align-items: center; gap: 16px; }
.profile-card b { display: block; font-size: 1.1rem; }
.profile-card small { color: var(--muted); }

.bottom-nav {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav .inner { display: flex; width: 100%; max-width: 560px; }
.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 .72rem var(--font);
  cursor: pointer;
  border-radius: 12px;
}
.bottom-nav button.active { color: var(--primary-text); }
.bottom-nav button.active .i { stroke-width: 2.4; }

/* Yuzni tekshirish (to'liq ekran) */
.scan {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #050816;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.scan-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
}
.scan-top b { flex: 1; }
.scan-top button { background: rgba(255, 255, 255, .1); color: #fff; }
.scan-top button:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.scan-view { position: relative; flex: 1; overflow: hidden; }
.scan-view video, .scan-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-view.mirror video { transform: scaleX(-1); }
.face-guide {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(68vw, 300px);
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 0 200vmax rgba(5, 8, 22, .6);
  border: 3px solid rgba(255, 255, 255, .7);
  transition: border-color .2s;
  pointer-events: none;
}
.face-guide.ok { border-color: #22c55e; }
.face-guide.warn { border-color: #f59e0b; }
/* Kamera tayyor bo'lguncha ko'rinadigan ekran */
.scan-view video { transition: opacity .45s; }
.scan-view.loading video, .scan-view.loading .face-guide { opacity: 0; }
.face-guide { transition: border-color .2s, opacity .45s; }
.scan-loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(420px 420px at 50% 42%, rgba(99, 102, 241, .28), transparent 70%),
    #050816;
  transition: opacity .45s;
}
.scan-loader.done { opacity: 0; pointer-events: none; }
.loader-face { position: relative; width: 150px; height: 150px; display: grid; place-items: center; margin-bottom: 8px; }
.loader-face .ring {
  position: absolute;
  inset: 0;
  border-radius: 40px;
  border: 2px solid rgba(129, 140, 248, .5);
  animation: loader-ring 2.4s ease-out infinite;
}
.loader-face .ring.r2 { animation-delay: 1.2s; }
@keyframes loader-ring { from { transform: scale(.75); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
.loader-box {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 32px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #c7d2fe;
  background: linear-gradient(160deg, rgba(99, 102, 241, .35), rgba(124, 58, 237, .25));
  border: 1px solid rgba(165, 180, 252, .35);
  box-shadow: 0 10px 40px rgba(79, 70, 229, .45);
}
.loader-box .i { width: 58px; height: 58px; stroke-width: 1.6; }
.scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, #a5b4fc, transparent);
  box-shadow: 0 0 14px 2px rgba(165, 180, 252, .8);
  animation: scan-move 1.6s ease-in-out infinite alternate;
}
@keyframes scan-move { from { top: 14%; } to { top: 84%; } }
.loader-title { font-size: 1.15rem; }
.loader-steps { display: flex; gap: 10px; }
.loader-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: #cbd5e1;
  font-size: .85rem;
  font-weight: 500;
  transition: background .3s, color .3s;
}
.loader-step .s-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #a5b4fc;
  animation: spin .8s linear infinite;
}
.loader-step.ok { background: rgba(34, 197, 94, .18); color: #86efac; }
.loader-step.ok .s-dot {
  animation: none;
  border: 0;
  background: #22c55e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 10px no-repeat;
}

.scan-bottom { padding: 18px 20px calc(24px + env(safe-area-inset-bottom)); text-align: center; }
.scan-hint { font-size: 1.05rem; font-weight: 600; min-height: 1.6em; }
.scan-sub { color: #94a3b8; font-size: .88rem; margin-top: 4px; }
.scan-dots { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }
.scan-dots span { width: 28px; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .2); transition: background .2s; }
.scan-dots span.on { background: #22c55e; }

.result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
  background: #050816;
  animation: fade-in .25s;
}
.result-icon {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  background: #16a34a;
  box-shadow: 0 0 0 12px rgba(22, 163, 74, .18);
  animation: pop .35s ease-out;
}
.result-icon .i { width: 52px; height: 52px; stroke-width: 2.6; }
.result.out .result-icon { background: #ea580c; box-shadow: 0 0 0 12px rgba(234, 88, 12, .18); }
.result.skip .result-icon { background: #d97706; box-shadow: 0 0 0 12px rgba(217, 119, 6, .18); }
.result.err .result-icon { background: #dc2626; box-shadow: 0 0 0 12px rgba(220, 38, 38, .18); }
.result h2 { font-size: 1.4rem; }
.result p { color: #cbd5e1; max-width: 320px; }
.result .big-time { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result .row { margin-top: 18px; justify-content: center; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

/* ===================== Yuklanish ===================== */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner.dark { border-color: var(--surface-3); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { display: grid; place-items: center; padding: 48px; }

/* ===================== Moslashuvchanlik ===================== */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
    overflow: hidden;
  }
  .sidebar .brand { padding: 0; }
  .sidebar .brand span { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { padding: 8px 12px; white-space: nowrap; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; }
  .sidebar-foot .who, .sidebar-foot .avatar { display: none; }
  .content { padding: 20px 16px 40px; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav-item span { display: none; }
  .nav-item.active span { display: inline; }
  .page-head { align-items: stretch; }
  .page-head > .btn { width: 100%; }
  .toolbar { padding: 14px; }
  .toolbar .field { max-width: none; }
  .card-head, .card-body { padding: 16px; }
  th, td { padding: 10px 12px; }
  .input, .field input, .field select { font-size: 16px; }
  .drawer { width: 100vw; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; border-radius: 10px; }
  .stat b { font-size: 1.2rem; }
  .stat span { font-size: .78rem; line-height: 1.3; display: block; }
  .map { height: 240px; }
}

/* Terminallar */
.help-card { padding: 16px 20px; }
.help-card summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.help-card ol { margin: 14px 0 4px; padding-left: 20px; color: var(--text-2); line-height: 1.7; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85em; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.push-box { background: var(--surface-2); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.copy-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.copy-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface); padding: 8px 10px; }
.device-card .actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.device-card .dev-error { font-size: .82rem; color: var(--danger-text); background: var(--danger-soft); padding: 8px 10px; border-radius: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status-dot.on { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.status-dot.err { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.method-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.warn-link { color: var(--warning-text); font-size: .85rem; justify-content: flex-start; }

/* Yuz rasmi manbasi: terminal yoki kamera */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 12px; }
.seg button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: 600 .85rem var(--font);
  cursor: pointer;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 1px 3px rgba(15, 23, 42, .08); }
.current-face {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.current-face img { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; background: #000; flex-shrink: 0; }
.current-face div { display: grid; gap: 4px; }
.term-preview {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 2px dashed var(--border);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  overflow: hidden;
  position: relative;
}
.term-preview.waiting { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
.term-preview.waiting .i { animation: pulse 1.2s infinite; }
.term-preview.done { border: 2px solid var(--success); padding: 0; }
.term-preview img { width: 100%; height: 100%; object-fit: contain; background: #000; }
.term-preview .badge-ok {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(22, 163, 74, .92);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.grid-id { display: grid; grid-template-columns: 130px 1fr; gap: 0 14px; }
.field-note { display: block; margin: -8px 0 14px; font-size: .8rem; }
.id-chip { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--primary-text); }
@media (max-width: 640px) { .grid-id { grid-template-columns: 1fr; } }
.import-list { padding: 0; margin: 8px 0 0; max-height: 55vh; overflow: auto; }
.import-list li { gap: 10px; }
.import-list input[type="checkbox"], .check-all input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; flex-shrink: 0; }
.import-list .method-chips { flex-shrink: 0; max-width: 55%; }
.check-all { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 600; font-size: .88rem; cursor: pointer; }

/* Terminal kartochkasi */
.device-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.device-card.inactive { opacity: .6; }
.dev-head { display: flex; gap: 12px; align-items: flex-start; }
.dev-head .pin-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-text); flex-shrink: 0;
}
.dev-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dev-title b { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-title small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--muted); margin: 2px 0; }
.dev-status.on { color: var(--success-text); }
.dev-status.err { color: var(--danger-text); }
.dev-status .status-dot { width: 8px; height: 8px; box-shadow: none; }
.dev-icons { display: flex; gap: 2px; margin: -6px -8px 0 0; flex-shrink: 0; }
.dev-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dev-meta div { background: var(--surface-2); border-radius: 10px; padding: 9px 10px; min-width: 0; }
.dev-meta b { display: block; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-meta span { display: block; font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-main { display: flex; flex-direction: column; gap: 8px; }
.dev-main .btn { width: 100%; min-width: 0; }
.dev-main .btn span { overflow: hidden; text-overflow: ellipsis; }
.dev-tools {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
  border-top: 1px solid var(--border); padding-top: 10px; margin-top: 2px;
}
.dev-tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
  padding: 8px 2px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text-2); font: 600 .74rem var(--font); cursor: pointer; transition: background .15s, color .15s;
}
.dev-tool:hover:not(:disabled) { background: var(--surface-2); color: var(--primary-text); }
.dev-tool:disabled { opacity: .6; cursor: wait; }
.dev-tool span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-tool .i { width: 19px; height: 19px; }
.device-card .warn-link { margin-top: -4px; }
#deviceList { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.dev-meta { grid-template-columns: minmax(0, .7fr) minmax(0, 1fr) minmax(0, 1.4fr); }
@media (max-width: 640px) { #deviceList { grid-template-columns: 1fr; } }

/* Yangilash tugmasi */
.refresh-btn.spinning .i { animation: spin .8s linear infinite; }
.refresh-btn:disabled { opacity: .8; }
@media (max-width: 640px) {
  .page-head .refresh-btn { width: 100%; }
}
.refresh-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.refresh-icon.spinning .i { animation: spin .8s linear infinite; }
