:root {
  color-scheme: light;
  font-family: "Inter", "Microsoft YaHei", system-ui, sans-serif;
  color: #182b3b;
  background: #f2f5f7;
  --navy: #112638;
  --ink: #182b3b;
  --muted: #516473;
  --line: #dbe4e9;
  --gold: #f4cc78;
  --white: #fff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 1rem; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 2.7rem); line-height: 1.12; letter-spacing: -.045em; }
h2 { font-size: 1.22rem; }
button, input, select, textarea, .button { font: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 42px;
  border: 1px solid #cbd8df; border-radius: 8px; padding: .53rem .85rem;
  background: var(--white); color: var(--ink); text-decoration: none; cursor: pointer;
  font-size: .9rem; font-weight: 650; white-space: nowrap;
}
button:hover, .button:hover { background: #e9f1f5; }
button:disabled { opacity: .55; cursor: wait; }
.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.primary:hover { background: #28465b; }
input, select, textarea {
  max-width: 100%; min-width: 0; min-height: 42px; padding: .5rem .68rem;
  color: var(--ink); background: #fff; border: 1px solid #cbd8df; border-radius: 8px;
}
textarea { resize: vertical; }
:focus-visible { outline: 3px solid #4687a8; outline-offset: 3px; }
.workspace { min-height: 100vh; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2.4rem;
  padding: 1.55rem 1.05rem; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; font-weight: 750; }
.brand-icon {
  display: inline-grid; width: 36px; height: 36px; place-items: center; border-radius: 9px;
  color: #31230a; background: var(--gold); font-family: Georgia, serif; font-size: 1.45rem; flex: none;
}
.sidebar nav { display: grid; gap: .35rem; }
.sidebar button { justify-content: flex-start; border: 0; background: transparent; color: #d4e0e7; }
.sidebar nav button { gap: .55rem; }
.sidebar nav button span { display: inline-grid; place-items: center; width: 19px; color: var(--gold); font-size: 1.05rem; }
.sidebar button:hover, .sidebar button[aria-current="page"] { background: #294358; color: #fff; }
.logout { margin-top: auto; }
main { width: 100%; max-width: 1440px; margin-inline: auto; padding: 2.25rem clamp(1rem, 4vw, 4rem) 3rem; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 1.1rem; margin-bottom: 1.55rem; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-size: .9rem; font-weight: 650; margin-bottom: .42rem; }
.actions, .filters, #import-form { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.dashboard-header {
  padding: 1.45rem 1.35rem 1.25rem;
  border-radius: 14px;
  color: #fff;
  background: radial-gradient(ellipse at top right, #2b5265, #112638 70%);
}
.dashboard-header .eyebrow { margin: .55rem 0 0; color: #d3e3ec; }
.dashboard-header .primary { background: var(--gold); color: #34250c; border-color: var(--gold); }
.dashboard-header .primary:hover { background: #ffdd97; }
.dashboard-header .month-step { min-height: 42px; padding-inline: .55rem; color: #eaf1f6; border-color: #6a8192; background: #203c4f; }
.dashboard-header .month-step:hover { background: #496578; }
.cards { display: grid; gap: .8rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards article, .panel { background: var(--white); border: 1px solid var(--line); border-radius: 12px; }
.cards article { padding: 1rem 1.12rem; min-height: 104px; border-top: 3px solid #16846d; }
.cards article:nth-child(2) { border-top-color: #c77a19; }
.cards article:nth-child(3) { border-top-color: #4b61b9; }
.cards article span { color: var(--muted); font-size: .9rem; }
.cards article strong { display: block; font-size: clamp(1rem, 2.1vw, 1.67rem); font-variant-numeric: tabular-nums; margin-top: .62rem; overflow-wrap: anywhere; }
.cards .emphasis { background: var(--navy); color: var(--gold); border-color: var(--navy); border-top-color: var(--gold); }
.cards .emphasis span { color: #d7e4ea; }
.meta { color: var(--muted); font-size: .875rem; line-height: 1.55; }
#metrics-source { margin: .4rem 0 1.1rem; min-height: 1.35rem; }
.panel { margin-bottom: 1rem; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .95rem 1.1rem; }
.insights { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 1rem; }
.trend-panel { padding-bottom: .8rem; }
.trend-panel header, .spotlight header { padding-bottom: .55rem; }
.trend-panel h2, .spotlight h2 { margin-bottom: .17rem; }
.trend-legend { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 1.1rem .45rem; }
.trend-legend button {
  --series: #12836d;
  display: inline-flex; gap: .36rem; min-height: 30px; padding: .2rem .46rem;
  font-size: .82rem; color: var(--muted); border-color: transparent;
}
.trend-legend button[data-series="expenses"] { --series: #c77a19; }
.trend-legend button[data-series="profit"] { --series: #4b61b9; }
.trend-legend button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--series); }
.trend-legend button[aria-pressed="true"] { color: var(--ink); background: #edf3f6; border-color: #dce7ed; }
.trend-legend button[aria-pressed="false"]::before { background: #a7b5bd; }
#trend-chart { display: block; width: calc(100% - 1.6rem); height: 157px; margin-inline: .8rem; }
.trend-months { display: flex; justify-content: space-between; gap: .12rem; margin: 0 .8rem 0 calc(.8rem + 28px); }
.trend-months button { min-height: 31px; padding: .14rem .32rem; border-color: transparent; color: var(--muted); font-size: .8rem; }
.trend-months button[aria-current="date"] { color: #123a4e; background: #e6f0f5; }
.trend-tooltip { padding: .38rem 1.1rem 0; min-height: 1.78rem; }
.ranking { display: grid; gap: .72rem; list-style: none; margin: 0; padding: .25rem 1.1rem .85rem; }
.ranking-line { display: flex; gap: .6rem; align-items: baseline; justify-content: space-between; min-width: 0; font-size: .9rem; }
.ranking-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-line strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ranking progress { display: block; appearance: none; width: 100%; height: 5px; margin-top: .35rem; border: 0; border-radius: 6px; background: #e9eff2; }
.ranking progress::-webkit-progress-bar { border-radius: 6px; background: #e9eff2; }
.ranking progress::-webkit-progress-value { border-radius: 6px; background: #b87529; }
.ranking progress::-moz-progress-bar { border-radius: 6px; background: #b87529; }
.review-entries { min-height: 34px; margin: 0 1.1rem .9rem; color: #754611; background: #fff5df; border-color: #ead6a8; }
.review-entries:hover { background: #f9e9c5; }
.ledger { scroll-margin-top: 1rem; }
.reconciliation dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 1.1rem 1.1rem; gap: .85rem; }
.reconciliation dt { color: var(--muted); font-size: .875rem; }
.reconciliation dd { margin-top: .38rem; font-size: 1.08rem; font-weight: 720; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.reconciliation > p { padding: 0 1.1rem .9rem; }
.filters { padding: 0 1.1rem .95rem; }
.filters input[type="search"] { width: min(100%, 270px); }
.check { display: flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .9rem; }
.check input { min-height: auto; width: 17px; height: 17px; margin: 0; }
.table-wrap { overflow: auto; border-radius: 0 0 12px 12px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; }
th, td { padding: .72rem .75rem; border-top: 1px solid var(--line); vertical-align: middle; }
th { white-space: nowrap; background: #edf3f6; color: #3a5262; }
td:first-child, td:nth-child(2), td.number { white-space: nowrap; }
td:nth-child(3) { min-width: 155px; overflow-wrap: anywhere; }
td:last-child { width: 1%; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
td .meta { display: block; white-space: normal; }
td .warning { color: #874817; }
td button { min-height: 36px; }
.empty { text-align: center; color: var(--muted); padding-block: 1.75rem; }
.storage { max-width: 850px; padding: 1.2rem; }
.storage > p { margin: .65rem 0 .85rem; line-height: 1.55; }
.storage ul { margin-bottom: 0; }
.storage a:not(.button) { color: #135c83; }
.preview { padding: .85rem; background: #edf3f6; border-radius: 8px; margin-top: .8rem; }
.preview p { margin-bottom: .6rem; white-space: pre-line; }
.feedback { color: #963441; line-height: 1.4; min-height: 1.3rem; }
.notice { position: fixed; bottom: 1.1rem; right: 1.1rem; padding: .72rem 1rem; border-radius: 8px; background: var(--navy); color: white; max-width: calc(100vw - 2.2rem); }
.login { min-height: 100dvh; display: grid; place-items: center; background: var(--navy); padding: 1rem; }
.login-card { display: grid; gap: .9rem; width: min(100%, 390px); padding: 1.8rem; border-radius: 14px; background: #fff; }
.login-card h1 { font-size: 2rem; }
.login-card label, .form-grid label:not(.check) { display: grid; gap: .32rem; font-size: .9rem; font-weight: 650; }
dialog { width: min(100% - 2rem, 565px); max-height: calc(100dvh - 2rem); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 65px #14273840; padding: 1.3rem; color: var(--ink); }
dialog::backdrop { background: #12233386; }
dialog header, dialog footer { display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
dialog footer { justify-content: flex-end; }
dialog .meta, dialog .feedback { margin-top: .6rem; }
.close { min-height: 36px; width: 36px; font-size: 1.2rem; padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin: .85rem 0; }
.wide { grid-column: 1/-1; }
.danger { color: #913746; margin-right: auto; }
.sr-only { position: absolute; left: 0; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 910px) {
  .workspace { grid-template-columns: 165px minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 650px) {
  .workspace { display: block; }
  .sidebar { position: static; flex-direction: row; align-items: center; height: auto; gap: .35rem .75rem; padding: .65rem .85rem; flex-wrap: wrap; }
  .brand { flex: 1; }
  .sidebar nav { display: flex; gap: .2rem; order: 2; width: 100%; }
  .sidebar button { padding-inline: .55rem; }
  .sidebar nav button span { display: none; }
  .logout { margin: 0; }
  main { padding-top: 1.3rem; }
  .page-header { align-items: start; }
  .dashboard-header { padding: 1rem; }
  .dashboard-header .actions { column-gap: .36rem; }
  .dashboard-header .actions input { min-width: 0; }
  .cards article { padding: .8rem; min-height: 86px; }
  .reconciliation dl { gap: .4rem; }
  .entry-month { grid-column: 1 / -1; }
  .table-wrap thead { position: absolute; left: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table, tbody { display: block; }
  tbody tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .4rem .6rem; padding: .75rem; border-top: 1px solid var(--line); }
  td { border: 0; padding: 0; }
  td:nth-child(1), td:nth-child(2), td:nth-child(5) { color: var(--muted); }
  td:nth-child(3) { grid-column: 1 / 3; grid-row: 2; min-width: 0; font-weight: 650; }
  td:nth-child(4) { grid-column: 3; grid-row: 1; font-weight: 700; }
  td:nth-child(5) { grid-column: 1 / 3; grid-row: 3; overflow-wrap: anywhere; }
  td:nth-child(6) { grid-column: 3; grid-row: 2 / 4; width: auto; align-self: center; }
  td.empty { grid-column: 1 / -1; padding-block: .6rem; }
}
