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

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

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

.top .small {
  font-size: 13px;
  color: var(--muted);
}

/* ===== 外層主卡 ===== */
.wrap > .card {
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  box-shadow:
    0 16px 36px rgba(15, 23, 42, 0.04),
    0 4px 14px rgba(15, 23, 42, 0.025);
}

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

.tabBtn {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* ===== 主版面 ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: stretch;
}

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

/* ===== 路燈 / 裝置區 ===== */
.lights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.edge-grid,
.service-grid {
  display: grid;
  gap: 12px;
}

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

.service-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ===== 內部卡片層次 ===== */
.card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow:
    0 10px 28px rgba(15, 23, 42, 0.035),
    0 2px 8px rgba(15, 23, 42, 0.02);
}

.device-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.device-card:hover {
  box-shadow:
    0 12px 26px rgba(15, 23, 42, 0.06),
    0 2px 10px rgba(15, 23, 42, 0.025);
}

/* ===== 控制列 ===== */
.control-panel-card {
  margin-bottom: 16px;
}

.control-bar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-bar-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 900;
  color: #0f172a;
}

.control-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.control-bar-actions > * {
  display: flex;
  align-items: center;
}

.control-bar-actions .small {
  display: flex;
  align-items: center;
  height: 36px;
  color: var(--muted);
}

.control-bar-actions .btn {
  height: 36px;
  padding: 0 14px;
}

.control-bar-actions .protoPills {
  height: auto;
  display: flex;
  align-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.control-bar-actions .protoPills button.active {
  box-shadow: 0 8px 18px rgba(14, 165, 233, 0.16);
}

.control-bar-actions .small strong {
  margin: 0 4px;
}

/* ===== 控制列與工具元件 ===== */
.btn {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.miniLinkBtn {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.025);
}

.miniLinkBtn:hover,
.btn:hover {
  box-shadow: 0 8px 18px rgba(14, 165, 233, 0.08);
}

/* ===== 通用 head row ===== */
.section-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 900;
  color: #0f172a;
}

.section-sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.link-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== Log 與細節 ===== */
.logBox {
  border: 1px solid rgba(148, 163, 184, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.reasonDetails {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.reasonDetails summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
  list-style: none;
}

.reasonDetails summary::-webkit-details-marker {
  display: none;
}

.reasonBody {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== status-badge ===== */
.status-badge.running {
  background: rgba(16, 185, 129, 0.12);
  color: #166534;
  border-color: rgba(16, 185, 129, 0.25);
}

.status-badge.error {
  background: rgba(239, 68, 68, 0.12);
  color: #991b1b;
  border-color: rgba(239, 68, 68, 0.25);
}

/* ===== 表單元件微調 ===== */
input[type="number"],
input[type="text"],
select {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.control-card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 900;
}

.control-card-sub {
  margin-top: 4px;
  color: #64748b;
}

/* ===== RWD ===== */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sticky {
    position: static;
  }
}

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

  .control-bar-row {
    align-items: flex-start;
  }

  .control-bar-actions {
    width: 100%;
    align-items: flex-start;
  }
}

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

  .top h2 {
    font-size: 1.5rem;
  }
}