/* Mini app «Сделки». Cold steel palette, status colours carry meaning only, one bold element: the deal route. */
:root, :root[data-theme="light"] {
  --bg: #EEF0F3;
  --surface: #FFFFFF;
  --surface-2: #F6F7F9;
  --ink: #14171C;
  --ink-2: #3A414C;
  --mute: #7A828E;
  --line: #E2E5EA;
  --track: #D3D8DF;
  --ok: #12805C;
  --warn: #B7791F;
  --bad: #C8323C;
  --info: #2B59C3;
  --scrim: rgba(20, 23, 28, .38);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E1115;
  --surface: #171B21;
  --surface-2: #1E232B;
  --ink: #ECEFF3;
  --ink-2: #C3C9D2;
  --mute: #8A93A0;
  --line: #262C35;
  --track: #2E3540;
  --ok: #3DBE8B;
  --warn: #E3A94A;
  --bad: #EF5F67;
  --info: #7EA2FF;
  --scrim: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
:root { --display: "Unbounded", "Onest", -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 "Onest", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "lnum" 1;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 6px; }

.app { max-width: 620px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 40px); }

/* Header */
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 6px 2px 14px; }
.head .day { font-size: 13px; color: var(--mute); }
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); white-space: nowrap; }
.fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.fresh.stale { color: var(--bad); }
.fresh.stale::before { background: var(--bad); }

/* Tabs: a quiet segmented control, sticky under Telegram's header */
.tabs { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; margin: 0 -2px 22px; border-radius: 12px; background: color-mix(in srgb, var(--ink) 7%, var(--bg)); }
.tabs button { padding: 7px 0; border-radius: 9px; text-align: center; font-size: 14px; font-weight: 550; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs b { font-weight: 600; color: var(--bad); margin-left: 4px; font-size: 12px; }

/* Hero: a sentence, not stat tiles */
.hero { margin: 4px 2px 18px; }
.hero h1 { font-size: 30px; line-height: 1.12; letter-spacing: -.022em; font-weight: 700; margin: 0 0 6px; text-wrap: balance; }
.hero p { margin: 0; color: var(--ink-2); font-size: 15px; max-width: 34em; }

h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; margin: 28px 2px 10px; display: flex; justify-content: space-between; align-items: baseline; }
h2 small { font-size: 13px; font-weight: 400; color: var(--mute); }

/* Task list */
.list { background: var(--surface); border-radius: 18px; overflow: hidden; }
.task { display: grid; grid-template-columns: 3px 1fr auto; gap: 12px; width: 100%; padding: 13px 16px 13px 0; position: relative; }
.task + .task::after { content: ""; position: absolute; top: 0; left: 15px; right: 0; height: 1px; background: var(--line); }
.task .bar { border-radius: 0 3px 3px 0; background: transparent; }
.task.bad .bar { background: var(--bad); } .task.warn .bar { background: var(--warn); }
.task .what { font-size: 15px; line-height: 1.35; color: var(--ink); }
.task .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 13px; color: var(--mute); }
.task .due { color: var(--ink-2); }
.task.bad .due { color: var(--bad); font-weight: 600; } .task.warn .due { color: var(--warn); font-weight: 600; }
.task .deal { color: var(--info); }
.task .sum { font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap; align-self: start; }
.wait { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--info); margin-bottom: 4px; }
.wait::before { content: ""; width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--info); }
.more { display: block; width: 100%; padding: 13px; text-align: center; color: var(--info); border-top: 1px solid var(--line); font-size: 14px; }
.empty { padding: 26px 16px; text-align: center; color: var(--mute); }

/* Agenda: the week by day */
.day-group + .day-group { margin-top: 14px; }
.day-name { font-size: 13px; color: var(--mute); margin: 0 4px 6px; }
.day-name b { color: var(--ink); font-weight: 600; }

