:root {
  color-scheme: light;
  --bg: #f3f6f9;
  --sidebar: #10252e;
  --sidebar-soft: #19343e;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --text: #20343d;
  --muted: #778994;
  --line: #e2e9ee;
  --accent: #0e8188;
  --accent-strong: #086a70;
  --accent-soft: #e9f6f5;
  --blue: #3977b6;
  --blue-soft: #edf5fc;
  --warn: #9b6b1d;
  --danger: #bf4b50;
  --code: #f6f8fa;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; min-height: 38px; border: 1px solid var(--accent); border-radius: 7px; padding: 8px 16px; background: var(--accent); color: #fff; font-weight: 600; line-height: 1.4; transition: background .15s, border-color .15s; }
button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button:focus-visible, a:focus-visible { outline: 3px solid #a8dadb; outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .5; }
button.line { color: #4c6572; background: #fff; border-color: #dbe4e9; font-weight: 500; }
button.line:hover { border-color: #95c9ca; background: #f3fbfa; color: var(--accent-strong); }
button.small { min-height: 30px; padding: 5px 10px; font-size: 12px; }
button.full { width: 100%; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; padding: 8px; height: 36px; width: 36px; min-height: 36px; background: #fff; border: 1px solid var(--line); color: #68808b; }
.icon-button svg { width: 19px; height: 19px; }
.icon-button:hover { background: var(--accent-soft); color: var(--accent); border-color: #b4d8d7; }
.mobile-menu { display: none; }
input:not([type="checkbox"]), select, textarea { width: 100%; min-width: 0; min-height: 39px; padding: 9px 11px; color: var(--text); background: #fff; border: 1px solid #dbe4e9; border-radius: 6px; outline: none; }
input::placeholder, textarea::placeholder { color: #9ba9b2; }
input:focus, select:focus, textarea:focus { border-color: #67b4b8; box-shadow: 0 0 0 3px #0e818810; }
input:disabled, select:disabled { background: #f5f7f9; color: #9aa8b1; }
input[type="checkbox"] { width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
textarea { min-height: 128px; resize: vertical; line-height: 1.65; }
label { min-width: 0; }
label > span { display: block; margin-bottom: 7px; color: #506875; font-size: 12px; font-weight: 600; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.shell { display: grid; grid-template-columns: 242px minmax(0, 1fr); min-height: 100vh; align-items: start; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sidebar); color: #d6e4e8; }
.brand { display: flex; align-items: center; gap: 11px; height: 85px; min-height: 85px; padding: 19px 19px; border-bottom: 1px solid #ffffff0d; text-decoration: none; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; flex: 0 0 39px; border-radius: 11px; color: #083d43; background: #c5eee7; font-size: 14px; font-weight: 800; letter-spacing: -.4px; }
.brand-copy strong { display: block; font-size: 15px; font-weight: 650; letter-spacing: .3px; }
.brand-copy small { display: block; margin-top: 3px; font-size: 11px; color: #7e9aa7; }
.sidebar-body { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #31505b transparent; padding: 16px 12px 24px; flex: 1; }
.sidebar-footer { display: flex; align-items: center; gap: 7px; padding: 15px 18px; border-top: 1px solid #ffffff0d; font-size: 11px; color: #7f9ba7; }
.sidebar-footer small { margin-left: auto; font-size: 10px; color: #5c7a88; }
.connection-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #46b8a9; flex-shrink: 0; }
.login-box { display: grid; gap: 11px; padding: 16px 13px; border: 1px solid #ffffff10; border-radius: 9px; background: #19313c; margin-bottom: 16px; }
.login-title { font-size: 14px; color: #e5f0f3; font-weight: 600; }
.sidebar-caption { margin: -7px 0 3px; color: #8aa5b1; font-size: 11px; }
.login-box label > span { font-size: 11px; color: #adc1ca; font-weight: 500; }
.login-box input { background: #112b36; border-color: #36505c; color: #eff9f8; min-height: 36px; font-size: 12px; }
.login-box input::placeholder { color: #6f8c99; }
.session-box { display: flex; align-items: center; gap: 9px; margin: 0 2px 17px; border: 1px solid #ffffff10; border-radius: 9px; background: #19323d; padding: 11px 10px; }
.user-avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; background: #244955; border: 1px solid #3b606b; color: #bce5df; border-radius: 8px; font-size: 11px; font-weight: 650; }
.session-copy { min-width: 0; flex: 1; }
.eyebrow { display: block; font-size: 10px; color: #7e9ca9; }
.session-copy strong { display: block; color: #e3f0f4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.session-logout { display: grid; place-items: center; min-height: 28px; width: 28px; padding: 5px; border: 0; background: transparent; color: #9bb5c1; }
.session-logout:hover { background: #284955; }
.session-logout svg { width: 19px; height: 19px; }
.nav-search { display: flex; align-items: center; margin: 0 3px 22px; border: 1px solid #ffffff15; border-radius: 6px; background: #ffffff04; padding-left: 10px; }
.nav-search svg { width: 15px; height: 15px; color: #698895; }
.nav-search input:not([type="checkbox"]) { min-height: 32px; padding: 7px 9px; border: 0; background: transparent; color: #d5e7ed; font-size: 11px; box-shadow: none; }
.nav-search input::placeholder { color: #698895; }
.nav { display: grid; gap: 19px; }
.nav-group { display: grid; gap: 3px; }
.nav-title { padding: 0 13px 7px; color: #627f8c; font-size: 10px; font-weight: 600; letter-spacing: .7px; }
.nav button { display: flex; align-items: center; justify-content: flex-start; gap: 11px; min-height: 34px; padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; color: #a8c0cb; text-align: left; font-size: 12px; font-weight: 500; }
.nav button:hover { background: #ffffff08; color: #effcfa; }
.nav button.active { color: #dcf7f4; background: #17606a; box-shadow: inset 3px 0 #6bd7c5; }
.nav-icon { width: 16px; height: 16px; color: #7695a3; flex-shrink: 0; }
.nav .active .nav-icon { color: #8cdbd0; }
.nav button .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-empty { padding: 14px; font-size: 12px; color: #89a8b7; }
.main { min-width: 0; padding: 18px 22px 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.page-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; color: #8b9ca6; font-size: 11px; }
.breadcrumb > span:first-child { color: #b8c6ce; }
.topbar h1 { margin: 0; font-size: 22px; line-height: 1.3; letter-spacing: -.5px; font-weight: 650; color: #183640; }
.topbar-tools { display: flex; align-items: center; gap: 15px; }
.status-strip { display: flex; align-items: center; gap: 16px; font-size: 11px; color: #8a9ca5; }
.status-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-item + .status-item { border-left: 1px solid var(--line); padding-left: 16px; }
.status-item strong { font-size: 11px; color: #577481; font-weight: 500; }
.overview { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.quick-label { margin-right: 5px; font-size: 11px; color: #93a2aa; }
.overview-card { display: flex; align-items: center; min-height: 31px; padding: 6px 13px; border-radius: 6px; border: 1px solid #e0e8ec; background: #fff; color: #637c89; font-size: 11px; font-weight: 500; }
.overview-card:hover, .overview-card.active { background: #e9f5f4; border-color: #bedfdb; color: var(--accent); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; align-items: start; }
body[data-layout="split"] .content-grid { grid-template-columns: clamp(400px, 36%, 540px) minmax(0, 1fr); }
body[data-action="add_agent"] .content-grid { grid-template-columns: clamp(440px, 40%, 580px) minmax(0, 1fr); }
.workspace, .result-panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; min-width: 0; overflow: hidden; }
.workspace { padding: 16px; }
.workspace > .panel-head { padding: 0; margin: 0 0 14px; border: 0; }
.workspace #formTitle { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.workspace .panel-head p { margin: 0; font-size: 12px; color: #7a8d98; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding-bottom: 17px; margin-bottom: 20px; border-bottom: 1px solid #edf1f4; }
.panel-head h2 { margin: 0; color: #304b57; font-size: 14px; font-weight: 650; line-height: 1.5; }
.panel-head p { margin: 4px 0 0; color: #91a1aa; font-size: 11px; line-height: 1.6; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 8px; border: 1px solid #e9dfc8; border-radius: 5px; background: #fffaf0; color: #a18a52; font-size: 10px; font-weight: 500; white-space: nowrap; }
.badge.ready { color: #4f9996; background: #f1faf8; border-color: #dbede7; }
.form { display: block; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
body[data-layout="split"] .grid { grid-template-columns: minmax(0, 1fr); }
body[data-action="generate_cards"] .grid { grid-template-columns: 100px minmax(0, 1fr); }
body[data-action="generate_cards"] .field[data-field="software"], body[data-action="generate_cards"] .field[data-field="card_type"] { grid-column: 1 / -1; }
body[data-action="add_agent"] .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body[data-action="extend_cards"] .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field[data-kind="card_type_multi"], .field[data-kind="textarea"] { grid-column: 1 / -1; }
body[data-layout="query"] .form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
body[data-layout="query"] .grid { display: contents; }
body[data-layout="query"] .field { flex: 0 1 220px; }
body[data-layout="query"] .field[data-kind="number"] { flex-basis: 96px; }
body[data-layout="query"] .field[data-kind="select"] { flex-basis: 170px; }
body[data-layout="query"] .field[data-kind="datetime-local"] { flex-basis: 205px; }
body[data-layout="query"] .field[data-kind="card_type"] { flex-basis: 290px; }
body[data-layout="query"] .actions { margin: 0; padding: 0; min-height: 39px; align-items: center; }
body[data-layout="toolbar"] .workspace { display: flex; align-items: center; gap: 16px; justify-content: space-between; }
body[data-layout="toolbar"] .workspace > .panel-head { margin: 0; }
body[data-layout="toolbar"] .actions { margin: 0; padding: 0; }
body[data-layout="batch"] .grid.batch-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: stretch; }
.batch-input-pane, .batch-settings-pane { min-width: 0; }
.batch-input-pane > .field { display: block; width: 100%; }
.batch-settings-pane { display: grid; align-content: start; gap: 14px; padding-left: 24px; border-left: 1px solid #e6edf0; }
.batch-settings-title { margin: 0; color: #45616e; font-size: 13px; font-weight: 600; }
.batch-operation-note { margin: 0; color: #81939d; font-size: 12px; line-height: 1.8; }
.batch-settings-pane .actions { margin-top: 0; }
.batch-settings-pane .actions button { flex: 1 1 120px; }
textarea.card-entry-input { display: block; min-height: 240px; padding: 12px; font: 14px/22px Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; overflow-x: hidden; overflow-y: auto; resize: vertical; }
.card-entry-helper { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: #8396a1; font-size: 12px; line-height: 1.7; }
.card-entry-count { flex-shrink: 0; color: #537b86; font-variant-numeric: tabular-nums; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 0; border: 0; }
.actions .muted { margin-left: auto; font-size: 11px; color: #9aacb4; }
.actions button { min-height: 35px; font-size: 12px; }
.check-list { border: 1px solid #dbe4e9; border-radius: 6px; background: #fff; overflow: hidden; }
.check-tools { display: flex; align-items: center; gap: 7px; background: #f8fafb; border-bottom: 1px solid var(--line); padding: 8px; }
.check-tools button { min-height: 26px; padding: 4px 9px; font-size: 11px; }
.check-items { max-height: 240px; overflow-y: auto; padding: 7px 10px; }
.check-row { display: flex; align-items: center; gap: 9px; padding: 5px 0; min-height: 29px; }
.check-row span { margin: 0; color: #617580; font-size: 12px; font-weight: 400; line-height: 1.4; }
.check-empty { padding: 17px; color: #94a2aa; font-size: 12px; }
.result-panel { padding: 0 16px 16px; }
.result-heading { min-height: 48px; margin-bottom: 0; align-items: center; padding: 10px 0; }
.result-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.result-count { color: var(--accent); background: #edf7f5; border-radius: 4px; padding: 2px 7px; font-size: 10px; }
.result-state { font-size: 10px; color: #a0aeb6; }
.result-state.success { color: #319185; }
.result-state.error { color: #bd6267; }
.result-tools { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.result-empty { display: grid; justify-items: center; align-content: center; min-height: 120px; padding: 20px 15px; color: #96a7af; text-align: center; }
.empty-symbol { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #f1f6f8; color: #a0b6c0; margin-bottom: 10px; }
.empty-symbol svg { width: 23px; height: 23px; }
.result-empty strong { font-size: 12px; font-weight: 500; color: #7f929c; }
.result-empty p { margin: 6px 0 0; color: #a4b1b8; font-size: 11px; }
.result-table-wrap { max-width: 100%; max-height: 580px; overflow: auto; margin: 12px 0 0; border: 1px solid #e8eef1; border-radius: 6px; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
.data-table th { padding: 9px 12px; color: #8094a0; background: #f8fafb; font-size: 11px; font-weight: 500; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.data-table td { padding: 9px 12px; color: #506975; border-top: 1px solid #edf2f5; vertical-align: middle; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { width: 58px; }
.data-table td.cell-code { min-width: 280px; max-width: none; font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; white-space: normal; word-break: break-all; overflow-wrap: anywhere; overflow: visible; text-overflow: clip; }
body[data-action="generate_cards"] .data-table td:nth-child(2) { font-family: Consolas, monospace; font-size: 13px; }
.data-table tbody tr:hover td { background: #f7fcfb; }
.data-table td:first-child { color: #42606f; }
.table-state { display: inline-block; border-radius: 4px; padding: 2px 7px; background: #eaf7f0; color: #48997b; font-size: 10px; }
.table-state.warn { color: #aa8a42; background: #fbf6e9; }
.table-state.bad { color: #bf7377; background: #fcf0f0; }
pre { font: 12px/1.8 "Segoe UI", "Microsoft YaHei UI", sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.result-detail { margin-top: 14px; border: 1px solid #e7edf1; border-radius: 6px; padding: 16px; background: #f8fafb; color: #617884; min-height: 100px; max-height: 560px; overflow: auto; }
.result-detail.result-error { background: #fff7f7; color: #ab555d; border-color: #f0dadd; }
.parameter-free .actions { margin-top: 0; padding-top: 0; border-top: 0; }
.result-summary { margin-top: 12px; }
.generation-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 12px; border-radius: 6px; background: #f0f8f5; color: #637e73; font-size: 12px; }
.generation-success { color: #35806b; font-size: 12px; font-weight: 600; }
.generation-cost { color: #506b62; }
.balance-summary { display: grid; grid-template-columns: 230px minmax(0, 1fr); border: 1px solid #deebe8; border-radius: 8px; background: #f6fbf9; padding: 18px; gap: 24px; align-items: center; }
.balance-main { display: flex; flex-direction: column; align-items: flex-start; gap: 11px; }
.balance-label { font-size: 13px; color: #577d73; }
.balance-value { color: #14685f; font-size: 32px; font-weight: 650; letter-spacing: -.6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; max-width: 100%; }
.balance-caption { display: none; }
.balance-details { margin: 0; border-left: 1px solid #deebe8; padding-left: 24px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.balance-details > div { display: grid; gap: 7px; align-content: start; }
.balance-details dt, .receipt-details dt { font-size: 12px; color: #8a9ba2; }
.balance-details dd, .receipt-details dd { margin: 0; color: #365966; font-size: 13px; overflow-wrap: anywhere; }
.business-receipt { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid #dcece6; border-radius: 6px; background: #f5faf8; }
.receipt-icon { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; background: #dff0e8; color: #398871; font-size: 16px; font-weight: 600; }
.business-receipt strong { display: block; font-size: 14px; line-height: 28px; color: #3f7462; font-weight: 600; overflow-wrap: anywhere; }
.business-receipt p { margin: 5px 0 0; color: #728a82; font-size: 13px; line-height: 1.7; white-space: pre-line; overflow-wrap: anywhere; }
.business-receipt.error { background: #fff8f7; border-color: #efdfdc; }
.business-receipt.error .receipt-icon { background: #f8e5df; color: #b66b54; }
.business-receipt.error strong { color: #a45f4d; }
.business-receipt.error p { color: #997a70; }
.receipt-details { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 12px 0 0; padding: 0; }
.receipt-details > div { min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
@media (max-width: 700px) {
  .balance-summary { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .balance-details { padding: 16px 0 0; border-left: 0; border-top: 1px solid #deebe8; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .balance-details > div { grid-template-columns: 90px minmax(0, 1fr); gap: 12px; }
  .balance-value { font-size: 30px; }
}
.result-notice { display: flex; align-items: center; gap: 8px; margin-top: 13px; padding: 12px 14px; border-radius: 6px; background: #f3f9f7; color: #5b8f80; font-size: 12px; }
.result-notice.error { color: #b3686c; background: #fcf3f3; }
body.account-extension-view .result-panel { display: none; }
body.account-extension-view .workspace { padding: 16px; }
body.account-extension-view .form { display: block; }
body.account-extension-view .grid.account-extension-filters { grid-template-columns: minmax(180px,1.2fr) minmax(170px,1fr) minmax(170px,1.2fr) minmax(105px,.6fr) minmax(125px,.7fr); gap: 12px; align-items: end; }
.account-extension-rule { font-size: 11px; color: #93a3ac; margin: 12px 0; line-height: 1.75; }
.account-extension-list { border: 1px solid #e7edf1; border-radius: 7px; background: #fff; max-width: 100%; overflow-x: auto; }
.account-extension-summary { font-size: 11px; color: #8ba0ab; padding: 10px 13px; background: #fafcfd; line-height: 1.7; min-width: 850px; }
.account-extension-table { display: grid; min-width: 1000px; width: 100%; max-height: 520px; overflow-y: auto; }
.account-extension-row { display: grid; grid-template-columns: 24px minmax(100px,1.1fr) minmax(82px,.8fr) minmax(75px,.7fr) minmax(75px,.7fr) minmax(145px,1.25fr) minmax(135px,1.15fr) minmax(140px,1.2fr); gap: 12px; align-items: center; padding: 11px 13px; border-top: 1px solid #edf2f5; font-size: 12px; }
.account-extension-row.header { color: #879da9; background: #f7f9fb; font-size: 11px; font-weight: 500; border-top: 0; position: sticky; top: 0; z-index: 1; }
.account-extension-row:not(.header):hover { background: #f6fbfa; }
.account-extension-row span { margin: 0; font-size: inherit; font-weight: 400; color: inherit; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-extension-row input[type="checkbox"] { width: 14px; height: 14px; min-height: 0; margin: 0; padding: 0; }
.account-extension-row:not(.header) span { color: #5b7582; }
.account-extension-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 13px; }
.form > .account-extension-actions { padding: 0 0 12px; }
.account-extension-actions button { min-height: 34px; font-size: 11px; padding: 7px 12px; }
.account-extension-feedback { padding: 15px 17px; border: 1px solid #daeae5; background: #f5faf8; border-radius: 7px; color: #557b6e; max-height: 330px; overflow: auto; margin-top: 18px; }
.main-footer { display: flex; justify-content: space-between; gap: 15px; padding: 16px 2px 2px; font-size: 10px; color: #a9b6be; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 11px 20px; border: 1px solid #dce9e7; border-radius: 8px; background: #fff; color: #4c7c74; box-shadow: 0 10px 35px #1d404a18; font-size: 12px; z-index: 100; }
.sidebar-backdrop { display: none; }
@media (max-width: 1250px) {
  .shell { grid-template-columns: 222px minmax(0,1fr); }
  .main { padding: 18px 20px 14px; }
  .status-strip { gap: 8px; }
  .status-item + .status-item { padding-left: 8px; }
  body.account-extension-view .grid.account-extension-filters { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 1100px) {
  body[data-layout="split"] .content-grid, body[data-action="add_agent"] .content-grid { grid-template-columns: minmax(0, 1fr); }
  body[data-layout="split"] .grid, body[data-action="generate_cards"] .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-action="generate_cards"] .field[data-field="software"], body[data-action="generate_cards"] .field[data-field="card_type"] { grid-column: auto; }
  body[data-layout="query"] .field { flex-basis: 205px; }
}
@media (max-width: 1180px) {
  body[data-layout="batch"] .grid.batch-form-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .batch-settings-pane { padding: 14px 0 0; border-left: 0; border-top: 1px solid #e6edf0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .batch-settings-title, .batch-operation-note { grid-column: 1 / -1; }
  .batch-settings-pane .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .batch-settings-pane .actions button { flex: 0 1 auto; }
}
@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: 242px; z-index: 60; transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open { overflow: hidden; }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; width: 100%; height: 100%; min-height: 100%; border: 0; border-radius: 0; background: #102b3980; z-index: 55; }
  .mobile-menu { display: inline-flex; }
  .main { padding: 16px; }
  .topbar h1 { font-size: 22px; }
  .topbar-tools { gap: 8px; }
  .status-strip { font-size: 10px; }
  .status-item + .status-item { display: none; }
}
@media (max-width: 600px) {
  body { font-size: 13px; }
  .main { padding: 16px 12px 12px; }
  .topbar { padding-bottom: 16px; margin-bottom: 15px; gap: 8px; }
  .topbar h1 { font-size: 20px; }
  .breadcrumb { font-size: 10px; gap: 6px; }
  .topbar-tools .status-strip { display: none; }
  .overview { gap: 6px; margin-bottom: 15px; }
  .quick-label { display: none; }
  .overview-card { flex: 1; justify-content: center; padding: 6px; font-size: 10px; }
  .workspace, body.account-extension-view .workspace { padding: 14px; border-radius: 8px; }
  .panel-head { gap: 10px; padding-bottom: 13px; margin-bottom: 15px; }
  .panel-head p { font-size: 10px; }
  .panel-head h2 { font-size: 13px; }
  .badge { display: none; }
  .grid, body[data-layout="split"] .grid, body[data-action="add_agent"] .grid, body[data-action="extend_cards"] .grid, body[data-action="generate_cards"] .grid, body.account-extension-view .grid.account-extension-filters { grid-template-columns: minmax(0,1fr); }
  .grid { gap: 12px; }
  body[data-layout="query"] .form { display: block; }
  body[data-layout="query"] .grid { display: grid; grid-template-columns: minmax(0, 1fr); }
  body[data-layout="query"] .actions { margin-top: 12px; }
  body[data-layout="toolbar"] .workspace { flex-wrap: wrap; gap: 12px; }
  .batch-settings-pane { grid-template-columns: minmax(0, 1fr); }
  .batch-settings-pane .actions button { flex: 1 1 auto; }
  .actions { gap: 8px; }
  .actions .muted { width: 100%; margin-left: 0; }
  .actions button { flex: 1 1 auto; }
  .result-panel { padding: 0 13px 14px; }
  .result-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .result-title { width: 100%; }
  .result-tools { align-self: flex-end; }
  .result-empty { min-height: 110px; }
  .account-extension-actions button { flex: 1 1 calc(50% - 8px); }
  .account-extension-rule { font-size: 10px; }
  .main-footer { font-size: 9px; }
  .main-footer span:last-child { max-width: 45%; text-align: right; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


/* Mobile records use labelled cards; desktop tables keep their column layout. */
@media (max-width: 900px) {
  .sidebar { height: 100dvh; max-width: calc(100vw - 40px); }
  .sidebar-body { min-height: 0; overscroll-behavior-y: contain; }
  .sidebar-footer { padding-bottom: max(15px, env(safe-area-inset-bottom)); }
  .nav button, .session-logout { min-height: 44px; }
  .session-logout { width: 44px; flex-shrink: 0; }
  .nav-search input:not([type="checkbox"]) { min-height: 44px; font-size: 16px; }
  .login-box input { min-height: 44px; font-size: 16px; }
  .login-box button { min-height: 44px; }
}
@media (max-width: 900px) {
  body { font-size: 14px; }
  .main { padding: 12px max(10px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .topbar { gap: 8px; margin-bottom: 12px; padding-bottom: 12px; }
  .topbar-tools .status-strip { display: none; }
  .topbar h1 { font-size: 20px; }
  .icon-button { width: 44px; height: 44px; min-height: 44px; flex-shrink: 0; }
  input:not([type="checkbox"]), select, textarea { min-height: 44px; font-size: 16px; }
  button, button.small, .actions button, .account-extension-actions button, .check-tools button { min-height: 44px; font-size: 13px; }
  label > span { font-size: 13px; }
  .workspace .panel-head p, .panel-head p, .account-extension-rule { font-size: 12px; }
  .workspace, body.account-extension-view .workspace { padding: 12px; }
  .result-panel { padding: 0 12px 12px; }
  .result-heading { flex-direction: column; align-items: stretch; gap: 8px; }
  .result-tools { align-self: stretch; display: flex; }
  .result-tools button { flex: 1 1 0; padding: 8px; }
  body[data-layout="query"] .form { display: block; }
  body[data-layout="query"] .grid { display: grid; grid-template-columns: minmax(0, 1fr); }
  body[data-layout="query"] .actions { margin-top: 12px; }
  body[data-layout="toolbar"] .workspace { flex-wrap: wrap; }
  body.account-extension-view .grid.account-extension-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  body.account-extension-view .field[data-field="search"] { grid-column: 1 / -1; }
  .account-extension-rule { margin: 12px 0; }
  .form > .account-extension-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; padding-bottom: 12px; }
  .form > .account-extension-actions button { width: 100%; min-width: 0; white-space: normal; text-wrap: balance; }
  .account-extension-actions [data-role="account-extension-commit"] { grid-column: 1 / -1; }
  .account-extension-list { overflow: visible; border: 0; background: transparent; }
  .account-extension-summary { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 7px; margin-bottom: 10px; font-size: 12px; overflow-wrap: anywhere; }
  .account-extension-table { min-width: 0; max-height: none; overflow: visible; gap: 10px; }
  .account-extension-row.header { display: none; }
  .account-extension-row:not(.header) { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; align-items: start; background: #fff; }
  .account-extension-row:not(.header):has(input:checked) { background: var(--accent-soft); border-color: #67b4b8; }
  .account-extension-row input[type="checkbox"] { position: absolute; right: 14px; top: 15px; width: 22px; height: 22px; }
  .account-extension-row:not(.header) span { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .account-extension-row:not(.header) span::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; font-weight: 400; }
  .account-extension-row span[data-field="account"] { grid-column: 1 / -1; padding-right: 36px; color: var(--text); font-size: 15px; font-weight: 600; }
  .account-extension-row span[data-field="effective_expire"],
  .account-extension-row span[data-field="register_time"] { grid-column: 1 / -1; font-variant-numeric: tabular-nums; }
  .account-extension-pagination { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); padding: 12px 0 0; }
  .account-extension-pagination .muted { text-align: center; }
  .account-extension-feedback { max-height: none; font-size: 13px; padding: 12px; margin-top: 12px; }
  .result-table-wrap { max-height: none; overflow: visible; margin-top: 12px; border: 0; border-radius: 0; }
  .data-table, .data-table tbody { display: block; width: 100%; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .data-table tbody { display: grid; gap: 10px; }
  .data-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
  .data-table td, .data-table td:first-child, .data-table td.cell-code { display: block; width: auto; min-width: 0; max-width: none; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; overflow: visible; text-overflow: clip; font-size: 13px; }
  .data-table tbody tr:hover td { background: transparent; }
  .data-table td::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font: 11px/1.5 "Segoe UI", "Microsoft YaHei UI", sans-serif; }
  .data-table td:first-child { grid-column: 1 / -1; padding-bottom: 7px; border-bottom: 1px solid #edf2f5; color: var(--muted); font-size: 11px; }
  .data-table td:first-child::before { display: inline; margin: 0 6px 0 0; }
  .data-table td.cell-code, .data-table td.cell-wide { grid-column: 1 / -1; }
  .data-table td.cell-code { font-size: 14px; line-height: 1.7; }
  .table-state { font-size: 12px; }
  .result-detail { font-size: 13px; max-height: none; padding: 12px; }
  textarea.card-entry-input { font-size: 16px; line-height: 24px; min-height: 220px; padding: 10px; }
  .card-entry-helper { font-size: 12px; }
  .batch-settings-pane .actions button, .actions button { flex: 1 1 auto; }
  .toast { max-width: calc(100vw - 24px); width: max-content; overflow-wrap: anywhere; bottom: max(16px, env(safe-area-inset-bottom)); }
}


/* Authentication is a first screen, independent of the management menu. */
.auth-screen { display: grid; min-height: 100vh; min-height: 100dvh; align-content: center; justify-items: center; gap: 18px; padding: max(28px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.auth-card { width: 100%; max-width: 416px; min-width: 0; padding: 32px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 44px #20343d08; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.auth-brand .brand-mark { width: 46px; height: 46px; flex-basis: 46px; border-radius: 12px; }
.auth-brand h1 { margin: 0; color: #183640; font-size: 21px; font-weight: 650; line-height: 1.4; }
.auth-brand p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.auth-screen .login-box { margin: 0; padding: 0; gap: 18px; border: 0; border-radius: 0; background: transparent; }
.auth-screen .login-box label > span { font-size: 13px; color: #506875; font-weight: 600; }
.auth-screen .login-box input { min-height: 48px; padding: 12px; font-size: 16px; color: var(--text); background: #fff; border-color: #dbe4e9; }
.auth-screen .login-box input::placeholder { color: #9ba9b2; }
.auth-screen .login-box input:focus { border-color: #67b4b8; }
.auth-screen .login-box button { min-height: 48px; font-size: 15px; }
.login-error { margin: 0; padding: 10px 12px; color: #a6474f; background: #fff5f5; border: 1px solid #efdadd; border-radius: 7px; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.auth-footer { margin: 0; color: #8c9da7; font-size: 12px; }
@media (max-width: 480px) {
  .auth-card { padding: 25px 22px; border-radius: 12px; }
  .auth-brand { gap: 12px; margin-bottom: 25px; }
  .auth-brand h1 { font-size: 19px; }
}
@media (max-height: 520px) {
  .auth-screen { align-content: start; padding-top: 18px; padding-bottom: 18px; }
  .auth-card { padding-top: 22px; padding-bottom: 22px; }
  .auth-brand { margin-bottom: 18px; }
}
