/* =========================================================
   GP MASTER CONTROL — uporządkowany arkusz stylów
   ========================================================= */

/* ---------- Zmienne i reset ---------- */

:root {
  color-scheme: light;
  --page-bg: #f7f9fb;
  --surface: #ffffff;
  --surface-muted: #f1f3f5;
  --text: #222222;
  --text-muted: #555555;
  --border: #d0d7de;
  --border-soft: #e5e7eb;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-panel: 0 2px 6px rgba(0, 0, 0, 0.10);
  --ok: #1a7f37;
  --error: #cf222e;
  --lamp-off: #bdbdbd;
  --gap: 10px;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  padding: 12px;
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--page-bg);
}

[hidden],
.tab-panel[hidden],
.schedule-modal[hidden] {
  display: none !important;
}

/* ---------- Główny kontener ---------- */

.page {
  width: 100%;
  max-width: 98vw;
  margin: 0 auto;
  padding: 0 12px;
}

h1 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 1.25rem;
}

/* ---------- Karty i panele ---------- */

.card {
  min-width: 0;
  margin-block: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-panel);
}

.panel h1 {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #eeeeee;
  font-size: 20px;
}

.panel.compact {
  padding: 12px;
}

.panel.compact h1 {
  margin-bottom: 6px;
  padding-bottom: 6px;
  font-size: 17px;
}

.params {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  align-items: stretch;
  margin-bottom: 14px;
}

.dashboard-main {
  grid-template-columns: 1fr 1.25fr 0.95fr 1.15fr 1fr;
}

.dashboard-second {
  grid-template-columns: 1.15fr 1.45fr 1.1fr;
}

.panel.energy-panel {
  grid-column: auto;
}

.params .panel .two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.params .panel .two-col > table,
.params .panel .two-col table {
  width: 100%;
  min-width: 0;
  height: 100%;
}

/* ---------- Górny pasek ---------- */

.card.flex-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 42px;
  margin-block: 8px;
  padding: 10px 14px;
  gap: 12px;
}

.card.flex-row > * {
  margin: 2px 0;
}

.row-group,
.control-panel {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

.row-group-buttons,
.history-row {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.row-group-status {
  min-width: 0;
}

.control-label {
  margin-right: 8px;
  font-weight: 700;
}

.chart-rotation-control {
  display: none;
}

/* ---------- Tabele ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 2px 5px;
  border-bottom: 1px solid var(--border-soft);
  line-height: 1.2;
  text-align: left;
}

th {
  color: var(--text);
  background: var(--surface-muted);
}

td {
  color: var(--text);
}

.panel table th {
  font-size: 1rem;
  font-weight: 600;
}

.panel table td {
  font-size: 1.05rem;
  font-weight: 700;
}

.panel.compact table {
  font-size: 0.9rem;
}

.panel.compact th,
.panel.compact td {
  padding: 2px 5px;
}

.panel.compact small {
  color: #666666;
  font-size: 0.75em;
}

.subrow th {
  padding-left: 40px;
  font-size: 0.9em;
  font-weight: 400;
}

/* ---------- Pompy ciepła i energia ---------- */

.pc-compact-table {
  width: 100%;
}

.pc-compact-table th,
.pc-compact-table td {
  padding: 3px 4px;
  white-space: nowrap;
  text-align: center;
}

.pc-compact-table th:first-child,
.pc-compact-table td:first-child {
  text-align: left;
}

.pc-info-grid {
  margin-bottom: 10px;
}

.pc-info-grid table {
  width: 100%;
}

.pc-info-grid th {
  width: 70%;
  white-space: nowrap;
}

.pc-info-grid td {
  width: 30%;
  font-weight: 700;
  text-align: right;
}

.pc-alarm-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  font-weight: 600;
}

.pc-alarm-grid span.ok {
  color: var(--ok);
  font-weight: 700;
}

.pc-alarm-grid span.err {
  color: var(--error);
  font-weight: 700;
}

/* ---------- Statusy, lampki i badge ---------- */

.ok {
  color: var(--ok);
  font-weight: 700;
}

.err {
  color: var(--error);
  font-weight: 700;
}

.status-lamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.lamp-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  vertical-align: middle;
  background: var(--lamp-off);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  transition: background 0.2s, opacity 0.2s;
}