/* Deal card with the route — the one bold element */
.deal-card { display: block; width: 100%; background: var(--surface); border-radius: 22px; padding: 18px 18px 16px; margin-bottom: 12px; }
.deal-card .top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.deal-card .name { font-size: 18px; font-weight: 650; letter-spacing: -.012em; line-height: 1.25; }
.deal-card .who { font-size: 13px; color: var(--mute); margin-top: 3px; }
.deal-card .money { text-align: right; white-space: nowrap; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.deal-card .money small { display: block; font-size: 12px; font-weight: 400; color: var(--mute); letter-spacing: 0; }

.route { position: relative; display: flex; justify-content: space-between; align-items: center; margin: 20px 4px 14px; height: 14px; }
.route::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--track); }
.route .done-line { position: absolute; left: 0; height: 4px; border-radius: 2px; background: var(--ok); transform-origin: left; animation: fill .7s cubic-bezier(.2,.7,.2,1) both; }
.route i { position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--track); }
.route i.done { background: var(--ok); border-color: var(--ok); }
.route i.overdue { background: var(--bad); border-color: var(--bad); }
.route i.now { width: 14px; height: 14px; border: 3px solid var(--ink); background: var(--surface); }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.route-label { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--mute); margin: 0 2px; }
.route-label .count { white-space: nowrap; }
.route-label b { color: var(--ink); font-weight: 600; }
.route-label .current { color: var(--ink); font-weight: 550; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-card .next { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.deal-card .next span { display: block; font-size: 12px; color: var(--mute); margin-bottom: 2px; }
.deal-card .next.bad em { color: var(--bad); font-style: normal; font-weight: 600; }

/* Deal page */
.back { color: var(--info); font-size: 15px; padding: 4px 2px 12px; }
.deal-head h1 { font-size: 26px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 4px; font-weight: 700; text-wrap: balance; }
.deal-head p { margin: 0 0 16px; color: var(--mute); font-size: 14px; }
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: 18px; overflow: hidden; }
.figures div { background: var(--surface); padding: 12px 14px; }
.figures div:last-child:nth-child(odd) { grid-column: span 2; }
.figures span { display: block; font-size: 12px; color: var(--mute); }
.figures b { display: block; font-size: 17px; font-weight: 650; letter-spacing: -.01em; line-height: 1.3; margin-top: 2px; white-space: nowrap; }
.figures small { display: block; font-size: 12px; color: var(--mute); margin-top: 2px; line-height: 1.3; }
.facts { background: var(--surface); border-radius: 18px; padding: 2px 16px; margin-top: 10px; }
.fact { display: grid; grid-template-columns: 9.5em 1fr; gap: 12px; padding: 10px 0; font-size: 14px; }
.fact + .fact { border-top: 1px solid var(--line); }
.fact span { color: var(--mute); }

/* Vertical route on the deal page */
.stations { background: var(--surface); border-radius: 18px; padding: 8px 16px; }
.station { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; position: relative; }
.station::before { content: ""; position: absolute; left: 9px; top: -10px; bottom: 50%; width: 4px; background: var(--track); }
.station:first-child::before { display: none; }
.station.done::before, .station.done + .station::before { background: var(--ok); }
.station .dot { position: relative; z-index: 1; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--track); }
.station.done .dot { background: var(--ok); border-color: var(--ok); }
.station.done .dot::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.station.overdue .dot { border-color: var(--bad); background: var(--bad); }
.station.overdue .dot::after { content: "!"; color: #fff; font-size: 12px; font-weight: 700; }
.station.now .dot { border: 4px solid var(--ink); }
.station .label { font-size: 15px; }
.station.missing .label { color: var(--mute); }
.station .when { font-size: 13px; color: var(--mute); text-align: right; white-space: nowrap; }
.station.overdue .when { color: var(--bad); font-weight: 600; }

.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 10px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 7px 13px; border-radius: 999px; background: var(--surface); font-size: 14px; color: var(--ink-2); }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chips small { margin-left: 5px; color: inherit; opacity: .6; }

