* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #e2e8f0;
}

.auth-card,
.dashboard-wrap {
  width: min(960px, 92vw);
  margin: 2rem auto;
}

.auth-card {
  max-width: 420px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  padding: 1.4rem;
}

h1,
h2 {
  margin-top: 0;
}

label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0b1220;
  color: #f8fafc;
}

select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0b1220;
  color: #f8fafc;
}

button,
.button {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.65rem 0.95rem;
  border-radius: 8px;
  border: 0;
  text-decoration: none;
  color: #fff;
  background: #2563eb;
  cursor: pointer;
}

.button.danger {
  background: #dc2626;
}

.button.button-secondary {
  background: #334155;
}

.button.button-ghost {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.dashboard-header .button,
.message-banner-head .button,
.modal-header .button,
.modal-actions .button {
  margin-top: 0;
}

.helper {
  margin-top: 0.9rem;
}

.helper.muted {
  color: #94a3b8;
  font-size: 0.9rem;
}

.message {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
}

.message.error {
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid rgba(248, 113, 113, 0.5);
}

.message.success {
  background: rgba(22, 163, 74, 0.2);
  border: 1px solid rgba(74, 222, 128, 0.5);
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dashboard-header.compact {
  margin-bottom: 0;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.control-nav {
  width: min(960px, 92vw);
  margin: 1rem auto;
}

.control-nav-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button.active {
  background: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.25) inset;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card,
.table-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  padding: 1rem;
}

.message-banner {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.message-banner-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.message-preview {
  padding: 1rem;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
  min-height: 72px;
  display: flex;
  align-items: center;
}

.message-preview p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.temperature-card {
  display: grid;
  gap: 1rem;
}

.temperature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.temperature-item {
  padding: 1rem;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.temperature-item h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: #cbd5e1;
}

.temperature-item p {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(640px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.45);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.modal-header h2 {
  margin: 0;
}

.modal-body {
  padding: 1.1rem;
  display: grid;
  gap: 1rem;
}

.message-view {
  padding: 1rem;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.message-view p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-edit-form textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.stat-card p {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  text-align: left;
  padding: 0.55rem;
  white-space: nowrap;
}

.table-actions .button {
  margin-top: 0;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-online {
  color: #dcfce7;
  background: rgba(22, 163, 74, 0.35);
  border: 1px solid rgba(74, 222, 128, 0.6);
}

.status-offline {
  color: #fee2e2;
  background: rgba(220, 38, 38, 0.35);
  border: 1px solid rgba(248, 113, 113, 0.6);
}

.status-unknown {
  color: #e2e8f0;
  background: rgba(71, 85, 105, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.45);
}

.measure-voda {
  color: #dbeafe;
  background: rgba(37, 99, 235, 0.35);
  border: 1px solid rgba(96, 165, 250, 0.6);
}

.measure-vysoky-tarif {
  color: #fef9c3;
  background: rgba(202, 138, 4, 0.35);
  border: 1px solid rgba(250, 204, 21, 0.6);
}

.measure-nizky-tarif {
  color: #ffedd5;
  background: rgba(234, 88, 12, 0.35);
  border: 1px solid rgba(251, 146, 60, 0.6);
}

.measure-plyn {
  color: #dcfce7;
  background: rgba(22, 163, 74, 0.35);
  border: 1px solid rgba(74, 222, 128, 0.6);
}

.measure-komin {
  color: #e5e7eb;
  background: rgba(107, 114, 128, 0.45);
  border: 1px solid rgba(156, 163, 175, 0.6);
}

.measure-unknown {
  color: #e2e8f0;
  background: rgba(71, 85, 105, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.45);
}

.device-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.form-actions .button,
.form-actions button {
  margin-top: 0;
}

.boiler-layout {
  grid-template-columns: 1.1fr 0.9fr;
  align-items: stretch;
}

.boiler-visual-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.boiler-shell {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
}

.boiler-tank {
  position: relative;
  width: min(280px, 100%);
  min-height: 440px;
  border-radius: 140px;
  border: 6px solid rgba(148, 163, 184, 0.55);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.88));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 20px 45px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}

.boiler-tank::before,
.boiler-tank::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 18px;
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.boiler-tank::before {
  top: 24px;
}

.boiler-tank::after {
  bottom: 24px;
}

.boiler-spirals {
  position: absolute;
  inset: 90px 40px 90px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}

.boiler-spiral {
  height: 64px;
  border-radius: 999px;
  border: 5px solid #94a3b8;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(148, 163, 184, 0.18) 0 16px,
      rgba(148, 163, 184, 0.42) 16px 32px
    );
  box-shadow: inset 0 0 16px rgba(15, 23, 42, 0.35);
}

.boiler-spiral.is-active {
  border-color: #facc15;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(250, 204, 21, 0.35) 0 16px,
      rgba(234, 179, 8, 0.82) 16px 32px
    );
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.35), inset 0 0 12px rgba(255, 255, 255, 0.18);
}

.boiler-temp {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 50px);
  text-align: center;
  font-weight: 600;
}

