/* iUz — owner admin panel. Guruh Mini App bilan BIR XIL dizayn tili
   (kroko/webapp/static/app.css), lekin bu ALOHIDA fayl/origin (auth.py
   docstring'idagi tahdid modeli) — qasddan nusxalanmagan, mustaqil.

   Harakat tizimi: faqat transform/opacity (GPU friendly), spring/standard
   easing, prefers-reduced-motion bilan o'chiriladi (fayl oxirida). */

:root {
  --bg: #f0f8f7;
  --surface: #ffffff;
  --surface-2: #e6f3f2;
  --surface-3: #f4fbfa;
  --text: #063a42;
  --muted: #5c7a80;
  --line: #d7ecec;
  --brand: #0d9a9d;
  --brand-2: #36e0cc;
  --accent: #d98f28;
  --accent-soft: #ffeab0;
  --accent-mid: #f0b84a;
  --danger: #e5484d;
  --danger-soft: #fbe2e2;
  --header-grad-1: #0e5f6b;
  --header-grad-2: #0a3b52;
  --shadow: 0 2px 14px rgba(10, 50, 60, .08);
  --shadow-lg: 0 10px 30px rgba(8, 40, 48, .16);
  --radius: 16px;
  --radius-lg: 22px;
  --gap: 12px;
  --tabbar-h: 60px;
  --topbar-h: 50px;
  color-scheme: light;

  --ease-spring: cubic-bezier(.34, 1.42, .4, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  --dur-1: 120ms;
  --dur-2: 220ms;
  --dur-3: 380ms;
}

:root[data-theme="dark"] {
  --bg: #063a42;
  --surface: #0d4a54;
  --surface-2: #0a3b52;
  --surface-3: #0f525d;
  --text: #f3fbfa;
  --muted: #9fd6d2;
  --line: #155861;
  --brand: #36e0cc;
  --brand-2: #0d9a9d;
  --accent: #f0b84a;
  --accent-soft: #ffeab0;
  --accent-mid: #f0b84a;
  --danger: #ef5b60;
  --danger-soft: rgba(239, 91, 96, .16);
  --shadow: 0 2px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #063a42; --surface: #0d4a54; --surface-2: #0a3b52; --surface-3: #0f525d; --text: #f3fbfa;
    --muted: #9fd6d2; --line: #155861; --brand: #36e0cc; --brand-2: #0d9a9d;
    --accent: #f0b84a; --accent-soft: #ffeab0; --accent-mid: #f0b84a; --danger: #ef5b60;
    --danger-soft: rgba(239, 91, 96, .16);
    --shadow: 0 2px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 14px 34px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  /* Tepa joy = sarlavhaning HAQIQIY balandligi (JS o'lchaydi): soat qatori + Telegram tugmalari
     + sarlavha qatori. Avval ikkalasi alohida hisoblanib, sarlavha soat ostiga kirib, kontent esa
     juda pastga tushib ketardi (2026-10-16, iPhone). */
  padding: calc(var(--header-h, calc(var(--topbar-h) + var(--top-inset, 0px))) + 10px) 14px
           calc(var(--tabbar-h) + 18px);
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background .25s var(--ease-standard), color .25s var(--ease-standard);
}

button, input, select, textarea { font-family: inherit; }

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2.5px solid var(--brand-2); outline-offset: 2px; border-radius: 8px;
}

#boot, #telegram-only, #need-ticket {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center;
  background: linear-gradient(160deg, var(--header-grad-1), var(--header-grad-2));
  color: #fff; z-index: 50; padding: 24px;
}
.boot-logo {
  width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 10px 26px rgba(2, 24, 28, .4);
  animation: boot-breathe 2.6s var(--ease-standard) infinite;
}
@keyframes boot-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
#telegram-only h1, #need-ticket h1 { font-size: 19px; margin: 6px 0; }
#telegram-only p, #need-ticket p { color: rgba(255, 255, 255, .8); font-size: 14px; max-width: 320px; }
#telegram-only code { background: rgba(255, 255, 255, .15); padding: 2px 6px; border-radius: 6px; }

