:root {
  --frame: 540px;
  --top-safe: max(env(safe-area-inset-top), var(--telegram-safe-top, 0px));
  --right-safe: max(env(safe-area-inset-right), var(--telegram-safe-right, 0px));
  --bottom-safe: max(env(safe-area-inset-bottom), var(--telegram-safe-bottom, 0px));
  --left-safe: max(env(safe-area-inset-left), var(--telegram-safe-left, 0px));
  --viewport-bottom: 0px;
  --visible-height: 100dvh;
  --frame-gutter: clamp(14px, 4.8vw, 27px);
  --sheet-bottom-padding: max(14px, var(--bottom-safe));
}
html { background: #e9e9e9; overscroll-behavior-y: none; }
body { background: transparent; }
main {
  max-width: var(--frame);
  min-height: 100dvh;
  margin: 0 auto;
  padding: var(--top-safe) max(var(--frame-gutter), var(--right-safe))
    calc(98px + var(--bottom-safe)) max(var(--frame-gutter), var(--left-safe));
  background: #f6f6f6;
  box-shadow: 0 0 60px #0001;
}
header { height: 65px; }
.brand { display: flex; justify-content: flex-start; background: none; color: inherit; padding: 0; font-size: 29px; gap: 6px; }
.orbit-mark { font-size: 36px; }
.header-right { gap: 12px; }
.local-label { display: block; font-size: 10px; color: #666; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; color: #222; background: #fafafa; }
.icon-button svg { width: 20px; height: 20px; }
.page-heading { align-items: center; margin: 24px 0 19px; gap: 10px; }
.page-heading > div { min-width: 0; }
h1 { font-size: clamp(25px, 7vw, 35px); font-weight: 800; letter-spacing: -.055em; }
.page-heading p { font-size: 12px; line-height: 1.45; color: #676767; margin-top: 4px; }
.page-heading > .primary { width: auto; flex: none; gap: 4px; font-size: 12px; min-height: 44px; padding: 9px 12px; }
.page-heading > .primary span { font-size: 18px; }
.sidebar {
  position: fixed;
  inset: auto 0 0;
  overscroll-behavior-y: none;
  width: min(100%, var(--frame));
  margin-inline: auto;
  min-height: calc(67px + var(--bottom-safe));
  height: auto;
  z-index: 5;
  border: 0;
  border-top: 1px solid #ddd;
  padding: 5px max(5px, var(--right-safe)) var(--bottom-safe) max(5px, var(--left-safe));
  background: #fafafaf2;
  backdrop-filter: blur(14px);
}
nav { display: flex; margin: 0; justify-content: space-evenly; }
nav .nav {
  width: 25%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  font-size: clamp(9px, 2.8vw, 11px);
  text-align: center;
  padding: 3px 0;
  margin: 0;
  color: #666;
}
nav .nav span { width: 42px; border-radius: 8px; text-align: center; font-size: 19px; line-height: 26px; transition: background .2s, transform .2s; }
nav .nav.active { background: transparent; color: #171717; }
nav .nav.active span { background: #e7e7e7; transform: translateY(-1px); }
nav .nav small { display: none; }
.hero-grid { grid-template-columns: minmax(0,1fr); gap: 10px; }
.hero { min-height: 170px; padding: 19px 20px; isolation: isolate; }
.hero-top span, .hero-note { font-size: 12px; }
.hero select { min-height: 34px; font-size: 12px; }
.total { margin-top: 8px; font-size: clamp(30px, 9vw, 47px); overflow-wrap: anywhere; }
.hero-bottom { margin-top: 12px; font-size: 11px; }
.summary-stack { gap: 10px; }
.stat { min-width: 0; padding: 12px 13px; }
.stat-label, .stat small { font-size: 11px; color: #666; }
.stat-number { font-size: 27px; margin-top: 5px; }
.stat small:empty { display: none; }
.upcoming { margin-top: 16px; padding: 16px; }
.upcoming h2 { font-size: 16px; }
.upcoming .section-head { margin-bottom: 5px; }
.upcoming .week, .upcoming .tip, .timeline-label { display: none; }
.upcoming .month { margin: 9px 0; }
.timeline { display: block; margin-top: 4px; }
.timeline-row { width: 100%; text-align: left; padding: 7px 0; margin: 0; background: transparent; color: inherit; }
.timeline-row > div { min-width: 0; overflow-wrap: anywhere; }
.timeline-row b, .timeline-price { font-size: 12px !important; }
.timeline-row small { font-size: 11px; color: #666; }
.timeline-price { flex-shrink: 0; }
.text-button { color: #555; min-height: 34px; font-size: 12px; }
.section-head { margin: 21px 0 10px; }
.section-head h2 { font-size: 17px; }
.toolbar { display: grid; grid-template-columns: minmax(0,1fr); gap: 8px; margin-bottom: 11px; }
.tabs { width: fit-content; max-width: 100%; }
.tabs button { min-height: 34px; color: #5d5d5d; font-size: 11px; }
.search { width: 100%; min-height: 42px; padding: 9px 12px; color: #242424; font-size: 16px; background: #fff; }
.search:focus-visible { outline: 2px solid #777; outline-offset: 2px; }
.cards { grid-template-columns: minmax(0,1fr); gap: 9px; }
.sub-card { padding: 13px; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,42%); align-items: center; gap: 0 8px; }
.card-top { min-width: 0; }
.card-top > div { min-width: 0; }
.card-name { font-size: 13px; overflow-wrap: anywhere; }
.category, .card-price small, .card-bottom { color: #666; font-size: 11px; }
.dots { display: none; }
.card-price { text-align: right; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.card-price small { display: block; }
.card-bottom { grid-column: 1/-1; padding-top: 8px; margin-top: 9px; }
.pill { color: #444; white-space: nowrap; }
.panel { padding: 13px; margin-top: 0; }
.calendar-grid { gap: 4px; grid-template-columns: repeat(7,minmax(0,1fr)); }
.cal-cell { min-height: 46px; padding: 5px; }
.cal-cell p { padding: 2px; margin: 4px 0 0; }
.cal-cell p a { display: block; font-size: 0; min-height: 7px; }
.cal-cell:has(p) { background: #dedede; }
.calendar-agenda { display: grid; gap: 5px; margin-top: 15px; }
.calendar-agenda .timeline-row { background: #f5f5f5; padding: 8px; border-radius: 8px; }
.chart-row { gap: 7px; font-size: 11px; margin: 16px 0; }
.chart-row > span { width: 28%; }
.chart-row b { width: auto; min-width: 55px; max-width: 39%; overflow-wrap: anywhere; }
.bar i { transform-origin: left; animation: bar-fill .55s ease-out both; }
.muted { color: #666; line-height: 1.55; }
.modal {
  align-items: flex-end;
  padding: var(--top-safe) var(--right-safe) var(--viewport-bottom) var(--left-safe);
}
.dialog {
  width: min(100%, var(--frame));
  max-height: min(calc(var(--visible-height) - var(--top-safe)), 760px);
  padding: 24px 20px var(--sheet-bottom-padding);
  border-radius: 22px 22px 0 0;
}
.dialog h2 { padding-right: 38px; overflow-wrap: anywhere; }
.dialog input, .dialog select { min-width: 0; font-size: 16px; padding: 9px 7px; min-height: 43px; }
.form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.dialog label { font-size: 11px; color: #555; }
.dialog .primary, .dialog .secondary { min-height: 44px; }
.toast {
  bottom: calc(80px + var(--bottom-safe) + var(--viewport-bottom));
  width: max-content;
  min-width: 0;
  max-width: calc(100% - 32px);
  text-align: center;
}
button:active, .sub-card:active { transform: scale(.98); }
@keyframes bar-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.cal-head { padding: 8px 0; color: #666; }
.cal-cell p { color: #222; background: #fff; text-align: center; font-size: 10px; }
