:root {
  color-scheme: light dark;
  --bg: #f7f7fc;
  --panel: #fff;
  --soft: #f8f8fc;
  --text: #211e35;
  --muted: #626077;
  --faint: #77748b;
  --border: #e8e6f0;
  --accent: #6546d7;
  --accent-hover: #5534c2;
  --accent-wash: #eee9fe;
  --accent-text: #5739bd;
  --green: #087e63;
  --green-wash: #e2f7ef;
  --coral: #b63e57;
  --coral-wash: #fce9ed;
  --alert: #8d540b;
  --alert-wash: #fff7e7;
  --alert-border: #f0dfb9;
  --shadow: 0 2px 5px #26185407;
  font-family: Inter, "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171620; --panel: #211f2e; --soft: #1a1925; --text: #f3efff; --muted: #bbb6d0; --faint: #a39ab6; --border: #373348;
    --accent: #7858eb; --accent-hover: #886cf1; --accent-wash: #372960; --accent-text: #cfbbff;
    --green: #72dec0; --green-wash: #1d4039; --coral: #ffa1b3; --coral-wash: #482c41;
    --alert: #f5c780; --alert-wash: #342a24; --alert-border: #554237;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171620; --panel: #211f2e; --soft: #1a1925; --text: #f3efff; --muted: #bbb6d0; --faint: #a39ab6; --border: #373348;
  --accent: #7858eb; --accent-hover: #886cf1; --accent-wash: #372960; --accent-text: #cfbbff;
  --green: #72dec0; --green-wash: #1d4039; --coral: #ffa1b3; --coral-wash: #482c41;
  --alert: #f5c780; --alert-wash: #342a24; --alert-border: #554237;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
button, select, input, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
main:focus { outline: 0; }
[hidden], .symbols { display: none !important; }
svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; fill: none; flex: none; }
p, h1, h2, h3 { margin: 0; }
a, .link { color: var(--accent-text); }
.layout { min-height: 100dvh; display: grid; grid-template-columns: 237px minmax(0, 1fr); }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border); position: sticky; top: 0;
  height: 100dvh; display: flex; flex-direction: column; padding: 29px 20px 23px;
}
.brand { display: inline-flex; align-items: center; text-align: left; gap: 12px; font-size: 21px; font-weight: 800; background: none; border: 0; color: var(--text); padding: 0 8px; min-height: 44px; letter-spacing: .04em; width: fit-content; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #8766ef, #5b39cf); box-shadow: 0 4px 9px #6546d737; }
.brand-mark svg { width: 23px; height: 23px; }
#side-nav { display: grid; gap: 6px; margin-top: 42px; }
.nav-item { display: flex; align-items: center; gap: 12px; color: var(--muted); background: transparent; border: 0; border-radius: 10px; min-height: 47px; padding: 0 12px; font-weight: 650; text-align: left; }
.nav-item:hover { background: var(--soft); }
.nav-item[aria-current="page"] { color: var(--accent-text); background: var(--accent-wash); --icon-fill: var(--accent-wash); }
.sidebar-footer { margin: auto 2px 0; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding: 18px 5px 3px; font-size: 13px; font-weight: 700; color: var(--muted); }
.sidebar-footer small { display: block; margin-top: 3px; font-size: 11px; color: var(--faint); font-weight: 500; }
.sidebar-footer svg { color: var(--accent-text); }
.bottom-nav, .mobile-brand { display: none; }
.workspace { min-width: 0; }
.topbar { height: 80px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(22px, 3.4vw, 54px); background: var(--panel); border-bottom: 1px solid var(--border); }
.breadcrumb { color: var(--muted); font-weight: 650; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.breadcrumb svg { width: 17px; height: 17px; color: var(--faint); }
.top-actions, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.top-actions { gap: 19px; }
.connection { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; font-size: 12px; font-weight: 650; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #169977; }
.button, .icon-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--panel); padding: 9px 14px; font-weight: 700; text-align: center; text-decoration: none; }
.button:hover, .icon-button:hover { background: var(--soft); }
.button.primary { color: #fff; background: var(--accent); border-color: transparent; box-shadow: 0 3px 7px #6646d52e; }
.button.primary:hover { background: var(--accent-hover); }
.button.danger { color: var(--coral); background: var(--coral-wash); border-color: transparent; }
.icon-button { padding: 0; width: 44px; flex: 0 0 44px; }
.button svg { width: 17px; height: 17px; }
.link { display: inline-flex; gap: 5px; align-items: center; padding: 5px 0; min-height: 36px; border: 0; background: none; font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link svg { width: 16px; height: 16px; }
main { max-width: 1450px; margin: 0 auto; padding: 35px clamp(22px, 3.4vw, 54px) 55px; }
.heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 25px; }
h1 { font-size: clamp(27px, 3vw, 36px); font-weight: 820; letter-spacing: .025em; line-height: 1.23; }
.subtitle { margin-top: 8px; color: var(--muted); line-height: 1.5; }
.month { display: flex; align-items: center; padding: 0 2px; gap: 0; flex: none; border: 1px solid var(--border); border-radius: 11px; background: var(--panel); }
.month .icon-button { border: 0; min-height: 42px; }
.month-label { position: relative; display: grid; place-items: center; min-height: 44px; min-width: 134px; padding: 0 6px; font-size: 14px; font-weight: 750; }
.month-label span { display: flex; align-items: center; gap: 7px; }
.month-label span svg { width: 16px; height: 16px; color: var(--accent-text); }
.month-label input { position: absolute; inset: 0; height: 100%; width: 100%; min-width: 0; opacity: 0; cursor: pointer; }
.month-label:focus-within { outline: 2px solid var(--accent); }
.month-label input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; cursor: pointer; }
.metrics { display: grid; grid-template-columns: 1.24fr 1fr 1fr; gap: 16px; margin-bottom: 21px; }
.metric, .panel { background: var(--panel); border: 1px solid var(--border); border-radius: 17px; min-width: 0; box-shadow: var(--shadow); }
.metric { position: relative; padding: 20px 21px; min-height: 147px; overflow: hidden; }
.metric.feature { background: linear-gradient(115deg, #5c39c6, #7950e3); border-color: transparent; color: white; }
.metric.feature::after { content: ""; pointer-events: none; position: absolute; width: 170px; height: 170px; border: 1px solid #ffffff37; border-radius: 50%; right: -72px; bottom: -61px; box-shadow: 0 0 0 18px #ffffff13, 0 0 0 36px #ffffff10, 0 0 0 54px #ffffff0a; }
.metric-head { display: flex; gap: 9px; align-items: center; font-size: 13px; font-weight: 750; }
.tile { border-radius: 10px; width: 36px; height: 36px; display: inline-grid; flex: none; place-items: center; color: var(--accent-text); background: var(--accent-wash); }
.tile svg { width: 18px; height: 18px; }
.tile.green { color: var(--green); background: var(--green-wash); }
.tile.coral { color: var(--coral); background: var(--coral-wash); }
.feature .tile { color: white; background: #ffffff26; }
.metric-amount { margin-top: 10px; position: relative; z-index: 1; font-size: clamp(22px, 2.45vw, 34px); font-weight: 800; line-height: 1.2; letter-spacing: -.035em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric-amount small { font-size: .51em; letter-spacing: 0; margin-right: 4px; font-weight: 700; opacity: .86; }
.metric-foot { margin-top: 7px; font-size: 12px; color: var(--faint); position: relative; z-index: 1; }
.feature .metric-foot { color: #f0e9ff; }
.quick-panel { padding: 15px 17px; margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.quick-panel h2 { font-size: 15px; white-space: nowrap; }
.quick-panel .actions { gap: 7px; }
.quick-panel .button { font-size: 13px; background: var(--soft); }
.dashboard-grid { display: grid; grid-template-columns: 1.37fr 1fr; gap: 19px; align-items: stretch; }
.panel { padding: 20px; }
.panel-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 13px; }
.panel-head h2 { font-size: 17px; }
.panel-head .link { font-size: 12px; flex: none; }
.panel-description, .note { color: var(--muted); line-height: 1.65; font-size: 13px; }
.empty { min-height: 209px; display: grid; align-content: center; justify-items: center; gap: 9px; color: var(--muted); text-align: center; padding: 22px 6px; }
.empty .tile { width: 48px; height: 48px; border-radius: 15px; margin-bottom: 2px; }
.empty .tile svg { width: 23px; height: 23px; }
.empty strong { color: var(--text); font-size: 14px; }
.empty p { font-size: 12px; line-height: 1.5; }
.empty .button { margin-top: 3px; min-height: 42px; font-size: 13px; }
.legend { display: grid; gap: 8px; }
.legend-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 9px; align-items: center; font-size: 13px; }
.legend-row span:nth-child(2) { overflow-wrap: anywhere; }
.legend-row small { color: var(--faint); min-width: 43px; text-align: end; }
.legend-row b, .row-money { font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--accent)); }
.donut { width: 122px; max-width: 100%; aspect-ratio: 1; border-radius: 50%; background: var(--ring, var(--accent-wash)); margin: 16px auto; display: grid; place-items: center; }
.donut-center { background: var(--panel); width: 74%; height: 74%; border-radius: 50%; display: grid; align-content: center; justify-items: center; line-height: 1.5; text-align: center; }
.donut-center b { font-size: 18px; letter-spacing: -.035em; max-width: 98%; overflow-wrap: anywhere; }
.donut-center small { color: var(--faint); font-size: 10px; }
.donut-empty { text-align: center; color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.banner { display: flex; align-items: center; gap: 12px; margin-top: 19px; padding: 11px 15px; background: var(--alert-wash); border: 1px solid var(--alert-border); color: var(--alert); border-radius: 12px; font-size: 13px; }
.banner p { flex: 1; line-height: 1.6; }
.banner .link { color: inherit; font-size: 13px; flex: none; }
.notice { display: flex; align-items: center; gap: 10px; background: var(--accent-wash); color: var(--accent-text); border-radius: 10px; margin-bottom: 16px; padding: 10px 13px; font-size: 13px; line-height: 1.6; }
.notice > :first-child:not(svg) { flex: 1; }
.filters { display: grid; grid-template-columns: minmax(140px, 1.4fr) repeat(4, minmax(105px, 1fr)); gap: 11px; margin-bottom: 17px; }
.filters label, .field { display: flex; flex-direction: column; min-width: 0; gap: 6px; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; min-width: 0; min-height: 44px; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px; font-size: 16px; }
input[type="date"], input[type="time"] { appearance: none; -webkit-appearance: none; }
input[type="file"] { padding: 8px; }
textarea { resize: vertical; min-height: 69px; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; flex: none; accent-color: var(--accent); }
.transaction-list { display: grid; }
.transaction-row { text-align: left; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 11px; align-items: center; border: 0; border-bottom: 1px solid var(--border); background: transparent; padding: 11px 2px; color: var(--text); min-width: 0; }
.transaction-row:hover { background: var(--soft); }
.transaction-row:last-child { border-bottom: 0; }
.row-title { min-width: 0; }
.row-title strong, .row-title small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-title strong { font-size: 14px; }
.row-title small { font-size: 12px; color: var(--faint); margin-top: 3px; }
.row-money { font-size: 14px; font-weight: 750; text-align: end; }
.row-money.green { color: var(--green); }
.row-money.coral { color: var(--coral); }
.transaction-row > svg { width: 14px; height: 14px; color: var(--faint); }
.cancelled { text-decoration: line-through; color: var(--muted) !important; }
.stack { display: grid; gap: 15px; }
.setting-list { display: grid; gap: 9px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin: 12px 0; }
.setting-chip { min-height: 44px; text-align: left; justify-content: space-between; overflow-wrap: anywhere; }
.setting-chip svg { flex: none; }
.section-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.section-columns > * { min-width: 0; }
.details { margin-top: 13px; }
.details summary { color: var(--accent-text); font-weight: 700; min-height: 38px; padding: 8px 0; }
.shortcut-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.file-name { overflow-wrap: anywhere; font-weight: 700; color: var(--text); }
.check-line { display: flex; align-items: center; gap: 8px; min-height: 37px; font-size: 14px; }
.preview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preview-grid div { background: var(--soft); padding: 10px; border-radius: 8px; font-size: 12px; }
.preview-grid strong { display: block; font-size: 20px; margin-top: 3px; }
.error { color: var(--coral); font-size: 13px; line-height: 1.55; }
dialog { color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 19px; width: min(600px, calc(100% - 24px)); max-height: calc(100dvh - 35px); padding: 0; box-shadow: 0 20px 60px #17103240; }
dialog::backdrop { background: #14102678; }
.dialog-inner { padding: 18px 23px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 15px; }
.dialog-head h2 { font-size: 21px; }
.dialog-content { display: grid; gap: 12px; }
.dialog-footer { display: flex; justify-content: end; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 5px; }
.dialog-footer .push { margin-right: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid .wide { grid-column: 1 / -1; }
.amount-input { font-size: 24px; font-weight: 800; background: var(--soft); min-height: 51px; }
.toggle { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--soft); border: 1px solid var(--border); padding: 4px; border-radius: 11px; }
.toggle button { min-height: 42px; border-radius: 8px; color: var(--muted); border: 0; background: none; font-weight: 700; }
.toggle button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-text); }
.confirm-dialog { max-width: 440px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; background: var(--text); color: var(--panel); border-radius: 11px; max-width: calc(100% - 40px); padding: 12px 17px; box-shadow: var(--shadow); font-size: 14px; }
.toast:empty { display: none; }
.loading { color: var(--muted); }
@media (max-width: 1050px) { .layout { grid-template-columns: 190px minmax(0, 1fr); } .sidebar { padding-inline: 14px; } }
@media (max-width: 850px) {
  .layout { display: block; }
  .sidebar, .breadcrumb { display: none; }
  .mobile-brand { display: inline-flex; padding: 0; }
  .topbar { height: auto; min-height: 69px; padding-top: max(9px, env(safe-area-inset-top)); padding-bottom: 9px; }
  main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .bottom-nav { position: fixed; display: grid; grid-template-columns: repeat(5, 1fr); bottom: 0; inset-inline: 0; z-index: 3; background: var(--panel); border-top: 1px solid var(--border); padding: 4px max(8px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .bottom-nav .nav-item { min-height: 51px; flex-direction: column; justify-content: center; gap: 3px; font-size: 10px; padding: 3px; align-items: center; margin: 0 2px; }
  .bottom-nav .nav-item svg { width: 19px; height: 19px; }
  .toast { bottom: calc(69px + env(safe-area-inset-bottom)); }
}
@media (max-width: 620px) {
  .topbar { padding-inline: 15px; }
  .top-actions { gap: 7px; }
  .top-actions .connection { display: none; }
  .brand { font-size: 18px; gap: 8px; }
  .brand-mark { width: 35px; height: 35px; border-radius: 10px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .top-add { font-size: 13px; padding-inline: 10px; }
  main { padding: 22px 15px calc(80px + env(safe-area-inset-bottom)); }
  .heading { align-items: start; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
  .heading h1 { font-size: 26px; }
  .subtitle { font-size: 13px; margin-top: 4px; }
  .month-label { min-width: 112px; font-size: 13px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 13px; }
  .metric { padding: 12px; min-height: 103px; border-radius: 13px; }
  .metric.feature { grid-column: 1 / -1; }
  .metric-amount { margin-top: 7px; font-size: 24px; }
  .feature .metric-amount { font-size: 29px; }
  .metric-head { gap: 6px; }
  .metric .tile { width: 30px; height: 30px; }
  .metric-foot { margin-top: 5px; font-size: 11px; }
  .dashboard-grid, .section-columns { grid-template-columns: 1fr; gap: 12px; }
  .panel { padding: 14px; border-radius: 13px; }
  .quick-panel { margin-bottom: 13px; gap: 7px; padding: 11px; flex-wrap: wrap; }
  .quick-panel .button { font-size: 12px; padding-inline: 8px; }
  .quick-panel h2 { font-size: 13px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters label:first-child { grid-column: 1 / -1; }
  .banner { margin-top: 13px; padding: 8px 10px; gap: 7px; }
  .empty { min-height: 170px; }
  .dialog-inner { padding: 13px 15px; padding-bottom: max(13px, env(safe-area-inset-bottom)); }
  dialog[open]:not(.confirm-dialog) { margin: auto auto 0; width: 100%; max-width: 100%; max-height: calc(100dvh - max(10px, env(safe-area-inset-top))); border-radius: 17px 17px 0 0; }
}
