:root {
  color-scheme: light;
  --ink: #1d2926;
  --muted: #74817c;
  --line: #e2e8e4;
  --paper: #ffffff;
  --canvas: #f3f6f3;
  --forest: #183c36;
  --green: #17836a;
  --green-soft: #e8f4ee;
  --coral: #c65e4d;
  --coral-soft: #faeeeb;
  --gold: #bd8b28;
  --shadow: 0 12px 30px rgba(24, 60, 54, .06);
  --soft-surface: color-mix(in srgb, var(--paper) 90%, var(--line));
  --table-line: color-mix(in srgb, var(--line) 75%, var(--paper));
  --secondary-ink: color-mix(in srgb, var(--muted) 60%, var(--ink));
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: "DM Sans", "Noto Sans JP", "Yu Gothic", sans-serif; font-size: 14px; }
body[data-palette="harbor"] {
  --ink: #1d2d37;
  --muted: #6d7f88;
  --line: #dce6e9;
  --paper: #ffffff;
  --canvas: #f0f5f6;
  --forest: #173a4a;
  --green: #167f8a;
  --green-soft: #e4f2f2;
  --coral: #c65e4d;
  --coral-soft: #faeeeb;
  --gold: #c18b2c;
}
body[data-palette="citrus"] {
  --ink: #30362a;
  --muted: #747763;
  --line: #e3e5d7;
  --paper: #fffefa;
  --canvas: #f5f5ec;
  --forest: #3c422d;
  --green: #6a7f34;
  --green-soft: #eef2df;
  --coral: #bb5741;
  --coral-soft: #f9ece6;
  --gold: #d38c20;
}
body[data-palette="harbor_balance"] {
  --ink: #061a24;
  --muted: #0b3a53;
  --line: #b5e2fa;
  --paper: #ffffff;
  --canvas: #f3faff;
  --forest: #061a24;
  --green: #0fa3b1;
  --green-soft: #dff3fa;
  --coral: #0b3a53;
  --coral-soft: #b5e2fa;
  --gold: #0fa3b1;
}
body[data-palette="rose_gold"] {
  --ink: #2a1f25;
  --muted: #7a4b57;
  --line: #f1d6dc;
  --paper: #ffffff;
  --canvas: #fff6f8;
  --forest: #2a1f25;
  --green: #d08c9b;
  --green-soft: #f8e9ed;
  --coral: #7a4b57;
  --coral-soft: #f1d6dc;
  --gold: #d08c9b;
}
body[data-palette="sandstone"] {
  --ink: #3a2f2a;
  --muted: #7a6a5a;
  --line: #e8e1d4;
  --paper: #ffffff;
  --canvas: #faf7f1;
  --forest: #3a2f2a;
  --green: #a38e68;
  --green-soft: #f1ece2;
  --coral: #7a6a5a;
  --coral-soft: #e8e1d4;
  --gold: #c2b59b;
}
body[data-palette="champagne"] {
  --ink: #2b2a28;
  --muted: #6b6258;
  --line: #efe2c8;
  --paper: #ffffff;
  --canvas: #fff9ef;
  --forest: #2b2a28;
  --green: #b38d4c;
  --green-soft: #f6eddc;
  --coral: #6b6258;
  --coral-soft: #efe2c8;
  --gold: #c9a86a;
}
body[data-palette="ledger_navy"] {
  --ink: #0b1f3b;
  --muted: #123a63;
  --line: #c9d6e5;
  --paper: #ffffff;
  --canvas: #f2f5f8;
  --forest: #0b1f3b;
  --green: #2f5d8c;
  --green-soft: #e4ebf3;
  --coral: #123a63;
  --coral-soft: #c9d6e5;
  --gold: #2f5d8c;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--forest); color: #edf4ef; display: flex; flex-direction: column; min-height: 100vh; padding: 27px 18px 20px; }
.brand { align-items: center; display: flex; gap: 12px; font-size: 15px; font-weight: 700; letter-spacing: 0; }
.brand-mark { align-items: center; background: var(--gold); border-radius: 7px; color: var(--forest); display: inline-flex; font-family: "Newsreader", "Noto Serif JP", "Yu Mincho", serif; font-size: 22px; height: 38px; justify-content: center; width: 38px; }
.brand small { color: #a9beb5; display: block; font-size: 9px; font-weight: 600; letter-spacing: 1.2px; margin-top: 3px; }
.primary-nav { display: grid; gap: 6px; margin-top: 54px; }
.sidebar-bottom { display: grid; gap: 6px; margin-top: 39px; }
.sidebar a:not(.brand) { align-items: center; border-radius: 6px; color: #c5d5cd; display: flex; gap: 12px; min-height: 42px; padding: 0 12px; transition: background .18s ease, color .18s ease; }
.sidebar a:not(.brand):hover, .sidebar a.active { background: rgba(255,255,255,.11); color: #fff; }
.nav-symbol { color: var(--gold); display: inline-flex; font-size: 18px; justify-content: center; width: 20px; }
.nav-caption { color: #91aaa0; font-size: 9px; font-weight: 700; letter-spacing: 1.2px; margin: 0 12px 7px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.14); color: #9fb3aa; font-size: 11px; line-height: 1.6; margin-top: auto; padding: 17px 7px 0; }
.main-area { min-width: 0; }
.topbar { align-items: center; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; height: 67px; justify-content: space-between; padding: 0 clamp(22px, 4vw, 58px); }
.topbar-label, .eyebrow, .metric-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 1.15px; }
.topbar-actions { align-items: center; display: flex; gap: 16px; }
.topbar-actions form { margin: 0; }
.signed-in-email { color: var(--muted); font-size: 11px; }
.signout-action { background: transparent; border: 0; cursor: pointer; padding: 0; }
.text-action { color: var(--green); font-size: 13px; font-weight: 700; }
.text-action span { font-size: 19px; margin-right: 5px; vertical-align: -1px; }
.page-content { margin: 0 auto; max-width: 1440px; padding: 38px clamp(22px, 4vw, 58px) 60px; }
.page-heading { align-items: end; display: flex; justify-content: space-between; margin-bottom: 28px; }
.heading-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; justify-content: end; }
.page-heading h1 { font-family: "Newsreader", "Noto Serif JP", "Yu Mincho", serif; font-size: 36px; font-weight: 500; line-height: 1.12; margin: 7px 0 0; }
.page-heading .eyebrow { margin: 0; }
.button { align-items: center; border: 0; border-radius: 5px; cursor: pointer; display: inline-flex; font-size: 13px; font-weight: 700; justify-content: center; min-height: 42px; padding: 0 17px; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-dark { background: var(--forest); color: #fff; }
.button-dark:hover { background: color-mix(in srgb, var(--forest) 84%, white); }
.button-quiet { background: var(--soft-surface); color: var(--ink); }
.metric-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 30px; }
.metric { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; min-height: 147px; padding: 20px 21px; position: relative; }
.metric::before { background: var(--green); content: ""; height: 3px; left: 0; position: absolute; right: 0; top: 0; }
.metric-expense::before { background: var(--coral); }
.metric-net::before { background: var(--gold); }
.metric-label { display: block; }
.metric strong { display: block; font-size: clamp(24px, 2.2vw, 31px); font-weight: 600; margin-top: 14px; overflow-wrap: anywhere; }
.metric-note { color: var(--muted); display: block; font-size: 11px; margin-top: 8px; }
.dashboard-grid { display: grid; gap: 25px; grid-template-columns: minmax(0, 1.65fr) minmax(250px, .85fr); }
.data-section { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; min-width: 0; padding: 21px 22px; }
.section-heading { align-items: center; display: flex; justify-content: space-between; margin-bottom: 16px; }
.section-heading .eyebrow { margin: 0 0 5px; }
.section-heading h2, .form-section h2 { font-family: "Newsreader", "Noto Serif JP", "Yu Mincho", serif; font-size: 22px; font-weight: 500; margin: 0; }
.quiet-link { color: var(--green); font-size: 12px; font-weight: 700; white-space: nowrap; }
.quiet-link span { font-size: 15px; margin-left: 4px; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; min-width: 540px; text-align: left; width: 100%; }
th { border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .9px; padding: 10px 8px; text-transform: uppercase; }
td { border-bottom: 1px solid var(--table-line); color: var(--secondary-ink); font-size: 12px; padding: 12px 8px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.numeric { text-align: right; }
.entry-name { color: var(--ink); display: block; font-weight: 600; }
.entry-sub { color: var(--muted); display: block; font-size: 10px; margin-top: 4px; }
.amount { font-size: 12px; font-weight: 700; white-space: nowrap; }
.positive { color: var(--green); }
.negative { color: var(--coral); }
.category-list, .settings-list { list-style: none; margin: 0; padding: 0; }
.category-list li { align-items: center; border-bottom: 1px solid var(--table-line); display: grid; gap: 9px; grid-template-columns: 10px minmax(0, 1fr) auto; min-height: 44px; }
.category-list li:last-child { border-bottom: 0; }
.category-list strong { font-size: 12px; font-weight: 600; }
.category-name { color: var(--secondary-ink); font-size: 12px; overflow-wrap: anywhere; }
.category-dot { background: var(--green); border-radius: 50%; display: inline-block; height: 8px; width: 8px; }
.dot-2 { background: var(--coral); }.dot-3 { background: var(--gold); }.dot-4 { background: #557c9c; }.dot-5 { background: #a27090; }.dot-income { background: var(--green); }.dot-expense { background: var(--coral); }
.exchange-section { margin-top: 25px; }
.empty-state { align-items: center; color: var(--muted); display: flex; flex-direction: column; min-height: 150px; justify-content: center; text-align: center; }
.empty-state p { margin: 7px 0 12px; }
.empty-mark { align-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--green); display: flex; font-size: 19px; height: 38px; justify-content: center; width: 38px; }
.small-empty { min-height: 95px; }
.small-empty p { font-size: 12px; line-height: 1.6; max-width: 360px; }
.full-section { width: 100%; }
.icon-action { background: transparent; border: 0; border-radius: 4px; color: var(--coral); cursor: pointer; font-size: 20px; height: 30px; width: 30px; }
.icon-action:hover { background: var(--coral-soft); }
.form-section { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; max-width: 680px; padding: 26px; }
.compact-heading { margin-bottom: 20px; }
.budget-form { display: grid; gap: 18px; }
.form-field { display: grid; gap: 7px; }
.form-field > label { color: var(--ink); font-size: 12px; font-weight: 700; }
.form-field input:not([type=radio]), .form-field select, .form-field textarea { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; color: var(--ink); min-height: 42px; padding: 9px 11px; width: 100%; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--green); outline: 2px solid color-mix(in srgb, var(--green) 16%, transparent); }
.type-field ul { display: flex; gap: 9px; list-style: none; margin: 0; padding: 0; }
.type-field li { align-items: center; background: var(--soft-surface); border-radius: 4px; display: flex; gap: 7px; min-height: 40px; padding: 0 12px; }
.type-field label { color: var(--ink); font-size: 12px; }
.field-error, .form-errors { color: #ae4233; font-size: 12px; margin: 0; }
.help-text { color: var(--muted); font-size: 11px; margin: 0; }
.form-actions { align-items: center; display: flex; gap: 10px; margin-top: 5px; }
.palette-options { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); max-width: 640px; }
.palette-option { align-items: center; background: var(--soft-surface); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; display: grid; gap: 6px 8px; grid-template-columns: 16px minmax(0, 1fr); grid-template-rows: 24px auto; min-height: 68px; padding: 8px 10px; }
.palette-option:has(input:checked) { border-color: var(--green); box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 16%, transparent); }
.palette-option input { accent-color: var(--green); grid-column: 1; grid-row: 1; justify-self: center; margin: 0; }
.palette-name { color: var(--ink); font-size: 11px; grid-column: 1 / -1; grid-row: 2; line-height: 1.3; }
.palette-swatch { background: linear-gradient(90deg, #183c36 0 38%, #17836a 38% 70%, #bd8b28 70%); border: 1px solid rgba(0,0,0,.1); border-radius: 3px; grid-column: 2; grid-row: 1; height: 24px; width: 100%; }
.palette-swatch[data-palette="harbor"] { background: linear-gradient(90deg, #173a4a 0 38%, #167f8a 38% 70%, #c18b2c 70%); }
.palette-swatch[data-palette="citrus"] { background: linear-gradient(90deg, #3c422d 0 38%, #6a7f34 38% 70%, #d38c20 70%); }
.palette-swatch[data-palette="harbor_balance"] { background: linear-gradient(90deg, #061a24 0 25%, #0b3a53 25% 48%, #0fa3b1 48% 68%, #b5e2fa 68% 84%, #f3faff 84%); }
.palette-swatch[data-palette="rose_gold"] { background: linear-gradient(90deg, #2a1f25 0 25%, #7a4b57 25% 48%, #d08c9b 48% 68%, #f1d6dc 68% 84%, #fff6f8 84%); }
.palette-swatch[data-palette="sandstone"] { background: linear-gradient(90deg, #3a2f2a 0 25%, #7a6a5a 25% 48%, #c2b59b 48% 68%, #e8e1d4 68% 84%, #faf7f1 84%); }
.palette-swatch[data-palette="champagne"] { background: linear-gradient(90deg, #2b2a28 0 25%, #6b6258 25% 48%, #c9a86a 48% 68%, #efe2c8 68% 84%, #fff9ef 84%); }
.palette-swatch[data-palette="ledger_navy"] { background: linear-gradient(90deg, #0b1f3b 0 25%, #123a63 25% 48%, #2f5d8c 48% 68%, #c9d6e5 68% 84%, #f2f5f8 84%); }
.management-grid { align-items: start; display: grid; gap: 24px; grid-template-columns: minmax(250px, .75fr) minmax(0, 1.4fr); }
.slim-form { max-width: none; }
.slim-form h2 { margin-bottom: 20px; }
.settings-list li { align-items: center; border-bottom: 1px solid var(--table-line); display: flex; gap: 11px; min-height: 46px; }
.settings-list li:last-child { border-bottom: 0; }
.settings-list > li > span:nth-child(2) { color: var(--ink); font-size: 12px; }
.list-meta { color: var(--muted); font-size: 11px; margin-left: auto; }
.list-code { color: var(--muted); font-size: 10px; letter-spacing: .8px; margin-left: auto; }
.currency-symbol { align-items: center; background: var(--soft-surface); border-radius: 4px; color: var(--forest); display: inline-flex; font-size: 11px; font-weight: 700; height: 27px; justify-content: center; width: 34px; }
.message-stack { margin: 18px clamp(22px, 4vw, 58px) 0; }
.message { background: var(--green-soft); border-left: 3px solid var(--green); color: var(--forest); font-size: 12px; margin: 0 0 8px; padding: 11px 13px; }
.message.error { background: var(--coral-soft); border-color: var(--coral); color: var(--coral); }
.auth-page { align-items: center; background: radial-gradient(ellipse at 10% 12%, color-mix(in srgb, var(--green) 12%, transparent), transparent 35%), var(--canvas); display: flex; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); max-width: 430px; padding: 38px; width: 100%; }
.auth-brand { color: var(--ink); margin-bottom: 36px; }
.auth-panel h1 { font-family: "Newsreader", serif; font-size: 32px; font-weight: 500; margin: 0 0 8px; }
.auth-copy, .auth-recovery, .auth-setup-message { color: var(--muted); font-size: 13px; line-height: 1.6; }
.google-signin { gap: 10px; margin-top: 20px; width: 100%; }
.google-signin-form { margin: 0; }
.google-mark { align-items: center; background: #fff; border-radius: 50%; color: #4285f4; display: inline-flex; font-size: 13px; font-weight: 700; height: 20px; justify-content: center; width: 20px; }
.auth-recovery { margin: 22px 0 0; }
.auth-recovery a { color: var(--green); font-weight: 700; }
.auth-setup-message { background: var(--coral-soft); border-left: 3px solid var(--coral); color: var(--ink); margin-top: 22px; padding: 12px; }
.classification-form { display: grid; gap: 16px; }
.classification-table { min-width: 860px; }
.classification-table th { white-space: nowrap; }
.transaction-type { align-items: center; background: var(--soft-surface); border-radius: 4px; color: var(--ink); display: inline-flex; font-size: 11px; font-weight: 700; gap: 6px; padding: 5px 8px; white-space: nowrap; }
.transaction-type::before { background: var(--green); border-radius: 50%; content: ""; height: 7px; width: 7px; }
.transaction-type-expense::before { background: var(--coral); }
.category-cell { min-width: 220px; }
.category-cell select, .new-category-field { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; color: var(--ink); min-height: 38px; padding: 7px 9px; width: 100%; }
.new-category-field { margin-top: 7px; }
.classification-actions { padding-left: 2px; }
.statement-account-field { margin-bottom: 20px; max-width: 420px; }
.account-list-item { min-height: 56px !important; }
.account-row-link { align-items: center; border-radius: 4px; display: flex; flex: 1; gap: 11px; min-height: 54px; min-width: 0; padding: 0 8px; transition: background-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.account-row-link:hover { background: color-mix(in srgb, var(--green) 20%, var(--paper)); box-shadow: inset 0 0 0 1px var(--green); transform: translateX(3px); }
.account-row-link:focus-visible { background: color-mix(in srgb, var(--green) 14%, var(--paper)); }
.account-row-link:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.account-rename-link { align-items: center; border-radius: 4px; color: var(--muted); display: inline-flex; flex: 0 0 34px; height: 34px; justify-content: center; transition: background-color .15s ease, color .15s ease; }
.account-rename-link:hover, .account-rename-link:focus-visible { background: var(--green-soft); color: var(--green); }
.account-rename-link:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.account-type-mark { align-items: center; background: var(--green-soft); border-radius: 4px; color: var(--green); display: inline-flex; font-size: 10px; font-weight: 700; height: 26px; justify-content: center; width: 26px; }
.account-type-credit { background: var(--coral-soft); color: var(--coral); }
.account-name-link { color: var(--ink); font-size: 12px; font-weight: 700; }
.account-cycle-summary { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.account-transfers-section { margin-top: 20px; }
.card-cycle-field[hidden] { display: none; }
.debit-currency-field[hidden] { display: none; }
.entry-actions { align-items: center; display: inline-flex; gap: 2px; }
.entry-actions form { display: inline-flex; }
.edit-action { color: var(--green); }
.credit-balances-section { margin-bottom: 20px; }
.credit-net-summary { align-items: baseline; background: var(--soft-surface); border-left: 3px solid var(--coral); display: flex; flex-wrap: wrap; gap: 7px 14px; padding: 14px 16px; }
.credit-net-summary span { color: var(--muted); font-size: 11px; font-weight: 700; }
.credit-net-summary strong { color: var(--ink); font-size: 24px; font-weight: 700; }
.credit-net-summary small { color: var(--muted); font-size: 10px; }
.credit-balance-subtitle { color: var(--muted); font-size: 10px; font-weight: 700; margin: 18px 0 0; }
.credit-balance-list { display: grid; gap: 0 24px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); list-style: none; margin: 0; padding: 0; }
.credit-balance-list li { align-items: baseline; border-bottom: 1px solid var(--table-line); display: flex; justify-content: space-between; min-height: 48px; padding: 11px 8px; }
.credit-balance-list li span { color: var(--muted); font-size: 11px; font-weight: 700; }
.credit-balance-list li strong { color: var(--ink); font-size: 18px; font-weight: 600; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .category-section { order: -1; }
}
@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { min-height: 0; padding: 12px 14px 10px; }
  .brand { margin: 2px 3px 11px; }
  .primary-nav, .sidebar-bottom { display: flex; gap: 4px; margin: 0; overflow-x: auto; }
  .nav-caption, .sidebar-foot { display: none; }
  .sidebar a:not(.brand) { flex: 0 0 auto; font-size: 11px; gap: 6px; min-height: 36px; padding: 0 9px; }
  .nav-symbol { font-size: 15px; width: 15px; }
  .topbar { height: 49px; padding: 0 18px; }
  .topbar-actions { gap: 9px; }
  .signed-in-email { display: none; }
  .page-content { padding: 27px 16px 42px; }
  .page-heading { align-items: start; gap: 16px; margin-bottom: 21px; }
  .heading-actions { align-items: stretch; flex-direction: column-reverse; }
  .page-heading h1 { font-size: 31px; }
  .page-heading .button { align-self: end; font-size: 11px; min-height: 38px; padding: 0 11px; }
  .metric-grid { gap: 8px; grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
  .metric { min-height: 122px; padding: 15px; }
  .metric-net { grid-column: 1 / -1; min-height: 106px; }
  .metric strong { font-size: 24px; margin-top: 10px; }
  .metric-note { font-size: 10px; line-height: 1.4; }
  .palette-options { grid-template-columns: minmax(0, 1fr); min-width: 0; width: 100%; }
  .palette-option { min-width: 0; }
  .data-section { padding: 17px 14px; }
  .dashboard-grid, .management-grid { gap: 14px; }
  .exchange-section { margin-top: 14px; }
  .form-section { padding: 20px 16px; }
  .section-heading h2, .form-section h2 { font-size: 20px; }
  .section-heading { align-items: end; gap: 10px; }
  .quiet-link { font-size: 11px; }
}