:root {
  color-scheme: light;
  --text: #262d2a;
  --muted: #66716b;
  --green: #225b45;
  --green-hover: #174431;
  --green-soft: #eef5f0;
  --border: #e2e7e3;
  --surface: #f7f9f7;
  --red: #a33332;
  --red-soft: #fcf1f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--text);
  background: #fff;
  font-size: 14px;
  line-height: 1.6;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a.button { touch-action: manipulation; }
button { cursor: pointer; }
a { color: var(--green); text-decoration: none; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid #589c7b; outline-offset: 3px; }
input:focus-visible, select:focus-visible { outline: 2px solid #589c7b; outline-offset: 1px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 650; line-height: 1.4; letter-spacing: -.5px; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 10; padding: 10px 16px; background: #fff; border: 1px solid var(--green); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border: 1px solid #d4dcd6; border-radius: 5px; background: #fff; color: var(--text); font-weight: 500; white-space: nowrap; line-height: 1.5; }
.button:hover:not(:disabled) { background: var(--surface); border-color: #a7b7ac; }
.button.primary { color: #fff; background: var(--green); border-color: var(--green); }
.button.primary:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }
.button.danger { color: #fff; background: var(--red); border-color: var(--red); }
.button.danger:hover:not(:disabled) { background: #862928; }
.button.quiet { color: var(--muted); background: transparent; border-color: transparent; padding: 5px 8px; }
.button.quiet:hover:not(:disabled) { color: var(--green); background: var(--green-soft); border-color: transparent; }
.icon-button { display: inline-flex; justify-content: center; align-items: center; flex: 0 0 auto; width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.icon-button:hover:not(:disabled) { background: var(--surface); color: var(--text); }
input:not([type="checkbox"]), select { width: 100%; min-height: 40px; border: 1px solid #cbd5cd; border-radius: 5px; padding: 8px 11px; color: var(--text); background: #fff; }
input::placeholder { color: #768178; }
input[readonly] { color: var(--muted); background: var(--surface); }
input[type="checkbox"] { accent-color: var(--green); width: 17px; height: 17px; margin: 0; }
input[aria-invalid="true"] { border-color: var(--red); }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 19px; min-width: 0; }
.field label, .field-label { display: block; color: #37423b; font-weight: 500; }
.field-hint { color: var(--muted); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.field-hint output { color: var(--green); }
.error-message, .list-error { background: var(--red-soft); color: #8b2d2a; border: 1px solid #ecd0cd; border-radius: 5px; padding: 10px 12px; overflow-wrap: anywhere; }
.error-message { margin-top: 12px; }
.muted { color: var(--muted); }
.boot-view { min-height: 100svh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; color: var(--muted); padding: 24px; text-align: center; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-word { font-family: "Segoe UI", -apple-system, sans-serif; font-size: 21px; line-height: 1; font-weight: 650; letter-spacing: -.7px; color: var(--text); }
.brand-mark { width: 29px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--green); color: #fff; font-size: 24px; font-weight: 600; line-height: 1; padding-bottom: 4px; }
.login-view { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--surface); padding: 32px 20px; }
.login-panel { width: 100%; max-width: 390px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 32px; }
.login-panel .brand { margin-bottom: 35px; }
.login-panel h1 { font-size: 23px; margin-bottom: 25px; }
.login-submit { width: 100%; margin-top: 5px; min-height: 40px; }
.login-footer { color: var(--muted); font-size: 12px; margin-top: 20px; }
.app-shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100svh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100svh; background: #f7f9f7; border-right: 1px solid var(--border); padding: 27px 17px 22px; }
.sidebar .brand { padding-left: 10px; }
.sidebar-caption { display: block; padding: 9px 0 32px 49px; font-size: 11px; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 5px; color: var(--text); font-weight: 550; }
.nav-item.active { color: var(--green); background: #e9f0eb; }
.nav-icon { font-size: 18px; line-height: 1; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--green); font-variant-numeric: tabular-nums; }
.workspace { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 67px; padding: 0 32px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.topbar strong { color: #4b5750; font-weight: 500; }
.account { display: flex; align-items: center; gap: 15px; }
.account > span { color: var(--text); }
.account .button { font-size: 12px; }
main { padding: 32px; max-width: 1800px; margin: 0 auto; }
main:focus { outline: none; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; }
.page-desc { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.notice { background: var(--green-soft); border: 1px solid #cfdfd3; border-radius: 5px; padding: 10px 14px; margin-bottom: 18px; }
.notice.error { background: var(--red-soft); border-color: #ecd0cd; color: #8b2d2a; }
.device-section { border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.settings { display: grid; gap: 16px; }
.settings-card { border: 1px solid var(--border); border-radius: 7px; padding: 20px 22px; }
.settings-card h2 { margin: 0 0 14px; font-size: 14px; font-weight: 600; }
.settings-list { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 0; font-size: 13px; }
.settings-list dt { color: var(--muted); }
.settings-list dd { margin: 0; overflow-wrap: anywhere; }
.settings-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 10px 0 0; font-size: 13px; }
.settings-links a[hidden] { display: none; }
.settings-steps { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.85; }
.settings-steps code { font-size: 12px; overflow-wrap: anywhere; }
.settings-card .unavailable-panel { margin-top: 16px; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; }
.filters { display: flex; gap: 10px; min-width: 0; flex: 1; }
.filters input { max-width: 290px; min-width: 100px; min-height: 36px; font-size: 12px; }
.filters select { width: 110px; min-height: 36px; font-size: 12px; padding: 6px 9px; }
.sync-controls { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; font-size: 11px; }
.sync-controls .button { font-size: 12px; }
.list-error { margin: 0 20px 16px; }
.list-state { display: flex; align-items: center; justify-content: center; min-height: 250px; color: var(--muted); padding: 32px 20px; text-align: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-spacing: 0; border-collapse: collapse; min-width: 890px; text-align: left; font-size: 12px; }
th { padding: 11px 16px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #f8faf8; color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
td { padding: 18px 16px; vertical-align: middle; border-bottom: 1px solid #edf0ed; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfdfc; }
.device-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.device-slug { color: var(--muted); font-size: 11px; margin-top: 3px; overflow-wrap: anywhere; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; white-space: nowrap; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #939e96; }
.status-badge.online { color: var(--green); }
.status-badge.online .status-dot { background: #2e7955; }
.status-badge.disabled { color: #707973; }
.last-seen { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.domain-button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 6px 0; color: var(--green); text-align: left; font-size: 12px; max-width: 255px; overflow-wrap: anywhere; }
.domain-button:hover { text-decoration: underline; }
.domain-button::after { content: "⧉"; color: #7c9284; font-size: 13px; }
.port-range, .connection-count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 1px; }
.row-actions button { font-size: 11px; padding: 5px 6px; }
.row-actions .delete-action { color: var(--red); }
.actions-heading { text-align: right; }
.mobile-label { display: none; }
.list-footer { display: flex; justify-content: space-between; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
dialog { width: min(520px, calc(100% - 32px)); max-height: calc(100svh - 48px); padding: 0; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); overflow-y: auto; box-shadow: 0 16px 60px #14271c1f; }
dialog::backdrop { background: #192a235e; }
body:has(dialog[open]) { overflow: hidden; }
.compact-dialog { width: min(450px, calc(100% - 32px)); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 24px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 24px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); background: #fafbfa; }
.dialog-footer .button { min-width: 76px; }
.port-fields { display: flex; align-items: center; gap: 12px; }
.port-fields .field { flex: 1; margin-bottom: 5px; }
.port-separator { padding-top: 23px; color: var(--muted); }
.auth-fields { border-top: 1px solid var(--border); padding-top: 19px; margin-top: 22px; }
.auth-fields > .field-hint { margin: 6px 0 15px; }
.auth-fields .field { margin-bottom: 0; }
.subtle-label { font-size: 11px; font-weight: 400; margin-left: 5px; color: var(--muted); }
.checkbox-field { display: flex; align-items: center; gap: 9px; margin-top: 22px; }
.confirm-description { color: #4c5850; line-height: 1.8; overflow-wrap: anywhere; white-space: pre-line; }
.sensitive-warning { color: #7e5524; background: #fcf6eb; border: 1px solid #eddfc6; padding: 10px 12px; border-radius: 5px; font-size: 12px; margin-bottom: 18px; }
.enrollment-meta { display: flex; gap: 12px; margin: 0 0 8px; font-size: 12px; }
.enrollment-meta dt { color: var(--muted); }
.enrollment-meta dd { margin: 0; overflow-wrap: anywhere; }
.config-preview, .command-line { background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 14px; font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; }
.config-preview { margin: 0 0 22px; max-height: 200px; overflow: auto; }
.command-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.command-heading h3 { font-size: 12px; }
.command-heading .button { font-size: 11px; min-height: 30px; }
.command-line { display: block; }
.access-url { display: block; margin: 8px 0 12px; padding: 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--green); overflow-wrap: anywhere; font-size: 13px; }
a.button:not([href]) { opacity: .5; cursor: not-allowed; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 20; padding: 11px 18px; max-width: calc(100% - 32px); border: 1px solid #cbd9cf; border-radius: 5px; color: var(--green); background: #fff; box-shadow: 0 4px 18px #152b1b12; font-size: 13px; overflow-wrap: anywhere; }
.noscript { padding: 24px; text-align: center; }
.nav-item + .nav-item { margin-top: 6px; }
.sidebar { overflow-y: auto; }
.client-downloads { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 18px; }
.client-downloads > a { display: block; font-size: 11px; margin-top: 7px; overflow-wrap: anywhere; }
.client-downloads [data-download-state] { margin-top: 5px; }
.download-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 10px; }
.enrollment-downloads { margin: 0 0 18px; padding: 0 0 16px; border-top: 0; border-bottom: 1px solid var(--border); }
.command-heading select { max-width: 240px; min-width: 0; min-height: 34px; flex: 1; font-size: 12px; }
.command-heading .button { flex-shrink: 0; }
.unavailable-panel { padding: 12px 15px; margin-bottom: 18px; background: #fcf8f0; border: 1px solid #ebdfca; border-radius: 5px; font-size: 12px; }
.unavailable-panel summary { cursor: pointer; color: #77552c; }
.unavailable-panel ul { padding-left: 20px; margin-bottom: 0; max-height: 180px; overflow: auto; overflow-wrap: anywhere; }
.reported-ports, .certificate-status { font-size: 10px; color: var(--muted); margin-top: 5px; max-width: 260px; overflow-wrap: anywhere; }
.certificate-error { color: var(--red); }
.rule-summary { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.rule-summary > div + div { margin-top: 4px; }
#mapping-dialog { width: min(600px, calc(100% - 32px)); }
.mapping-rules-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.mapping-port-row { display: grid; grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr) 28px; gap: 8px; align-items: end; margin-bottom: 12px; }
.mapping-port-row .field { margin: 0; }
.mapping-port-row .field label { font-size: 12px; }
.mapping-port-row .mapping-arrow { padding-bottom: 10px; color: var(--muted); }
.mapping-port-row .icon-button { width: 28px; height: 40px; }
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  main { padding: 24px; }
  .topbar { padding: 0 24px; }
  .sync-controls #sync-status, .sync-controls #mapping-sync-status { display: none; }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 20px; border-right: 0; border-bottom: 1px solid var(--border); padding: 16px 20px; }
  .sidebar .brand { padding: 0; }
  .sidebar-caption { display: none; }
  .sidebar { flex-wrap: wrap; }
  .sidebar nav { display: flex; flex-basis: 100%; gap: 8px; margin-left: 0; }
  .sidebar nav .nav-item { flex: 1; margin-top: 0; justify-content: center; white-space: nowrap; }
  .sidebar nav .nav-count { margin-left: auto; }
  #mapping-table td[data-column="ports"] { grid-column: 1 / -1; }
  #mapping-table td[data-column="connections"] { grid-column: 1 / -1; text-align: left; }
  .nav-item { padding: 6px 10px; gap: 8px; font-size: 12px; }
  .nav-count { display: none; }
  .topbar { height: 51px; padding: 0 20px; }
  main { padding: 24px 20px; }
  .table-wrap { overflow: visible; }
  table, tbody { display: block; min-width: 0; }
  thead { display: none; }
  tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, auto); padding: 18px 20px 10px; border-top: 1px solid var(--border); gap: 13px 14px; }
  td { display: block; padding: 0; border: 0; }
  td[data-column="device"] { grid-column: 1; grid-row: 1; }
  td[data-column="status"] { grid-column: 2; grid-row: 1; text-align: right; }
  td[data-column="domain"] { grid-column: 1 / -1; }
  td[data-column="actions"] { grid-column: 1 / -1; border-top: 1px solid #edf0ed; padding-top: 6px; }
  td[data-column="connections"] { text-align: right; }
  .row-actions { gap: 8px; }
  .row-actions button { min-height: 38px; font-size: 12px; }
  .device-name { font-size: 14px; }
  .domain-button { max-width: 100%; font-size: 13px; padding: 0; }
  .mobile-label { display: inline; font-size: 11px; color: var(--muted); margin-right: 8px; }
  .last-seen { font-size: 10px; }
  .stats > div { padding: 0 20px; }
}
@media (max-width: 540px) {
  h1 { font-size: 24px; }
  .sidebar { padding: 15px 16px; gap: 10px; }
  .sidebar .brand-word { font-size: 19px; }
  .nav-icon { display: none; }
  .topbar { padding: 0 16px; font-size: 11px; }
  .account { gap: 8px; }
  .breadcrumb-divider { margin: 0 6px; }
  main { padding: 24px 16px; }
  .page-heading { margin-bottom: 22px; }
  .page-heading .button { padding: 7px 11px; font-size: 12px; }
  .stats { padding: 16px 0; margin-bottom: 20px; }
  .stats > div { padding: 0 12px; gap: 7px; }
  .stats span { font-size: 10px; }
  .stats strong { font-size: 22px; }
  .list-toolbar { flex-wrap: wrap; padding: 14px; gap: 12px; }
  .filters { flex-basis: calc(100% - 64px); gap: 6px; }
  .filters input { padding: 8px; min-width: 80px; width: 100%; }
  .filters select { width: 90px; padding: 6px 4px; flex: 0 0 auto; }
  .sync-controls { flex-shrink: 0; }
  .sync-controls .button { padding: 7px 10px; }
  .list-error { margin: 0 14px 14px; }
  tbody tr { padding: 17px 14px 8px; }
  .row-actions { justify-content: space-between; gap: 2px; flex-wrap: wrap; }
  .mapping-port-row { gap: 6px; }
  .mapping-port-row .field label { font-size: 11px; }
  .row-actions button { padding: 5px 8px; }
  .list-footer { padding: 12px 14px; font-size: 10px; }
  dialog { max-height: calc(100svh - 24px); }
  .dialog-header { padding: 16px 18px; }
  .dialog-body { padding: 20px 18px; }
  .dialog-footer { padding: 14px 18px; }
  .login-panel { padding: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
