/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

input,
select,
textarea,
button {
  max-width: 100%;
  box-sizing: border-box;
}

/* ===== Base ===== */
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #ebebeb;
  color: #1a1a1a;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  position: relative;
}

/* ===== Top Bar ===== */
.top-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 52px;
  background: #1a1a1a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 200;
  flex-shrink: 0;
}

.app-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.header-month {
  font-size: 13px;
  color: #888;
}

/* ===== Content Scroll Area ===== */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  margin-top: 52px;
  margin-bottom: 60px;
}

/* ===== Pages ===== */
.page {
  display: none;
  max-width: 100%;
  overflow-x: hidden;
}

.page.active {
  display: block;
}

.page-label {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/* ===== Dashboard — Stat Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: #f7f7f7;
  border: 1px solid #ececec;
  border-radius: 12px;
  padding: 14px 12px 12px;
}

.stat-card.highlight {
  background: #fff4eb;
  border-color: #fcd5ad;
}

.stat-card.wide {
  grid-column: span 2;
}

.stat-label {
  font-size: 12px;
  color: #999;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -0.5px;
}

/* 本月净额颜色由 JS 动态设置，不在 highlight 里写死 */
.net-positive {
  color: #1a8a4a !important;
}

.net-negative {
  color: #cc2000 !important;
}

/* ===== Quick Entry Form ===== */
.entry-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: #666;
}

.form-input {
  height: 46px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 16px;
  color: #1a1a1a;
  background: #fafafa;
  outline: none;
  width: 100%;
  font-family: inherit;
}

.form-input:focus {
  border-color: #d85000;
  background: #fff;
}

/* Radio */
.radio-group {
  display: flex;
  gap: 20px;
  padding: 4px 0;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  color: #333;
  cursor: pointer;
  user-select: none;
}

.radio-item input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #d85000;
  cursor: pointer;
}

/* 日期 + 时间：固定紧凑宽度，同一行，不撑满整行 */
.form-row-inline {
  display: grid;
  grid-template-columns: clamp(160px, 47vw, 188px) clamp(94px, 27vw, 110px);
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  overflow: visible;
}

/* grid 内的 form-col 不强制撑满列宽 */
.form-row-inline .form-col {
  width: auto;
  min-width: 0;
}

