/* ═══ SOLARsk Dashboard Styles ═══ */

:root {
  --green: #3CAA5F;
  --green-light: #E8F5ED;
  --green-dark: #2D8A4A;
  --navy: #1B2A4A;
  --navy-light: #243556;
  --lav: #9BA8C7;
  --lav-light: #C5CEE0;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --card-hover: #F0F4F8;
  --border: #E2E8F0;
  --border-dark: #CBD5E1;
  --text: #1A2332;
  --text-dim: #4A5568;
  --text-muted: #8292A7;
  --blue: #5EAED5;
  --blue-light: #EBF5FB;
  --warn: #E8A838;
  --warn-light: #FEF6E7;
  --danger: #E04560;
  --danger-light: #FDE8EC;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Loading */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
}
.loading-screen .spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Layout */
.container { max-width: 960px; margin: 0 auto; padding: 16px; }
/* Live list spans the full width so station cards tile across the whole screen,
   however wide the monitor is. */
body.live-wide .container { max-width: none; }

/* Header */
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.header-brand { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.brand-name { font-size: 16px; font-weight: 700; color: var(--navy); }
.brand-name span { color: var(--green); }
.header-center { text-align: center; margin-bottom: 32px; padding-top: 20px; }
.header-center .brand-block { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.header-center .brand-block .brand-name { font-size: 22px; letter-spacing: 1px; }
.header-center h1 { font-size: clamp(20px, 5vw, 32px); font-weight: 800; color: var(--text); margin: 4px 0; }
.header-center .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

/* Back button */
.btn-back {
  background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; box-shadow: var(--shadow);
  font-weight: 500; transition: all 0.15s;
}
.btn-back:hover { border-color: var(--green); }

/* Section label */
.section-label {
  font-size: 12px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 2px; margin-bottom: 10px; padding-left: 4px; font-weight: 600;
}

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px; box-shadow: var(--shadow);
  transition: all 0.2s; cursor: pointer;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateX(3px); }
.card-grid { display: grid; gap: 10px; }

.card-row {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.card-title { font-size: clamp(16px, 4vw, 20px); font-weight: 700; color: var(--text); }
.card-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* Two-row card layout (narrow-screen friendly) */
.card-2row { display: flex; flex-direction: column; gap: 10px; }
.card-line1 {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.card-sub-inline {
  color: var(--text-muted); font-size: 12px;
  width: 100%; /* push to its own sub-line under title+status */
}
.card-line2 {
  display: flex; gap: 10px;
}
.metric-pill {
  display: flex; align-items: baseline; gap: 5px;
  background: var(--bg); border-radius: 8px;
  padding: 6px 12px;
}
.metric-pill-val { font-size: 17px; font-weight: 700; font-family: monospace; }
.metric-pill-lbl { font-size: 11px; color: var(--text-muted); }

/* Metric value */
.metric { text-align: right; }
.metric-value { font-size: 18px; font-weight: 700; font-family: monospace; }
.metric-label { font-size: 10px; color: var(--text-muted); }

/* Status badge */
.badge {
  padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 600;
  display: inline-block;
}
.badge-good { color: var(--green); background: var(--green-light); }
.badge-warn { color: var(--warn); background: var(--warn-light); }
.badge-danger { color: var(--danger); background: var(--danger-light); }
.badge-neutral { color: var(--text-muted); background: #F1F5F9; }
.badge-blue { color: var(--blue); background: var(--blue-light); }

/* Summary cards grid */
.summary-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.summary-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow);
}
.summary-card .label {
  font-size: 10px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 1px; display: flex; align-items: center; gap: 2px;
}
.summary-card .value {
  font-size: 22px; font-weight: 800; font-family: monospace; margin-top: 4px;
}
.summary-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Stat boxes inside station cards */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px; margin-top: 10px;
}
.stat-box { background: #F8FAFC; border-radius: 8px; padding: 8px 10px; }
.stat-box .label {
  font-size: 10px; color: var(--text-muted); margin-bottom: 2px;
  display: flex; align-items: center; gap: 2px;
}
.stat-box .value { font-size: 15px; font-weight: 700; font-family: monospace; }

/* Chart container */
.chart-block {
  background: var(--card); border-radius: 12px; padding: 16px 12px;
  border: 1px solid var(--border); margin-bottom: 16px; box-shadow: var(--shadow);
  /* Prevent infinite growth */
  min-width: 0;
  overflow: hidden;
}
.chart-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px; margin-bottom: 12px; padding-left: 4px;
}
.chart-title { font-size: 14px; font-weight: 600; color: var(--text-dim); }

/* Chart canvas wrapper — CRITICAL: fixes Chart.js infinite height growth */
.chart-wrap {
  position: relative;
  height: 260px;
  width: 100%;
}
.chart-wrap-sm {
  position: relative;
  height: 200px;
  width: 100%;
}
.chart-wrap canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
}