h1 { font-size: 19px; margin: 8px 0 12px; font-weight: 700; }
h2 { font-size: 14px; margin: 0 0 10px; color: var(--text); font-weight: 700; }

.page { padding-top: 2px; }
.page.pg-enter { animation: pg-in var(--dur-3) var(--ease-out) both; }
@keyframes pg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: var(--gap);
}

.note { color: var(--muted); font-size: 13px; margin: 6px 0; }

.skeleton {
  height: 52px; border-radius: 12px; margin-bottom: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ─── Topbar ─── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  min-height: calc(var(--topbar-h) + var(--top-inset, 0px));
  /* soat qatori + Telegram "Yopish/…" tugmalari bandi bo'sh qoladi, sarlavha undan PASTDA */
  padding: var(--top-inset, 0px) 10px 0 14px;
  background: linear-gradient(90deg, var(--header-grad-1), var(--header-grad-2));
  color: #fff; display: flex; align-items: center; gap: 10px;
  z-index: 15; box-shadow: var(--shadow);
}
.topbar-logo { width: 22px; height: 22px; border-radius: 6px; }
.topbar-title { font-weight: 700; font-size: 15px; flex: 1; letter-spacing: -.01em; }
.icon-btn {
  background: rgba(255, 255, 255, .14); border: none; color: #fff; width: 36px; height: 36px;
  border-radius: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--dur-1) var(--ease-standard), transform var(--dur-1) var(--ease-standard);
}
.icon-btn:active { transform: scale(.92); background: rgba(255, 255, 255, .24); }
.icon-btn svg { width: 18px; height: 18px; }

/* ─── KPI ─── */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 4px; }
@media (min-width: 420px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px;
  opacity: 0; transform: translateY(8px);
  animation: stagger-in var(--dur-3) var(--ease-out) forwards;
}
@keyframes stagger-in { to { opacity: 1; transform: none; } }
.kpi .k-val { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.kpi .k-lab { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi .k-delta {
  display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700;
  margin-top: 6px; padding: 2px 7px; border-radius: 999px;
}
.kpi .k-delta.up { color: var(--brand); background: rgba(13, 154, 157, .13); }
.kpi .k-delta.down { color: var(--danger); background: var(--danger-soft); }
.kpi .k-delta.flat { color: var(--muted); background: var(--surface-2); }

/* ─── Charts (smooth inline SVG, gradient fill, tooltip) ─── */
.chart-wrap { position: relative; touch-action: pan-y; }
.chart-svg { width: 100%; height: 108px; display: block; overflow: visible; }
.chart-svg .area { opacity: .9; }
.chart-svg .line {
  fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}
.chart-svg .line.drawing { transition: stroke-dashoffset 1.1s var(--ease-out); }
.chart-svg .dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2.2; }
.chart-svg .hit { fill: transparent; }
.chart-svg .cursor-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart-svg .cursor-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; opacity: 0; }
.chart-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.chart-tooltip {
  position: absolute; top: 2px; pointer-events: none; background: var(--text); color: var(--bg);
  font-size: 11.5px; font-weight: 700; padding: 4px 8px; border-radius: 8px; white-space: nowrap;
  opacity: 0; transform: translate(-50%, -4px); transition: opacity var(--dur-1) var(--ease-standard);
  z-index: 2; box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}
.chart-tooltip.show { opacity: 1; }
.chart-tooltip .tt-sub { font-weight: 500; opacity: .75; margin-left: 5px; }

