/* ============================================================
   HORION tizimi — dizayn tizimi (brend magenta #DC04AF, dark/light)
   ============================================================ */
:root {
  --brand: #DC04AF;
  --brand-2: #A00580;
  --brand-3: #7A0463;
  --brand-soft: rgba(220, 4, 175, 0.12);
  --brand-glow: rgba(220, 4, 175, 0.30);
  --purple: #7C3AED;
  --success: #22C55E;
  --danger: #EF4444;
  --warn: #F59E0B;
  --info: #0EA5E9;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Inter, system-ui, sans-serif;
  --sidebar-w: 260px;
}

/* DARK (asosiy) */
:root, [data-theme="dark"] {
  --bg: #0E0F13;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(124, 58, 237, 0.10), transparent 60%),
             radial-gradient(1000px 500px at -10% 10%, rgba(220, 4, 175, 0.08), transparent 55%);
  --surface: #16181F;
  --surface-2: #1E212B;
  --surface-3: #262A36;
  --border: #2A2E3A;
  --text: #E7E9EE;
  --muted: #9AA0AD;
  --muted-2: #6B7280;
}

/* LIGHT */
[data-theme="light"] {
  --bg: #F4F5F8;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(124, 58, 237, 0.06), transparent 60%),
             radial-gradient(1000px 500px at -10% 10%, rgba(220, 4, 175, 0.10), transparent 55%);
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #EEF0F4;
  --border: #E4E7EC;
  --text: #1A1D24;
  --muted: #6B7280;
  --muted-2: #9AA0AD;
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--brand-soft); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 20px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px 34px;
  box-shadow: var(--shadow);
  animation: rise .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
/* Logo rasmlari — tema bo'yicha almashadi (oq/magenta) */
.brand-img { width: auto; display: block; }
.theme-light { display: none; }
[data-theme="light"] .theme-dark { display: none; }
[data-theme="light"] .theme-light { display: block; }

.login-logo-wrap { display: flex; justify-content: center; margin-bottom: 8px; }
.login-logo-wrap .brand-img { height: 46px; }
.login-card h1 { text-align: center; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.login-card .sub { text-align: center; color: var(--muted); margin-top: 10px; margin-bottom: 26px; font-size: 13px; }

.touchid-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #ffffff; font-weight: 700; font-size: 15px;
  border: none; border-radius: var(--radius);
  padding: 15px; margin-bottom: 14px;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 6px 20px rgba(220, 4, 175, 0.28);
}
.touchid-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(220, 4, 175, 0.4); }
.touchid-btn:active { transform: translateY(0); }
.touchid-btn svg { width: 22px; height: 22px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: 12px; margin: 8px 0 16px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.pw-toggle { text-align: center; }
.pw-toggle button { background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; }

/* PIN pad */
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 20px 0 24px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border); transition: .2s; }
.pin-dot.filled { background: var(--brand); border-color: var(--brand); transform: scale(1.1); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-key {
  aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 22px; font-weight: 600;
  display: grid; place-items: center; transition: .12s; max-width: 74px; margin: 0 auto; width: 100%;
}
.pin-key:hover { background: var(--surface-3); }
.pin-key:active { transform: scale(.93); background: var(--brand-soft); }
.pin-key.wide { font-size: 14px; font-weight: 500; }

/* ============================================================
   FORMALAR
   ============================================================ */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px; color: var(--text); font-size: 14px;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: 14px; font-weight: 600;
  transition: .15s;
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #ffffff; border: none; }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 6px 18px rgba(220, 4, 175, 0.3); }
.btn-danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

.err-msg { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; min-height: 18px; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app { display: none; min-height: 100vh; }
.app.active { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
/* Backdrop faqat mobil menyu uchun — desktopda grid'ni buzmasligi kerak */
.sidebar-backdrop { display: none; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; padding: 8px 10px 2px; }
.brand .brand-img { height: 28px; }
.brand-sub { font-size: 10px; color: var(--muted); font-weight: 600; letter-spacing: .22em; padding: 2px 12px 20px; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--radius-sm); color: var(--muted);
  font-weight: 500; font-size: 14px; transition: .13s; border: 1px solid transparent;
}
.nav-item .ico { font-size: 18px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); border-color: rgba(220, 4, 175, 0.2); font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3);
  display: grid; place-items: center; font-weight: 700; color: var(--brand);
}
.user-chip .info { flex: 1; min-width: 0; }
.user-chip .info b { font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .info span { font-size: 11px; color: var(--muted); }

/* MAIN */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px); z-index: 20;
}
.topbar .burger { display: none; }
.page-title { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.page-title small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; font-size: 17px; color: var(--text);
}