/* Toggle */
.toggle-group {
  display: flex; gap: 2px; background: #F1F5F9; border-radius: 8px; padding: 3px;
}
.toggle-btn {
  padding: 6px 14px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 12px; font-weight: 600; transition: all 0.15s;
  background: transparent; color: var(--text-muted);
}
.toggle-btn.active { background: var(--green); color: #fff; }

/* Date picker */
.date-picker { display: flex; align-items: center; gap: 4px; position: relative; }
.date-arrow {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; transition: all 0.15s;
}
.date-arrow:disabled { background: #F1F5F9; color: #CBD5E1; cursor: default; }
.date-current {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600; min-width: 90px; text-align: center;
  transition: all 0.15s;
}
.date-current.open { border-color: var(--green); background: var(--green-light); }
.date-dropdown {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md); z-index: 100; padding: 8px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; min-width: 220px;
}
.date-opt {
  padding: 6px 8px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 12px; background: transparent; color: var(--text); transition: all 0.1s;
}
.date-opt:hover { background: #F1F5F9; }
.date-opt.active { background: var(--green); color: #fff; font-weight: 700; }

/* Hint button */
.hint-btn {
  width: 16px; height: 16px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
  cursor: pointer; user-select: none; transition: all 0.15s;
  background: #E2E8F0; color: var(--text-dim); margin-left: 4px;
  border: none; line-height: 1; position: relative;
}
.hint-btn.open { background: var(--green); color: #fff; }
.hint-popup {
  position: fixed;
  width: 280px; max-width: calc(100vw - 16px);
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow-md);
  z-index: 9000; text-align: left;
}
.hint-popup h4 { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.hint-popup p { font-size: 12px; color: var(--text-dim); line-height: 1.5; margin: 0; }

/* Warning block */
.warning-block {
  background: var(--warn-light); border: 1px solid rgba(240,216,144,0.2);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
}
.warning-block .title { font-size: 13px; font-weight: 700; color: var(--warn); margin-bottom: 6px; }
.warning-block .item { font-size: 12px; color: #92600A; padding: 3px 0; border-bottom: 1px solid rgba(240,216,144,0.15); }

/* Inverter list */
.inv-list {
  background: var(--card); border-radius: 12px; border: 1px solid var(--border);
  overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow);
}
.inv-list-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.inv-list-header .title { font-size: 14px; font-weight: 600; color: var(--text-dim); }
.sort-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.sort-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 11px;
  font-weight: 400; transition: all 0.15s;
}
.sort-btn.active { background: var(--green-light); border-color: var(--green); color: var(--green); font-weight: 600; }
.inv-list-body { max-height: 500px; overflow-y: auto; }

.inv-row {
  padding: 10px 16px; border-bottom: 1px solid var(--bg);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 6px; transition: background 0.15s;
}
.inv-row:hover { background: var(--card-hover); }
.inv-name { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.inv-sub { font-size: 11px; color: var(--text-muted); }
.inv-dot {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.inv-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.mini-stat { text-align: right; min-width: 55px; }
.mini-stat .val { font-size: 14px; font-weight: 700; font-family: monospace; color: var(--text); }
.mini-stat .val.warn { color: var(--warn); }
.mini-stat .val .unit { font-size: 10px; color: var(--text-muted); }
.mini-stat .lbl { font-size: 9px; color: var(--text-muted); }

/* Inverter history button */
.inv-hist-btn {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s; margin-left: 4px;
}
.inv-hist-btn:hover { border-color: var(--blue); color: var(--blue); }
.inv-hist-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* Inverter history panel */
.inv-history {
  background: #F0F6FC; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.inv-history-title {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 10px;
}
.inv-history-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 8px; }
.inv-hist-row {
  display: flex; align-items: center; gap: 10px; padding: 4px 0;
}
.inv-hist-date {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  font-family: monospace; width: 42px; flex-shrink: 0;
}
.inv-hist-bar-wrap {
  flex: 1; height: 16px; background: rgba(0,0,0,0.05);
  border-radius: 4px; overflow: hidden; min-width: 40px;
}
.inv-hist-bar { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
.inv-hist-val {
  font-size: 12px; font-weight: 700; font-family: monospace;
  color: var(--text); width: 64px; text-align: right; flex-shrink: 0;
}
.inv-hist-val .unit { font-size: 9px; color: var(--text-muted); font-weight: 400; }
.inv-hist-trend-cell { width: 54px; text-align: right; flex-shrink: 0; }
.inv-hist-trend { font-size: 10px; font-weight: 700; font-family: monospace; }
.inv-hist-trend.up { color: var(--green); }
.inv-hist-trend.down { color: var(--danger); }
.inv-hist-trend.flat { color: var(--text-muted); }

.inv-detail {
  background: #F8FAFC; padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px;
}
.detail-item .lbl { font-size: 10px; color: var(--text-muted); display: flex; align-items: center; gap: 2px; }
.detail-item .val { font-size: 13px; font-weight: 600; font-family: monospace; color: var(--text); }
.detail-item .val.warn { color: var(--warn); }

/* Scrollable bar chart wrapper — horizontal scroll with touch swipe */
.chart-bar-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  height: 270px;              /* extra 30px so scrollbar doesn't cover x-axis labels */
  padding-bottom: 6px;        /* gap between content and scrollbar track */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-dark) transparent;
}
.chart-bar-scroll::-webkit-scrollbar { height: 6px; }
.chart-bar-scroll::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
.chart-bar-scroll::-webkit-scrollbar-track { background: transparent; margin: 0 4px; }
.chart-bar-scroll canvas {
  display: block;
  height: 255px !important;   /* canvas is slightly shorter than wrapper — scrollbar lives in the gap */
}

/* ─── Status indicators ─── */
.status-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: middle;
}
.status-pulse {
  box-shadow: 0 0 0 0 currentColor;
  animation: statusPulse 1.8s ease-in-out infinite;
}
@keyframes statusPulse {
  0%   { box-shadow: 0 0 0 0 rgba(224,69,96,0.55); }
  50%  { box-shadow: 0 0 0 7px rgba(224,69,96,0); }
  100% { box-shadow: 0 0 0 0 rgba(224,69,96,0); }
}

/* Region alert labels on home */
.region-alert {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
  letter-spacing: 0.3px;
  animation: alertFade 1.5s ease-in-out infinite alternate;
}
.danger-alert { background: var(--danger-light); color: var(--danger); }
.warn-alert   { background: var(--warn-light);   color: var(--warn); }
.region-ok    { font-size: 11px; font-weight: 600; color: var(--green); }
@keyframes alertFade {
  from { opacity: 0.75; }
  to   { opacity: 1; }
}

.badge-pulse {
  animation: alertFade 1.5s ease-in-out infinite alternate;
}

/* Inverter inline status badge */
.inv-status-badge {
  display: inline-flex; align-items: center;
  font-size: 9px; font-weight: 600;
  padding: 1px 6px; border-radius: 4px;
  margin-left: 4px;
}

/* Footer */
.footer {
  text-align: center; padding: 20px 0; color: var(--text-muted); font-size: 11px;
  border-top: 1px solid var(--border); margin-top: 20px;
}

/* Responsive */
@media (max-width: 600px) {
  .container { padding: 10px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .date-dropdown { grid-template-columns: repeat(3, 1fr); min-width: 180px; }
  .inv-stats { gap: 10px; }
  .hint-popup { width: 240px; }
}

/* ─── Country Switcher ─── */
.country-switcher {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
.country-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}
.country-btn:hover { border-color: var(--green); color: var(--green); }
.country-btn.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* ─── Deviation table ─── */
.dev-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.dev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 480px;
}
.dev-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  text-align: center;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.dev-table th:first-child { text-align: left; min-width: 140px; }
.dev-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}
.dev-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  font-size: 11px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dev-table tr:last-child td { border-bottom: none; }
.dev-table tr:hover td { background: var(--bg-hover); }
.dev-val { font-weight: 700; font-family: monospace; font-size: 12px; }
.dev-val.pos { color: var(--green); }
.dev-val.neg { color: var(--danger); }
.dev-val.warn { color: var(--warn); }
.dev-val.neutral { color: var(--text-muted); }
.dev-table-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.dev-date-head { font-size: 11px; }

/* ═══════════════════════════════════════════
   Forecast Page Styles
   ═══════════════════════════════════════════ */

/* Forecast button — neutral outline, matches datepicker style */
.fc-open-btn {
  display: inline-flex; align-items: center;
  padding: 7px 14px;
  background: var(--bg); color: var(--text-dim);
  border: 1px solid var(--border-dark); border-radius: 8px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
  line-height: 1;
}
.fc-open-btn:hover { border-color: var(--navy); color: var(--navy); }
.fc-open-btn:active { background: var(--card); }

/* Page header */
.fc-page { animation: fcPageIn 0.2s ease; }
@keyframes fcPageIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.fc-page-header {
  margin-bottom: 16px;
}
.fc-page-label {
  font-size: 11px; letter-spacing: 3px; color: var(--text-muted);
  text-transform: uppercase; font-weight: 600; margin-bottom: 2px;
}
.fc-page-title {
  font-size: clamp(20px, 5vw, 28px); font-weight: 800; margin: 0;
  color: var(--text);
}

/* Tab bar */
.fc-tabs-bar {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.fc-tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  background: none; border: none; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; font-family: inherit; border-radius: 6px 6px 0 0;
  transition: color 0.15s, border-color 0.15s;
}
.fc-tab-btn:hover { color: var(--text); }
.fc-tab-active { color: var(--navy); border-bottom-color: var(--green); }

/* Controls bar */
.fc-controls {
  display: flex; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 16px;
}
.fc-ctrl-group { display: flex; flex-direction: column; gap: 5px; }
.fc-ctrl-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
}
.fc-select {
  font-size: 12px; padding: 6px 10px; border: 1px solid var(--border-dark);
  border-radius: 7px; background: var(--bg); color: var(--text);
  font-family: inherit; outline: none; transition: border-color 0.15s;
  min-width: 140px;
}
.fc-select:focus { border-color: var(--green); }
/* Pills: station multi-selector */
.fc-ctrl-wide { flex: 1 1 100% !important; }
.fc-pills {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.fc-pill {
  padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--border-dark);
  background: var(--bg); color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all 0.12s; white-space: nowrap;
  user-select: none;
}
.fc-pill:hover { border-color: var(--navy); color: var(--navy); }
.fc-pill-on {
  background: var(--navy); color: #fff;
  border-color: var(--navy);
}
.fc-pill-all {
  font-size: 10px; font-weight: 600; padding: 3px 9px;
  border: 1px solid var(--border-dark); border-radius: 5px;
  background: var(--card); color: var(--text-muted);
  cursor: pointer; font-family: inherit; transition: all 0.12s;
}
.fc-pill-all:hover { border-color: var(--green); color: var(--green); }

/* Toggle row */
.fc-toggle-row { display: flex; gap: 3px; }
.fc-toggle {
  font-size: 11px; font-weight: 600; padding: 6px 12px;
  border: 1px solid var(--border-dark); border-radius: 7px;
  background: var(--card); color: var(--text-muted);
  cursor: pointer; font-family: inherit; transition: all 0.14s;
  white-space: nowrap;
}
.fc-toggle:hover { border-color: var(--green); color: var(--green); }
.fc-toggle-active {
  background: var(--navy); border-color: var(--navy); color: #fff;
}

/* Preset buttons */
.fc-preset {
  font-size: 10px; font-weight: 600; padding: 5px 9px;
  border: 1px solid var(--border-dark); border-radius: 6px;
  background: var(--card); color: var(--text-dim);
  cursor: pointer; font-family: inherit; transition: all 0.14s;
}
.fc-preset:hover { border-color: var(--green); color: var(--green); }

/* Card grid (hourly tab) */
.fc-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.fc-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; overflow: hidden;
}
.fc-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.fc-card-title {
  font-size: 12px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.fc-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.fc-dot-sm {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; flex-shrink: 0;
}

/* Chart box */
.fc-chart-box { position: relative; width: 100%; }

/* Mini stats row */
.fc-mini-row {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 4px; margin-top: 10px;
  background: var(--bg); border-radius: 7px; padding: 7px 6px;
}
.fc-mini-lbl { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.fc-mini-val { font-size: 11px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin-top: 1px; }

/* Overview blocks */
.fc-block-list { display: flex; flex-direction: column; gap: 16px; }
.fc-block {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.fc-block-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.fc-block-meta {
  font-weight: 400; font-size: 12px; color: var(--text-muted);
  text-transform: none; letter-spacing: 0; margin-left: auto;
}

/* Summary cards */
.fc-smry-row {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 8px; margin-bottom: 14px;
}
@media (max-width:600px) { .fc-smry-row { grid-template-columns: repeat(2,1fr); } }
.fc-smry-card {
  border-radius: 8px; padding: 10px 12px; border: 1px solid;
}
.fc-smry-lbl  { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.65; }
.fc-smry-val  { font-size: 17px; font-weight: 800; margin: 3px 0; font-variant-numeric: tabular-nums; }
.fc-smry-unit { font-size: 9px; opacity: 0.55; }
.fc-smry-blue  { background:#EBF5FB; color:#1a6896;  border-color:#b8ddf0; }
.fc-smry-amber { background:#FEF6E7; color:#92600A;  border-color:#f6d98a; }
.fc-smry-green { background:#E8F5ED; color:#1c6836;  border-color:#a3d9b5; }
.fc-smry-red   { background:#FDE8EC; color:#9b1c1c;  border-color:#f9adb9; }
.fc-smry-navy  { background:#EEF1F8; color:#1B2A4A;  border-color:#C5CEE0; }

/* Table */
.fc-table-wrap { overflow-x: auto; margin-top: 12px; border-radius: 8px; border: 1px solid var(--border); }
.fc-table {
  width: 100%; border-collapse: collapse; font-size: 12px; min-width: 400px;
}
.fc-table th {
  background: var(--bg); color: var(--text-muted);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 7px 10px; border-bottom: 2px solid var(--border); text-align: left;
  white-space: nowrap;
}
.fc-table td {
  padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--text);
}
.fc-table tr:last-child td { border-bottom: none; }
.fc-table tr:hover td { background: var(--bg); }
.fc-table tfoot td {
  font-weight: 700; background: var(--bg);
  border-top: 2px solid var(--border); border-bottom: none;
}
.fc-tr { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Error / empty states */
.fc-err-block {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 50px 20px; text-align: center;
  color: var(--text-dim);
}
.fc-err-icon { font-size: 42px; }

.fc-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 60px 20px;
  color: var(--text-muted);
}
.fc-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border); border-top-color: var(--green);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.fc-empty {
  text-align: center; padding: 28px; color: var(--text-muted);
  font-size: 13px; border: 1px dashed var(--border-dark);
  border-radius: 8px; background: var(--bg);
}

/* Primary action button */
.btn-primary {
  background: var(--green); color: #fff;
  border: none; border-radius: 8px; padding: 10px 20px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--green-dark); }

/* Forecast button inside station page */
.fc-station-btn {
  font-size: 11px !important;
  padding: 6px 12px !important;
}

/* ═══ Greeting ═══ */
.greeting-topleft {
  font-size: 14px; font-weight: 700; color: var(--green);
  margin-bottom: 4px; text-align: left;
}

/* ═══ Guest gate ═══ */
.guest-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow: hidden;
}
.guest-blur-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 25% 30%, rgba(60,170,95,0.18), transparent 45%),
    radial-gradient(circle at 75% 70%, rgba(46,144,230,0.18), transparent 45%),
    var(--bg);
  filter: blur(2px);
}
.guest-card {
  position: relative; z-index: 1;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-md);
  padding: 36px 28px; max-width: 380px; width: 100%;
  text-align: center;
  animation: guestIn 0.4s ease;
}
@keyframes guestIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.guest-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.guest-title {
  font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 10px;
}
.guest-text {
  font-size: 14px; color: var(--text-dim); line-height: 1.6; margin-bottom: 20px;
}
.guest-contact {
  display: inline-block; font-size: 16px; font-weight: 700;
  color: var(--green); text-decoration: none;
  border-bottom: 2px solid var(--green); padding-bottom: 2px;
  transition: opacity 0.15s; margin-bottom: 28px;
}
.guest-contact:hover { opacity: 0.7; }
.guest-continue {
  display: block; width: 100%;
  background: var(--bg); color: var(--text-muted);
  border: 1px dashed var(--border-dark); border-radius: 10px;
  padding: 11px 16px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.guest-continue:hover { border-color: var(--navy); color: var(--navy); }

/* ═══ Top bar (burger + greeting) ═══ */
.top-bar {
  display: flex; align-items: center; gap: 12px;
  min-height: 36px; margin-bottom: 4px;
}
.burger-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--navy); cursor: pointer; flex-shrink: 0;
  transition: all 0.15s;
}
.burger-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.top-bar .greeting-topleft { margin-bottom: 0; }

