:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --blue: #2563eb;
  --green: #0f8f61;
  --red: #c2410c;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html {
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}
button, input, select {
  font: inherit;
}
button {
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  background: #e6ebf2;
  color: var(--ink);
}
button.primary {
  background: var(--blue);
  color: #fff;
}
button.ghost {
  background: transparent;
  color: #d5dce8;
  border: 1px solid rgba(255,255,255,.25);
}
button:disabled { opacity: .55; cursor: wait; }
input, select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #e8edf5, #f8fafc);
}
.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}
.login-panel h1 { margin: 0 0 8px; font-size: 28px; }
.login-panel p { margin: 0 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 8px; color: var(--muted); }
.login-form button { background: var(--blue); color: #fff; }
.alert {
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff1f0;
  color: #b42318;
  border: 1px solid #fecdca;
}

.app-shell {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}
.sidebar {
  background: #1f2937;
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand {
  font-size: 20px;
  font-weight: 700;
}
.sidebar nav {
  display: grid;
  gap: 18px;
}
.nav-section {
  display: grid;
  gap: 6px;
}
.nav-section > span {
  padding: 0 10px 2px;
  color: #9aa4b2;
  font-size: 12px;
  font-weight: 700;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d5dce8;
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 6px;
}
.sidebar a i {
  width: 18px;
  color: #cbd5e1;
  font-style: normal;
  text-align: center;
}
.sidebar a.active, .sidebar a:hover {
  color: #fff;
  background: rgba(255,255,255,.12);
}
.sidebar form { margin-top: auto; }

.content {
  padding: 16px 18px 20px;
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.topbar h1 { margin: 0; font-size: 24px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
#syncStatusWrap,
#cashSyncStatusWrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.help-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
}
.help-tip::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: 260px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  content: attr(aria-label);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition: opacity .14s ease, transform .14s ease;
}
.help-tip:hover::after,
.help-tip:focus::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.filters {
  display: grid;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.filter-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.filter-label {
  color: var(--muted);
  font-weight: 700;
  line-height: 30px;
  white-space: nowrap;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.chip-group.scroll {
  max-height: 116px;
  overflow: auto;
  padding-right: 4px;
}
.chip-group.compact {
  max-height: 80px;
  overflow: auto;
}
.chip {
  min-height: 30px;
  max-width: 260px;
  padding: 5px 9px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #263241;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip:hover {
  border-color: #94a3b8;
  background: #eef2f7;
}
.chip.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .22);
}
.date-range {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.time-row {
  grid-template-columns: 62px minmax(300px, 1fr) auto;
}
.time-row .date-range {
  min-width: 244px;
}
.time-row input[type="date"] {
  width: 116px;
}
.date-range span,
.empty-hint {
  color: var(--muted);
}
.inline-filter-group {
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(260px, 420px);
  gap: 10px;
  align-items: end;
  justify-content: start;
}
.inline-filter {
  display: grid;
  gap: 5px;
}
.inline-filter > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.account-select-wrap select {
  min-width: 260px;
}
.keyword-row {
  grid-template-columns: 62px minmax(220px, 420px);
  align-items: center;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.metrics article, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.metrics article {
  min-height: 76px;
  padding: 12px 14px;
  display: grid;
  gap: 5px;
}
.metrics span { color: var(--muted); }
.metrics strong { font-size: 22px; letter-spacing: 0; }
.panel { padding: 12px 14px; }
.panel { overflow: hidden; }
.panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
}
.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.rank-list {
  display: grid;
  gap: 7px;
}
.rank-item {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 120px;
  gap: 7px;
  align-items: center;
}
.rank-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.rank-column {
  min-width: 0;
}
.compact-rank .rank-item:nth-child(n+7) {
  display: none;
}
.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  grid-column: 1 / -1;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--blue);
}
.amount { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}
.col-date { width: 112px; }
.col-account { width: 190px; }
.col-account-wide { width: 240px; }
.col-code { width: 120px; }
.col-subject { width: 150px; }
.col-detail { width: auto; }
.col-money { width: 118px; }
.col-balance { width: 118px; }
.col-type { width: 110px; }
.col-currency { width: 90px; }
.col-status { width: 90px; }
th, td {
  text-align: left;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}
th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.detail-cell {
  min-width: 320px;
  line-height: 1.45;
}
.cash-metrics {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}
.cash-filter-board {
  grid-template-columns: 1fr 1fr minmax(260px, 420px);
  align-items: end;
}
.cash-filter-board .filter-row {
  grid-template-columns: 52px minmax(0, 1fr);
}
.cash-keyword-row {
  grid-template-columns: 58px minmax(180px, 1fr);
}
.disabled-row {
  color: #98a2b3;
  background: #f8fafc;
}
.user-create {
  display: grid;
  grid-template-columns: 1fr 1fr 160px auto 1fr;
  gap: 10px;
  align-items: end;
}
.user-create h2 {
  grid-column: 1 / -1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.income-content {
  gap: 10px;
}

.compact-topbar h1 {
  font-size: 22px;
}

.compact-topbar p {
  font-size: 13px;
}

.income-filter-strip {
  grid-template-columns: minmax(460px, 1.35fr) minmax(430px, 1.1fr) minmax(420px, 1fr) minmax(220px, .65fr);
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  font-size: 13px;
}

.filter-cluster {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 6px;
  background: #f8fafc;
}

.filter-title {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.income-filter-strip .chip {
  min-height: 25px;
  max-width: 190px;
  padding: 3px 8px;
  font-size: 12px;
}

.income-filter-strip input,
.income-filter-strip select {
  min-height: 28px;
  padding: 5px 8px;
  font-size: 13px;
}

.time-cluster {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: start;
}

.time-cluster .filter-title {
  padding-top: 7px;
}

.preset-group {
  max-height: 58px;
  overflow: auto;
}

.compact-date-range {
  justify-content: flex-end;
  min-width: 236px;
}

.compact-date-range input[type="date"] {
  width: 112px;
}

.scope-cluster {
  grid-template-columns: 34px minmax(138px, .75fr) minmax(190px, 1fr) minmax(150px, .9fr);
  align-items: start;
}

.scope-cluster .filter-title {
  padding-top: 7px;
}

.scope-cluster .inline-filter {
  gap: 4px;
}

.scope-cluster .inline-filter > span,
.subject-filter-line > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.currency-chip-line {
  max-height: 58px;
}

.subject-cluster {
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
}

.subject-cluster .filter-title {
  padding-top: 7px;
  grid-row: 1 / span 2;
}

.subject-filter-line {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.subject-filter-line .chip-group.scroll {
  max-height: 50px;
}

.keyword-cluster {
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
}

.keyword-cluster .filter-title {
  padding-top: 7px;
}

.compact-metrics {
  gap: 8px;
}

.compact-metrics article {
  min-height: 62px;
  padding: 10px 12px;
}

.compact-metrics span {
  font-size: 12px;
}

.compact-metrics strong {
  font-size: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0 0 3px;
  font-size: 16px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-stat {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.subject-panel {
  padding: 10px 12px;
}

.subject-board {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.subject-board-head,
.subject-row {
  display: grid;
  grid-template-columns: minmax(230px, 1.15fr) minmax(170px, .8fr) minmax(170px, .8fr) minmax(118px, .45fr) 64px;
  gap: 8px;
  align-items: center;
}

.subject-board-head {
  padding: 7px 10px;
  color: var(--muted);
  background: #eef2f7;
  font-size: 12px;
  font-weight: 700;
}

.subject-row {
  min-height: 40px;
  padding: 6px 10px;
  border-top: 1px solid #edf1f6;
}

.subject-row.level-1 {
  background: #fbfcfe;
}

.subject-row.level-1 .subject-title {
  font-weight: 700;
}

.subject-row.level-2 {
  background: #fff;
}

.subject-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.subject-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-indent {
  width: 14px;
  flex: 0 0 14px;
  color: #98a2b3;
}

.subject-badge {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 4px;
  background: #eef2f7;
  color: #667085;
  font-size: 11px;
}

.bar-cell {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  width: 100%;
  min-height: 28px;
  padding: 3px 5px;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.bar-cell.hot {
  cursor: pointer;
}

.bar-cell.hot:hover,
.bar-cell.hot:focus {
  background: #f1f5f9;
  outline: 1px solid #cbd5e1;
}

.bar-cell:disabled {
  cursor: default;
  opacity: .72;
}

.bar-value {
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #e5e7eb;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.bar-cell.income .bar-track i {
  background: #16a34a;
}

.bar-cell.expense .bar-track i {
  background: #e11d48;
}

.subject-net,
.subject-count {
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.subject-net.positive {
  color: #0f766e;
}

.subject-net.negative {
  color: #be123c;
}

.subject-empty {
  padding: 18px;
  color: var(--muted);
}

.subject-popover {
  position: fixed;
  z-index: 50;
  width: min(520px, calc(100vw - 24px));
  max-height: min(480px, calc(100vh - 24px));
  overflow: auto;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(15, 23, 42, .18);
}

.subject-popover[hidden] {
  display: none;
}

.popover-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.popover-head span {
  color: var(--muted);
  white-space: nowrap;
}

.popover-loading,
.popover-error {
  color: var(--muted);
  padding: 12px;
}

.mini-table {
  min-width: 0;
  font-size: 12px;
}

.mini-table th,
.mini-table td {
  padding: 6px;
  font-size: 12px;
}

.mini-table th:nth-child(1),
.mini-table td:nth-child(1) {
  width: 88px;
  white-space: nowrap;
}

.mini-table th:nth-child(3),
.mini-table td:nth-child(3),
.mini-table th:nth-child(4),
.mini-table td:nth-child(4) {
  width: 108px;
}

.popover-pager,
.table-pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.popover-pager button,
.table-pager button {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 12px;
}

.details-panel {
  padding: 10px 12px;
}

.details-table-wrap table {
  min-width: 1180px;
}

.col-money-wide {
  width: 150px;
}

.account-cell {
  min-width: 160px;
}

.amount-pair {
  display: grid;
  gap: 2px;
  line-height: 1.15;
}

.amount-pair span {
  color: #667085;
  font-size: 12px;
  white-space: nowrap;
}

.amount-pair strong {
  font-size: 13px;
  white-space: nowrap;
}

.amount-pair.income strong {
  color: #15803d;
}

.amount-pair.expense strong {
  color: #be123c;
}

.amount-empty {
  display: block;
  min-height: 28px;
}

@media (max-width: 1500px) {
  .income-filter-strip {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .filter-cluster {
    overflow: hidden;
  }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    padding: 12px;
  }
  .sidebar nav { display: flex; }
  .nav-section {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .nav-section > span {
    display: none;
  }
  .sidebar form { margin-left: auto; margin-top: 0; }
  .filter-row,
  .keyword-row,
  .time-row,
  .cash-filter-board,
  .cash-filter-board .filter-row,
  .cash-keyword-row { grid-template-columns: 1fr; }
  .date-range { grid-column: auto; }
  .time-row .date-range,
  .account-select-wrap select {
    min-width: 0;
  }
  .time-row input[type="date"] {
    width: min(160px, 44vw);
  }
  .inline-filter-group {
    grid-template-columns: 1fr;
  }
  .filter-label { line-height: 1.2; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid.two,
  .rank-panel { grid-template-columns: 1fr; }
  .user-create { grid-template-columns: 1fr; }
  .income-filter-strip,
  .time-cluster,
  .scope-cluster,
  .subject-cluster,
  .keyword-cluster {
    grid-template-columns: 1fr;
  }
  .compact-date-range {
    justify-content: flex-start;
  }
  .subject-board {
    overflow-x: auto;
  }
  .subject-board-head,
  .subject-row {
    min-width: 820px;
  }
}

@media (max-width: 560px) {
  .content { padding: 14px; }
  .topbar { display: grid; }
  .metrics { grid-template-columns: 1fr; }
  .sidebar { overflow-x: auto; }
  .sidebar a {
    white-space: nowrap;
  }
}

[hidden] {
  display: none !important;
}

.income-content {
  gap: 10px;
}

.compact-topbar {
  min-height: 42px;
}

.income-filters {
  gap: 9px;
  padding: 10px;
}

.filter-group {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.filter-body {
  min-width: 0;
}

.time-filter .filter-body {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.preset-group {
  flex-wrap: wrap;
}

.scope-body {
  display: grid;
  grid-template-columns: auto minmax(230px, 360px) minmax(180px, 1fr);
  gap: 10px;
  align-items: end;
}

.direction-filter,
.currency-filter,
.subject-chip-block {
  display: grid;
  gap: 4px;
}

.direction-filter > span,
.currency-filter > span,
.subject-chip-block > span,
.account-select-wrap > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.subject-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.subject-body .chip-group.scroll {
  max-height: 70px;
}

.keyword-filter {
  grid-template-columns: 58px minmax(360px, 720px);
  align-items: center;
}

.view-section {
  display: grid;
  gap: 10px;
}

.board-metrics {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.board-metrics article {
  min-height: 66px;
  padding: 10px 12px;
}

.board-metrics strong {
  font-size: 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0 0 3px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-stat {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.subject-panel {
  padding: 12px;
}

.subject-board {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.subject-board-head,
.subject-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) minmax(160px, 1fr) minmax(160px, 1fr) 110px 72px;
  gap: 8px;
  align-items: center;
  min-width: 840px;
}

.subject-board-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.subject-row {
  padding: 7px 10px;
  border-top: 1px solid var(--line);
}

.subject-row.level-1 {
  background: #fbfcfe;
  color: #475467;
}

.subject-row.level-2 {
  background: #fff;
}

.subject-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.subject-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-indent {
  flex: 0 0 auto;
  min-width: 34px;
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.level-2 .subject-indent {
  margin-left: 18px;
  background: #e8f1ff;
  color: #1d4ed8;
}

.subject-amount {
  min-width: 0;
}

.money-track {
  position: relative;
  width: 100%;
  height: 26px;
  overflow: hidden;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #f8fafc;
  padding: 0 8px;
  text-align: right;
}

.money-track i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
}

.money-track span {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.money-track.income i {
  background: rgba(15, 143, 97, .22);
}

.money-track.expense i {
  background: rgba(194, 65, 12, .2);
}

.level-2 .money-track.income i {
  background: rgba(15, 143, 97, .42);
}

.level-2 .money-track.expense i {
  background: rgba(194, 65, 12, .36);
}

.money-track:hover {
  border-color: #94a3b8;
  background: #fff;
}

.subject-net,
.subject-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.subject-net.positive {
  color: var(--green);
}

.subject-net.negative {
  color: var(--red);
}

.board-empty {
  margin: 0;
  padding: 16px;
}

.subject-popover {
  position: fixed;
  z-index: 50;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .18);
  padding: 10px;
}

.popover-loading {
  color: var(--muted);
  font-size: 13px;
}

.popover-head,
.popover-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.popover-head {
  margin-bottom: 8px;
}

.popover-head span,
.popover-pager span {
  color: var(--muted);
  font-size: 12px;
}

.popover-table-wrap {
  max-height: 260px;
  overflow: auto;
}

.popover-table {
  min-width: 390px;
  font-size: 12px;
}

.popover-table th,
.popover-table td {
  padding: 6px;
  font-size: 12px;
}

.popover-pager {
  margin-top: 8px;
}

.popover-pager button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.details-panel {
  padding: 12px;
}

.details-table {
  min-width: 1220px;
}

.col-money-wide {
  width: 150px;
}

.amount-pair {
  white-space: pre-line;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .filter-group,
  .time-filter .filter-body,
  .scope-body,
  .subject-body,
  .keyword-filter {
    grid-template-columns: 1fr;
  }

  .keyword-filter {
    max-width: none;
  }

  .board-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .income-filters {
    padding: 9px;
  }

  .sidebar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    max-width: 100vw;
    overflow: hidden;
  }

  .sidebar nav {
    min-width: 0;
    overflow-x: auto;
  }

  .sidebar form {
    margin: 0;
  }

  .board-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .board-metrics article {
    min-height: 62px;
  }

  .board-metrics strong {
    font-size: 18px;
  }

  .panel-head {
    display: grid;
  }

  .subject-board-head,
  .subject-row {
    min-width: 760px;
    grid-template-columns: 220px 150px 150px 100px 64px;
  }

  .subject-popover {
    left: 10px !important;
    right: 10px;
    width: auto !important;
  }
}

.details-table-wrap table.details-table {
  min-width: 0;
  table-layout: fixed;
}

.details-table .col-date {
  width: 92px;
}

.details-table .col-account {
  width: 132px;
}

.details-table .col-subject {
  width: 105px;
}

.details-table .col-money-wide {
  width: 122px;
}

.details-table .col-balance {
  width: 88px;
}

.details-table th,
.details-table td {
  padding: 7px 8px;
  font-size: 13px;
}

.details-table .detail-cell,
.details-table .account-cell {
  min-width: 0;
  white-space: normal;
  word-break: break-word;
}

.details-table .amount-pair {
  white-space: normal;
}

.details-table .amount-pair span,
.details-table .amount-pair strong {
  white-space: normal;
}

.details-pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.details-pager button {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 12px;
}

.income-shell,
.income-content,
.income-filters,
.filter-group,
.filter-body,
.preset-group,
.scope-body,
.subject-body,
.keyword-filter,
.subject-panel,
.details-panel,
.subject-board,
.table-wrap {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 980px) {
  .income-shell {
    width: 100%;
    max-width: 100vw;
  }

  .sidebar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: auto;
  }

  .sidebar nav {
    display: flex;
    min-width: 0;
    overflow-x: auto;
    gap: 8px;
  }

  .nav-section {
    flex: 0 0 auto;
  }

  .sidebar form {
    flex: 0 0 auto;
    margin: 0;
  }

  .filter-group,
  .time-filter .filter-body,
  .scope-body,
  .subject-body,
  .keyword-filter {
    grid-template-columns: 1fr;
  }

  .date-range,
  .chip-group {
    max-width: 100%;
  }

  .account-select-wrap select,
  .keyword-filter input {
    width: 100%;
    min-width: 0;
  }

  .subject-board {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 12px;
  }

  .sidebar {
    gap: 10px;
  }

  .sidebar a {
    white-space: nowrap;
  }

  .date-range input[type="date"] {
    flex: 1 1 132px;
    min-width: 0;
    max-width: 160px;
  }

  .board-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .subject-board-head,
  .subject-row {
    min-width: 760px;
  }
}

@media (max-width: 980px) {
  .sidebar {
    overflow-x: hidden;
  }

  .sidebar nav {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }
}
