:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-soft: #e0f2fe;
  --cr-accent: #29b6f6;
  --cr-glow: rgba(41, 182, 246, 0.45);
  --ok-bg: #dcfce7;
  --ok-fg: #166534;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --warn-fg: #92400e;
  --danger-bg: #fee2e2;
  --danger-fg: #991b1b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* =========================================================
   雙層旗艦 Banner（深海藍黑頁首 + Cr 電光天藍主題）
   ========================================================= */
.topbar {
  background: linear-gradient(135deg, #07111e 0%, #0d2238 55%, #0c3147 100%);
  color: #f8fafc;
  border-bottom: 1px solid rgba(41, 182, 246, 0.22);
  padding: 16px 0;
}

.topbar-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
}

.banner-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.element-tile {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(41, 182, 246, 0.24), rgba(14, 165, 233, 0.12));
  border: 1.5px solid var(--cr-accent);
  box-shadow: 0 0 16px rgba(41, 182, 246, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  position: relative;
}

.el-num {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #7dd3fc;
}

.el-sym {
  font-size: 1.18rem;
  font-weight: 800;
  color: #ffffff;
  margin-top: 4px;
}

.el-name {
  font-size: 0.56rem;
  color: #bae6fd;
  letter-spacing: 0.02em;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.26rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.brand-text p {
  margin: 3px 0 0;
  font-size: 0.82rem;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 第二層：4 張毛玻璃 KPI 數據卡 + hao-element-badge */
.banner-row2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.banner-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-chip {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  min-width: 96px;
}

.stat-label {
  font-size: 0.68rem;
  color: #94a3b8;
}

.stat-val {
  font-size: 0.9rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.engine-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

.engine-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.85);
}

.engine-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.topbar-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* 右側動畫區（260px–320px）：ROAD · MRV SHORTEST PATH */
.banner-live-card {
  width: 300px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(145deg, #061325 0%, #0b223d 100%);
  border: 1px solid rgba(41, 182, 246, 0.34);
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 18px rgba(2, 132, 199, 0.16);
}

.live-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(41, 182, 246, 0.14);
  border: 1px solid rgba(41, 182, 246, 0.36);
  border-radius: 999px;
  padding: 2px 9px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cr-accent);
  box-shadow: 0 0 8px var(--cr-accent);
  animation: pulseDot 2s ease-in-out infinite;
}

.live-title {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #7dd3fc;
}

.live-road-svg {
  width: 100%;
  height: auto;
  display: block;
}

.shortest-glow {
  stroke-dasharray: 280;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 4px rgba(41, 182, 246, 0.85));
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

/* =========================================================
   純白頁籤列
   ========================================================= */
.tabs-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.tabs-inner {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-inner::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 13px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* =========================================================
   主體容器與卡片
   ========================================================= */
.main-content {
  padding: 22px 20px 44px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.card-header h2 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 700;
}

.sub-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* 淡天藍結果摘要卡 */
.summary-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: 18px 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.summary-metric {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(14, 165, 233, 0.22);
  border-radius: 10px;
  padding: 12px 14px;
}

.summary-metric .label {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.summary-metric .value {
  font-size: 1.32rem;
  font-weight: 800;
  color: #0369a1;
}

/* 表單與按鈕 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}

.field input,
.field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: #cbd5e1;
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-alt);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

/* Pills & Badges */
.pill-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-pill {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.badge-car {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-moto {
  background: #fef3c7;
  color: #92400e;
}

.badge-unit {
  background: #f1f5f9;
  color: #334155;
}

/* 表格 */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fafc;
}

.num-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

/* 截圖預覽 */
.screenshot-box {
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  background: #f8fafc;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.screenshot-box img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

/* 提示框 */
.notice {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 0.86rem;
  margin-bottom: 14px;
}

.notice-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.notice-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-fg);
}

.notice-danger {
  background: var(--danger-bg);
  border: 1px solid #fca5a5;
  color: var(--danger-fg);
}

.progress-wrap {
  margin-top: 12px;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--cr-accent) 100%);
  transition: width 0.25s ease;
}

.thumb-img {
  width: 120px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 無障礙降級與響應式 */
@media (prefers-reduced-motion: reduce) {
  .live-dot,
  .live-road-svg animateMotion,
  .live-road-svg animate {
    animation: none !important;
  }
  .live-road-svg .anim-vehicle {
    display: none;
  }
}

@media (max-width: 860px) {
  .banner-live-card {
    display: none;
  }
  .brand-text p {
    white-space: normal;
  }
}
