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

:root {
  --bg:         #f4f6fa;
  --surface:    #ffffff;
  --surface2:   #f8fafc;
  --border:     #e8edf5;
  --border2:    #d1dae8;
  --text:       #111827;
  --text-muted: #6b7280;
  --text-hint:  #9ca3af;
  --sys:        #dc2626;
  --sys-light:  #fee2e2;
  --dia:        #0369a1;
  --dia-light:  #e0f2fe;
  --pulse:      #b45309;
  --pulse-light:#fef3c7;
  --ok:         #059669;
  --ok-light:   #d1fae5;
  --warn:       #d97706;
  --warn-light: #fef3c7;
  --danger:     #dc2626;
  --accent:     #dc2626;
  --primary:    #4f46e5;
  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.06);
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:  0 6px 24px rgba(0,0,0,0.10);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.13);
  --chart-grid:    #f1f5f9;
  --chart-border:  #e2e8f0;
  --chart-tick:    #94a3b8;
  --tooltip-bg:    #1e293b;
  --tooltip-text:  #f1f5f9;
  --tooltip-muted: #94a3b8;
}

html[data-theme="dark"] {
  --bg:         #0e1117;
  --surface:    #161b26;
  --surface2:   #1e2436;
  --border:     rgba(255,255,255,0.08);
  --border2:    rgba(255,255,255,0.14);
  --text:       #f1f5f9;
  --text-muted: #8b95a8;
  --text-hint:  #5a6478;
  --sys-light:  rgba(220,38,38,0.15);
  --dia-light:  rgba(3,105,161,0.15);
  --pulse-light:rgba(180,83,9,0.15);
  --ok-light:   rgba(5,150,105,0.15);
  --warn-light: rgba(217,119,6,0.15);
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.4);
  --shadow:     0 2px 14px rgba(0,0,0,0.45);
  --shadow-md:  0 6px 28px rgba(0,0,0,0.55);
  --shadow-lg:  0 12px 44px rgba(0,0,0,0.65);
  --chart-grid:    rgba(255,255,255,0.04);
  --chart-border:  rgba(255,255,255,0.07);
  --chart-tick:    #475569;
  --tooltip-bg:    #0f172a;
  --tooltip-text:  #f1f5f9;
  --tooltip-muted: #64748b;
  --primary:       #6366f1;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.35s ease, color 0.35s ease;
  -webkit-font-smoothing: antialiased;
}

/* ── gradient top bar ── */
body::before {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200;
  background: linear-gradient(90deg, #dc2626 0%, #f97316 25%, #eab308 50%, #22c55e 75%, #3b82f6 100%);
  background-size: 200% 100%;
  animation: shimmer 4s linear infinite;
}
@keyframes shimmer { 0%{background-position:0%} 100%{background-position:200%} }

/* ── layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 36px 20px 48px; }

/* ── header ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px; gap: 16px; flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 14px; }
.logo-icon {
  position: relative; width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  background: var(--sys-light);
  border-radius: 16px;
  box-shadow: 0 0 0 0 rgba(220,38,38,0.35);
  animation: heartglow 2s ease-in-out infinite;
}
@keyframes heartglow {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); transform: scale(1); }
  30%     { box-shadow: 0 0 0 8px rgba(220,38,38,0.15); transform: scale(1.05); }
  50%     { box-shadow: 0 0 0 0 rgba(220,38,38,0); transform: scale(1); }
  70%     { box-shadow: 0 0 0 5px rgba(220,38,38,0.10); transform: scale(1.03); }
}
.logo h1 { font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; line-height: 1; }
.logo h1 em { font-style: normal; color: var(--accent); }
.subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; letter-spacing: 0.02em; }
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.last-update {
  font-size: 12px; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 20px;
  box-shadow: var(--shadow-sm);
  transition: background 0.35s, border-color 0.35s;
}

/* ── buttons ── */
.btn {
  border: none; cursor: pointer; border-radius: var(--radius-sm);
  padding: 8px 16px; font-family: inherit; font-size: 13px; font-weight: 600;
  transition: all 0.18s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-print {
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-sm);
}
.btn-print:hover { opacity: 0.85; transform: translateY(-1px); box-shadow: var(--shadow); }
/* ── плавающая кнопка добавления показания/записи ── */
.fab-add {
  position: fixed; right: 24px; bottom: 24px; z-index: 500;
  border: none; border-radius: 12px;
  padding: 14px 22px;
  background: var(--primary); color: #fff;
  font-size: 14px; font-weight: 700; font-family: inherit;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 18px rgba(79,70,229,0.35);
  animation: fabPulse 2.2s ease-in-out infinite;
  transition: transform 0.15s ease;
  white-space: nowrap;
}
.fab-add:hover { transform: translateY(-2px); }
.fab-add:active { transform: translateY(0) scale(0.97); }
@keyframes fabPulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(79,70,229,0.35), 0 0 0 0 rgba(79,70,229,0.4); }
  50%      { box-shadow: 0 6px 18px rgba(79,70,229,0.35), 0 0 0 9px rgba(79,70,229,0); }
}
@media (max-width: 640px) {
  .fab-add { right: 12px; bottom: 12px; padding: 12px 16px; font-size: 13px; }
}
.btn-refresh {
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); transition: all 0.18s;
}
.btn-refresh:hover { color: var(--text); border-color: var(--border2); }
.btn-theme {
  background: var(--surface); border: 1px solid var(--border);
  font-size: 16px; padding: 7px 11px; border-radius: var(--radius-sm);
  line-height: 1; transition: all 0.2s;
}
.btn-theme:hover { background: var(--surface2); transform: rotate(15deg) scale(1.1); }

