﻿:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dfe5ef;
  --text: #1a2233;
  --muted: #6b7384;
  --primary: #2557d6;
  --primary-2: #143fb3;
  --primary-soft: #eaf0ff;
  --success: #0e8f61;
  --warn: #b7791f;
  --danger: #c53030;
  --shadow: 0 12px 30px rgba(18, 38, 63, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: linear-gradient(120deg, var(--primary-2) 0%, var(--primary) 60%, #5a86ff 100%);
  color: #fff;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.brand h1 .sub {
  font-weight: 400;
  font-size: 13px;
  opacity: 0.75;
  margin-left: 4px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cc4444;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12);
  transition: background 0.2s;
}

.dot[data-state="connecting"] { background: #f0b400; }
.dot[data-state="on"]         { background: #2cd07e; }
.dot[data-state="error"]      { background: #ff6868; }

.meta {
  display: flex;
  gap: 18px;
  font-size: 13px;
}

.kv { display: inline-flex; align-items: center; gap: 6px; }
.kv .k { opacity: 0.7; }
.kv .v { font-variant-numeric: tabular-nums; font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 18px;
  padding: 18px 24px 24px;
  align-items: start;
}

.panel, .stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel section + section { margin-top: 20px; }
.panel h2, .stageHead { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.panel h2 { text-align: left; }

.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row.buttons { margin-top: 8px; }
.row label { width: 56px; color: var(--muted); font-size: 13px; }
.row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

button {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}
button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
button.primary:hover:not(:disabled) { background: var(--primary-2); color: #fff; }
button.ghost { background: #fff; }
button.danger { background: #fff; color: #c0392b; border-color: #e5b8b2; }
button.danger:hover:not(:disabled) { background: #c0392b; color: #fff; border-color: #c0392b; }

.appList {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.appList li {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  transition: all 0.15s;
}
.appList li:hover { border-color: var(--primary); }
.appList li.active { border-color: var(--primary); background: var(--primary-soft); }
.appList li b { font-size: 12px; }
.appList li span { color: var(--muted); font-size: 11px; }
.appList li a.openLink { align-self: flex-end; font-size: 11px; }
.appList li.muted { color: var(--muted); border: none; padding: 4px 0; grid-column: span 2; }

.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.kvList { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 13px; }
.kvList li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kvList li:last-child { border-bottom: none; }
.kvList li span { color: var(--muted); }
.kvList li b { font-weight: 600; font-variant-numeric: tabular-nums; }
.kvList .bad { color: var(--danger); }

.stage { padding: 14px; }
.stageHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 10px;
  text-transform: none;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--text);
}
.stageHeadRight {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stageHeadRight button {
  padding: 4px 12px;
  font-size: 12px;
}
.screenBox {
  position: relative;
  background: #0a1224;
  border-radius: 12px;
  padding: 8px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 480px;
}
.screenBox:fullscreen {
  background: #000;
  border-radius: 0;
  padding: 0;
  min-height: 0;
}
.screenBox:fullscreen canvas {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  border-radius: 0;
}
.screenBox canvas {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  background: #1f4fb3;
  outline: none;
  image-rendering: auto;
  cursor: default;
}
.overlay {
  position: absolute;
  inset: 8px;
  background: rgba(10, 18, 36, 0.78);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 6px;
  color: #fff;
  text-align: center;
  padding: 24px;
}
.overlay.hidden { display: none; }
.overlayInner h3 { margin: 0 0 8px; font-size: 18px; }
.overlayInner p { margin: 4px 0; color: rgba(255,255,255,0.85); }
.overlayInner .muted { color: rgba(255,255,255,0.5); font-size: 12px; }

.log { display: flex; flex-direction: column; }
.log ol {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-height: 360px;
  overflow-y: auto;
  background: #0f172a;
  color: #dbeafe;
  border-radius: 8px;
  padding: 8px;
}
.log li {
  padding: 2px 0;
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 6px;
  border-bottom: 1px dashed rgba(255,255,255,0.08);
}
.log li:last-child { border-bottom: none; }
.log li time { color: #6e85b8; }
.log li.err  { color: #ff8a8a; }
.log li.ok   { color: #98e8b7; }

.footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 18px;
}

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