/*
 * Mini App styles.
 *
 * Surfaces and text follow Telegram's own theme (--tg-theme-*, kept current by the SDK), so the app
 * sits inside the client's palette. What Telegram does not supply — one accent and the three status
 * colours — is fixed here, with a light and a dark value each, chosen for contrast on both. The theme
 * is told to us by JS (data-theme) because the phone's setting and the Telegram theme can differ.
 *
 * Layout idea: the page is the secondary background, content sits in flat grouped lists on the
 * primary one. Only the "hero" of the home screen is a card in the usual sense.
 */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --page: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #14171a);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --line: rgba(127, 127, 127, .2);
  --fill: rgba(127, 127, 127, .1);
  --accent: #2f6fed;
  --on-accent: #ffffff;
  --accent-soft: rgba(47, 111, 237, .12);
  --ready: #17935a;
  --ready-soft: rgba(23, 147, 90, .13);
  --done: #7b8494;
  --warn: #c77700;
  --bad: #d23b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: var(--tg-theme-bg-color, #17212b);
    --page: var(--tg-theme-secondary-bg-color, #0e1621);
    --text: var(--tg-theme-text-color, #f3f5f7);
    --hint: var(--tg-theme-hint-color, #8b98a5);
    --accent: #5b93ff;
    --on-accent: #0b1220;
    --accent-soft: rgba(91, 147, 255, .16);
    --ready: #4cc38a;
    --ready-soft: rgba(76, 195, 138, .15);
    --done: #8b98a5;
    --warn: #f0a63a;
    --bad: #ff7a7a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: var(--tg-theme-bg-color, #17212b);
  --page: var(--tg-theme-secondary-bg-color, #0e1621);
  --text: var(--tg-theme-text-color, #f3f5f7);
  --hint: var(--tg-theme-hint-color, #8b98a5);
  --accent: #5b93ff;
  --on-accent: #0b1220;
  --accent-soft: rgba(91, 147, 255, .16);
  --ready: #4cc38a;
  --ready-soft: rgba(76, 195, 138, .15);
  --done: #8b98a5;
  --warn: #f0a63a;
  --bad: #ff7a7a;
  --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--page); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: var(--app-h, 100vh);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button { font: inherit; color: inherit; }
.app { max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; }
body.has-tabs .app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ── type ─────────────────────────────────────────── */
.title { font-size: 26px; line-height: 32px; font-weight: 650; letter-spacing: -.01em; margin: 12px 0 2px; }
.lead { color: var(--hint); font-size: 15px; line-height: 21px; margin: 2px 0 16px; }
.section { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--hint); margin: 24px 4px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.section .link { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 500; }
.pre { white-space: pre-wrap; }
.meta { color: var(--hint); font-size: 13px; line-height: 18px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .94em; letter-spacing: .01em; overflow-wrap: anywhere; }
.link { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }

/* ── screen transition ────────────────────────────── */
.screen { animation: enter .24s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: enter .3s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }

/* ── grouped lists ────────────────────────────────── */
.group { background: var(--bg); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.cell {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px;
  background: none; border: 0; text-align: left; cursor: pointer; position: relative;
}
.cell + .cell::before { content: ""; position: absolute; top: 0; left: 62px; right: 0; border-top: 1px solid var(--line); }
.cell.plain::before { left: 14px; }
.cell:active { background: var(--fill); }
.cell-icon { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--fill); color: var(--hint); }
.cell-icon.transit { background: var(--accent-soft); color: var(--accent); }
.cell-icon.ready { background: var(--ready-soft); color: var(--ready); }
.cell-icon.done { color: var(--done); }
.cell-main { flex: 1 1 auto; min-width: 0; }
.cell-title { font-size: 16px; line-height: 21px; overflow-wrap: anywhere; }
.cell-sub { color: var(--hint); font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }
.cell-end { flex: 0 0 auto; color: var(--hint); display: flex; align-items: center; gap: 6px; font-size: 15px; }
.cell.static { cursor: default; }
.cell.static:active { background: none; }
.ic { display: block; flex: 0 0 auto; }

/* ── chips and steppers ───────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px 0 7px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--fill); color: var(--hint); white-space: nowrap; }
.chip.transit { background: var(--accent-soft); color: var(--accent); }
.chip.ready { background: var(--ready-soft); color: var(--ready); }

/* ── hero ─────────────────────────────────────────── */
.hero { background: var(--bg); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hero-big { font-size: 32px; line-height: 38px; font-weight: 650; letter-spacing: -.02em; margin-top: 12px; }
.hero-big small { font-size: 16px; font-weight: 500; color: var(--hint); letter-spacing: 0; margin-left: 4px; }
.hero-line { margin-top: 10px; display: flex; gap: 8px; align-items: flex-start; color: var(--hint); font-size: 14px; line-height: 19px; }
.hero-line .ic { margin-top: 1px; }
.hero.ready { border: 1px solid var(--ready-soft); }
.bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-top: 14px; }
.bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--accent); transition: width .9s var(--ease); }

/* ── buttons ──────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; padding: 0 18px;
  border: 0; border-radius: 14px; font-size: 16px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--on-accent); transition: transform .12s var(--ease), opacity .12s;
}
.btn:active { transform: scale(.98); opacity: .9; }
.btn[disabled] { opacity: .5; }
.btn.secondary { background: var(--fill); color: var(--text); }
.btn.small { min-height: 36px; width: auto; padding: 0 14px; font-size: 14px; border-radius: 10px; font-weight: 500; }
.btn + .btn { margin-top: 8px; }
.hero .btn { margin-top: 14px; }

/* ── quick actions ────────────────────────────────── */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 12px; border: 0; border-radius: 14px; background: var(--bg); box-shadow: var(--shadow); text-align: left; cursor: pointer; font-size: 15px; font-weight: 500; transition: transform .12s var(--ease); }
.tile:active { transform: scale(.98); }
.tile .cell-icon { width: 32px; height: 32px; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }

/* ── segmented control ────────────────────────────── */
.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--fill); margin: 4px 0 12px; }
.seg button { flex: 1 1 0; min-height: 34px; border: 0; border-radius: 8px; background: none; font-size: 14px; font-weight: 500; color: var(--hint); cursor: pointer; transition: background .18s, color .18s; }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* ── order detail ─────────────────────────────────── */
.mapcard { background: var(--bg); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.mapcard .caption { padding: 12px 16px 14px; }
.mapcard .big { font-size: 20px; line-height: 26px; font-weight: 600; }
.callout { display: flex; gap: 12px; padding: 14px; border-radius: 14px; background: var(--accent-soft); margin-top: 12px; }
.callout.ready { background: var(--ready-soft); }
.callout .ic { margin-top: 1px; color: var(--accent); }
.callout.ready .ic { color: var(--ready); }
.callout strong { display: block; font-weight: 600; margin-bottom: 2px; }
.callout p { margin: 0; font-size: 14px; line-height: 20px; }
.timeline { padding: 6px 14px; }
.tl { display: flex; gap: 14px; min-height: 56px; position: relative; }
.tl-dot { flex: 0 0 auto; width: 22px; display: flex; flex-direction: column; align-items: center; }
.tl-dot b { width: 12px; height: 12px; margin-top: 16px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg); }
.tl-dot em { flex: 1 1 auto; width: 2px; background: var(--line); margin-top: 4px; }
.tl:last-child .tl-dot em { display: none; }
.tl.done .tl-dot b { background: var(--accent); border-color: var(--accent); }
.tl.done .tl-dot em { background: var(--accent); }
.tl.current .tl-dot b { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-body { padding: 10px 0 12px; }
.tl.todo .tl-title { color: var(--hint); }
.tl-title { font-size: 15px; line-height: 20px; font-weight: 500; }

/* ── forms ────────────────────────────────────────── */
.field { margin: 12px 0 0; }
.field label { display: block; font-size: 13px; color: var(--hint); margin: 0 4px 6px; }
/* 16px: below that Safari zooms the page when a field takes focus. */
.field input, .field select { width: 100%; height: 50px; padding: 0 14px; font-size: 16px; font-family: inherit; color: var(--text); background: var(--fill); border: 1.5px solid transparent; border-radius: 12px; outline: none; transition: border-color .15s; }
.field input:focus { border-color: var(--accent); }
.field.bad input { border-color: var(--bad); }
.err { color: var(--bad); font-size: 13px; line-height: 18px; margin: 6px 4px 0; }
.form-actions { margin-top: 16px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 20px; font-weight: 600; }
.who { display: flex; align-items: center; gap: 14px; margin: 12px 0 4px; }
.who .title { margin: 0; }

/* ── bottom sheet ─────────────────────────────────── */
.sheet-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(0, 0, 0, .42); opacity: 0; transition: opacity .2s; }
.sheet-overlay.open { opacity: 1; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 90%; overflow: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .3s var(--ease); }
.sheet-overlay.open .sheet { transform: none; }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
.sheet-title { font-size: 19px; line-height: 24px; font-weight: 650; margin: 4px 0 2px; }