.btn-lock {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(220,38,38,0.14), rgba(249,115,22,0.16));
  color: var(--accent);
  border: 1px solid rgba(220,38,38,0.22);
  box-shadow: 0 8px 22px rgba(220,38,38,0.12);
  animation: lockFloat 2.6s ease-in-out infinite;
}
.btn-lock::before {
  content: '';
  position: absolute;
  inset: -45%;
  background: radial-gradient(circle, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0) 62%);
  opacity: 0.32;
  animation: lockGlow 2.8s ease-in-out infinite;
}
.btn-lock .lock-emoji,
.btn-lock .lock-text {
  position: relative;
  z-index: 1;
}
.btn-lock .lock-emoji {
  display: inline-block;
  animation: lockBounce 1.7s ease-in-out infinite;
}
.btn-lock:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 28px rgba(220,38,38,0.18);
}
@keyframes lockFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes lockBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.08); }
}
@keyframes lockGlow {
  0%, 100% { transform: scale(0.95) rotate(0deg); opacity: 0.20; }
  50% { transform: scale(1.04) rotate(10deg); opacity: 0.55; }
}

/* ── stat cards ── */
.status-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px;
}
@media (max-width: 860px) { .status-row { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 480px) { .status-row { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px 18px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
  transition: transform 0.22s cubic-bezier(.34,1.56,.64,1), box-shadow 0.22s, background 0.35s, border-color 0.35s;
  cursor: default;
}
.stat-card:hover { transform: translateY(-4px) scale(1.01); box-shadow: var(--shadow-lg); }

/* coloured top accent */
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.9;
}
.card-sys::before   { background: linear-gradient(90deg, #dc2626, #f87171); }
.card-dia::before   { background: linear-gradient(90deg, #0369a1, #38bdf8); }
.card-pulse::before { background: linear-gradient(90deg, #b45309, #fcd34d); }
.card-status::before{ background: linear-gradient(90deg, #059669, #6ee7b7); }

/* big bg icon */
.stat-card .bg-icon {
  position: absolute; bottom: -6px; right: 8px;
  font-size: 56px; opacity: 0.06; pointer-events: none; line-height: 1;
  transition: opacity 0.2s;
}
.stat-card:hover .bg-icon { opacity: 0.11; }

.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; margin-bottom: 10px; }
.stat-value { font-size: 44px; font-weight: 800; line-height: 1; margin-bottom: 6px; letter-spacing: -1.5px; }
.stat-unit  { font-size: 12px; color: var(--text-hint); }
.card-sys   .stat-value { color: var(--sys); }
.card-dia   .stat-value { color: var(--dia); }
.card-pulse .stat-value { color: var(--pulse); }
.card-status .stat-value { font-size: 17px; font-weight: 700; letter-spacing: 0; line-height: 1.35; }

/* ── avg row ── */
.avg-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 22px;
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: background 0.35s, border-color 0.35s;
}
@media (max-width: 860px) { .avg-row { grid-template-columns: repeat(2, 1fr); } }

.avg-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 12px;
  border-right: 1px solid var(--border);
  transition: background 0.15s;
}
.avg-item:last-child { border-right: none; }
.avg-item:hover { background: var(--surface2); }
.avg-label { font-size: 11px; color: var(--text-hint); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.avg-value { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }

/* ── admin panel ── */
.admin-panel {
  background: linear-gradient(180deg, rgba(220,38,38,0.05), transparent 35%), var(--surface);
  border: 1px solid rgba(220,38,38,0.14);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}
.admin-panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.admin-panel-title {
  display: flex;
  align-items: center;
  gap: 14px;
}
.admin-panel-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 24px;
  border-radius: 16px;
  color: var(--accent);
  background: var(--sys-light);
  box-shadow: inset 0 0 0 1px rgba(220,38,38,0.08);
}
.admin-panel-title h3 {
  font-size: 18px;
  line-height: 1.15;
  margin-bottom: 4px;
}
.admin-panel-title p {
  color: var(--text-muted);
  font-size: 13px;
}
.admin-panel-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}
.admin-panel-controls label {
  font-size: 11px;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}
.admin-panel-controls select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font: inherit;
}
.admin-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.admin-summary-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.admin-summary-card span {
  font-size: 11px;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.admin-summary-card strong {
  font-size: 22px;
  letter-spacing: -0.03em;
  color: var(--text);
}
@media (max-width: 920px) {
  .admin-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .admin-summary { grid-template-columns: 1fr; }
}

/* ── tabs wrap ── */
.tabs-wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.tabs {
  display: flex; gap: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px;
  box-shadow: var(--shadow-sm);
  transition: background 0.35s, border-color 0.35s;
}
.tab {
  border: none; cursor: pointer;
  padding: 7px 18px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-muted); background: transparent;
  transition: all 0.2s;
}
.tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(220,38,38,0.35);
}
.tab:not(.active):hover { color: var(--text); background: var(--surface2); }

/* ── chart card ── */
.chart-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: background 0.35s, border-color 0.35s;
}
.chart-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.chart-header-left { display: flex; flex-direction: column; gap: 6px; }
.chart-title { font-size: 15px; font-weight: 700; color: var(--text); }
.legend-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
}
.legend-item {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px 3px 5px; border-radius: 8px;
  transition: opacity 0.28s ease, transform 0.28s ease,
              background 0.28s ease, font-weight 0s;
  cursor: default; position: relative;
}
.legend-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  transition: width 0.28s ease, height 0.28s ease,
              box-shadow 0.28s ease, transform 0.28s ease;
}

