:root {
  color-scheme: light;
  font-family: "DM Sans", "Noto Sans TC", system-ui, sans-serif;
  color: #172b27;
  background: #f5f7f5;
  font-synthesis: none;
  --green: #17483f;
  --green-dark: #10382f;
  --mint: #e5f2ec;
  --muted: #71817c;
  --line: #e5ebe7;
  --surface: #fff;
  --red: #bd5c54;
  --shadow: 0 10px 35px #173d3020;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar { height: 68px; padding: 0 max(22px, calc((100vw - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.button-small { min-height: 34px; padding: 0 11px; font-size: 11px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--green); font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; color: white; border-radius: 11px; background: var(--green); }
.local-badge { color: var(--muted); font-size: 12px; }
.local-badge span { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #55a47b; }
.shell { width: min(100% - 40px, 1120px); margin: 0 auto; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 46px 0 32px; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 650px; margin-bottom: 10px; font-size: clamp(27px, 4vw, 40px); letter-spacing: -.035em; line-height: 1.22; }
h2 { margin-bottom: 0; font-size: 25px; letter-spacing: -.025em; }
h3 { margin-bottom: 0; font-size: 17px; }
.subtitle { max-width: 650px; margin-bottom: 0; color: var(--muted); line-height: 1.7; font-size: 14px; }
.eyebrow { margin-bottom: 8px; color: #7e9b90; font-size: 10px; font-weight: 700; letter-spacing: .15em; }
.button { min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 12px; font-size: 13px; font-weight: 600; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--green); box-shadow: 0 5px 12px #17483f26; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--green); background: var(--mint); }
.button-outline { color: var(--green); background: white; border-color: #dbe5df; }
.text-button { padding: 6px 0; color: var(--green); background: transparent; border: 0; font-weight: 600; font-size: 12px; }
.tabs { display: flex; gap: 7px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: #ebf0ec; }
.tab { min-width: 86px; padding: 10px 16px; color: #72817b; border: 0; border-radius: 10px; background: transparent; font-size: 13px; }
.tab.active { color: var(--green); background: white; box-shadow: 0 2px 8px #1e44340c; font-weight: 600; }
.view { padding: 33px 0 48px; }
.section-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading { margin-bottom: 22px; }
.date-control { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
input, select { min-height: 42px; width: 100%; padding: 0 11px; border: 1px solid #dce5df; border-radius: 9px; color: #243c34; background: white; outline: none; }
input:focus, select:focus { border-color: #75a78d; box-shadow: 0 0 0 3px #dcefe4; }
.date-control input { width: auto; min-width: 150px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin-bottom: 13px; }
.summary-card { min-height: 108px; display: flex; flex-direction: column; justify-content: space-between; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.summary-card span, .networth-card span { color: var(--muted); font-size: 12px; }
.summary-card strong { font-size: 25px; letter-spacing: -.025em; }
.summary-positive strong { color: #398561; }
.summary-negative strong { color: var(--red); }
.networth-card { display: grid; grid-template-columns: 1fr 1fr 1.15fr; align-items: center; gap: 14px; margin-bottom: 26px; padding: 20px 24px; color: white; border-radius: 16px; background: linear-gradient(112deg, #17483f, #27735d); box-shadow: var(--shadow); }
.networth-card div { display: grid; gap: 8px; }
.networth-card span { color: #c0d7cc; }
.networth-card strong { font-size: 20px; }
.networth-total { padding-left: 22px; border-left: 1px solid #ffffff38; }
.networth-total strong { font-size: 25px; }
.panel { margin-bottom: 16px; padding: 21px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.panel-heading { margin-bottom: 18px; }
.muted { color: var(--muted); font-size: 12px; }
.transaction-list, .account-list, .manage-list { display: grid; }
.transaction-row { display: grid; grid-template-columns: minmax(130px, 1.2fr) minmax(110px, 1fr) minmax(100px, .8fr) auto; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid #eff2ef; }
.transaction-row:first-child, .account-row:first-child, .manage-row:first-child { border-top: 0; }
.transaction-main { display: grid; gap: 4px; min-width: 0; }
.transaction-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.transaction-main small, .transaction-meta { color: var(--muted); font-size: 11px; }
.transaction-amount { text-align: right; font-weight: 700; font-size: 14px; }
.amount-income { color: #398561; }
.amount-expense { color: var(--red); }
.row-actions { display: flex; gap: 8px; justify-content: end; }
.row-actions button, .manage-actions button { padding: 5px 8px; color: #6c7d76; border: 0; border-radius: 7px; background: #f3f6f4; font-size: 11px; }
.empty-state { padding: 26px 12px; color: var(--muted); text-align: center; font-size: 13px; }
.account-row, .manage-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid #eff2ef; }
.account-name { display: grid; gap: 4px; font-size: 13px; }
.account-name small { color: var(--muted); font-size: 11px; }
.account-balance { font-weight: 700; font-size: 14px; }
.report-grid, .management-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 15px; }
.chart { min-height: 230px; display: grid; place-items: center; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; justify-content: center; gap: 20px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.donut-wrap { min-height: 220px; display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 20px; }
.donut { width: 142px; height: 142px; border-radius: 50%; background: #edf1ee; position: relative; }
.donut::after { content: ""; position: absolute; inset: 30px; border-radius: 50%; background: white; }
.legend { display: grid; gap: 11px; }
.legend-row { display: grid; grid-template-columns: 9px minmax(60px, 1fr) auto; align-items: center; gap: 8px; font-size: 11px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-row span:last-child { color: var(--muted); text-align: right; white-space: nowrap; }
.inline-form { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr auto; align-items: end; gap: 10px; margin-bottom: 15px; }
.inline-form label, .form-grid label { display: grid; gap: 7px; color: #576d63; font-size: 11px; }
.inline-form .button { white-space: nowrap; }
.manage-row { min-height: 49px; }
.manage-name { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.manage-actions { display: flex; gap: 6px; }
.inactive-label { color: #9aa6a0; font-size: 10px; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }
.file-button { display: inline-flex; align-items: center; }
.small-note { margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.demo-panel { display: flex; justify-content: space-between; align-items: center; gap: 18px; background: #f8fbf8; }
.demo-panel h3 { margin-bottom: 8px; }
.demo-panel p:last-child { max-width: 740px; margin-bottom: 0; }
footer { display: flex; justify-content: space-between; gap: 12px; width: min(100% - 40px, 1120px); margin: 0 auto; padding: 0 0 28px; color: #8a9891; font-size: 10px; }
.dialog { width: min(560px, calc(100% - 26px)); max-height: min(88vh, 850px); padding: 24px; overflow: auto; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 80px #122f2440; }
.dialog::backdrop { background: #10251eb5; backdrop-filter: blur(3px); }
.dialog-wide { width: min(900px, calc(100% - 26px)); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 23px; }
.dialog-heading h2 { font-size: 22px; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 10px; color: var(--muted); background: #f2f5f3; font-size: 22px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: 12px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 18px; }
.auth-field { display: grid; gap: 7px; margin-top: 14px; color: #576d63; font-size: 11px; }
#request-password-reset { margin-top: 10px; }
.notice { margin: -13px 0 16px; padding: 11px 14px; border: 1px solid #cfe4d7; border-radius: 11px; color: var(--green); background: #eef8f1; font-size: 12px; }
.notice.error { color: #8d3932; border-color: #f0d5d1; background: #fff5f3; }
.mapping-list { display: grid; gap: 10px; margin-bottom: 15px; }
.mapping-row { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(190px, 1.4fr); align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: #f6f8f6; font-size: 12px; }
.mapping-row small { display: block; margin-top: 3px; color: var(--muted); }
.mapping-shortcut { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; }
.table-scroll { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 10px 11px; border-bottom: 1px solid #edf1ee; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; color: var(--muted); background: #f8faf8; }
.status-ready { color: #398561; }
.status-invalid, .status-currency { color: var(--red); }
.status-duplicate { color: #aa7c2e; }
[hidden] { display: none !important; }

@media (max-width: 760px) {
  .shell { width: min(100% - 28px, 1120px); }
  .topbar { height: 58px; padding: 0 16px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .local-badge { max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
  .intro { align-items: flex-start; flex-direction: column; padding: 32px 0 23px; }
  .intro .button { width: 100%; }
  .tabs { gap: 2px; overflow-x: auto; }
  .tab { min-width: max-content; flex: 1; padding: 10px 11px; }
  .view { padding-top: 26px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .summary-grid { gap: 8px; }
  .summary-card { min-height: 92px; padding: 14px 12px; }
  .summary-card span { font-size: 10px; }
  .summary-card strong { font-size: clamp(17px, 5vw, 23px); }
  .networth-card { gap: 12px; padding: 17px 14px; }
  .networth-card span { font-size: 10px; }
  .networth-card strong { font-size: 15px; }
  .networth-total { padding-left: 12px; }
  .networth-total strong { font-size: 17px; }
  .panel { padding: 17px 15px; }
  .transaction-row { grid-template-columns: minmax(90px, 1fr) minmax(68px, .7fr) auto; gap: 7px; }
  .transaction-meta { display: none; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .transaction-amount { font-size: 12px; }
  .report-grid, .management-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr 1fr; }
  .inline-form .button { width: 100%; }
  .donut-wrap { grid-template-columns: 120px 1fr; gap: 12px; }
  .donut { width: 116px; height: 116px; }
  .donut::after { inset: 25px; }
  .demo-panel { align-items: flex-start; flex-direction: column; }
  footer { width: min(100% - 28px, 1120px); flex-direction: column; }
}

@media (max-width: 420px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card:last-child { grid-column: 1 / -1; min-height: 72px; }
  .date-control { width: 100%; justify-content: space-between; }
  .date-control input { min-width: 145px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .mapping-row { grid-template-columns: 1fr; }
}
