:root {
  color-scheme: light;
  --bg: #f4f7f7;
  --surface: #ffffff;
  --surface-muted: #eef3f2;
  --text: #12201e;
  --muted: #63716f;
  --line: #d9e2e0;
  --accent: #087e68;
  --accent-hover: #066b59;
  --accent-soft: #ddf2ec;
  --danger: #b42318;
  --danger-soft: #ffebe9;
  --warning: #946200;
  --warning-soft: #fff2cc;
  --sidebar: #132925;
  --shadow: 0 24px 70px rgba(31, 61, 55, 0.12);
  --radius-sm: 9px;
  --radius-md: 14px;
  --radius-lg: 20px;
  font-family: "Segoe UI Variable", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100dvh; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header { height: 72px; max-width: 1200px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -0.02em; }
.brand-mark { width: 36px; height: 36px; display: inline-grid; place-items: center; color: #fff; background: var(--accent); border-radius: 11px; }
.large-mark { width: 48px; height: 48px; margin-bottom: 20px; border-radius: var(--radius-md); font-size: 19px; }
.header-link, .back-link { color: var(--muted); font-size: 14px; font-weight: 650; transition: color .18s ease; }
.header-link:hover, .back-link:hover { color: var(--accent); }

.customer-shell { max-width: 1120px; min-height: calc(100dvh - 72px); margin: 0 auto; padding: 56px 24px 88px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(390px, 0.82fr); gap: 72px; align-items: center; }
.intro-panel { align-self: center; }
.section-label { margin: 0 0 11px; color: var(--accent); font-size: 12px; line-height: 1.2; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.intro-panel h1 { max-width: 580px; margin: 0; font-size: clamp(42px, 6vw, 70px); line-height: .98; letter-spacing: -.055em; }
.intro-copy { max-width: 560px; margin: 28px 0 0; color: var(--muted); font-size: 18px; line-height: 1.75; }
.trust-list { margin-top: 36px; display: grid; gap: 15px; color: #3f514e; font-size: 14px; }
.trust-list div { display: flex; align-items: center; gap: 12px; }
.trust-list i { width: 20px; color: var(--accent); text-align: center; }

.auth-panel, .account-panel { background: var(--surface); border: 1px solid rgba(199, 214, 211, .8); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.auth-panel { padding: 34px; }
.panel-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.icon-box { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); }
.panel-heading h2, .account-panel h2 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.field { display: grid; gap: 8px; margin-bottom: 18px; color: #30413e; font-size: 13px; font-weight: 700; }
.input-wrap { min-height: 48px; display: flex; align-items: center; gap: 11px; padding: 0 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color .18s ease, box-shadow .18s ease; }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 126, 104, .13); }
.input-wrap > i { color: #84918f; }
.input-wrap input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.input-wrap input::placeholder { color: #9ba6a4; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; flex: 0 0 auto; border: 0; color: var(--muted); background: transparent; border-radius: var(--radius-sm); }
.icon-button:hover { color: var(--text); background: var(--surface-muted); }
.icon-button.bordered { border: 1px solid var(--line); background: var(--surface); }
.icon-button:disabled { cursor: not-allowed; opacity: .4; }
.primary-button, .secondary-button, .text-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; border: 0; border-radius: var(--radius-sm); font-size: 14px; font-weight: 750; white-space: nowrap; transition: background .18s ease, border-color .18s ease, transform .12s ease; }
.primary-button { color: #fff; background: var(--accent); }
.primary-button:hover { background: var(--accent-hover); }
.secondary-button { color: var(--text); background: var(--surface); border: 1px solid var(--line); }
.secondary-button:hover { border-color: #a7b8b4; background: var(--surface-muted); }
.text-button { padding-inline: 9px; color: var(--muted); background: transparent; }
.text-button:hover { color: var(--text); background: var(--surface-muted); }
.primary-button:active, .secondary-button:active, .text-button:active { transform: translateY(1px); }
.primary-button:disabled, .secondary-button:disabled { cursor: wait; opacity: .65; }
.full-button { width: 100%; }
.form-error { min-height: 18px; margin: -4px 0 12px; color: var(--danger); font-size: 13px; }
.privacy-note { display: flex; align-items: flex-start; gap: 8px; margin: 18px 0 0; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.6; }

.account-panel { grid-column: 1 / -1; padding: 36px; }
.account-topline { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.account-meta { margin-top: 28px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.account-meta div { min-width: 0; padding: 18px 20px; display: grid; gap: 8px; }
.account-meta div + div { border-left: 1px solid var(--line); }
.account-meta span { color: var(--muted); font-size: 12px; }
.account-meta strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.contact-card { margin-top: 28px; padding: 24px; display: flex; align-items: center; justify-content: space-between; gap: 32px; background: var(--surface-muted); border-radius: var(--radius-md); }
.contact-copy { display: flex; align-items: flex-start; gap: 15px; }
.contact-copy .icon-box { width: 46px; height: 46px; font-size: 20px; }
.contact-copy h3 { margin: 2px 0 8px; font-size: 19px; letter-spacing: -.02em; }
.contact-copy p { max-width: 440px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.contact-copy small { display: block; margin-top: 12px; color: var(--accent); font-size: 12px; font-weight: 750; }
.qr-link { width: 220px; flex: 0 0 auto; padding: 10px; display: grid; gap: 8px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); text-align: center; transition: border-color .18s ease, transform .18s ease; }
.qr-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.qr-link img { width: 100%; height: auto; display: block; border-radius: var(--radius-sm); }
.qr-link span { font-size: 11px; font-weight: 700; }
.lookup-action { margin-top: 28px; padding: 23px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--surface-muted); border-radius: var(--radius-md); }
.lookup-action h3 { margin: 0 0 6px; font-size: 17px; }
.lookup-action p { margin: 0; color: var(--muted); font-size: 13px; }
.results-region { margin-top: 22px; }
.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); border: 1px dashed #bdcbc8; border-radius: var(--radius-md); }
.empty-state > i { font-size: 24px; color: #82908d; }
.empty-state h3 { margin: 13px 0 6px; color: var(--text); font-size: 15px; }
.empty-state p { margin: 0; font-size: 13px; }
.mail-list { display: grid; gap: 10px; }
.mail-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 17px 18px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.mail-row h3 { margin: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.mail-row p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.code-group { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.code-button { min-height: 40px; padding: 0 13px; border: 1px solid #acd6cd; color: #075d4e; background: var(--accent-soft); border-radius: var(--radius-sm); font-family: "Cascadia Mono", Consolas, monospace; font-size: 17px; font-weight: 800; letter-spacing: .08em; }
.code-button:hover { border-color: var(--accent); }
.no-code { color: var(--muted); font-size: 12px; }
.skeleton { height: 76px; border-radius: var(--radius-md); background: linear-gradient(90deg, #edf1f0 25%, #f8faf9 50%, #edf1f0 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

.admin-body { background: #f1f4f3; }
.admin-login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-dialog { width: min(100%, 430px); padding: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.login-dialog h1 { margin: 0; font-size: 34px; letter-spacing: -.04em; }
.login-dialog > p:not(.section-label):not(.form-error) { margin: 11px 0 28px; color: var(--muted); line-height: 1.6; }
.back-link { margin-top: 22px; display: flex; justify-content: center; gap: 8px; }
.admin-app { min-height: 100dvh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; padding: 24px 18px; display: flex; flex-direction: column; color: #dce9e6; background: var(--sidebar); }
.inverse-brand { padding: 0 10px 27px; color: #fff; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item { width: 100%; min-height: 43px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 0; color: #aebfbb; background: transparent; border-radius: var(--radius-sm); font-size: 14px; font-weight: 650; text-align: left; }
.nav-item i { width: 18px; text-align: center; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.09); }
.sidebar-note { margin-top: auto; padding: 15px; color: #b6c8c4; background: rgba(255,255,255,.055); border-radius: var(--radius-md); font-size: 12px; line-height: 1.6; }
.sidebar-note i { color: #6dd5bf; }
.sidebar-note p { margin: 9px 0 0; }
.logout-nav { margin-top: 12px; }
.admin-main { min-width: 0; padding: 40px clamp(24px, 4vw, 56px) 64px; }
.admin-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.admin-header h1 { margin: 0; font-size: clamp(28px, 3.2vw, 40px); letter-spacing: -.04em; }
.header-actions { display: flex; gap: 10px; }
.stats-grid { margin-top: 32px; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.stats-grid article { padding: 20px 22px; display: grid; gap: 5px; }
.stats-grid article + article { border-left: 1px solid var(--line); }
.stats-grid span { color: var(--muted); font-size: 12px; }
.stats-grid strong { font-family: "Cascadia Mono", Consolas, monospace; font-size: 26px; letter-spacing: -.04em; }
.stats-grid small { color: #8b9795; font-size: 11px; }
.table-section { margin-top: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.table-toolbar { padding: 15px 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.search-box { width: min(340px, 100%); height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--surface-muted); border: 1px solid transparent; border-radius: var(--radius-sm); }
.search-box:focus-within { border-color: var(--accent); }
.search-box i { color: #84918f; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.select-wrap { height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted); font-size: 12px; }
.select-wrap select { border: 0; outline: 0; color: var(--text); background: transparent; font-weight: 650; }
.table-toolbar #refreshPage { margin-left: auto; }
.table-status { min-height: 0; padding: 0 18px; color: var(--muted); font-size: 12px; }
.table-status:not(:empty) { padding-block: 10px; border-bottom: 1px solid var(--line); }
.account-table-wrap { overflow-x: auto; }
.account-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.account-table th { padding: 12px 16px; color: var(--muted); background: #fafcfc; font-size: 11px; font-weight: 750; text-align: left; white-space: nowrap; }
.account-table td { padding: 15px 16px; border-top: 1px solid #e7eceb; white-space: nowrap; }
.account-table td:first-child { max-width: 290px; overflow: hidden; font-weight: 650; text-overflow: ellipsis; }
.account-table td:last-child { text-align: right; }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.plan-badge, .status-badge { display: inline-flex; min-height: 25px; align-items: center; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.plan-pro, .plan-pro_plus, .plan-ultra, .plan-team { color: #075d4e; background: var(--accent-soft); }
.plan-free, .plan-unknown { color: #566360; background: #edf1f0; }
.status-active { color: #075d4e; background: var(--accent-soft); }
.status-free, .status-unknown { color: #566360; background: #edf1f0; }
.status-unchecked, .status-network_error, .status-api_error { color: var(--warning); background: var(--warning-soft); }
.status-invalid_token, .status-expired_token, .status-canceled, .status-past_due { color: var(--danger); background: var(--danger-soft); }
.pagination { padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination > div { display: flex; gap: 7px; }

.app-dialog { width: min(92vw, 500px); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgba(13, 31, 27, .45); backdrop-filter: blur(3px); }
.app-dialog form { padding: 26px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 0; font-size: 21px; }
.dialog-note { margin: 16px 0 22px; padding: 13px 14px; color: var(--muted); background: var(--surface-muted); border-radius: var(--radius-sm); font-size: 12px; line-height: 1.6; }
.copy-field { min-height: 46px; display: flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.copy-field input { min-width: 0; flex: 1; padding: 0 12px; border: 0; outline: 0; color: var(--text); background: var(--surface); }
.copy-field button { min-width: 74px; border: 0; border-left: 1px solid var(--line); color: var(--accent); background: var(--surface-muted); font-size: 12px; font-weight: 750; }
.copy-field button i { margin-right: 5px; }
.select-field { min-height: 46px; display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.select-field select { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.token-valid { color: #075d4e; background: var(--accent-soft); }
.token-invalid, .token-expired { color: var(--danger); background: var(--danger-soft); }
.token-unchecked, .token-network_error, .token-api_error { color: var(--warning); background: var(--warning-soft); }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: grid; gap: 9px; pointer-events: none; }
.toast { max-width: 340px; padding: 12px 15px; color: #fff; background: #213d37; border-radius: var(--radius-sm); box-shadow: 0 12px 35px rgba(15, 40, 34, .2); font-size: 13px; animation: toast-in .2s ease both; }
.toast.error { background: #8e2d25; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 980px) {
  .customer-shell { grid-template-columns: 1fr; gap: 42px; align-items: start; padding-top: 40px; }
  .intro-panel h1 { max-width: 720px; }
  .auth-panel { max-width: 600px; width: 100%; }
  .admin-app { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .sidebar .brand > span:last-child, .nav-item span, .sidebar-note, .inverse-brand { justify-content: center; }
  .inverse-brand { padding-inline: 0; }
  .inverse-brand > span:last-child, .nav-item span, .sidebar-note { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid article:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .stats-grid article:nth-child(4) { border-top: 1px solid var(--line); }
}

@media (max-width: 720px) {
  .site-header { height: 64px; padding-inline: 18px; }
  .customer-shell { min-height: calc(100dvh - 64px); padding: 28px 16px 60px; }
  .intro-panel h1 { font-size: 42px; }
  .intro-copy { margin-top: 20px; font-size: 16px; }
  .trust-list { margin-top: 26px; }
  .auth-panel, .account-panel { padding: 22px; border-radius: var(--radius-md); }
  .account-topline { align-items: flex-start; }
  .account-meta { grid-template-columns: 1fr; }
  .account-meta div + div { border-left: 0; border-top: 1px solid var(--line); }
  .lookup-action { align-items: stretch; flex-direction: column; }
  .lookup-action .primary-button { width: 100%; }
  .contact-card { align-items: stretch; flex-direction: column; }
  .qr-link { width: min(100%, 260px); align-self: center; }
  .mail-row { grid-template-columns: 1fr; }
  .code-group { justify-content: flex-start; }
  .admin-app { display: block; }
  .sidebar { position: static; width: 100%; height: 64px; padding: 0 16px; flex-direction: row; align-items: center; gap: 8px; }
  .inverse-brand { margin-right: auto; padding: 0; }
  .inverse-brand > span:last-child { display: inline; }
  .sidebar nav { display: flex; }
  .sidebar .nav-item { width: 42px; min-height: 42px; }
  .sidebar-note { display: none; }
  .logout-nav { margin: 0; }
  .admin-main { padding: 28px 16px 50px; }
  .admin-header { align-items: stretch; flex-direction: column; }
  .header-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .stats-grid { margin-top: 24px; }
  .stats-grid article { padding: 16px; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .select-wrap { justify-content: space-between; }
  .table-toolbar #refreshPage { margin-left: 0; }
  .account-table { min-width: 900px; }
  .login-dialog { padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1715;
    --surface: #14211f;
    --surface-muted: #1b2b28;
    --text: #edf5f3;
    --muted: #9caca8;
    --line: #30413d;
    --accent: #47c5aa;
    --accent-hover: #62d4ba;
    --accent-soft: #193b33;
    --danger: #ff8e84;
    --danger-soft: #4c2421;
    --warning: #efc66b;
    --warning-soft: #42371c;
    --sidebar: #091411;
    --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  }
  .trust-list, .field { color: #c7d5d2; }
  .input-wrap > i, .search-box i, .empty-state > i { color: #8ca09b; }
  .input-wrap input::placeholder { color: #72837f; }
  .auth-panel, .account-panel, .login-dialog, .stats-grid, .table-section, .app-dialog { border-color: var(--line); }
  .skeleton { background: linear-gradient(90deg, #1a2926 25%, #243633 50%, #1a2926 75%); background-size: 200% 100%; }
  .admin-body { background: var(--bg); }
  .account-table th { background: #172522; }
  .account-table td { border-color: var(--line); }
  .plan-free, .plan-unknown { color: #c5d1ce; background: #293734; }
  .plan-pro, .plan-pro_plus, .plan-ultra, .plan-team, .status-active, .token-valid { color: #8ce2cf; }
  .status-free, .status-unknown { color: #c5d1ce; background: #293734; }
  .code-button { color: #a5ecdc; border-color: #347363; }
  .copy-field button { color: #83dfcb; }
  .qr-link { background: #f5f7f7; }
}
