/* ===== Shared dashboard UI ===== */

:root {
  --ui-card-radius: 16px;
  --ui-pill-radius: 999px;
  --ui-card-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  --ui-gap-sm: 12px;
  --ui-gap-md: 16px;
  --ui-gap-lg: 20px;
}

/* ===== Shared layout helpers ===== */
.page-header,
.toolbar,
.panel-head,
.light-head,
.filter-row,
.hero-actions,
.trendSectionHeader,
.card-head,
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== Shared cards ===== */
.card,
.panel,
.overview-card,
.data-card,
.light-card,
.miniCard,
.hero-card {
  border-radius: var(--ui-card-radius);
  border: 1px solid var(--border);
  background: var(--card);
}

.card {
  padding: 18px;
  box-shadow: var(--ui-card-shadow);
}

.panel,
.overview-card {
  padding: 16px;
}

.hero-card {
  padding: 18px 20px;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 62%);
  border-color: #dbeafe;
  box-shadow: 0 16px 40px rgba(14, 165, 233, 0.08);
}

/* ===== Shared segmented controls ===== */
.seg {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: var(--ui-pill-radius);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.seg a,
.seg button {
  padding: 8px 14px;
  border-radius: var(--ui-pill-radius);
  font-weight: 900;
  font-size: 13px;
  color: #475569;
  border: 0;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.seg a.active,
.seg button.active {
  background: #0ea5e9;
  color: #fff;
}

.seg-control {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: var(--ui-pill-radius);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.seg-control a {
  padding: 8px 16px;
  border-radius: var(--ui-pill-radius);
  font-weight: 900;
  font-size: 14px;
  color: #334155;
  text-decoration: none;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.seg-control a:hover {
  background: rgba(14, 165, 233, 0.08);
}

.seg-control a.active {
  background: #e0f2fe;
  color: #0284c7;
  box-shadow: inset 0 0 0 1px rgba(2, 132, 199, 0.15);
}

/* ===== Shared tabs ===== */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tabBtn {
  padding: 8px 14px;
  border-radius: var(--ui-pill-radius);
  font-weight: 900;
  font-size: 13px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
}

.tabBtn.active {
  background: #0ea5e9;
  color: #fff;
  border-color: transparent;
}

/* ===== Shared badges ===== */
.kpi-badge,
.metric-badge,
.status-badge,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--ui-pill-radius);
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
}

.kpi-badge,
.metric-badge,
.status-badge {
  border: 1px solid var(--border);
}

.ok {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.22);
}

.warn {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.22);
}

.down {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.22);
}

.none {
  background: rgba(148, 163, 184, 0.12);
  color: #64748b;
  border-color: rgba(148, 163, 184, 0.22);
}

/* ===== Shared buttons ===== */
.btn,
.miniLinkBtn {
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 900;
  font-size: 13px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.miniLinkBtn {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--card);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.miniLinkBtn:hover,
.btn:hover {
  border-color: rgba(14, 165, 233, 0.35);
}

/* ===== Shared special button ===== */
.btn-warn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--ui-pill-radius);
  font-size: 12px;
  font-weight: 800;
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-warn:hover {
  background: #f59e0b;
  color: #fff;
}

/* ===== Shared protocol pills ===== */
.protoPills {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: var(--ui-pill-radius);
  background: #f1f5f9;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.protoPills button {
  padding: 8px 12px;
  border-radius: var(--ui-pill-radius);
  border: 0;
  font-weight: 900;
  font-size: 13px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.protoPills button.active {
  background: #0ea5e9;
  color: #fff;
}

/* ===== Shared hover / dirty ===== */
.device-card {
  transition: all 0.2s ease;
}

.device-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.device-card.dirty {
  outline: 2px solid rgba(234, 179, 8, 0.65);
  box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.14);
}

/* ===== Shared utility ===== */
.empty-state {
  text-align: center;
  color: #94a3b8;
  padding: 28px;
}

.logBox {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: #020617;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.55;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ===== Button System ===== */
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-warn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 40px;
  padding: 10px 16px;

  border-radius: 12px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* 主要按鈕：首頁 Hero / 主要操作 */
.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #ffffff !important;
  border: 1px solid rgba(2, 132, 199, 0.6);
  box-shadow:
    0 8px 20px rgba(14, 165, 233, 0.22),
    0 2px 8px rgba(15, 23, 42, 0.06);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow:
    0 12px 26px rgba(14, 165, 233, 0.28),
    0 4px 10px rgba(15, 23, 42, 0.08);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow:
    0 5px 12px rgba(14, 165, 233, 0.16);
}

/* 次要按鈕：柔和填色 */
.btn-secondary {
  background: #e0f2fe;
  color: #0284c7 !important;
  border: 1px solid #bae6fd;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.06);
}

.btn-secondary:hover {
  background: #bae6fd;
  border-color: #7dd3fc;
}

/* 描邊按鈕：工具頁 / 次操作 */
.btn-outline {
  background: #ffffff;
  color: #334155 !important;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.btn-outline:hover {
  border-color: #7dd3fc;
  color: #0369a1 !important;
  background: #f8fbff;
}

/* 警示按鈕：保留你原本風格，但跟整體一致 */
.btn-warn {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b !important;
  border: 1px solid rgba(245, 158, 11, 0.3);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.08);
}

.btn-warn:hover {
  background: #f59e0b;
  color: #ffffff !important;
}

/* 小尺寸 */
.btn-sm {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 10px;
}

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


.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.title-block h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 900;
}

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

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


/* ===== Shared mobile ===== */
@media (max-width: 900px) {
  .page-header,
  .topbar-actions,
  .trendSectionHeader,
  .top {
    align-items: flex-start;
  }

  .seg {
    width: 100%;
  }

  .seg a,
  .seg button {
    flex: 1 1 auto;
    text-align: center;
  }
}

@media (max-width: 600px) {
  .seg,
  .protoPills {
    border-radius: 14px;
  }

  .seg a,
  .protoPills button {
    flex: 1;
    text-align: center;
    min-width: 0;
  }
}