/* ============ Токени ============ */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-sunken: #eef0f3;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;
  --accent: #1f5fbf;
  --accent-hover: #1a50a3;
  --accent-soft: #e8f0fc;
  --accent-text: #1a50a3;
  --energy: #ffc53d;
  --good: #0a7d32;
  --good-soft: #e6f6ec;
  --warn: #8a5300;
  --warn-soft: #fff4dc;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --neutral-soft: #f0f1f4;
  --series-1: #2a78d6;
  --grid: #eceef1;
  --focus: 0 0 0 3px rgb(31 95 191 / 0.35);
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow: 0 1px 3px rgb(16 24 40 / 0.06), 0 4px 12px rgb(16 24 40 / 0.05);
  --shadow-lg: 0 12px 40px rgb(16 24 40 / 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #121316;
  --surface: #1b1c20;
  --surface-2: #202126;
  --surface-sunken: #16171a;
  --border: #2c2e34;
  --border-strong: #3b3e46;
  --text: #f0efec;
  --text-2: #c3c2bd;
  --text-3: #9b9a96;
  --accent: #4a8fe8;
  --accent-hover: #6aa3ee;
  --accent-soft: #1c2b42;
  --accent-text: #8cb9f3;
  --good: #4cc26f;
  --good-soft: #15291c;
  --warn: #f2b443;
  --warn-soft: #2e2511;
  --bad: #f07067;
  --bad-soft: #351816;
  --neutral-soft: #26272c;
  --series-1: #3987e5;
  --grid: #2a2b30;
  --focus: 0 0 0 3px rgb(74 143 232 / 0.45);
  --shadow-sm: none;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #121316;
    --surface: #1b1c20;
    --surface-2: #202126;
    --surface-sunken: #16171a;
    --border: #2c2e34;
    --border-strong: #3b3e46;
    --text: #f0efec;
    --text-2: #c3c2bd;
    --text-3: #9b9a96;
    --accent: #4a8fe8;
    --accent-hover: #6aa3ee;
    --accent-soft: #1c2b42;
    --accent-text: #8cb9f3;
    --good: #4cc26f;
    --good-soft: #15291c;
    --warn: #f2b443;
    --warn-soft: #2e2511;
    --bad: #f07067;
    --bad-soft: #351816;
    --neutral-soft: #26272c;
    --series-1: #3987e5;
    --grid: #2a2b30;
    --focus: 0 0 0 3px rgb(74 143 232 / 0.45);
    --shadow-sm: none;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.55);
  }
}

/* ============ База ============ */
[hidden] {
  display: none !important;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
main {
  flex: 1;
  outline: none;
}
h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  font-weight: 700;
}
h2 {
  font-size: 1.2rem;
  font-weight: 650;
}
h3 {
  font-size: 1rem;
  font-weight: 650;
}
p {
  margin: 0;
}
a {
  color: var(--accent-text);
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--text-3);
}
.secondary {
  color: var(--text-2);
}
.small {
  font-size: 0.875rem;
}
.xs {
  font-size: 0.8125rem;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: 8px;
  top: -40px;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus {
  top: 8px;
}
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 720px) {
  .container {
    padding: 0 24px;
  }
}
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm {
  width: 16px;
  height: 16px;
}
.icon-lg {
  width: 28px;
  height: 28px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap, 16px);
}
.row {
  display: flex;
  align-items: center;
  gap: var(--gap, 12px);
  flex-wrap: wrap;
}
.spacer {
  flex: 1;
}

