/* สไตล์เฉพาะของแต่ละหน้า */

/* ================= ภาพรวม ================= */
.hero-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 980px) {
  .hero-row {
    grid-template-columns: 1fr;
  }
}

.hero-card {
  background: linear-gradient(160deg, var(--panel) 55%, #0b1f15 100%);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
}

.hero-figure {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 10px 0 4px;
  position: relative;
  z-index: 1;
}

.hero-num {
  font-family: var(--font-disp);
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
}

.hero-unit {
  font-size: 16px;
  color: var(--text-mid);
  font-weight: 600;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  position: relative;
  z-index: 1;
}

.cost-chip {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--panel-raised);
  border: 1px solid var(--hairline);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-hi);
}

.trend-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.trend-chip.up {
  color: var(--danger);
  background: var(--danger-soft);
}

.trend-chip.flat {
  color: var(--text-mid);
  background: var(--panel-raised);
}

.spark-wrap {
  margin-top: 16px;
  position: relative;
  z-index: 1;
}

.spark-days {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-low);
  margin-top: 6px;
  padding: 0 2px;
}

.spark-hit {
  cursor: crosshair;
}

.spark-tip {
  position: absolute;
  background: var(--panel-raised);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 11px;
  font-family: var(--font-mono);
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  z-index: 3;
}

.stat-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-mini {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  /* การ์ดสี่ช่องนี้ถูกยืดให้สูงเท่าการ์ดใหญ่ข้าง ๆ
     ดันคำอธิบายไปชิดล่างเพื่อให้ช่องว่างดูตั้งใจ ไม่ใช่เหมือนวางผิด */
  justify-content: space-between;
  gap: 8px;
  min-height: 108px;
}

.stat-mini-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-mini-val {
  font-family: var(--font-disp);
  font-size: 24px;
  font-weight: 700;
}

.stat-mini-val small {
  font-size: 13px;
  color: var(--text-mid);
  font-weight: 600;
}

.stat-mini-label {
  font-size: 11.5px;
  color: var(--text-mid);
}

/* ---------- Building Pulse ---------- */
.pulse-card {
  margin-bottom: 16px;
}

.pulse-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.pulse-title {
  font-family: var(--font-disp);
  font-size: 16px;
  font-weight: 700;
}

.pulse-desc {
  font-size: 12px;
  color: var(--text-mid);
  margin-top: 3px;
  max-width: 460px;
  line-height: 1.6;
}

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-mid);
}

.legend-bar {
  width: 70px;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--panel-raised), var(--accent));
}

.pulse-floor {
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid var(--hairline-soft);
}

.pulse-floor:first-of-type {
  border-top: none;
}

.pulse-floor-label {
  width: 64px;
  flex: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mid);
  display: flex;
  align-items: center;
}

.pulse-cells {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.pulse-cell {
  position: relative;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  padding: 9px 10px;
  min-width: 78px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: transform 0.15s;
  color: inherit;
  text-align: left;
  background: var(--panel-raised);
}

.pulse-cell:hover {
  transform: translateY(-2px);
  cursor: pointer;
}

.pulse-cell .room {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
}

.pulse-cell .kwh {
  font-size: 10.5px;
  color: var(--text-mid);
}

.pulse-live {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.pulse-live::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.8s ease-out infinite;
}

.pulse-live.warn {
  background: var(--warn);
}

.pulse-live.warn::after {
  background: var(--warn);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.55);
  }
  100% {
    box-shadow: 0 0 0 9px rgba(62, 207, 142, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-live::after {
    animation: none;
  }
}

.two-col {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
}

@media (max-width: 980px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* ---------- การแจ้งเตือน ---------- */
.alert-item {
  display: flex;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--hairline-soft);
}

.alert-item:last-child {
  border-bottom: none;
}

.alert-bar {
  width: 3px;
  border-radius: 3px;
  flex: none;
  align-self: stretch;
}

.alert-bar.pending {
  background: var(--warn);
}

.alert-bar.done {
  background: var(--accent);
}

.alert-bar.ack {
  background: var(--info);
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.alert-room {
  font-size: 13px;
  font-weight: 600;
}

.alert-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-low);
  flex: none;
}

.alert-desc {
  font-size: 12px;
  color: var(--text-mid);
  margin: 3px 0 7px;
  line-height: 1.5;
}

/* ---------- อันดับการใช้ไฟ ---------- */
.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--hairline-soft);
}

.rank-item:last-child {
  border-bottom: none;
}

.rank-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-low);
  width: 16px;
}

.rank-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--panel-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--accent);
}

.rank-name {
  font-size: 13px;
  font-weight: 600;
}

.rank-sub {
  font-size: 11px;
  color: var(--text-mid);
}

.rank-val {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-hi);
  font-weight: 600;
  text-align: right;
}

.rank-bar-track {
  width: 60px;
  height: 4px;
  border-radius: 3px;
  background: var(--panel-raised);
  margin-top: 4px;
  overflow: hidden;
  margin-left: auto;
}

