:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --primary: #2f855a;

  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;

  --temperature: #e53e3e;
  --humidity: #3182ce;

  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
}

/* LAYOUT */
.container {
  max-width: 1162px;
  margin: 0 auto;
  padding: 8px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
}

/* GRID */
.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* CARD */
.card {
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* CONTENT */
.content {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* TOP ROW */
.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.title {
  font-weight: 600;
  font-size: 1rem;
}

.title[style*="cursor"]:hover {
  color: var(--primary);
}

/* TOP STATUS (age + dot) */
.top-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.age {
  white-space: nowrap;
}

/* STATUS DOT */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.online {
  background: var(--ok);
}

.status-dot.offline {
  background: var(--bad);
}

.status-dot.warn {
  background: var(--warn);
}

/* VALUES */
.values {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.main-value {
  font-size: 2.2rem;
  font-weight: 600;
}

.secondary-value {
  font-size: 1.2rem;
  color: var(--muted);
}

/* GRAPH */
.graph {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}

.graph canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.graph .no-data-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #f9fafb;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}

/* MIN MAX */
.minmax {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

/* STATUS BAR (BOTTOM) */
.status-bar {
  display: flex;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 8px 12px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
}

.status-bar .last-update {
  margin-left: auto;
}

/* FOOTER */
footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

footer a {
  color: #0ea5e9;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* DOOR */
.door-state {
  font-size: 1.6rem;
}

.door-state.open {
  color: var(--warn);
}

.door-state.closed {
  color: var(--ok);
}

.door-history {
  max-height: 180px;
  overflow-y: auto;
}

.door-log {
  list-style: none;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.door-detail-log {
  list-style: none;
  font-size: 0.85rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* MOBILE */
@media (max-width: 600px) {
    .main-value {
        font-size: 1.8rem;
    }
}