/* FLIGHT HUNTER Mini App — follows the Telegram theme (light / dark) via themeParams CSS variables. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f7);
  --text: var(--tg-theme-text-color, #0f1419);
  --hint: var(--tg-theme-hint-color, #7a828c);
  --accent: var(--tg-theme-button-color, #2a7ae2);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2a7ae2);
  --danger: var(--tg-theme-destructive-text-color, #d93a3a);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {   /* outside Telegram only; inside, Telegram's theme variables win */
    --bg: #17191d; --bg2: #0e0f12; --text: #f2f4f7; --hint: #8e96a1; --accent: #4a94f0; --card: #1f2227;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); min-height: 100vh; }
[hidden] { display: none !important; }

.hero { padding: 28px 4px 16px; }
.hero h1 { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; }
.hero p { margin: 8px 0 0; color: var(--hint); }
.hero.small { padding-top: 20px; }
.hero.small h1 { font-size: 26px; }

.card { background: var(--card); border-radius: var(--radius); padding: 6px; margin-bottom: 12px; }
.form { position: relative; }
.field { display: flex; flex-direction: column; width: 100%; min-height: 64px; padding: 10px 14px; border-radius: 12px; }
.field:active { background: var(--bg2); }
.form > .field + .field, .row2 { border-top: 1px solid var(--line); }
.label { font-size: 13px; color: var(--hint); }
.value { font-size: 18px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.value.placeholder { color: var(--hint); font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1.4fr 1fr; }
.row2 .field + .field { border-left: 1px solid var(--line); }
.swap { position: absolute; right: 16px; top: 46px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg2); color: var(--accent); font-size: 20px; display: grid; place-items: center; z-index: 1; }

.primary { display: block; width: 100%; padding: 14px; border-radius: 14px; background: var(--accent);
  color: var(--accent-text); font-weight: 650; text-align: center; font-size: 17px; }
.primary.big { padding: 18px; font-size: 18px; margin-top: 8px; }
.primary:disabled { opacity: .45; }
.secondary { display: block; width: 100%; padding: 13px; border-radius: 14px; background: var(--bg2);
  color: var(--link); font-weight: 600; text-align: center; }
.danger { color: var(--danger); }
.link-btn { color: var(--link); font-weight: 600; padding: 10px 4px; }
#filters-count:not(:empty) { background: var(--accent); color: var(--accent-text); border-radius: 10px;
  padding: 1px 7px; font-size: 13px; margin-left: 4px; }
.error { color: var(--danger); margin: 6px 4px; }
.muted { color: var(--hint); }
.small { font-size: 14px; }
.note { color: var(--hint); font-size: 14px; margin: 12px 4px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px;
  color: var(--hint); padding: 6px 0; text-align: center; }
.tabbar button span { font-size: 22px; filter: grayscale(1); opacity: .7; }
.tabbar button.on { color: var(--accent); font-weight: 600; }
.tabbar button.on span { filter: none; opacity: 1; }

.bar { display: flex; align-items: center; gap: 8px; padding: 14px 0 10px; }
.bar h2 { margin: 0; font-size: 20px; }
.bar p { margin: 2px 0 0; color: var(--hint); font-size: 14px; }
.back { font-size: 30px; line-height: 1; width: 36px; height: 36px; color: var(--accent); flex: none; text-align: center; }

.offer { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.offer .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.offer .price { font-size: 24px; font-weight: 750; letter-spacing: -0.01em; }
.offer .per { color: var(--hint); font-size: 13px; }
.offer .meta { color: var(--hint); font-size: 14px; margin: 4px 0 10px; }
.offer .bag { font-size: 13px; color: var(--hint); margin-bottom: 10px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 8px; background: var(--bg2); color: var(--hint); }
.ad { font-size: 12px; color: var(--hint); margin-top: 8px; }
.empty { background: var(--card); border-radius: var(--radius); padding: 22px 16px; text-align: center; }
.empty .big-emoji { font-size: 40px; }
.empty h3 { margin: 6px 0; }
.sticky-actions { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); padding: 8px 0; }
.sheet .sticky-actions { bottom: 0; background: var(--bg); }

