:root {
  color-scheme: light;
  --navy: #101d32;
  --ink: #17304c;
  --muted: #52657a;
  --canvas: #f1f5f9;
  --line: #dbe4ed;
  --white: #fff;
  --teal: #08786d;
  --teal-dark: #075e56;
  --teal-light: #e5f3ef;
  --danger: #a62936;
  --radius: .875rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; min-width: 16rem; min-height: 100vh; color: var(--ink); background: var(--canvas); }
h1, h2, p, dl, dd { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 3px solid #32a99e; outline-offset: 3px; }

.layout { width: min(100% - 3rem, 76rem); margin-inline: auto; }
.topbar { background: var(--navy); color: var(--white); }
.topbar-inner { min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .625rem; font-size: 1.375rem; font-weight: 750; letter-spacing: -.045em; white-space: nowrap; }
.brand-mark { position: relative; display: inline-block; width: 1.875rem; height: 1.875rem; border-radius: .45rem; background: #68dfc4; }
.brand-mark::before, .brand-mark::after { position: absolute; top: .5rem; left: .82rem; width: .23rem; height: .875rem; border-radius: .125rem; background: var(--navy); content: ""; }
.brand-mark::before { transform: rotate(45deg); }
.brand-mark::after { transform: rotate(-45deg); }

.dashboard-main { padding-block: 2.6rem 3rem; }
.page-heading, .users-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.page-heading { margin-bottom: 1.65rem; }
h1 { color: var(--navy); font-size: clamp(1.875rem, 4vw, 2.625rem); font-weight: 750; letter-spacing: -.04em; line-height: 1.2; }
h2 { color: var(--navy); font-size: 1.25rem; font-weight: 700; }
.period { margin-top: .45rem; color: var(--muted); font-size: .9375rem; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: .4rem; min-height: 2.5rem; padding: .45rem .85rem; border: 1px solid transparent; border-radius: .5rem; font-weight: 650; line-height: 1.35; white-space: nowrap; }
.primary { min-height: 2.75rem; padding-inline: 1.05rem; color: var(--white); background: var(--teal); }
.primary:hover:not(:disabled) { background: var(--teal-dark); }
.primary span { font-size: 1.25rem; line-height: 1; }
.secondary { border-color: #cbd7e3; color: var(--ink); background: var(--white); }
.secondary:hover:not(:disabled) { background: #edf3f8; }
.logout { border-color: #5e7089; color: var(--white); background: transparent; }
.logout:hover:not(:disabled) { background: #283951; }
.danger { color: var(--white); background: var(--danger); }
.danger:hover:not(:disabled) { background: #86202c; }
.danger-quiet { border-color: #e8c3c8; color: var(--danger); background: var(--white); }
.danger-quiet:hover:not(:disabled) { background: #fff0f2; }
.copy-link { color: var(--teal-dark); background: var(--teal-light); }
.copy-link:hover:not(:disabled) { background: #d1ebe3; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.summary-card { display: flex; flex-direction: column; justify-content: space-between; gap: .45rem; min-height: 7.1rem; padding: 1.15rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.summary-card dt { color: var(--muted); font-weight: 620; }
.summary-card dd { color: var(--navy); font-size: clamp(1.55rem, 3vw, 2.25rem); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.045em; line-height: 1.2; overflow-wrap: anywhere; }
.summary-card:nth-child(2) dd { color: var(--teal-dark); }

.notice, .notification { padding: .75rem 1rem; border: 1px solid #badec8; border-radius: .6rem; color: #0f5144; background: #eef9f4; }
.notice { margin-bottom: 1rem; }
.warning { border-color: #eecb89; color: #6d4300; background: #fff7e7; }
.notification { position: fixed; z-index: 2; inset: auto 1.25rem 1.25rem auto; max-width: min(30rem, 100% - 2.5rem); box-shadow: 0 .35rem 1.25rem #101d3220; }
.notification.error { border-color: #ebbdc3; color: #8d2632; background: #fff0f2; }

.users-panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.users-heading { min-height: 4.35rem; padding: .95rem 1.2rem; }
.users-heading .button, .logout { font-size: .875rem; }
.table-state { padding: 2.3rem 1rem; border-top: 1px solid var(--line); color: var(--muted); text-align: center; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { border-block: 1px solid var(--line); background: #f5f8fb; }
thead th { padding: .75rem 1rem; color: var(--muted); font-size: .875rem; font-weight: 700; white-space: nowrap; }
tbody tr + tr { border-top: 1px solid var(--line); }
tbody th, tbody td { padding: 1.05rem 1rem; text-align: left; vertical-align: middle; }
thead th:first-child, tbody th { padding-left: 1.2rem; }
thead th:last-child, tbody td:last-child { padding-right: 1.2rem; }
.user-cell { width: 24%; min-width: 10rem; }
.user-name, .user-remark { display: block; overflow-wrap: anywhere; }
.user-name { color: var(--navy); font-weight: 700; }
.user-remark, .remaining, .last-traffic, .quota { color: var(--muted); font-size: .875rem; font-weight: 500; }
.user-remark { margin-top: .15rem; }
.connection-cell { white-space: nowrap; }
.connection { display: inline-flex; align-items: center; gap: .4rem; min-height: 1.75rem; padding: .125rem .55rem; border-radius: 999px; color: #475e75; background: #edf2f7; font-size: .875rem; font-weight: 650; }
.connection::before { width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; content: ""; }
.connection.online { color: #076b58; background: #e2f4ec; }
.connection.disabled { color: #8d3540; background: #fae9ed; }
.connection.unknown { color: #6d4300; background: #fff3dc; }
.usage-cell { min-width: 12rem; font-variant-numeric: tabular-nums; }
.usage-values { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem; }
.usage-values strong { font-size: .9375rem; }
.usage-bar { display: block; width: 100%; height: .38rem; appearance: none; margin-block: .4rem .28rem; overflow: hidden; border: 0; border-radius: 99rem; background: #e3ebf3; }
.usage-bar::-webkit-progress-bar { border-radius: 99rem; background: #e3ebf3; }
.usage-bar::-webkit-progress-value { border-radius: 99rem; background: var(--teal); }
.usage-bar::-moz-progress-bar { border-radius: 99rem; background: var(--teal); }
.usage-bar.full::-webkit-progress-value { background: var(--danger); }
.usage-bar.full::-moz-progress-bar { background: var(--danger); }
.traffic-cell { min-width: 8rem; }
.last-traffic { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.row-actions .button { min-height: 2.25rem; padding-inline: .5rem; font-size: .875rem; }
.mobile-label { display: none; }

.auth-screen { display: grid; min-height: 100vh; min-height: 100dvh; place-items: center; padding: 1.5rem; background: radial-gradient(ellipse at 30% 0%, #213e5d, var(--navy) 72%); }
.auth-card { width: min(100%, 27rem); padding: clamp(1.45rem, 6vw, 2.35rem); border: 1px solid #d5e0eb; border-radius: 1rem; background: var(--white); box-shadow: 0 1rem 3.5rem #030e2450; }
.auth-card h1 { margin-block: 1.3rem 1.4rem; font-size: 1.875rem; }
.loading-card p { margin-top: 1.25rem; color: var(--muted); }
.form-stack { display: flex; flex-direction: column; gap: .45rem; }
.form-stack label, dialog > label { font-weight: 650; }
.form-stack label:not(:first-child) { margin-top: .45rem; }
input, textarea { width: 100%; padding: .62rem .75rem; border: 1px solid #aebed0; border-radius: .5rem; color: var(--navy); background: var(--white); }
input { min-height: 2.75rem; }
.login-submit { margin-top: .8rem; }
.form-error { margin-top: .35rem; color: var(--danger); }

dialog { width: min(30rem, 100% - 2rem); max-height: calc(100% - 2rem); padding: 1.45rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--white); box-shadow: 0 .65rem 2.5rem #030e2435; }
dialog::backdrop { background: #101d3299; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; gap: .625rem; }
.dialog-heading { justify-content: space-between; margin-bottom: 1rem; }
.dialog-actions { justify-content: flex-end; margin-top: .9rem; }
.dialog-description { overflow-wrap: anywhere; }
.icon-button { display: grid; width: 2.25rem; height: 2.25rem; padding: 0; place-items: center; border: 0; border-radius: .45rem; color: var(--muted); background: #edf3f8; font-size: 1.5rem; line-height: 1; }
.icon-button:hover { background: #e2ebf4; }
.field-note { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.copy-value { display: block; margin-top: .35rem; resize: vertical; overflow-wrap: anywhere; }

@media (max-width: 56rem) {
  .row-actions { max-width: 11.2rem; }
}

@media (max-width: 46rem) {
  .layout { width: calc(100% - 2rem); }
  .dashboard-main { padding-block: 1.65rem 2rem; }
  .page-heading { margin-bottom: 1.2rem; }
  .summary { gap: .55rem; }
  .summary-card { min-height: 6rem; padding: .65rem; }
  .summary-card dt { font-size: .875rem; }
  .summary-card dd { font-size: 1.5rem; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; padding: 0; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
  tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .8rem 1rem; padding: 1rem; }
  tbody tr:first-child { border-top: 1px solid var(--line); }
  tbody td, tbody th, tbody td:last-child { min-width: 0; padding: 0; }
  .user-cell { width: auto; }
  .mobile-label { display: block; margin-bottom: .23rem; color: var(--muted); font-size: .875rem; font-weight: 650; }
  .connection-cell { align-self: start; text-align: right; }
  .connection-cell .mobile-label { display: none; }
  .traffic-cell { min-width: 6.5rem; }
  .actions-cell { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: .65rem !important; }
  .row-actions { max-width: none; }
  .row-actions .button { min-height: 2.5rem; padding-inline: .65rem; }
}

@media (max-width: 23rem) {
  .layout { width: calc(100% - 1.25rem); }
  .summary { gap: .35rem; }
  .summary-card { padding-inline: .5rem; }
  .summary-card dd { font-size: 1.3rem; }
  .row-actions .button { padding-inline: .48rem; }
}
