/* Ranglar Telegram mavzusidan olinadi; Telegramdan tashqarida zaxira qiymatlar ishlaydi */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #eff1f5);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #14171c);
  --hint: var(--tg-theme-hint-color, #7d8693);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d93a2f);
  --ok: #24a05a;
  --warn: #d08a00;
  --line: color-mix(in srgb, var(--hint) 18%, transparent);
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.42 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
  overflow-wrap: anywhere;
}
main { padding: 12px 12px 4px; max-width: 720px; margin: 0 auto; }
h2 {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--hint); margin: 20px 6px 8px;
}
.muted { color: var(--hint); font-size: 13px; }
.small { font-size: 12px; }
.gap { height: 10px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }

/* Kartalar */
.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.card.note { color: var(--hint); font-size: 13px; background: transparent; border: 1px dashed var(--line); }
.card.empty { color: var(--hint); text-align: center; padding: 22px 14px; }
.actions { margin-top: 8px; flex-wrap: wrap; row-gap: 4px; }

/* Bosh holat kartasi */
.hero { border-radius: var(--radius); padding: 16px; color: #fff; background: var(--ok); }
.hero.warn { background: var(--warn); }
.hero.danger { background: var(--danger); }
.hero-title { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.hero-detail { opacity: .92; margin-top: 2px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13px; opacity: .92; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .3); }

/* Raqamli plitkalar */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.tile b { display: block; font-size: 26px; line-height: 1.15; font-weight: 700; }
.tile span { color: var(--hint); font-size: 13px; }
.tile.ok b { color: var(--ok); }
.tile.accent b { color: var(--accent); }

.icon {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  color: #fff; font-weight: 700; background: var(--hint);
}
.icon.ok { background: var(--ok); }
.icon.warn { background: var(--warn); }
.icon.danger { background: var(--danger); }

/* Tugma va maydonlar */
button, input, select { font: inherit; color: inherit; }
button {
  border: 0; border-radius: 10px; padding: 8px 14px; background: var(--accent);
  color: var(--accent-text); cursor: pointer; font-weight: 500;
}
button:active { opacity: .7; }
button.ghost { background: transparent; color: var(--accent); padding: 6px 8px; }
button.danger { background: transparent; color: var(--danger); padding: 6px 8px; }
button.wide { width: 100%; padding: 12px; }
button.picked { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
button.picked.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
button:disabled { opacity: .5; }
input, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; background: var(--bg);
  border: 1px solid transparent; outline: none;
}
input[type="search"] { background: var(--card); }
input:focus, select:focus { border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--hint); margin: 10px 0 4px; }
.form-row { display: flex; gap: 8px; align-items: flex-end; }
.form-row > * { flex: 1; }
.form-row > button, .form-row > .narrow { flex: 0 0 auto; }
.narrow input { width: 72px; }

/* Yoqish/o'chirish qatori */
label.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--text); font-size: 15px; margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line);
}
label.switch:last-of-type { border-bottom: 0; }
label.switch small { display: block; color: var(--hint); font-size: 12px; }
label.switch input { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--accent); }

/* Ichki yorliqlar */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: var(--card); color: var(--text); border-radius: 18px;
  padding: 7px 13px; font-size: 13px; font-weight: 500;
}
.chip.active { background: var(--accent); color: var(--accent-text); }