/* ── dim: остальные параметры ── */
.legend-item.legend-dim {
  opacity: 0.18;
  transform: scale(0.88);
}

/* ── active: выбранный параметр ── */
.legend-item.legend-active {
  font-weight: 700;
  transform: scale(1.13);
}
.legend-item.legend-active .legend-dot {
  width: 12px; height: 12px;
  box-shadow: 0 0 0 3px var(--legend-glow),
              0 0 14px var(--legend-glow);
  animation: legendPing 1.4s ease-in-out infinite;
}

/* пульс-кольцо вокруг dot */
@keyframes legendPing {
  0%   { box-shadow: 0 0 0 2px var(--legend-glow), 0 0  8px var(--legend-glow); transform: scale(1);    }
  50%  { box-shadow: 0 0 0 6px var(--legend-glow), 0 0 20px var(--legend-glow); transform: scale(1.18); }
  100% { box-shadow: 0 0 0 2px var(--legend-glow), 0 0  8px var(--legend-glow); transform: scale(1);    }
}

/* текстовое свечение совпадающего цвета */
.legend-item.legend-active {
  text-shadow: 0 0 10px var(--legend-glow, transparent);
}
.legend-norm { margin-left: auto; font-size: 11px; color: var(--text-hint); }
.chart-badge {
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--sys-light); color: var(--sys);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: 20px; padding: 4px 12px;
  transition: background 0.35s;
}
.chart-wrap { position: relative; height: 350px; }
.no-data {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 70px 20px; text-align: center;
  color: var(--text-muted); font-size: 15px;
}
.no-data-icon { font-size: 44px; opacity: 0.5; }
.no-data-hint { font-size: 13px; color: var(--text-hint); }
.hidden { display: none !important; }