.write { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 16px; border-radius: 18px; background: var(--surface); color: var(--info); font-size: 15px; margin-top: 28px; }
.write svg { flex: none; }

details.group { margin-top: 10px; }
details.group summary { list-style: none; cursor: pointer; padding: 12px 4px; display: flex; justify-content: space-between; font-size: 15px; font-weight: 550; }
details.group summary::-webkit-details-marker { display: none; }
details.group summary small { color: var(--mute); font-weight: 400; }

/* Hero: a dark steel slab in both themes, the day's one number */
.hero-card { position: relative; overflow: hidden; border-radius: 26px; padding: 18px 20px 20px; margin: 4px 0 12px; color: #F2F4F7;
  background: radial-gradient(120% 90% at 100% 0%, #39424F 0%, rgba(57,66,79,0) 55%), linear-gradient(160deg, #1D232B 0%, #10141A 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
.hero-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(100deg, rgba(255,255,255,.025) 0 1px, transparent 1px 4px); }
.hc-label { font-size: 13px; color: #A9B1BC; }
.hc-main { display: flex; align-items: baseline; gap: 12px; margin: 6px 0 14px; }
.hc-num { font-family: var(--display); font-weight: 700; font-size: 64px; line-height: .95; letter-spacing: -.03em; }
.hc-text { font-size: 17px; line-height: 1.25; color: #DCE1E7; max-width: 11em; }
.hc-pills { display: flex; flex-wrap: wrap; gap: 6px; position: relative; z-index: 1; }
.pill { font-size: 13px; padding: 5px 11px; border-radius: 999px; background: rgba(255,255,255,.09); color: #DCE1E7; }
.pill.bad { background: rgba(239,95,103,.18); color: #FF9AA0; }

/* Deal as a shipment ticket */
.ticket { display: block; width: 100%; position: relative; background: var(--surface); border-radius: 24px; padding: 16px 18px 14px; margin-bottom: 12px; }
.t-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.t-title { font-size: 15px; font-weight: 600; color: var(--ink-2); line-height: 1.3; }
.t-sum { font-weight: 650; font-size: 15px; white-space: nowrap; }
.t-route { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; margin: 16px 0 14px; }
.t-end b { display: block; font-family: var(--display); font-weight: 700; font-size: 28px; line-height: 1; letter-spacing: -.01em; }
.t-end span { display: block; font-size: 12px; color: var(--mute); margin-top: 6px; max-width: 8.5em; line-height: 1.25; }
.t-end.right { text-align: right; }
.t-end.right span { margin-left: auto; }
.t-line { position: relative; height: 2px; margin-bottom: 18px; background-image: linear-gradient(90deg, var(--track) 55%, transparent 0); background-size: 8px 2px; }
.t-done { position: absolute; left: 0; top: 0; height: 2px; background: var(--ok); border-radius: 2px; transform-origin: left; animation: fill .9s cubic-bezier(.2,.7,.2,1) both; }
.t-truck { position: absolute; top: -9px; transform: translateX(-50%); color: var(--ink); animation: drive .9s cubic-bezier(.2,.7,.2,1) both; }
.t-truck.late { color: var(--bad); }
@keyframes drive { from { left: 0; opacity: 0; } to { opacity: 1; } }
.t-cut { position: relative; height: 0; border-top: 1.5px dashed var(--line); margin: 0 -2px 12px; }
.t-cut::before, .t-cut::after { content: ""; position: absolute; top: -11px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); }
.t-cut::before { left: -29px; } .t-cut::after { right: -29px; }
.t-step { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 0; font-size: 13px; color: var(--mute); }
.t-step b { font-family: var(--display); font-size: 15px; color: var(--ink); font-weight: 700; }
.t-step em { font-style: normal; color: var(--ink); font-weight: 550; margin-left: 10px; }
.t-step i { font-style: normal; margin-left: auto; font-size: 12px; color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); padding: 2px 8px; border-radius: 999px; }
.t-next { margin-top: 8px; font-size: 14px; color: var(--ink-2); line-height: 1.35; }
.t-next span { display: block; font-size: 12px; color: var(--mute); margin-top: 2px; }
.t-next.bad span { color: var(--bad); font-weight: 600; }

/* Money coming in */
.money-card { background: var(--surface); border-radius: 24px; padding: 18px; margin: 4px 0 12px; }
.mc-label { font-size: 13px; color: var(--mute); }
.mc-sum { font-family: var(--display); font-weight: 700; font-size: 30px; letter-spacing: -.02em; margin: 4px 0 14px; }
.mc-rows { display: grid; gap: 12px; }
.mc-row { display: grid; grid-template-columns: 5.6em 1fr auto; gap: 4px 12px; align-items: center; width: 100%; }
.mc-date { font-size: 13px; color: var(--ink-2); }
.mc-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.mc-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--ok), color-mix(in srgb, var(--ok) 55%, var(--info))); transform-origin: left; animation: fill .9s cubic-bezier(.2,.7,.2,1) both; }
.mc-amount { font-weight: 650; font-size: 14px; white-space: nowrap; }
.mc-deal { grid-column: 2 / 4; font-size: 12px; color: var(--mute); margin-top: -2px; }