/* ============ Шапка ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.12);
}
.brand-mark svg {
  width: 22px;
  height: 22px;
  fill: var(--energy);
  stroke: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}
.brand-title {
  font-weight: 700;
  font-size: 0.98rem;
  white-space: nowrap;
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.topnav a.navlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 550;
  font-size: 0.92rem;
}
.topnav a.navlink:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.topnav a.navlink[aria-current='page'] {
  color: var(--accent-text);
  background: var(--accent-soft);
}
.role-chip {
  font-size: 0.75rem;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  white-space: nowrap;
}
@media (max-width: 719px) {
  .topnav .navlink span.label,
  .hide-sm {
    display: none !important;
  }
}

/* ============ Кнопки ============ */
.btn {
  --h: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--h);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  background: var(--surface-sunken);
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
:root[data-theme='dark'] .btn-primary,
:root:not([data-theme='light']) .btn-primary {
  color: #fff;
}
.btn-danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.btn-danger:hover {
  filter: brightness(0.95);
  background: var(--bad);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.btn-sm {
  --h: 36px;
  padding: 0 12px;
  font-size: 0.875rem;
}
.btn-lg {
  --h: 52px;
  padding: 0 22px;
  font-size: 1.02rem;
}
.btn-icon {
  --h: 40px;
  width: var(--h);
  padding: 0;
}
.btn-block {
  width: 100%;
}

/* ============ Поля ============ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label,
.label {
  font-weight: 600;
  font-size: 0.9rem;
}
.hint {
  font-size: 0.85rem;
  color: var(--text-3);
}
.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder {
  color: var(--text-3);
  opacity: 0.8;
}
.input:hover {
  border-color: var(--text-3);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}
.input[disabled] {
  background: var(--surface-sunken);
  color: var(--text-2);
  cursor: not-allowed;
}
.input-error {
  border-color: var(--bad) !important;
}
.input-warn {
  border-color: var(--warn) !important;
}
.field-error {
  color: var(--bad);
  font-size: 0.85rem;
  font-weight: 550;
}
.search {
  position: relative;
}
.search .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.search .input {
  padding-left: 44px;
}

/* ============ Картки / секції ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad {
  padding: 20px;
}
@media (max-width: 559px) {
  .card-pad {
    padding: 16px;
  }
}
.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 28px 0 12px;
}
.section-title .count {
  color: var(--text-3);
  font-weight: 500;
  font-size: 0.95rem;
}
.page-head {
  padding: 28px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 550;
  font-size: 0.92rem;
  padding: 6px 8px 6px 2px;
  border-radius: 8px;
  align-self: flex-start;
}
.back-link:hover {
  color: var(--text);
}
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 0;
  color: var(--text-3);
}
.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============ Плашки статусу ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
  line-height: 1.4;
}
.badge .icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}
.badge-done {
  background: var(--good-soft);
  color: var(--good);
}
.badge-partial {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-none {
  background: var(--bad-soft);
  color: var(--bad);
}
.badge-empty,
.badge-neutral {
  background: var(--neutral-soft);
  color: var(--text-2);
}
.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ============ Банери ============ */
.banner {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  align-items: flex-start;
}
.banner .icon {
  margin-top: 2px;
}
.banner-info {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--text);
}
.banner-info .icon {
  color: var(--accent-text);
}
.banner-warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}
.banner-warn .icon {
  color: var(--warn);
}
.banner-bad {
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
}
.banner-bad .icon {
  color: var(--bad);
}
.banner-good {
  background: var(--good-soft);
  border-color: color-mix(in srgb, var(--good) 30%, transparent);
}
.banner-good .icon {
  color: var(--good);
}