.boiler-temp span {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.boiler-temp-top {
  top: 88px;
}

.boiler-temp-bottom {
  bottom: 88px;
}

.boiler-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.boiler-spiral-statuses {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.boiler-spiral-toggle {
  margin: 0;
}

.boiler-spiral-status {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.55);
  width: 100%;
  margin-top: 0;
  text-align: left;
}

button.boiler-spiral-status {
  appearance: none;
  -webkit-appearance: none;
}

.boiler-spiral-status:hover {
  border-color: rgba(148, 163, 184, 0.45);
}

.boiler-spiral-status:focus-visible {
  outline: 2px solid rgba(147, 197, 253, 0.8);
  outline-offset: 2px;
}

.boiler-spiral-status.is-active {
  border-color: rgba(250, 204, 21, 0.45);
  box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.08);
}

.boiler-spiral-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 1.45rem;
  line-height: 1;
  color: #cbd5e1;
  background: rgba(100, 116, 139, 0.3);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.boiler-spiral-status.is-active .boiler-spiral-icon {
  color: #422006;
  background: rgba(250, 204, 21, 0.92);
  border-color: rgba(234, 179, 8, 0.95);
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.28);
}

.boiler-spiral-state {
  grid-column: 1 / -1;
  font-weight: 700;
}

.boiler-spiral-state.is-active {
  color: #facc15;
}

.boiler-spiral-state.is-inactive {
  color: #94a3b8;
}

.boiler-badge-active {
  color: #422006;
  background: rgba(250, 204, 21, 0.9);
  border: 1px solid rgba(234, 179, 8, 0.95);
}

.boiler-badge-inactive {
  color: #e2e8f0;
  background: rgba(100, 116, 139, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.45);
}

.boiler-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.boiler-form input[type="range"] {
  padding: 0;
  border: 0;
  background: transparent;
}

.boiler-temperature-readout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.boiler-sensor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.fve-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.fve-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  padding: 1rem;
}

.fve-card h2 {
  margin: 0;
  font-size: 1rem;
  color: #cbd5e1;
}

.fve-card p {
  margin: 0.45rem 0 0;
  font-size: clamp(1.55rem, 2.8vw, 2.15rem);
  font-weight: 800;
  line-height: 1.15;
  color: #f8fafc;
}

.fve-state {
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}

.fve-state-normal {
  color: #dcfce7;
  background: rgba(22, 163, 74, 0.35);
  border: 1px solid rgba(74, 222, 128, 0.6);
}

.fve-state-warning {
  color: #fef9c3;
  background: rgba(202, 138, 4, 0.35);
  border: 1px solid rgba(250, 204, 21, 0.6);
}

.fve-state-critical {
  color: #fee2e2;
  background: rgba(220, 38, 38, 0.35);
  border: 1px solid rgba(248, 113, 113, 0.6);
}

.fve-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.fve-control-form {
  margin: 0;
}

.fve-toggle-pair {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.fve-state-button {
  width: 100%;
  margin-top: 0;
  font-weight: 700;
}

.fve-state-button.is-active {
  color: #dcfce7;
  background: #15803d;
}

.fve-state-button.is-inactive {
  color: #e2e8f0;
  background: #64748b;
}

.fve-auto-card {
  margin-top: 1rem;
}

.fve-auto-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.fve-auto-actions form,
.fve-hour-form {
  margin: 0;
}

.fve-auto-actions button,
.fve-hour-form button {
  width: 100%;
}

.fve-hour-form {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: end;
}

.fve-hour-form label {
  grid-column: 1 / -1;
}

.fve-hour-form input {
  margin: 0;
}

.section-separator {
  margin: 1.5rem 0;
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.fve-dilna-card {
  margin-top: 0;
}

.fve-dilna-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 700px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .boiler-layout,
  .boiler-sensor-grid,
  .boiler-spiral-statuses {
    grid-template-columns: 1fr;
  }

  .fve-grid {
    grid-template-columns: 1fr;
  }

  .fve-control-grid,
  .fve-auto-actions,
  .fve-hour-form,
  .fve-dilna-grid {
    grid-template-columns: 1fr;
  }

  .fve-toggle-pair {
    flex-direction: column;
  }

  .boiler-spiral-status {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .device-form-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
