:root {
  color: #17211c;
  background: #f4f6f5;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  --ink: #17211c;
  --muted: #66726c;
  --line: #d9dfdc;
  --surface: #ffffff;
  --green: #137a4b;
  --green-soft: #e8f4ed;
  --amber: #9a5d00;
  --amber-soft: #fff2d6;
  --red: #b32d36;
  --red-soft: #fdebed;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f5; color: var(--ink); }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #eef2f0 0 49%, #e6ece9 49% 51%, #f7f8f7 51%); }
.login-panel { width: min(100%, 400px); padding: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 50px rgba(30, 50, 40, .10); }
.brand-mark { width: 42px; height: 42px; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 4px; padding: 8px; background: var(--ink); border-radius: 6px; }
.brand-mark span { display: block; background: #72d39d; }
.brand-mark span:nth-child(1) { height: 40%; }
.brand-mark span:nth-child(2) { height: 75%; }
.brand-mark span:nth-child(3) { height: 100%; }
.brand-mark.small { width: 36px; height: 36px; padding: 7px; }
.brand-name { margin: 16px 0 4px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 1.8px; }
.login-panel h1 { margin: 0 0 30px; font-size: 26px; letter-spacing: 0; }
label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.key-field { display: grid; grid-template-columns: 1fr auto; border: 1px solid #aeb9b3; border-radius: 6px; overflow: hidden; background: #fff; }
.key-field:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(19, 122, 75, .12); }
.key-field input { min-width: 0; height: 44px; padding: 0 12px; border: 0; outline: 0; }
.icon-button { width: 58px; border: 0; border-left: 1px solid var(--line); background: #f6f8f7; color: var(--muted); font-size: 12px; font-weight: 700; }
.form-error { min-height: 20px; margin: 8px 0 10px; color: var(--red); font-size: 13px; }
.primary-button, .secondary-button, .quiet-button { min-height: 38px; border-radius: 6px; padding: 0 16px; font-weight: 700; }
.primary-button { width: 100%; height: 44px; border: 1px solid var(--ink); background: var(--ink); color: #fff; }
.primary-button:hover { background: #28362f; }
.primary-button:disabled { cursor: wait; opacity: .65; }

.dashboard { min-height: 100vh; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px clamp(20px, 4vw, 56px); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand-inline { display: flex; align-items: center; gap: 12px; }
.brand-inline .brand-name { margin: 0 0 2px; }
.brand-inline h1 { margin: 0; font-size: 20px; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.updated-at { margin-right: 8px; color: var(--muted); font-size: 12px; }
.secondary-button { border: 1px solid #aeb9b3; background: #fff; color: var(--ink); }
.quiet-button { border: 1px solid transparent; background: transparent; color: var(--muted); }
.secondary-button:hover, .quiet-button:hover { background: #eef2f0; }

.summary-band { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); border-bottom: 1px solid var(--line); background: #edf1ef; padding: 0 clamp(20px, 4vw, 56px); }
.summary-band > div { min-height: 92px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); padding: 14px 28px; }
.summary-band > div:first-child { border-left: 1px solid var(--line); }
.summary-value { font-size: 28px; line-height: 1; font-weight: 760; font-variant-numeric: tabular-nums; }
.summary-label { margin-top: 7px; color: var(--muted); font-size: 12px; }
.status-online-text { color: var(--green); }
.status-warning-text { color: var(--red); }

.workspace { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: calc(100vh - 169px); }
.node-list-region { min-width: 0; padding: 30px clamp(20px, 4vw, 56px) 60px; }
.section-heading { min-height: 36px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 17px; letter-spacing: 0; }
.loading-state { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; border-top: 1px solid #aeb9b3; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--surface); }
th { height: 42px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: left; text-transform: uppercase; }
td { height: 66px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
th:nth-child(1) { width: 22%; } th:nth-child(2) { width: 18%; } th:nth-child(3) { width: 13%; } th:nth-child(4) { width: 14%; } th:nth-child(5) { width: 24%; } th:nth-child(6) { width: 9%; }
tbody tr { transition: background .15s ease; }
tbody tr:hover, tbody tr.selected { background: #f0f6f3; }
.node-id { display: block; font-weight: 750; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 800; }
.status::before { content: ""; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: currentColor; }
.status-online { color: var(--green); }
.status-suspect { color: var(--amber); }
.status-offline { color: var(--red); }
.detail-link { border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 800; }
.empty-state { min-height: 240px; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.empty-state strong { color: var(--ink); }

.detail-panel { width: min(440px, 40vw); min-height: 100%; padding: 28px; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -14px 0 35px rgba(30, 50, 40, .06); }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 1.5px; }
.detail-header h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; letter-spacing: 0; }
.close-button { width: 34px; height: 34px; flex: 0 0 34px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--muted); font-size: 22px; line-height: 1; }
.detail-section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.detail-item span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.detail-item strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.worker-row { padding: 12px 0; border-top: 1px solid var(--line); }
.worker-row:first-of-type { border-top: 0; }
.worker-row-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.worker-row-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 11px; }
.json-block { max-height: 230px; overflow: auto; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 4px; background: #f7f9f8; color: #34423b; font: 11px/1.6 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.inline-error { padding: 12px 14px; border-left: 3px solid var(--red); background: var(--red-soft); color: var(--red); font-size: 13px; }
.deploy-control { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.deploy-control h3 { margin-bottom: 5px; }
.deploy-control p { margin: 0; color: var(--muted); font-size: 12px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: 0 0 44px; margin: 0; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: #aeb9b3; transition: background .15s ease; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s ease; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid rgba(19,122,75,.2); outline-offset: 2px; }
.switch input:disabled + span { cursor: wait; opacity: .55; }

@media (max-width: 900px) {
  .updated-at { display: none; }
  .summary-band { grid-template-columns: repeat(2, 1fr); }
  .summary-band > div:nth-child(3) { border-left: 1px solid var(--line); }
  .workspace { display: block; }
  .detail-panel { position: fixed; inset: 0 0 0 auto; z-index: 10; width: min(100%, 440px); overflow-y: auto; }
}

@media (max-width: 640px) {
  .login-panel { padding: 28px 22px; }
  .topbar { align-items: flex-start; padding: 14px 16px; }
  .brand-inline h1 { font-size: 17px; }
  .topbar-actions { gap: 2px; }
  .secondary-button, .quiet-button { min-height: 36px; padding: 0 10px; }
  .summary-band { padding: 0 16px; }
  .summary-band > div { min-height: 78px; padding: 12px 16px; }
  .node-list-region { padding: 24px 16px 40px; }
  .table-wrap { overflow: visible; border-top: 0; }
  table, tbody { display: block; }
  thead { display: none; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
  td { display: block; height: auto; padding: 0; border: 0; }
  td::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
  td:first-child, td:nth-child(5) { grid-column: 1 / -1; }
  td:last-child { grid-column: 2; grid-row: 2; align-self: end; justify-self: end; }
  .detail-panel { padding: 22px 18px; }
}