/* ── states ───────────────────────────────────────── */
.empty { text-align: center; padding: 40px 12px 8px; }
.empty .halo { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty h2 { font-size: 19px; line-height: 24px; margin: 0 0 6px; font-weight: 650; }
.empty p { margin: 0 auto 18px; max-width: 320px; color: var(--hint); font-size: 15px; line-height: 21px; }
.empty .btn { max-width: 320px; margin-left: auto; margin-right: auto; }
.empty.bad .halo { background: rgba(210, 59, 59, .12); color: var(--bad); }
.success .halo { background: var(--ready-soft); color: var(--ready); }
.check path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .45s .1s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.skel { border-radius: 12px; background: var(--bg); position: relative; overflow: hidden; }
.skel::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 60%; background: linear-gradient(90deg, transparent, var(--fill), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(170%); } }
.banner { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--warn); color: #fff; padding: 8px 12px; border-radius: 12px; margin-bottom: 8px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: rgba(20, 23, 26, .92); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; animation: enter .2s var(--ease); }

/* ── bottom navigation ────────────────────────────── */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar[hidden], body.typing .tabbar { display: none; }
.tab { flex: 1 1 0; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; border: 0; background: none; color: var(--hint); font-size: 11px; font-weight: 500; cursor: pointer; transition: color .15s; }
.tab.on { color: var(--accent); }
.tab:active .ic { transform: scale(.92); }
.tab .ic { transition: transform .15s var(--ease); }