.lamp-dot.on-ok {
  background: #4caf50;
}

.lamp-dot.on-alarm {
  background: #f44336;
}

.lamp-dot.off {
  opacity: 0.6;
  background: var(--lamp-off);
}

.pc-compact-table .lamp-dot {
  width: 14px;
  height: 14px;
}

.state-badge {
  display: inline-block;
  min-width: 70px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

.state-stop {
  color: #ffffff;
  background: #6b7280;
}

.state-starting,
.state-stopping {
  color: #ffffff;
  background: #f59e0b;
}

.state-running {
  color: #ffffff;
  background: #10b981;
}

.state-awaria {
  color: #ffffff;
  background: #ef4444;
}

.state-service {
  color: #ffffff;
  background: #8b5cf6;
}

/* ---------- Przyciski i kontrolki ---------- */

.theme-btn,
.pill-btn,
.btn {
  font-family: inherit;
}

.theme-btn {
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: #eeeeee;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}

.theme-btn:hover {
  background: #dddddd;
}

.card.flex-row .theme-btn {
  padding: 6px 12px;
  font-size: 0.9rem;
}

.success-btn {
  border-color: #1e8e3e !important;
  color: #ffffff !important;
  background: #1e8e3e !important;
}

.success-btn:hover {
  border-color: #176c30 !important;
  background: #176c30 !important;
}

.danger-btn {
  border-color: #c5221f !important;
  color: #ffffff !important;
  background: #c5221f !important;
}

.danger-btn:hover {
  border-color: #9b1b18 !important;
  background: #9b1b18 !important;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, #2196f3, #21cbf3);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}

.pill-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.pill-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.pill-btn:disabled {
  opacity: 0.5;
  box-shadow: none;
  cursor: default;
  transform: none;
}

.btn {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s, transform 0.1s;
}

.btn.minus {
  background: #2196f3;
}

.btn.minus:hover {
  background: #1976d2;
}

.btn.minus:active {
  transform: scale(0.95);
  background: #0d47a1;
}

.btn.plus {
  background: #f44336;
}

.btn.plus:hover {
  background: #d32f2f;
}

.btn.plus:active {
  transform: scale(0.95);
  background: #b71c1c;
}

.number-control {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
}

.setpoint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  font-size: 1.1rem;
}

.setpoint-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 90px;
  height: 36px;
  cursor: pointer;
}

.toggle input {
  display: none;
}

.slider {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.slider .on,
.slider .off {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

.slider .on {
  background: #4caf50;
}

.slider .off {
  background: #b8b8b8;
}

.toggle input:not(:checked) ~ .slider .on,
.toggle input:checked ~ .slider .off {
  opacity: 0.3;
}

/* ---------- Wykresy ---------- */

.charts {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  align-items: stretch;
}

.charts .card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-block: 6px;
  padding: 7px;
}

.charts .card h1 {
  flex: 0 0 auto;
  margin: 0 0 3px;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chart-box,
.charts .chart-box {
  position: relative;
  width: 100%;
  height: 225px;
  min-height: 0;
  overflow: hidden;
}

.chart-box canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.meta,
.charts .meta {
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1.15;
}

.charts .meta {
  flex: 0 0 auto;
  margin-top: 3px;
}

@keyframes chart-slide-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Harmonogram i modal ---------- */

.schedule-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.schedule-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.schedule-modal-content {
  position: relative;
  width: min(1280px, 96vw);
  max-height: 92vh;
  margin: 3vh auto;
  padding: 16px;
  overflow: auto;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.schedule-modal-header,
.schedule-modal-footer {
  position: sticky;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  background: inherit;
}

.schedule-modal-header {
  top: 0;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.schedule-modal-footer {
  bottom: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.schedule-pump-card {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.schedule-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.schedule-toolbar label {
  display: flex;
  flex-direction: column;
  min-width: 130px;
  gap: 4px;
  font-size: 0.95rem;
}

.schedule-toolbar input {
  padding: 8px;
}

.schedule-timeline-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}

.schedule-ticks,
.schedule-timeline {
  position: relative;
  width: 1440px;
  min-width: 1440px;
}

.schedule-ticks {
  height: 22px;
  margin-bottom: 6px;
}

.schedule-timeline {
  height: 56px;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      to right,
      #eef2f7 0,
      #eef2f7 59px,
      #dbe3ea 60px
    );
}

.schedule-tick {
  position: absolute;
  top: 0;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  transform: translateX(-50%);
}

.schedule-break {
  position: absolute;
  top: 8px;
  height: 40px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: grab;
  touch-action: none;
}

.schedule-break:active {
  cursor: grabbing;
}

.break-a {
  background: rgba(33, 150, 243, 0.78);
}

.break-b {
  background: rgba(244, 67, 54, 0.78);
}

/* ---------- Tryb ciemny ---------- */

body.dark {
  color: #e0e0e0;
  background: #121212;
}

body.dark .card,
body.dark .panel,
body.dark .schedule-modal-content,
body.dark .schedule-pump-card {
  border-color: #333333;
  background: #1e1e1e;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

body.dark h1 {
  color: #f1f1f1;
  border-bottom-color: #333333;
}

body.dark table {
  border-color: #333333;
}

body.dark th {
  color: #f1f1f1;
  border-bottom-color: #333333;
  background: #2c2c2c;
}

body.dark td {
  color: #e0e0e0;
  border-bottom-color: #333333;
}

body.dark .ok {
  color: #4caf50;
}

body.dark .err {
  color: #f44336;
}

body.dark .lamp-dot.off {
  background: #555555;
  box-shadow: 0 0 0 1px #000000;
}

body.dark .lamp-dot.on-ok {
  background: #66bb6a;
}

body.dark .lamp-dot.on-alarm {
  background: #ef5350;
}

body.dark .pill-btn {
  background: linear-gradient(135deg, #1565c0, #1e88e5);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

body.dark .btn.minus {
  background: #13688a;
}

body.dark .btn.plus {
  background: #801212;
}

body.dark .toggle .on {
  background: #388e3c;
}

body.dark .toggle .off {
  background: #c62828;
}

body.dark .theme-btn {
  color: #f1f1f1;
  background: #333333;
}

body.dark .theme-btn:hover {
  background: #444444;
}

body.dark .panel.compact small {
  color: #aaaaaa;
}

body.dark .schedule-modal-header,
body.dark .schedule-modal-footer {
  border-color: #333333;
}

body.dark .schedule-timeline {
  border-color: #444444;
  background:
    repeating-linear-gradient(
      to right,
      #232323 0,
      #232323 59px,
      #353535 60px
    );
}

body.dark .schedule-tick {
  color: #cccccc;
}

body.dark .schedule-timeline-wrap {
  border-color: #333333;
  background: rgba(255, 255, 255, 0.03);
}

/* =========================================================
   Duży monitor / kiosk
   ========================================================= */

@media (min-width: 1401px) and (min-height: 750px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body {
    padding: 4px;
  }

  .page {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 0 4px;
    overflow: hidden;
  }

  .card.flex-row {
    flex: 0 0 auto;
    min-height: 48px;
    margin-block: 6px;
    padding: 8px 12px;
  }

  .params {
    flex: 0 0 auto;
    gap: 6px;
    margin-bottom: 8px;
  }

  .dashboard-main {
    grid-template-columns: 1.05fr 1.35fr 0.95fr 1.35fr 1.05fr;
  }

  .dashboard-second {
    grid-template-columns: 1.10fr 1.65fr 1.15fr;
  }

  .panel.compact {
    min-width: 0;
    padding: 12px;
  }

  .panel.compact h1 {
    margin-bottom: 6px;
    padding-bottom: 6px;
    font-size: clamp(24px, 1.35vw, 28px);
    line-height: 1.15;
  }

  .panel.compact table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
  }

  .panel.compact th,
  .panel.compact td {
    min-width: 0;
    padding: 3px 5px;
    overflow: hidden;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .panel.compact table th {
    font-size: clamp(20px, 1.15vw, 23px);
    font-weight: 650;
  }

  .panel.compact table td {
    font-size: clamp(22px, 1.28vw, 26px);
    font-weight: 750;
    text-align: right;
  }

  .params .panel .two-col {
    gap: 6px;
  }

  .dashboard-main > .panel:nth-child(1) > table th,
  .dashboard-main > .panel:nth-child(2) > table th,
  .dashboard-main > .panel:nth-child(3) > table th,
  .dashboard-main > .panel:nth-child(5) > table th {
    width: 64%;
  }

  .dashboard-main > .panel:nth-child(1) > table td,
  .dashboard-main > .panel:nth-child(2) > table td,
  .dashboard-main > .panel:nth-child(3) > table td,
  .dashboard-main > .panel:nth-child(5) > table td {
    width: 36%;
  }

  .dashboard-main > .panel:nth-child(4) th {
    width: 64%;
    font-size: clamp(18px, 1vw, 21px);
  }

  .dashboard-main > .panel:nth-child(4) td {
    width: 36%;
    font-size: clamp(21px, 1.12vw, 23px);
  }

  .dashboard-second > .panel:nth-child(1) th {
    width: 66%;
    font-size: clamp(18px, 1.02vw, 21px);
  }

  .dashboard-second > .panel:nth-child(1) td {
    width: 34%;
    font-size: clamp(21px, 1.18vw, 24px);
  }

  .dashboard-second > .panel:nth-child(1) small {
    font-size: 0.58em;
  }

  .panel.compact .pc-compact-table {
    table-layout: fixed;
  }

  .panel.compact .pc-compact-table th,
  .panel.compact .pc-compact-table td {
    padding: 4px 3px;
    font-size: clamp(18px, 1.02vw, 21px) !important;
    text-align: center;
  }

  .panel.compact .pc-info-grid {
    gap: 6px;
  }

  .panel.compact .pc-info-grid th,
  .panel.compact .pc-info-grid td {
    padding: 4px 5px;
    font-size: clamp(18px, 1.05vw, 22px) !important;
  }

  .panel.compact .pc-info-grid th {
    width: 72%;
  }

  .panel.compact .pc-info-grid td {
    width: 28%;
  }

  .dashboard-second > .panel:nth-child(3) th {
    font-size: clamp(18px, 1.02vw, 21px);
  }

  .dashboard-second > .panel:nth-child(3) td {
    font-size: clamp(21px, 1.12vw, 23px);
  }

  .dashboard-second > .panel:nth-child(3) th:nth-child(1),
  .dashboard-second > .panel:nth-child(3) td:nth-child(1) {
    width: 20%;
  }

  .dashboard-second > .panel:nth-child(3) th:nth-child(2),
  .dashboard-second > .panel:nth-child(3) td:nth-child(2) {
    width: 27%;
  }

  .dashboard-second > .panel:nth-child(3) th:nth-child(3),
  .dashboard-second > .panel:nth-child(3) td:nth-child(3) {
    width: 30%;
  }

  .dashboard-second > .panel:nth-child(3) th:nth-child(4),
  .dashboard-second > .panel:nth-child(3) td:nth-child(4) {
    width: 23%;
  }

  .panel.compact .lamp-dot {
    width: 21px;
    height: 21px;
  }

  .panel.compact .pc-compact-table .lamp-dot {
    width: 22px;
    height: 22px;
  }

  .panel.compact .state-badge {
    min-width: 84px;
    padding: 3px 9px;
    font-size: 17px;
  }

  .dashboard-main > .panel:first-child table tr:nth-child(2) th {
    font-size: clamp(21px, 1.2vw, 24px) !important;
    font-weight: 800 !important;
  }

  .pc-info-grid > table:first-child tr:first-child th {
    font-size: clamp(20px, 1.15vw, 23px) !important;
    font-weight: 800 !important;
  }

  .dashboard-main > .panel:first-child table tr:nth-child(2) td,
  .pc-info-grid > table:first-child tr:first-child td {
    font-weight: 800 !important;
  }

  .dashboard-main > .panel:first-child table tr:nth-child(2) .state-badge,
  .pc-info-grid > table:first-child tr:first-child .state-badge {
    min-width: 88px;
    padding: 4px 10px;
    font-size: 18px !important;
    font-weight: 800 !important;
  }

  .chart-rotation-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
  }

  #chartSlideInterval {
    min-width: 58px;
  }

  /* Siedem wykresów przed uruchomieniem JS albo bez pokazu */
  .charts {
    flex: 0 0 auto;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    min-height: 0;
  }

  .charts .card {
    margin: 0 0 6px;
    padding: 5px;
  }

  .charts .chart-box {
    height: clamp(180px, 24vh, 230px);
    max-height: 230px;
  }

  .charts .meta {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* Pokaz slajdów przejmuje dokładnie pozostałą wysokość */
  .charts.chart-slideshow-active {
    flex: 1 1 0;
    grid-template-columns:
      repeat(var(--visible-chart-count, 3), minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
  }

  .charts.chart-slideshow-active > .card {
    display: none;
  }

  .charts.chart-slideshow-active > .card.chart-slide-visible {
    display: flex;
    align-self: stretch;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 5px;
    overflow: hidden;
    animation: chart-slide-in 220ms ease-out;
  }

  .charts.chart-slideshow-active > .card.chart-slide-visible > h1,
  .charts.chart-slideshow-active > .card.chart-slide-visible > .meta {
    flex: 0 0 auto;
  }

  .charts.chart-slideshow-active > .card.chart-slide-visible > .chart-box {
    flex: 1 1 0;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }
}

/* =========================================================
   Średnie ekrany
   ========================================================= */

@media (min-width: 1000px) and (max-width: 1400px) {
  .dashboard-main,
  .dashboard-second {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel.compact h1 {
    font-size: 17px;
  }

  .panel.compact table th {
    font-size: 0.95rem;
  }

  .panel.compact table td {
    font-size: 1rem;
  }

  .charts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .charts .chart-box {
    height: 190px;
  }
}

/* =========================================================
   Tablety
   ========================================================= */

@media (min-width: 769px) and (max-width: 999px) {
  .dashboard-main,
  .dashboard-second {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts .chart-box {
    height: 210px;
  }
}

@media (min-width: 769px) {
  .status-lamp {
    gap: 10px;
    font-size: 1.15rem;
  }

  .status-lamp .lamp-dot {
    width: 20px;
    height: 20px;
  }
}

/* =========================================================
   Telefony
   ========================================================= */

@media (max-width: 768px) {
  body {
    padding: 8px;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  .dashboard-main,
  .dashboard-second,
  .params {
    grid-template-columns: 1fr;
  }

  .params .panel .two-col {
    grid-template-columns: 1fr;
  }

  .params .panel table th,
  .params .panel table td {
    font-size: 1rem !important;
    font-weight: 500;
  }

  .card.flex-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .card.flex-row .row-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 6px;
  }

  .row-group-buttons {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 10px;
  }

  .row-group-status {
    width: 100%;
    margin-top: 4px;
  }

  .history-row {
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    gap: 10px;
  }

  #historyLength,
  #applyMaxPoints {
    flex: 1;
  }

  #applyMaxPoints {
    text-align: center;
  }

  .theme-btn {
    display: inline-flex;
    align-items: center;
    width: auto;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.9rem;
  }

  .setpoint-value {
    font-size: 1rem !important;
    font-weight: 500 !important;
  }

  .pc-info-grid {
    grid-template-columns: 1fr !important;
  }

  .pc-compact-table {
    font-size: 0.8rem;
  }

  .charts {
    display: flex;
    flex-direction: column;
  }

  .charts .chart-box {
    height: 220px;
  }

  .chart-rotation-control {
    display: none !important;
  }

  .schedule-modal-content {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    padding: 12px;
    border-radius: 0;
  }

  .schedule-modal-header h1 {
    margin: 0;
    font-size: 1.05rem;
  }

  .schedule-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 10px;
  }

  .schedule-toolbar label {
    width: 100%;
    min-width: 0;
    font-size: 0.9rem;
  }

  .schedule-toolbar span {
    grid-column: 1 / -1;
    margin-top: 4px;
    font-size: 0.95rem;
  }

  .schedule-modal-footer {
    justify-content: stretch;
  }

  .schedule-modal-footer .pill-btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .schedule-pump-card {
    padding: 10px;
  }

  .schedule-pump-card h2 {
    margin: 0 0 10px;
    font-size: 1rem;
  }

  .schedule-timeline-wrap {
    padding: 8px 0 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.02);
  }
}
