/* ==========================================================================
   Dashboard / Index Page
   >>>
   1. 保留首頁 dashboard 層次感
   2. 與 control-center 同色系、同元件語言
   3. 不動 .lights-panel #lightsGrid
   ========================================================================== */

.page-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px 18px 24px;
}

.page-header {
  margin-bottom: 18px;
}

.title-block h1 {
  margin: 0;
  font-size: 1.72rem;
  font-weight: 900;
  letter-spacing: 0.2px;
  color: #0f172a;
}

.title-block p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  align-items: center;
  display: flex;  
  flex-direction: column; 
  align-items: flex-end; 
  gap: 6px;
}

.topbar-actions .rangeMeta {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
}

/* ===== Hero 區 ===== */
.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.hero-card,
.overview-card,
.panel,
.data-card,
.light-card,
.miniCard {
  border-radius: 18px;
  border: 1px solid var(--border);
}

.hero-card {
  padding: 20px 22px;
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.18), transparent 30%),
    linear-gradient(135deg, #eef6ff 0%, #ffffff 62%);
  border-color: #dbeafe;
  box-shadow:
    0 18px 44px rgba(14, 165, 233, 0.08),
    0 4px 14px rgba(15, 23, 42, 0.04);
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
  font-size: 12px;
  font-weight: 900;
}

.hero-title {
  margin: 14px 0 0;
  font-size: 1.72rem;
  line-height: 1.2;
  font-weight: 900;
  color: #0f172a;
}

.hero-copy {
  margin: 12px 0 0;
  color: #475569;
  line-height: 1.78;
  font-size: 14px;
  max-width: 62ch;
}

.hero-actions {
  margin-top: 18px;
}

.hero-actions .primary {
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.18);
}

.overview-card,
.panel {
  padding: 17px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.04),
    0 2px 10px rgba(15, 23, 42, 0.02);
}

.overview-card h3,
.panel-title,
.trendSectionTitle {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: 0.1px;
}

.overview-card p,
.panel-subtitle,
.rangeMeta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.card-head {
  align-items: flex-start;
}

/* ===== 摘要列表 ===== */
.signal-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.signal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #f3f7fb 100%);
  border: 1px solid #eef2f7;
}

.signal-row strong {
  color: #0f172a;
  font-weight: 900;
}

.signal-row .small,
.signal-row span {
  color: #64748b;
}

/* ===== KPI ===== */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.data-card {
  position: relative;
  padding: 16px;
  min-height: 112px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
  box-shadow:
    0 10px 26px rgba(15, 23, 42, 0.035),
    0 2px 8px rgba(15, 23, 42, 0.025);
}

.data-card .label {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.data-card .value {
  margin-top: 9px;
  font-size: 1.5rem;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.15;
}

.data-card .subtext {
  margin-top: 6px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
}

.kpi-badge {
  position: absolute;
  top: 14px;
  right: 14px;
}

/* ===== 上方圖表區 ===== */
.layout-top {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.chartBox {
  height: 260px;
  min-width: 0;
}

.chartBox canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.panel .panel-head {
  margin-bottom: 2px;
}

/* ===== 即時趨勢 ===== */
.trendSectionHeader {
  align-items: flex-end;
}

#quickRangeBar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rangeLabel {
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
}

#timeRangeSelect,
#statusFilter,
#sortFilter,
#searchInput {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

#searchInput {
  min-width: 220px;
}

#btnDownloadAllTrends {
  padding: 9px 13px;
  border-radius: 11px;
  border: 1px solid #cfe6f7;
  background: #f0f9ff;
  color: #0369a1;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: 0.18s ease;
}

#btnDownloadAllTrends:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

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

.miniCard {
  padding: 13px;
  min-height: 324px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.03),
    0 2px 8px rgba(15, 23, 42, 0.02);
  display: flex;
  flex-direction: column;
}

.mini {
  flex: 1;
  min-height: 260px;
}

/* ===== 下方主區 ===== */
.layout-bottom {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-top: 26px;
}

.lights-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.lights-panel .panel-head {
  margin-bottom: 4px;
}


.lights-panel #lightsGrid {
  flex: 1;
  min-height: 0;
  max-height: min(1400px, calc(150vh - 100px));
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.lights-panel #lightsGrid::-webkit-scrollbar,
.alerts-list::-webkit-scrollbar {
  width: 10px;
}

.lights-panel #lightsGrid::-webkit-scrollbar-thumb,
.alerts-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
}

.lights-panel #lightsGrid::-webkit-scrollbar-track,
.alerts-list::-webkit-scrollbar-track {
  background: transparent;
}

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

.light-card {
  padding: 13px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow:
    0 8px 22px rgba(15, 23, 42, 0.03),
    0 2px 7px rgba(15, 23, 42, 0.02);
}

.light-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.metric-box {
  padding: 8px 9px;
  border-radius: 11px;
  background: linear-gradient(180deg, #f8fafc 0%, #f3f7fb 100%);
  border: 1px solid #edf2f7;
}

.metric-box .small {
  display: block;
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 4px;
}

.light-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eef2f7;
  color: #64748b;
  font-size: 12px;
}

.sticky-rail {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.alerts-list {
  max-height: min(720px, calc(100vh - 260px));
  overflow-y: auto;
}

.alert-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #e8eef5;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  text-decoration: none;
  color: inherit;
  transition: 0.18s ease;
}

.alert-link:hover {
  border-color: #7dd3fc;
  box-shadow: 0 12px 24px rgba(14, 165, 233, 0.08);
}

.empty-state {
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #f3f7fb 100%);
  border: 1px dashed #d9e2ec;
}

/* ===== Hero / 特殊按鈕細修 ===== */
.btn-warn {
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.08);
}

.hero-actions a,
.hero-actions button,
.topbar-actions a,
.topbar-actions button {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

/* ===== RWD ===== */
@media (max-width: 1180px) {
  .hero-grid,
  .layout-top,
  .layout-bottom {
    grid-template-columns: 1fr;
  }

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

  .sticky-rail {
    position: static;
    height: auto;
  }

  .lights-panel {
    height: auto;
  }

  .lights-panel #lightsGrid,
  .alerts-list {
    max-height: 520px;
    flex: none;
  }
}

@media (max-width: 900px) {
  .lights-grid,
  .miniCharts {
    grid-template-columns: 1fr;
  }

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

  #searchInput {
    min-width: 0;
    width: 100%;
  }

  .lights-panel #lightsGrid,
  .alerts-list {
    max-height: 420px;
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding: 12px;
  }

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

  .data-card {
    min-height: auto;
  }

  .kpi-badge {
    position: static;
    margin-bottom: 8px;
  }

  .hero-card {
    padding: 18px;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .lights-panel #lightsGrid,
  .alerts-list {
    max-height: 360px;
  }
}