:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e6edf3;
  --muted: #8b9cb3;
  --accent: #3d9dff;
  --ok: #3ecf8e;
  --bad: #f85149;
  --warn: #d4a72c;
  --purple: #a371f7;
}

* {
  box-sizing: border-box;
}
html {
  height: 100%;
}
body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  height: 100%;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

code,
pre,
.mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #15202b 0%, var(--bg) 100%);
  flex-shrink: 0;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 600;
}
.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 40rem;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

input[type="text"],
input[type="password"] {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  min-width: 12rem;
  font-size: 0.9rem;
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
button.primary {
  background: linear-gradient(180deg, #2563a8 0%, #1a4a7a 100%);
  border-color: #3d7dcc;
  color: #fff;
}
button.ghost {
  background: transparent;
}
button.btn-ws-tap {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  color: var(--accent);
  border-color: rgba(61, 157, 255, 0.4);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.on {
  background: rgba(62, 207, 142, 0.2);
  color: var(--ok);
}
.badge.off {
  background: rgba(248, 81, 73, 0.15);
  color: var(--bad);
}
.badge.st {
  background: rgba(212, 167, 44, 0.2);
  color: var(--warn);
}

/* 左侧 Tab 轨 + 主内容区（全宽贴左，不整体居中） */
.shell.shell-full {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  max-width: none;
  margin: 0;
  flex: 1;
  min-height: 0;
}

.main-col {
  flex: 1;
  min-width: 0;
  padding: 1rem 1.25rem 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.tabs-rail {
  width: 158px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #161d28 0%, var(--panel) 40%);
  padding: 1rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tabs-rail-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.tab-v {
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.tab-v:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tab-v.active {
  background: rgba(61, 157, 255, 0.14);
  border-color: rgba(61, 157, 255, 0.45);
  color: var(--accent);
  font-weight: 600;
}

.tabs-rail-hint {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
  text-align: left;
}

/* 系统配置 Tab */
.settings-page {
  max-width: 32rem;
  margin-top: 0.5rem;
}
.settings-config-path {
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
  margin: 0 0 1.25rem;
  padding: 0.6rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  line-height: 1.4;
}
.settings-field {
  margin-bottom: 1.1rem;
}
.settings-field-hint {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}
.settings-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.settings-check input {
  margin: 0;
  accent-color: var(--accent);
}
.settings-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.settings-input {
  width: 100%;
  max-width: 16rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
}
.settings-actions {
  margin-top: 1.25rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: var(--accent);
}
.tab-desc {
  margin: 0 0 0.75rem;
}

/* 当前可见 Tab 占满主列剩余高度；油企 Tab 由内层 workspace 自己分配滚动 */
.main-col > .tab-panel:not(.hidden) {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.main-col > .tab-panel.ent-tab:not(.hidden) {
  overflow: hidden;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-row label {
  color: var(--muted);
  font-size: 0.85rem;
}

/* 油企 Tab：左侧窄列表 + 右侧总览 + WS */
.tab-panel.ent-tab {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  border: none;
}
.ent-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}
.ent-picker {
  width: 272px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem 0.65rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ent-picker-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}
.filter-row-compact {
  margin-bottom: 0.5rem;
}
.filter-row-compact button {
  padding: 0.3rem 0.45rem;
  font-size: 0.78rem;
}
.ent-search {
  width: 100%;
  margin-bottom: 0.65rem;
  min-width: 0;
  font-size: 0.82rem;
  padding: 0.4rem 0.5rem;
}
.ent-list {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
}
.ent-pick-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.55rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.15);
  transition:
    background 0.12s,
    border-color 0.12s;
}
.ent-pick-item:hover {
  border-color: rgba(61, 157, 255, 0.35);
  background: rgba(61, 157, 255, 0.06);
}
.ent-pick-item.selected {
  border-color: rgba(61, 157, 255, 0.65);
  background: rgba(61, 157, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(61, 157, 255, 0.2);
}
.ent-pick-item .ent-name {
  font-weight: 600;
  font-size: 0.88rem;
  display: block;
  margin-top: 0.2rem;
}
.ent-pick-item .ent-no {
  color: var(--muted);
  font-size: 0.75rem;
}
.ent-pick-item .pick-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.ent-detail {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ent-overview {
  flex-shrink: 0;
  max-height: min(34vh, 280px);
  overflow: auto;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}
.ent-overview h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
}
.ent-overview .ov-badges {
  margin-bottom: 0.5rem;
}
.ent-tab-foot {
  margin: 0.65rem 0 0;
  padding: 0 0.25rem;
}

.ws-live-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.65rem 1rem 0.85rem;
}
.ws-live-panel-orphan {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  min-height: 200px;
}
.ws-live-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
}
.ws-live-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
}
.ws-live-cid {
  font-size: 0.78rem;
  color: var(--muted);
}
.ws-live-hint {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
}
/* 油企 Tab：WS 列表占满右侧剩余高度，仅框内滚动，避免整页出现纵向滚动条 */
#tab-ent .ws-live-panel {
  flex: 1 1 0;
  min-height: 0;
}
#tab-ent .ws-live-body {
  flex: 1 1 0;
  min-height: 200px;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  overscroll-behavior: contain;
}

/* 未绑定 Tab：无 flex 父链限制高度，用 max-height 把滚动限制在框内 */
#tab-orphan .ws-live-body {
  min-height: 180px;
  max-height: min(52vh, 560px);
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  overscroll-behavior: contain;
}
.ws-tap-filter {
  min-width: 8rem;
  max-width: 14rem;
  flex: 1 1 10rem;
  font-size: 0.78rem;
  padding: 0.28rem 0.45rem;
}
.ws-stop {
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  flex-shrink: 0;
}

