/* Минимум: данные — синий, всё остальное — серое, красный — только удаление и ошибка скана. */
:root {
  --bg: #ffffff;
  --fg: #1c1c1e;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --soft: #f2f2f5;
  --blue: #2f6fe4;
  --red: #d93025;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151517;
    --fg: #f2f2f4;
    --muted: #9b9ba2;
    --line: #2c2c31;
    --soft: #1f1f23;
    --blue: #5a8dff;
    --red: #ff6a5c;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; }

.page { max-width: 720px; margin: 0 auto; padding: 16px 16px 48px; }

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
}

h1 { margin: 0; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }

.small { font-size: 13px; }
.muted { color: var(--muted); }
.bad { color: var(--red); }

.periods { display: flex; gap: 2px; font-size: 13px; }

.periods button {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.periods button[aria-pressed="true"] { color: var(--fg); background: var(--soft); }

.status { margin: 12px 0 8px; color: var(--muted); }

.message { margin: 32px 0; color: var(--muted); }

/* Список моделей */
.project { margin: 24px 0 2px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 76px 64px 180px;
  grid-template-areas: "name total delta spark note";
  align-items: center;
  gap: 0 12px;
  padding: 10px 8px;
  margin: 0 -8px;
  border-radius: 8px;
}

.row:hover, .row:focus-visible { background: var(--soft); outline: none; }

.row .name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .total { grid-area: total; text-align: right; }
.row .delta { grid-area: delta; text-align: right; }
.row .spark { grid-area: spark; display: block; }
.row .note { grid-area: note; font-size: 13px; color: var(--muted); }
.row .note.bad { color: var(--red); }

@media (max-width: 600px) {
  .row {
    grid-template-columns: minmax(0, 1fr) auto auto 48px;
    grid-template-areas: "name total delta spark" "note note note note";
  }
  .row .note:empty { display: none; }
}

/* Экран модели */
.back { display: inline-block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.back:hover { color: var(--fg); }

.head-project { font-size: 13px; color: var(--muted); }

.big { margin: 24px 0 0; font-size: 40px; font-weight: 600; line-height: 1.1; }
.sub { margin: 4px 0 24px; color: var(--muted); }

.notice { margin: 0 0 12px; color: var(--red); }

.chart-title { margin: 0 0 4px; font-size: 13px; color: var(--muted); }

.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }

.c-up { fill: var(--blue); }
.c-down { fill: var(--red); }
.c-grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.c-axis { stroke: var(--muted); stroke-width: 1; shape-rendering: crispEdges; opacity: .5; }
.c-label { fill: var(--muted); font-size: 13px; }
/* Обводка цветом фона, чтобы подпись читалась поверх столбика. */
.c-halo { paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.c-band { fill: var(--soft); }
.c-spark { fill: none; stroke: var(--blue); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }

details.days { margin: 12px 0 0; font-size: 13px; }
details.days summary { display: inline; cursor: pointer; color: var(--muted); list-style: none; }
details.days summary::-webkit-details-marker { display: none; }
details.days summary:hover { color: var(--fg); }
details.days ol { list-style: none; margin: 8px 0 0; padding: 0; max-width: 260px; }
details.days li { display: flex; justify-content: space-between; padding: 2px 0; }

table.cats { width: 100%; margin-top: 28px; border-collapse: collapse; }
table.cats th { font-size: 13px; font-weight: normal; color: var(--muted); text-align: right; padding: 0 0 6px 12px; }
table.cats th:first-child { text-align: left; padding-left: 0; }
table.cats td { padding: 8px 0 8px 12px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
table.cats td:first-child { padding-left: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
table.cats tbody tr { cursor: pointer; }
table.cats tbody tr:hover td, table.cats tbody tr:focus-visible td { background: var(--soft); outline: none; }
table.cats tbody tr.selected td { background: var(--soft); font-weight: 600; }
table.cats .qty { color: var(--muted); }

@media (max-width: 480px) {
  table.cats .qty { display: none; }
}

.tip {
  position: fixed;
  z-index: 10;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-size: 13px;
  pointer-events: none;
}
