:root {
  color-scheme: dark;
  --bg: #070b14;
  --text: #e7f3ff;
  --muted: #8eabc4;
  --line: rgba(110, 190, 220, 0.24);
  --panel: rgba(10, 18, 34, 0.88);
  --green: #3dffb0;
  --amber: #ffc857;
  --pink: #ff6b8a;
  --cyan: #67e8ff;
  font-family: "WenQuanYi Micro Hei", "Droid Sans Fallback", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--text);
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(40, 140, 180, 0.18), transparent 60%),
    radial-gradient(700px 380px at 110% 0%, rgba(180, 60, 120, 0.12), transparent 55%),
    var(--bg);
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #7ee8ff; outline-offset: 2px; }

body[data-lighting="day"] {
  background:
    radial-gradient(900px 420px at 80% -20%, rgba(120, 190, 230, 0.2), transparent 60%),
    #0c1724;
}
body[data-lighting="evening"] {
  background:
    radial-gradient(800px 380px at 0% 0%, rgba(180, 90, 40, 0.2), transparent 55%),
    #120e18;
}

.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px 12px 12px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}
.kpis { display: flex; gap: 8px; }
.kpi {
  min-width: 74px;
  padding: 6px 10px 7px;
  border-radius: 12px;
  background: rgba(6, 12, 24, 0.72);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.kpi b {
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-family: "DejaVu Sans Mono", "WenQuanYi Micro Hei Mono", ui-monospace, monospace;
}
.kpi span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.kpi.working b { color: var(--green); }
.kpi.idle b { color: var(--amber); }
.kpi.blocked b { color: var(--pink); }
.kpi.output b { color: var(--cyan); }
.brand { min-width: 0; text-align: center; }
.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 18px rgba(90, 220, 255, 0.28);
}
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.clock-block { text-align: right; min-width: 168px; }
.clock {
  font-size: 28px;
  line-height: 1;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
  font-family: "DejaVu Sans Mono", ui-monospace, monospace;
  text-shadow: 0 0 12px rgba(80, 220, 255, 0.35);
}
.date-line { margin-top: 4px; color: var(--muted); font-size: 12px; }
.ghost {
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 12px;
}
.ghost:hover { color: var(--text); }

.ticker {
  height: 32px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(6, 14, 26, 0.8);
  display: flex;
  align-items: center;
  mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}
.ticker-track {
  display: flex;
  gap: 28px;
  width: max-content;
  animation: marquee linear infinite;
}
.tick { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; white-space: nowrap; }
.tick em { color: var(--cyan); font-style: normal; }
.tick b { font-weight: 650; }
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
}

.banner {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(120, 40, 50, 0.35);
  color: #ffd0d8;
  font-size: 13px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 332px;
  grid-template-rows: minmax(0, 1fr) 196px;
  gap: 10px;
}
.office-panel { grid-column: 1; grid-row: 1; position: relative; overflow: hidden; }
.side {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.bottom {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 10px;
}

.panel {
  background: linear-gradient(180deg, rgba(14, 24, 42, 0.94), rgba(8, 14, 28, 0.92));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 30px rgba(0, 0, 0, 0.28);
  min-height: 0;
}
.padded { padding: 10px 12px; display: flex; flex-direction: column; }
.panel header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.panel h2 { margin: 0; font-size: 14px; letter-spacing: 0.06em; }
.panel header span, .panel header .live, .panel header .poll { color: var(--muted); font-size: 12px; }
.live { color: var(--green) !important; }
.poll { color: var(--amber) !important; }
.scroll { overflow: auto; min-height: 0; }
.scroll::-webkit-scrollbar, .cards::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb, .cards::-webkit-scrollbar-thumb { background: rgba(90, 170, 210, 0.35); border-radius: 99px; }

.team-panel, .log-panel { flex: 1; }
.output-panel { flex: 0 0 auto; }
.team-row {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: inset 2px 0 0 var(--id, transparent);
}
.team-row:hover, .team-row.active { background: rgba(80, 180, 220, 0.1); }
.team-row.disconnected { opacity: 0.55; }
.who { min-width: 0; display: flex; flex-direction: column; }
.name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role, .empty { color: var(--muted); font-size: 11px; }
.status { color: var(--c); font-size: 12px; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--c, #888);
  box-shadow: 0 0 8px var(--c, transparent);
}
.log-row, .result {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 12px;
}
.log-row time, .result em { color: var(--cyan); font-style: normal; }
.log-row span, .result span { color: #d5e7f6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.out {
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(6, 14, 28, 0.65);
  border: 1px solid rgba(100, 170, 210, 0.16);
}
.out b {
  display: block;
  font-size: 20px;
  line-height: 1;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}
.out span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.3; }

