/* NZ.UA Helper — Telegram Mini App */

/* Layout: Telegram-native grouped sections on the secondary background; the key numbers sit on
   notebook-grid cards with a red margin line, like a school exercise book; fixed bottom tab bar. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #eef1f5);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #161a20);
  --hint: var(--tg-theme-hint-color, #6e7784);
  --head: var(--tg-theme-section-header-text-color, #6e7784);
  --accent: var(--tg-theme-button-color, #2a76ee);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2a76ee);
  --danger: var(--tg-theme-destructive-text-color, #df3a3f);
  --line: var(--tg-theme-section-separator-color, #e4e8ed);
  --paper-margin: #e98597;

  /* 12-бальна шкала: високий / достатній / середній / початковий рівень */
  --g-high: #12904e;
  --g-good: #b37b00;
  --g-mid: #d9621a;
  --g-low: #d5383e;
  /* контрольні, тематичні та інші роботи, про які треба знати заздалегідь */
  --work: #e09a00;
  --work-text: #8a5c00;

  --press: rgb(22 26 32 / 0.06);
  --shadow: 0 1px 2px rgb(22 30 45 / 0.05), 0 10px 24px -12px rgb(22 30 45 / 0.18);
  --scrim: rgb(10 14 20 / 0.42);
  --toast-bg: #1d232c;
  --toast-fg: #f4f6f9;
  --tint: color-mix(in srgb, var(--accent) 12%, transparent);
  --grid: color-mix(in srgb, var(--accent) 11%, transparent);
  --muted-fill: color-mix(in srgb, var(--text) 7%, transparent);

  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;

  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-t: var(--tg-content-safe-area-inset-top, 0px);
  --tabbar-h: 58px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--tg-theme-secondary-bg-color, #0d1015);
    --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #171b22));
    --text: var(--tg-theme-text-color, #edf0f4);
    --hint: var(--tg-theme-hint-color, #8b95a3);
    --head: var(--tg-theme-section-header-text-color, #8b95a3);
    --accent: var(--tg-theme-button-color, #4a8ef6);
    --on-accent: var(--tg-theme-button-text-color, #ffffff);
    --link: var(--tg-theme-link-color, #6ea6ff);
    --danger: var(--tg-theme-destructive-text-color, #ff5e63);
    --line: var(--tg-theme-section-separator-color, #252b34);
    --paper-margin: #b9586a;
    --g-high: #3fcf88;
    --g-good: #f1b73a;
    --g-mid: #ff8d4f;
    --g-low: #ff6469;
    --work: #f5b52e;
    --work-text: #f5c35a;
    --press: rgb(255 255 255 / 0.06);
    --shadow: 0 0 0 1px rgb(255 255 255 / 0.04);
    --scrim: rgb(0 0 0 / 0.55);
    --toast-bg: #f1f3f6;
    --toast-fg: #14181e;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: var(--tg-theme-secondary-bg-color, #0d1015);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #171b22));
  --text: var(--tg-theme-text-color, #edf0f4);
  --hint: var(--tg-theme-hint-color, #8b95a3);
  --head: var(--tg-theme-section-header-text-color, #8b95a3);
  --accent: var(--tg-theme-button-color, #4a8ef6);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #6ea6ff);
  --danger: var(--tg-theme-destructive-text-color, #ff5e63);
  --line: var(--tg-theme-section-separator-color, #252b34);
  --paper-margin: #b9586a;
  --g-high: #3fcf88;
  --g-good: #f1b73a;
  --g-mid: #ff8d4f;
  --g-low: #ff6469;
  --work: #f5b52e;
  --work-text: #f5c35a;
  --press: rgb(255 255 255 / 0.06);
  --shadow: 0 0 0 1px rgb(255 255 255 / 0.04);
  --scrim: rgb(0 0 0 / 0.55);
  --toast-bg: #f1f3f6;
  --toast-fg: #14181e;
  color-scheme: dark;
}

/* ── база ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.4 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, p, blockquote { margin: 0; }
img { max-width: 100%; }
a { color: var(--link); text-decoration: none; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: inherit;
  cursor: pointer;
}
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

.icon { display: inline-flex; width: 22px; height: 22px; flex: none; }
.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── каркас екрана ────────────────────────────────────────────────────── */
.view { max-width: 640px; margin: 0 auto; }
.screen {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: calc(14px + var(--safe-t)) calc(var(--tabbar-h) + var(--safe-b) + 28px);
}
.screen.enter { animation: enter 0.22s ease-out both; }
@keyframes enter { from { opacity: 0.35; transform: translateY(6px); } }
.stack { display: flex; flex-direction: column; gap: 22px; }

.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.topbar-text { display: grid; gap: 3px; min-width: 0; }
.topbar-actions { display: flex; gap: 8px; flex: none; }
.title {
  font: 600 24px/1.15 var(--font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.subtitle { color: var(--hint); font-size: 14px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text);
  flex: none;
}
.icon-btn .icon { width: 20px; height: 20px; }
.pill-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  background: var(--tint);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.icon-btn:active, .pill-btn:active, .chip:active, .wk-day:active { transform: scale(0.95); }

.demo {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--tint);
  font-size: 13px;
  line-height: 1.4;
}
.demo b { color: var(--accent); }
.demo .icon { width: 18px; height: 18px; color: var(--accent); margin-top: 1px; }

/* ── секції та списки ─────────────────────────────────────────────────── */
.section { display: grid; gap: 8px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}
.section-title {
  color: var(--head);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.section-action { color: var(--link); font-size: 14px; font-weight: 500; }
.section-note { padding: 0 4px; color: var(--hint); font-size: 13px; line-height: 1.4; }

.card { background: var(--surface); border-radius: 16px; overflow: hidden; }
.list > * { position: relative; }
.list > * + *::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--sep-inset, 14px);
  right: 0;
  height: 1px;
  background: var(--line);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 11px 14px;
}
button.row:active { background: var(--press); }
.row-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-title { font-weight: 500; overflow-wrap: anywhere; }
.row-sub { color: var(--hint); font-size: 13px; line-height: 1.35; }
.row .chev { width: 18px; height: 18px; color: var(--hint); opacity: 0.7; }
.row-ico {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--tint);
  color: var(--accent);
  flex: none;
}
.row-ico .icon { width: 18px; height: 18px; }
.with-ico { --sep-inset: 56px; }
.row.is-accent { color: var(--link); }
.row.is-danger { color: var(--danger); }
.row.is-danger .row-ico { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.check { color: var(--accent); width: 20px; height: 20px; }
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--bg);
  color: var(--hint);
  font-size: 12px;
  font-weight: 500;
}

/* ── оцінка ───────────────────────────────────────────────────────────── */
.mark {
  --c: var(--hint);
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 10px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  font: 600 14px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.mark-md { min-width: 40px; height: 40px; border-radius: 12px; font-size: 16px; }
.mark-lg { min-width: 48px; height: 48px; border-radius: 14px; font-size: 19px; }
.mark-avg { min-width: 52px; }
.mark.is-text { font: 600 12px/1 var(--font-body); }
.mark.is-absent {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--hint) 45%, transparent);
}
.mark.is-empty { background: transparent; font-family: var(--font-body); }

/* ── зошит ────────────────────────────────────────────────────────────── */
.notebook {
  position: relative;
  border-radius: 20px;
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 17px 17px;
  background-position: -1px -1px;
  box-shadow: var(--shadow);
}
.has-margin { --margin-w: 86px; }
.has-margin::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: var(--margin-w);
  width: 1.5px;
  background: var(--paper-margin);
  pointer-events: none;
}
.margin-mark {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 12px 6px;
  text-align: center;
}
.margin-mark strong {
  color: var(--c, var(--text));
  font: 700 30px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  transform: rotate(-4deg);
}
.margin-mark span { color: var(--hint); font-size: 11px; line-height: 1.2; }

.now {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 16px 18px;
  text-align: left;
}
.eyebrow {
  color: var(--hint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.now .eyebrow { color: var(--accent); }
.now-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.now-time { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.now-subject {
  font: 600 22px/1.2 var(--font-display);
  letter-spacing: -0.01em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.now-meta { color: var(--hint); font-size: 14px; }
.now-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding-top: 8px;
  color: var(--hint);
  font-size: 13px;
}
.dots { display: flex; gap: 5px; }
.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--hint) 60%, transparent);
}
.dots i.is-done { background: color-mix(in srgb, var(--hint) 55%, transparent); border-color: transparent; }
.dots i.is-now { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint); }

.avg {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--margin-w);
  width: 100%;
  text-align: left;
}
.avg-main { display: grid; gap: 4px; align-content: start; min-width: 0; padding: 16px 16px 16px 18px; }
.avg-level { font: 600 18px/1.25 var(--font-display); letter-spacing: -0.01em; }
.avg-sub { color: var(--hint); font-size: 13px; }
.avg-extremes { display: grid; gap: 6px; padding-top: 10px; }
.extreme { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.extreme-label { color: var(--hint); flex: none; }
.extreme-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.extreme b { color: var(--c); font: 600 13px/1 var(--font-display); font-variant-numeric: tabular-nums; }

.dist { display: grid; gap: 8px; padding-top: 12px; }
.dist-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line); }
.dist-bar span { background: var(--c); min-width: 3px; }
.dist-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--hint); font-size: 12px; }
.dist-legend b { color: var(--c); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── головна ──────────────────────────────────────────────────────────── */
.hello { display: flex; align-items: center; gap: 12px; }
.avatar {
  --size: 44px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 70%, #ffffff), var(--accent));
  color: var(--on-accent);
  font: 600 calc(var(--size) * 0.34)/1 var(--font-display);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { --size: 78px; }
.avatar-sm { --size: 34px; }
.acc-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
}
.acc-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-chip .icon { width: 16px; height: 16px; color: var(--hint); transform: rotate(90deg); }

.hscroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-block: 2px 4px;
}
.hscroll::-webkit-scrollbar { display: none; }
.mini {
  flex: none;
  width: 150px;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  scroll-snap-align: start;
}
.mini .mark { justify-self: start; }
.mini-subject { font-size: 14px; font-weight: 600; line-height: 1.25; }
.mini-meta { color: var(--hint); font-size: 12px; line-height: 1.3; }
.hw-row { align-items: flex-start; }
.hw-row .row-sub { color: var(--text); opacity: 0.8; font-size: 14px; }
.hw-row .icon { width: 16px; height: 16px; color: var(--hint); }

/* ── розклад ──────────────────────────────────────────────────────────── */
.week { display: grid; grid-template-columns: repeat(var(--days, 5), minmax(0, 1fr)); gap: 6px; }
.wk-day {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 8px 0 7px;
  border-radius: 14px;
  background: var(--surface);
}
.wk-day .wd { color: var(--hint); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.wk-day .dn { font: 600 18px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.wk-dots { display: flex; gap: 3px; height: 5px; }
.wk-day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.wk-day .dot.is-off { visibility: hidden; }
.wk-day .dot.is-work { background: var(--work); }
.wk-day.is-today .dn { color: var(--accent); }
.wk-day.is-selected { background: var(--accent); }
.wk-day.is-selected .wd, .wk-day.is-selected .dn { color: var(--on-accent); }
.wk-day.is-selected .dot { background: var(--on-accent); }
.wk-day.is-selected .dot.is-work { background: var(--work); box-shadow: 0 0 0 1px var(--on-accent); }

.type-tag {
  justify-self: start;
  padding: 2px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--work) 18%, transparent);
  color: var(--work-text);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.5;
}
.mark-comment { display: flex; align-items: flex-start; gap: 6px; color: var(--hint); font-size: 13px; line-height: 1.4; }
.mark-comment .icon { width: 14px; height: 14px; margin-top: 2px; }
.with-when { --sep-inset: 66px; }
.when { width: 40px; flex: none; display: grid; justify-items: center; gap: 1px; }
.when span { color: var(--hint); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.when b { font: 600 17px/1.15 var(--font-display); font-variant-numeric: tabular-nums; }

.day { display: grid; gap: 10px; touch-action: pan-y; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px; }
.day-title { font-size: 16px; font-weight: 600; }
.day-count { color: var(--hint); font-size: 13px; white-space: nowrap; }

.lesson {
  --sep-inset: 58px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}
.lesson-num {
  color: var(--hint);
  font: 600 20px/1.25 var(--font-display);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.lesson.is-now .lesson-num { color: var(--accent); }
.lesson.is-past .lesson-num { opacity: 0.5; }
.lesson-body { display: grid; gap: 4px; min-width: 0; }
.lesson-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.lesson-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.lesson-subject { font-size: 16px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.lesson-marks { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.lesson-meta { color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.now-pill {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hw {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
.hw > .icon { width: 17px; height: 17px; margin-top: 2px; color: var(--accent); }
.hw-text { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.hw-text p { white-space: pre-line; }
.chip-btn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--tint);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
}
.chip-btn .icon { width: 16px; height: 16px; }
.is-busy { opacity: 0.55; pointer-events: none; }

/* ── оцінки ───────────────────────────────────────────────────────────── */
.seg {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  padding: 3px;
  border-radius: 12px;
  background: var(--muted-fill);
}
.seg button {
  padding: 8px 6px;
  border-radius: 9px;
  color: var(--hint);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.subj-main { flex: 1; min-width: 0; display: grid; gap: 5px; }
.subj-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.subj-marks {
  display: flex;
  gap: 7px;
  overflow: hidden;
  white-space: nowrap;
  font: 600 12.5px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  -webkit-mask-image: linear-gradient(90deg, #000 80%, transparent);
  mask-image: linear-gradient(90deg, #000 80%, transparent);
}
.subj-marks span { color: var(--c, var(--hint)); }
.subj-count { color: var(--hint); font: 500 12px/1 var(--font-body); }

.chart { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .axis-label { fill: var(--hint); font: 500 10px var(--font-body); }
.chart .avg-line { stroke: var(--text); stroke-opacity: 0.45; stroke-dasharray: 4 3; }
.chart .avg-label { fill: var(--text); font: 600 10px var(--font-body); }
.chart rect { fill: var(--c, var(--accent)); }
.chart-wrap { padding: 14px 12px 10px; }
.chart-caption { padding: 2px 4px 0; color: var(--hint); font-size: 12px; }

.calc { display: grid; gap: 12px; padding: 14px; }
.calc-text { color: var(--hint); font-size: 13.5px; line-height: 1.45; }
.calc-results { display: grid; gap: 8px; }
.calc-option { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.calc-option b { font-variant-numeric: tabular-nums; }
.marks-date { width: 48px; flex: none; color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }

.report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, 44px);
  gap: 8px;
  align-items: center;
  padding: 11px 14px;
}
.report-row .mark { justify-self: center; }
.report-head {
  padding-block: 9px;
  color: var(--hint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.report-head span + span { text-align: center; }
.report-subject { font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.report-themes { display: flex; flex-wrap: wrap; gap: 3px 10px; padding-top: 3px; color: var(--hint); font-size: 12.5px; }
.report-themes span { display: inline-flex; gap: 5px; align-items: baseline; }
.report-themes b { color: var(--c, var(--text)); font: 600 12px/1 var(--font-display); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; gap: 4px; align-content: start; padding: 12px; border-radius: 16px; background: var(--surface); }
.tile-value { font: 600 24px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.tile-label { color: var(--hint); font-size: 12.5px; line-height: 1.25; }
.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile-sub { color: var(--hint); font-size: 12px; }
.chart rect.bar-day { fill: color-mix(in srgb, var(--accent) 45%, transparent); }
.chart rect.bar-today { fill: var(--accent); }
.chart .value-label { fill: var(--text); font: 600 9px var(--font-body); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.count { font: 600 14px/1 var(--font-display); font-variant-numeric: tabular-nums; }

/* ── новини ───────────────────────────────────────────────────────────── */
.news { --sep-inset: 66px; align-items: flex-start; }
.news-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--tint);
  color: var(--accent);
}
.news-ico .icon { width: 20px; height: 20px; }
.news-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.news-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.news-subject { min-width: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.news-time { flex: none; color: var(--hint); font-size: 12px; white-space: nowrap; }
.news-text { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.news-comment { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--bg); font-size: 14px; }
.news-comment small { color: var(--hint); font-size: 12px; }
.ext-link { justify-self: start; display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 500; }
.ext-link .icon { width: 15px; height: 15px; }
.count-pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* ── профіль ──────────────────────────────────────────────────────────── */
.profile { display: grid; justify-items: center; gap: 8px; padding-top: 8px; text-align: center; }
.profile-name { font: 600 20px/1.25 var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
.profile-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.profile-meta .tag { background: var(--surface); color: var(--text); font-size: 13px; padding: 5px 10px; }
.foot { color: var(--hint); font-size: 12.5px; line-height: 1.45; text-align: center; padding: 0 12px; }
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 15px;
  background: color-mix(in srgb, var(--hint) 35%, transparent);
  cursor: pointer;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* ── кнопки, форма входу, стани ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 0 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
}
.btn:active { transform: scale(0.98); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-tonal { width: auto; min-height: 42px; background: var(--tint); color: var(--accent); font-size: 15px; }
.btn-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn-plain { color: var(--link); min-height: 44px; }

.login { max-width: 460px; margin: 0 auto; padding-top: calc(36px + var(--safe-t)); }
.brand-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: var(--accent);
  font: 700 24px/1 var(--font-display);
  background-size: 12px 12px;
}
.lead { color: var(--hint); font-size: 15px; line-height: 1.5; }
.login-form { display: grid; gap: 14px; }
.field {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 8px 0 14px;
}
.field-label { font-weight: 500; }
.field-input {
  min-width: 0;
  padding: 14px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.field-input::placeholder { color: var(--hint); opacity: 0.75; }
.field-eye { width: 38px; height: 38px; display: grid; place-items: center; color: var(--hint); }
.field-eye .icon { width: 20px; height: 20px; }
.form-error { padding: 0 4px; color: var(--danger); font-size: 14px; }
.hint { padding: 0 8px; color: var(--hint); font-size: 13px; line-height: 1.45; text-align: center; }

.state { display: grid; justify-items: center; gap: 8px; padding: 28px 20px; text-align: center; }
.state-icon { width: 40px; height: 40px; color: var(--hint); }
.state-title { font-size: 16px; font-weight: 600; }
.state-text { max-width: 34ch; color: var(--hint); font-size: 14px; line-height: 1.45; }
.state .btn { margin-top: 6px; }

.skel { background: var(--muted-fill); border-radius: 12px; animation: pulse 1.1s ease-in-out infinite alternate; }
.skel-hero { height: 138px; border-radius: 20px; }
.skel-card { height: 168px; border-radius: 20px; }
.skel-line { height: 12px; border-radius: 6px; }
.skel-line.short { width: 58%; }
.skel-box { width: 34px; height: 34px; border-radius: 10px; flex: none; }
.skel-lines { flex: 1; display: grid; gap: 8px; }
.skel-strip { height: 62px; border-radius: 14px; }
@keyframes pulse { to { opacity: 0.45; } }

/* ── шторка, тост, таббар ─────────────────────────────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.22s;
}
.backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 640px;
  max-height: 90vh;
  max-height: 90dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.is-open { transform: none; }
.sheet-grip {
  flex: none;
  width: 36px;
  height: 5px;
  margin: 8px auto 0;
  border-radius: 3px;
  background: color-mix(in srgb, var(--hint) 45%, transparent);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 8px;
}
.sheet-title { min-width: 0; font: 600 18px/1.25 var(--font-display); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 4px calc(24px + var(--safe-b));
}
.confirm { display: grid; gap: 10px; }
.confirm p { font-size: 15px; line-height: 1.45; padding: 0 4px 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-fg);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-open { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #ffffff; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 6px calc(6px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
}
.tab {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 4px 0;
  color: var(--hint);
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
}
.tab .icon { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab-badge {
  position: absolute;
  top: 0;
  left: calc(50% + 5px);
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
}

/* Рівні 12-бальної шкали — після .mark, щоб перекрити його колір за замовчуванням. */
.lv-high { --c: var(--g-high); }
.lv-good { --c: var(--g-good); }
.lv-mid { --c: var(--g-mid); }
.lv-low { --c: var(--g-low); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