.rank-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

/* ================= ห้องและควบคุม ================= */
.rooms-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

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

.room-card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 15px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s, transform 0.15s;
  text-align: left;
  color: inherit;
}

.room-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
  cursor: pointer;
}

.room-card.counting {
  border-color: var(--warn);
}

.room-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.room-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex: none;
}

.room-card-name {
  font-family: var(--font-disp);
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}

.room-card-desc {
  font-size: 11.5px;
  color: var(--text-mid);
}

.room-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-mid);
  border-top: 1px solid var(--hairline-soft);
  padding-top: 11px;
  gap: 8px;
}

.status-dot-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-low);
}

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

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

.devices-chip {
  font-family: var(--font-mono);
  background: var(--panel-raised);
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 10.5px;
}

.countdown-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--warn-soft);
  border: 1px solid rgba(232, 163, 61, 0.35);
  color: var(--warn);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 11.5px;
  font-weight: 600;
}

.countdown-strip .clock {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---------- รีโมตแอร์ในลิ้นชัก ---------- */
.ac-card {
  background: var(--panel-raised);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.ac-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

.ac-name {
  font-size: 12.5px;
  color: var(--text-mid);
  font-weight: 600;
}

.ac-sub {
  font-size: 10.5px;
  color: var(--text-low);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.temp-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-bottom: 6px;
}

.temp-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text-hi);
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.temp-btn:hover {
  border-color: var(--accent-dim);
}

.temp-val {
  font-family: var(--font-disp);
  font-size: 34px;
  font-weight: 700;
  min-width: 108px;
  text-align: center;
}

.ac-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.metric-box {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 8px;
  text-align: center;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.metric-label {
  font-size: 9.5px;
  color: var(--text-low);
  margin-top: 2px;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.chip-row .chip-label {
  font-size: 10.5px;
  color: var(--text-low);
  width: 100%;
  margin-bottom: -4px;
}

.mode-chip {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text-mid);
}

.mode-chip.sel {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-soft);
}

.mode-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ================= ตารางเรียน ================= */
.sched-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.sched-card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 15px;
  padding: 16px;
}

.sched-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.sched-room {
  font-family: var(--font-disp);
  font-weight: 700;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-soft {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 100px;
}

.badge-soft.dim {
  color: var(--text-low);
  background: var(--panel-raised);
}

.sched-empty {
  font-size: 12px;
  color: var(--text-low);
  padding: 10px 0;
}

.sched-row {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--hairline-soft);
  align-items: flex-start;
}

.sched-row:first-of-type {
  border-top: none;
}

.sched-row.now {
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding-left: 8px;
  padding-right: 8px;
}

.sched-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mid);
  width: 78px;
  flex: none;
  padding-top: 1px;
}

.sched-info {
  flex: 1;
  min-width: 0;
}

.sched-info .course {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.45;
}

.sched-info .meta {
  font-size: 11px;
  color: var(--text-low);
  margin-top: 2px;
  line-height: 1.5;
}

/* ================= อัตราค่าไฟ ================= */
.rate-wrap {
  max-width: 540px;
}

.rate-current {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(160deg, #1b3324, #0e1d15);
  border: 1px solid var(--hairline);
  border-radius: 15px;
  padding: 18px;
  margin-bottom: 18px;
}

.rate-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--warn-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--warn);
  flex: none;
}

.rate-value {
  font-family: var(--font-disp);
  font-size: 22px;
  font-weight: 700;
  margin-top: 2px;
}

.rate-value small {
  font-size: 14px;
  color: var(--text-mid);
  font-weight: 600;
}

.rate-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 10px;
}

.rate-input-row input {
  background: none;
  border: none;
  color: var(--text-hi);
  font-family: var(--font-mono);
  font-size: 16px;
  width: 100%;
  outline: none;
}

.rate-hint {
  font-size: 11px;
  color: var(--text-low);
  margin-top: 6px;
}

.rate-example {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 16px;
  margin-top: 20px;
}

.rate-example-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-top: 1px solid var(--hairline-soft);
  gap: 10px;
}

.rate-example-row:first-of-type {
  border-top: none;
}

.rate-example-row.total {
  font-weight: 700;
  color: var(--accent);
  font-size: 15px;
}

/* ================= ข้อมูลไฟฟ้า ================= */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.metric-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--panel-raised);
  border: 1px solid var(--hairline);
  color: var(--text-mid);
  cursor: pointer;
}

.checkbox-chip.sel {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-soft);
}

.checkbox-chip input {
  display: none;
}

/* ================= ผู้ใช้ / อุปกรณ์ ================= */
.list-card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.list-card + .list-card {
  margin-top: 10px;
}

.list-title {
  font-size: 13.5px;
  font-weight: 600;
}

.list-sub {
  font-size: 11.5px;
  color: var(--text-mid);
  margin-top: 3px;
  line-height: 1.6;
}

.token-box {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--panel-raised);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  word-break: break-all;
  line-height: 1.6;
  color: var(--accent);
}