/* ── map ──────────────────────────────────────────── */
.map { width: 100%; height: auto; display: block; background: var(--page); }
.map .land { fill: var(--bg); stroke: var(--line); stroke-width: .6; stroke-linejoin: round; }
.map .land.cn { fill: rgba(127, 127, 127, .13); stroke: var(--hint); stroke-opacity: .5; stroke-width: .7; }
.map .land.kg { fill: var(--accent-soft); stroke: var(--accent); stroke-width: .9; }
.map .road { fill: none; stroke: var(--hint); stroke-width: 1.5; stroke-dasharray: 2 5; stroke-linecap: round; opacity: .65; }
.map .done { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; }
.map.grey .done { stroke: var(--done); }
.map .city { fill: var(--accent); stroke: var(--bg); stroke-width: 1; }
.map .city.mid { fill: var(--hint); }
.map text { fill: var(--text); font-size: 10px; font-weight: 500; paint-order: stroke; stroke: var(--bg); stroke-width: 2.6px; stroke-linejoin: round; }
.map text.country { fill: var(--hint); font-size: 8.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 400; opacity: .85; }
.map .dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.map .ring { fill: var(--accent); opacity: .3; transform-box: fill-box; transform-origin: center; animation: pulse 1.9s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .4; } to { transform: scale(3); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .screen, .rise, .toast { animation: none; }
  .sheet, .sheet-overlay, .bar i, .btn, .tile, .tab .ic { transition: none; }
  .skel::after, .map .ring { animation: none; }
  .check path { animation: none; stroke-dashoffset: 0; }
}
/* Nothing here reacts to :hover: a tap leaves it stuck on touch screens. Press feedback is :active. */