/* ── card tooltip ── */
.card-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%; transform: translateX(-50%) translateY(-6px);
  min-width: 210px;
  background: var(--text);
  color: var(--bg);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.6;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
.card-tooltip::after {
  content: '';
  position: absolute;
  bottom: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--text);
}
.stat-card:hover .card-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.stat-card { overflow: visible; }

.tip-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 20px; padding: 2px 0;
}
.tip-label { opacity: 0.6; font-weight: 500; }
.tip-value { font-weight: 700; font-size: 13px; }
.tip-divider {
  border: none; border-top: 1px solid rgba(255,255,255,0.12);
  margin: 8px 0;
}
.tip-title {
  font-weight: 700; font-size: 12px; text-align: center;
  opacity: 0.5; text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}

/* ── trend indicator on cards ── */
.trend { font-size: 11px; font-weight: 600; margin-top: 4px; }
.trend-up   { color: var(--danger); }
.trend-down { color: var(--ok); }
.trend-flat { color: var(--text-hint); }

/* ── table ── */
.table-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); margin-bottom: 24px;
  transition: background 0.35s, border-color 0.35s;
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.table-header h3 { font-size: 14px; font-weight: 700; color: var(--text); }
.table-count { font-size: 12px; color: var(--text-hint); }
.table-scroll { overflow: auto; max-height: 68vh; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-hint); font-weight: 600;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  transition: background 0.35s;
  position: sticky; top: 0; z-index: 5;
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface2); }

/* подсветка строки при наведении → точки на графике */
.table-row-hover { cursor: crosshair; transition: background 0.15s; }
.table-row-hover:hover td {
  background: var(--surface2) !important;
  position: relative;
}
/* левая цветная полоска на активной строке */
.table-row-hover:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}

/* подсветка со стороны графика */
tr.row-chart-active td {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface2)) !important;
  transition: background 0.12s;
}
tr.row-chart-active td:first-child {
  box-shadow: inset 3px 0 0 var(--ok);
}

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-ok     { background: var(--ok-light);   color: var(--ok); }
.badge-warn   { background: var(--warn-light);  color: var(--warn); }
.badge-danger { background: var(--sys-light);   color: var(--sys); }
.badge-crit   { background: var(--sys-light);   color: var(--sys); font-weight: 800; }
.val-sys   { color: var(--sys);   font-weight: 700; font-size: 15px; }
.val-dia   { color: var(--dia);   font-weight: 700; font-size: 15px; }
.val-pulse { color: var(--pulse); font-weight: 700; font-size: 15px; }
.val-time  { color: var(--text-muted); font-size: 13px; }
.loading-row { text-align: center; color: var(--text-hint); padding: 40px; }

/* ── footer ── */
.footer {
  text-align: center; color: var(--text-hint); font-size: 12px;
  padding: 20px 0 0; letter-spacing: 0.02em;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(220,38,38,0.15), transparent 28%),
    radial-gradient(circle at bottom right, rgba(59,130,246,0.12), transparent 24%),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  padding: 34px 28px;
  text-align: center;
  backdrop-filter: blur(8px);
}
.auth-lock {
  width: 78px;
  height: 78px;
  margin: 0 auto 16px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 36px;
  color: var(--accent);
  background: linear-gradient(135deg, var(--sys-light), rgba(249,115,22,0.18));
  box-shadow: 0 16px 40px rgba(220,38,38,0.18);
  animation: authPulse 2.8s ease-in-out infinite;
}
.auth-card h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}
.auth-card p {
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}
@keyframes authPulse {
  0%, 100% { transform: translateY(0) scale(1); box-shadow: 0 16px 40px rgba(220,38,38,0.14); }
  50% { transform: translateY(-3px) scale(1.03); box-shadow: 0 22px 48px rgba(220,38,38,0.22); }
}