.form-col {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-col input,
.form-col select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* 日期/时间控件紧凑样式 */
.form-row-inline input[type="date"],
.form-row-inline input[type="time"] {
  height: 44px;
  font-size: 14px;
  padding-left: 8px;
  padding-right: 6px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.form-row-inline input[type="time"] {
  text-align: center;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
  height: 50px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  opacity: 0.75;
}

.btn-dark {
  flex: 1;
  background: #1a1a1a;
  color: #fff;
}

.btn-ghost {
  flex: 1;
  background: #fff;
  color: #1a1a1a;
  border: 1.5px solid #ddd;
}

.btn-danger {
  background: #fff;
  color: #cc2000;
  border: 1.5px solid #cc2000;
}

.btn-full {
  width: 100%;
  flex: unset;
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 0 48px;
  color: #bbb;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 14px;
  opacity: 0.3;
}

.empty-text {
  font-size: 16px;
  font-weight: 500;
  color: #bbb;
  margin-bottom: 6px;
}

.empty-hint {
  font-size: 13px;
  color: #ccc;
}

/* ===== Placeholder Cards ===== */
.placeholder-card {
  background: #fafafa;
  border: 1.5px dashed #ddd;
  border-radius: 12px;
  padding: 18px 16px;
  margin-bottom: 12px;
}

.placeholder-title {
  font-size: 14px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}

.placeholder-desc {
  font-size: 13px;
  color: #aaa;
}

/* ===== Summary List ===== */
.summary-list {
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  font-size: 15px;
  color: #444;
  border-bottom: 1px solid #f0f0f0;
}

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

.summary-row.summary-total {
  font-weight: 700;
  color: #1a1a1a;
  background: #f7f7f7;
}

.summary-key {
  color: #666;
}

.summary-val {
  font-weight: 600;
  color: #999;
}

.summary-total .summary-val {
  color: #d85000;
}

/* ===== Sync Page ===== */
.sync-block {
  margin-bottom: 20px;
}

.sync-block-title {
  font-size: 13px;
  font-weight: 600;
  color: #999;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.sync-textarea {
  display: block;
  width: 100%;
  height: 96px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  color: #333;
  background: #fafafa;
  resize: none;
  outline: none;
  margin-bottom: 8px;
  overflow-wrap: break-word;
  word-break: break-all;
}

.sync-textarea:focus {
  border-color: #d85000;
  background: #fff;
}

.danger-zone {
  padding-top: 18px;
  border-top: 1px solid #fce8e8;
  margin-top: 8px;
}

.danger-title {
  color: #cc2000 !important;
}

/* ===== Bottom Tab Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 60px;
  background: #fff;
  border-top: 1px solid #e8e8e8;
  display: flex;
  align-items: stretch;
  z-index: 200;
}

.tab-btn {
  flex: 1;
  min-width: 0;        /* 防止撑宽底部导航栏 */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.tab-btn.active {
  color: #d85000;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: #d85000;
  border-radius: 0 0 2px 2px;
}

.tab-icon {
  font-size: 17px;
  line-height: 1;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

/* ===== Default Person Bar ===== */
.default-person-bar {
  background: #f7f7f7;
  border: 1px solid #ececec;
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 14px;
}

.default-person-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.default-person-title {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  flex-shrink: 0;
  min-width: 72px;
}

.default-person-radios {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.default-person-radios .radio-item {
  font-size: 13px;
}

.default-person-hint {
  font-size: 11px;
  color: #bbb;
  margin-top: 5px;
}

/* ===== Record Cards ===== */
.record-card {
  background: #fff;
  border: 1px solid #eee;
  border-left: 3px solid #eee;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.record-card.expense {
  border-left-color: #cc2000;
}

.record-card.income {
  border-left-color: #1a8a4a;
}

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.record-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.record-datetime {
  font-size: 12px;
  color: #aaa;
}

.record-person {
  font-size: 12px;
  color: #888;
}

.record-amount {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.amount-expense {
  color: #cc2000;
}

.amount-income {
  color: #1a8a4a;
}

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 7px;
}

.tag {
  font-size: 11px;
  background: #f0f0f0;
  color: #555;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.tag-work {
  background: #fff0e0;
  color: #d85000;
}

.record-note {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
  line-height: 1.4;
}

.record-footer {
  display: flex;
  justify-content: flex-end;
}

.record-delete {
  font-size: 12px;
  color: #bbb;
  background: none;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.record-delete:active {
  color: #cc2000;
  border-color: #cc2000;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(26, 26, 26, 0.85);
  color: #fff;
  padding: 9px 22px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Budget Page ===== */
.budget-overview-card {
  background: #f7f7f7;
  border: 1px solid #ececec;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.budget-ov-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
}

.bov-label {
  font-size: 14px;
  color: #666;
}

.bov-val {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
}

.text-safe   { color: #1a8a4a; }
.text-danger { color: #cc2000; }

/* Progress bar */
.progress-wrap {
  height: 8px;
  background: #e8e8e8;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0 5px;
}

.progress-fill {
  height: 100%;
  background: #d85000;
  border-radius: 4px;
  min-width: 0;
}

.progress-fill.over {
  background: #cc2000;
}

.budget-pct-row {
  font-size: 12px;
  color: #999;
  text-align: right;
}

.budget-pct-row.over {
  color: #cc2000;
  font-weight: 600;
}

/* Category items */
.budget-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin: 4px 0 10px;
}

.budget-cat-item {
  background: #fafafa;
  border: 1px solid #ececec;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.budget-cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.budget-cat-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.budget-cat-pct {
  font-size: 13px;
  color: #888;
}

.budget-cat-pct.over {
  color: #cc2000;
  font-weight: 600;
}

.budget-cat-detail {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #aaa;
  margin-top: 5px;
}

/* Budget settings form */
.budget-form-wrap {
  margin-top: 6px;
}

.section-divider {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 12px 0 10px;
  border-top: 1px solid #eee;
  margin-top: 4px;
}

.budget-cat-label {
  font-size: 11px;
  font-weight: 600;
  color: #bbb;
  letter-spacing: 0.5px;
  margin: 12px 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #eee;
}

/* ===== Recurring Page ===== */
.recurring-reminder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff4eb;
  border: 1px solid #fcd5ad;
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #d85000;
  font-weight: 500;
}

.btn-reminder-gen {
  background: #d85000;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.recurring-actions {
  margin-bottom: 14px;
}

.recurring-card {
  background: #fff;
  border: 1px solid #eee;
  border-left: 3px solid #1a1a1a;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.recurring-card.disabled {
  border-left-color: #ccc;
  opacity: 0.5;
}

.recurring-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.recurring-card-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recurring-name {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
}

.recurring-status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.recurring-status-badge.enabled {
  background: #e8f5ee;
  color: #1a8a4a;
}

.recurring-status-badge.stopped {
  background: #f0f0f0;
  color: #999;
}

.recurring-amount {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.btn-edit-recurring {
  font-size: 12px;
  color: #555;
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
  margin-right: 8px;
  -webkit-tap-highlight-color: transparent;
}

.btn-edit-recurring:active {
  background: #f0f0f0;
}

.recurring-form-wrap {
  margin-top: 6px;
}

/* Tab badge */
.tab-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 14px;
  height: 14px;
  background: #cc2000;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 7px;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* ===== Sync Page Extras ===== */
.sync-output-area {
  height: 140px;
  background: #f5f5f5;
  font-size: 11px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  color: #444;
  cursor: text;
  overflow-wrap: break-word;
  word-break: break-all;
}

.import-result {
  margin-top: 10px;
  background: #f8f8f8;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px 14px;
}

.import-result-row {
  font-size: 14px;
  color: #333;
  padding: 3px 0;
}

.import-result-note {
  font-size: 12px;
  color: #d85000;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  line-height: 1.5;
}

.summary-text-display {
  margin-top: 10px;
  background: #f8f8f8;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: #333;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}

/* ===== Monthly Summary ===== */
.summary-card {
  background: #f7f7f7;
  border: 1px solid #ececec;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.summary-ov-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 15px;
  color: #444;
  border-bottom: 1px solid #f0f0f0;
}

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

.summary-ov-net {
  font-weight: 700;
  color: #1a1a1a;
}

.summary-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin: 14px 0 8px;
}

.summary-item {
  background: #fafafa;
  border: 1px solid #ececec;
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 7px;
}

.summary-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-item-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item-amount {
  font-size: 14px;
  font-weight: 700;
  color: #cc2000;
  flex-shrink: 0;
  margin-left: 10px;
}

.summary-item-meta {
  font-size: 12px;
  color: #aaa;
  margin-top: 4px;
}

.summary-person-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.summary-person-stat {
  font-size: 12px;
  color: #777;
}

.summary-empty {
  font-size: 13px;
  color: #bbb;
  text-align: center;
  padding: 16px 0;
}


/* ===== Desktop shadow ===== */
@media (min-width: 480px) {
  body {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
  }
}