.bar-list .bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.bar-list .bar-name { width: 70px; flex-shrink: 0; color: var(--muted); text-transform: uppercase; font-size: 11px; }
.bar-list .bar-track { flex: 1; height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar-list .bar-fill {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 6px;
  transition: width var(--dur-3) var(--ease-out);
}
.bar-list .bar-val { width: 34px; text-align: right; flex-shrink: 0; font-weight: 700; }

/* ─── Funnel (referral) ─── */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-step { display: flex; align-items: center; gap: 10px; }
.funnel-step .f-label { width: 128px; flex-shrink: 0; font-size: 12px; color: var(--muted); }
.funnel-step .f-bar-track { flex: 1; height: 28px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.funnel-step .f-bar-fill {
  height: 100%; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px;
  min-width: 36px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); border-radius: 8px;
  color: #fff; font-weight: 700; font-size: 12px; transition: width var(--dur-3) var(--ease-out);
}
.funnel-step .f-pct { width: 44px; text-align: right; flex-shrink: 0; font-size: 12px; color: var(--muted); }

/* ─── Lists / rows ─── */
.list { display: flex; flex-direction: column; gap: 6px; }
.row-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  padding: 11px 12px; cursor: pointer; min-height: 44px;
  opacity: 0; transform: translateY(6px);
  animation: stagger-in var(--dur-2) var(--ease-out) forwards;
  transition: transform var(--dur-1) var(--ease-standard);
}
.row-item:active { transform: scale(.985); }
.row-item .r-left { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.row-item .r-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.row-item .r-sub { font-size: 12px; color: var(--muted); }
.row-item .r-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; font-weight: 700; color: var(--brand); }
.badge {
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.badge.on { background: var(--brand); color: #fff; }
.badge.warn { background: var(--accent); color: #fff; }
.badge.danger { background: var(--danger); color: #fff; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; font-size: 14px; }

/* ─── Toolbar / inputs (umumiy — qayerda bo'lishidan qat'i nazar bir xil) ─── */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }

input[type="text"], input[type="url"], input[type="number"],
input[type="datetime-local"], textarea, select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; min-height: 42px;
  transition: border-color var(--dur-2) var(--ease-standard), background var(--dur-2) var(--ease-standard);
}
input[type="text"], input[type="url"] { width: 100%; min-width: 0; }
.toolbar input[type="text"] { flex: 1; }
textarea { width: 100%; margin-top: 6px; resize: vertical; }
input[type="number"], input[type="datetime-local"] { width: 100%; margin-top: 6px; }
select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235c7a80' stroke-width='2'%3E%3Cpath d='M5 8l5 5 5-5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}
::placeholder { color: var(--muted); opacity: .75; }

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(.45) sepia(1) saturate(4) hue-rotate(140deg) brightness(.95);
  cursor: pointer; border-radius: 4px;
}
:root[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(.85) sepia(1) saturate(4) hue-rotate(140deg) brightness(1.15);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(.85) sepia(1) saturate(4) hue-rotate(140deg) brightness(1.15);
  }
}

.field-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; min-height: 44px;
}
.field-row select, .field-row input[type="number"] { width: auto; min-width: 110px; margin-top: 0; }

/* ─── Custom toggle (bir xil guruh Mini App bilan) ─── */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; min-height: 44px; }
.switch-toggle { position: relative; width: 46px; height: 28px; flex-shrink: 0; }
.switch-toggle input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-toggle .track {
  position: absolute; inset: 0; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line);
  transition: background var(--dur-2) var(--ease-standard), border-color var(--dur-2) var(--ease-standard);
}
.switch-toggle .thumb {
  position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch-toggle input:checked ~ .track { background: var(--brand); border-color: var(--brand); }
.switch-toggle input:checked ~ .track .thumb { transform: translateX(18px); }

.btn {
  width: 100%; padding: 12px; border-radius: 12px; border: none;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 700;
  cursor: pointer; margin-top: 8px; transition: transform var(--dur-1) var(--ease-standard), opacity var(--dur-2);
  min-height: 46px;
}
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; margin-top: 6px; min-height: 38px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { margin-top: 8px; }

.bc-button-row { display: flex; gap: 6px; margin-top: 6px; }
.bc-button-row input { flex: 1; margin-top: 0; }
.bc-preview { font-size: 13px; white-space: pre-wrap; word-break: break-word; }

.log-box {
  max-height: 260px; overflow-y: auto; background: var(--surface-2); border-radius: 10px;
  padding: 10px; font-size: 11px; line-height: 1.5; white-space: pre-wrap; word-break: break-all;
  color: var(--muted); margin: 0;
}

/* ─── Tabbar — ikonka-faqat (sarlavha allaqachon topbar'da), brend SVG
   to'plami (emoji EMAS — bir xil chiziq og'irligi/uslub). 8 ta bo'lim
   360px'da sig'maydigan bo'lsa gorizontal scroll + ikki chekkada xira
   (mask-image fade) "yana bor" signalini beradi. ─── */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar-h);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--tg-safe-area-inset-bottom, 0px));
  z-index: 20; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
