:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-raised: #f1f5f9;
  --line: #dbe3ec;
  --text: #17212b;
  --muted: #64748b;
  --faint: #94a3b8;
  --cyan: #087f73;
  --cyan-dim: #e7f7f3;
  --amber: #996000;
  --red: #b23e3e;
  --blue: #2867b2;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: "Aptos", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button { font: inherit; }

.shell { min-height: 100vh; background: var(--bg); }
.topbar, main, .footer { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.topbar { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #8bcfc5; color: var(--cyan); font: 700 12px var(--mono); letter-spacing: 0; }
.brand h1, h2, h3, p { margin: 0; }
.brand h1 { font-size: 16px; line-height: 1.2; font-weight: 650; letter-spacing: 0; }
.eyebrow { color: var(--cyan); font: 700 10px/1.3 var(--mono); letter-spacing: 0.08em; }
.topbar-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.status-chip { border: 1px solid var(--line); padding: 7px 10px; font-size: 12px; }
.status-ready { color: var(--cyan); border-color: #a5ddd4; background: var(--cyan-dim); }
.status-demo { color: var(--amber); border-color: #e4c47e; background: #fff5dd; }
.status-waiting { color: var(--amber); border-color: #e4c47e; background: #fff8e9; }
.status-error { color: var(--red); border-color: #e7b4b4; background: #fff0f0; }
.device-id { color: var(--muted); font: 12px var(--mono); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { padding: 38px 0 52px; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.hero-row h2 { margin-top: 5px; font-size: 34px; line-height: 1.08; letter-spacing: 0; }
.muted { margin-top: 9px; color: var(--muted); font-size: 13px; }
.hero-actions, .panel-actions, .log-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.button { border: 1px solid var(--line); padding: 9px 13px; border-radius: 3px; cursor: pointer; transition: border-color .15s, background .15s, color .15s; font-size: 12px; }
.button:hover, .command-button:hover, .text-button:hover { border-color: var(--cyan); }
.button:disabled, .command-button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { color: #ffffff; border-color: var(--cyan); background: var(--cyan); }
.button-primary:hover { background: #096d63; }
.button-secondary { color: var(--text); background: #eef3f7; }
.button-ghost { color: var(--muted); background: transparent; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.metric-card { min-width: 0; min-height: 112px; border: 1px solid var(--line); background: var(--panel); padding: 16px; box-shadow: 0 1px 2px rgba(23, 33, 43, .04); }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 14px; color: var(--cyan); font-size: 25px; font-weight: 650; line-height: 1; }
.metric-value-small { font-size: 18px; font-family: var(--mono); }
.metric-detail { margin-top: 10px; color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.panel { min-width: 0; border: 1px solid var(--line); background: var(--panel); padding: 18px; box-shadow: 0 1px 2px rgba(23, 33, 43, .04); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.panel-heading h3 { margin-top: 5px; font-size: 16px; font-weight: 650; }
.panel-index { color: var(--faint); font: 11px var(--mono); white-space: nowrap; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 22px; margin: 0; }
.detail-list div { min-width: 0; border-bottom: 1px solid #e8edf2; padding-bottom: 8px; }
.detail-list dt { color: var(--muted); font-size: 11px; }
.detail-list dd { margin: 5px 0 0; min-height: 17px; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px !important; }
.panel-actions { margin-top: 19px; }
.panel-note { margin-top: 17px; color: var(--faint); font-size: 11px; line-height: 1.5; }
.panel-params, .panel-logs { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e8edf2; text-align: left; }
th { color: var(--muted); background: var(--panel-raised); font-size: 11px; font-weight: 500; }
td:first-child { width: 33%; color: var(--blue); font-family: var(--mono); }
td:nth-child(2) { color: var(--text); word-break: break-word; }
td:last-child { color: var(--faint); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.empty-state { color: var(--faint) !important; text-align: center; font-family: inherit !important; }
.command-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.command-button { min-height: 62px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; border: 1px solid var(--line); background: #f6f8fb; color: var(--text); padding: 11px 13px; cursor: pointer; text-align: left; }
.command-button span { color: var(--faint); font: 10px var(--mono); }
.command-danger { color: var(--red); }
.text-button { border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--muted); padding: 0 0 2px; cursor: pointer; font-size: 11px; }
.log-window { height: 280px; overflow: auto; border: 1px solid var(--line); background: #f8fafc; padding: 9px 11px; font: 11px/1.6 var(--mono); }
.log-line { display: grid; grid-template-columns: 90px 58px minmax(0, 1fr); gap: 9px; padding: 2px 0; }
.log-time { color: var(--faint); }
.log-level { font-weight: 700; text-transform: uppercase; }
.log-level-info { color: var(--blue); }
.log-level-success { color: var(--cyan); }
.log-level-incoming { color: #bb9dff; }
.log-level-outgoing { color: var(--amber); }
.log-level-warn { color: var(--amber); }
.log-level-error { color: var(--red); }
.log-message { color: #334155; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.footer { display: flex; justify-content: space-between; gap: 16px; padding: 15px 0 22px; color: var(--faint); font: 10px var(--mono); }

@media (max-width: 860px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .panel-params, .panel-logs { grid-column: auto; }
}
@media (max-width: 560px) {
  .topbar, main, .footer { width: min(100% - 24px, 1240px); }
  .topbar { min-height: 74px; align-items: flex-start; padding-top: 17px; }
  .topbar-meta { align-items: flex-end; gap: 5px; }
  .device-id { max-width: 130px; font-size: 10px; }
  main { padding-top: 27px; }
  .hero-row { align-items: flex-start; flex-direction: column; margin-bottom: 22px; }
  .hero-row h2 { font-size: 27px; }
  .hero-actions { width: 100%; }
  .button { flex: 1; }
  .metric-card { min-height: 102px; padding: 13px; }
  .metric-value { margin-top: 11px; font-size: 21px; }
  .metric-value-small { font-size: 14px; }
  .panel { padding: 15px; }
  .detail-list { gap: 11px 13px; }
  .command-list { grid-template-columns: 1fr; }
  .log-line { grid-template-columns: 78px 49px minmax(0, 1fr); gap: 5px; }
  .footer { flex-direction: column; gap: 4px; }
}
