:root {
    --ink: #17232e;
    --muted: #657483;
    --line: #dce4e9;
    --paper: #ffffff;
    --canvas: #f4f7f8;
    --primary: #175c51;
    --primary-hover: #0f493f;
    --primary-soft: #e6f2ee;
    --accent: #cb8a26;
    --danger: #a83c36;
    --danger-soft: #fff0ed;
    --success: #176c4b;
    --success-soft: #e8f5ed;
    --warning: #8a5b0a;
    --warning-soft: #fff5d9;
    --shadow: 0 12px 35px rgba(27, 48, 63, .05);
}
* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button, select, input { min-height: 42px; }
input, select { width: 100%; border: 1px solid #cbd6dc; border-radius: 9px; padding: 10px 12px; color: var(--ink); background: #fff; }
input:focus, select:focus { outline: 3px solid rgba(23, 92, 81, .15); border-color: var(--primary); }
input[type="file"] { padding: 8px; background: #fbfcfc; }
label { display: block; margin: 3px 0 6px; font-weight: 650; font-size: 13px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(25px, 3vw, 32px); line-height: 1.2; letter-spacing: -.7px; }
h2 { margin-bottom: 4px; font-size: 19px; letter-spacing: -.25px; }
h3 { margin-bottom: 9px; font-size: 15px; }
small { font-size: 12px; }
.topbar { min-height: 76px; padding: 0 4.5vw; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 26px; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; color: var(--ink); font-weight: 800; font-size: 17px; line-height: 1.1; }
.brand:hover { text-decoration: none; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 550; letter-spacing: .3px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 39px; height: 39px; border-radius: 12px; background: var(--primary); color: white; font-size: 12px; letter-spacing: .3px; }
.main-nav { display: flex; align-items: center; gap: 4px; height: 76px; }
.main-nav a { display: inline-flex; align-items: center; height: 100%; padding: 0 16px; color: #51616c; font-weight: 650; border-bottom: 3px solid transparent; }
.main-nav a:hover { color: var(--primary); text-decoration: none; }
.main-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.user-menu { display: flex; align-items: center; gap: 12px; color: #43525e; font-weight: 600; white-space: nowrap; }
.user-menu form { margin: 0; }
.container { width: min(1440px, 92vw); min-height: calc(100vh - 135px); margin: 0 auto; padding: 34px 0 60px; }
.login-main { display: flex; justify-content: center; align-items: center; min-height: calc(100vh - 50px); padding: 28px 16px; }
.login-card { width: min(430px, 100%); border: 1px solid var(--line); border-radius: 20px; padding: 34px; background: var(--paper); box-shadow: var(--shadow); }
.brand-login { margin-bottom: 35px; }
.login-card h1 { font-size: 27px; }
.muted { color: var(--muted); }
.login-card .muted { margin-bottom: 23px; }
.form-stack { display: flex; flex-direction: column; gap: 8px; }
.form-stack label:not(:first-child) { margin-top: 7px; }
.form-help { color: var(--muted); font-size: 12px; margin: 2px 0 4px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 42px; padding: 10px 15px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; text-decoration: none; font-weight: 700; font-size: 13px; white-space: nowrap; transition: background .15s, border-color .15s; }
.button:hover { text-decoration: none; }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { color: var(--primary); background: white; border-color: #b7cbc5; }
.button-secondary:hover { background: var(--primary-soft); }
.button-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.button-quiet:hover { color: var(--ink); background: #f7f9fa; }
.button-danger { color: var(--danger); background: white; border-color: #e4b5ae; }
.button-danger:hover { background: var(--danger-soft); }
.button-small { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.button-full { width: 100%; margin-top: 10px; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-heading > div { max-width: 800px; }
.page-heading .muted { margin-bottom: 0; }
.eyebrow { margin-bottom: 8px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: 1.6px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 39px; }
.stat-card { min-height: 135px; padding: 21px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: flex-start; }
.stat-card-accent { background: #f0f7f4; border-color: #cde1d9; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-card strong { margin: 10px 0 8px; font-size: clamp(24px, 2.4vw, 32px); letter-spacing: -.8px; line-height: 1.1; }
.stat-foot { margin-top: auto; color: #75828b; font-size: 11px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 36px 0 15px; }
.section-heading .muted { margin: 4px 0 0; font-size: 13px; }
.text-link { font-size: 12px; font-weight: 750; white-space: nowrap; }
.suggestion-list, .transaction-list { display: flex; flex-direction: column; gap: 13px; }
.suggestion-card, .transaction-card, .panel, .empty-state { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.suggestion-card { padding: 17px 19px 14px; }
.suggestion-main { display: flex; align-items: flex-start; gap: 12px; }
.transaction-symbol { display: grid; place-items: center; flex: 0 0 37px; width: 37px; height: 37px; border-radius: 11px; color: var(--success); background: var(--success-soft); font-size: 20px; }
.suggestion-copy { flex: 1; min-width: 0; }
.suggestion-topline { display: flex; flex-wrap: wrap; align-items: center; gap: 11px; }
.suggestion-topline > strong { font-size: 18px; letter-spacing: -.3px; }
.suggestion-topline > span { color: var(--muted); font-size: 12px; }
.suggestion-copy p { margin: 5px 0 0; overflow-wrap: anywhere; font-weight: 600; }
.suggestion-copy small { display: block; margin-top: 3px; color: var(--muted); }
.account-pill { padding: 3px 8px; border-radius: 6px; background: #f0f3f5; color: #52616b !important; }
.match-proposal { display: flex; align-items: center; gap: 14px; margin: 14px 0 0 49px; padding: 13px; background: #f7faf9; border: 1px solid #e0ebe7; border-radius: 10px; }
.match-score { flex: 0 0 54px; text-align: center; color: var(--primary); }
.match-score strong { display: block; font-size: 17px; }
.match-score span { display: block; font-size: 9px; color: var(--muted); }
.proposal-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.proposal-copy strong { overflow-wrap: anywhere; }
.proposal-copy span, .proposal-copy small { color: var(--muted); font-size: 11px; }
.inline-form { margin: 0; }
.alternative-note { margin: 10px 0 0 49px; color: var(--muted); font-size: 11px; }
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
th { padding: 12px 15px; color: #687782; background: #f8fafb; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; font-weight: 800; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 13px 15px; border-bottom: 1px solid #edf1f3; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.table-subtitle { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 100px; font-size: 10px; font-weight: 750; white-space: nowrap; background: #eef2f4; color: #5a6771; }
.status-completed { color: var(--success); background: var(--success-soft); }
.status-completed_with_errors { color: var(--warning); background: var(--warning-soft); }
.status-failed { color: var(--danger); background: var(--danger-soft); }
.status-processing { color: #855b0c; background: #fff4d8; }
.status-neutral { color: #596772; background: #eef2f4; }
.amount-open { color: #9b5d08; }
.amount-closed { color: var(--success); }
.row-muted { color: #6e7a83; }
.empty-state { text-align: center; padding: 48px 20px; }
.empty-icon { display: inline-grid; place-items: center; width: 50px; height: 50px; margin-bottom: 14px; border-radius: 15px; color: var(--primary); background: var(--primary-soft); font-size: 25px; }
.empty-state h3 { font-size: 18px; }
.empty-state p { max-width: 500px; margin: 0 auto 20px; color: var(--muted); }
.empty-inline { color: var(--muted); padding: 22px; border: 1px dashed #c8d2d9; border-radius: 12px; text-align: center; background: #fbfcfc; }
.notice { margin: 0 0 17px; padding: 12px 15px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; }
.notice-success { color: #155f41; background: var(--success-soft); border-color: #cce6d5; }
.notice-error { color: #922f29; background: var(--danger-soft); border-color: #f0d0c9; }
.notice-warning { color: #785009; background: var(--warning-soft); border-color: #ead9a4; }
.notice-info { color: #315a72; background: #eaf4f8; border-color: #cfe3ec; }
.balance-review-box { width: 220px; max-width: 100%; margin-top: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.balance-review-box p { margin: 0; color: var(--warning); font-size: 11px; }
.balance-review-box form { margin: 0; width: 100%; }
.balance-review-box .button { white-space: normal; width: 100%; }
.balance-review-box small { display: block; color: var(--muted); font-size: 10px; line-height: 1.4; }
.compact-notice { margin-top: 14px; }
.import-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.panel { padding: 22px; min-width: 0; }
.panel-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 15px; }
.panel-heading h2 { margin-bottom: 2px; }
.panel-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.step-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; flex: 0 0 36px; color: var(--primary); background: var(--primary-soft); font-size: 14px; font-weight: 800; }
.small-text { font-size: 12px; line-height: 1.6; }
.draft-box { margin-top: 19px; padding-top: 19px; border-top: 1px solid var(--line); }
.mini-stats { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0; }
.mini-stats span { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font-size: 10px; }
.mini-stats strong { color: var(--ink); }
.mini-table { max-width: 100%; margin: 12px 0; }
.mini-table table { font-size: 11px; }
.mini-table th, .mini-table td { padding: 8px 9px; }
.errors-details { margin: 11px 0; padding: 10px; border-radius: 8px; background: #fff8e8; color: #765313; font-size: 12px; }
.errors-details summary, .history-details summary { cursor: pointer; font-weight: 750; }
.errors-details ul { padding-left: 19px; }
.errors-details li { margin: 5px 0; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.inline-help { margin: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mapping-form { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfc; }
.mapping-form button { margin-top: 8px; }
.filter-bar { display: flex; align-items: center; gap: 10px; margin: 20px 0 17px; }
.search-field { display: block; flex: 1; margin: 0; }
.filter-select { display: block; width: 220px; margin: 0; }
.transaction-card { padding: 18px; }
.transaction-header { display: flex; align-items: center; gap: 16px; }
.transaction-amount { min-width: 130px; font-size: 19px; font-weight: 800; letter-spacing: -.5px; }
.transaction-amount.positive { color: var(--success); }
.transaction-amount.negative { color: var(--muted); }
.transaction-description { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.transaction-description strong { overflow-wrap: anywhere; }
.transaction-description span, .transaction-description small { color: var(--muted); font-size: 11px; }
.transaction-status { margin-left: auto; }
.transaction-suggestions { margin-top: 17px; border-top: 1px solid var(--line); padding-top: 13px; }
.suggestion-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; }
.candidate-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid #edf1f3; }
.candidate-row:last-child { border-bottom: 0; }
.candidate-score { display: grid; place-items: center; width: 43px; height: 38px; flex: 0 0 43px; border-radius: 9px; color: var(--primary); background: var(--primary-soft); font-weight: 850; }
.candidate-details { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.candidate-details strong { overflow-wrap: anywhere; }
.candidate-details span { color: var(--muted); font-size: 11px; }
.candidate-row form { margin: 0; }
.no-suggestion { margin-top: 13px; padding: 11px 13px; border-radius: 8px; background: #f5f7f8; color: var(--muted); font-size: 12px; }
.confirmed-match { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-top: 15px; padding: 13px; border-radius: 9px; background: var(--success-soft); }
.confirmed-match > div { display: flex; flex-direction: column; gap: 3px; }
.confirmed-match span { color: #44715c; font-size: 11px; }
.reverse-form { display: flex; align-items: center; gap: 6px; margin: 0; }
.reverse-form input { width: min(230px, 34vw); min-height: 34px; padding: 7px; font-size: 11px; }
.history-details { margin-top: 13px; color: var(--muted); font-size: 11px; }
.history-details p { margin: 8px 0 0; }
.footer { display: flex; justify-content: space-between; gap: 18px; padding: 14px 4.5vw; border-top: 1px solid var(--line); background: #fff; color: #84909a; font-size: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 1050px) {
    .topbar { padding: 0 3vw; gap: 12px; }
    .main-nav a { padding: 0 9px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .import-grid { grid-template-columns: 1fr; }
    .container { width: 94vw; }
}
@media (max-width: 700px) {
    body { font-size: 13px; }
    .topbar { min-height: auto; padding: 12px 4vw 0; flex-wrap: wrap; gap: 8px; }
    .brand { font-size: 15px; }
    .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
    .user-menu { margin-left: auto; gap: 6px; font-size: 11px; }
    .main-nav { order: 3; width: 100%; height: 44px; overflow-x: auto; gap: 0; }
    .main-nav a { flex: 1 0 auto; justify-content: center; padding: 0 12px; font-size: 12px; }
    .container { width: 92vw; padding-top: 23px; }
    .page-heading { align-items: flex-start; flex-direction: column; gap: 13px; margin-bottom: 22px; }
    .page-heading > .button { width: 100%; }
    h1 { font-size: 26px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 30px; }
    .stat-card { min-height: 118px; padding: 14px; border-radius: 12px; }
    .stat-label { font-size: 10px; }
    .stat-card strong { font-size: 23px; margin: 9px 0 6px; overflow-wrap: anywhere; }
    .stat-foot { font-size: 10px; }
    .section-heading { align-items: flex-start; flex-direction: column; margin-top: 29px; }
    .suggestion-card { padding: 13px; }
    .match-proposal { margin-left: 0; gap: 8px; padding: 10px; flex-wrap: wrap; }
    .proposal-copy { flex-basis: calc(100% - 65px); }
    .match-proposal .inline-form { margin-left: 62px; }
    .alternative-note { margin-left: 0; }
    .panel { padding: 16px; }
    .field-row { grid-template-columns: 1fr; }
    .button-row { align-items: stretch; flex-direction: column; }
    .button-row > * { width: 100%; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-select { width: 100%; }
    .transaction-card { padding: 13px; }
    .transaction-header { align-items: flex-start; gap: 9px; flex-wrap: wrap; }
    .transaction-amount { min-width: auto; flex-basis: 100%; font-size: 19px; }
    .transaction-description { flex-basis: calc(100% - 5px); }
    .transaction-status { margin-left: 0; }
    .candidate-row { align-items: flex-start; flex-wrap: wrap; }
    .candidate-details { flex-basis: calc(100% - 55px); }
    .candidate-row form { margin-left: 54px; }
    .confirmed-match { align-items: flex-start; }
    .reverse-form { width: 100%; }
    .reverse-form input { flex: 1; width: 1px; }
    .footer { flex-direction: column; gap: 4px; padding: 13px 4vw; }
    .login-card { padding: 26px 22px; }
}
@media (max-width: 390px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 100px; }
    .user-menu > span { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
    .main-nav a { padding: 0 9px; }
}
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px; margin: 22px 0; }
.pagination span { color: var(--muted); font-size: 12px; font-weight: 700; }
.manual-match-details { margin-top: 13px; padding-top: 12px; border-top: 1px solid #edf1f3; color: var(--muted); font-size: 12px; }
.manual-match-details summary { cursor: pointer; font-weight: 750; }
.manual-search-form, .manual-confirm-form { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.manual-search-controls { display: flex; gap: 8px; }
.manual-search-controls input { flex: 1; min-width: 0; }
.manual-confirm-form { padding: 12px; background: #f7faf9; border: 1px solid #e0ebe7; border-radius: 9px; color: var(--ink); }
.manual-confirm-form select { min-height: 44px; }
@media (max-width: 700px) { .manual-search-controls { align-items: stretch; flex-direction: column; } }
