:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  color: #17202a;
  background: #f4f6f8;
  letter-spacing: 0;
  --ink: #17202a;
  --muted: #65717e;
  --line: #dce2e8;
  --soft: #f4f6f8;
  --surface: #ffffff;
  --action: #1769aa;
  --action-dark: #10558d;
  --success: #19734b;
  --success-soft: #e8f5ee;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #8a5a00;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--soft);
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner,
.workspace {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row h1 { margin: 0; font-size: 18px; line-height: 1.25; }
.brand-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  font-size: 20px;
}

.brand-mark.small { width: 36px; height: 36px; font-size: 16px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #25a56a; }

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: #43505d;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
}

.icon-button:hover { background: #eef2f5; border-color: var(--line); }
.icon-button svg { width: 19px; height: 19px; }

.workspace { padding: 32px 0 48px; }

.control-band,
.status-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 24px;
}

.status-band { margin-top: 20px; }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-heading h2 { margin: 3px 0 0; font-size: 20px; line-height: 1.3; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(360px, 100%);
  padding: 3px;
  margin-bottom: 22px;
  background: #edf1f4;
  border-radius: 6px;
}

.segment {
  min-height: 36px;
  padding: 7px 12px;
  color: #53606d;
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-weight: 650;
}

.segment.active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(23, 32, 42, .12); }

.proxy-inputs { border-top: 1px solid var(--line); }
.proxy-row { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.proxy-row label { color: #34414e; font-size: 13px; font-weight: 750; }

input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd3db;
  border-radius: 5px;
  outline: none;
}

input:focus { border-color: var(--action); box-shadow: 0 0 0 3px rgba(23, 105, 170, .14); }
input::placeholder { color: #98a2ad; }

.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 20px; }
.form-message { flex: 1; min-height: 22px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.form-message.success { color: var(--success); }
.form-message.error { color: var(--danger); }
.form-message.working { color: var(--warning); }

.primary-button,
.secondary-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button { color: #fff; background: var(--action); }
.primary-button:hover { background: var(--action-dark); }
.primary-button:disabled { cursor: not-allowed; opacity: .48; }
.primary-button svg { width: 17px; height: 17px; }
.secondary-button { color: #34414e; background: #fff; border-color: #cbd3db; }
.apply-button { min-width: 172px; }
.apply-button.loading svg { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.status-heading-row { align-items: flex-end; }
.status-heading-row time { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; }
table { width: 100%; min-width: 650px; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; white-space: nowrap; }
th { color: var(--muted); background: #f7f9fa; font-size: 11px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.node-cell { font-weight: 750; }
.mono-cell { font-family: "Cascadia Mono", Consolas, monospace; }
.status-badge { display: inline-flex; min-width: 52px; justify-content: center; padding: 4px 7px; color: #5f6b77; background: #eef1f3; border-radius: 4px; font-size: 11px; font-weight: 700; }
.status-badge.ready { color: var(--success); background: var(--success-soft); }

dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 20px 60px rgba(18, 29, 39, .2); }
dialog::backdrop { background: rgba(18, 29, 39, .42); }
dialog form { padding: 24px; }
dialog h2 { margin: 14px 0 8px; font-size: 19px; }
dialog p { margin: 0; color: var(--muted); line-height: 1.55; }
.dialog-icon { width: 38px; height: 38px; display: grid; place-items: center; color: var(--action); background: #eaf3fa; border-radius: 5px; }
.dialog-icon svg { width: 20px; height: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.login-page { display: grid; place-items: center; background: #eef2f5; }
.login-shell { width: min(390px, calc(100% - 32px)); }
.login-panel { padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 12px 36px rgba(23, 32, 42, .08); }
.login-panel h1 { margin: 20px 0 24px; font-size: 22px; }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: 13px; font-weight: 700; }
.login-form .primary-button { width: 100%; margin-top: 8px; }
.form-error { margin: 2px 0 0; color: var(--danger); font-size: 13px; }

@media (max-width: 680px) {
  .topbar-inner, .workspace { width: min(100% - 20px, 1040px); }
  .workspace { padding-top: 18px; }
  .control-band, .status-band { padding: 18px 14px; }
  .proxy-row { grid-template-columns: 1fr; gap: 7px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .apply-button { width: 100%; }
  .section-heading { margin-bottom: 16px; }
}