/* Belgilar */
.badge {
  display: inline-block; border-radius: 7px; padding: 2px 8px; font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--hint); white-space: nowrap;
}
.badge.published { background: var(--ok); color: #fff; }
.badge.candidate { background: var(--accent); color: var(--accent-text); }
.badge.driver_ad, .badge.publish_failed, .badge.too_long { background: var(--danger); color: #fff; }
.badge.duplicate, .badge.unclear, .badge.off_route { background: var(--warn); color: #fff; }

/* Xabar va namuna matnlari */
.msg-text { white-space: pre-wrap; margin: 8px 0 6px; max-height: 6.4em; overflow: hidden; }
.msg-text.open { max-height: none; }
.examples { margin-top: 8px; }
.example {
  white-space: pre-wrap; font-size: 13px; padding: 8px 10px; border-radius: 10px;
  background: var(--bg); margin-bottom: 6px; max-height: 7em; overflow: hidden;
}

/* Kalit so'zlar */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; background: var(--bg); border-radius: 16px; padding: 3px 4px 3px 11px; font-size: 14px; }
.tag-x { background: transparent; color: var(--hint); padding: 0 7px; font-size: 18px; line-height: 1.2; }

/* Pastki menyu */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; background: transparent; color: var(--hint); border-radius: 0;
  padding: 7px 2px 8px; font-size: 11px; font-weight: 500;
}
#tabs button span { display: block; font-size: 19px; line-height: 1.3; filter: grayscale(1); opacity: .7; }
#tabs button.active { color: var(--accent); }
#tabs button.active span { filter: none; opacity: 1; }
#toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom));
  background: #23272e; color: #fff; padding: 11px 14px; border-radius: 12px; text-align: center; z-index: 5;
}
#toast.error { background: var(--danger); }
.refresh { margin: 8px 6px 0; }

/* --- Qayta ishlangan bo'limlar uchun qo'shimcha uslublar --- */
textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; background: var(--bg); color: inherit;
  border: 1px solid transparent; outline: none; font: inherit; resize: vertical;
}
textarea:focus { border-color: var(--accent); }
.card.alert { border-left: 4px solid var(--warn); }
button.danger-fill { background: var(--danger); color: #fff; }
.badge.removed { background: var(--hint); color: #fff; }

/* Tezkor amallar */
.quick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.quick {
  background: var(--card); color: var(--text); border-radius: var(--radius); padding: 12px 6px;
  font-size: 13px; font-weight: 500; line-height: 1.25;
}
.quick span { display: block; font-size: 22px; margin-bottom: 4px; }

/* Statistika: davrni tanlash qatori */
.stat-nav { display: flex; align-items: center; gap: 8px; text-align: center; }
.stat-nav b { display: block; font-size: 16px; }
.stat-nav input[type="date"] { width: auto; max-width: 100%; margin-top: 6px; padding: 6px 10px; font-size: 13px; }
button.step {
  flex: 0 0 auto; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  background: var(--bg); color: var(--accent); font-size: 24px; line-height: 1;
}

/* Statistika jadvali: oraliq, xabarlar, jo'natma, yo'lovchi */
.card.stats { padding: 4px 14px; }
.stat-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 58px 66px 66px; column-gap: 6px;
  align-items: baseline; padding: 8px 0 6px; border-bottom: 1px solid var(--line);
}
.stat-row:last-child { border-bottom: 0; }
.stat-row.head { color: var(--hint); font-size: 12px; font-weight: 600; padding: 8px 0; }
.stat-row.link { cursor: pointer; }
.stat-row.current .when { font-weight: 600; }
.stat-row .when { font-variant-numeric: tabular-nums; }
.stat-row .when small { margin-left: 6px; color: var(--accent); font-size: 11px; font-weight: 600; }
.stat-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.stat-row .num.ok { color: var(--ok); font-weight: 700; }
.stat-row .num.accent { color: var(--accent); font-weight: 700; }
.stat-row .num.zero { color: var(--hint); opacity: .6; }
.volume { grid-column: 1 / -1; height: 3px; margin-top: 5px; border-radius: 2px; background: transparent; }
.volume span { display: block; height: 100%; min-width: 2px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 40%, transparent); }
.pad { padding: 14px 0; }
.hint { margin: 8px 6px 0; }

/* So'nggi e'lonlar ro'yxati */
.live-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.live-row:last-child { border-bottom: 0; }
.live-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }

/* Haydovchilar */
.phones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.phone { background: var(--bg); color: var(--text); border-radius: 16px; padding: 5px 11px; font-size: 14px; font-weight: 500; }

/* Filtrni sinash natijasi */
.check { display: flex; gap: 8px; padding: 3px 0; font-size: 14px; }
.check span:first-child { width: 16px; font-weight: 700; flex: 0 0 auto; }
.check.ok span:first-child { color: var(--ok); }
.check.bad span:first-child { color: var(--danger); }
.check.bad { color: var(--danger); }
.badge.passenger { background: var(--accent); color: var(--accent-text); }
.stat-row .when small.warn { color: var(--warn); }
