:root {
  --bg: #060a13;
  --bg-2: #0b1220;
  --panel: rgba(17, 25, 42, 0.72);
  --panel-solid: #0f1729;
  --line: rgba(148, 170, 210, 0.14);
  --line-2: rgba(148, 170, 210, 0.26);
  --text: #e8eefb;
  --muted: #8a98b4;
  --dim: #5d6b88;
  --sky: #7cc4ff;
  --mint: #7cf5c4;
  --coral: #ff7a8a;
  --amber: #ffc861;
  --radius: 18px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Space Grotesk', system-ui, -apple-system, Segoe UI, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 85% -10%, rgba(124, 196, 255, 0.16), transparent 60%),
    radial-gradient(700px 480px at -10% 30%, rgba(124, 245, 196, 0.08), transparent 60%),
    linear-gradient(180deg, #070c18 0%, var(--bg) 60%);
}
.sky::after {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 120px 120px; opacity: .06;
  mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
em { font-style: normal; }
code { font-family: var(--mono); font-size: .9em; background: rgba(124,196,255,.1); padding: 1px 6px; border-radius: 6px; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--sky); }

/* ---------- brand / top bar ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; font-size: 18px; }
.brand.big { font-size: 28px; justify-content: center; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; position: relative;
  background: linear-gradient(135deg, var(--sky), var(--mint));
  box-shadow: 0 0 24px rgba(124, 245, 196, 0.35);
}
.brand-mark::after {
  content: ''; position: absolute; inset: 7px 6px 7px 6px;
  border-top: 2.5px solid var(--bg); border-right: 2.5px solid var(--bg);
  transform: skewX(-20deg) rotate(-14deg); border-radius: 2px;
}
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(16px, calc((100vw - 1180px) / 2));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: rgba(6, 10, 19, 0.6); border-bottom: 1px solid var(--line);
}
.top-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.03);
  padding: 9px 14px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .2s ease;
}
.btn:hover { background: rgba(255,255,255,.06); border-color: rgba(148,170,210,.4); }
.btn:active { transform: scale(.98); }
.btn.primary {
  border: 0; color: #04140e;
  background: linear-gradient(135deg, var(--mint), #a9f7ff);
  box-shadow: 0 6px 24px -6px rgba(124, 245, 196, .55);
}
.btn.primary:hover { box-shadow: 0 8px 30px -6px rgba(124, 245, 196, .75); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--coral); border-color: rgba(255,122,138,.3); background: transparent; }
.btn.wide { width: 100%; padding: 13px; font-size: 15px; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.btn.loading .btn-label::after { content: ''; display: inline-block; width: 14px; height: 14px; margin-left: 10px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 16px 80px; }
.banner {
  border: 1px solid rgba(255, 200, 97, .35); background: rgba(255, 200, 97, .07);
  color: #f6dfb0; padding: 14px 16px; border-radius: 14px; margin-bottom: 22px; font-size: 14px;
}
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin: 8px 0 26px; }
.hero h1 { font-size: clamp(28px, 4.2vw, 44px); line-height: 1.05; letter-spacing: -0.035em; margin: 6px 0 0; font-weight: 600; max-width: 14ch; }
.hero h1 span:first-child { color: var(--mint); font-family: var(--mono); font-weight: 700; }
.eyebrow { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--sky); margin: 0; display: flex; align-items: center; gap: 8px; }
.eyebrow::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(124,245,196,.15); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(124,245,196,0); } }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 10px 14px; min-width: 120px; }
.stat b { display: block; font-family: var(--mono); font-size: 20px; letter-spacing: -0.02em; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.good b { color: var(--mint); }

/* ---------- flight cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card {
  position: relative; overflow: hidden; text-align: left; width: 100%;
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .2s ease, border-color .2s ease, box-shadow .25s ease;
  animation: rise .45s cubic-bezier(.2,.8,.2,1) both;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: 0 18px 40px -20px rgba(0,0,0,.8), 0 0 0 1px rgba(124,196,255,.08); }
.card.is-drop { border-color: rgba(124,245,196,.35); }
.card.is-drop::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 2px; background: linear-gradient(90deg, transparent, var(--mint), transparent); }
.card.inactive { opacity: .55; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.route { display: flex; align-items: center; gap: 10px; }
.code { font-family: var(--mono); font-weight: 700; font-size: 28px; letter-spacing: .02em; line-height: 1; }
.city { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; max-width: 11ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-top > div:first-child { min-width: 0; }
.route > div { min-width: 0; }
.path { position: relative; height: 22px; flex: 1 1 64px; min-width: 22px; max-width: 64px; }
.price-block { flex: none; }
.path svg { width: 100%; height: 100%; overflow: visible; }
.label-chip { font-size: 12px; color: var(--sky); margin-bottom: 8px; font-weight: 500; }

.price-block { text-align: right; }
.price { font-family: var(--mono); font-weight: 700; font-size: 30px; letter-spacing: -0.03em; line-height: 1; }
.price.none { color: var(--dim); font-size: 22px; }
.delta { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.delta.down { color: var(--mint); background: rgba(124,245,196,.1); }
.delta.up { color: var(--coral); background: rgba(255,122,138,.1); }
.delta.flat { color: var(--muted); background: rgba(148,170,210,.08); }

.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.meta b { color: var(--text); font-weight: 500; }
.spark { height: 54px; margin: 0 -4px; }
.spark svg { width: 100%; height: 100%; display: block; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px dashed var(--line-2); padding-top: 12px; font-size: 12.5px; color: var(--muted); }
.airline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.airline img { width: 20px; height: 20px; border-radius: 5px; background: #fff; padding: 1px; flex: none; }
.airline span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2); white-space: nowrap; }
.pill.low { color: var(--mint); border-color: rgba(124,245,196,.35); }
.pill.high { color: var(--coral); border-color: rgba(255,122,138,.35); }
.pill.typical { color: var(--amber); border-color: rgba(255,200,97,.3); }
.err { color: var(--coral); font-size: 12.5px; }

.card.skeleton { min-height: 230px; background: linear-gradient(100deg, var(--panel) 30%, rgba(124,196,255,.06) 50%, var(--panel) 70%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 50px 16px; max-width: 460px; margin: 0 auto; }
.empty-art { width: 100%; max-width: 320px; }
.empty h2 { margin: 10px 0 6px; letter-spacing: -0.02em; }
.empty p { margin: 0 0 22px; }

/* ---------- dialogs ---------- */
dialog { color: var(--text); border: 1px solid var(--line-2); background: var(--panel-solid); padding: 0; }
dialog::backdrop { background: rgba(2, 5, 12, .66); backdrop-filter: blur(4px); }
.sheet { width: min(520px, calc(100vw - 24px)); border-radius: 22px; box-shadow: 0 40px 80px -20px rgba(0,0,0,.8); }
.sheet[open] { animation: pop .25s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.sheet form { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.drawer .sheet-head { padding: 20px 22px 10px; }

.drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(760px, 100vw);
  border-radius: 0; border-width: 0 0 0 1px; overflow-y: auto; overflow-x: hidden;
}
.drawer.narrow { width: min(440px, 100vw); }
.drawer[open] { animation: slide .3s cubic-bezier(.2,.8,.2,1); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.field > span { font-weight: 500; }
input, select {
  font: inherit; color: var(--text); width: 100%;
  background: rgba(255,255,255,.04); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 11px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(124,196,255,.18); }
input[type=date] { color-scheme: dark; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.code-field input { font-family: var(--mono); font-size: 26px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; }
.hint { min-height: 16px; font-size: 12px; color: var(--sky); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.swap { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--sky); display: grid; place-items: center; margin-top: 4px; transition: transform .3s; }
.swap:hover { transform: rotate(180deg); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; padding: 4px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); align-self: flex-start; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .15s; }
.seg input:checked + span { background: rgba(124,196,255,.16); color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--sky); }
.stepper { display: grid; grid-template-columns: 40px 1fr 40px; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; }
.stepper button { border: 0; background: rgba(255,255,255,.04); font-size: 18px; }
.stepper button:hover { background: rgba(255,255,255,.08); }
.stepper input { border: 0; border-radius: 0; text-align: center; font-family: var(--mono); background: transparent; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.prefix { position: relative; }
.prefix b { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; }
.prefix input { padding-left: 26px; font-family: var(--mono); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(255,255,255,.03); font-size: 13px; color: var(--muted); transition: all .15s; }
.chip img { width: 18px; height: 18px; border-radius: 50%; background: #fff; padding: 1px; }
.chip[aria-pressed=true] { color: var(--text); border-color: var(--sky); background: rgba(124,196,255,.14); }
.tag { font-family: var(--mono); font-size: 11.5px; padding: 2px 7px; border-radius: 6px; background: rgba(124,196,255,.12); color: var(--sky); }
.form-error { color: var(--coral); font-size: 13px; margin: 0; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; text-align: center; padding: 34px 26px; border-radius: 24px; border: 1px solid var(--line-2); background: var(--panel); backdrop-filter: blur(12px); }
.login-card p { margin: -6px 0 6px; }
.login-card .field { text-align: left; }

/* ---------- detail ---------- */
.detail-head { padding: 22px 24px 0; display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.detail-head .code { font-size: 40px; }
.detail-head .route { gap: 14px; }
.detail-sub { color: var(--muted); font-size: 14px; margin-top: 8px; }
.detail-price { padding: 18px 24px 0; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.detail-price .price { font-size: 46px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 18px 24px 0; }
.kpi { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: rgba(255,255,255,.02); }
.kpi span { display: block; font-size: 11.5px; color: var(--muted); }
.kpi b { font-family: var(--mono); font-size: 17px; }
.chart-wrap { margin: 18px 24px 0; border: 1px solid var(--line); border-radius: 18px; padding: 14px 14px 8px; background: linear-gradient(180deg, rgba(124,196,255,.04), transparent); position: relative; }
.chart-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.chart { height: 280px; position: relative; touch-action: pan-y; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tip { position: absolute; pointer-events: none; transform: translate(-50%, -100%); background: #f2f6ff; color: #071022; border-radius: 10px; padding: 7px 10px; font-size: 12px; white-space: nowrap; box-shadow: 0 10px 30px rgba(0,0,0,.4); opacity: 0; transition: opacity .12s; }
.tip b { font-family: var(--mono); font-size: 14px; display: block; }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 14px; text-align: center; }
.section { padding: 20px 24px 0; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-family: var(--mono); font-weight: 600; margin: 0 0 10px; }
.itin { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.leg { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.leg:last-child { border-bottom: 0; }
.leg img { width: 26px; height: 26px; border-radius: 6px; background: #fff; padding: 2px; }
.leg .t { font-family: var(--mono); }
.layover { padding: 6px 14px; font-size: 12px; color: var(--amber); background: rgba(255,200,97,.05); border-bottom: 1px solid var(--line); }
.alts { display: flex; flex-direction: column; gap: 6px; }
.alt { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.025); }
.alt b { font-family: var(--mono); }
table.history { width: 100%; border-collapse: collapse; font-size: 13px; }
table.history th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.history td { padding: 8px; border-bottom: 1px solid var(--line); }
table.history td.num { font-family: var(--mono); text-align: right; }
table.history th.num { text-align: right; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 22px 24px 30px; }
.target-form { display: flex; gap: 8px; align-items: center; }
.target-form .prefix { width: 130px; }
.target-form input { padding: 9px 10px 9px 26px; }

/* ---------- alerts ---------- */
#alerts-body { padding: 0 22px 24px; display: flex; flex-direction: column; gap: 10px; }
.alert-item { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); cursor: pointer; }
.alert-item.unseen { border-color: rgba(124,245,196,.35); }
.alert-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(124,245,196,.12); color: var(--mint); font-size: 16px; }
.alert-icon.target { background: rgba(255,200,97,.12); color: var(--amber); }
.alert-item small { color: var(--muted); display: block; }
.alert-item .p { font-family: var(--mono); text-align: right; }
.alert-item .p s { color: var(--dim); font-size: 12px; display: block; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #f2f6ff; color: #071022; padding: 11px 16px; border-radius: 12px; font-weight: 500; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: calc(100vw - 32px); box-shadow: 0 20px 40px -10px rgba(0,0,0,.6); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--coral); color: #2a0509; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 9px 11px; }
  .grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); padding: 16px 16px 0; }
  .detail-head, .detail-price, .section, .detail-actions { padding-left: 16px; padding-right: 16px; }
  .chart-wrap { margin: 16px 16px 0; }
  .chart { height: 230px; }
  .detail-head .code { font-size: 32px; }
  .detail-price .price { font-size: 38px; }
  .two { grid-template-columns: 1fr; }
  .code-field input { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.queued { color: var(--amber); font-size: 12.5px; }
.email-box { margin: 0 22px 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(124,196,255,.05); font-size: 14px; }
.email-box small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