.track { display: block; width: 100%; background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.track h3 { margin: 0 0 2px; font-size: 17px; }
.track .row { display: flex; justify-content: space-between; color: var(--hint); font-size: 14px; }
.track .best { color: var(--text); font-weight: 650; }
.actions { display: grid; gap: 8px; margin: 12px 0 20px; }

.hist { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 8px 4px 0; }
.hist .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.hist .bar-v { width: 100%; max-width: 26px; background: var(--accent); border-radius: 6px 6px 2px 2px; opacity: .85; }
.hist .d { font-size: 11px; color: var(--hint); margin-top: 4px; white-space: nowrap; }
.hist-list { font-size: 14px; color: var(--hint); margin: 8px 4px 2px; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; display: flex; align-items: flex-end; }
.sheet-body { background: var(--bg); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
.sheet-body.full { height: 100vh; max-height: 100vh; border-radius: 0; padding-top: 0; }
.sheet h2 { margin: 6px 0 14px; font-size: 21px; }
#pl-input { width: 100%; font: inherit; font-size: 18px; padding: 14px; border-radius: 12px; border: 0;
  background: var(--bg2); color: var(--text); outline: none; margin-bottom: 8px; }
.list .li, .place { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  padding: 14px 10px; border-bottom: 1px solid var(--line); }
.place b { font-weight: 600; }
.place small, .li .muted { color: var(--hint); font-size: 13px; text-align: right; }
.place .codes { color: var(--hint); font-size: 13px; }
.group-title { font-size: 13px; color: var(--hint); padding: 14px 10px 4px; text-transform: uppercase; letter-spacing: .04em; }
.chev { color: var(--hint); font-size: 22px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg2); border-radius: 12px; padding: 3px; margin: 6px 0 10px; }
.seg button { text-align: center; padding: 9px 4px; border-radius: 10px; font-size: 14px; color: var(--hint); }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.chips button { padding: 9px 14px; border-radius: 20px; background: var(--bg2); font-size: 15px; }
.chips button.on { background: var(--accent); color: var(--accent-text); }

.cal .month { margin: 10px 0 18px; }
.cal .mtitle { font-weight: 650; margin: 0 4px 8px; text-transform: capitalize; }
.cal .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--hint); padding-bottom: 4px; }
.cal .day { height: 44px; border-radius: 10px; text-align: center; font-size: 16px; }
.cal .day:disabled { color: var(--hint); opacity: .35; }
.cal .day.in { background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 0; }
.cal .day.sel { background: var(--accent); color: var(--accent-text); font-weight: 700; border-radius: 10px; }

.stepper { display: grid; grid-template-columns: 1fr 44px 36px 44px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stepper small { display: block; color: var(--hint); font-size: 13px; }
.stepper button { width: 44px; height: 44px; border-radius: 50%; background: var(--bg2); color: var(--accent); font-size: 22px; text-align: center; }
.stepper span { text-align: center; font-size: 18px; font-weight: 600; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.field-input { display: block; margin: 12px 0 6px; }
.field-input span { display: block; font-size: 14px; color: var(--hint); margin-bottom: 6px; }
.field-input input { width: 100%; font: inherit; font-size: 18px; padding: 13px; border-radius: 12px; border: 0; background: var(--bg2); color: var(--text); }
.sheet-body > .primary { margin-top: 16px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(20,22,26,.92); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 20; font-size: 15px; max-width: 90%; }
.skeleton { height: 108px; border-radius: var(--radius); background: var(--card); margin-bottom: 10px; animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* pushed screens cover the tab they were opened from */
.view { position: fixed; inset: 0; z-index: 4; overflow-y: auto; background: var(--bg2);
  padding: 0 16px calc(170px + env(safe-area-inset-bottom)); }
.view > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.view .sticky-actions { position: fixed; left: 0; right: 0; bottom: calc(68px + env(safe-area-inset-bottom));
  padding: 10px 16px; background: linear-gradient(to top, var(--bg2) 70%, transparent); }
.view .sticky-actions > * { max-width: 528px; margin: 0 auto; }
.row2 { grid-template-columns: 1.35fr 1fr; }
.row2 .field { border-radius: 0; }
.row2 .field:first-child { border-bottom-left-radius: 12px; }
.row2 .field:last-child { border-bottom-right-radius: 12px; }
.row2 .value { font-size: 17px; }
.view .secondary, #tab-tracks .secondary { background: var(--card); }
