:root {
  color-scheme: dark;
  --page-bg: var(--tg-theme-secondary-bg-color, #141b17);
  --card-bg: var(--tg-theme-bg-color, #1c2520);
  --text: var(--tg-theme-text-color, #f1f4ef);
  --muted: var(--tg-theme-hint-color, #a5b1a7);
  --accent: var(--tg-theme-button-color, #e4b56e);
  --accent-text: var(--tg-theme-button-text-color, #242016);
  --link: var(--tg-theme-link-color, #ebc88e);
  --brand-mark-bg: #e4b56e;
  --line: color-mix(in srgb, var(--text) 9%, transparent);
  --soft: color-mix(in srgb, var(--text) 5%, transparent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

.sales-home { margin-top: 26px; padding: 18px; }
.sales-home h2 { font-size: 15px; font-weight: 600; }
.history-badge { color: var(--muted); font-size: 8px; letter-spacing: .08em; white-space: nowrap; }
.segmented { display: flex; gap: 3px; padding: 3px; border-radius: 10px; background: var(--soft); }
.segmented button { flex: 1; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; padding: 9px 8px; white-space: nowrap; min-height: 36px; }
.segmented button[aria-pressed="true"] { color: var(--text); background: var(--card-bg); box-shadow: 0 1px 5px #0002; }
.sales-home .segmented { margin-top: 15px; }
.sales-metrics { margin-bottom: 16px; }
.sales-filter-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; margin: 12px 0; }
.sales-filter-row label, .sales-comparison { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 11px; min-width: 0; }
.sales-filter-row select, .sales-filter-row input, .sales-comparison select { min-width: 0; width: 100%; min-height: 44px; padding: 10px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-bg); color: var(--text); font: inherit; font-size: 12px; }
.sales-filters { padding: 14px; margin: 15px 0; }
.sales-filters summary { cursor: pointer; font-size: 13px; min-height: 28px; }
.sales-filters summary span { float: right; color: var(--muted); font-size: 11px; }
.sales-filters .form-hint { margin: 12px 0; }
.category-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.category-chips label { display: flex; align-items: center; gap: 7px; padding: 10px; min-height: 44px; font-size: 12px; border: 1px solid var(--line); border-radius: 11px; }
.category-chips label:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.category-chips input { accent-color: var(--accent); }
.sales-comparison { margin: 15px 0; }
.sales-result { padding: 17px 12px; }
.sales-result .card-top, .sales-result > .revenue-value, .sales-result > .form-hint, .sales-delta { margin-left: 4px; margin-right: 4px; }
.sales-delta { color: var(--muted); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.sales-chart { width: 100%; min-width: 0; }
.chart-plot { position: relative; height: 245px; width: 100%; }
.is-compact .chart-plot { height: 145px; }
.chart-tooltip { position: absolute; z-index: 4; max-width: min(225px,90%); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 5px 18px #0003; background: var(--card-bg); color: var(--text); pointer-events: none; overflow-wrap: anywhere; }
.tooltip-date { color: var(--muted); font-size: 9px; margin: 3px 0; }
.tooltip-value { font-size: 11px; line-height: 1.5; font-variant-numeric: tabular-nums; margin: 3px 0 7px; }
.chart-empty { min-height: 145px; display: grid; place-content: center; text-align: center; padding: 20px; color: var(--muted); font-size: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 9px; margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 3px; background: transparent; border: 0; color: var(--text); font-size: 10px; }
.legend-item::before { content: ""; height: 7px; width: 7px; background: var(--series-color); border-radius: 50%; flex-shrink: 0; }
.legend-item[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.sales-chart-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin: 16px 0; }
.zoom-actions { display: flex; gap: 5px; }
.zoom-actions button { min-width: 33px; min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--card-bg); color: var(--text); font-size: 11px; }
.chart-scroll-label { display: block; color: var(--muted); font-size: 10px; margin-top: 13px; }
.chart-scroll-label input { display: block; width: 100%; margin: 8px 0; accent-color: var(--accent); }
.chart-hint { color: var(--muted); font-size: 10px; line-height: 1.6; margin: 12px 0 0; }
.sales-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.sales-stats article { padding: 13px 8px; min-width: 0; }
.sales-stats h2 { color: var(--muted); font-size: 10px; font-weight: 400; min-height: 30px; line-height: 1.5; }
.sales-stats strong { display: block; margin-top: 8px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.sales-stats span { display: block; margin-top: 7px; font-size: 9px; color: var(--muted); }
.sales-live { padding: 17px; margin-top: 18px; }
.sales-live h2 { font-size: 14px; margin-top: 13px; }
.shift-status { margin: 12px 0; font-size: 13px; color: var(--link); }
.shift-fields { border: 0; padding: 0; margin: 15px 0; min-width: 0; }
.shift-fact-card { padding: 16px; margin-top: 12px; }
.shift-fact-card h2, .shift-report h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.shift-input-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px 10px; }
.shift-input-grid label { display: flex; flex-direction: column; min-width: 0; gap: 7px; font-size: 11px; color: var(--muted); }
.shift-input-grid input { width: 100%; min-width: 0; min-height: 46px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--page-bg); color: var(--text); font: inherit; font-size: 16px; }
.shift-fact-card .form-hint { margin-top: 12px; }
.shift-actions { display: flex; flex-direction: column; gap: 10px; margin: 17px 0; }
.shift-report { padding: 17px; margin: 15px 0; }
.shift-report summary { font-size: 13px; cursor: pointer; min-height: 30px; }
.shift-report pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 12px; line-height: 1.7; margin: 15px 0; }
@media (prefers-color-scheme: light) {
  :root { --page-bg: var(--tg-theme-secondary-bg-color,#f3f4f0); --card-bg: var(--tg-theme-bg-color,#fff); --text: var(--tg-theme-text-color,#222c25); --muted: var(--tg-theme-hint-color,#66716a); }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page-bg); color: var(--text); }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: wait; opacity: .55; }
button:focus-visible { outline: 2px solid var(--link); outline-offset: 4px; }
button, a { touch-action: manipulation; }
svg { display: block; flex-shrink: 0; }
h1, h2, p { margin: 0; }
.app-shell { max-width: 480px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; padding-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px)); }
.brand-header { display: flex; align-items: center; gap: 11px; padding: 24px 22px 25px; border-bottom: 1px solid var(--line); }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--brand-mark-bg); color: #282b1d; flex-shrink: 0; }
.brand-mark svg { width: 31px; height: 31px; }
.brand-copy { min-width: 0; }
.eyebrow { color: var(--muted); font-size: 9px; letter-spacing: .14em; font-weight: 650; line-height: 1.5; }
.brand-name { margin-top: 2px; font-size: 21px; font-weight: 650; letter-spacing: -.6px; }
.user-avatar { display: grid; place-items: center; width: 34px; height: 34px; margin-left: auto; flex-shrink: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 13px; font-weight: 600; }
main { padding: 25px 20px calc(108px + max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px))); }
.section-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
h1 { margin-top: 4px; font-size: 29px; line-height: 1.15; font-weight: 650; letter-spacing: -.9px; }
.refresh-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--text); font-size: 12px; }
.refresh-button svg { width: 16px; height: 16px; }
.refresh-button.is-loading svg { animation: spin 1.4s linear infinite; }
.notice { display: flex; gap: 10px; padding: 14px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 13px; background: var(--soft); }
.notice-dot { width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.notice-content { min-width: 0; }
#notice-title { font-size: 13px; font-weight: 600; line-height: 1.45; }
#notice-message { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.notice-warning .notice-dot, .notice-error .notice-dot { background: #dba65b; }
.text-button { min-height: 36px; margin: 5px 0 -5px; padding: 4px 0; border: 0; background: transparent; color: var(--link); text-align: left; font-size: 12px; font-weight: 600; }
.shift-context { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 0 2px 19px; }
.shift-context > div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.field-label { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }
.context-value { margin-top: 5px; font-size: 15px; font-weight: 550; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card { border: 1px solid var(--line); border-radius: 18px; background: var(--card-bg); }
.revenue-card { position: relative; overflow: hidden; padding: 20px; background-image: linear-gradient(120deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 75%); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.live-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 9px; letter-spacing: .07em; font-weight: 700; }
.live-badge > span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.live-badge.is-live { color: var(--text); }
.live-badge.is-live > span { background: #88b595; box-shadow: 0 0 0 3px #88b5951a; }
.revenue-value { margin: 15px 0 8px; font-size: clamp(27px, 8.5vw, 39px); line-height: 1.15; font-weight: 620; letter-spacing: -1.2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card-caption { color: var(--muted); font-size: 11px; line-height: 1.5; }
.updated-row { display: flex; align-items: center; gap: 6px; padding-top: 16px; margin-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.4; }
.updated-row svg { width: 14px; height: 14px; }
.metrics-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.metric-card { padding: 17px 15px 16px; }
.metric-value { margin: 12px 0 6px; font-size: clamp(21px, 6vw, 27px); line-height: 1.2; font-weight: 600; letter-spacing: -.6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-empty { color: var(--muted); }
.metric-value.metric-empty, .revenue-value.metric-empty { letter-spacing: 0; }
.channels-section { margin-top: 28px; }
.channels-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 2px 12px; }
.channels-heading h2 { font-size: 15px; font-weight: 600; letter-spacing: -.2px; }
.channels-heading > span { color: var(--muted); font-size: 10px; }
.channel-list { padding: 2px 16px; }
.channel-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 16px 0; }
.channel-row + .channel-row { border-top: 1px solid var(--line); }
.channel-name { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; white-space: nowrap; }
.channel-dot { width: 7px; height: 7px; border-radius: 3px; flex-shrink: 0; }
.channel-offline { background: #8cbaa0; }
.channel-loyalhub { background: #a89ac3; }
.channel-yandex { background: #dbbb75; }
.channel-other { background: #8ca3b7; }
.channel-value { min-width: 0; font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.data-caption { margin: 16px 3px 0; max-width: 295px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.bottom-nav { position: fixed; z-index: 10; bottom: 0; left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(100%, 480px); gap: 2px; padding: 9px 10px calc(9px + max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px))); border-top: 1px solid var(--line); background: var(--card-bg); }
.nav-item { display: flex; align-items: center; flex-direction: column; justify-content: center; gap: 5px; min-height: 52px; padding: 6px 0; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 10px; }
.nav-item svg { width: 21px; height: 21px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.is-active { color: var(--link); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.placeholder-card { display: flex; align-items: center; flex-direction: column; padding: 42px 25px; margin-top: 28px; text-align: center; }
.placeholder-icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 23px; border-radius: 19px; background: var(--soft); color: var(--muted); }
.placeholder-icon svg { width: 38px; height: 38px; }
.placeholder-card > p { max-width: 245px; font-size: 19px; line-height: 1.4; font-weight: 550; letter-spacing: -.3px; }
.placeholder-card > span { margin-top: 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.noscript-notice { position: fixed; z-index: 20; inset: 15px 15px auto; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--card-bg); color: var(--text); }
.inline-notice { padding: 14px 15px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--soft); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.inline-notice.is-error, .form-error { color: var(--tg-theme-destructive-text-color, #efaa97); }
.inline-notice.is-success { color: var(--text); border-color: color-mix(in srgb, #88b595 45%, transparent); }
.primary-button, .secondary-button, .danger-button { min-height: 46px; padding: 12px 16px; border: 1px solid transparent; border-radius: 12px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.primary-button { background: var(--accent); color: var(--accent-text); }
.secondary-button { background: transparent; border-color: var(--line); color: var(--text); }
.danger-button { color: var(--tg-theme-destructive-text-color, #efaa97); background: var(--soft); border-color: currentColor; }
.full-width { width: 100%; }
.section-action { margin-top: 16px; }
.editor-card { margin-top: 18px; padding: 19px 17px; scroll-margin-top: 18px; }
.editor-card h2, .order-card h2 { font-size: 17px; font-weight: 600; }
.editor-card h3 { font-size: 15px; margin: 0; }
.editor-card fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.form-hint, .context-caption { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.context-caption { margin: -6px 2px 18px; }
.input-label { display: block; margin: 18px 0 7px; font-size: 13px; color: var(--muted); }
input, select { width: 100%; min-width: 0; min-height: 48px; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; font: inherit; font-size: 16px; background: var(--page-bg); color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--link); outline-offset: 1px; }
input:disabled, select:disabled { opacity: .65; }
.form-error { margin-top: 13px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.button-row { display: flex; gap: 9px; margin-top: 18px; }
.button-row > button { flex: 1; min-width: 0; }
.confirmation { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.confirmation-summary { margin-top: 10px; white-space: pre-line; overflow-wrap: anywhere; font-size: 14px; line-height: 1.7; }
.list-section { margin-top: 28px; }
.expense-list { list-style: none; margin: 0; padding: 0; }
.expense-item { padding: 16px; margin-bottom: 10px; }
.expense-item-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.expense-item-label { min-width: 0; font-size: 14px; font-weight: 550; overflow-wrap: anywhere; line-height: 1.5; }
.expense-item-amount { flex-shrink: 0; max-width: 58%; font-size: 16px; font-weight: 600; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.expense-item-reason { margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.expense-item-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.delete-link { border: 0; padding: 8px 0 8px 12px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; min-height: 36px; }
.empty-state { padding: 26px 15px; border: 1px dashed var(--line); border-radius: 15px; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.6; }
.supply-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.supply-metrics .metric-card { padding: 15px 10px 12px; }
.supply-metrics .field-label { min-height: 34px; font-size: 11px; }
.supply-metrics .metric-value { font-size: clamp(19px, 5.7vw, 25px); margin: 8px 0 4px; }
.supply-metrics .text-button { font-size: 11px; }
.order-card { padding: 19px; margin-top: 14px; }
.order-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0 15px; }
.order-breakdown > div { display: flex; flex-direction: column; gap: 8px; }
.order-breakdown > div + div { border-left: 1px solid var(--line); padding-left: 17px; }
.order-breakdown strong { font-size: 21px; font-weight: 550; overflow-wrap: anywhere; }
.norms-list { overflow: hidden; }
.norm-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 16px; width: 100%; text-align: left; color: var(--text); background: transparent; border: 0; }
.norm-row + .norm-row { border-top: 1px solid var(--line); }
.norm-name { display: block; font-size: 13px; font-weight: 550; }
.norm-recommendation { display: block; color: var(--muted); margin-top: 5px; font-size: 11px; line-height: 1.5; }
.norm-value { font-size: 17px; font-weight: 550; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 360px) {
  .brand-header { padding-right: 17px; padding-left: 17px; }
  .brand-name { font-size: 20px; }
  main { padding-right: 16px; padding-left: 16px; }
  .revenue-card { padding: 18px; }
  .metric-card { padding-right: 13px; padding-left: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
