:root {
  --bg: #030708;
  --panel: #071013;
  --panel2: #0a1519;
  --line: #24414a;
  --line-strong: #3d7180;
  --text: #c9d9dc;
  --muted: #6f8b91;
  --cyan: #52d9e8;
  --green: #52e09d;
  --yellow: #f0c45b;
  --red: #ff6979;
  --blue: #6ba1ff;
  --mono: "Cascadia Mono", "D2Coding", Consolas, "Malgun Gothic", monospace;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
}

button, input { font: inherit; }

.shell {
  position: relative;
  display: grid;
  grid-template-rows: 38px 100px 39px minmax(0, 1fr) 24px;
  width: 100%;
  max-width: 1920px;
  height: 100dvh;
  margin: 0 auto;
  padding: 7px 10px;
  border: 1px solid #152a30;
  background: #03080a;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px,1fr) auto auto;
  gap: 14px;
  align-items: center;
  min-width: 0;
  border-bottom: 1px solid var(--line-strong);
}

.console-brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; white-space: nowrap; }
.console-brand b { color: #061013; background: var(--cyan); padding: 3px 7px; font-size: 12px; }
.console-brand span, .eyebrow { color: var(--muted); font-size: 9px; letter-spacing: 1.5px; }
.eyebrow { margin: 0 0 4px; color: var(--cyan); }

.live { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 9px; white-space: nowrap; }
.live i { width: 7px; height: 7px; background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.live.connected i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.live.failed i { background: var(--red); box-shadow: 0 0 8px var(--red); }
.live time { color: var(--text); }

.overview-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 7px;
  min-width: 0;
  padding: 7px 0;
}

.status-card {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  grid-template-areas: "label total" "normal error" "hint hint";
  gap: 4px 8px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #071216;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.status-card:hover, .status-card:focus-visible { border-color: var(--cyan); outline: 0; }
.status-card > .card-label { grid-area: label; align-self: center; overflow: hidden; color: #94b1b7; font-size: 10px; font-weight: 700; letter-spacing: .5px; text-overflow: ellipsis; white-space: nowrap; }
.status-card > strong { grid-area: total; color: var(--cyan); font-size: 23px; line-height: 1; }
.card-count { min-width: 0; padding: 4px 6px; border: 1px solid; border-radius: 2px; font-size: 9px; white-space: nowrap; }
.card-count b { float: right; margin-left: 6px; font-size: 11px; }
.card-count.normal { grid-area: normal; border-color: #215c45; background: #0c251c; color: var(--green); }
.status-card:not(.has-error) .card-count.normal { grid-column: 1 / -1; }
.card-count.error { grid-area: error; display: flex; align-items: center; justify-content: space-between; min-width: 76px; border-color: #9e3e4c; background: #3a1118; color: var(--red); font-weight: 800; }
.card-count.error b { float: none; margin-left: 10px; font-size: 22px; line-height: .85; }
.card-count.error[hidden] { display: none; }
.status-card > small { grid-area: hint; overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }

.monitor-tabs {
  display: flex;
  gap: 5px;
  align-items: end;
  min-width: 0;
  border-bottom: 1px solid var(--line-strong);
}
.monitor-tab {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #050c0f;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}
.monitor-tab:hover { color: var(--cyan); }
.monitor-tab.active { border-color: var(--line-strong); background: var(--panel2); color: var(--cyan); }
.error-badge { min-width: 22px; padding: 2px 6px; border-radius: 9px; background: var(--red); color: #170307; font-size: 8px; text-align: center; }
.error-badge.clear { background: #225b45; color: var(--green); }

.tab-stage, .tab-panel { min-width: 0; min-height: 0; }
.tab-panel { width: 100%; height: 100%; }
.tab-panel[hidden] { display: none; }
.collector-panel { display: grid; grid-template-rows: 39px 31px minmax(0,1fr); }
.legacy-panel { display: grid; grid-template-rows: 35px 24px minmax(0,1fr); border: 1px solid var(--line); border-top: 0; background: var(--panel); }
.dual-list-panel { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; padding-top: 6px; }
.dual-list-panel .legacy-panel { min-width: 0; min-height: 0; border-top: 1px solid var(--line); }
.items-panel { border-top: 0; }

.console-controls {
  display: grid;
  grid-template-columns: auto minmax(200px,1fr) auto minmax(190px,310px) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  border-bottom: 1px solid var(--line);
}
.prompt { color: var(--cyan); font-size: 9px; font-weight: 700; }
.node-overview { display: flex; gap: 4px; min-width: 0; overflow: hidden; }
.node-button, .page-button {
  min-width: 0;
  border: 1px solid var(--line);
  background: #050c0f;
  color: var(--muted);
  cursor: pointer;
  font-size: 8px;
}
.node-button { overflow: hidden; padding: 4px 6px; text-overflow: ellipsis; white-space: nowrap; }
.node-button b { color: var(--cyan); }
.node-button .node-isp { color: var(--blue); font-weight: 700; }
.node-button.active { border-color: var(--cyan); background: #0b1d22; color: var(--text); }
.node-button.problem { border-color: #826d32; color: var(--yellow); }
.node-button.stale { border-color: #7e3540; color: var(--red); }
.page-button { padding: 3px 6px; color: var(--cyan); white-space: nowrap; }
.page-button:hover, .node-button:hover { border-color: var(--cyan); }

.search { display: flex; align-items: center; height: 26px; border: 1px solid var(--line); background: #040b0d; color: var(--cyan); font-size: 8px; }
.search span { padding-left: 6px; }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); padding: 5px 6px; font-size: 9px; }
.search:focus-within { border-color: var(--cyan); }
.toggle { display: flex; gap: 5px; align-items: center; color: var(--muted); font-size: 8px; white-space: nowrap; }
.toggle input { accent-color: var(--cyan); }

.node-detail {
  display: flex;
  gap: 13px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  padding: 0 8px;
  border-bottom: 1px solid var(--line-strong);
  background: #071216;
  font-size: 9px;
  white-space: nowrap;
}
.node-detail span { overflow: hidden; text-overflow: ellipsis; }
.node-detail .node-code { color: #041012; background: var(--cyan); padding: 3px 6px; font-weight: 800; }
.node-detail b { color: var(--text); }
.node-detail .healthy { color: var(--green); }
.node-detail .warning { color: var(--yellow); }
.node-detail .critical { color: var(--red); }
.skeleton { color: var(--muted); }

.console-pane { min-width: 0; min-height: 0; border: 1px solid var(--line); background: var(--panel); }
.worker-pane { display: grid; grid-template-rows: 23px 22px minmax(0,1fr) auto 23px; }
.console-rule, .list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  color: var(--cyan);
  background: #08171b;
  font-size: 9px;
}
.console-rule i, .list-toolbar i { overflow: hidden; color: var(--muted); font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.list-toolbar b { color: var(--text); font-size: 8px; font-weight: 600; }

.worker-row {
  display: grid;
  grid-template-columns: minmax(145px,1.45fr) 82px 58px 48px 54px 62px 62px 65px 40px 38px minmax(145px,1.8fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
  height: 24px;
  padding: 0 7px;
  border-bottom: 1px solid #13282e;
  color: var(--muted);
  font-size: 8px;
}
.worker-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.worker-row > span:nth-child(n+3):nth-child(-n+10) { text-align: right; }
.worker-table-head { height: 22px; color: #83a8af; background: #050c0f; font-size: 7px; letter-spacing: .5px; }
.worker-table-body { min-height: 0; overflow: hidden; }
.worker-table-body .worker-row { position: relative; cursor: pointer; }
.worker-table-body .worker-row:hover, .worker-table-body .worker-row.selected { background: #0d2228; color: var(--text); }
.worker-table-body .worker-row.selected::before { content: ">"; position: absolute; left: 1px; color: var(--yellow); }
.worker-row .worker-id { color: var(--text); }
.worker-row .worker-id small { color: var(--muted); }
.worker-row .state { font-weight: 700; }
.worker-row.running .state { color: var(--green); }
.worker-row.problem .state { color: var(--red); }
.worker-row.waiting .state { color: var(--yellow); }
.worker-row.off .state { color: #60767b; }
.worker-row.problem { background: rgba(70, 18, 25, .24); }
.worker-row .error-count { color: var(--red); }
.worker-detail { overflow: hidden; padding: 4px 7px; border-top: 1px solid var(--line-strong); color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.worker-detail b { color: var(--cyan); }
.console-empty { display: grid; place-items: center; min-height: 24px; color: var(--muted); font-size: 9px; }

.console-footer { display: flex; justify-content: space-between; align-items: center; min-width: 0; padding: 0 7px; overflow: hidden; background: var(--cyan); color: #041013; font-size: 8px; font-weight: 800; white-space: nowrap; }
.node-tabs { overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--muted); }
.healthy { color: var(--green); }
.warning { color: var(--yellow); }
.critical { color: var(--red); }

@media (max-width: 1100px) {
  .worker-row { grid-template-columns: minmax(130px,1.4fr) 76px 50px 50px 58px 58px 58px 36px 34px minmax(110px,1fr); }
  .worker-row > span:nth-child(4) { display: none; }
  .topbar { grid-template-columns: minmax(245px,1fr) auto auto; gap: 8px; }
  .console-brand span, #wakeState { display: none; }
  .status-card { padding: 7px 8px; }
}

@media (max-width: 850px) {
  .shell { padding: 5px 6px; }
  .topbar { grid-template-columns: minmax(220px,1fr) auto; }
  .live { display: none; }
  .status-card > .card-label { font-size: 8px; }
  .status-card > strong { font-size: 19px; }
  .console-controls { grid-template-columns: auto minmax(130px,1fr) auto minmax(145px,220px) auto; gap: 4px; }
  .worker-row { grid-template-columns: minmax(125px,1.5fr) 72px 58px 58px 58px 34px 32px; }
  .worker-row > span:nth-child(3), .worker-row > span:nth-child(4), .worker-row > span:nth-child(5), .worker-row > span:nth-child(11) { display: none; }
  .account a:not(.diagnostic-download) { display: none; }
}

@media (max-width: 650px) {
  .shell { grid-template-rows: 34px 132px 37px minmax(0,1fr) 23px; }
  .console-brand b { font-size: 10px; }
  .overview-cards { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; padding: 4px 0; }
  .status-card { padding: 5px 7px; gap: 2px 5px; }
  .status-card > strong { font-size: 16px; }
  .card-count { padding: 2px 4px; font-size: 8px; }
  .card-count b { font-size: 9px; }
  .card-count.error { min-width: 60px; }
  .card-count.error b { margin-left: 6px; font-size: 17px; }
  .status-card > small { display: none; }
  .monitor-tab { flex: 1; justify-content: center; gap: 5px; padding: 0 5px; font-size: 8px; }
  .dual-list-panel { grid-template-columns: 1fr; grid-template-rows: repeat(2,minmax(0,1fr)); gap: 4px; padding-top: 4px; }
  .collector-panel { grid-template-rows: 37px 29px minmax(0,1fr); }
  .console-controls { grid-template-columns: auto minmax(100px,1fr) auto; }
  .search, .toggle { display: none; }
  .worker-row { grid-template-columns: minmax(115px,1.4fr) 68px 52px 52px 48px 31px 29px; gap: 3px; padding: 0 4px; font-size: 7px; }
  .account a, .account button { padding: 0 5px; font-size: 8px; }
}

@media (max-height: 700px) {
  .shell { grid-template-rows: 31px 78px 34px minmax(0,1fr) 21px; padding-top: 4px; padding-bottom: 4px; }
  .overview-cards { padding: 4px 0; gap: 4px; }
  .status-card { padding: 5px 7px; gap: 2px 5px; }
  .status-card > strong { font-size: 17px; }
  .status-card > small { display: none; }
  .card-count { padding: 2px 4px; }
  .card-count.error b { font-size: 17px; }
  .monitor-tab { height: 28px; }
  .collector-panel { grid-template-rows: 33px 26px minmax(0,1fr); }
  .worker-row { height: 21px; }
  .worker-table-head { height: 20px; }
  .worker-pane { grid-template-rows: 21px 20px minmax(0,1fr) auto 20px; }
  .console-rule { font-size: 8px; }
}
