[hidden] { display: none !important; }

:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f0f3f8;
    --text: #172033;
    --muted: #68758a;
    --line: #e2e7ef;
    --brand: #275ee7;
    --brand-dark: #1748c9;
    --brand-soft: #e9efff;
    --green: #137a4c;
    --green-soft: #e7f7ef;
    --amber: #966000;
    --amber-soft: #fff4d6;
    --red: #b53434;
    --red-soft: #ffeded;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 14px; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px; background: #111827; color: #e8edf6; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; font-size: 18px; font-weight: 700; padding: 4px 8px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: inline-block; flex: 0 0 auto; background: url('/assets/brand/sun.svg') center / 100% 100% no-repeat; font-size: 0; }
.context { display: grid; gap: 4px; margin: 24px 8px 14px; padding: 12px; border: 1px solid #2b3545; border-radius: 9px; background: #1b2432; }
.context small { color: #97a4b8; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { color: #aeb9ca; border-radius: 8px; padding: 10px 12px; }
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: #26334a; }
.logout { margin-top: auto; display: grid; gap: 8px; padding: 12px 8px 2px; color: #9eabbf; border-top: 1px solid #293344; }
.logout button { border: 0; padding: 0; color: #d1d8e4; background: transparent; text-align: left; }
.content-shell { min-width: 0; }
.topbar { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.user-pill { padding: 6px 10px; color: var(--muted); background: var(--surface-soft); border-radius: 999px; }
.page-content { max-width: 1440px; margin: 0 auto; padding: 24px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.delivery-link-row { display: flex; align-items: center; gap: 9px; margin: 13px 0 9px; }
.delivery-link-row code { min-width: 0; flex: 1; padding: 11px 12px; overflow-wrap: anywhere; border-radius: 8px; background: var(--surface-soft); }
h1 { margin: 0 0 6px; font-size: 24px; line-height: 1.3; }
h2 { margin: 0; font-size: 17px; }
p { margin: 0; color: var(--muted); line-height: 1.6; }
.button, button.primary, button.secondary, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); }
.primary { color: #fff !important; border-color: var(--brand) !important; background: var(--brand) !important; }
.primary:hover { background: var(--brand-dark) !important; }
.secondary { color: var(--text); background: var(--surface); }
.danger-button { color: #fff; border-color: var(--red); background: var(--red); }
.block { width: 100%; }
.center { text-align: center; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric, .panel, .summary-grid article, .delivery-box { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.metric { padding: 16px; }
.metric span, .metric small { color: var(--muted); }
.metric strong { display: block; margin: 7px 0 3px; font-size: 25px; }
.panel, .delivery-box { padding: 17px; margin-bottom: 14px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-title > span { color: var(--muted); }
.split-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.product-list { display: grid; }
.product-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.product-row:first-child { border-top: 0; }
td strong, td small, .product-row small { display: block; }
td small, .product-row small { margin-top: 3px; color: var(--muted); }
.product-row > span { font-weight: 700; }
.warn, .danger-text { color: var(--red) !important; }
.health-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.health-list > div { padding: 18px; border-radius: 9px; background: var(--surface-soft); }
.health-list span { color: var(--muted); }
.health-list strong { display: block; margin-top: 8px; font-size: 26px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.summary-grid article { padding: 15px; display: grid; gap: 7px; }
.summary-grid article span { font-size: 20px; font-weight: 700; }
.summary-grid article small { color: var(--muted); }
.inventory-summary { margin-bottom: 14px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 780px; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; background: var(--surface-soft); }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.status.unactivated { color: var(--amber); background: var(--amber-soft); }
.status.activated, .status.available { color: var(--green); background: var(--green-soft); }
.status.unusable, .status.quarantined { color: var(--red); background: var(--red-soft); }
.status.allocated { color: var(--brand); background: var(--brand-soft); }
.actions { white-space: nowrap; }
.actions > * { margin-right: 9px; }
.text-button { padding: 0; border: 0; color: var(--brand); background: transparent; }
.text-button.danger { color: var(--red); }
.alert { margin-bottom: 14px; padding: 11px 13px; border-radius: 8px; }
.alert.success { color: var(--green); background: var(--green-soft); }
.alert.error { color: var(--red); background: var(--red-soft); }
label { display: grid; gap: 6px; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 39px; padding: 8px 10px; color: var(--text); background: var(--surface); border: 1px solid #cfd7e4; border-radius: 8px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 100px; resize: vertical; }
.inline-form { display: grid; grid-template-columns: 1.5fr .6fr 1fr auto; gap: 12px; align-items: end; }
.list-filter { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 0; }
.list-filter input, .list-filter select { min-width: 150px; width: auto; }
.list-filter input[type="search"] { min-width: 260px; }
.list-filter .live-list-error { color: var(--danger); }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.grid-form .wide { grid-column: span 2; }
.field-error { min-height: 16px; color: var(--red); }
.delivery-box { border-color: #b9caff; background: #f7f9ff; }
.delivery-item { padding: 12px 0; border-top: 1px solid var(--line); }
.delivery-item:first-of-type { border-top: 0; }
.delivery-item > div { display: flex; justify-content: space-between; gap: 10px; }
pre { overflow-x: auto; padding: 12px; border-radius: 8px; color: #e8edf6; background: #151c28; white-space: pre-wrap; word-break: break-all; }
.credential-panel { max-width: 820px; }
dl { margin: 0; display: grid; }
dl > div { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-all; }
dialog { width: min(480px, calc(100% - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-close { float: right; border: 0; color: var(--muted); background: transparent; font-size: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.auth-page, .activation-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #edf2ff, #f7f8fb 48%, #edf7f3); }
.login-panel, .activation-card { width: min(440px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 18px 55px rgba(24, 36, 58, .10); }
.login-brand { padding: 0 0 22px; }
.login-panel h1, .activation-card h1 { margin-top: 8px; }
.stack-form { display: grid; gap: 14px; margin-top: 20px; }
.demo-box { display: grid; gap: 5px; margin-top: 18px; padding: 12px; color: var(--muted); border-radius: 8px; background: var(--surface-soft); }
.activation-card .status { margin-bottom: 8px; }
.activation-card dl { margin: 18px 0; }
.notice { margin: 16px 0; padding: 11px; color: #345189; border-radius: 8px; background: var(--brand-soft); line-height: 1.5; }
.privacy-note { margin-top: 14px; font-size: 12px; text-align: center; }
.activation-card .secondary { margin-top: 9px; }
.error-state { text-align: center; }
.error-icon { width: 56px; height: 56px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: 28px; font-weight: 700; }
.metric-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.muted-hint { color: var(--muted); }
.check-col { width: 34px; padding-right: 0; }
.check-col input { width: 16px; min-height: 16px; padding: 0; }
.batch-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.batch-bar button { min-height: 32px; padding: 5px 12px; }
.batch-bar .batch-count { margin-right: auto; color: var(--muted); }
.inline-check { display: flex; align-items: center; gap: 7px; color: var(--text); }
.inline-check input { width: 16px; min-height: 16px; padding: 0; }
.wide-dialog { width: min(720px, calc(100% - 32px)); }
.dialog-form { margin-top: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dialog-form .wide { grid-column: span 2; }
.dialog-actions.wide { grid-column: span 2; }
.token-value { margin-right: 8px; }
.offscreen { position: absolute; width: 1px; height: 1px; min-height: 0; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
.portal-shell { width: min(880px, 100%); text-align: center; }
.portal-shell .login-brand { justify-content: center; padding-bottom: 10px; }
.portal-shell h1 { font-size: 28px; }
.portal-shell > p { max-width: 520px; margin: 0 auto; }
.portal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 26px; text-align: left; }
.portal-card { display: grid; align-content: start; gap: 8px; padding: 20px; color: var(--text); border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 12px 34px rgba(24, 36, 58, .07); transition: border-color .16s ease, transform .16s ease; }
.portal-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.portal-card strong { font-size: 17px; }
.portal-card small { color: var(--muted); line-height: 1.6; }
.portal-card .portal-go { margin-top: 6px; color: var(--brand); font-weight: 600; }
.portal-tag { justify-self: start; display: inline-flex; padding: 3px 9px; border-radius: 999px; font-size: 12px; }
.portal-tag.admin { color: var(--brand); background: var(--brand-soft); }
.portal-tag.agent { color: var(--green); background: var(--green-soft); }
.portal-tag.public { color: var(--amber); background: var(--amber-soft); }
.login-panel .portal-tag { margin-bottom: 10px; }
.login-panel.login-admin { border-top: 3px solid var(--brand); }
.login-panel.login-agent { border-top: 3px solid var(--green); }
.login-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.compact { min-height: 31px; padding: 5px 10px; }
.profile-form { max-width: 560px; }
.product-management-row { display: flex; gap: 9px; align-items: center; }
.product-edit-row { flex: 1; display: grid; grid-template-columns: 1fr 1.2fr .8fr .8fr .65fr auto auto; gap: 9px; align-items: center; }
.product-status-form { flex: 0 0 auto; }
.token-selection { display: grid; gap: 6px; }
.token-selection strong { color: var(--text); }
.token-picker-list { display: grid; gap: 8px; max-height: 380px; margin-top: 14px; overflow-y: auto; }
.token-picker-item { width: 100%; display: grid; grid-template-columns: 1.1fr 1fr auto; gap: 10px; align-items: center; padding: 11px; text-align: left; color: var(--text); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.token-picker-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.token-picker-item.bound { opacity: .55; cursor: not-allowed; }
.token-picker-item span, .token-picker-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-editor { display: flex; align-items: center; gap: 5px; min-width: 110px; }
.usage-editor input { width: 74px; }
.tenant-table { min-width: 1450px; }
.permission-editor { min-width: 250px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; }
.permission-editor label { display: flex; align-items: center; gap: 6px; color: var(--text); white-space: nowrap; font-size: 12px; }
.permission-editor input { width: 15px; min-height: 15px; padding: 0; }
.permission-editor button { grid-column: 1 / -1; justify-self: start; }
.sms-search-form { grid-template-columns: minmax(260px, 1fr) auto auto; align-items: end; }
.verification-code { font-size: 17px; letter-spacing: .06em; }
.welcome-page { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 56px 24px; overflow: hidden;
    background: radial-gradient(125% 78% at 50% -8%, #fff3de 0%, rgba(255, 243, 222, 0) 58%), linear-gradient(180deg, #fffdfa 0%, #fdf8f2 52%, #fff5e8 100%); }
/* 太阳光晕：给版面一个视觉焦点，不靠堆元素撑场面 */
.welcome-glow { position: absolute; left: 50%; top: 21%; width: min(760px, 130vw); height: min(760px, 130vw); transform: translate(-50%, -50%); pointer-events: none;
    background: radial-gradient(circle, rgba(255, 166, 56, .20) 0%, rgba(255, 166, 56, .085) 36%, rgba(255, 166, 56, 0) 66%); }
.welcome { position: relative; width: min(760px, 100%); text-align: center; }
.welcome-mark { width: 88px; height: 88px; margin: 0 auto; border-radius: 25px; background: url('/assets/brand/sun.svg') center / 100% 100% no-repeat;
    box-shadow: 0 20px 44px rgba(226, 122, 30, .28), 0 3px 10px rgba(226, 122, 30, .16); }
/* 字距会在末字后留白，text-indent 补回来才是真正的光学居中 */
.welcome-wordmark { margin: 26px 0 0; color: #b0611b; font-size: 13px; font-weight: 700; letter-spacing: .44em; text-indent: .44em; text-transform: uppercase; }
.welcome-rule { width: 132px; height: 1px; margin: 26px auto 0; background: linear-gradient(90deg, rgba(244, 116, 31, 0), rgba(244, 116, 31, .55), rgba(244, 116, 31, 0)); }
.welcome-quote { margin: 34px 0 0; color: #26303f; font-size: clamp(21px, 3.3vw, 33px); font-weight: 600; line-height: 1.92; letter-spacing: .012em; }
.welcome-quote .line { display: block; }
.welcome-quote .accent { color: #d9600f; background: linear-gradient(94deg, #f0921f, #dd530b); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.welcome-tagline { display: inline-flex; align-items: center; gap: 10px; margin: 38px 0 0; padding: 9px 19px; border: 1px solid rgba(226, 148, 60, .3); border-radius: 999px;
    background: rgba(255, 255, 255, .62); color: #6c6357; font-size: 13.5px; letter-spacing: .02em; box-shadow: 0 4px 16px rgba(180, 120, 50, .07); }
.welcome-tagline strong { color: #c2570f; font-weight: 700; }
.welcome-tagline i { color: #d7bb9a; font-style: normal; }
.welcome-tagline .dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: linear-gradient(#ffb020, #f4741f); box-shadow: 0 0 0 3px rgba(244, 116, 31, .13); }
@keyframes welcomeRise { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: none; } }
.welcome > * { animation: welcomeRise .72s cubic-bezier(.22, .7, .3, 1) both; }
.welcome-wordmark { animation-delay: .07s; }
.welcome-rule { animation-delay: .13s; }
.welcome-quote { animation-delay: .19s; }
.welcome-tagline { animation-delay: .27s; }
@media (max-width: 560px) {
    .welcome-mark { width: 68px; height: 68px; border-radius: 20px; }
    .welcome-wordmark { margin-top: 20px; font-size: 12px; }
    .welcome-rule { width: 96px; margin-top: 20px; }
    .welcome-quote { margin-top: 26px; line-height: 1.85; }
    .welcome-tagline { margin-top: 30px; padding: 8px 15px; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
    .welcome > * { animation: none; }
}
.support-fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1px solid rgba(244, 116, 31, .28); border-radius: 999px; background: rgba(255, 255, 255, .62); color: #b8530e; font-size: 13.5px; font-weight: 600; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 8px 26px rgba(120, 80, 30, .14); transition: background-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.support-fab:hover { background: rgba(255, 255, 255, .92); transform: translateY(-2px); box-shadow: 0 12px 32px rgba(120, 80, 30, .2); }
.support-fab:focus-visible { outline: 3px solid rgba(244, 116, 31, .35); outline-offset: 3px; }
.support-fab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.support-dialog { width: min(340px, calc(100% - 32px)); text-align: center; }
.support-dialog h2 { margin-bottom: 6px; }
.support-dialog > p { margin-bottom: 16px; }
.support-qr { width: 260px; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; }
@media (max-width: 480px) {
    .support-fab { right: 14px; bottom: 14px; padding: 9px 14px; font-size: 13px; }
}
@media (max-width: 900px) {
    .metric-grid, .metric-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .portal-grid { grid-template-columns: 1fr; }
    .split-grid { grid-template-columns: 1fr; }
    .inline-form, .grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-form .wide { grid-column: span 1; }
    .dialog-form .wide, .dialog-actions.wide { grid-column: span 2; }
    .product-management-row { align-items: stretch; flex-direction: column; }
    .product-edit-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
    .metric-grid-3 { grid-template-columns: 1fr; }
    .dialog-form { grid-template-columns: 1fr; }
    .dialog-form .wide, .dialog-actions.wide { grid-column: span 1; }
    .batch-bar { flex-wrap: wrap; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 10px; }
    .sidebar .context { display: none; }
    .sidebar nav { grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
    .sidebar nav a { text-align: center; }
    .logout { display: flex; justify-content: space-between; margin-top: 8px; }
    .topbar { display: none; }
    .page-content { padding: 16px; }
    .page-heading { flex-direction: column; }
    .page-actions, .delivery-link-row { width: 100%; align-items: stretch; flex-direction: column; }
    .metric-grid, .summary-grid, .inline-form, .grid-form { grid-template-columns: 1fr; }
    dl > div { grid-template-columns: 1fr; gap: 5px; }
    .product-edit-row, .token-picker-item { grid-template-columns: 1fr; }
}