/* ============ Головна ============ */
.hero {
  padding: 32px 0 8px;
  display: grid;
  gap: 16px;
}
.hero p.lead {
  color: var(--text-2);
  font-size: 1.05rem;
  max-width: 60ch;
}
.deadline-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: var(--shadow-sm);
  justify-self: start;
}
.deadline-pill .icon {
  color: var(--accent-text);
}
.deadline-pill.urgent .icon {
  color: var(--bad);
}
.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--good);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.continue-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), var(--surface);
}
.continue-card:hover {
  border-color: var(--accent);
}
.continue-card .arrow {
  margin-left: auto;
  color: var(--accent-text);
}
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
@media (max-width: 559px) {
  .unit-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
.unit-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  min-height: 72px;
}
.unit-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.unit-card:active {
  transform: scale(0.995);
}
.unit-card .code {
  font-weight: 700;
  font-size: 1.05rem;
}
.unit-card .place {
  color: var(--text-3);
  font-size: 0.88rem;
}
.unit-card .meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.unit-card .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-state .icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ============ Сторінка частини ============ */
.unit-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.unit-title .place {
  color: var(--text-3);
  font-size: 1.05rem;
  font-weight: 500;
}
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  align-self: flex-start;
  max-width: 100%;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.tab:hover {
  color: var(--text);
}
.tab[aria-selected='true'],
.tab[aria-current='page'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.month-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
}
.month-nav .label {
  min-width: 150px;
  text-align: center;
  font-weight: 650;
  text-transform: capitalize;
  padding: 0 4px;
}
.month-nav .btn {
  --h: 36px;
}

.meter-list {
  display: grid;
  gap: 12px;
}
.meter {
  padding: 16px;
  display: grid;
  gap: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.meter.is-dirty {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}
.meter-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.meter-name {
  font-weight: 650;
  font-size: 1.05rem;
  word-break: break-word;
}
.meter-prev {
  color: var(--text-3);
  font-size: 0.88rem;
}
.meter-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  margin-top: -6px;
  margin-right: -6px;
}
.meter-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
@media (min-width: 640px) {
  .meter-body {
    grid-template-columns: minmax(0, 320px) 1fr;
    align-items: center;
    gap: 16px;
  }
}
.reading-input {
  position: relative;
}
.reading-input .input {
  font-size: 1.35rem;
  font-weight: 650;
  min-height: 56px;
  padding-right: 84px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.reading-input .unit-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-weight: 600;
  font-size: 0.9rem;
  pointer-events: none;
}
.meter-calc {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 44px;
  justify-content: center;
}
.meter-calc .delta {
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.meter-calc .delta.bad {
  color: var(--bad);
}
.meter-calc .delta.warn {
  color: var(--warn);
}
.meter-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-3);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.meter-foot .ok {
  color: var(--good);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.meter-foot .pending {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--text-2);
}
.add-meter {
  border-style: dashed;
  border-width: 1.5px;
  background: transparent;
  box-shadow: none;
}
.add-meter-btn {
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--accent-text);
  font-weight: 650;
  border-radius: var(--radius);
}
.add-meter-btn:hover {
  background: var(--accent-soft);
}
.add-form {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  margin: 20px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(110%);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  pointer-events: none;
}
.save-bar.visible {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}
.save-bar .info {
  flex: 1;
  font-weight: 600;
  min-width: 0;
}
@media (min-width: 720px) {
  .save-bar {
    margin: 20px 0 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    bottom: 16px;
    box-shadow: var(--shadow-lg);
  }
}

details.trash {
  margin-top: 24px;
}
details.trash > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-weight: 600;
  padding: 10px 4px;
  border-radius: 8px;
}
details.trash > summary::-webkit-details-marker {
  display: none;
}
details.trash > summary .chev {
  transition: transform 0.2s;
}
details.trash[open] > summary .chev {
  transform: rotate(90deg);
}
.trash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.trash-item:first-child {
  border-top: 0;
}