/* ═══ Slide-out menu ═══ */
#side-menu { position: fixed; inset: 0; z-index: 9500; }
.menu-overlay {
  position: absolute; inset: 0; background: rgba(15,23,42,0);
  transition: background 0.25s;
}
#side-menu.open .menu-overlay { background: rgba(15,23,42,0.45); }
.menu-panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 280px; max-width: 82vw;
  background: var(--card); box-shadow: var(--shadow-md);
  transform: translateX(-100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}
#side-menu.open .menu-panel { transform: translateX(0); }
.menu-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px; border-bottom: 1px solid var(--border);
}
.menu-title { font-size: 18px; font-weight: 800; color: var(--text); }
.menu-title span { color: var(--green); }
.menu-close {
  margin-left: auto; background: none; border: none;
  font-size: 18px; color: var(--text-muted); cursor: pointer;
}
.menu-items { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: left; font-family: inherit;
  transition: all 0.15s;
}
.menu-item:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.menu-ico { font-size: 18px; }
/* Заглавна кнопка розділу: підсвічуємо той, у якому користувач зараз */
.menu-item.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.menu-count {
  margin-left: auto; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 7px; border-radius: 999px;
  background: var(--border); color: var(--text-muted);
}
.menu-item.active .menu-count,
.menu-item:hover .menu-count { background: rgba(255,255,255,.22); color: #fff; }

/* Смуга вкладок розділу — суцільний сегментний перемикач.
   Раніше вкладки були окремими «таблетками» того ж стилю, що й решта кнопок
   сторінки, і зливалися з наповненням. Тепер вони в спільній рамці: видно, що
   це один перемикач, а не набір різних дій. */
.nav-tabs {
  display: flex; gap: 4px;
  width: fit-content; max-width: 100%;
  margin: 0 auto 18px;                 /* по центру під верхньою смугою */
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
  background: transparent; border: 0;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: all .15s;
}
.nav-tab:hover { color: var(--text); background: var(--card); }
.nav-tab.active {
  background: var(--navy); color: #fff;
  box-shadow: 0 1px 3px rgba(27, 42, 74, .28);
}

/* Короткий рядок під вкладками там, де в шапці був корисний елемент
   (статус провайдерів, кнопка довідки) — заголовок прибрали, це лишили. */
.page-note {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: -6px 0 16px; font-size: 12px; color: var(--text-muted);
}
.menu-foot {
  padding: 14px 18px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
}

/* ═══ Admin panel ═══ */
.admin-cards {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
@media (min-width: 600px) { .admin-cards { grid-template-columns: repeat(4, 1fr); } }
.admin-stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; text-align: center;
}
.admin-stat-val { font-size: 22px; font-weight: 800; color: var(--navy); font-family: monospace; }
.admin-stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.online-list { display: flex; flex-wrap: wrap; gap: 8px; }
.online-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(60,170,95,0.12); color: var(--green);
  padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.online-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  animation: pulse-dot 1.6s infinite;
}
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.admin-chart-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; height: 200px;
}
.admin-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--card); }
.admin-table th {
  text-align: left; padding: 10px 12px; font-size: 11px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--bg); color: var(--text); }
.lb-name { font-weight: 600; }
.lb-resp { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .ar { text-align: right; }
.admin-table .small { font-size: 11px; color: var(--text-muted); }
.role-pill {
  display: inline-block; padding: 2px 9px; border-radius: 10px;
  font-size: 11px; font-weight: 700;
}
.role-admin      { background: rgba(212,93,121,0.15); color: #D45D79; }
.role-dispatcher { background: rgba(46,144,230,0.15); color: #2E90E6; }
.role-engineer   { background: rgba(232,168,56,0.15); color: #C77E00; }

.never-list { display: flex; flex-wrap: wrap; gap: 8px; }
.never-chip {
  background: var(--bg); border: 1px dashed var(--border-dark);
  color: var(--text-muted); padding: 6px 12px; border-radius: 8px; font-size: 12px;
}
.never-role { opacity: 0.7; font-size: 10px; }

/* ═══ AI Assistant chat ═══ */
#chat-widget { position: fixed; z-index: 9000; }
#chat-fab {
  position: fixed; right: 18px; bottom: 18px;
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--navy); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 6px 20px rgba(15,23,42,0.3);
  transition: transform 0.15s, opacity 0.2s;
}
#chat-fab:hover { transform: translateY(-2px); background: #1a2a47; }
#chat-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

#chat-panel {
  position: fixed; right: 18px; bottom: 18px;
  width: 380px; max-width: calc(100vw - 36px);
  height: 560px; max-height: calc(100vh - 100px);
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: 0 12px 40px rgba(15,23,42,0.28);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(20px) scale(0.97);
  transition: opacity 0.2s, transform 0.2s;
}
#chat-panel.open { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--navy); color: #fff;
}
.chat-title { font-weight: 700; font-size: 15px; }
.chat-header-actions { display: flex; gap: 4px; }
.chat-clear, .chat-close {
  background: rgba(255,255,255,0.12); border: none; color: #fff;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.chat-clear:hover, .chat-close:hover { background: rgba(255,255,255,0.25); }

.chat-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg);
}
.chat-empty {
  color: var(--text-muted); font-size: 13px; text-align: center;
  margin: auto; padding: 20px; line-height: 1.5;
}
.chat-msg {
  max-width: 85%; padding: 10px 13px; border-radius: 14px;
  font-size: 14px; line-height: 1.45; word-wrap: break-word; position: relative;
}
.chat-user {
  align-self: flex-end; background: var(--navy); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-assistant {
  align-self: flex-start; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.chat-typing { display: flex; align-items: center; gap: 8px; padding: 12px 14px; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted);
  animation: chat-bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
.typing-label { font-size: 12px; color: var(--text-muted); font-style: italic; }
@keyframes chat-bounce { 0%,60%,100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Failed (rate-limited) message in admin view */
.chat-msg.chat-failed { border: 1px dashed var(--danger); opacity: 0.85; }
.conv-prov.prov-failed { color: var(--danger); font-weight: 600; opacity: 1; }

.chat-input-row {
  display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border);
  background: var(--card); align-items: flex-end;
}
#chat-input {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); max-height: 120px; line-height: 1.4;
}
#chat-input:focus { outline: none; border-color: var(--navy); }
.chat-send {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--navy); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-send:hover { background: #1a2a47; }

@media (max-width: 460px) {
  #chat-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100vh - 80px); }
  #chat-fab { right: 14px; bottom: 14px; }
}

/* Admin chat history */
.conv-list { display: flex; flex-direction: column; gap: 8px; }
.conv-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; text-align: left; font-family: inherit;
  transition: all 0.15s;
}
.conv-item:hover { border-color: var(--navy); box-shadow: var(--shadow-sm); }
.conv-name { font-weight: 600; font-size: 14px; color: var(--text); }
.conv-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.conv-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.conv-modal { position: fixed; inset: 0; z-index: 9600; display: flex; align-items: center; justify-content: center; }
.conv-modal-bg { position: absolute; inset: 0; background: rgba(15,23,42,0.5); }
.conv-modal-card {
  position: relative; background: var(--card); border-radius: 16px;
  width: 440px; max-width: calc(100vw - 32px); height: 600px; max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-md);
}
.conv-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--navy); color: #fff; font-weight: 700;
}
.conv-modal-head button { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; }
.conv-modal-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.conv-prov { display: block; font-size: 9px; opacity: 0.5; margin-top: 4px; text-transform: uppercase; }

