:root {
  color-scheme: light;
  --paper: #f3f5f4;
  --surface: #fff;
  --text: #172720;
  --muted: #55665c;
  --line: #dce5de;
  --accent: #125c44;
  --accent-hover: #0a4934;
  --error: #a32a23;
  font: 15px/1.5 system-ui, -apple-system, "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--text); }
.container { width: min(1140px, calc(100% - 40px)); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-inner { min-height: 65px; display: flex; align-items: center; justify-content: space-between; }
.wordmark { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 14px; font-weight: 720; letter-spacing: -.3px; }
.mark { width: 17px; height: 17px; border: 3px solid var(--accent); border-radius: 5px; transform: rotate(-12deg); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(27px, 4vw, 38px); letter-spacing: -.04em; font-weight: 740; }
h2 { font-size: 19px; line-height: 1.25; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; background: transparent; border: 1px solid transparent; min-height: 39px; border-radius: 7px; padding: 7px 13px; white-space: nowrap; }
button:disabled { cursor: progress; opacity: .65; }
.primary { color: #fff; background: var(--accent); font-weight: 650; }
.primary:hover { background: var(--accent-hover); }
.secondary { border-color: var(--line); background: var(--surface); color: var(--text); }
.secondary:hover, .quiet:hover { background: #e8f1eb; }
.quiet { color: var(--accent); }
.danger { color: var(--error); border-color: #eed3cf; }
.danger:hover { background: #fff0ed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.login { max-width: 440px; margin: clamp(35px, 12vh, 120px) auto; padding: 28px; }
.login form { display: grid; gap: 12px; margin-top: 23px; }
.help { margin-top: 14px; font-size: 13px; }
#session-actions { align-items: center; }
#session-user { padding-inline: 6px; overflow-wrap: anywhere; }
.account-notice { padding: 12px 18px; margin-bottom: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
#portal .metric strong { font-size: clamp(15px, 2.15vw, 25px); overflow-wrap: anywhere; }
.login button { justify-self: start; min-width: 86px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-block: 34px 24px; }
.endpoint, .muted, small, .empty { color: var(--muted); }
.endpoint { margin-top: 5px; overflow-wrap: anywhere; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metric { padding: 16px 20px; display: grid; gap: 3px; color: var(--muted); }
.metric strong { color: var(--text); font-size: 28px; font-weight: 700; line-height: 1.3; }
#adapters { overflow-wrap: anywhere; font-size: 12px; }
.status { margin-block: 8px; min-height: 23px; color: var(--accent); }
.problem { color: var(--error); overflow-wrap: anywhere; }
.problem:empty { display: none; }
.table-card { margin-bottom: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 21px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-spacing: 0; text-align: left; }
.cell-label { display: none; }
th, td { padding: 10px 16px; border-top: 1px solid var(--line); white-space: nowrap; }
th { font-size: 13px; font-weight: 680; color: var(--muted); background: #f8faf8; }
th:first-child, td:first-child { padding-left: 21px; }
th:last-child, td:last-child { padding-right: 21px; }
.empty { padding-block: 22px; }
.item-name { font-weight: 650; }
.item-name small { display: block; font-size: 12px; font-weight: 450; }
.actions { display: flex; flex-wrap: wrap; gap: 5px; }
td .actions { flex-wrap: nowrap; }
.pill { display: inline-block; border-radius: 100px; padding: 3px 9px; font-size: 12px; font-weight: 650; }
.ok { color: #155a3a; background: #e6f3e9; }
.warn { color: #79480c; background: #fff0d8; }
.off { color: #546257; background: #eef1ee; }
dialog { width: min(640px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--text); box-shadow: 0 20px 80px #142b2730; }
dialog::backdrop { background: #17272070; }
dialog .section-head { border-bottom: 1px solid var(--line); }
.form-body { display: grid; gap: 16px; padding: 18px 21px; }
.route-group th { color: var(--text); }
.route-ip { white-space: nowrap; }
#protocols-form textarea { display: block; width: 100%; min-height: 240px; resize: vertical; font-family: monospace; }
#clash-policy-dialog { width: min(930px, calc(100% - 24px)); }
#node-upgrades-list { display: grid; gap: 12px; }
#node-upgrades-list fieldset { display: grid; gap: 8px; }
#node-install-output, #node-inventory-nodes, .inventory-node { display: grid; gap: 12px; }
.inventory-node .copy-row + .copy-row { margin-top: 4px; }
#node-upgrades-list select { width: auto; max-width: 100%; }
.legacy-rdt summary { padding: 17px 21px; cursor: pointer; }
.rdt-p-fallback { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 10px; margin: 8px 0; }
#clash-policy-form { display: flex; flex-direction: column; max-height: calc(100dvh - 26px); }
.clash-tabs { display: flex; gap: 3px; padding: 8px 17px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.clash-tabs button[aria-pressed="true"] { background: #e8f1eb; font-weight: 650; }
.clash-panel { overflow-y: auto; min-height: 175px; }
#clash-list, .clash-item-fields { display: grid; gap: 12px; align-content: start; }
.clash-line { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 7px; border-top: 1px solid var(--line); }
.clash-line > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.clash-line small { margin-top: 3px; }
.clash-line .actions { flex: 0 0 auto; }
.clash-line button { min-height: 32px; padding: 4px 8px; }
.clash-item-fields fieldset > .actions { margin-top: 10px; flex-wrap: nowrap; }
.clash-item-fields textarea { display: block; width: 100%; padding: 8px; resize: vertical; font: 13px/1.45 ui-monospace, monospace; }
.clash-options summary { cursor: pointer; font-weight: 650; }
.clash-options > :not(summary) { margin-top: 9px; }
#clash-policy-form .form-actions { flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { font-weight: 600; display: grid; min-width: 0; gap: 5px; }
label small { font-weight: 400; }
input:not([type="checkbox"]), select { width: 100%; min-width: 0; min-height: 40px; padding: 7px 9px; border: 1px solid #c5d2ca; border-radius: 6px; background: var(--surface); color: var(--text); }
input[readonly] { background: #f6f8f6; }
input[type="checkbox"] { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; }
.inline { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.checklist { display: flex; flex-direction: column; justify-content: center; gap: 9px; }
fieldset { min-width: 0; margin: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; }
legend { font-weight: 600; padding-inline: 5px; }
.selection, .copy-row { display: grid; align-items: center; gap: 8px; grid-template-columns: 1fr minmax(0, 235px); }
.selection + .selection { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.copy-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.copy-row input { font-family: ui-monospace, monospace; font-size: 13px; }
.device-list { display: grid; gap: 14px; }
.device-list > fieldset { display: grid; gap: 8px; }
.device-list > fieldset > button { justify-self: start; }
.device-list > form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.form-actions { border-top: 1px solid var(--line); padding: 13px 21px; display: flex; justify-content: end; gap: 8px; }

@media (max-width: 760px) {
  .page-head { flex-wrap: wrap; align-items: start; gap: 12px; }
  .page-head > div { min-width: 0; }
  .scroll { overflow: visible; }
  .responsive-table { position: relative; display: block; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .responsive-table tbody { display: block; }
  .responsive-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 14px; border-top: 1px solid var(--line); }
  .responsive-table tbody :is(td, th) { padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .responsive-table tbody :is(td:first-child, .cell-actions, th) { grid-column: 1 / -1; }
  .responsive-table tbody tr.route-group { background: #f8faf8; padding-block: 9px; }
  .responsive-table .route-ip { white-space: normal; }
  .cell-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12px; }
  .responsive-table .cell-actions .actions { flex-wrap: wrap; }
  .responsive-table .cell-actions .quiet { background: #f3f7f4; }
}

@media (max-width: 620px) {
  .container { width: calc(100% - 24px); }
  .topbar-inner { min-height: 56px; gap: 8px; }
  .wordmark { flex: none; gap: 10px; }
  #session-actions { justify-content: end; gap: 0 3px; min-width: 0; }
  #session-user { min-width: 0; }
  #session-actions button { padding-inline: 7px; }
  .login { margin-block: clamp(22px, 8vh, 72px); padding: 22px; }
  .login form { gap: 15px; margin-top: 18px; }
  .login button { width: 100%; }
  .page-head { margin-block: 23px 18px; }
  .summary { gap: 8px; }
  .metric { padding: 12px 10px; font-size: 12px; }
  .metric strong { font-size: 22px; }
  .section-head, .form-body, .form-actions { padding: 12px 14px; }
  .section-head { gap: 8px; }
  .legacy-rdt summary { padding: 14px; }
  .form-actions { flex-wrap: wrap; }
  .form-grid, .selection, .rdt-p-fallback { grid-template-columns: minmax(0, 1fr); }
  .rdt-p-fallback button { justify-self: start; }
  .clash-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 6px 10px; }
  .clash-panel { min-height: 0; }
  .clash-line { display: grid; }
  .clash-item-fields fieldset > .actions { flex-wrap: wrap; }
  .clash-item-fields fieldset > .actions select { flex: 1 1 150px; width: auto; }
  .form-body, .section-head, .metric { overflow-wrap: anywhere; }
  .inline input[type="checkbox"] { flex: none; }
}

@media (max-width: 620px), (pointer: coarse) {
  button, .clash-line button { min-height: 44px; white-space: normal; }
  input:not([type="checkbox"]), select, textarea { min-height: 44px; font-size: 16px; }
  .copy-row input, .clash-item-fields textarea { font-size: 16px; }
}

@media (max-width: 420px) {
  #portal .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #portal .summary > :first-child { grid-column: 1 / -1; }
}
