/* Ovozchi admin — dizayn tizimi */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f4f5f8);
  --surface: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0f172a);
  --muted: var(--tg-theme-hint-color, #7c8597);
  --accent: var(--tg-theme-button-color, #4f6bff);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --danger: #e5484d;
  --success: #12a150;
  --warning: #e88a0c;
  --border: color-mix(in srgb, var(--text) 8%, transparent);
  --subtle: color-mix(in srgb, var(--text) 4.5%, transparent);
  --tint: color-mix(in srgb, var(--accent) 11%, transparent);
  --tint-strong: color-mix(in srgb, var(--accent) 18%, transparent);
  --r-lg: 20px; --r-md: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 400 14px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; letter-spacing: -.006em; }
#app { max-width: 640px; margin: 0 auto; padding: 14px 14px calc(70px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 14px; height: 14px; }
svg.i.lg { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- sarlavha */
.topbar { display: flex; align-items: center; gap: 12px; margin: 2px 2px 16px; }
.topbar .avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 600;
  font-size: 14px; color: var(--on-accent); background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #a855f7)); }
.topbar .who { flex: 1; min-width: 0; }
.topbar .hello { font-size: 12px; color: var(--muted); }
.topbar .name { font-size: 16px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 4px 9px;
  border-radius: 999px; background: var(--tint); color: var(--accent); }
h1.title { font-size: 20px; font-weight: 650; letter-spacing: -.025em; margin: 4px 2px 4px; }
.lead { font-size: 13px; color: var(--muted); margin: 0 2px 14px; }
.label { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 4px 8px; }

/* ----------------------------------------------------------------- kartalar */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.card.flush { padding: 4px 14px; }
.bento { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; }
.bento .stack { display: grid; gap: 10px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-height: 92px; }
.metric .head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 500; }
.metric .chip { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--subtle); color: var(--text); }
.metric .value { font-size: 24px; font-weight: 650; letter-spacing: -.03em; line-height: 1; }
.metric.primary { background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #a855f7)); color: var(--on-accent); border: 0; }
.metric.primary .head { color: color-mix(in srgb, var(--on-accent) 80%, transparent); }
.metric.primary .chip { background: rgba(255, 255, 255, .18); color: var(--on-accent); }
.metric.primary .value { font-size: 32px; }
.metric .foot { font-size: 11.5px; opacity: .8; }

/* ixcham statistika: bitta qatorda uchta karta */
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 10px 11px;
  box-shadow: var(--shadow); min-width: 0; }
