/* eKochat boshqaruv paneli — "glass" dizayn tizimi.
   Har bir modulning o'z urg'u rangi bor (body[data-module]): QR-kod tizimi — zumrad,
   Ko'chatchilik reestri — indigo/binafsha. Mobil ilova bilan bir xil ranglar. */
:root {
  --qr: #10b981;
  --qr-2: #14b8a6;
  --reestr: #6366f1;
  --reestr-2: #a855f7;
  --accent: var(--qr);
  --accent-2: var(--qr-2);
  --accent-ink: #047857;

  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --bg: #f4f7fb;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --glass-rim: rgba(255, 255, 255, 0.9);
  --field: rgba(255, 255, 255, 0.85);
  --danger: #dc2626;
  --warn: #d97706;
  --shadow: 0 18px 44px -18px rgba(15, 23, 42, 0.18);
  --radius: 22px;
}
body[data-module="nursery"] {
  --accent: var(--reestr);
  --accent-2: var(--reestr-2);
  --accent-ink: #4338ca;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e2e8f0;
    --muted: #94a3b8;
    --line: rgba(148, 163, 184, 0.16);
    --bg: #070b14;
    --glass: rgba(17, 24, 39, 0.62);
    --glass-strong: rgba(17, 24, 39, 0.88);
    --glass-rim: rgba(255, 255, 255, 0.1);
    --field: rgba(15, 23, 42, 0.7);
    --accent-ink: #6ee7b7;
    --shadow: 0 18px 44px -18px rgba(0, 0, 0, 0.6);
  }
  body[data-module="nursery"] { --accent-ink: #c4b5fd; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 13px; }
a { color: var(--accent-ink); }

/* Fon: modul rangidagi sekin suzuvchi "blob"lar */
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-blobs span {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .45;
  transition: background 0.6s ease;
  animation: drift 18s ease-in-out infinite alternate;
}
.bg-blobs span:nth-child(1) { width: 520px; height: 520px; top: -160px; right: -120px; background: var(--accent); }
.bg-blobs span:nth-child(2) { width: 460px; height: 460px; top: 35%; left: -180px; background: var(--accent-2); animation-delay: -6s; }
.bg-blobs span:nth-child(3) { width: 560px; height: 560px; bottom: -220px; right: 10%; background: color-mix(in srgb, var(--accent) 50%, var(--accent-2)); animation-delay: -12s; opacity: .3; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.08); } }
@media (prefers-color-scheme: dark) { .bg-blobs span { opacity: .28; } }
@media (prefers-reduced-motion: reduce) { .bg-blobs span { animation: none; } }

/* Shisha sirt */
.glass, .stat, .modal-card, .login-card, .sidebar, .table-wrap, .toolbar {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--glass-rim);
  box-shadow: var(--shadow);
}