#tabbar::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 58px; min-width: 58px; border: none; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; padding: 6px 2px; min-height: 44px;
  transition: color var(--dur-2) var(--ease-standard);
}
.tab svg { width: 21px; height: 21px; transition: transform var(--dur-2) var(--ease-spring); }
.tab .lb { font-size: 8.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab.on { color: var(--brand); }
.tab.bounce svg { animation: tab-bounce var(--dur-3) var(--ease-spring); }
@keyframes tab-bounce { 0% { transform: scale(1); } 40% { transform: scale(1.25) translateY(-2px); } 100% { transform: scale(1); } }

/* ─── Modal / konfirmatsiya varog'i (bottom sheet, spring) ─── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(2, 20, 24, .5); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease-standard);
}
#modal-overlay.show { opacity: 1; pointer-events: auto; }
#modal-box {
  background: var(--surface-3); border-radius: 22px 22px 0 0; padding: 18px; width: 100%;
  max-width: 480px; max-height: 80vh; overflow-y: auto;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform var(--dur-3) var(--ease-spring);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .3);
}
#modal-overlay.show #modal-box { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
#modal-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
#modal-title.danger-title { color: var(--danger); }
#modal-body p { margin: 0 0 8px; font-size: 14px; }
#modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
#modal-actions .btn { margin-top: 0; flex: 1 1 calc(50% - 4px); }

/* ─── Toast ─── */
#toast {
  position: fixed; left: 14px; right: 14px; bottom: calc(var(--tabbar-h) + 10px);
  background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: 12px;
  text-align: center; font-size: 13.5px; opacity: 0; transform: translateY(10px) scale(.98);
  transition: opacity var(--dur-2) var(--ease-spring), transform var(--dur-2) var(--ease-spring);
  pointer-events: none; z-index: 45; max-width: 480px; margin: 0 auto;
}
#toast.show { opacity: .98; transform: none; }
#toast.error { background: var(--danger); color: #fff; }

@media (min-width: 480px) {
  body { max-width: 480px; margin: 0 auto; }
  .topbar, #tabbar { max-width: 480px; margin: 0 auto; left: 0; right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* ─── Dashboard salomlashuv kartasi ─── */
.hero {
  position: relative; overflow: hidden; padding: 16px 16px 14px;
  background: linear-gradient(135deg, var(--header-grad-1), var(--header-grad-2)); color: #fff;
  animation: pg-in var(--dur-3) var(--ease-out) both;
}
.hero::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle, rgba(54, 224, 204, .35), transparent 70%);
  animation: hero-glow 4s var(--ease-standard) infinite;
}
@keyframes hero-glow { 0%, 100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.15); opacity: 1; } }
.hero-hi { font-size: 18px; font-weight: 700; margin: 0 0 2px; position: relative; z-index: 1; }
.hero-date { font-size: 12.5px; color: rgba(255, 255, 255, .72); margin: 0 0 10px; position: relative; z-index: 1; }
.hero-live { display: flex; align-items: center; gap: 8px; font-size: 13.5px; position: relative; z-index: 1; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #36E0CC; box-shadow: 0 0 0 0 rgba(54, 224, 204, .6);
  animation: live-pulse 1.8s ease-out infinite; flex: none; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(54, 224, 204, .6); } 100% { box-shadow: 0 0 0 10px rgba(54, 224, 204, 0); } }
@media (prefers-reduced-motion: reduce) { .hero, .hero::after, .live-dot { animation: none; } }
