/* 与首页一致的深色风格 */
:root {
  --app-bg: #0f1419;
  --app-card: #1a2332;
  --app-text: #e6edf3;
  --app-muted: #8b949e;
  --app-accent: #1a73e8;
  --app-accent-hover: #2b7de9;
  --app-border: #30363d;
  --app-input-bg: #0d1117;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  font-size: 14px;
  background: var(--app-bg);
  color: var(--app-text);
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
}

.app a {
  color: var(--app-accent);
  text-decoration: none;
}

.app a:hover {
  color: var(--app-accent-hover);
  text-decoration: underline;
}

.app-header {
  background: var(--app-card);
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid var(--app-border);
  margin-bottom: 20px;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--app-text);
}

.app-header .back-home {
  font-size: 14px;
  font-weight: 500;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 13px;
  color: var(--app-muted);
  margin-right: 4px;
}

.toolbar #billPath {
  flex: 1;
  min-width: 220px;
  padding: 9px 12px;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  background: var(--app-input-bg);
  color: var(--app-text);
}

.toolbar #billPath::placeholder {
  color: var(--app-muted);
}

.toolbar button,
.panel button,
.section-transactions button {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: var(--app-accent);
  color: #ffffff !important;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
}

.toolbar button:hover,
.panel button:hover,
.section-transactions button:hover {
  background: var(--app-accent-hover);
  color: #ffffff !important;
}

/* 类别 + 类别管理：左大右小 */
.section-category {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .section-category { grid-template-columns: 1fr; }
}

.panel {
  background: var(--app-card);
  padding: 18px 20px;
  border-radius: 8px;
  border: 1px solid var(--app-border);
}

.panel-title {
  margin: 0 0 14px 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--app-text);
}

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

.panel label {
  display: block;
  font-size: 12px;
  color: var(--app-muted);
  margin-bottom: 6px;
}

.panel select {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  background: var(--app-input-bg);
  color: var(--app-text);
}

.panel input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  background: var(--app-input-bg);
  color: var(--app-text);
}

.panel input::placeholder {
  color: var(--app-muted);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* 选择类别与关键词：第一块 */
.keywords-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.keywords-select {
  flex: 1;
  min-width: 180px;
}

.keywords-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.keywords-box {
  margin-top: 4px;
}

.keywords-box label {
  color: var(--app-muted);
  font-size: 12px;
  margin-bottom: 6px;
  display: block;
}

.keywords-box .keyword-list {
  min-height: 100px;
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13px;
  background: var(--app-input-bg);
  color: var(--app-text);
  width: 100%;
}

.keywords-box .keyword-list::placeholder {
  color: var(--app-muted);
}

/* 分类花费统计：独立一块 */
.panel-summary {
  margin-bottom: 20px;
}

.bill-total {
  font-weight: 600;
  margin: 0 0 12px 0;
  font-size: 14px;
  color: var(--app-text);
}

.summary-table-wrap {
  overflow-x: auto;
  margin-bottom: 14px;
}

.btn-charts {
  margin-top: 4px;
}

.summary-table-wrap table,
.section-transactions .table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table-wrap th,
.summary-table-wrap td,
.section-transactions .table-wrap th,
.section-transactions .table-wrap td {
  border: 1px solid var(--app-border);
  padding: 6px 10px;
  text-align: left;
  color: var(--app-text);
}

.summary-table-wrap thead,
.section-transactions .table-wrap thead {
  background: var(--app-card);
  color: var(--app-text);
  font-weight: 600;
}

.section-transactions .table-wrap thead th {
  border-color: var(--app-border);
}

.section-transactions {
  background: var(--app-card);
  padding: 18px 20px;
  border-radius: 8px;
  border: 1px solid var(--app-border);
}

.transactions-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.transactions-toolbar .hint {
  margin: 0;
  font-size: 12px;
  color: var(--app-muted);
}

.section-transactions .table-wrap {
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
}

.section-transactions tbody tr:hover {
  background: rgba(26, 115, 232, 0.08);
}

.section-transactions tbody tr.selected {
  background: rgba(26, 115, 232, 0.15);
}

.section-transactions .amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.section-transactions input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--app-accent);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: var(--app-card);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--app-border);
  max-width: 95vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
}

.modal-content h2 {
  color: var(--app-text);
  margin: 0 0 16px 0;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  cursor: pointer;
  color: var(--app-muted);
}

.modal-close:hover {
  color: var(--app-text);
}

.chart-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.chart-wrap {
  width: 360px;
  height: 280px;
}

.chart-wrap canvas {
  max-width: 100%;
  max-height: 100%;
}