.ws-dir-btn {
  font-size: 0.76rem;
  padding: 0.25rem 0.5rem;
  flex-shrink: 0;
  border-color: rgba(61, 157, 255, 0.25);
}
.ws-dir-btn:hover {
  border-color: rgba(61, 157, 255, 0.45);
}
.ws-dir-btn.active {
  background: rgba(61, 157, 255, 0.18);
  border-color: rgba(61, 157, 255, 0.55);
  color: var(--accent);
  font-weight: 600;
}
.ws-dir-btn[data-ws-dir="in"].active {
  background: rgba(163, 113, 247, 0.18);
  border-color: rgba(163, 113, 247, 0.5);
  color: var(--purple);
}

.ent-name {
  font-weight: 600;
}
.ent-no {
  color: var(--muted);
  font-size: 0.85rem;
}

.station-block {
  margin-bottom: 0.75rem;
}
.station-title {
  font-size: 0.85rem;
  color: var(--purple);
  margin-bottom: 0.35rem;
}

.conn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.conn-table th,
.conn-table td {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.conn-table th {
  color: var(--muted);
  font-weight: 500;
}

.perf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.perf-tile {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}
.perf-tile .v {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent);
}
.perf-tile .k {
  font-size: 0.75rem;
  color: var(--muted);
}

.perf-placeholder {
  color: var(--muted);
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.msg {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.msg.err {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid var(--bad);
  color: #fbb;
}
.msg.ok {
  background: rgba(62, 207, 142, 0.1);
  border: 1px solid var(--ok);
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem;
  text-align: center;
}
.muted {
  color: var(--muted);
  font-size: 0.8rem;
}
.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.tap-row {
  border-left: 3px solid var(--border);
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 6px 6px 0;
}
.tap-row.in {
  border-left-color: var(--purple);
}
.tap-row.out {
  border-left-color: var(--accent);
}
.tap-dir-tag {
  display: inline-block;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.tap-dir-tag.in {
  background: rgba(163, 113, 247, 0.25);
  color: var(--purple);
}
.tap-dir-tag.out {
  background: rgba(61, 157, 255, 0.22);
  color: var(--accent);
}
.tap-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.session-snippet {
  font-size: 0.75rem;
  max-width: 35rem;
  display: inline-block;
  vertical-align: top;
  word-break: break-all;
}
.tap-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .ent-workspace {
    flex-direction: column;
  }
  .ent-picker {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 42vh;
  }
  .ent-overview {
    max-height: min(32vh, 260px);
  }
}

@media (max-width: 720px) {
  .shell.shell-full {
    flex-direction: column;
  }
  .tabs-rail {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    justify-content: flex-start;
    align-items: center;
  }
  .tabs-rail-hint {
    display: none;
  }
  .tab-v {
    text-align: center;
    flex: 1;
    min-width: 100px;
  }
}

/* —— 联调台（并入 tab-devtest）—— */
.devtest-banner {
  margin-bottom: 1rem;
}
.devtest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 960px) {
  .devtest-grid {
    grid-template-columns: 1fr;
  }
}
.devtest-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.devtest-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--accent);
}
.devtest-panel h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
}
.devtest-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.devtest-row label,
.devtest-row .label-like {
  color: var(--muted);
  font-size: 0.85rem;
}
.devtest-panel input[type="text"],
.devtest-panel input[type="number"],
.devtest-panel select,
.devtest-panel textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d1117;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
}
.devtest-panel textarea {
  resize: vertical;
}
.devtest-btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.devtest-btn-row.tight {
  margin: 0;
  gap: 0.35rem;
}
.devtest-mt {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.devtest-log {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  min-height: 140px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
}
.devtest-params.hidden {
  display: none !important;
}
#tab-devtest .preset-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}
#tab-devtest .preset-btns button {
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
}
.dev-redis-op-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.dev-redis-op-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}
.dev-redis-op-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.dev-redis-op-panel {
  margin-top: 0.5rem;
}
.dev-redis-op-panel.hidden {
  display: none !important;
}
.dev-redis-op-panel input,
.dev-redis-op-panel textarea {
  margin-bottom: 0.5rem;
}
#tab-devtest .primary {
  background: var(--accent);
  border-color: #2b7fd4;
  color: #061018;
  font-weight: 600;
}
