:root {
  --bg-page: #F7F6F2;
  --bg-card: #FFFFFF;
  --bg-subtle: #F1EFE9;
  --border: #EAE7DF;
  --border-strong: #DCD7CA;
  --text-primary: #1C1B18;
  --text-secondary: #5C5850;
  --text-muted: #7C776D;
  --accent: #2D6A4F;
  --accent-hover: #23533D;
  --accent-soft: #EAF3EE;
  --accent-bar: #D6E4DC;
  --danger: #C53B3B;
  --danger-soft: #FDF0F0;
  --radius-lg: 20px;
  --radius-sm: 10px;
  --font-main: 'LXGW WenKai', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}
*::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.tabular {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.app-root {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-page);
}

/* 顶栏：外层与主滚动区同 padding，内层同 max-width 确保像素级左右齐平 */
.app-header {
  flex-shrink: 0;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  justify-self: start;
}

.brand-icon {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}

.header-date-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.seg-control {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: 999px;
  padding: 4px;
  border: 1px solid var(--border);
  gap: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--text-secondary);
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 700;
}

.pill-btn {
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pill-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.lock-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.lock-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lock-btn.unlocked {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.app-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 40px;
}

.main-container {
  max-width: 1080px;
  margin: 0 auto;
}

/* 日期导航 */
.nav-arrow {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-arrow:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.date-picker-trigger {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.date-picker-trigger:hover {
  background: var(--bg-subtle);
}

.date-main {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.date-week {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.date-native-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.today-chip {
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.mobile-date-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.mobile-date-center {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* PC 每日双栏 */
.day-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 356px;
  gap: 24px;
  align-items: start;
}

.entries-column {
  min-width: 0;
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
}

.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

.hero-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.hero-amount {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.08;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 1px;
}

.hero-currency {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 3px;
}

.hero-decimal {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hero-meta {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.guest-unlock-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guest-unlock-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.guest-unlock-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.entries-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pc-table-head {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) 100px 100px 110px;
  padding: 12px 22px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #FAF9F6;
}

.pc-table-head span:nth-child(n+2) {
  text-align: right;
}

.entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) 100px 100px 110px;
  align-items: center;
  padding: 15px 22px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}

.entry-row:last-child {
  border-bottom: none;
}

.entry-row:hover {
  background: #FAF9F6;
}

.entry-row.editing {
  background: var(--accent-soft);
}

.entry-title-cell {
  min-width: 0;
  padding-right: 12px;
}

.entry-title-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.entry-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-note {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-mobile-calc {
  display: none;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.entry-num-cell {
  text-align: right;
  font-size: 14px;
  color: var(--text-secondary);
}

.entry-total-cell {
  text-align: right;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

/* 表单与编辑面板 */
.pc-editor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.editor-title {
  font-size: 16px;
  font-weight: 700;
}

.editor-preview {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.sheet-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.suggest-chips:empty {
  display: none;
}

.suggest-chip {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.suggest-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.field-group {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.field-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-main);
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field-input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
}

.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.pin-actions {
  margin-top: 10px;
}

.btn-primary {
  flex: 1;
  border: none;
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  padding: 11px 14px;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  padding: 11px 14px;
  border-radius: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-danger {
  border: 1px solid #F0D2D2;
  background: var(--danger-soft);
  color: var(--danger);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  padding: 11px 14px;
  border-radius: 11px;
  cursor: pointer;
}

.btn-ghost {
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 13px;
  padding: 11px 14px;
  border-radius: 11px;
  cursor: pointer;
}

.empty-state {
  padding: 52px 24px;
  text-align: center;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* 月度统计 */
.month-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.month-kpi-row {
  display: flex;
  align-items: center;
  gap: 32px;
}

.kpi-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.month-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.chart-card, .rank-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  min-height: 24px;
}

.rank-header {
  margin-bottom: 4px;
}

.rank-sub-title {
  font-size: 12px;
  color: var(--text-muted);
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-focus {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
}

.chart-jump-btn {
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.bar-chart-wrap {
  width: 100%;
  height: 176px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding-top: 12px;
  overflow-x: auto;
}

.bar-col {
  flex: 1;
  min-width: 24px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  cursor: pointer;
}

.bar-col.empty {
  cursor: default;
}

.bar-track {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar-fill {
  width: 100%;
  max-width: 22px;
  border-radius: 6px 6px 3px 3px;
  background: var(--accent-bar);
  transition: background 0.15s ease, height 0.2s ease;
}

.bar-col.empty .bar-fill {
  height: 3px !important;
  border-radius: 2px;
  background: var(--border);
}

.bar-col.active .bar-fill,
.bar-col:not(.empty):hover .bar-fill {
  background: var(--accent);
}

.bar-day {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.bar-col.active .bar-day {
  color: var(--accent);
  font-weight: 700;
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.rank-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 14px;
}

.rank-name {
  font-weight: 700;
  color: var(--text-primary);
}

.rank-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

.rank-amt {
  font-weight: 700;
  color: var(--text-primary);
}

.rank-track {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.rank-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.month-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}

.month-day-row:last-child {
  border-bottom: none;
}

.month-day-row:hover {
  background: #FAF9F6;
}

.month-day-meta {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* 移动端已解锁底部吸底栏 */
.bottom-dock {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-page);
  border-top: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.dock-add-btn {
  width: 100%;
  border: none;
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* 模态弹窗与底部抽屉 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 24, 0.42);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}

.modal-mask.open {
  display: flex;
}

.pin-modal {
  width: 100%;
  max-width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 22px;
}

.pin-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.pin-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.pin-input {
  width: 100%;
  text-align: center;
  letter-spacing: 0.25em;
  font-size: 20px;
  font-weight: 700;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-main);
  outline: none;
}

.pin-input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
}

.pin-error {
  margin-top: 8px;
  min-height: 18px;
  font-size: 12px;
  color: var(--danger);
  text-align: center;
}

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 24, 0.38);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 35;
}

.sheet-mask.open {
  display: flex;
}

.sheet-panel {
  width: 100%;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: 24px 24px 0 0;
  padding: 12px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 14px;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: #FFFFFF;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 50;
  white-space: nowrap;
}

.empty-unlock-btn {
  margin-top: 14px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.toast.show {
  opacity: 1;
}

.hidden {
  display: none !important;
}

/* ============ 移动端响应式 (< 768px) ============ */
@media (max-width: 767px) {
  .app-header {
    border-bottom: none;
    padding: 0 16px;
  }

  .header-inner {
    display: flex;
    justify-content: space-between;
    padding: 16px 0 10px;
  }

  .header-date-slot,
  .export-label {
    display: none;
  }

  .pill-btn.export-btn,
  .lock-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }

  .app-scroll {
    padding: 4px 16px 96px;
  }

  .mobile-date-bar {
    display: flex;
  }

  .day-workspace {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .day-workspace > * {
    width: 100%;
  }

  .side-column {
    order: -1;
    position: static;
    width: 100%;
  }

  .pc-editor-card,
  .guest-unlock-card,
  .pc-table-head,
  .entry-num-cell {
    display: none !important;
  }

  .entry-row {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
  }

  .entry-mobile-calc {
    display: block;
  }

  .app-root.is-unlocked .bottom-dock {
    display: flex;
  }

  .toast {
    bottom: 86px;
  }

  .month-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 20px;
    gap: 16px;
  }

  .month-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }

  .month-grid {
    grid-template-columns: 1fr;
  }

  .month-day-row {
    padding: 14px 16px;
  }
}

/* ============ A4 简洁打印视图 ============ */
@media print {
  html, body, .app-root, .app-scroll {
    height: auto !important;
    overflow: visible !important;
    background: #FFFFFF !important;
  }
  .header-actions,
  .nav-arrow,
  .today-chip,
  .pc-editor-card,
  .guest-unlock-card,
  .bottom-dock,
  .sheet-mask,
  .modal-mask,
  .toast {
    display: none !important;
  }
  .day-workspace {
    display: block !important;
  }
  .side-column {
    position: static !important;
    margin-bottom: 16px;
  }
}
