:root {
  color-scheme: light;
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-2: #eaf0f2;
  --ink: #17242d;
  --muted: #64737d;
  --line: #d5dde1;
  --brand: #156f68;
  --brand-dark: #0e5651;
  --accent: #b98218;
  --danger: #b73530;
  --warn: #9a6700;
  --ok: #246f45;
  --shadow: 0 12px 26px rgba(23, 36, 45, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.login-box {
  display: grid;
  gap: 14px;
  width: min(410px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand img {
  width: 74px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.65rem;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(21, 111, 104, 0.13);
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 900;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.login-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 800;
}

.app-shell {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.topbar,
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.filters,
.summary-grid {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

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

.summary-card,
.device-card,
.filters,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filters {
  padding: 14px;
}

.summary-card {
  padding: 14px;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.3rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.device-card {
  display: grid;
  gap: 13px;
  padding: 16px;
  overflow: hidden;
}

.device-card.alarm {
  border-color: rgba(183, 53, 48, 0.5);
}

.device-card.offline {
  border-color: rgba(154, 103, 0, 0.5);
}

.card-head,
.card-actions,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  min-width: 0;
}

.card-title h2 {
  margin: 0;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.card-title p,
.meta-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.temperature {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.temperature strong {
  font-size: 2.1rem;
}

.temperature span {
  color: var(--muted);
  font-weight: 900;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge.normal {
  background: #dff1e6;
  color: var(--ok);
}

.badge.alarm {
  background: #fae0de;
  color: var(--danger);
}

.badge.offline {
  background: #fff1cf;
  color: var(--warn);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.meta-grid div {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface-2);
}

.meta-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.card-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(440px, calc(100vw - 44px));
  border-radius: 8px;
  padding: 13px 15px;
  background: #17242d;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 980px) {
  .filters,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 16px;
  }

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

  .filters,
  .summary-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }
}
