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

:root {
  --pink:   #ee559e;
  --purple: #6d3c89;
  --dark:   #1b1b1b;
  --gray:   #5c5d62;
  --border: #e5e7eb;
  --bg:     #f1f2f3;
  --white:  #ffffff;
  --green:  #22c55e;
  --gold:   #e5a100;
  --red:    #ef4444;
  --radius: 12px;
  --font:   'Inter', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  padding: 16px;
}

.dashboard {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.title { font-size: 18px; font-weight: 700; }
.last-update { font-size: 11px; color: var(--gray); margin-left: auto; white-space: nowrap; }

/* ===== STATS CARDS ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.25s;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card:hover { border-color: var(--pink); box-shadow: 0 4px 20px rgba(238,85,158,0.08); }
.stat-card.active { border-color: var(--pink); background: #fdf2f8; }
.stat-label { font-size: 11px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-name { font-size: 14px; font-weight: 700; }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-sub { font-size: 11px; color: var(--gray); }

/* ===== TABLE WRAPPER ===== */
.table-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
}

/* ===== DESKTOP TABLE ===== */
.table-grid { display: none; }
@media (min-width: 640px) {
  .table-grid { display: block; }
  .card-list { display: none; }
}

.table-header {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  padding: 12px 20px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 600; color: var(--gray);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.table-header > *:not(:first-child) { text-align: center; }

.table-body-grid { overflow-y: auto; }

.table-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: background 0.15s;
}
.table-row:last-child { border-bottom: none; }
.table-row:hover { background: #fdf2f8; }

.room-name { font-size: 14px; font-weight: 600; line-height: 1.3; }

.num-block { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.num-block .big   { font-size: 20px; font-weight: 700; }
.num-block .small { font-size: 11px; color: var(--gray); }

.occ-pill {
  display: inline-block; padding: 5px 14px;
  border-radius: 50px; font-size: 14px; font-weight: 700;
}
.occ-pill.green { background: #dcfce7; color: #15803d; }
.occ-pill.gold  { background: #fef9c3; color: #a16207; }
.occ-pill.red   { background: #fce4e4; color: #b91c1c; }

/* ===== MOBILE CARDS ===== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}
@media (min-width: 640px) {
  .card-list { display: none; }
}

.unit-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s;
}
.unit-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.05); }
.unit-card.summary { background: #fdf2f8; border-color: var(--pink); }

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-name { font-size: 15px; font-weight: 700; }
.card-occ { flex-shrink: 0; }

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.card-stat {
  background: #f9fafb;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}
.card-stat .val { font-size: 20px; font-weight: 700; }
.card-stat .lbl { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.3px; }

/* ===== LEGEND ===== */
.legend {
  display: flex; justify-content: center; gap: 16px;
  font-size: 12px; font-weight: 500; padding: 4px 0;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ===== LOADING / ERROR / EMPTY ===== */
.loading, .error, .state-empty {
  display: flex; align-items: center; justify-content: center; height: 250px;
}
.loading.hidden { display: none; }
.error { color: var(--red); font-weight: 500; }
.state-empty { color: var(--gray); }

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MOBILE FINE-TUNE ===== */
@media (max-width: 480px) {
  body { padding: 8px; }
  .dashboard { gap: 10px; }
  .header { gap: 6px; }
  .title { font-size: 15px; }
  .last-update { font-size: 10px; }

  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .stat-card {
    padding: 10px 6px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
    border-radius: 10px;
  }
  .stat-label { font-size: 10px; letter-spacing: 0; }
  .stat-name { font-size: 13px; }
  .stat-value { font-size: 20px; }
  .stat-sub { display: none; }

  .card-list { padding: 8px; gap: 6px; }
  .unit-card { padding: 12px; gap: 8px; }
  .card-name { font-size: 13px; }
  .card-stat { padding: 8px 10px; }
  .card-stat .val { font-size: 16px; }
  .card-stat .lbl { font-size: 9px; }
  .occ-pill { font-size: 12px; padding: 4px 8px; }
}
