:root {
  color-scheme: light;
  --ink: #202b27;
  --muted: #7f8984;
  --line: #e9ede9;
  --paper: #fff;
  --canvas: #f5f7f4;
  --green: #23755e;
  --green-dark: #175c49;
  --green-soft: #e8f3ee;
  --income: #147548;
  --income-soft: #e7f5ec;
  --expense: #b33d32;
  --expense-soft: #fff0ed;
  --shadow: 0 10px 34px rgba(33, 50, 42, .055);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 3; display: flex; width: 232px; flex-direction: column; padding: 26px 16px 18px; border-right: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 9px 35px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 13px; color: #fff; background: var(--green); font-family: Georgia, serif; font-size: 27px; font-weight: 700; }
.brand b { display: block; font-size: 19px; letter-spacing: -.7px; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.side-nav { display: grid; gap: 5px; }
.nav-item { display: flex; min-height: 43px; align-items: center; gap: 11px; padding: 0 12px; border: 0; border-radius: 10px; color: #737e78; background: transparent; text-align: left; }
.nav-item span { width: 18px; font-size: 18px; text-align: center; }
.nav-item.active { color: var(--green); background: var(--green-soft); font-weight: 700; }
.sidebar-bottom { margin-top: auto; }
.sync-card { display: flex; align-items: flex-start; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; }
.sync-card b, .sync-card small { display: block; }
.sync-card b { font-size: 11px; }
.sync-card small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.sync-indicator { flex: 0 0 9px; width: 9px; height: 9px; margin-top: 3px; border-radius: 50%; background: #c18a27; box-shadow: 0 0 0 3px #fbf0d9; }
.sync-indicator.online { background: #67b48c; box-shadow: 0 0 0 3px #e9f5ed; }
.sync-indicator.offline, .sync-indicator.error { background: var(--expense); box-shadow: 0 0 0 3px #fce5e1; }
.privacy-note { margin: 10px 4px 0; color: #959d98; font-size: 9px; line-height: 1.5; }
.main { max-width: 1480px; margin-left: 232px; padding: 31px 42px 70px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 11px; }
h1 { margin: 0; font-size: 24px; font-weight: 720; letter-spacing: -.7px; }
h2 { margin: 0; font-size: 15px; letter-spacing: -.2px; }
p { line-height: 1.55; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 6px; padding: 0 15px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; font-weight: 700; text-decoration: none; transition: background .15s, border-color .15s; }
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { border-color: var(--line); color: #56635b; background: #fff; }
.button-secondary:hover { border-color: #c8d8cc; background: #fafcfb; }
.avatar { display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 50%; color: #855b3f; background: #f6e5d5; font-weight: 750; }
.notice { margin: -9px 0 18px; padding: 11px 14px; border: 1px solid #f0d9ac; border-radius: 10px; color: #684c17; background: #fff9e9; font-size: 12px; line-height: 1.5; }
.notice[hidden] { display: none; }
.view[hidden] { display: none; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.summary-card { min-height: 136px; padding: 18px 19px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.summary-card > span:not(.flow-label) { display: block; color: #77827c; font-size: 11px; }
.summary-card strong { display: block; overflow-wrap: anywhere; margin: 12px 0 6px; font-size: clamp(21px, 2.3vw, 29px); letter-spacing: -.8px; }
.summary-card small { color: var(--muted); font-size: 10px; }
.income-card strong, .income-card .flow-label { color: var(--income); }
.expense-card strong, .expense-card .flow-label { color: var(--expense); }
.flow-label { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .03em; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .9fr); gap: 14px; margin-top: 15px; }
.panel { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.panel-heading { display: flex; min-height: 35px; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-heading p, .report-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.text-button { padding: 3px 0; border: 0; color: var(--green); background: transparent; font-size: 11px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.transaction-list, .category-summary, .settings-list { display: grid; gap: 3px; }
.transaction-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #f0f2f0; }
.table-transaction-item { display: flex; padding: 0; border: 0; }
.transaction-main { display: flex; min-width: 0; align-items: center; gap: 10px; }
.category-icon { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: #f2f6f3; font-size: 18px; }
.transaction-name { overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.transaction-sub { overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.transaction-value { text-align: right; font-size: 12px; font-weight: 750; white-space: nowrap; }
.transaction-value.income { color: var(--income); }
.transaction-value.expense { color: var(--expense); }
.category-line { display: grid; grid-template-columns: minmax(78px, .65fr) minmax(45px, 1fr) auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid #f0f2f0; }
.category-line-name { overflow: hidden; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.category-track { height: 7px; overflow: hidden; border-radius: 8px; background: #f0f2f0; }
.category-bar { height: 100%; border-radius: inherit; background: #5aa284; }
.category-line-amount { color: #59655e; font-size: 10px; font-weight: 700; white-space: nowrap; }
.insight-card { margin-top: 14px; padding: 16px 18px; border: 1px solid #e1ebe4; border-radius: 13px; background: #f8fbf8; color: #41554a; font-size: 12px; line-height: 1.6; }
.insight-card b { display: block; margin-bottom: 4px; color: var(--green); font-size: 11px; }
.filters { display: flex; flex-wrap: wrap; gap: 9px; margin: 15px 0; }
.search-field { display: flex; min-width: min(290px, 100%); min-height: 40px; flex: 1; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #fff; }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.filters select, .period-field select, .inline-field input, .inline-field select { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; font-size: 11px; }
.date-filter { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.date-filter input { min-height: 40px; padding: 0 7px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; font-size: 10px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 9px 10px; border-bottom: 1px solid var(--line); color: #929b95; font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
td { padding: 11px 10px; border-bottom: 1px solid #f0f2f0; font-size: 11px; }
.amount-cell { text-align: right; }
.tx-amount { text-align: right; font-weight: 750; white-space: nowrap; }
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-actions button, .settings-row button { min-height: 31px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; color: #66736b; background: #fff; font-size: 10px; }
.row-actions .delete, .settings-row .delete { color: #a43930; }
.empty-state { padding: 28px 10px; color: var(--muted); text-align: center; }
.report-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.report-heading h2 { font-size: 18px; }
.period-field, .inline-field { display: grid; gap: 6px; color: #657068; font-size: 10px; font-weight: 650; }
.period-field select { min-width: 145px; }
.report-panel { margin-top: 15px; }
.monthly-trend { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; gap: 11px; min-height: 170px; padding: 12px 5px 0; border-bottom: 1px solid var(--line); }
.trend-month { display: grid; min-width: 0; grid-template-rows: 1fr auto; gap: 8px; height: 150px; text-align: center; }
.trend-bars { display: flex; align-items: end; justify-content: center; gap: 5px; height: 100%; border-bottom: 1px solid #eff2ef; }
.trend-bar { width: min(23px, 34%); min-height: 2px; border-radius: 5px 5px 0 0; }
.trend-bar.income { background: #4b9d71; }
.trend-bar.expense { background: #dc806e; }
.trend-month-label { color: var(--muted); font-size: 9px; }
.trend-legend { display: flex; align-items: center; gap: 11px; color: #758078; font-size: 9px; }
.trend-legend span { display: flex; align-items: center; gap: 4px; }
.trend-legend i { width: 8px; height: 8px; border-radius: 3px; background: #4b9d71; }
.trend-legend i.expense { background: #dc806e; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-panel { align-self: start; }
.settings-panel .inline-field { margin-bottom: 12px; }
.settings-row { display: flex; min-height: 47px; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-top: 1px solid #f0f2f0; }
.settings-row-main { display: flex; min-width: 0; align-items: center; gap: 8px; }
.settings-row-icon, .wallet-mark { display: grid; flex: 0 0 31px; width: 31px; height: 31px; place-items: center; border-radius: 9px; color: #fff; background: #657c6f; font-size: 10px; font-weight: 800; }
.wallet-mark.cash { background: #278350; }
.wallet-mark.bank { background: #405c86; }
.wallet-mark.vcb { background: #08783f; }
.wallet-mark.tcb { background: #cf303b; }
.wallet-mark.mb, .wallet-mark.bidv { background: #2469a5; }
.wallet-mark.acb { background: #1680bd; }
.wallet-mark.vpb { background: #28874a; }
.wallet-mark.ctg { background: #145b9d; }
.wallet-mark.momo { background: #a50077; }
.wallet-mark.zalopay { background: #146de1; }
.wallet-mark.shopeepay { background: #e84b2c; }
.wallet-mark.vnpay { background: #2860a8; }
.wallet-mark.visa { background: #173b70; }
.settings-row-label { overflow: hidden; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.settings-row-sub { margin-top: 3px; color: var(--muted); font-size: 9px; }
.settings-row-actions { display: flex; flex: 0 0 auto; gap: 4px; }
.editor-form { display: grid; gap: 10px; margin-top: 13px; padding: 12px; border: 1px solid #e4ece6; border-radius: 11px; background: #f8fbf8; }
.editor-form .inline-field { font-size: 10px; }
.editor-form input, .editor-form select { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.form-actions { display: flex; justify-content: flex-end; gap: 7px; }
.form-actions .button { min-height: 37px; font-size: 10px; }
.google-panel, .export-panel { margin-top: 14px; }
.provider-mark { display: grid; width: 29px; height: 29px; place-items: center; border: 1px solid #e4e9e4; border-radius: 9px; color: #4285f4; font-weight: 800; }
.privacy-copy, .helper-text, .export-panel p { color: #707c75; font-size: 10px; line-height: 1.6; }
.privacy-copy code { padding: 2px 4px; border-radius: 4px; background: #f2f5f2; }
.google-panel > .inline-field { max-width: 510px; }
.google-panel > .inline-field input { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 11px; }
.google-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.link-sheet-form { display: flex; max-width: 700px; align-items: end; gap: 9px; margin-top: 13px; }
.link-sheet-form .inline-field { flex: 1; }
.link-sheet-form input { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 11px; }
.helper-text { margin-bottom: 0; }
.conflict-list { display: grid; gap: 8px; }
.conflict-card { padding: 11px; border: 1px solid #f0d9ac; border-radius: 9px; background: #fffaf0; font-size: 10px; }
.conflict-card p { margin: 0 0 8px; }
.conflict-actions { display: flex; gap: 6px; }
.export-panel { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.export-panel p { margin: 4px 0 0; }
.dialog { width: min(470px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 0; border: 0; border-radius: 17px; box-shadow: 0 24px 80px #152b2240; }
.dialog::backdrop { background: #18251f70; backdrop-filter: blur(3px); }
.dialog-form { display: grid; gap: 13px; padding: 19px 21px 21px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { font-size: 17px; }
.icon-button { width: 31px; height: 31px; border: 0; border-radius: 8px; color: #77827c; background: #f4f6f4; font-size: 20px; }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border-radius: 10px; background: #f3f6f3; }
.type-switch button { min-height: 39px; border: 0; border-radius: 8px; color: #657068; background: transparent; font-size: 12px; font-weight: 700; }
.type-switch button.active.expense { color: var(--expense); background: #fff; }
.type-switch button.active.income { color: var(--income); background: #fff; }
.field { display: grid; gap: 6px; color: #56635b; font-size: 10px; font-weight: 650; }
.field input, .field select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #e4e9e4; border-radius: 9px; outline: 0; color: var(--ink); background: #fff; font-size: 12px; }
.field input:focus, .field select:focus, .inline-field input:focus { border-color: #83b9a3; box-shadow: 0 0 0 3px #e5f2eb; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.submit-entry { min-height: 48px; margin-top: 2px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: min(440px, calc(100vw - 30px)); padding: 12px 16px; border-radius: 10px; color: #fff; background: #253b32; box-shadow: var(--shadow); opacity: 0; transform: translateY(9px); transition: .18s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-nav, .mobile-quickbar { display: none; }
@media (max-width: 1080px) { .main { padding-right: 25px; padding-left: 25px; } .dashboard-grid { grid-template-columns: minmax(0, 1.15fr) minmax(245px, .85fr); } }
@media (max-width: 800px) {
  .sidebar { display: none; }
  .main { max-width: 740px; margin: 0 auto; padding: 22px 19px 150px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 5; display: flex; height: calc(59px + env(safe-area-inset-bottom)); align-items: center; justify-content: space-around; padding: 0 6px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: #ffffffed; backdrop-filter: blur(12px); }
  .mobile-nav button { display: grid; justify-items: center; gap: 2px; min-width: 55px; padding: 4px; border: 0; color: #89938d; background: transparent; font-size: 9px; }
  .mobile-nav button span { font-size: 17px; }
  .mobile-nav button.active { color: var(--green); font-weight: 700; }
  .mobile-quickbar { position: fixed; right: 0; bottom: calc(59px + env(safe-area-inset-bottom)); left: 0; z-index: 6; display: block; padding: 8px 14px; border-top: 1px solid var(--line); background: #ffffffed; backdrop-filter: blur(12px); }
  .mobile-quickbar .button { width: 100%; min-height: 50px; }
}
@media (max-width: 520px) {
  .main { padding: 18px 13px 145px; }
  .topbar { margin-bottom: 18px; }
  h1 { font-size: 21px; }
  .top-actions .button { min-height: 39px; padding: 0 10px; font-size: 11px; }
  .top-actions .button span { display: none; }
  .summary-grid { gap: 7px; }
  .summary-card { min-height: 112px; padding: 11px 9px; border-radius: 12px; }
  .summary-card > span:not(.flow-label) { font-size: 9px; line-height: 1.4; }
  .summary-card strong { margin: 9px 0 4px; font-size: clamp(14px, 4.5vw, 19px); letter-spacing: -.5px; }
  .summary-card small { font-size: 8px; }
  .panel { padding: 14px 12px; }
  .filters { flex-direction: column; }
  .search-field, .filters select { width: 100%; }
  .date-filter { justify-content: space-between; }
  .date-filter input { flex: 1; }
  .table-scroll table { min-width: 620px; }
  .report-heading { align-items: flex-start; flex-direction: column; }
  .link-sheet-form { align-items: stretch; flex-direction: column; }
  .report-summary .summary-card { min-height: 112px; }
  .two-fields { grid-template-columns: 1fr; }
  .toast { right: 12px; bottom: calc(138px + env(safe-area-inset-bottom)); left: 12px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
