:root {
  color-scheme: light;
  --ink: #18302b;
  --muted: #697b77;
  --line: #dfe8e5;
  --paper: #ffffff;
  --wash: #f3f7f5;
  --brand: #087f5b;
  --brand-dark: #075f47;
  --positive: #087f5b;
  --negative: #b5473c;
  font-family: Inter, "Noto Sans Thai", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--wash); color: var(--ink); }
a { color: var(--brand-dark); text-decoration: none; font-weight: 700; }
.topbar { min-height: 88px; padding: 20px clamp(20px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar h1, .login-card h1 { margin: 2px 0 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.03em; }
.eyebrow { margin: 0; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 20px; }
.top-actions form { margin: 0; }
.link-button { padding: 0; border: 0; background: none; color: var(--brand-dark); font: inherit; font-weight: 700; cursor: pointer; }
.page-shell { width: min(1440px, 100%); margin: 0 auto; padding: 28px clamp(16px, 4vw, 56px) 72px; }
section { margin-bottom: 34px; }
h2 { margin: 0 0 14px; font-size: 18px; }
.metric-grid, .account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metric-card, .account-card, .statement-list, .table-wrap, .filters { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 3px 14px rgba(32, 68, 58, .04); }
.metric-card { padding: 20px; }
.metric-card span, .account-card .muted { display: block; color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin-top: 8px; font-size: clamp(24px, 3vw, 36px); }
.metric-card.positive strong { color: var(--positive); }
.metric-card.negative strong { color: var(--negative); }
.account-card { padding: 18px; display: grid; gap: 8px; }
.account-heading { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.account-role { padding: 4px 8px; border-radius: 999px; background: #e5f5ef; color: var(--brand-dark); font-weight: 700; }
.account-card > strong { font-size: 19px; }
.account-card .balance { font-size: 23px; font-weight: 800; }
.statement-list { overflow: hidden; }
.statement-row { display: flex; justify-content: space-between; gap: 18px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.statement-row:last-child { border-bottom: 0; }
.statement-row div { display: grid; gap: 4px; }
.statement-row div:last-child { text-align: right; }
.statement-row span { color: var(--muted); font-size: 12px; }
.filters { display: flex; align-items: end; gap: 12px; padding: 14px; margin-bottom: 14px; }
.filters label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
select { min-width: 145px; border: 1px solid #cbd9d5; border-radius: 9px; background: var(--paper); color: var(--ink); padding: 9px 32px 9px 10px; font: inherit; }
.primary-button { border: 0; border-radius: 9px; padding: 10px 18px; background: var(--brand); color: white; font: inherit; font-weight: 800; cursor: pointer; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); background: #f9fbfa; font-size: 12px; letter-spacing: .03em; }
td { font-size: 13px; }
td small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.35; max-width: 320px; }
td.money { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 800; }
.money.credit { color: var(--positive); }
.money.debit { color: var(--negative); }
.status { display: inline-block; padding: 5px 8px; border-radius: 999px; background: #edf1f0; white-space: nowrap; }
.status-company { background: #e4f5ee; color: var(--brand-dark); }
.status-personal { background: #f7e8e5; color: #8c372f; }
.status-pending { background: #fff3d6; color: #805d05; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #dff2eb, var(--wash) 60%); }
.login-card { width: min(460px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255, 255, 255, .96); box-shadow: 0 22px 70px rgba(30, 73, 61, .12); }
.brand-mark { width: 48px; height: 48px; margin-bottom: 20px; display: grid; place-items: center; border-radius: 14px; background: var(--brand); color: white; font-size: 28px; font-weight: 900; }
.login-help { margin: 18px 0; color: #435650; line-height: 1.7; }
.security-note { padding: 12px 14px; border-radius: 10px; background: #f1f6f4; color: var(--muted); font-size: 13px; }
.language-links { display: flex; gap: 20px; margin-top: 24px; }
.auth-form { display: grid; gap: 14px; margin: 22px 0; }
.auth-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.auth-form input { width: 100%; border: 1px solid #cbd9d5; border-radius: 9px; padding: 11px 12px; background: white; color: var(--ink); font: inherit; }
.auth-form input:focus { outline: 3px solid rgba(8, 127, 91, .15); border-color: var(--brand); }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.line-login-button { display: block; padding: 12px 14px; border-radius: 9px; background: #06c755; color: white; text-align: center; font-weight: 800; }
.line-login-button.disabled { background: #a8b5b1; cursor: not-allowed; }
.register-link { display: block; margin: 18px 0; text-align: center; }
.form-error { padding: 11px 13px; border-radius: 9px; background: #fbe9e7; color: #8c372f; font-size: 13px; line-height: 1.5; }
.review-shell { max-width: 1280px; }
.review-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.review-intro h2 { margin-bottom: 6px; font-size: 24px; }
.review-intro p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.6; }
.review-metrics { display: flex; gap: 10px; }
.review-metrics span { min-width: 96px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--muted); font-size: 11px; text-align: center; }
.review-metrics strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 22px; }
.notice { margin: -16px 0 20px; padding: 12px 15px; border: 1px solid #b9dfd2; border-radius: 10px; background: #e9f7f2; color: var(--brand-dark); }
.review-tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.review-tabs a { flex: 0 0 auto; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); font-size: 13px; }
.review-tabs a.active { border-color: var(--brand); background: var(--brand); color: white; }
.review-list { display: grid; gap: 18px; }
.review-card { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 4px 18px rgba(32, 68, 58, .05); }
.review-column { min-width: 0; padding: 20px; }
.document-column { border-right: 1px solid var(--line); background: #fbfcfc; }
.review-column-heading { min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.review-column-heading h2 { margin: 0; }
.match-badge { padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.match-auto_matched { background: #e4f5ee; color: var(--brand-dark); }
.match-suggested { background: #fff3d6; color: #805d05; }
.match-confirmed { background: #e6f0ff; color: #285a9b; }
.match-rejected { background: #f7e8e5; color: #8c372f; }
.match-invalidated { background: #f2eafd; color: #67408d; }
.match-unmatched { background: #edf1f0; color: var(--muted); }
.document-preview { height: 240px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #eef3f1; }
.document-preview img { width: 100%; height: 100%; object-fit: contain; }
.file-link { display: block; padding: 28px; border: 1px dashed #b9c9c4; border-radius: 12px; text-align: center; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin: 16px 0 0; }
.detail-grid div { min-width: 0; }
.detail-grid dt { margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }
.transaction-hero { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px; border-radius: 12px; background: var(--wash); }
.transaction-hero span { color: var(--muted); font-size: 12px; }
.transaction-hero strong { font-size: 20px; }
.signal-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0; padding: 0; list-style: none; }
.signal-list li { padding: 5px 8px; border-radius: 7px; background: #edf5f2; color: #3d6258; font-size: 11px; }
.review-actions { display: flex; gap: 9px; margin-top: 18px; }
.review-actions form { margin: 0; }
.danger-button { border: 1px solid #d9a7a1; border-radius: 9px; padding: 9px 14px; background: white; color: var(--negative); font: inherit; font-weight: 800; cursor: pointer; }
.manual-match { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.manual-match summary { color: var(--brand-dark); font-size: 13px; font-weight: 800; cursor: pointer; }
.manual-match form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(130px, .7fr) minmax(0, 1fr) auto; align-items: end; gap: 10px; margin-top: 14px; }
.manual-match label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.manual-match select, .manual-match input { width: 100%; min-width: 0; border: 1px solid #cbd9d5; border-radius: 9px; background: white; color: var(--ink); padding: 9px 10px; font: inherit; }
.edit-fields { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 13px; }
.edit-fields summary { color: var(--brand-dark); font-size: 13px; font-weight: 800; cursor: pointer; }
.edit-fields form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 13px; }
.edit-fields label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.edit-fields input, .edit-fields select { width: 100%; min-width: 0; border: 1px solid #cbd9d5; border-radius: 9px; background: white; color: var(--ink); padding: 9px 10px; font: inherit; }
.edit-fields button { grid-column: 1 / -1; }
.unmatched-reasons { margin: 0 0 16px; padding: 12px 14px; border-radius: 10px; background: #fff6df; color: #6d5209; font-size: 12px; line-height: 1.55; }
.unmatched-reasons ul { margin: 6px 0 0; padding-left: 18px; }
.inline-empty { padding: 20px 0; text-align: left; }
.review-empty { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.import-shell { max-width: 1100px; }
.import-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.import-card { padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 4px 18px rgba(32, 68, 58, .05); }
.muted-copy { color: var(--muted); font-size: 13px; line-height: 1.6; }
.upload-form { display: grid; gap: 14px; margin-top: 18px; }
.upload-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.upload-form input[type="file"] { width: 100%; padding: 11px; border: 1px dashed #afc2bc; border-radius: 10px; background: var(--wash); font: inherit; }
.preview-summary { margin-bottom: 18px; }
.parse-error { padding: 12px; border-radius: 10px; background: #fbe9e7; color: #8c372f; font-weight: 700; }
.parse-error small { display: block; margin-top: 6px; font-weight: 400; overflow-wrap: anywhere; }
.bound-account-role { display: grid; gap: 4px; padding: 12px; border: 1px solid #b9dfd2; border-radius: 10px; background: #f1f8f5; }
.bound-account-role span, .bound-account-role small { color: var(--muted); font-size: 12px; }
.bound-account-role small { line-height: 1.45; }
.confirm-import { width: 100%; margin-top: 6px; }
.password-help { margin: 16px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.password-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.password-form label, .confirm-password { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.password-form input, .confirm-password input { width: 100%; border: 1px solid #cbd9d5; border-radius: 9px; padding: 10px; font: inherit; }
.confirm-password { margin: 10px 0; }
.match-ready { background: #fff3d6; color: #805d05; }
.match-password_required { background: #fff3d6; color: #805d05; }
.match-duplicate { background: #edf1f0; color: var(--muted); }
.match-failed { background: #f7e8e5; color: #8c372f; }
.upload-history a { color: var(--ink); font-weight: inherit; }
@media (max-width: 760px) {
  .login-body {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
  }
  .login-card {
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px;
    border-radius: 16px;
  }
  .login-card h1 { font-size: 25px; }
  .login-help { margin: 14px 0; line-height: 1.55; }
  .auth-form { gap: 12px; margin: 18px 0; }
  .auth-form input { min-height: 46px; font-size: 16px; }
  .auth-divider { margin: 16px 0; }
  .register-link { margin: 16px 0; }
  .language-links { margin-top: 18px; }
  .topbar { min-height: 72px; padding: 14px 18px; }
  .topbar h1 { font-size: 22px; }
  .top-actions { gap: 12px; font-size: 12px; }
  .metric-grid, .account-grid { grid-template-columns: 1fr; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters label:first-of-type { grid-column: 1 / -1; }
  select { width: 100%; min-width: 0; }
  .primary-button { grid-column: 1 / -1; }
  .statement-row { display: grid; }
  .statement-row div:last-child { text-align: left; }
  .table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  table, tbody { display: block; min-width: 0; }
  thead { display: none; }
  tr { display: grid; gap: 8px; margin-bottom: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
  td { display: grid; grid-template-columns: 105px 1fr; gap: 10px; padding: 0; border: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  td.money { text-align: left; }
  .review-intro { display: grid; }
  .review-metrics { width: 100%; }
  .review-metrics span { min-width: 0; flex: 1; }
  .review-card { grid-template-columns: 1fr; }
  .document-column { border-right: 0; border-bottom: 1px solid var(--line); }
  .review-column { padding: 16px; }
  .document-preview { height: min(54vh, 330px); }
  .manual-match form { grid-template-columns: 1fr; }
  .review-actions { display: grid; grid-template-columns: 1fr; }
  .review-actions form, .review-actions button { width: 100%; }
  .import-grid { grid-template-columns: 1fr; }
  .import-card { padding: 17px; }
  .password-form { grid-template-columns: 1fr; }
}