/* Success state in the sheet */
.success { text-align: center; padding: 18px 0 8px; }
.success svg { display: block; margin: 0 auto 12px; fill: none; stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.success circle { stroke-dasharray: 183; stroke-dashoffset: 183; animation: draw .5s ease-out forwards; }
.success path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .35s .4s ease-out forwards; }
.success b { display: block; font-family: var(--display); font-size: 20px; font-weight: 700; }
.success p { margin: 4px 0 0; color: var(--mute); }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Bottom sheet */
.scrim { position: fixed; inset: 0; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px); transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1); max-width: 620px; margin: 0 auto; }
.sheet.on { transform: none; }
.sheet .grip { width: 38px; height: 5px; border-radius: 3px; background: var(--track); margin: 0 auto 14px; }
.sheet h3 { font-size: 19px; line-height: 1.3; letter-spacing: -.012em; margin: 0 0 6px; font-weight: 650; }
.sheet .sub { font-size: 14px; color: var(--mute); margin: 0 0 4px; }
.sheet .proof { margin: 12px 0 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; color: var(--ink-2); }
.sheet .proof span { display: block; font-size: 12px; color: var(--mute); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.actions button { padding: 13px 12px; border-radius: 14px; background: var(--surface-2); font-size: 15px; font-weight: 550; display: flex; align-items: center; gap: 8px; }
.actions button.primary { background: var(--ink); color: var(--bg); }
.actions button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: -2px; }
.form { margin-top: 12px; }
.form label { display: block; font-size: 13px; color: var(--mute); margin: 10px 2px 6px; }
.form textarea, .form input[type="date"] { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 11px 12px; }
.form textarea { min-height: 76px; resize: vertical; }
.file { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1.5px dashed var(--track); border-radius: 12px; color: var(--ink-2); font-size: 14px; cursor: pointer; }
.file input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.file b { font-weight: 550; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.go { width: 100%; margin-top: 14px; padding: 15px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 16px; font-weight: 600; text-align: center; }
.go:disabled { opacity: .45; }
.note { margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.note.ok { color: var(--ok); } .note.bad { color: var(--bad); }

.error { background: var(--surface); border-radius: 22px; padding: 28px 22px; text-align: center; margin-top: 18vh; }
.error b { display: block; font-size: 19px; margin-bottom: 6px; }
.error p { margin: 0; color: var(--mute); }
.skeleton { height: 120px; border-radius: 22px; background: var(--surface); margin-bottom: 12px; opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  .route .done-line, .t-done, .t-truck, .mc-bar i, .success circle, .success path { animation: none; stroke-dashoffset: 0; }
  .sheet, .scrim { transition: none; }
}