/* ═══ Roles panel ═══ */
.roles-list { display: flex; flex-direction: column; gap: 8px; }
.role-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px;
}
.role-row-main { min-width: 0; }
.role-row-name { font-weight: 600; font-size: 14px; color: var(--text); }
.role-you { font-size: 11px; color: var(--green); font-weight: 600; }
.role-row-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.role-row-id { font-size: 10px; color: var(--text-muted); opacity: 0.6; margin-top: 3px; font-family: monospace; }
.role-view-btn {
  flex-shrink: 0; background: var(--navy); color: #fff; border: none;
  border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.role-view-btn:hover { background: #1a2a47; }

/* Impersonation banner */
#imp-banner {
  position: fixed; top: 10px; left: 50%; right: auto; transform: translateX(-50%);
  z-index: 9700; width: auto; max-width: calc(100% - 24px);
  background: linear-gradient(90deg, #C77E00, #E8A838);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  gap: 12px; padding: 9px 14px; font-size: 13px;
  border-radius: 14px; border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 6px 20px rgba(199,126,0,0.35);
}
.imp-text { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-exit {
  background: rgba(255,255,255,0.25); border: none; color: #fff;
  border-radius: 9px; padding: 5px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.imp-exit:hover { background: rgba(255,255,255,0.4); }

/* Chat inline charts */
.chat-chart {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; margin: 8px 0; height: 200px; position: relative;
}
.chat-assistant .chat-chart { max-width: 100%; }

/* Chat history delete controls */
.conv-item .conv-main { flex: 1; min-width: 0; cursor: pointer; }
.conv-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.conv-del {
  background: rgba(212,93,121,0.12); border: none; color: #D45D79;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.conv-del:hover { background: rgba(212,93,121,0.25); }
.conv-clearall {
  background: rgba(212,93,121,0.12); border: none; color: #D45D79;
  border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; text-transform: none; letter-spacing: 0;
}
.conv-clearall:hover { background: rgba(212,93,121,0.22); }

/* Chat report button */
.report-btn {
  display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 2px;
  background: var(--green); color: #fff; border: none; border-radius: 10px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all 0.15s; box-shadow: var(--shadow-sm);
}
.report-btn:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }
.report-btn:disabled { opacity: 0.7; cursor: default; }
.report-btn.ready { background: var(--navy); }
.report-spinner {
  width: 13px; height: 13px; border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: report-spin 0.7s linear infinite;
}
@keyframes report-spin { to { transform: rotate(360deg); } }

/* Chat suggestion chips */
.chat-chips {
  display: flex; gap: 7px; padding: 8px 12px 0; flex-wrap: wrap;
  max-height: 76px; overflow-y: auto;
}
.chat-chip {
  background: var(--card); border: 1px solid var(--border); color: var(--navy);
  border-radius: 16px; padding: 6px 12px; font-size: 12px; cursor: pointer;
  font-family: inherit; white-space: nowrap; transition: all 0.15s;
}
.chat-chip:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ═══ ESS / УЗЕ «Homer-Elios» (BESS) ═══ */
.ess-toggle {
  display: inline-flex; gap: 4px; margin-top: 12px; padding: 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
}
.ess-toggle-btn {
  font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 9px;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all 0.18s ease; font-family: inherit;
}
.ess-toggle-btn:hover { color: var(--text-dim); }
.ess-toggle-btn.active {
  background: var(--navy); color: #fff; box-shadow: var(--shadow);
}
.ess-admin-tag {
  background: var(--navy); color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px; padding: 1px 7px; border-radius: 6px; text-transform: uppercase;
}
.ess-daypick {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 6px 0 16px; position: relative;
}
.ess-empty {
  text-align: center; color: var(--text-muted); padding: 30px 16px; font-size: 14px;
}

.ess-kpi-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px;
}
.ess-kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 10px; text-align: center; box-shadow: var(--shadow);
}
.ess-kpi.danger { border-color: var(--danger); background: var(--danger-light); }
.ess-kpi-val { font-size: clamp(16px, 4.4vw, 22px); font-weight: 800; color: var(--text); line-height: 1.1; }
.ess-kpi-unit { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.ess-kpi-lbl { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.ess-anom-row { text-align: center; margin: 4px 0 12px; }
.ess-badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 8px;
}
.ess-badge.ok   { background: var(--green-light); color: var(--green-dark); }
.ess-badge.warn { background: var(--warn-light); color: #9A6B00; }

.ess-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.ess-card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.ess-card-sub { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.ess-chart-wrap { position: relative; height: 260px; }
.ess-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 8px; }

/* command timeline */
.ess-tl {
  display: flex; gap: 1px; height: 26px; border-radius: 7px; overflow: hidden;
  border: 1px solid var(--border);
}
.ess-tl.ess-tl-thin { height: 9px; margin-top: 3px; }
.ess-tl-cell { flex: 1 1 0; min-width: 0; }
.ess-tl-arvch { flex: 1 1 0; min-width: 0; }
.ess-tl-axislabel { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.ess-tl-axis {
  display: flex; justify-content: space-between; font-size: 10px;
  color: var(--text-muted); margin-top: 4px;
}
.ess-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.ess-leg { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }
.ess-leg i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* battery health */
.ess-hkpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.ess-hkpi {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 6px; text-align: center;
}
.ess-hkpi.warn   { border-color: var(--warn); background: var(--warn-light); }
.ess-hkpi.danger { border-color: var(--danger); background: var(--danger-light); }
.ess-hkpi-val { font-size: 18px; font-weight: 800; color: var(--text); }
.ess-alarm {
  background: var(--danger-light); color: #B02038; border: 1px solid var(--danger);
  border-radius: 9px; padding: 8px 12px; font-size: 12px; font-weight: 600; margin-bottom: 10px;
}
.ess-okrow { color: var(--green-dark); font-size: 12px; font-weight: 600; margin-bottom: 10px; }
.ess-bat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.ess-bat {
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 4px; text-align: center;
}
.ess-bat.weak { border-color: var(--warn); background: var(--warn-light); }
.ess-bat-id { font-size: 10px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.3px; }
.ess-bat-soc { font-size: 16px; font-weight: 800; color: var(--text); margin: 1px 0; }
.ess-bat-soc span { font-size: 10px; font-weight: 600; color: var(--text-muted); }
.ess-bat-sub { font-size: 10px; color: var(--text-muted); }

@media (max-width: 360px) {
  .ess-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ess-bat-grid, .ess-hkpi-grid { grid-template-columns: repeat(3, 1fr); }
}

/* SOLARsk Assistant beta tag */
.chat-beta { font-size: 11px; font-weight: 600; opacity: 0.75; letter-spacing: 0.2px; }

/* ═══ Alerts bell + panel ═══ */
#alerts-slot { margin-left: auto; }
.alerts-bell {
  position: relative; border: 1px solid var(--border); background: var(--card);
  border-radius: 12px; padding: 7px 11px; font-size: 17px; cursor: pointer;
  box-shadow: var(--shadow); line-height: 1;
}
.alerts-bell.warn { animation: bellblink 1.6s ease-in-out infinite; }
.alerts-bell.crit { animation: bellcrit 1.0s ease-in-out infinite; border-color: var(--danger); }
@keyframes bellblink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,168,56,0.0); }
  50%      { box-shadow: 0 0 0 6px rgba(232,168,56,0.25); }
}
@keyframes bellcrit {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224,69,96,0.0); background: var(--card); }
  50%      { box-shadow: 0 0 0 7px rgba(224,69,96,0.28); background: var(--danger-light); }
}
.alerts-badge {
  position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800; border-radius: 9px; padding: 1px 5px; min-width: 16px;
  text-align: center;
}
#alerts-panel {
  position: fixed; top: 54px; right: 10px; z-index: 9600;
  width: min(360px, calc(100vw - 20px)); max-height: 62vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 34px rgba(27,42,74,0.22); padding: 8px;
}
.alerts-head {
  font-size: 13px; font-weight: 800; color: var(--text); padding: 6px 8px 8px;
  display: flex; align-items: center; gap: 8px;
}
.alerts-count { background: var(--navy); color:#fff; border-radius: 8px; font-size: 11px; padding: 1px 7px; }
.alert-item {
  display: flex; gap: 9px; align-items: flex-start; padding: 9px 8px; border-radius: 10px;
  cursor: pointer; font-size: 12.5px; color: var(--text);
}
.alert-item:hover { background: var(--bg); }
.alert-item.crit { border-left: 3px solid var(--danger); background: var(--danger-light); margin-bottom: 4px; }
.alert-item.warn { border-left: 3px solid var(--warn); }
.alert-ico { flex-shrink: 0; }
.alert-text { line-height: 1.35; }

/* ═══ Live monitoring (Helia / Optimus) ═══ */
.live-station-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 14px; }
.live-st-name { font-size: 19px; font-weight: 800; color: var(--text); }
.live-fresh { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: livepulse 1.6s ease-in-out infinite; }
@keyframes livepulse { 0%,100% { box-shadow: 0 0 0 0 rgba(60,170,95,0.5);} 50% { box-shadow: 0 0 0 5px rgba(60,170,95,0);} }
.live-logger-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.live-logger { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center; }
.live-lg-name { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.live-lg-kw { font-size: 18px; font-weight: 800; color: var(--text); margin: 2px 0; }
.live-lg-kw span { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.live-lg-sub { font-size: 10px; color: var(--text-muted); }
.live-entry { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(90deg, rgba(60,170,95,0.10), rgba(60,170,95,0.02));
  border: 1px solid var(--green); border-left: 4px solid var(--green); border-radius: 12px;
  padding: 12px 16px; margin: 6px 0 18px; cursor: pointer; transition: background .15s; }
.live-entry:hover { background: rgba(60,170,95,0.16); }
.live-entry-l { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); }
.live-entry-l svg { width: 18px; height: 18px; }
.live-entry-r { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.live-entry-r b { color: var(--green); }
.live-entry-r svg { width: 15px; height: 15px; }
/* Live station grid: responsive tiles that fill by screen width (1 col on phone,
   many on a wide screen). Cards are vertical, closer to square. */
#live-grid.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  align-items: stretch;
}
#live-grid .live-card {
  display: flex; flex-direction: column; align-items: stretch; justify-content: space-between;
  gap: 10px; min-height: 132px;
}
#live-grid .live-card-info { flex: 1 1 auto; }
#live-grid .live-card-power { justify-content: flex-end; align-self: flex-end; }
/* Source badges: translucent fill, crisp colored outline + text, uniform width. */
.src-badge {
  display: inline-block; vertical-align: middle;
  font-size: 10px; font-weight: 800; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 5px; margin-right: 6px;
  text-transform: none; line-height: 1.5;
  min-width: 52px; text-align: center;
  border: 1.5px solid var(--src, var(--text-muted));
  color: var(--src, var(--text-muted));
  background: color-mix(in srgb, var(--src, #888) 14%, transparent);
}
.src-badge.sg  { --src: #f5820b; }                 /* Sungrow — оранжевый */
.src-badge.fs  { --src: #4aa8e0; }                 /* Fusion — нежно-голубой */
.src-badge.sma { --src: #7b61c9; }                 /* SMA — приглушений фіолетовий */

/* Uniform live cards: fixed internal zones so long names don't shift the layout. */
#live-grid .live-card-head { display: flex; align-items: center; gap: 6px; min-height: 20px; margin-bottom: 4px; }
#live-grid .live-card-name {
  font-weight: 800; font-size: 15px; line-height: 1.25; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 38px; margin-bottom: 4px;
}
#live-grid .live-card-meta { min-height: 16px; }
.live-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.live-card-info { min-width: 0; flex: 1; }
.live-card-foot { margin-top: 4px; }
.live-cd { color: var(--text-muted); }
.live-cd b { color: var(--text); font-variant-numeric: tabular-nums; }
.live-card-power { display: flex; align-items: baseline; gap: 3px; flex: 0 0 auto; font-weight: 800; }
.live-card-kw { font-size: 26px; line-height: 1; }
.live-card-unit { font-size: 12px; font-weight: 700; opacity: 0.85; }
.live-logger-group { margin-bottom: 14px; }
.live-logger-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin: 2px 0 7px;
  padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.live-logger-head svg { width: 14px; height: 14px; }
.live-logger-head span { margin-left: auto; font-weight: 700; color: var(--text); text-transform: none; }
.live-inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.live-inv-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.live-modal-sub { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.live-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; margin-bottom: 8px; }
.live-stat { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 4px; text-align: center; }
.live-stat-v { font-size: 14px; font-weight: 800; color: var(--text); }
.live-stat-v span { font-size: 9px; font-weight: 600; color: var(--text-muted); }
.live-stat-l { font-size: 9px; color: var(--text-muted); margin-top: 1px; }
.live-phase { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 11px; color: var(--text-muted); background: var(--bg); border-radius: 8px; padding: 7px 10px; margin-bottom: 8px; }
.live-phase b { color: var(--text); }
.live-reason { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--danger); background: var(--danger-light); border: 1px solid var(--danger); border-radius: 8px; padding: 7px 10px; margin-bottom: 8px; }
.live-reason svg { width: 15px; height: 15px; flex: 0 0 auto; }
.live-str-title { font-size: 12px; font-weight: 700; color: var(--text); margin: 4px 0 6px; }
.live-str-title span { color: var(--text-muted); font-weight: 600; }
.live-str-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.live-str { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 5px; text-align: center; }
.live-str.dead { background: var(--danger-light); border-color: var(--danger); }
.live-str-id { font-size: 10px; font-weight: 700; color: var(--text-muted); }
.live-str-av { font-size: 11px; font-weight: 700; color: var(--text); }
.live-str-w { font-size: 9px; color: var(--text-muted); }
.live-inv { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 7px 5px; text-align: center; cursor: pointer; transition: border-color .15s; }
.live-inv:hover { border-color: var(--green); }
.live-inv.off { background: var(--danger-light); border-color: var(--danger); }
/* Не відповідає — сірий (нейтральний). Помер удень — червоний.
   Нуль уночі на живому інверторі не підсвічуємо взагалі. */
.live-inv.dim { background: var(--bg); border-color: var(--border); opacity: .55; }
.live-inv.alarm { background: var(--danger-light); border-color: var(--danger); }
.live-inv.alarm .live-inv-sub { color: var(--danger); font-weight: 700; }
.live-inv-name { font-size: 9.5px; font-weight: 700; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-inv-kw { font-size: 14px; font-weight: 800; color: var(--text); }
.live-inv-kw span { font-size: 9px; font-weight: 600; color: var(--text-muted); }
.live-inv-sub { font-size: 9px; color: var(--text-muted); }
#live-inv-modal {
  position: fixed; inset: 0; z-index: 9800; background: rgba(20,28,46,0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  overscroll-behavior: contain;          /* прокрутка не «протекает» на фон */
}
/* Карточка не может быть выше экрана: длинный список стрингов + график
   прокручиваются ВНУТРИ неё, а не растягивают её за края экрана. */
.live-modal-card {
  background: var(--card); border-radius: 16px; width: min(520px, 100%);
  padding: 16px; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);       /* учитывает панели браузера на телефоне */
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* Шапка с крестиком всегда на виду, сколько бы ни прокручивали */
.live-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 800; color: var(--text); margin-bottom: 10px;
  position: sticky; top: -16px; z-index: 2;
  background: var(--card); padding: 16px 0 10px; margin-top: -16px;
}
.live-modal-head button { border: none; background: var(--bg); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 15px; }

/* ═══ Inline icon sizing ═══ */
.ic { width: 1.05em; height: 1.05em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.ess-toggle-btn .ic, .card-title .ic { vertical-align: -0.16em; }
.alerts-bell .ic { width: 18px; height: 18px; vertical-align: middle; }
.alert-ico .ic { width: 16px; height: 16px; }
.live-home-card .live-tag .ic { width: 12px; height: 12px; }
h1 .ic { width: 0.82em; height: 0.82em; vertical-align: -0.05em; }

/* live station card on home */
.live-home-card .live-tag { display: inline-flex; align-items: center; gap: 4px; background: var(--green-light); color: var(--green-dark); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 7px; }
.live-home-card .live-tag .live-dot { width: 7px; height: 7px; }

/* alert item: expandable detail + go-to-device */
.alert-row { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.alert-caret { margin-left: auto; color: var(--text-muted); transition: transform .18s; flex-shrink: 0; }
.alert-caret.open { transform: rotate(90deg); }
.alert-detail { padding: 8px 2px 4px 25px; }
.alert-detail-text { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; margin-bottom: 8px; }
.alert-goto {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--navy);
  background: var(--navy); color: #fff; border-radius: 9px; padding: 6px 12px;
  font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.alert-goto:hover { opacity: 0.9; }
.alert-item { display: block; }

/* ═══ Server logs viewer (admin) ═══ */
.logs-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 2px 12px; }
.logs-bar select, .logs-search { border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; font-size: 13px; font-family: inherit; background: var(--card); color: var(--text); }
.logs-search { flex: 1; min-width: 120px; }
.logs-auto { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.btn-mini { border: 1px solid var(--navy); background: var(--navy); color: #fff; border-radius: 9px; padding: 7px 12px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; }
.logs-out { background: #0f1626; border-radius: 12px; padding: 10px; max-height: 68vh; overflow-y: auto; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; line-height: 1.5; }
.log-line { display: flex; gap: 8px; padding: 1px 4px; white-space: pre-wrap; word-break: break-word; border-radius: 4px; }
.log-line:hover { background: rgba(255,255,255,0.04); }
.log-t { color: #6b7a99; flex-shrink: 0; }
.log-lvl { flex-shrink: 0; width: 62px; font-weight: 700; }
.log-src { color: #7c8bb0; flex-shrink: 0; }
.log-msg { color: #c7d2e6; }
.log-info .log-lvl { color: #5fa8d3; }
.log-warning { background: rgba(232,168,56,0.07); }
.log-warning .log-lvl { color: #e8a838; }
.log-error, .log-critical { background: rgba(224,69,96,0.10); }
.log-error .log-lvl, .log-critical .log-lvl { color: #ff6b81; }

/* ═══ DB viewer (admin) ═══ */
.dbv-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.dbv-db { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: var(--text); font-size: 14px; margin-bottom: 8px; }
.dbv-size { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.dbv-tables { display: flex; flex-wrap: wrap; gap: 6px; }
.dbv-table-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--bg); border-radius: 9px; padding: 7px 11px; font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit; }
.dbv-table-btn:hover { border-color: var(--navy); }
.dbv-rows { background: var(--navy); color: #fff; border-radius: 7px; font-size: 10px; padding: 1px 6px; }
.dbv-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.dbv-loc { font-size: 13px; color: var(--text); }
.dbv-pager { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.dbv-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; max-height: 62vh; overflow-y: auto; }
.dbv-table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
.dbv-table th { position: sticky; top: 0; background: var(--navy); color: #fff; padding: 7px 9px; text-align: left; white-space: nowrap; z-index: 1; }
.dbv-table td { padding: 5px 9px; border-top: 1px solid var(--border); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.dbv-table tbody tr:nth-child(even) { background: var(--bg); }
.btn-mini:disabled { opacity: .4; cursor: default; }

/* ═══ Live day chart header + export panel ═══ */
.live-day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.live-day-nav { min-width: 34px; font-size: 18px; line-height: 1; padding: 4px 10px; }
.live-day-center { text-align: center; flex: 1; }
.live-date-input { border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font-family: inherit; font-size: 12px; color: var(--text); background: var(--card); }
.live-day-total { font-size: 13px; color: var(--text); margin-top: 3px; }
.export-card { max-width: 560px; max-height: 88vh; overflow-y: auto; }
.exp-sec { margin: 12px 0; }
.exp-lbl { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.exp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.exp-inv-box { max-height: 180px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: 8px; }
.exp-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; font-size: 12px; cursor: pointer; background: var(--bg); }
.exp-chip.sm { font-size: 11px; padding: 4px 7px; }
.exp-lg { color: var(--text-muted); font-size: 9px; margin-left: 3px; }
.exp-mini { border: none; background: var(--bg); border-radius: 6px; padding: 2px 8px; font-size: 11px; cursor: pointer; font-weight: 600; color: var(--navy); }
.exp-dates { display: flex; gap: 12px; }
.exp-dates label { font-size: 12px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; }
.exp-dates input { border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; font-family: inherit; }
.exp-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.exp-preview { margin-top: 10px; }

/* export modal overlay (was falling to page bottom) */
#live-export-modal { position: fixed; inset: 0; z-index: 9800; background: rgba(20,28,46,0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.exp-hint-inline { font-size: 10px; color: var(--text-muted); font-weight: 500; margin-left: auto; }
.exp-count { font-size: 12px; color: var(--text-muted); margin: 8px 0 6px; }

/* ── DB browser: help panel + sortable headers ── */
.dbv-help-btn { border: 1px solid var(--border); background: var(--card); color: var(--text-muted);
  width: 22px; height: 22px; border-radius: 50%; font-weight: 800; font-size: 13px; cursor: pointer;
  vertical-align: middle; margin-left: 6px; line-height: 1; }
.dbv-help-btn:hover { border-color: var(--green); color: var(--green); }
.dbv-help { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 14px; }
.dbv-help-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dbv-help-head b { flex: 1; }
.dbv-help-head svg { width: 16px; height: 16px; }
.dbv-help-db { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.dbv-help-db-name { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; margin-bottom: 4px; }
.dbv-help-db-name svg { width: 14px; height: 14px; }
.dbv-help-t { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.dbv-help-t b { color: var(--text); font-family: ui-monospace, monospace; }
.dbv-th { cursor: pointer; user-select: none; white-space: nowrap; }
.dbv-th:hover { color: var(--green); }
.dbv-sort { font-size: 9px; opacity: .8; }
.dbv-sort.dim { opacity: .3; }

/* ── FusionSolar backfill panel ── */
.bf-panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 14px; }
.bf-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bf-head svg { width: 16px; height: 16px; }
.bf-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 10px; }
.bf-row label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.bf-input { border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 7px 9px; font-size: 13px; font-family: inherit; }
#bf-station { min-width: 210px; max-width: 100%; }
.bf-run { padding: 8px 16px; background: var(--green); color: #fff; border: none; font-weight: 700; }
.bf-run:disabled { opacity: .55; cursor: default; }
.bf-out { margin-top: 10px; }
.bf-busy { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.bf-busy .spinner { width: 16px; height: 16px; border-width: 2px; margin: 0; }
/* Вибір станцій для бекапу: кілька одразу, а не один пункт зі списку */
.bf-picker { margin-top: 10px; }
.bf-picker-head { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.bf-picker-acts { margin-left: auto; display: flex; gap: 6px; }
.bf-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--border);
           border-radius: 10px; padding: 4px; background: var(--card); }
.bf-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px;
           border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.bf-item:hover { background: var(--bg); }
.bf-item input { width: 15px; height: 15px; accent-color: var(--green); cursor: pointer; flex: none; }
.bf-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bf-item-dev { flex: none; font-size: 11px; opacity: .65; }
.bf-hidden-note { padding: 6px 8px; }
.bf-run:disabled { opacity: .45; cursor: not-allowed; }

/* «Перезаписати» — руйнівний режим бекапу, тож і виглядає інакше */
.bf-ow { display: flex; align-items: center; gap: 7px; margin-top: 10px;
         font-size: 12px; font-weight: 600; cursor: pointer; user-select: none; }
.bf-ow input { width: 15px; height: 15px; accent-color: var(--danger); cursor: pointer; }
.bf-ow-warn { margin-top: 6px; padding: 8px 10px; border-radius: 8px;
              border-left: 3px solid var(--danger); background: rgba(220, 53, 69, .07); }
.bf-run.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.bf-ok { font-size: 13px; }
.bf-ok b { color: var(--green); font-size: 15px; }
.bf-days { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.bf-day { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }
.bf-day.hit { border-color: var(--green); color: var(--green); font-weight: 700; }

/* ── Live: state tally (green / red / gray) ── */
.live-tally-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 14px; }
.live-tally { display: flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; transition: border-color .15s, background .15s; }
.live-tally:hover { border-color: var(--text-muted); }
.live-tally.on { border-color: var(--text); background: rgba(0,0,0,0.03); }
.live-tally.empty { opacity: .5; }
.live-tally-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.live-tally-n { font-size: 19px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.live-tally-l { font-size: 11px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .02em; font-weight: 700; line-height: 1.15; }
@media (max-width: 420px) { .live-tally { flex-direction: column; align-items: flex-start; gap: 3px; padding: 8px 9px; }
  .live-tally-l { font-size: 10px; } }

/* ── Backfill history table ── */
.bf-hist-table td { font-variant-numeric: tabular-nums; }
.bf-hist-bad td { background: rgba(220,80,80,0.06); }
.bf-hist-err td { font-size: 11px; color: var(--danger); padding-top: 0; }

/* ── Backfill progress ── */
.bf-prog { margin-top: 4px; }
.bf-prog-bar { height: 7px; border-radius: 4px; background: var(--border); overflow: hidden; }
.bf-prog-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width .4s ease; }
.bf-prog-txt { font-size: 12px; color: var(--text-muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.bf-prog-txt b { color: var(--green); }

/* Sortable leaderboard headers */
.admin-table thead th.lb-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.admin-table thead th.lb-sort:hover { color: var(--accent, #2d6cdf); }
.lb-arrow { font-weight: 700; }

/* Живі картки: бліда заливка за станом, щоб проблемні станції одразу впадали
   в око у довгому списку. Колір навмисно приглушений — картка має читатися,
   а не світитися. */
#live-grid .live-card.st-down  { background: color-mix(in srgb, var(--danger) 7%, var(--card)); }
#live-grid .live-card.st-stale { background: color-mix(in srgb, var(--text-muted) 9%, var(--card)); }
#live-grid .live-card.st-down:hover  { background: color-mix(in srgb, var(--danger) 11%, var(--card)); }
#live-grid .live-card.st-stale:hover { background: color-mix(in srgb, var(--text-muted) 13%, var(--card)); }

/* Меню диспетчера: лише «Головна» та «Керування пристроями» —
   адмінські розділи ховаємо, а не прибираємо з коду. */

/* ═══ Керування пристроями ═══ */
.dev-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 14px 0 18px; }
.dev-stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.dev-stat b { display: block; font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.1; }
.dev-stat span { font-size: 11px; color: var(--text-muted); }
.dev-stat.warn b { color: var(--danger); }

.dev-add { padding: 16px; margin-bottom: 16px; }
.dev-hint { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }
.dev-add-row { display: flex; gap: 8px; }
.dev-add-row .dev-input { flex: 1; }
.dev-input {
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit; width: 100%;
}
.dev-input:focus { outline: none; border-color: var(--accent, #2d6cdf); }
.btn-primary {
  padding: 11px 20px; border: 0; border-radius: 9px; background: var(--accent, #2d6cdf);
  color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.dev-preview:empty { display: none; }
.dev-found { margin-top: 12px; padding: 12px; border-radius: 9px; border: 1px solid var(--border); }
.dev-found.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 8%, transparent); }
.dev-found.bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.dev-sub.warn { color: var(--danger); }

.dev-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0 4px; }
.dev-filters .dev-input { flex: 1 1 180px; width: auto; }
.dev-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.dev-card { padding: 13px; display: flex; flex-direction: column; gap: 3px; }
.dev-card.off { opacity: .6; background: color-mix(in srgb, var(--text-muted) 7%, var(--card)); }
.dev-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.dev-name { font-weight: 800; font-size: 14px; color: var(--text); line-height: 1.25; }
.dev-sub { font-size: 12px; color: var(--text-muted); }
.dev-sub.tiny { font-size: 11px; }
.dev-sub.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.dev-note { font-size: 12px; color: var(--text); background: var(--bg); border-radius: 7px; padding: 6px 8px; margin-top: 4px; }
.dev-edit {
  margin-top: 8px; padding: 7px; border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--text-muted); font-size: 12px; cursor: pointer; font-family: inherit;
}
.dev-edit:hover { color: var(--accent, #2d6cdf); border-color: var(--accent, #2d6cdf); }

/* перемикач «показувати в Live» */
.dev-toggle { position: relative; flex: 0 0 auto; width: 38px; height: 22px; cursor: pointer; }
.dev-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.dev-toggle span { position: absolute; inset: 0; background: var(--border); border-radius: 22px; transition: background .18s; }
.dev-toggle span::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.dev-toggle input:checked + span { background: var(--green); }
.dev-toggle input:checked + span::before { transform: translateX(16px); }

/* вікно редагування */
#dev-modal { position: fixed; inset: 0; z-index: 9900; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dev-modal-bg { position: absolute; inset: 0; background: rgba(20,28,46,.45); }
.dev-modal-card {
  position: relative; background: var(--card); border-radius: 16px; padding: 18px;
  width: min(460px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.dev-lbl { display: block; font-size: 12px; color: var(--text-muted); margin: 12px 0 5px; }
.dev-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ═══ Журнал змін ═══ */
.daud-row { padding: 13px; margin-bottom: 9px; }
.daud-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.daud-act { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 6px; border: 1.5px solid var(--src, var(--text-muted)); color: var(--src, var(--text-muted)); background: color-mix(in srgb, var(--src, #888) 12%, transparent); }
.daud-act.act-add  { --src: #1f9d55; }
.daud-act.act-hide { --src: #e2506a; }
.daud-act.act-edit { --src: #4aa8e0; }
.daud-ts { font-size: 11px; color: var(--text-muted); }
.daud-dev { font-weight: 700; font-size: 14px; color: var(--text); }
.daud-change { font-size: 12px; margin-top: 5px; padding: 5px 8px; background: var(--bg); border-radius: 7px; }
.daud-field { font-weight: 700; color: var(--text); margin-right: 6px; }
.daud-was { color: var(--text-muted); text-decoration: line-through; }
.daud-now { color: var(--green); font-weight: 700; }
.daud-foot { text-align: center; font-size: 12px; color: var(--text-muted); margin: 14px 0; }

/* ═══ Заготовка розділу ═══ */
.wip-card { padding: 20px; text-align: center; }
.wip-badge { display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  padding: 4px 12px; border-radius: 6px; margin-bottom: 12px;
  color: #f5820b; border: 1.5px solid #f5820b; background: color-mix(in srgb, #f5820b 12%, transparent); }

.empty-state { text-align: center; padding: 26px 14px; color: var(--text-muted); font-size: 14px; }

/* ═══ Спливаюче повідомлення ═══ */
.app-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: #1c1c1c; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 10000; opacity: 0; transition: opacity .2s, transform .2s;
  box-shadow: 0 8px 26px rgba(0,0,0,.3); max-width: 88vw; text-align: center;
}
.app-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Регіон і парк на картці пристрою */
.dev-place { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 3px 0 2px; }
.cc-badge {
  font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 5px;
  border: 1.5px solid var(--cc, var(--text-muted)); color: var(--cc, var(--text-muted));
  background: color-mix(in srgb, var(--cc, #888) 13%, transparent);
}
.cc-badge.cc-ua { --cc: #4aa8e0; }
.cc-badge.cc-nm { --cc: #f5820b; }
.dev-park { font-size: 11px; color: var(--text-muted); background: var(--bg); padding: 2px 8px; border-radius: 5px; }
.dev-park.warnbg { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* Оновлення довідника пристроїв */
.dev-refresh-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--border); }
.dev-refresh {
  padding: 9px 16px; border: 1.5px solid var(--accent, #2d6cdf); border-radius: 9px;
  background: transparent; color: var(--accent, #2d6cdf); font-weight: 700; font-size: 13px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.dev-refresh:hover:not(:disabled) { background: color-mix(in srgb, var(--accent, #2d6cdf) 10%, transparent); }
.dev-refresh:disabled { opacity: .6; cursor: progress; }
.dev-refresh-row .dev-sub { flex: 1 1 200px; }
#dev-refresh-res:empty { display: none; }
#dev-refresh-res { margin-top: 10px; }

/* Нові станції в результаті оновлення */
.dev-newst { margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }
.dev-newst-name { font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 7px; }
.dev-newst-row { display: flex; gap: 8px; align-items: center; }
.dev-newst-row .dev-input { flex: 1; }

/* Небезпечні дії у вікні пристрою */
.dev-danger { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.dev-danger-title { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 10px; }
.dev-danger-opt { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border); }
.dev-danger-opt:last-child { border-bottom: 0; }
.dev-danger-opt b { font-size: 13px; color: var(--text); }
.dev-danger-opt .dev-sub { margin-top: 3px; line-height: 1.4; }
.dev-btn-warn, .dev-btn-danger {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 8px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit; background: transparent; white-space: nowrap;
}
.dev-btn-warn { border: 1.5px solid #f5820b; color: #f5820b; }
.dev-btn-warn:disabled { opacity: .4; cursor: not-allowed; }
.dev-btn-danger { border: 1.5px solid var(--danger); color: var(--danger); }
.dev-btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* Перемикач моніторингу у вікні пристрою */
.dev-mon { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.dev-mon b { font-size: 13px; color: var(--text); }

/* Фільтр неактивних стрінгів */
.live-str-filter { float: right; font-size: 11px; font-weight: 500; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; text-transform: none; letter-spacing: 0; }
.live-str-filter-txt { opacity: .8; }
/* неактивні стрінги ховаються суто візуально */
.live-str-grid.hide-idle .live-str.idle { display: none; }
/* компактний тумблер */
.mini-toggle { position: relative; flex: 0 0 auto; width: 30px; height: 17px; display: inline-block; }
.mini-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.mini-toggle > span { position: absolute; inset: 0; background: var(--border); border-radius: 17px; transition: background .18s; }
.mini-toggle > span::before { content: ""; position: absolute; width: 13px; height: 13px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.mini-toggle input:checked + span { background: var(--green); }
.mini-toggle input:checked + span::before { transform: translateX(13px); }

/* Перехід між станціями зі сторінки станції */
.live-st-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* Підбір пристрою, коли серійника немає */
.dev-alt { margin-top: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }
.dev-alt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--border); }
.dev-alt-row:last-child { border-bottom: 0; }
.dev-alt-row b { font-size: 13px; color: var(--text); }
.dev-alt-add { flex: 0 0 auto; padding: 6px 13px; border-radius: 8px; font-size: 12px; font-weight: 700;
  border: 1.5px solid var(--accent, #2d6cdf); color: var(--accent, #2d6cdf); background: transparent;
  cursor: pointer; font-family: inherit; }

/* ═══ Доступи: користувачі, парки, компанії ═══ */
.acc-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.acc-search {
  flex: 1; min-width: 180px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 13px; font-family: inherit;
}
.acc-search:focus { outline: none; border-color: var(--navy); }
.btn-mini.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-mini.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.acc-list { display: flex; flex-direction: column; gap: 6px; }
.acc-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px;
  background: var(--card); border: 1px solid var(--border); border-radius: 11px;
}
.acc-row.off { opacity: .55; }
.acc-row-main { flex: 1; min-width: 0; cursor: pointer; }
.acc-row-name { font-size: 14px; font-weight: 700; display: flex; align-items: center;
  gap: 7px; flex-wrap: wrap; }
.acc-row-note {
  font-size: 12px; color: var(--text-muted); margin-top: 3px;
  padding-left: 8px; border-left: 2px solid var(--border-dark);
}
.acc-row-sub { display: flex; align-items: center; gap: 7px; margin-top: 5px;
  font-size: 12px; flex-wrap: wrap; }
.acc-row-id { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.acc-row-acts { display: flex; flex-direction: column; gap: 5px; flex: none; }
.acc-dim { color: var(--text-muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.acc-count { font-weight: 700; font-size: 12px; color: var(--green-dark);
  background: var(--green-light); padding: 2px 7px; border-radius: 999px; }
.acc-tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); }
.acc-tag.off { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.acc-chip { display: inline-block; font-size: 11.5px; padding: 4px 9px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); color: var(--text-muted); }
.acc-loose { display: flex; flex-wrap: wrap; gap: 5px; }

/* модальне вікно */
#acc-modal { position: fixed; inset: 0; z-index: 9000; }
.acc-ov { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); }
.acc-dlg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px)); max-height: min(88vh, 760px);
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.acc-dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); font-size: 15px; }
.acc-dlg-head b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-dlg-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.acc-dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px;
  border-top: 1px solid var(--border); flex-wrap: wrap; }

.acc-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acc-form > label { display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .3px; }
.acc-form > label:last-of-type { grid-column: 1 / -1; }
.acc-input { padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 13.5px; font-family: inherit;
  font-weight: 500; text-transform: none; letter-spacing: 0; width: 100%; }
.acc-input:focus { outline: none; border-color: var(--navy); background: var(--card); }
.acc-input[readonly] { opacity: .65; }
textarea.acc-input { resize: vertical; }
.acc-check { flex-direction: row !important; align-items: center; gap: 8px !important;
  align-self: end; padding-bottom: 9px; }
.acc-check input { width: 16px; height: 16px; accent-color: var(--green); }
.acc-check span { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }

/* дерево доступів */
.acc-tree-head { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 16px 0 8px; font-size: 13px; }
.acc-tree { border: 1px solid var(--border); border-radius: 11px; padding: 6px;
  background: var(--bg); max-height: 300px; overflow-y: auto; }
.acc-tree.locked { opacity: .45; pointer-events: none; }
.acc-tree-c + .acc-tree-c { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.acc-country, .acc-park-head { display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.acc-country:hover, .acc-park-head:hover { background: var(--card); }
.acc-park-head.plain { cursor: default; }
.acc-tree-body { padding-left: 18px; }
.acc-park-body { padding-left: 20px; display: flex; flex-direction: column; }
.acc-tree-body.dimmed, .acc-park-body.dimmed { opacity: .42; }
.acc-st { display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.acc-st:hover { background: var(--card); }
.acc-st.taken { opacity: .8; }
.acc-cb, .pk-cb { width: 15px; height: 15px; accent-color: var(--green);
  cursor: pointer; flex: none; }
.acc-cb:disabled, .pk-cb:disabled { cursor: not-allowed; }
.acc-err { margin-top: 12px; padding: 9px 12px; border-radius: 9px; font-size: 12.5px;
  background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }

/* компанії */
.acc-co { display: flex; align-items: center; gap: 11px; }
.acc-co-logo { width: 38px; height: 38px; border-radius: 9px; object-fit: contain;
  background: var(--bg); border: 1px solid var(--border); flex: none; }
.acc-co-logo.empty { display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--text-muted); font-size: 16px; }
.acc-uploads { display: flex; gap: 14px; flex-wrap: wrap; }
.acc-up { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.acc-up-prev { width: 74px; height: 74px; border-radius: 11px; border: 1px dashed var(--border-dark);
  background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.acc-up-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.acc-up .btn-mini { cursor: pointer; }

@media (max-width: 520px) {
  .acc-form { grid-template-columns: 1fr; }
  .acc-row { flex-direction: column; align-items: stretch; }
  .acc-row-acts { flex-direction: row; }
  .acc-row-acts .btn-mini { flex: 1; }
}

/* Шахматка під прозорим лого: інакше не видно, що фон справді знято */
.acc-up-prev.checkered {
  background-image:
    linear-gradient(45deg, var(--border) 25%, transparent 25%),
    linear-gradient(-45deg, var(--border) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--border) 75%),
    linear-gradient(-45deg, transparent 75%, var(--border) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

/* ═══ Помилки інвертора (SunSpec Evt1) ═══ */
/* Плитка з активною помилкою: інвертор може при цьому видавати потужність,
   тому позначка окрема від «не видає». */
.live-inv.has-evt { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-light); }
.live-inv { position: relative; }
.live-inv-evt {
  position: absolute; top: 5px; right: 6px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 15px; text-align: center;
}
.live-evt-title { display: flex; align-items: center; gap: 7px; margin: 14px 0 7px;
  font-size: 13px; font-weight: 700; color: var(--danger); }
.live-evt-title span { font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; background: var(--danger-light); }
.live-evt-list { display: flex; flex-direction: column; gap: 5px; }
.live-evt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 11px; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--border-dark);
  font-size: 12.5px;
}
.live-evt.crit { border-left-color: var(--danger); background: var(--danger-light); }
.live-evt span { font-size: 10.5px; color: var(--text-muted); font-family: ui-monospace, monospace; }

/* Плитка «Стан»: нуль — це відповідь «аварій немає», а не порожнеча */
.live-stat.ok .live-stat-v { color: var(--green-dark); }
.live-stat.ok { background: var(--green-light); border-color: var(--green); }
.live-stat.bad { background: var(--danger-light); border-color: var(--danger); }
.live-stat.bad .live-stat-v { color: var(--danger); }
.live-stat.bad .live-stat-l { color: var(--danger); font-weight: 700; }

/* Крок усереднення у вивантаженні */
.exp-buckets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.exp-bucket { position: relative; }
.exp-bucket input { position: absolute; opacity: 0; pointer-events: none; }
.exp-bucket span {
  display: block; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; color: var(--text-muted); transition: all .15s;
}
.exp-bucket input:checked + span {
  background: var(--navy); border-color: var(--navy); color: #fff;
}
.exp-bucket input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ═══ Вибір станції замість «попередня/наступна» ═══ */
/* Стрілками до потрібної станції з двох десятків треба дотиснути десяток разів,
   і не видно, куди йдеш. Кнопка з назвою відкриває весь перелік. */
.live-st-pick {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  font-family: inherit; cursor: pointer; max-width: 100%;
  transition: all .15s;
}
.live-st-pick:hover { border-color: var(--navy); }
.live-st-pick .live-st-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-st-caret { color: var(--text-muted); font-size: 11px; flex: none; }

#live-pick { position: fixed; inset: 0; z-index: 9500; }
.live-pick-ov { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.live-pick-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw); display: flex; flex-direction: column;
  background: var(--card); box-shadow: -8px 0 32px rgba(0,0,0,.2);
  animation: livePickIn .18s ease-out;
}
@keyframes livePickIn { from { transform: translateX(100%); } to { transform: none; } }
.live-pick-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}
.live-pick-head b { flex: none; }
.live-pick-head .acc-search { flex: 1; min-width: 0; }
.live-pick-list { flex: 1; overflow-y: auto; padding: 6px; }
.live-pick-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 10px 11px; border-radius: 10px; margin-bottom: 3px;
  background: transparent; border: 1px solid transparent;
  font-family: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
  color: var(--text);
}
.live-pick-item:hover { background: var(--bg); }
.live-pick-item.cur { background: var(--bg); border-color: var(--navy); font-weight: 700; }
.live-pick-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--green); }
.live-pick-item.st-down .live-pick-dot { background: var(--danger); }
.live-pick-item.st-stale .live-pick-dot { background: var(--text-muted); }
.live-pick-n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-pick-m { flex: none; font-size: 11.5px; color: var(--text-muted); }
.live-pick-kw { flex: none; font-weight: 700; min-width: 52px; text-align: right; }

/* ═══ Логери просто в картці станції ═══ */
/* Логери в картці малюються завжди, а видимість вирішує клас на сітці: так
   перемикання тумблера не вимагає перемальовувати перелік. */
.live-card-lgs { display: none; flex-direction: column; gap: 3px; margin: 6px 0 2px; }
.card-grid.with-details .live-card-lgs { display: flex; }
.live-card-lg {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 8px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 11.5px; line-height: 1.2;
}
.live-card-lg.bad { border-color: var(--danger); background: var(--danger-light); }
.live-card-lg.off { opacity: .6; }
.live-card-lg .lg-n { flex: 1; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.live-card-lg .lg-p { flex: none; font-weight: 700; }
.live-card-lg .lg-p i { font-style: normal; font-weight: 500; font-size: 9.5px;
  color: var(--text-muted); margin-left: 2px; }
.live-card-lg .lg-c { flex: none; min-width: 34px; text-align: right;
  color: var(--text-muted); font-variant-numeric: tabular-nums; }
.live-card-lg.bad .lg-c { color: var(--danger); font-weight: 700; }

/* Тумблер подробиць над переліком станцій */
.live-list-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.live-list-head .section-label { flex: 1; margin-bottom: 0; }
.live-details-tgl {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 5px 11px 5px 8px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  user-select: none; transition: all .15s;
}
.live-details-tgl:hover { border-color: var(--navy); color: var(--text); }
.live-details-tgl input { width: 15px; height: 15px; accent-color: var(--green); cursor: pointer; }
.live-details-tgl:has(input:checked) {
  background: var(--green-light); border-color: var(--green); color: var(--green-dark);
}

/* ═══ Трекери БКД ═══ */
.trk-sum { margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--text-muted); }

/* Захист — головне на цій панелі, тому окремою смугою вгорі */

.trk-meteo { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.trk-met { flex: 1 1 90px; padding: 8px 10px; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--border); text-align: center; }
.trk-met b { display: block; font-size: 16px; }
.trk-met b i { font-style: normal; font-size: 10px; font-weight: 500;
  color: var(--text-muted); margin-left: 2px; }
.trk-met span { font-size: 10.5px; color: var(--text-muted); }


.trk-grid { display: grid; gap: 5px;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
.trk-cell { padding: 6px 4px; border-radius: 8px; text-align: center;
  background: var(--card); border: 1px solid var(--border); cursor: default; }
.trk-cell.warn { border-color: #E8A33D; background: #FDF4E6; }
.trk-cell.bad { border-color: var(--danger); background: var(--danger-light); }
.trk-cell.off { opacity: .45; }
.trk-n { font-size: 10.5px; color: var(--text-muted); }
.trk-a { font-size: 14px; font-weight: 700; line-height: 1.15; }
.trk-d { font-size: 10px; color: #C97A16; font-weight: 700; min-height: 12px; }
.trk-cell.bad .trk-d { color: var(--danger); }

.trk-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px;
  font-size: 11px; color: var(--text-muted); }
.trk-legend span { display: inline-flex; align-items: center; gap: 5px; }
.trk-legend i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--border);
  background: var(--card); }
.trk-legend i.warn { border-color: #E8A33D; background: #FDF4E6; }
.trk-legend i.bad { border-color: var(--danger); background: var(--danger-light); }
.trk-legend i.off { opacity: .45; }

/* Підвкладки станції: генерація / трекери */
.live-sub-tabs { margin: 0 auto 14px; }
.trk-sumline { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px;
  font-size: 12px; color: var(--text-muted); }
.trk-sumline .warn { color: #C97A16; font-weight: 700; }
.trk-sumline .bad { color: var(--danger); font-weight: 700; }
/* «z» — трекер мовчить, але кут відомий: це не те саме, що застарілий запис */

.trkbf-cmd { margin: 8px 0; padding: 10px 12px; border-radius: 9px;
  background: var(--navy); color: #E6EDF7; font-size: 11.5px; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; word-break: break-all; user-select: all; }

/* Плитка трекера — тепер кнопка: відкриває його власну картку */
.trk-cell { font-family: inherit; cursor: pointer; width: 100%; }
.trk-cell:hover { border-color: var(--navy); }

/* Картка одного трекера */
#trk-one, #trk-exp { position: fixed; inset: 0; z-index: 9600; }
.trk-one-ov { position: absolute; inset: 0; background: rgba(15,23,42,.5); }
.trk-one-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(680px, calc(100vw - 20px)); max-height: min(90vh, 860px);
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.trk-one-box.narrow { width: min(420px, calc(100vw - 24px)); }
.trk-one-head { display: flex; align-items: center; gap: 9px; padding: 13px 16px;
  border-bottom: 1px solid var(--border); font-size: 15px; }
.trk-one-head b { flex: none; }
.trk-one-head .ess-card-sub { flex: 1; }
.trk-one-body { padding: 14px 16px; overflow-y: auto; }
.trk-one-ch { height: 190px; margin-top: 12px; }
.trk-one-err { margin-top: 10px; padding: 8px 12px; border-radius: 9px;
  background: var(--danger-light); color: var(--danger);
  border-left: 3px solid var(--danger); font-size: 12.5px; font-weight: 600; }
.trk-ev { display: flex; flex-direction: column; gap: 4px; }
.trk-ev-row { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px;
  border-radius: 8px; background: var(--bg); font-size: 12.5px; }
.trk-ev-row b { min-width: 42px; }
.trk-ev-row span { flex: 1; color: var(--danger); }
.trk-ev-row i { font-style: normal; font-size: 11px; color: var(--text-muted); }

/* Черга завдань для міні-ПК */
.jobs-tbl { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.jobs-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px;
  border-radius: 9px; background: var(--card); border: 1px solid var(--border);
  border-left: 3px solid var(--border-dark); font-size: 12.5px; cursor: pointer;
}
.jobs-row:hover { border-color: var(--navy); }
.jobs-row.run { border-left-color: var(--navy); background: var(--bg); }
.jobs-row.ok { border-left-color: var(--green); }
.jobs-row.bad { border-left-color: var(--danger); }
.jobs-t { font-weight: 700; flex: none; }
.jobs-p { flex: 1; color: var(--text-muted); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs-s { flex: none; font-weight: 600; }
.jobs-row.ok .jobs-s { color: var(--green-dark); }
.jobs-row.bad .jobs-s { color: var(--danger); }
.jobs-w { flex: none; color: var(--text-muted); font-size: 11px; }

/* Легенда під графіком кутів: 38 приладів, тож компактно і з прокруткою
   лише по вертикалі — горизонтальна на телефоні незручна. */
.trk-legend-box { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px;
  max-height: 108px; overflow-y: auto; }
.trk-lg-acts { display: flex; gap: 5px; width: 100%; margin-bottom: 2px; }
.trk-lg { display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border);
  font-size: 10.5px; font-weight: 600; font-family: inherit; color: var(--text); }
.trk-lg i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.trk-lg.off { opacity: .38; text-decoration: line-through; }
.trk-lg:hover { border-color: var(--navy); }
.trkx-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 10px; padding: 5px; background: var(--bg);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.acc-picker-acts { display: flex; gap: 6px; }

/* Джерело станції в переліку пристроїв: FusionSolar і Sungrow поруч, і без
   позначки незрозуміло, чиї це інвертори. */
.dev-src-tag { font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; margin-left: 6px; vertical-align: middle;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); }
.dev-src-tag.src-fusionsolar { border-color: #C0392B; color: #C0392B; }
.dev-src-tag.src-sungrow { border-color: #2E86C1; color: #2E86C1; }
.dev-src-tag.src-sma { border-color: var(--green-dark); color: var(--green-dark); }