/* ============ Таблиці ============ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-weight: 600;
  color: var(--text-3);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.table tbody tr.clickable {
  cursor: pointer;
}
.table tbody tr.clickable:hover {
  background: var(--surface-2);
}
.table .unit-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.table .unit-link:hover {
  color: var(--accent-text);
  text-decoration: underline;
}
.table .sub {
  display: block;
  color: var(--text-3);
  font-size: 0.8rem;
  font-weight: 400;
}
.delta-up {
  color: var(--bad);
}
.delta-down {
  color: var(--good);
}

/* ============ Дашборд ============ */
.kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.kpi {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi .k-label {
  color: var(--text-3);
  font-size: 0.85rem;
  font-weight: 600;
}
.kpi .k-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.kpi .k-value .k-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-3);
  margin-left: 4px;
}
.kpi.hero .k-value {
  font-size: 2.6rem;
}
.kpi .k-sub {
  font-size: 0.88rem;
  color: var(--text-2);
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-2);
}
.chip:hover {
  color: var(--text);
}
.chip[aria-pressed='true'] {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.chip .n {
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}
.grid-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============ Графіки ============ */
.chart {
  position: relative;
  width: 100%;
}
.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}
.chart .grid-line {
  stroke: var(--grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.chart .axis-text {
  fill: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chart .value-text {
  fill: var(--text);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.chart .bar {
  fill: var(--series-1);
  transition: opacity 0.15s;
}
.chart .bar.dim {
  opacity: 0.35;
}
.chart .hit {
  fill: transparent;
  cursor: default;
}
.chart .hit:focus-visible {
  outline: none;
  stroke: var(--accent);
  stroke-width: 2;
}
.chart .baseline {
  stroke: var(--border-strong);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
  z-index: 5;
  transform: translate(-50%, calc(-100% - 10px));
  opacity: 0;
  transition: opacity 0.1s;
}
.tooltip.show {
  opacity: 1;
}
.tooltip .t-title {
  color: var(--text-3);
  font-size: 0.78rem;
  text-transform: capitalize;
}
.tooltip .t-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chart-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-3);
}

/* ============ Модальні вікна ============ */
dialog.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(520px, calc(100vw - 24px));
  width: 100%;
  color: inherit;
}
dialog.modal::backdrop {
  background: rgb(10 14 22 / 0.55);
  backdrop-filter: blur(2px);
}
dialog.modal[open] .modal-card {
  animation: pop 0.18s ease;
}
@keyframes pop {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }
}
.modal-card {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  display: grid;
  gap: 16px;
}
.modal-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.modal-icon.danger {
  background: var(--bad-soft);
  color: var(--bad);
}
.modal-icon.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap-reverse;
}
@media (max-width: 479px) {
  .modal-actions .btn {
    flex: 1;
  }
}
.confirm-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 46vh;
  overflow-y: auto;
}
.confirm-list .item {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.confirm-list .item:first-child {
  border-top: 0;
}
.confirm-list .item .name {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.confirm-list .item .val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.confirm-list .item.warn {
  background: var(--warn-soft);
}
code.kbd {
  font-family: inherit;
  font-weight: 700;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  word-break: break-word;
}

/* ============ Сповіщення ============ */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1d2433;
  color: #f4f6fa;
  box-shadow: var(--shadow-lg);
  font-weight: 550;
  font-size: 0.92rem;
  animation: toast-in 0.2s ease;
}
:root[data-theme='dark'] .toast {
  background: #2c2e35;
}
.toast .icon {
  color: #7ad694;
}
.toast.error .icon {
  color: #ff8a80;
}
.toast .msg {
  flex: 1;
}
.toast button {
  background: transparent;
  border: 0;
  color: #9cc3ff;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
}
.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.2s;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ============ Вхід ============ */
.login-wrap {
  max-width: 420px;
  margin: 48px auto;
}

/* ============ Футер ============ */
.footer {
  padding-top: 32px;
  padding-bottom: 28px;
  color: var(--text-3);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}
.footer a {
  color: var(--text-2);
}

/* ============ Журнал ============ */
.log-action {
  display: flex;
  flex-direction: column;
}
.actor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  white-space: nowrap;
}

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

@media print {
  .topbar,
  .footer,
  .save-bar,
  .btn,
  .toasts {
    display: none !important;
  }
  body {
    background: #fff;
  }
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
}
.unit-card .code {
  white-space: nowrap;
}
.unit-card .place {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unit-card {
  align-items: center;
}
.unit-card .status-dot {
  align-self: flex-start;
  margin-top: 8px;
}
.unit-card .chev {
  color: var(--text-3);
  width: 18px;
  height: 18px;
}