.content { padding: 26px; flex: 1; }

/* ============================================================
   CARDS / GRID
   ============================================================ */
.grid { display: grid; gap: 16px; }
.stat-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 16px; font-weight: 700; }
.card-head .btn { margin-left: auto; }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after { content: ''; position: absolute; inset: 0 0 auto auto; width: 80px; height: 80px;
  background: radial-gradient(circle, var(--accent, var(--brand-soft)), transparent 70%); opacity: .5; }
.stat .stat-ico { font-size: 22px; margin-bottom: 10px; display: inline-block; }
.stat .stat-label { color: var(--muted); font-size: 13px; }
.stat .stat-val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .stat-val small { font-size: 14px; font-weight: 600; color: var(--muted); }
.stat .stat-sub { font-size: 12px; margin-top: 6px; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 12px 14px; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .1s; }
table.tbl tbody tr:hover { background: var(--surface-2); }
.tbl-empty { text-align: center; color: var(--muted); padding: 40px !important; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-green { background: rgba(34, 197, 94, 0.14); color: var(--success); }
.badge-red { background: rgba(239, 68, 68, 0.14); color: var(--danger); }
.badge-gold { background: var(--brand-soft); color: var(--brand); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-blue { background: rgba(14, 165, 233, 0.14); color: var(--info); }
.badge-purple { background: rgba(124, 58, 237, 0.16); color: var(--purple); }
.badge-gray { background: var(--surface-3); color: var(--muted); }
.badge-warn { background: rgba(245, 158, 11, 0.16); color: var(--warn); }

.pill-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.money-pos { color: var(--success); font-weight: 700; }
.money-neg { color: var(--danger); font-weight: 700; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px);
  display: none; place-items: center; z-index: 100; padding: 20px; animation: fade .2s;
}
.modal-bg.active { display: grid; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow);
  animation: rise .25s;
}
.modal-head { display: flex; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-head .x { margin-left: auto; background: var(--surface-2); border: none; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); font-size: 18px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Toast */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand);
  border-radius: 12px; padding: 13px 18px; box-shadow: var(--shadow); min-width: 260px; max-width: 380px;
  animation: slideIn .25s; font-size: 13.5px; font-weight: 500;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* Segmented / tabs */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; border: 1px solid var(--border); width: fit-content; }
.tab { padding: 8px 16px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 13px; border: none; background: none; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
.search-input { max-width: 240px; }

/* Chart (simple bars) */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar { width: 40%; border-radius: 6px 6px 0 0; min-height: 3px; transition: height .4s; }
.bar.inc { background: linear-gradient(180deg, var(--success), rgba(34, 197, 94, 0.4)); }
.bar.exp { background: linear-gradient(180deg, var(--danger), rgba(239, 68, 68, 0.4)); }
.bar-label { font-size: 11px; color: var(--muted); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .big { font-size: 44px; margin-bottom: 12px; }

.qty-ctl { display: inline-flex; align-items: center; gap: 8px; }
.qty-ctl button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 16px; }
.qty-ctl span { min-width: 22px; text-align: center; font-weight: 700; }

.cart-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cart-line:last-child { border: none; }

.menu-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface-2); transition: .13s;
}
.menu-item:hover { border-color: var(--brand); }
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-col { display: flex; flex-direction: column; gap: 10px; }

/* Responsive */
@media (max-width: 900px) {
  .app.active { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 90; width: 260px; transform: translateX(-100%);
    transition: transform .25s;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .topbar .burger { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 18px; }
  .content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 80; display: none; }
  .sidebar-backdrop.show { display: block; }
}