.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; min-height: 0; flex: 1; }
.column { min-height: 0; display: flex; flex-direction: column; }
.col-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; color: var(--muted); }
.col-head b { color: var(--text); font-weight: 650; }
.cards { overflow: auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.card {
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(8, 16, 30, 0.72);
  border: 1px solid rgba(100, 170, 210, 0.14);
}
.card-title {
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; color: var(--muted); font-size: 11px; }
.badge { font-style: normal; border-radius: 99px; padding: 0 6px; }
.badge.bad { color: #ffd0d8; background: rgba(180, 40, 70, 0.35); }
.badge.wait { color: #ffe6b0; background: rgba(160, 110, 20, 0.35); }

.stage, .labels { position: absolute; inset: 0; }
.labels { pointer-events: none; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hud { position: absolute; z-index: 3; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.hud.tl { top: 10px; left: 10px; flex-direction: row; gap: 6px; }
.hud.bl { left: 10px; bottom: 12px; font-size: 12px; color: #d5e8f6; }
.chip, .hud.bl div {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(5, 10, 20, 0.62);
  border: 1px solid rgba(120, 190, 220, 0.2);
}
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.wait { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.dot.pause { background: var(--pink); box-shadow: 0 0 8px var(--pink); }
.dot.off { background: #66788c; }
.lighting {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(5, 10, 20, 0.72);
  border: 1px solid rgba(120, 190, 220, 0.28);
}
.lighting button {
  border: 0;
  background: transparent;
  color: #c5d7e6;
  border-radius: 999px;
  padding: 6px 14px;
}
.lighting button[aria-pressed="true"] {
  background: rgba(70, 200, 230, 0.2);
  color: #f3fcff;
  box-shadow: inset 0 0 0 1px rgba(140, 230, 255, 0.5);
}
.detail {
  position: absolute;
  z-index: 3;
  top: 10px;
  right: 10px;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(5, 10, 20, 0.7);
  border: 1px solid rgba(120, 190, 220, 0.24);
}
.detail .eye { color: var(--cyan); font-size: 11px; }
.detail strong { display: block; margin-top: 2px; }
.detail p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.alabel, .rlabel {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.rlabel {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #d7f4ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(8, 12, 20, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  white-space: nowrap;
}
.pill i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.bubble {
  max-width: 168px;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(8, 14, 24, 0.88);
  border: 1px solid rgba(140, 210, 240, 0.28);
  font-size: 11px;
  white-space: nowrap;
}
.bubble.working { border-color: rgba(80, 255, 190, 0.45); }
.bubble.idle { border-color: rgba(255, 200, 80, 0.5); }
.bubble.blocked { border-color: rgba(255, 100, 130, 0.55); }
.alabel.dim { opacity: 0.82; transform: translate(-50%, -55%); }

.login-body {
  display: grid;
  place-items: center;
  overflow: auto;
}
.login-card {
  width: min(420px, calc(100% - 32px));
  padding: 28px 26px 24px;
  border-radius: 18px;
  background: rgba(10, 18, 32, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.login-card h1 { margin: 8px 0 4px; font-size: 22px; letter-spacing: 0.04em; }
.login-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(4, 10, 18, 0.8);
}
.login-card button[type="submit"] {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #1ec8e8, #1394c4);
  color: #041018;
  font-weight: 700;
}
.login-card button[disabled] { opacity: 0.7; }
.form-error { color: #ffb4c2; }
.logo { display: flex; justify-content: center; }

@media (max-width: 1100px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100%; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: 560px auto auto; }
  .office-panel { min-height: 560px; }
  .side, .bottom { grid-column: 1; grid-row: auto; }
  .side { display: grid; grid-template-columns: 1fr 1fr; }
  .output-panel { grid-column: 1 / -1; }
}
