:root {
  --paper: #f2f5f3;
  --ink: #182823;
  --muted: #50645b;
  --hairline: #dce5df;
  --accent: #176448;
  --accent-hover: #104e37;
  --accent-tint: #e3f1e8;
  --soft: #f6f8f6;
  --tblr-body-color: var(--ink);
  --tblr-body-bg: var(--paper);
  --tblr-font-sans-serif: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --tblr-primary: var(--accent);
  --tblr-primary-rgb: 23, 100, 72;
  --tblr-link-color: var(--accent);
  --tblr-link-hover-color: var(--accent-hover);
}

body {
  font-family: var(--tblr-font-sans-serif);
  font-variant-numeric: tabular-nums;
  font-size: .9375rem;
  color: var(--ink);
  background: var(--paper);
}

[hidden] { display: none !important; }
::selection { color: var(--ink); background: #c7e7d6; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select, textarea { caret-color: var(--accent); }
a { text-underline-offset: .16em; }
button, summary { cursor: pointer; }
.skip-link { position: fixed; top: 1rem; left: 1rem; padding: .6rem 1rem; background: #fff; transform: translateY(-180%); z-index: 9; }
.skip-link:focus { transform: translateY(0); }
.app-top { background: #fff; border-bottom: 1px solid var(--hairline); }
.app-top-inner { max-width: 1536px; margin: 0 auto; min-height: 4.6rem; padding: .7rem 2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; gap: .65rem; align-items: center; min-width: 0; color: var(--ink); line-height: 1.32; text-decoration: none; }
.brand:hover { color: var(--accent); text-decoration: none; }
.brand-icon { display: grid; place-items: center; flex: 0 0 2.55rem; height: 2.55rem; border-radius: .55rem; background: var(--accent); color: #fff; }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-size: 1rem; }
.brand small, .page-heading p, .section-heading p, .sidebar-mode, .form-note { color: var(--muted); }
.brand small { font-size: .75rem; }
.top-actions { display: flex; align-items: center; gap: .6rem; }
.year-switch { display: flex; gap: .35rem; }
.year-switch select { width: auto; min-width: 7.5rem; }
.app-shell { max-width: 1536px; margin: 0 auto; display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); }
.app-sidebar { min-width: 0; padding: 1.7rem 1rem 1rem 1.6rem; border-right: 1px solid var(--hairline); }
.app-nav { display: grid; gap: 1.65rem; }
.nav-group { display: grid; gap: .2rem; }
.nav-label { padding: 0 .65rem .35rem; color: var(--muted); font-size: .76rem; }
.app-nav a { display: block; padding: .55rem .65rem; border-radius: .4rem; color: var(--ink); text-decoration: none; font-weight: 500; }
.app-nav a:hover { background: #edf2ee; color: var(--accent); }
.app-nav a[aria-current="page"] { background: var(--accent-tint); color: #11553b; font-weight: 700; }
.sidebar-mode { font-size: .76rem; margin: 2rem .65rem 0; }
.mobile-mode { display: none; }
.app-main { min-width: 0; padding: 1.7rem 2rem 3rem; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: 1.3rem; }
.page-heading h1, .login-intro h1 { margin: 0 0 .33rem; font-size: 1.8rem; line-height: 1.3; letter-spacing: -.025em; }
.page-heading p, .section-heading p { margin: 0; font-size: .85rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.section-heading h2 { margin-bottom: .22rem; }
.surface { min-width: 0; border: 1px solid var(--hairline); border-radius: .8rem; background: #fff; padding: 1.25rem; }
.surface h2 { font-size: 1.12rem; line-height: 1.38; letter-spacing: -.01em; }
.btn { min-height: 2.4rem; white-space: nowrap; }
.btn-sm { min-height: 2rem; }
.btn-primary, .btn-primary:focus-visible { --tblr-btn-bg: var(--accent); --tblr-btn-border-color: var(--accent); --tblr-btn-hover-bg: var(--accent-hover); --tblr-btn-hover-border-color: var(--accent-hover); }
.btn-outline-secondary { --tblr-btn-color: #3b5046; --tblr-btn-border-color: #bdccc3; --tblr-btn-hover-bg: #e6eee8; --tblr-btn-hover-color: var(--ink); --tblr-btn-hover-border-color: #9eb3a5; }
.logout-btn { min-height: 2.3rem; }
.overview-surface h2 { margin: 0 0 .6rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; }
.metric-item { padding: .65rem 1rem; border-left: 1px solid var(--hairline); overflow-wrap: anywhere; }
.metric-item:first-child { border-left: 0; padding-left: 0; }
.metric-item dt { font-size: .82rem; font-weight: 600; color: var(--muted); }
.metric-item dd { margin: .22rem 0; color: var(--ink); font-weight: 700; font-size: 1.53rem; line-height: 1.24; letter-spacing: -.025em; }
.metric-item .metric-hint { font-size: .76rem; line-height: 1.4; font-weight: 400; color: var(--muted); letter-spacing: normal; }
.dashboard-lower { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(13.2rem, 1fr); gap: 1rem; margin-top: 1rem; }
.chart-box { position: relative; height: 17rem; }
.task-surface h2 { margin-bottom: .7rem; }
.task-links { display: grid; }
.task-links a { display: grid; padding: .72rem .12rem; border-top: 1px solid var(--hairline); color: var(--accent); text-decoration: none; }
.task-links a:hover { text-decoration: underline; }
.task-links a span { margin-top: .14rem; color: var(--muted); font-size: .78rem; }
.empty-state { padding: 1.2rem .75rem; margin: .75rem 0 0; background: var(--soft); border-radius: .4rem; color: var(--muted); }
.date-controls, .report-filters { display: flex; align-items: end; gap: .5rem; }
.date-controls input, .report-filters .form-control { min-width: 8rem; }
.date-picker .form-label, .report-filters .form-label { margin-bottom: .3rem; }
.date-shortcuts { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .42rem; }
.date-shortcuts .btn { min-height: 2.25rem; padding-inline: .65rem; }
.date-shortcuts .btn:disabled { opacity: .68; }
.date-shortcuts .btn[aria-current="date"] { background-color: var(--accent-tint); border-color: #a3c0ae; color: var(--accent); font-weight: 650; }
.revenue-workbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .35rem .8rem; margin: .28rem 0 .6rem; }
.revenue-workbar strong { color: var(--ink); }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }
.form-note, .field-help { margin: 0; font-size: .8rem; line-height: 1.5; }
.edit-status:not(:empty) { color: #825117; font-weight: 650; }
.field-help { color: var(--muted); }
.field-grid { display: grid; gap: 1rem; }
.field-block > label { display: block; font-weight: 650; margin-bottom: .32rem; font-size: .88rem; }
.field-block input:not([type="checkbox"]), .field-block select, .field-block textarea {
  width: 100%; min-height: 2.55rem; padding: .43rem .7rem; border: 1px solid #bdccc3; border-radius: .32rem; background-color: #fff; color: var(--ink); font: inherit;
}
.field-block textarea { min-height: 5rem; resize: vertical; }
.field-block input[type="file"] { max-width: 100%; }
.field-error { color: #a32728; font-size: .84rem; }
.field-error ul, .alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.table-scroll { overflow-x: auto; padding-bottom: .25rem; }
.ledger-table { color: var(--ink); border-collapse: collapse; width: 100%; margin-bottom: 0; font-size: .87rem; }
.ledger-table thead th { background: #eef3ef; color: #40554a; padding: .68rem .55rem; white-space: nowrap; font-size: .76rem; font-weight: 680; letter-spacing: 0; }
.ledger-table td, .ledger-table tbody th { vertical-align: middle; white-space: normal; border-bottom-color: var(--hairline); padding: .62rem .55rem; }
.ledger-table .date-cell, .number-cell { white-space: nowrap; }
.number-cell { text-align: right; }
.revenue-grid .channel-name, .revenue-grid output { font-weight: 650; white-space: nowrap; }
.revenue-grid td { padding-inline: .38rem; }
.revenue-grid input { min-width: 3.9rem; padding-inline: .45rem; font-size: .82rem; }
.revenue-grid .quantity-input { min-width: 2.3rem; }
.revenue-grid .revenue-row-action { text-align: right; }
.status-pending, output[data-pending="true"] { color: #825117; }
.delete-details { margin-top: 1.1rem; padding-top: .8rem; border-top: 1px solid var(--hairline); }
.delete-details summary, .row-delete summary { color: #a32728; }
.delete-details p { margin: .45rem 0; }
.journal-layout { display: grid; align-items: start; grid-template-columns: minmax(14.4rem, 1fr) minmax(0, 2.4fr); gap: 1rem; }
.journal-form h2 { margin: 0 0 1rem; }
.table-actions { min-width: 6.35rem; }
.table-actions > a { display: inline-block; min-height: 1.6rem; }
.row-delete { display: inline-block; margin-left: .35rem; }
.row-delete form { padding: .35rem 0 0; }
.note-cell { min-width: 5rem; overflow-wrap: anywhere; }
.balance-line, .report-opening { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; background: var(--soft); border-radius: .4rem; padding: .65rem .7rem; }
.report-opening { margin: 0 0 .75rem; font-size: .85rem; }
.report-table { min-width: 43rem; }
.report-table :is(td, th):not(:first-child) { text-align: right; }
.report-annotation { display: block; margin-top: .15rem; font-size: .73rem; font-weight: 500; line-height: 1.4; color: var(--muted); }
.report-annotation.status-pending { color: #825117; font-weight: 650; }
.report-empty-row td { color: var(--muted); }
.report-note { margin-top: .8rem; }
.import-form { max-width: 40rem; }
.import-results { margin-top: 1rem; }
.import-results .ledger-table { min-width: 36rem; }
.login-main { display: grid; place-items: center; min-height: 100vh; padding: 2.1rem 1rem; }
.login-wrap { width: min(100%, 28rem); }
.login-intro .brand { margin-bottom: 1.75rem; }
.login-intro p { color: var(--muted); margin-bottom: 1rem; }
.login-form { display: grid; gap: 1rem; padding: 1.35rem; }
.login-form button { justify-content: center; min-height: 2.6rem; }
.login-foot { margin: .8rem 0 0; color: var(--muted); font-size: .77rem; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 11rem minmax(0, 1fr); }
  .app-main { padding-inline: 1.25rem; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-sidebar { padding: .45rem 1.2rem; border: 0; border-bottom: 1px solid var(--hairline); background: #fff; }
  .app-nav { display: flex; flex-wrap: wrap; gap: .25rem; }
  .nav-group { display: contents; }
  .nav-label, .sidebar-mode { display: none; }
  .app-nav a { font-size: .83rem; padding: .5rem .6rem; }
  .app-main { padding-bottom: 2rem; }
}

@media (max-width: 650px) {
  .app-top-inner { padding: .55rem .8rem; min-height: 3.6rem; gap: .4rem; }
  .top-actions { gap: .35rem; }
  .brand-icon { flex-basis: 2rem; height: 2rem; }
  .brand { gap: .4rem; }
  .brand strong { font-size: .86rem; }
  .brand small { font-size: .66rem; }
  .year-switch select { min-width: 6rem; font-size: .77rem; padding-left: .4rem; }
  .logout-btn { padding-inline: .55rem; font-size: .77rem; }
  .logout-btn span { display: none; }
  .app-sidebar { padding: .35rem .65rem; }
  .app-nav { gap: .12rem .18rem; }
  .app-nav a { padding: .42rem .58rem; }
  .app-main { padding: 1.1rem .8rem 1.8rem; }
  .mobile-mode { display: block; color: var(--muted); font-size: .72rem; margin: 0 0 .45rem; }
  .surface { padding: .9rem; border-radius: .65rem; }
  .page-heading { align-items: start; margin-bottom: 1rem; }
  .page-heading h1, .login-intro h1 { font-size: 1.46rem; }
  .page-heading .btn { margin-top: .03rem; }
  .section-heading { flex-wrap: wrap; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-item { padding-left: .6rem; padding-right: .45rem; }
  .metric-item:nth-child(odd) { padding-left: 0; border-left: 0; }
  .metric-item:nth-child(n+3) { border-top: 1px solid var(--hairline); }
  .metric-item dd { font-size: 1.32rem; }
  .dashboard-lower, .journal-layout { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
  .chart-box { height: 13rem; }
  .ledger-surface .section-heading { align-items: start; }
  .date-picker, .report-filters { width: 100%; }
  .report-filters { flex-wrap: wrap; }
  .table-scroll > .daily-report { display: block; min-width: 0; }
  .daily-report thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .daily-report tbody { display: block; }
  .daily-report tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .1rem .8rem; }
  .daily-report th, .daily-report td { display: block; padding: .45rem 0; }
  .daily-report :is(td, th):not(:first-child) { text-align: left; }
  .daily-report th { grid-column: 1 / -1; }
  .daily-report td::before { display: block; content: attr(data-label); color: var(--muted); font-size: .75rem; }
  .revenue-grid { display: block; }
  .revenue-grid thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .revenue-grid tbody { display: grid; gap: .66rem; }
  .revenue-grid tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: .55rem .6rem .65rem; border: 1px solid var(--hairline); border-radius: .5rem; gap: .35rem .45rem; }
  .revenue-grid td, .revenue-grid tbody th { display: block; padding: 0; border: 0; min-width: 0; }
  .revenue-grid tbody th { grid-column: 1 / -1; }
  .revenue-grid td[data-label]::before { display: block; content: attr(data-label); color: var(--muted); font-size: .72rem; margin-bottom: .15rem; }
  .revenue-grid input { min-width: 0; width: 100%; min-height: 2.1rem; }
  .revenue-grid output { font-size: .82rem; }
  .revenue-grid .revenue-row-action { align-self: end; }
  .journal-list .table-scroll > table { min-width: 26rem; }
  .login-main { place-items: start center; padding-top: 3rem; }
}

@media (hover: none) and (pointer: coarse) {
  .keyboard-hint { display: none; }
}

@media (max-width: 345px) {
  .brand strong { font-size: .76rem; }
  .brand small { font-size: .62rem; }
  .brand-icon { flex-basis: 1.7rem; height: 1.7rem; }
  .brand-icon svg { width: 18px; }
  .page-heading { flex-wrap: wrap; }
  .revenue-grid tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
