:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #202721;
  background: #f6f7f8;
  font-size: 14px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  letter-spacing: 0;
  --muted: #6a736f;
  --line: #dfe4e1;
  --accent: #216748;
  --accent-hover: #195239;
  --danger: #a52a34;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
input:disabled { color: #7e8782; background: #f0f2f1; }
input, select, textarea { min-width: 0; color: inherit; }
input, select, textarea { border: 1px solid #cbd3ce; border-radius: 5px; background: #fff; }
input { height: 40px; padding: 8px 11px; }
input[type="checkbox"] { width: 16px; height: 16px; padding: 0; margin: 0; accent-color: var(--accent); }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
select { height: 40px; padding: 8px 30px 8px 11px; }
textarea { width: 100%; padding: 10px 11px; line-height: 1.65; resize: vertical; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid #a5cbb7; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: 25px; line-height: 1.45; font-weight: 650; }
h2 { font-size: 18px; line-height: 1.5; font-weight: 650; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex: 0 0 18px; display: block; opacity: .78; }
.button { min-height: 40px; padding: 9px 14px; border: 1px solid #cbd3ce; border-radius: 5px; background: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 7px; line-height: 20px; font-weight: 550; white-space: nowrap; }
.button:hover { background: #f0f3f1; }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.primary .icon, .button.danger .icon { filter: brightness(0) invert(1); opacity: 1; }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.danger:hover { background: #86212a; }
.button.subtle { border-color: transparent; background: transparent; color: #40534a; }
.button.subtle:hover { background: #edf1ee; }
.button.small { min-height: 34px; padding: 6px 8px; font-size: 13px; }
.icon-button { width: 36px; height: 36px; padding: 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; display: inline-flex; justify-content: center; align-items: center; flex: 0 0 36px; }
.icon-button:hover { background: #edf1ee; border-color: #dce3de; }
.icon-button:disabled { background: transparent; }
.icon-button.destructive:hover { background: #fbeaec; border-color: #edcdd1; }
.notice { border-radius: 5px; padding: 11px 13px; line-height: 1.6; overflow-wrap: anywhere; }
.notice.error { color: #8e2430; background: #fcedee; border: 1px solid #f0ccd0; }
.notice.success { color: #216044; background: #eaf5ed; border: 1px solid #c5dfcc; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span:first-child { font-weight: 550; line-height: 1.5; }
.field + .field { margin-top: 18px; }

.login-view { min-height: 100svh; display: grid; place-items: center; padding: 38px 24px; background: #f6f7f8; }
.login-panel { width: min(100%, 360px); }
.login-brand { display: block; margin-bottom: 20px; border-radius: 13px; object-fit: contain; }
.login-panel h1 { font-size: 27px; }
.login-caption { margin-top: 7px; color: var(--muted); font-size: 15px; }
.login-panel form { margin-top: 30px; }
.login-submit { width: 100%; margin-top: 24px; }
.login-panel .notice { margin-top: 18px; }
.session-check { min-height: 24px; margin-top: 17px; text-align: center; color: var(--muted); font-size: 13px; }

.topbar { min-height: 72px; background: #fff; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; padding: 14px 32px; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand img { border-radius: 8px; object-fit: contain; flex: 0 0 36px; }
.brand span { font-size: 18px; font-weight: 650; line-height: 1.45; }
.account-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.account-name { margin: 0 11px 0 13px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.workspace { max-width: 1540px; margin: 0 auto; padding: 34px 32px 24px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.eyebrow { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; margin-top: 22px; padding-bottom: 23px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.summary > span { display: inline-flex; gap: 7px; align-items: center; }
.summary strong { font-size: 15px; font-weight: 600; color: #283d31; font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; flex: 0 0 7px; background: #a0a8a3; }
.dot.online { background: #418460; }
.dot.pending { background: #b88731; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 22px 0 16px; }
.search-field { display: flex; align-items: center; position: relative; flex: 1 1 250px; max-width: 380px; }
.search-field > .icon { position: absolute; left: 12px; pointer-events: none; opacity: .5; }
.search-field input { width: 100%; padding-left: 38px; }
.filter-field { flex: 0 1 auto; min-width: 0; }
.filter-field select { width: 100%; }
.refresh-control { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.refresh-control > span { font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.workspace > .notice { margin-bottom: 14px; }
.table-frame { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.device-table { width: 100%; min-width: 1090px; border-collapse: collapse; text-align: left; font-size: 13px; }
.device-table th { padding: 14px 17px; height: 61px; background: #f9faf9; color: #637068; font-weight: 550; border-bottom: 1px solid var(--line); white-space: nowrap; }
.device-table td { padding: 18px 17px; vertical-align: middle; border-bottom: 1px solid #e9edea; line-height: 1.6; }
.device-table tr:last-child td { border-bottom: 0; }
.device-table tbody tr:hover { background: #fcfdfc; }
.th-note { display: block; font-size: 11px; color: #7a847d; font-weight: 400; margin-top: 3px; }
.device-cell { width: 200px; max-width: 225px; }
.device-name { display: block; font-size: 14px; font-weight: 600; line-height: 1.55; overflow-wrap: anywhere; }
.device-id { font-family: ui-monospace, Consolas, monospace; display: block; font-size: 11px; margin-top: 4px; color: #818b84; }
.status-badge { display: inline-flex; align-items: center; border-radius: 4px; font-size: 12px; line-height: 20px; padding: 1px 7px; white-space: nowrap; background: #f0f2f1; color: #66716b; }
.status-allowed { color: #2c6b48; background: #eaf3ec; }
.status-pending { color: #8c6522; background: #faf1df; }
.status-disabled { color: #5b626a; background: #edf0f2; }
.status-revoked { color: #8a4146; background: #f8ecee; }
.status-expired, .status-quota_exhausted { color: #9d4830; background: #fbede8; }
.connection-state { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; margin-top: 6px; white-space: nowrap; }
.connection-state.is-online { color: #3b7552; }
.quota-cell { min-width: 170px; }
.quota-text { white-space: nowrap; font-variant-numeric: tabular-nums; }
.quota-progress { display: block; appearance: none; -webkit-appearance: none; width: 130px; height: 4px; margin-top: 9px; border: none; border-radius: 2px; overflow: hidden; background: #e7ece8; }
.quota-progress::-webkit-progress-bar { background: #e7ece8; }
.quota-progress::-webkit-progress-value { background: #6a9e7c; }
.quota-progress::-moz-progress-bar { background: #6a9e7c; }
.quota-progress.exhausted::-webkit-progress-value { background: #bc6650; }
.quota-progress.exhausted::-moz-progress-bar { background: #bc6650; }
.traffic-total { display: block; font-variant-numeric: tabular-nums; white-space: nowrap; }
.traffic-breakdown { display: block; font-variant-numeric: tabular-nums; white-space: nowrap; color: #7b857e; font-size: 11px; margin-top: 3px; }
.expiry-cell, .last-seen-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.expiry-cell time, .last-seen-cell time { display: block; }
.time-date { display: block; }
.time-clock { display: block; color: #7b857e; font-size: 11px; }
.actions-heading { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 1px; }
.row-actions .icon-button { width: 32px; height: 32px; flex-basis: 32px; padding: 7px; }
.row-actions .icon { width: 17px; height: 17px; flex-basis: 17px; }
.table-empty { text-align: center; padding: 54px 18px 48px; width: 100%; min-width: 250px; }
.empty-icon { opacity: .3; display: block; margin: 0 auto 11px; }
.table-empty p { color: var(--muted); margin-bottom: 9px; }
.list-footer { display: flex; justify-content: space-between; gap: 12px; padding: 14px 1px; color: #7a847e; font-size: 12px; }
.is-loading .icon { animation: turn 1s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }

.dialog { width: min(480px, calc(100% - 32px)); padding: 0; border: 1px solid #d4dcd6; border-radius: 8px; color: inherit; background: #fff; box-shadow: 0 18px 70px #12211929; max-height: calc(100svh - 40px); overflow-y: auto; }
.dialog::backdrop { background: #17231b66; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { min-width: 0; overflow-wrap: anywhere; }
.dialog-header > .icon-button { margin-right: -6px; }
.dialog-body { padding: 23px 24px; }
.dialog-body .notice { margin-top: 18px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); padding: 16px 24px; background: #fafbf9; }
.device-identity { font-family: ui-monospace, Consolas, monospace; color: #7e8881; font-size: 11px; overflow-wrap: anywhere; margin-bottom: 19px; }
.policy-fieldset { margin: 23px 0 0; padding: 0; border: 0; min-width: 0; }
.policy-fieldset legend { font-weight: 550; padding: 0; line-height: 1.5; margin-bottom: 11px; }
.policy-fieldset legend .muted { margin-left: 4px; font-size: 11px; font-weight: 400; }
.checkbox-field { display: flex; align-items: center; gap: 8px; width: fit-content; margin-bottom: 10px; line-height: 1.5; }
.number-field { display: flex; align-items: center; border: 1px solid #cbd3ce; border-radius: 5px; overflow: hidden; background: #f5f7f5; }
.number-field input { flex: 1; min-width: 0; border: 0; border-radius: 0; }
.number-field > span { width: 47px; text-align: center; color: var(--muted); flex-shrink: 0; }
.quota-record { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.quota-record strong { font-weight: 550; color: #37473d; display: block; margin-top: 2px; }
.dialog-notice { margin: 0 24px 20px; }
.result-heading { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; margin-bottom: 22px; }
.code-field { font-family: ui-monospace, Consolas, monospace; font-size: 15px; word-break: break-all; background: #f5f7f5; }
#invite-result > .muted { font-size: 12px; margin-top: 9px; }
.invite-summary { margin: 24px 0 0; border-top: 1px solid var(--line); padding-top: 13px; font-size: 13px; }
.invite-summary > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 12px; padding: 6px 0; }
.invite-summary dt { color: var(--muted); }
.invite-summary dd { margin: 0; overflow-wrap: anywhere; }
.compact-dialog { width: min(420px, calc(100% - 32px)); }
.confirm-description { line-height: 1.8; overflow-wrap: anywhere; }
.copy-field { display: flex; gap: 4px; align-items: center; }
.copy-field input, .copy-field textarea { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: #f8faf8; }
.copy-field .icon-button { flex-shrink: 0; }
.pin-copy { align-items: flex-start; }
.pin-copy .icon-button { margin-top: 2px; }
.connection-dialog .dialog-body > .muted { margin-top: 17px; font-size: 12px; }

@media (min-width: 1440px) {
  .device-table { table-layout: fixed; }
  .device-table th:nth-child(1) { width: 19%; }
  .device-table th:nth-child(2) { width: 13%; }
  .device-table th:nth-child(3) { width: 17%; }
  .device-table th:nth-child(4) { width: 15%; }
  .device-table th:nth-child(5) { width: 13%; }
  .device-table th:nth-child(6) { width: 12%; }
  .device-table th:nth-child(7) { width: 11%; }
}

@media (max-width: 900px) {
  .topbar { padding: 12px 22px; gap: 16px; }
  .workspace { padding: 28px 22px 20px; }
  .search-field { max-width: none; }
  .refresh-control { margin-left: 0; }
  .refresh-control > span { display: none; }
  .account-name { display: none; }
}

@media (max-width: 560px) {
  .topbar { min-height: 65px; padding: 12px 16px; gap: 7px; }
  .brand { gap: 8px; }
  .brand span { font-size: 15px; }
  .brand img { width: 30px; height: 30px; flex-basis: 30px; border-radius: 7px; }
  .compact-label { display: none; }
  .account-actions { gap: 0; }
  .account-actions .button { padding: 8px; width: 34px; min-height: 34px; }
  .account-actions .icon-button { width: 32px; height: 34px; flex-basis: 32px; padding: 7px; }
  .workspace { padding: 24px 16px 16px; }
  h1 { font-size: 23px; }
  .page-heading > .button { padding: 8px 11px; font-size: 13px; }
  .summary { gap: 9px 20px; margin-top: 20px; padding-bottom: 20px; font-size: 12px; }
  .summary strong { font-size: 14px; }
  .summary > span:last-child { width: 100%; }
  .toolbar { gap: 9px 8px; margin-top: 18px; }
  .search-field { flex-basis: 100%; }
  .filter-field { flex: 1 1 0; }
  .filter-field select { padding-right: 20px; font-size: 12px; }
  .refresh-control { flex: 0 0 34px; }
  .refresh-control .icon-button { width: 34px; height: 38px; flex-basis: 34px; }
  .dialog { max-height: calc(100svh - 24px); width: calc(100% - 24px); }
  .dialog-header { padding: 14px 17px; }
  .dialog-body { padding: 21px 20px; }
  .dialog-footer { padding: 14px 20px; }
  .dialog-notice { margin-left: 20px; margin-right: 20px; }
  .policy-fieldset legend .muted { display: block; margin: 3px 0 0; }
  .login-view { padding: 30px 25px; }
  .login-panel h1 { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  .is-loading .icon { animation: none; }
}