/* ── live dot ── */
.live-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); margin-right: 5px; vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(5,150,105,0.4);
  animation: livepulse 2.5s ease-in-out infinite;
}
@keyframes livepulse {
  0%   { box-shadow: 0 0 0 0   rgba(5,150,105,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(5,150,105,0); }
  100% { box-shadow: 0 0 0 0   rgba(5,150,105,0); }
}

/* ── skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes skel { 0%{background-position:200%} 100%{background-position:-200%} }

/* ── card number fade-in ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stat-value { animation: fadeUp 0.5s ease both; }

/* ── mobile: таблица в приоритете, график — компактный и вторичный ── */
@media (max-width: 640px) {
  .container { display: flex; flex-direction: column; padding: 20px 12px 32px; }
  .header        { order: 1; }
  .status-row    { order: 2; }
  .avg-row       { order: 3; }
  .admin-panel   { order: 4; }
  .tabs-wrap     { order: 5; }
  .table-container { order: 6; margin-bottom: 16px; }
  .chart-container  { order: 7; padding: 14px; }
  .footer        { order: 8; }

  /* график — сворачиваем визуальный вес */
  .chart-wrap { height: 200px; }
  .chart-header { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 10px; }
  .legend-row { gap: 10px; }
  .legend-norm { margin-left: 0; width: 100%; }
  .chart-title { font-size: 13px; }

  /* таблица — чётко и красиво */
  .table-header { padding: 14px 14px 10px; }
  .table-header h3 { font-size: 13px; }
  .data-table { font-size: 12.5px; }
  .data-table th { padding: 8px 10px; font-size: 10px; white-space: nowrap; }
  .data-table td { padding: 9px 10px; }
  .val-sys, .val-dia, .val-pulse { font-size: 13.5px; }
  .val-time { font-size: 12px; }
  .badge { padding: 2px 8px; font-size: 11px; }

  /* первая колонка (дата/время) прилипает при горизонтальном скролле */
  .table-scroll { -webkit-overflow-scrolling: touch; }
  .data-table th:first-child,
  .data-table td:first-child {
    position: sticky; left: 0;
    background: var(--surface);
    z-index: 1;
  }
  .data-table th:first-child { background: var(--surface2); }
}

/* ── PRINT ── */
@media print {
  body::before, .tabs-wrap, .btn-print, .btn-theme,
  .header, .footer, .live-dot, .topnav, .no-print,
  .chart-container, .status-row, .avg-row, .admin-summary,
  .admin-panel { display: none !important; }
  body { background: #fff !important; }
  .container { padding: 0; max-width: 100%; }
  .table-container {
    box-shadow: none !important; border: 1px solid #e5e7eb !important;
    background: #fff !important;
  }
  .table-scroll { overflow: visible; max-height: none; }
  .data-table tr { page-break-inside: avoid; }
  .data-table thead { display: table-header-group; }
  .data-table { font-size: 11px; }
  .data-table th { padding: 4px 8px; font-size: 9px; position: static; }
  .data-table td { padding: 4px 8px; }
  .month-header-row td { padding-top: 5px; padding-bottom: 5px; }
  .table-header { padding: 10px 12px 8px; }
  .table-header h3 { font-size: 12px; }
  .cell-arrow { font-size: 9px; }
  .badge { padding: 1px 6px; font-size: 10px; }
  .print-header { display: block !important; text-align: center; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #e5e7eb; }
  .print-header h2 { font-size: 16px; font-weight: 700; }
  .print-header p  { font-size: 11px; color: #6b7280; margin-top: 2px; }
  @page { margin: 10mm; }
}
.print-header { display: none; }
