:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef2f1;
  --text: #17201e;
  --muted: #66726f;
  --border: #d8dfdd;
  --primary: #116354;
  --primary-dark: #0b4c40;
  --blue: #2266a8;
  --gold: #9a6414;
  --red: #b4322d;
  --green: #16745c;
  --sidebar: #172220;
  --sidebar-text: #dce5e2;
  --sidebar-muted: #8fa19c;
  --shadow: 0 1px 2px rgb(23 32 30 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; color: var(--text); background: var(--bg); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
svg { flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 12px 14px; display: flex; flex-direction: column; background: var(--sidebar); color: var(--sidebar-text); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; color: white; }
.brand:hover { color: white; }
.brand-mark { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 7px; background: #d7a73f; color: #17201e; font-weight: 700; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; font-weight: 600; }
.brand small { margin-top: 2px; color: var(--sidebar-muted); font-size: 11px; text-transform: uppercase; }
.nav-list { display: grid; gap: 3px; }
.nav-list a, .sidebar-footer a, .nav-button { min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 6px; color: var(--sidebar-text); background: transparent; width: 100%; text-align: left; }
.nav-list a:hover, .sidebar-footer a:hover, .nav-button:hover { background: #23312e; color: white; }
.nav-list a.active { background: #2a3b37; color: white; box-shadow: inset 3px 0 #d7a73f; }
.nav-count { margin-left: auto; min-width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%; background: var(--red); color: white; font-size: 11px; }
.status-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: #687873; }
.status-dot.ok { background: #50c49f; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #30403c; padding-top: 10px; }
.sidebar-footer form { margin: 0; }
.main-content { min-width: 0; width: min(1320px, 100%); padding: 28px clamp(20px, 3vw, 44px) 56px; }

.page-header { min-height: 64px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-header h1 { margin: 2px 0 0; font-size: 25px; line-height: 1.25; font-weight: 600; }
.eyebrow { margin: 0; color: var(--primary); font-size: 12px; font-weight: 600; text-transform: uppercase; }
.page-description { margin: 7px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.page-actions form, .inline-form { margin: 0; }
.category-create { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; max-width: 640px; margin: 24px 0 32px; }
.category-create .field { flex: 1 1 220px; min-width: 0; }
.category-create > .button { margin-top: 24px; }
.category-section { margin-top: 28px; }
.category-empty { color: var(--muted); padding: 14px 0; border-top: 1px solid var(--border); }
.category-table { table-layout: fixed; }
.category-table th:last-child { width: 100px; }
.category-table td { overflow-wrap: anywhere; }
.category-actions { display: flex; gap: 8px; justify-content: flex-end; }
.category-actions form { margin: 0; }
.category-actions .icon-button { width: 34px; height: 34px; }
.category-actions .icon-button:disabled { opacity: .4; cursor: not-allowed; }
.builtin-category-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0 20px; list-style: none; padding: 0; margin: 0; color: var(--muted); }
.builtin-category-list li { padding: 12px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.notification-settings { max-width: 720px; padding: 20px 0; border-top: 1px solid var(--border); }
.notification-form { display: grid; gap: 18px; }
.notification-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.notification-options .confirmation-check { margin: 0; }
.notification-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.notification-actions form, .notifications-table form { margin: 0; }
.notification-actions .button:disabled { cursor: not-allowed; }
.notification-history { margin-top: 24px; }
.notification-count { color: var(--muted); font-size: 12px; }
.notifications-table { table-layout: fixed; }
.notifications-table th:nth-child(1) { width: 23%; }
.notifications-table th:nth-child(2) { width: 29%; }
.notifications-table th:nth-child(4) { width: 90px; }
.notifications-table th:nth-child(5) { width: 68px; }
.notifications-table td { min-width: 0; overflow-wrap: anywhere; }
.notifications-table .icon-button { margin-left: auto; }
.notification-error { max-width: 100%; }
.status-sent { background: #e5f3ed; color: #0f674f; }
.status-pending, .status-sending { background: #e9eef5; color: #375674; }
@media (max-width: 700px) {
  .notification-options { grid-template-columns: minmax(0, 1fr); }
  .notifications-table-wrap { overflow: visible; background: transparent; box-shadow: none; }
  .notifications-table, .notifications-table tbody { display: block; }
  .notifications-table thead { display: none; }
  .notifications-table tr { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 10px 12px; padding: 16px 0; border-bottom: 1px solid var(--border); }
  .notifications-table td { padding: 0; border: 0; }
  .notifications-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .notifications-table td:nth-child(2) { grid-column: 1; grid-row: 2; }
  .notifications-table td:nth-child(3) { grid-column: 1; grid-row: 3; color: var(--muted); font-size: 12px; }
  .notifications-table td:nth-child(4) { grid-column: 2; grid-row: 3; align-self: center; font-size: 12px; color: var(--muted); }
  .notifications-table td:nth-child(4)::before { content: attr(data-label) " "; }
  .notifications-table td:nth-child(5) { grid-column: 2; grid-row: 1 / 3; align-self: center; }
  .category-create { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .category-create > .button { margin-top: 0; }
  .category-table-wrap { overflow: visible; }
  .category-table, .category-table tbody { display: block; }
  .category-table thead { display: none; }
  .category-table tr { display: grid; grid-template-columns: minmax(0, 1fr) 82px; padding: 14px; gap: 8px; border-bottom: 1px solid var(--border); }
  .category-table td { padding: 0; border: 0; }
  .category-table td:nth-child(2) { grid-column: 1; grid-row: 2; font-size: 12px; color: var(--muted); }
  .category-table td:last-child { grid-column: 2; grid-row: 1 / 3; align-self: center; }
}
.dashboard-filter { display: flex; gap: 8px; }
.dashboard-filter input { min-width: 150px; }
.dashboard-filter select { width: 92px; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

.button, .icon-button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; box-shadow: var(--shadow); }
.button { min-height: 38px; padding: 8px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 550; }
.button:hover { border-color: #aab8b4; color: var(--text); }
.button.primary { border-color: var(--primary); background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); color: white; }
.button.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.button.compact { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.button:disabled { opacity: .55; cursor: wait; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.metric { padding: 17px 18px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 7px 0 5px; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.positive { color: var(--green) !important; }
.danger { color: var(--red) !important; }
.danger-text { color: var(--red); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .85fr); gap: 18px; }
.content-section, .form-section { padding: 20px; border-top: 2px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.bar-chart { display: grid; gap: 16px; }
.bar-meta { display: flex; justify-content: space-between; gap: 12px; }
.bar-meta strong { font-variant-numeric: tabular-nums; }
.bar-track { height: 7px; margin: 7px 0 5px; overflow: hidden; border-radius: 3px; background: var(--surface-soft); }
.bar-track span { display: block; min-width: 2px; height: 100%; border-radius: inherit; background: var(--blue); }
.bar-row:nth-child(3n+2) .bar-track span { background: var(--primary); }
.bar-row:nth-child(3n) .bar-track span { background: var(--gold); }
.bar-row small { color: var(--muted); }

.alert-list { display: grid; }
.alert-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 11px 0; border-bottom: 1px solid var(--border); color: var(--text); }
.alert-row:last-child { border: 0; }
.alert-row small, td small { display: block; margin-top: 3px; color: var(--muted); }
.alert-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--gold); background: #f7edd8; }
.alert-row b { color: var(--red); font-variant-numeric: tabular-nums; }

.message-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.message { padding: 11px 13px; border-left: 3px solid var(--blue); background: #eaf2fa; }
.message.success { border-color: var(--green); background: #e8f5f0; }
.message.error { border-color: var(--red); background: #fbeceb; }

.connection-strip { display: flex; align-items: center; gap: 13px; padding: 15px 18px; margin-bottom: 18px; border-left: 3px solid var(--gold); background: #fff7e6; }
.connection-strip.connected { border-color: var(--green); background: #eaf6f1; }
.connection-strip p, .connection-strip strong { margin: 0; }
.connection-strip p { margin-top: 3px; color: var(--muted); }
.connection-icon { width: 32px; height: 32px; display: grid; place-items: center; }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.form-section.narrow { max-width: 680px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.provider-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.provider-fields[hidden] { display: none; }
.form-stack { display: grid; gap: 10px; }
.form-stack p { display: grid; gap: 6px; margin: 0; }
.field { display: grid; gap: 6px; }
.field-full, .form-actions { grid-column: 1 / -1; }
.field label, .filter-bar label, .form-stack label { font-size: 12px; font-weight: 600; color: #46524f; }
.field-check { display: flex; align-items: center; gap: 8px; padding-top: 22px; }
.field-check label { order: 2; }
.field-check input { width: 17px; height: 17px; }
input:not([type="checkbox"]):not([type="hidden"]), select, textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid #b9c4c1; border-radius: 5px; background: white; color: var(--text); }
textarea { min-height: 82px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgb(34 102 168 / 22%); outline-offset: 1px; }
.field small { color: var(--muted); }
.field-error { color: var(--red) !important; }
.form-actions { margin-top: 4px; }
.sticky-actions { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 14px 0; margin-top: 10px; background: linear-gradient(transparent, var(--bg) 20%); }
.device-code { display: grid; justify-items: start; gap: 12px; margin-top: 18px; padding: 18px; background: var(--surface-soft); }
.device-code p { margin: 0; }
.device-code strong { font-size: 27px; letter-spacing: 4px; font-variant-numeric: tabular-nums; }
.setup-steps { margin: 20px 0 0; padding-left: 20px; color: var(--muted); }
.setup-steps li { padding: 3px 0; }
.mailbox-note { margin-top: 20px; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; padding: 12px 0; margin-bottom: 12px; }
.filter-bar > div { min-width: 150px; }
.filter-bar.wide > div:first-child { flex: 1 1 230px; }
.filter-bar input, .filter-bar select { min-width: 145px; }
.table-wrap { overflow-x: auto; border-top: 2px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #f8faf9; font-size: 12px; font-weight: 600; }
td { min-width: 92px; }
tbody tr:hover { background: #fafcfb; }
.nowrap { white-space: nowrap; }
.align-right { text-align: right; }
.amount { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.inline-category select { min-width: 108px; width: auto; }
.classification-control { display: flex; align-items: center; gap: 6px; min-width: 0; }
.classification-value { white-space: nowrap; }
.classification-reset { width: 34px; height: 34px; box-shadow: none; }
.table-action { display: block; margin-top: 6px; font-size: 12px; }
.transaction-context { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; padding: 16px 18px; border-left: 3px solid var(--blue); background: #eaf2fa; }
.transaction-context h2 { margin: 0; }
.transaction-context p { margin: 6px 0 0; color: #3f4a48; }
.transaction-context .row-actions { flex-wrap: wrap; }
.transaction-context .row-actions form { margin: 0; }
.transactions-table tr.transaction-related { background: #f2f8f5; }
.transactions-table tr:target { outline: 2px solid var(--primary); outline-offset: -2px; background: #e3f1eb; }
.transactions-table tr, .risk-item { scroll-margin-top: 80px; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 12px; background: #edf1f0; color: #4b5855; font-size: 12px; white-space: nowrap; }
.status-parsed, .status-reconciled, .status-refund, .status-normal { background: #e5f3ed; color: #0f674f; }
.status-needs_review, .status-annual_fee, .status-bank_fee { background: #fff0d5; color: #80500b; }
.status-failed, .status-data_quality { background: #fae7e5; color: #9c2823; }
.status-duplicate, .status-unsupported { background: #e9eef5; color: #375674; }

.card-list, .risk-list, .settings-list { display: grid; gap: 10px; }
.credit-card-row { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(340px, 1.6fr) auto; gap: 18px; align-items: center; padding: 16px 18px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.card-identity { display: flex; align-items: center; gap: 12px; }
.card-identity h2, .card-identity p { margin: 0; }
.card-identity p { margin-top: 3px; color: var(--muted); }
.bank-monogram { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 7px; background: #e6f0ed; color: var(--primary); font-weight: 700; }
.credit-card-row dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0; }
.credit-card-row dl div { min-width: 0; }
.credit-card-row dt { color: var(--muted); font-size: 11px; }
.credit-card-row dd { margin: 4px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.risk-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) 150px; gap: 16px; align-items: center; padding: 16px 18px; border-left: 3px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.risk-score { text-align: center; color: var(--blue); }
.risk-score.warning { color: var(--gold); }
.risk-score.critical { color: var(--red); }
.risk-score strong, .risk-score span { display: block; }
.risk-score strong { font-size: 22px; }
.risk-score span { color: var(--muted); font-size: 10px; }
.risk-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.risk-title h2, .risk-body p { margin: 0; }
.risk-body p { margin-top: 6px; color: #3f4a48; }
.risk-body small { display: block; margin-top: 7px; color: var(--muted); }
.risk-title h2 a { color: var(--text); }
.risk-title h2 a:hover { color: var(--primary); text-decoration: underline; }
.risk-transactions { display: grid; gap: 7px; margin: 12px 0; padding: 0; list-style: none; font-size: 12px; }
.risk-transactions a { display: block; width: fit-content; max-width: 100%; overflow-wrap: anywhere; }
.risk-transactions a:hover { text-decoration: underline; }
.risk-transactions span { display: block; margin-top: 2px; color: var(--muted); }
.risk-detail-link { margin-top: 12px; }
.settings-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 17px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.settings-row h2, .settings-row p { margin: 0; }
.settings-row p { margin-top: 4px; color: var(--muted); }
.settings-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-soft); color: var(--primary); }
.detail-list { display: grid; gap: 0; margin: 0; }
.detail-list div { display: grid; grid-template-columns: 95px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.review-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.review-actions, .review-transactions { margin-top: 24px; }
.review-actions .inline-form { flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.review-actions select { width: min(280px, 100%); }
.review-warnings { padding-left: 20px; color: var(--red); overflow-wrap: anywhere; }
.review-warnings li { margin: 8px 0; }
.review-table td:nth-child(3) { min-width: 180px; max-width: 380px; overflow-wrap: anywhere; }
.source-preview { margin: 24px 0; }
.source-preview summary { cursor: pointer; font-weight: 600; }
.source-preview pre { max-height: 320px; overflow: auto; padding: 16px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; }
.review-confirmation { padding: 20px 0; border-top: 1px solid var(--border); margin-top: 24px; }
.review-confirmation form { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.confirmation-check { display: flex; align-items: center; gap: 8px; }
.confirmation-check input { flex: 0 0 18px; width: 18px; height: 18px; }
.pagination, .pagination-controls { display: flex; align-items: center; gap: 12px; }
.pagination { justify-content: space-between; padding: 16px 0; color: var(--muted); }
.pagination-controls { min-height: 38px; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .review-columns { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .review-actions .inline-form { align-items: stretch; }
  .review-actions select { width: 100%; }
  .review-confirmation form { align-items: stretch; }
  .review-confirmation .button { width: 100%; }
  .review-transactions .section-heading { flex-wrap: wrap; gap: 10px; }
  .review-transactions .table-wrap { overflow: visible; border: 0; box-shadow: none; background: transparent; }
  .review-table, .review-table tbody { display: block; }
  .review-table thead { display: none; }
  .review-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, auto); grid-template-areas: "merchant amount" "date posted" "direction original"; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--border); }
  .review-table td { min-width: 0; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .review-table td:nth-child(1) { grid-area: date; color: var(--muted); font-size: 12px; }
  .review-table td:nth-child(2) { grid-area: posted; text-align: right; color: var(--muted); font-size: 12px; }
  .review-table td:nth-child(2)::before { content: "入账 "; }
  .review-table td:nth-child(3) { grid-area: merchant; min-width: 0; max-width: none; }
  .review-table td:nth-child(4) { grid-area: direction; color: var(--muted); font-size: 12px; }
  .review-table td:nth-child(5) { grid-area: amount; }
  .review-table td:nth-child(6) { grid-area: original; font-size: 12px; color: var(--muted); }
  .review-table td:nth-child(6)::before { content: "原币 "; font-weight: 400; }
}

.empty-state { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 7px; padding: 30px; text-align: center; border: 1px dashed #b7c2bf; background: var(--surface); }
.empty-state svg { width: 30px; height: 30px; color: var(--muted); }
.empty-state h2, .empty-state h3, .empty-state p { margin: 0; }
.empty-state p { color: var(--muted); }
.empty-state .button { margin-top: 8px; }
.success-empty svg { color: var(--green); }
.empty-inline { display: flex; align-items: center; gap: 8px; color: var(--muted); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9efed; }
.auth-panel { width: min(390px, 100%); padding: 30px; border-top: 3px solid var(--gold); background: var(--surface); box-shadow: 0 8px 30px rgb(23 32 30 / 12%); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand h1, .auth-brand p { margin: 0; }
.auth-brand h1 { font-size: 21px; }
.auth-brand p { margin-top: 3px; color: var(--muted); }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .two-column { grid-template-columns: 1fr; }
  .credit-card-row { grid-template-columns: 1fr auto; }
  .credit-card-row dl { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; z-index: 10; height: auto; padding: 8px 10px; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { padding: 0; margin-right: 4px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand span:last-child, .nav-list span, .sidebar-footer { display: none; }
  .nav-list { display: flex; gap: 2px; }
  .nav-list a { width: 40px; min-height: 40px; justify-content: center; padding: 8px; }
  .nav-list a.active { box-shadow: inset 0 -3px #d7a73f; }
  .nav-count { position: absolute; margin: -26px 0 0 24px; min-width: 17px; height: 17px; }
  .status-dot { position: absolute; margin: 23px 0 0 24px; }
  .main-content { padding: 20px 14px 40px; }
  .page-header { align-items: center; margin-bottom: 18px; }
  .page-header h1 { font-size: 21px; }
  .metric { padding: 14px; }
  .metric strong { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .provider-fields { grid-template-columns: 1fr; }
  .field-full, .form-actions { grid-column: auto; }
  .credit-card-row { grid-template-columns: 1fr; }
  .credit-card-row dl { grid-column: auto; grid-row: auto; grid-template-columns: repeat(2, 1fr); }
  .row-actions { justify-content: space-between; }
  .risk-item { grid-template-columns: 52px minmax(0, 1fr); align-items: start; }
  .risk-action { grid-column: 2; }
  .settings-row { grid-template-columns: 36px minmax(0, 1fr); }
  .settings-row > :last-child { grid-column: 2; justify-self: start; }
  .transactions-table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .transactions-table, .transactions-table tbody { display: block; }
  .transactions-table thead { display: none; }
  .transactions-table tbody { display: grid; gap: 9px; }
  .transactions-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "merchant amount" "card date" "category type";
    gap: 9px 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .transactions-table td { min-width: 0; padding: 0; border: 0; }
  .transactions-table td:nth-child(1) { grid-area: date; justify-self: end; color: var(--muted); font-size: 12px; }
  .transactions-table td:nth-child(2) { grid-area: card; color: var(--muted); font-size: 12px; }
  .transactions-table td:nth-child(3) { grid-area: merchant; overflow-wrap: anywhere; }
  .transactions-table td:nth-child(4) { grid-area: category; }
  .transactions-table td:nth-child(5) { grid-area: type; align-self: center; justify-self: end; color: var(--muted); }
  .transactions-table td:nth-child(6) { grid-area: amount; align-self: start; }
  .transactions-table .classification-control { flex-wrap: wrap; }
  .transactions-table .inline-category select { width: 130px; min-width: 0; }
  .imports-table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .imports-table, .imports-table tbody { display: block; }
  .imports-table thead { display: none; }
  .imports-table tbody { display: grid; gap: 9px; }
  .imports-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "bank state" "file file" "parser confidence" "time time";
    gap: 8px 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .imports-table td { min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
  .imports-table td:nth-child(1) { grid-area: time; color: var(--muted); font-size: 12px; }
  .imports-table td:nth-child(2) { grid-area: bank; }
  .imports-table td:nth-child(3) { grid-area: file; }
  .imports-table td:nth-child(4) { grid-area: parser; color: var(--muted); }
  .imports-table td:nth-child(5) { grid-area: confidence; justify-self: end; color: var(--muted); }
  .imports-table td:nth-child(6) { grid-area: state; display: grid; justify-items: end; gap: 5px; }
  .imports-table .table-action { margin-top: 2px; }
  .rules-table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .rules-table, .rules-table tbody { display: block; }
  .rules-table thead { display: none; }
  .rules-table tbody { display: grid; gap: 9px; }
  .rules-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "merchant category" "merchant count" "updated action";
    gap: 7px 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .rules-table td { min-width: 0; padding: 0; border: 0; }
  .rules-table td:nth-child(1) { grid-area: merchant; overflow-wrap: anywhere; }
  .rules-table td:nth-child(2) { grid-area: category; }
  .rules-table td:nth-child(3) { grid-area: count; }
  .rules-table td:nth-child(4) { grid-area: updated; color: var(--muted); font-size: 12px; }
  .rules-table td:nth-child(5) { grid-area: action; justify-self: end; }
  .rules-table td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: 11px; }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { min-width: 0; }
  .metric strong { font-size: 18px; overflow-wrap: anywhere; }
  .page-header { flex-wrap: wrap; }
  .page-actions { width: 100%; justify-content: stretch; }
  .page-actions > * { flex: 1 1 140px; }
  .page-actions .button { width: 100%; }
  .filter-bar > div, .filter-bar input, .filter-bar select { width: 100%; min-width: 0; }
  .filter-bar .button { width: 100%; }
}