/* ---------------- Tugmalar ---------------- */
button { font: inherit; }
.btn-primary, .btn-secondary, .btn-danger {
  cursor: pointer; border: none; border-radius: 14px; font-weight: 700; font-size: 14px;
  padding: 10px 18px; transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
  white-space: nowrap;
}
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px -10px var(--accent);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-secondary {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.btn-secondary:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.btn-secondary.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn-danger { color: var(--danger); background: rgba(220, 38, 38, 0.1); }
.btn-danger:hover { background: rgba(220, 38, 38, 0.16); }
.icon-round {
  cursor: pointer; width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--glass-strong); color: var(--ink); font-size: 16px; display: grid; place-items: center;
}
.icon-round:hover { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.icon-btn { border: none; background: none; cursor: pointer; padding: 4px 8px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.icon-btn.del, .row-actions .del { color: var(--danger); }

/* ---------------- Maydonlar ---------------- */
input, select {
  font: inherit; font-size: 14px; color: var(--ink);
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--field); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
input:disabled, select:disabled { opacity: .7; }

/* ---------------- Login ---------------- */
#login-screen { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
#login-screen[hidden] { display: none; }
.login-hero {
  position: relative; overflow: hidden; color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
  background: linear-gradient(135deg, #047857 0%, #0d9488 40%, #4f46e5 75%, #9333ea 100%);
}
.login-hero::after {
  content: ""; position: absolute; inset: auto -120px -160px auto; width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); filter: blur(10px);
}
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; }
.login-hero h1 { font-size: clamp(26px, 3.2vw, 40px); line-height: 1.15; font-weight: 800; max-width: 560px; }
.login-hero > p { margin: 0; opacity: .85; }
.login-modules { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; max-width: 460px; }
.login-modules li {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.25); backdrop-filter: blur(6px);
}
.login-modules small { display: block; opacity: .85; margin-top: 2px; }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex: none; }
.dot.qr { background: linear-gradient(135deg, var(--qr), var(--qr-2)); box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.dot.reestr { background: linear-gradient(135deg, var(--reestr), var(--reestr-2)); box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.login-side { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 380px; border-radius: 28px; padding: 32px; display: flex; flex-direction: column; }
.login-card h2 { font-size: 24px; font-weight: 800; }
.login-card label { font-size: 13px; font-weight: 700; margin: 16px 0 6px; }
.login-card .btn-primary { margin-top: 22px; padding: 13px; font-size: 15px; }
.public-link { margin-top: 16px; text-align: center; font-size: 13px; font-weight: 600; text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(135deg, var(--qr), var(--reestr-2)); box-shadow: 0 8px 20px -8px rgba(79, 70, 229, .6);
  flex: none;
}
@media (max-width: 860px) {
  #login-screen { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 20px; }
  .login-modules { display: none; }
}

/* ---------------- Asosiy tuzilish ---------------- */
.layout { display: flex; min-height: 100vh; }
.layout[hidden] { display: none; }
.sidebar {
  position: sticky; top: 12px; height: calc(100vh - 24px); margin: 12px 0 12px 12px;
  width: 272px; flex: none; border-radius: 26px; padding: 18px 14px;
  display: flex; flex-direction: column; gap: 18px; overflow-y: auto; z-index: 30;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.side-brand b { font-size: 18px; font-weight: 800; display: block; }
.side-brand small { color: var(--muted); font-size: 12px; }
.side-nav { display: flex; flex-direction: column; gap: 16px; }
.side-group { display: flex; flex-direction: column; gap: 4px; }
.side-label {
  display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; padding: 0 10px 4px;
}
.side-label i { width: 9px; height: 9px; border-radius: 50%; }
.side-group.qr .side-label { color: var(--qr); }
.side-group.qr .side-label i { background: linear-gradient(135deg, var(--qr), var(--qr-2)); }
.side-group.reestr .side-label { color: var(--reestr); }
.side-group.reestr .side-label i { background: linear-gradient(135deg, var(--reestr), var(--reestr-2)); }
.side-nav button, .side-link, .side-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  border: none; background: none; color: var(--ink); font-size: 14px; font-weight: 600;
  padding: 11px 12px; border-radius: 14px; text-decoration: none; transition: background .15s;
}
.side-nav button:hover, .side-link:hover, .side-btn:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.ico { width: 20px; height: 20px; flex: none; opacity: .85; }
.side-group.qr button.active { background: color-mix(in srgb, var(--qr) 16%, transparent); color: #047857; }
.side-group.reestr button.active { background: color-mix(in srgb, var(--reestr) 16%, transparent); color: #4338ca; }
@media (prefers-color-scheme: dark) {
  .side-group.qr button.active { color: #6ee7b7; }
  .side-group.reestr button.active { color: #c4b5fd; }
}
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-user {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 16px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}
.avatar {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.side-user-text { min-width: 0; flex: 1; }
.side-user-text b { display: block; font-size: 14px; }
.side-user-text small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.sidebar-scrim { display: none; }

.main-area { flex: 1; min-width: 0; padding: 12px 24px 40px; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 18px 4px 20px; }
.topbar h1 { font-size: 26px; font-weight: 800; }
.menu-btn { display: none; }
.module-chip {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.module-chip i { width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.module[hidden] { display: none; }

@media (max-width: 640px) {
  .toolbar > * { flex: 1 1 150px; }
  .stat-value { font-size: 22px; }
}
@media (max-width: 960px) {
  .sidebar {
    position: fixed; left: 0; top: 0; margin: 0; height: 100vh; border-radius: 0 26px 26px 0;
    transform: translateX(-105%); transition: transform .25s ease; background: var(--glass-strong);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(15, 23, 42, .35); }
  .menu-btn { display: grid; }
  .main-area { padding: 8px 16px 32px; }
  .topbar h1 { font-size: 21px; }
}

/* ---------------- Statistika plitalari ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  position: relative; overflow: hidden; text-align: left; border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px; color: var(--ink); font: inherit;
}
button.stat { cursor: pointer; transition: transform .15s ease; }
button.stat:hover { transform: translateY(-2px); }
.stat::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .8;
}
.stat-value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat.hero {
  color: #fff; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 18px 40px -16px var(--accent);
}
.stat.hero::before { display: none; }
.stat.hero .stat-label { color: rgba(255, 255, 255, .85); }
.stat-alert { box-shadow: inset 0 0 0 2px var(--warn), var(--shadow); }

/* ---------------- Asboblar paneli ---------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; border-radius: 18px; margin-bottom: 14px; }
.toolbar input, .toolbar select { min-height: 40px; }
#search-input, .toolbar .grow { flex: 1; min-width: 220px; }
.toolbar p.grow { margin: 0; }
.admin-bar { border-style: dashed; }
p.hint, div.hint, .alert { border-radius: 14px; padding: 12px 14px; font-size: 13.5px; margin: 0 0 14px; }
.hint { background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.alert { background: rgba(220, 38, 38, .08); border: 1px solid rgba(220, 38, 38, .2); color: var(--ink); }
.hint ul, .alert ul { margin: 6px 0 0; padding-left: 18px; }
#count-label, p.muted[data-el="count"] { margin: 0 4px 10px; font-weight: 600; }

/* ---------------- Jadvallar ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--glass-strong); color: var(--muted); font-weight: 800; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
tbody tr:last-child td { border-bottom: none; }
table.clickable tbody tr[data-id] { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--muted); padding: 40px; white-space: normal; }
.total-row td { font-weight: 800; }
td[rowspan] { vertical-align: middle; }
.row-actions button { border: none; background: none; cursor: pointer; padding: 5px 7px; border-radius: 8px; }
.row-actions button:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-ink);
}
.st-review { background: rgba(217, 119, 6, .14); color: #b45309; }
@media (prefers-color-scheme: dark) { .st-review { color: #fbbf24; } }

/* ---------------- Oynalar (modal) ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto; padding: 40px 16px;
  background: rgba(15, 23, 42, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  width: 100%; max-width: 440px; margin: 0 auto; border-radius: 28px; padding: 26px;
  background: var(--glass-strong); animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-card-wide { max-width: 760px; }
.modal-card-xl { max-width: 1080px; }
.modal-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.modal-card h3 { font-size: 15px; font-weight: 800; margin: 24px 0 10px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; }
.modal-card label { display: block; font-size: 12px; font-weight: 700; margin: 10px 0 5px; color: var(--muted); }
.modal-card input, .modal-card select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-actions.wrap {
  flex-wrap: wrap; position: sticky; bottom: -40px; z-index: 2;
  margin: 22px -26px -26px; padding: 14px 26px 16px;
  background: var(--bg); border-top: 1px solid var(--line); border-radius: 0 0 28px 28px;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 14px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 560px) { .form-grid .span2 { grid-column: auto; } }
.stir-row { display: flex; gap: 6px; }
.stir-row input { flex: 1; }
.stir-row .btn-secondary.small { margin: 0; }

.stock-table { font-size: 13px; }
.stock-table td { padding: 6px; vertical-align: middle; }
.stock-table input, .stock-table select { min-width: 92px; padding: 8px 10px; border-radius: 10px; }
.stock-table input.sm { min-width: 84px; }
.stock-table input.xs { min-width: 50px; width: 64px; }
.row-buttons { display: flex; gap: 8px; margin-top: 8px; }
.history { list-style: none; padding: 0; margin: 0; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }

.users-table-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 16px; margin-top: 10px; }
.users-pw-input { width: 100%; padding: 7px 9px; font-size: 13px; }
.user-create { border: 1px dashed var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.user-create summary { cursor: pointer; font-weight: 800; font-size: 13.5px; color: var(--accent-ink); }
.user-create .btn-primary { margin-top: 12px; }

/* ---------------- Bildirishnomalar ---------------- */
#toast-area { position: fixed; top: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; border-radius: 14px; font-size: 13.5px; font-weight: 700; color: #fff;
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, .35); animation: pop .2s ease;
}
.toast.success { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.toast.error { background: var(--danger); }
