:root {
  --ink: #17202a;
  --muted: #66727f;
  --line: #dce2e7;
  --surface: #ffffff;
  --canvas: #f3f5f6;
  --nav: #18212a;
  --teal: #087f73;
  --teal-dark: #06675e;
  --teal-soft: #e7f5f2;
  --amber: #a66100;
  --amber-soft: #fff3d6;
  --red: #b42318;
  --red-soft: #ffebe9;
  --blue: #245ea8;
  --blue-soft: #eaf2fb;
  --coral: #c24f36;
  --coral-soft: #fff0eb;
  --radius: 6px;
  --shadow: 0 14px 38px rgba(23, 32, 42, 0.14);
  --shadow-soft: 0 3px 14px rgba(23, 32, 42, 0.06);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body { min-width: 320px; background: var(--canvas); }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: inherit; }
.icon { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  background: var(--surface);
}
.auth-brand {
  background: #17262b;
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: #159b8e; border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.brand-name { font-size: 25px; }
.auth-brand h1 { margin: 0; max-width: 500px; font-size: 34px; line-height: 1.35; font-weight: 650; }
.auth-brand p { margin: 18px 0 0; max-width: 460px; color: #b8c3cc; line-height: 1.8; }
.auth-meta { color: #8d9aa5; font-size: 13px; }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 36px; }
.auth-panel { width: min(420px, 100%); }
.auth-panel h2 { font-size: 24px; margin: 0 0 8px; }
.auth-panel > p { color: var(--muted); margin: 0 0 28px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #f3f6f7; }
.auth-channel { margin-bottom: 20px; }
.segment { min-height: 36px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-weight: 650; }
.segment.active { color: var(--teal-dark); background: #fff; box-shadow: 0 1px 5px rgba(23,32,42,.1); }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 7px; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.field input, .field select, .toolbar input, .toolbar select, .drawer select, .drawer input {
  width: 100%; height: 42px; border: 1px solid #c8d0d7; border-radius: 5px;
  padding: 0 12px; color: var(--ink); background: #fff; outline: none;
}
.field input:focus, .field select:focus, .toolbar input:focus, .toolbar select:focus, .drawer input:focus, .drawer select:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 127, 115, 0.12);
}
.code-input-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.code-input-row .button { min-width: 108px; white-space: nowrap; }
.registration-note { margin: -6px 0 18px; padding: 10px 12px; border-left: 3px solid var(--teal); background: var(--teal-soft); color: #40605c; font-size: 12px; line-height: 1.55; }
.button {
  border: 1px solid transparent; border-radius: 5px; min-height: 38px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650;
  background: var(--teal); color: #fff;
}
.button:hover { background: var(--teal-dark); }
.button.secondary { background: #fff; color: var(--ink); border-color: #c8d0d7; }
.button.secondary:hover { background: #f6f8f9; }
.button.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.button.ghost:hover { background: #edf1f3; color: var(--ink); }
.button.danger { background: var(--red); }
.button.full { width: 100%; height: 44px; }
.auth-switch { margin-top: 20px; color: var(--muted); text-align: center; font-size: 14px; }
.link-button { border: 0; background: none; color: var(--teal); padding: 2px 4px; font-weight: 650; }

.app-shell { min-height: 100vh; display: block; padding-left: 232px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; height: auto; z-index: 20; background: #17262b; color: #fff; padding: 20px 15px; display: flex; flex-direction: column; }
.sidebar .brand-lockup { padding: 4px 8px 22px; }
.sidebar .brand-mark { width: 32px; height: 32px; }
.sidebar .brand-name { font-size: 19px; }
.nav-list { display: grid; gap: 4px; }
.nav-item {
  width: 100%; border: 0; color: #b9c3cb; background: transparent; min-height: 42px;
  padding: 0 12px; display: flex; align-items: center; gap: 10px; border-radius: 6px; text-align: left;
  transition: color 140ms ease, background 140ms ease, transform 140ms ease;
}
.nav-item:hover { color: #fff; background: #25383d; transform: translateX(2px); }
.nav-item.active { color: #fff; background: #27504e; box-shadow: inset 3px 0 0 #5ad3c2; }
.sidebar-user { margin-top: auto; padding: 10px; border: 1px solid #344b50; border-radius: 6px; background: #1d3035; box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.sidebar-profile { width: 100%; min-height: 38px; margin: 0 0 9px; padding: 0 8px; display: flex; align-items: center; gap: 9px; border: 0; border-radius: 5px; color: #d4dce1; background: #263c40; text-align: left; }
.sidebar-profile:hover, .sidebar-profile.active { color: #fff; background: #25383d; }
.sidebar-profile span { margin: 0; color: inherit !important; font-size: 13px !important; font-weight: 650; }
.sidebar-user strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { display: block; margin-top: 4px; color: #8f9ca6; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span + span { color: #75d7c3; font-weight: 700; }
.main-shell { min-width: 0; overflow-x: hidden; }
.topbar {
  height: 66px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 8px rgba(23, 32, 42, 0.04);
}
.topbar h1 { margin: 0; font-size: 18px; }
.top-actions { display: flex; gap: 8px; }
.icon-button {
  width: 38px; height: 38px; padding: 0; border: 1px solid #c8d0d7; border-radius: 5px;
  display: grid; place-items: center; background: #fff; color: var(--ink);
}
.icon-button:hover { background: #f4f6f7; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; min-width: 126px; }
.icon-button.danger-icon { color: var(--red); }
.icon-button.danger-icon:hover { background: var(--red-soft); border-color: #efb5b5; }
.content { padding: 28px 32px 48px; max-width: 1540px; margin: 0 auto; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 22px; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 20px; box-shadow: var(--shadow-soft); overflow: hidden; }
.metric { padding: 16px 18px; border-right: 1px solid var(--line); min-width: 0; }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 5px; font-size: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-sub { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.upload-tool {
  border: 1px dashed #9daab4; background: #fff; border-radius: var(--radius); min-height: 142px;
  padding: 26px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px;
  box-shadow: var(--shadow-soft); transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.upload-tool:hover { border-color: #6c9c97; box-shadow: 0 5px 18px rgba(23, 32, 42, 0.08); }
.upload-tool.dragging { border-color: var(--teal); background: var(--teal-soft); }
.upload-copy { display: flex; gap: 16px; align-items: center; min-width: 0; }
.upload-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 5px; color: var(--teal); background: var(--teal-soft); }
.upload-copy h3 { margin: 0 0 5px; font-size: 16px; }
.upload-copy p { margin: 0; color: var(--muted); font-size: 13px; }

.table-frame { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-soft); }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail-table { table-layout: fixed; min-width: 960px; }
.detail-table th:nth-child(1) { width: 4%; }
.detail-table th:nth-child(2) { width: 14%; }
.detail-table th:nth-child(3) { width: 22%; }
.detail-table th:nth-child(4) { width: 25%; }
.detail-table th:nth-child(5) { width: 9%; }
.detail-table th:nth-child(6) { width: 9%; }
.detail-table th:nth-child(7) { width: 13%; }
.detail-table th:nth-child(8) { width: 4%; }
th { height: 44px; padding: 0 12px; background: #f5f8f8; color: #46545e; text-align: left; font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { min-height: 48px; padding: 10px 12px; border-bottom: 1px solid #e7ebee; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.truncate { max-width: 330px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amount { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; color: #495560; font-size: 12px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7b8790; }
.status.completed::before { background: var(--teal); }
.status.processing::before, .status.queued::before { background: #d68512; }
.status.failed::before { background: var(--red); }
.category-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 8px; border-radius: 4px; background: #eef2f4; white-space: nowrap; }
.category-badge.review { color: var(--amber); background: var(--amber-soft); }
.category-badge.red-flush { color: #9f2f25; background: var(--red-soft); }
.category-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.red-role-tag { min-height: 23px; padding: 0 6px; display: inline-flex; align-items: center; border: 1px solid #e7aaa5; border-radius: 4px; color: #9f2f25; background: #fff7f6; font-size: 11px; font-weight: 800; }
.red-flush-row { background: #fff8f7; box-shadow: inset 3px 0 0 #d46a61; }
.red-flush-row:hover { background: #fff1ef; }
.ai-origin-tag { min-height: 23px; padding: 0 6px; display: inline-flex; align-items: center; gap: 3px; border: 1px solid #9bcac5; border-radius: 4px; color: var(--teal-dark); background: var(--teal-soft); font-size: 11px; font-weight: 800; }
.ai-origin-tag .icon { width: 12px; height: 12px; }
.ai-classified-row { background: #f2faf8; box-shadow: inset 3px 0 0 #45a99e; }
.ai-classified-row:hover { background: #eaf7f4; }
.reason-text { min-width: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.55; color: #43515c; }
.empty { min-height: 210px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 28px; }
.empty .icon { width: 30px; height: 30px; margin-bottom: 10px; color: #8c99a3; }

.progress-track { width: 160px; height: 6px; background: #e4e9ec; overflow: hidden; border-radius: 3px; }
.progress-bar { height: 100%; background: var(--teal); }
.job-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.job-heading h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-strip { display: grid; grid-template-columns: repeat(10, minmax(110px, 1fr)); border: 1px solid var(--line); background: #fff; overflow-x: auto; margin-bottom: 16px; }
.summary-item { padding: 13px 14px; border-right: 1px solid var(--line); min-width: 110px; }
.summary-item:last-child { border-right: 0; }
.summary-item button { border: 0; background: transparent; padding: 0; text-align: left; width: 100%; }
.summary-item span { color: var(--muted); font-size: 12px; }
.summary-item strong { display: block; margin-top: 4px; font-size: 18px; }
.summary-item.active { box-shadow: inset 0 -3px 0 var(--teal); background: var(--teal-soft); }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px; background: #fff; border: 1px solid var(--line); border-bottom: 0; }
.toolbar .search { position: relative; width: min(340px, 100%); }
.toolbar .search .icon { position: absolute; left: 11px; top: 11px; color: #7b8790; }
.toolbar .search input { padding-left: 37px; }
.toolbar select { width: 150px; }
.toolbar-spacer { flex: 1; }
.checkbox-label { display: inline-flex; gap: 7px; align-items: center; color: var(--muted); font-size: 13px; white-space: nowrap; }
.settings-panel { margin-top: 22px; padding: 22px; border: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.settings-panel h3, .panel-title h3 { margin: 0 0 5px; font-size: 16px; }
.settings-panel p, .panel-title span { margin: 0; color: var(--muted); font-size: 13px; }
.inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-form input { min-width: 170px; height: 40px; border: 1px solid #c8d0d7; border-radius: 5px; padding: 0 10px; }
.panel-form { padding: 16px; border-top: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.button.compact { min-height: 34px; padding: 7px 10px; font-size: 12px; }
.amount.credit { color: var(--teal); font-weight: 800; }
.admin-grid { margin-bottom: 22px; }
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.plan-card { min-width: 0; padding: 22px; border: 1px solid var(--line); border-top: 4px solid #89959f; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-soft); }
.plan-card:nth-child(2) { border-top-color: var(--teal); }
.plan-card:nth-child(3) { border-top-color: var(--coral); }
.plan-card.current { border-color: #84beb7; box-shadow: inset 0 0 0 1px #84beb7, var(--shadow-soft); }
.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-height: 48px; }
.plan-head h3 { margin: 0 0 5px; font-size: 17px; }
.plan-head span { color: var(--muted); font-size: 12px; }
.plan-current { flex: 0 0 auto; padding: 4px 7px; border-radius: 4px; color: var(--teal) !important; background: var(--teal-soft); font-weight: 700; }
.plan-price { display: flex; align-items: baseline; gap: 4px; margin: 18px 0; }
.plan-price strong { font-size: 29px; font-variant-numeric: tabular-nums; }
.plan-price span { color: var(--muted); font-size: 13px; }
.plan-features { margin: 0; display: grid; }
.plan-features div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #e7ebee; }
.plan-features dt { color: var(--muted); font-size: 12px; }
.plan-features dd { margin: 0; font-size: 13px; font-weight: 700; text-align: right; }
.upgrade-callout { display: flex; align-items: center; gap: 16px; margin: 0 0 22px; padding: 18px 20px; border: 1px solid #b8d5ee; border-left: 4px solid var(--blue); border-radius: var(--radius); background: var(--blue-soft); }
.upgrade-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; color: var(--blue); background: #fff; border: 1px solid #c9dff1; border-radius: 6px; }
.upgrade-callout h3 { margin: 0 0 4px; font-size: 15px; }
.upgrade-callout p { margin: 0; color: #4c6275; font-size: 13px; }
.profile-layout { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(320px,.65fr); gap: 20px; align-items: start; }
.profile-panel { overflow: visible; }
.profile-fields { padding: 20px; }
.profile-fields .field:last-child { margin-bottom: 0; }
.profile-footer { min-height: 66px; padding: 12px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.profile-footer > span { color: var(--muted); font-size: 12px; }
.verification-config-form { display: grid; gap: 18px; }
.verification-config-form fieldset { min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 6px; }
.verification-config-form legend { padding: 0 7px; font-size: 14px; font-weight: 700; }
.config-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0 14px; }
.rules-editor { margin-top: 22px; }
.rules-editor textarea { display: block; width: calc(100% - 32px); min-height: 360px; margin: 10px 16px 16px; padding: 12px; border: 1px solid #c8d0d7; border-radius: 5px; font: 12px/1.6 Consolas, monospace; resize: vertical; }
.checkbox-label input { width: 16px; height: 16px; accent-color: var(--teal); }
.pagination { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.pagination-actions { display: flex; gap: 6px; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(23, 32, 42, 0.32); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; width: min(480px, 100%); height: 100vh; background: #fff; z-index: 31; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: drawer-in 160ms ease-out; }
@keyframes drawer-in { from { transform: translateX(18px); opacity: .7; } to { transform: translateX(0); opacity: 1; } }
.drawer-header { min-height: 66px; border-bottom: 1px solid var(--line); padding: 0 20px; display: flex; align-items: center; justify-content: space-between; }
.drawer-header h3 { margin: 0; font-size: 17px; }
.drawer-body { padding: 20px; overflow: auto; flex: 1; }
.drawer-footer { border-top: 1px solid var(--line); padding: 14px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.original-value { padding: 12px; background: #f5f7f8; border: 1px solid var(--line); line-height: 1.65; border-radius: 5px; word-break: break-word; }
.review-alert { display: flex; gap: 9px; align-items: flex-start; padding: 11px 12px; border: 1px solid #e7b95c; background: #fff8e8; color: #744d00; font-size: 13px; line-height: 1.5; }
.review-alert .icon { flex: 0 0 auto; margin-top: 1px; }
.meta-list { display: grid; grid-template-columns: 110px 1fr; gap: 9px 12px; font-size: 13px; margin-top: 20px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; word-break: break-word; }
.toast { position: fixed; right: 24px; bottom: 24px; min-width: 220px; max-width: 420px; padding: 13px 16px; background: var(--nav); color: #fff; border-radius: 6px; box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none; transition: 160ms ease; z-index: 50; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(18,29,37,.48); backdrop-filter: blur(2px); }
.result-modal { position: fixed; z-index: 41; left: 50%; top: 50%; width: min(680px, calc(100% - 32px)); max-height: min(720px, calc(100vh - 48px)); transform: translate(-50%,-50%); display: flex; flex-direction: column; overflow: hidden; border-radius: 7px; background: #fff; box-shadow: 0 24px 70px rgba(16,27,35,.3); }
.result-modal > header { min-height: 78px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.result-modal > header > div { display: flex; align-items: center; gap: 12px; }
.result-modal h3 { margin: 0 0 4px; font-size: 18px; }
.result-modal p, .result-modal footer span { margin: 0; color: var(--muted); font-size: 12px; }
.result-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 6px; color: var(--teal); background: var(--teal-soft); }
.ai-result-list { padding: 8px 20px; overflow-y: auto; }
.ai-result-item { min-height: 66px; padding: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid #e8edef; }
.ai-result-item:last-child { border-bottom: 0; }
.ai-result-item > div { min-width: 0; }
.ai-result-item strong { display: block; margin-bottom: 4px; overflow-wrap: anywhere; }
.ai-result-item > div > span:not(.category-badge) { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.ai-result-item > div:last-child { flex: 0 0 auto; display: grid; justify-items: end; gap: 4px; }
.ai-result-item .confidence { font-variant-numeric: tabular-nums; }
.result-modal > footer { min-height: 66px; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); background: #f8fafb; }
.mobile-brand { display: none; }
.mobile-nav { display: none; }

@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { min-height: auto; padding: 26px; }
  .auth-brand h1, .auth-brand p, .auth-meta { display: none; }
  .auth-main { min-height: calc(100vh - 90px); padding: 26px; }
  .app-shell { padding-left: 0; }
  .sidebar { display: none; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
  .mobile-brand .brand-mark { width: 30px; height: 30px; }
  .topbar { padding: 0 16px; }
  .topbar > h1 { display: none; }
  .content { padding: 18px 14px 34px; }
  .content { padding-bottom: 92px; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; min-height: 62px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 5px max(8px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); box-shadow: 0 -5px 18px rgba(23,32,42,.08); }
  .mobile-nav-item { min-width: 0; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; }
  .mobile-nav-item .icon { width: 19px; height: 19px; }
  .mobile-nav-item.active { color: var(--teal); font-weight: 700; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .upload-tool { align-items: flex-start; flex-direction: column; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { width: 100%; }
  .toolbar-spacer { display: none; }
  .summary-strip { grid-template-columns: repeat(10, 120px); }
  .section-heading { align-items: flex-start; }
  .plan-grid { grid-template-columns: 1fr; }
  .upgrade-callout { align-items: flex-start; }
  .settings-panel { align-items: stretch; flex-direction: column; }
  .profile-layout { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr 1fr; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form input, .inline-form .button { width: 100%; }
  .ai-result-item { align-items: flex-start; }
}

@media (max-width: 520px) {
  .auth-main { padding: 22px 18px; }
  .auth-brand { padding: 18px; }
  .top-actions .button span { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 13px; }
  .metric strong { font-size: 19px; }
  .upload-copy { align-items: flex-start; }
  .section-heading h2 { font-size: 19px; }
  .job-heading { align-items: flex-start; }
  .drawer-footer .button { flex: 1; }
  .code-input-row { grid-template-columns: minmax(0,1fr); }
  .code-input-row .button { width: 100%; }
  .profile-footer { align-items: stretch; flex-direction: column; }
  .config-grid { grid-template-columns: 1fr; }
  .result-modal > footer { align-items: stretch; flex-direction: column; }
  .result-modal > footer .button { width: 100%; }
}
