/* =========================================================
   Макет · демоданные — оболочка и экран «Обзор»
   Пакет A. Без внешних ресурсов, без импортов.
   ========================================================= */

/* ---------- Токены темы ---------- */

:root {
  --bg: #fbefdc;
  --panel: #fffaf0;
  --fg: #2a499c;
  --muted: #48597f;
  --accent: #2a499c;
  --line: rgba(42, 73, 156, 0.22);
  --r: 18px;
  --r-sm: 12px;
  --shadow: 0 1px 0 rgba(42, 73, 156, 0.06);
  --caret-bg: #ffffff;
  --caret-ring: #2a499c;
  --pos: #1f6b4a;
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-dot: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color-scheme: light;
}

html[data-theme="light"] {
  --bg: #fbefdc;
  --panel: #fffaf0;
  --fg: #2a499c;
  --muted: #48597f;
  --accent: #2a499c;
  --line: rgba(42, 73, 156, 0.22);
  --caret-bg: #ffffff;
  --caret-ring: #2a499c;
  --pos: #1f6b4a;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0e1c3f;
  --panel: #081229;
  --fg: #fbefdc;
  --muted: #c6cfe8;
  --accent: #9db4f5;
  --line: rgba(251, 239, 220, 0.16);
  --caret-bg: #ffffff;
  --caret-ring: rgba(0, 0, 0, 0.55);
  --pos: #a8dcc0;
  color-scheme: dark;
}

/* Пока JS не выставил data-theme — слушаем системную тему */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #0e1c3f;
    --panel: #081229;
    --fg: #fbefdc;
    --muted: #c6cfe8;
    --accent: #9db4f5;
    --line: rgba(251, 239, 220, 0.16);
    --caret-ring: rgba(0, 0, 0, 0.55);
    --pos: #a8dcc0;
    color-scheme: dark;
  }
}

/* ---------- База ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
}

p,
h1,
h2,
h3,
ul {
  margin: 0;
}

ul {
  list-style: none;
  padding: 0;
}

.app {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- Верхняя панель ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 0 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 3px;
  background-image: radial-gradient(circle, var(--accent) 1.4px, transparent 1.5px);
  background-size: 4px 4px;
  background-color: var(--line);
}

.brand-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sep {
  opacity: 0.55;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--fg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.theme-toggle-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: linear-gradient(90deg, currentColor 0 50%, transparent 50% 100%);
}

.theme-toggle:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Табы ---------- */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.tab {
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.tab.is-active {
  background: var(--accent);
  color: var(--panel);
}

html[data-theme="dark"] .tab.is-active {
  color: #081229;
}

/* ---------- Приветствие ---------- */

.greeting-block {
  margin-bottom: 14px;
}

.greeting {
  position: relative;
  display: block;
  font-family: var(--font-dot);
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
  min-height: 1.25em;
  overflow: hidden;
}

.greeting-measure {
  display: inline-block;
  visibility: hidden;
  padding-right: 10px;
  white-space: pre;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.greeting-live {
  position: absolute;
  inset: 0 0 auto 0;
  display: block;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}

.greeting-text.dot-type {
  white-space: pre;
  letter-spacing: inherit;
  text-transform: none;
}

.caret {
  display: inline-block;
  width: 0.5em;
  height: 0.92em;
  margin-left: 2px;
  vertical-align: -0.06em;
  background: var(--caret-bg);
  box-shadow: 0 0 0 1px var(--caret-ring);

}

@keyframes caret-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.greeting-sub {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

/* ---------- Метки дня ---------- */

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.meta-chip {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  min-width: 0;
}

.meta-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Карточки ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card-title {
  font-size: 12px;
  line-height: 1.3;
}

.card-hint {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}

/* ---------- Точечная типографика ---------- */

.dot-type {
  font-family: var(--font-dot);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: transparent;
  background-image: radial-gradient(circle at 50% 50%, var(--fg) 1.05px, transparent 1.3px);
  background-size: 3px 3px;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@supports not ((background-clip: text) or (-webkit-background-clip: text)) {
  .dot-type {
    color: var(--fg);
    -webkit-text-fill-color: currentColor;
    background: none;
  }
}

@media (forced-colors: active) {
  .dot-type {
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
    background: none;
  }
}

/* ---------- Выручка ---------- */

.big-number {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-dot);
  font-size: 38px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  margin-bottom: 8px;
}

.big-number-cur {
  font-size: 20px;
  font-weight: 600;
  color: var(--muted);
}

.delta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 14px;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--pos);
}

.delta-arrow {
  font-size: 8px;
  transform: translateY(-1px);
}

.delta-note {
  font-size: 11.5px;
  color: var(--muted);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.mini-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mini-label {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.mini-value {
  font-family: var(--font-dot);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  white-space: nowrap;
}

.note {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  border: 1px dashed var(--line);
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

.note-mark {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- График 8 недель ---------- */

.chart {
  min-width: 0;
}

.chart-cols {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 116px;
  padding: 0 2px;
  border-bottom: 1px solid var(--line);
}

.chart-col {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.dot-stack {
  display: block;
  width: 9px;
  height: var(--h, 50%);
  background-image: radial-gradient(circle, var(--accent) 2.9px, transparent 3.05px);
  background-size: 9px 9px;
  background-position: center bottom;
  background-repeat: repeat-y;
}

.chart-col-now .dot-stack {
  background-image: radial-gradient(circle, var(--muted) 2.9px, transparent 3.05px);
  opacity: 0.75;
}

.chart-labels {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
  padding: 0 2px;
}

.chart-labels span {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.chart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 11px;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--muted);
}

.legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.75;
}

.chart-note {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---------- Категории ---------- */

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.cat-row {
  min-width: 0;
}

.cat-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.cat-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg);
  min-width: 0;
  overflow-wrap: anywhere;
}

.cat-val {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.dot-bar {
  display: block;
  width: var(--w, 50%);
  height: 8px;
  background-image: radial-gradient(circle, var(--accent) 2.7px, transparent 2.9px);
  background-size: 9px 8px;
  background-repeat: repeat-x;
}

.dot-bar-dim {
  background-image: radial-gradient(circle, var(--muted) 2.7px, transparent 2.9px);
  opacity: 0.6;
}

.more-link {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Подвал ---------- */

.foot-note {
  margin: 4px 2px 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- Уважение к reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .caret {
    animation: none;
  }
}

/* ---------- Очень узкие экраны ---------- */

@media (max-width: 344px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .greeting {
    font-size: 23px;
  }

  .big-number {
    font-size: 33px;
  }

  .mini-value {
    font-size: 15px;
  }

  .chart-cols {
    height: 100px;
    gap: 4px;
  }

  .brand-text {
    letter-spacing: 0.08em;
  }
}