.mini .chip { position: absolute; top: 9px; right: 9px; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  background: var(--subtle); color: var(--muted); }
.mini .chip svg { width: 12px; height: 12px; }
.mini .v { font-size: 19px; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; margin-top: 2px; }
.mini .k { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini.primary { background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #a855f7)); color: var(--on-accent); border: 0; }
.mini.primary .k { color: color-mix(in srgb, var(--on-accent) 78%, transparent); }
.mini.primary .chip { background: rgba(255, 255, 255, .18); color: var(--on-accent); }

/* ------------------------------------------------------- so'rovnomalar ro'yxati */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer; }
.item + .item { border-top: 1px solid var(--border); }
.item:active { opacity: .6; }
.thumb { width: 44px; height: 44px; border-radius: 12px; flex: none; overflow: hidden; display: grid; place-items: center;
  background: var(--tint); color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 3px; }
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.chev { color: var(--muted); opacity: .6; }

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.active { color: var(--success); }
.status.active::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent); }
.status.stopped, .status.ended { color: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.badge.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ------------------------------------------------------------------ tugmalar */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 46px; padding: 0 16px;
  border: 0; border-radius: var(--r-md); font: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.01em; cursor: pointer;
  background: var(--accent); color: var(--on-accent); transition: transform .15s var(--ease), opacity .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.secondary { background: var(--tint); color: var(--accent); }
.btn.ghost { background: var(--subtle); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.btn.sm { height: 34px; width: auto; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-sm); gap: 6px; }
.btn.icon { width: 34px; height: 34px; padding: 0; border-radius: var(--r-sm); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions .full { grid-column: span 2; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

/* -------------------------------------------------------------------- forma */
.field { margin-top: 14px; }
.field:first-child { margin-top: 0; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 2px 6px; }
input, textarea, select { width: 100%; font: inherit; font-size: 14px; color: var(--text); background: var(--subtle);
  border: 1px solid transparent; border-radius: var(--r-md); padding: 11px 13px; outline: none; transition: border-color .15s, background .15s; }
input:focus, textarea:focus, select:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { min-height: 128px; resize: vertical; line-height: 1.5; }
.search { position: relative; margin-bottom: 10px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; background: var(--surface); border-color: var(--border); }
.hint { font-size: 12px; color: var(--muted); margin: 6px 2px 0; }
.counter { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 5px; }
.counter.over { color: var(--danger); font-weight: 600; }

.drop { position: relative; display: grid; place-items: center; gap: 8px; min-height: 148px; border-radius: var(--r-lg);
  border: 1.5px dashed color-mix(in srgb, var(--text) 16%, transparent); background: var(--subtle); color: var(--muted);
  text-align: center; font-size: 13px; overflow: hidden; cursor: pointer; }
.drop .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.drop img { width: 100%; max-height: 280px; object-fit: cover; display: block; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.filled { border-style: solid; border-color: var(--border); min-height: 0; }

.toggle-row { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.toggle-row .body { flex: 1; }
.toggle-row .t { font-weight: 550; }
.toggle-row .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 26px; background: color-mix(in srgb, var(--text) 16%, transparent); transition: .2s var(--ease); }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch input:checked + i { background: var(--success); }
.switch input:checked + i::after { transform: translateX(18px); }

/* -------------------------------------------------------------------- stepper */
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 2px 0 16px; }
.stepper div { font-size: 11px; font-weight: 600; color: var(--muted); }
.stepper div::before { content: ""; display: block; height: 4px; border-radius: 4px; background: var(--border); margin-bottom: 6px; transition: background .3s; }
.stepper div.on { color: var(--accent); }
.stepper div.on::before { background: var(--accent); }

.parts { counter-reset: p; }
.part { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.part + .part { border-top: 1px solid var(--border); }
.part .n { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
  background: var(--tint); color: var(--accent); flex: none; }
.part .name { flex: 1; min-width: 0; word-break: break-word; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; }

/* ------------------------------------------------- Telegram ko'rinishidagi namuna */
.tg-frame { border-radius: var(--r-lg); padding: 14px 12px; background:
  radial-gradient(circle at 20% 20%, #b7d3a8 0, transparent 45%), radial-gradient(circle at 80% 70%, #9fc09a 0, transparent 50%), #a9c79d; }
.tg-msg { max-width: 380px; margin: 0 auto; background: #fff; color: #111; border-radius: 16px 16px 16px 6px; overflow: hidden; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.tg-msg img { width: 100%; display: block; }
.tg-msg .tx { padding: 8px 11px 9px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.4; }
.tg-btns { max-width: 380px; margin: 3px auto 0; display: grid; gap: 3px; }
.tg-btns div { background: rgba(60, 92, 52, .45); color: #fff; text-align: center; font-size: 13px; font-weight: 600; padding: 8px; border-radius: 9px; backdrop-filter: blur(6px); }

/* ------------------------------------------------------------------- natijalar */
.hero-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--r-lg); display: block; margin-bottom: 12px; }
.poll-text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.55; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kpi { background: var(--subtle); border-radius: var(--r-md); padding: 10px; }
.kpi .v { font-size: 16px; font-weight: 650; letter-spacing: -.02em; }
.kpi .k { font-size: 11px; color: var(--muted); margin-top: 1px; }
.res { padding: 11px 0; }
.res + .res { border-top: 1px solid var(--border); }
.res .top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.res .rank { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: 11px; font-weight: 650;
  background: var(--subtle); color: var(--muted); flex: none; }
.res.first .rank { background: linear-gradient(140deg, #f5c542, #e88a0c); color: #fff; }
.res .name { flex: 1; min-width: 0; font-weight: 500; word-break: break-word; }
.res .val { font-weight: 650; white-space: nowrap; }
.res .val small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.track { height: 6px; border-radius: 6px; background: var(--subtle); overflow: hidden; margin-left: 32px; }
.track i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--accent); transition: width .8s var(--ease); }
.res.first .track i { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #a855f7)); }

.notice { display: flex; gap: 12px; padding: 13px 14px; border-radius: var(--r-lg); margin-bottom: 10px; font-size: 13px;
  background: color-mix(in srgb, var(--warning) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); }
.notice .ic { color: var(--warning); margin-top: 1px; }
.notice b { display: block; font-weight: 600; margin-bottom: 2px; }

/* ------------------------------------------------------------- ro'yxat qatorlari */
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.row-item + .row-item { border-top: 1px solid var(--border); }
.row-item .body { flex: 1; min-width: 0; }
.row-item .t { font-weight: 550; word-break: break-word; }
.row-item.off { opacity: .45; }
.lead-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--subtle); color: var(--text); flex: none; }
.menu .row-item { cursor: pointer; }
.menu .row-item:active { opacity: .6; }
.menu .lead-ic { background: var(--tint); color: var(--accent); }
.menu .d { font-size: 12px; color: var(--muted); }

.empty { display: grid; place-items: center; gap: 10px; text-align: center; padding: 34px 16px; color: var(--muted); font-size: 13px; }
.empty .ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--tint); color: var(--accent); }
.empty b { color: var(--text); font-size: 15px; font-weight: 600; }

/* segment (ikki bo'limli tugma) */
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--subtle); margin-bottom: 10px; }
.seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; border: 0;
  border-radius: 9px; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }

/* ----------------------------------------------------------------- skelet */
.sk { border-radius: var(--r-md); background: linear-gradient(90deg, var(--subtle) 25%, color-mix(in srgb, var(--text) 8%, transparent) 50%, var(--subtle) 75%);
  background-size: 200% 100%; animation: sk 1.3s ease infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* --------------------------------------------------------------- pastki menyu */
/* pastki menyu: ekranning eng pastiga yopishgan, ingichka, butun kenglikda */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  padding: 3px 8px env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-top: 1px solid var(--border); backdrop-filter: blur(18px) saturate(1.6); }
.tabbar button { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 4px 4px;
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 10px; font-weight: 600; cursor: pointer;
  position: relative; transition: color .2s; }
.tabbar button svg.i.lg { width: 20px; height: 20px; }
.tabbar button.on { color: var(--accent); }
.tabbar button.on::before { content: ""; position: absolute; top: -3px; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 14px; background: rgba(15, 23, 42, .92); color: #fff; font-size: 13px;
  font-weight: 500; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .25s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { color: #4ade80; }
.toast.err svg { color: #f87171; }

.fade { animation: fade .28s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
