/* ===========================================
   露丝金店收支明细 — 双标签页版 + PWA 云同步
   首页：干净整洁（统计+表单）
   明细页：历史记录（需点击切换）
   =========================================== */

:root {
  --bg: #f4efe4;
  --bg-warm: #efe8d6;
  --bg-deep: #e6dcc8;
  --sidebar-bg: #faf6ee;
  --card: #ffffff;
  --card-alt: #fdf9f0;
  --text: #1f1508;
  --text-secondary: #6b5c40;
  --text-light: #9a8b6d;
  --text-muted: #c4b898;
  --accent: #a8852e;
  --accent-light: #d4b76a;
  --accent-bg: rgba(168,133,46,0.08);
  --accent-border: rgba(168,133,46,0.18);
  --gold: #c9a227;
  --gold-light: #fce9b8;
  --gold-gradient: linear-gradient(135deg, #a8852e 0%, #c9a227 50%, #d4b76a 100%);
  --gold-shimmer: linear-gradient(90deg, #a8852e 0%, #e8c84a 30%, #c9a227 50%, #e8c84a 70%, #a8852e 100%);
  --profit-pos: #1a7a2e;
  --profit-neg: #c02020;
  --profit-pos-bg: rgba(26,122,46,0.06);
  --profit-neg-bg: rgba(192,32,32,0.06);
  --border: rgba(168,133,46,0.10);
  --border-strong: rgba(168,133,46,0.22);
  --shadow-sm: 0 1px 3px rgba(30,18,6,0.04);
  --shadow-md: 0 2px 8px rgba(30,18,6,0.06);
  --shadow-lg: 0 4px 16px rgba(30,18,6,0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --transition: 0.22s ease;
}

* {
  margin: 0; padding: 0; box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  -webkit-font-smoothing: antialiased;
  -webkit-overflow-scrolling: touch;
}

.gold-bar {
  height: 3px;
  background: var(--gold-shimmer);
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.app { display: flex; flex-direction: column; min-height: 100vh; min-height: -webkit-fill-available; }

/* ========== Header ========== */
.header {
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 56px; }
.logo-area { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 36px; height: 36px;
  background: var(--gold-shimmer); background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
  border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-diamond { color: #fff; font-size: 1rem; }
.logo-text { display: flex; flex-direction: column; }
.title { font-size: 1.2rem; font-weight: 700; color: var(--accent); letter-spacing: 3px; line-height: 1.2; }
.title-sub { font-size: 0.72rem; color: var(--text-muted); font-weight: 400; letter-spacing: 2px; margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-date { font-size: 0.85rem; color: var(--text-light); font-weight: 500; }
.export-btn, .export-btn-history { font-size: 0.82rem; }

/* 同步状态按钮 */
#syncStatusBtn {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  white-space: nowrap;
}
#syncStatusBtn.synced {
  background: rgba(26,122,46,0.08);
  border-color: rgba(26,122,46,0.2);
  color: var(--profit-pos);
}

/* ========== Tab Navigation ========== */
.tab-nav {
  display: flex; gap: 0; padding: 0 24px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
}
.tab-btn {
  background: none; border: none; padding: 10px 20px;
  font-size: 0.82rem; font-weight: 500; color: var(--text-muted);
  cursor: pointer; position: relative; transition: all var(--transition);
  font-family: inherit; letter-spacing: 0.5px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn:hover { color: var(--text-light); }
.tab-btn.active {
  color: var(--accent); font-weight: 600;
}
.tab-btn.active::after {
  content: ''; position: absolute; bottom: 0; left: 10%; right: 10%;
  height: 2px; background: var(--gold-gradient); border-radius: 1px;
}

/* ========== Tab Content ========== */
.tab-content { flex: 1; }
.tab-content.hidden { display: none; }

/* ========== New Layout (Tab 1) ========== */
.new-layout {
  max-width: 860px; margin: 0 auto;
  padding: 24px 28px 40px;
}

/* Stats Overview */
.stats-overview {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 18px; display: flex; align-items: center; gap: 12px;
  transition: all var(--transition); box-shadow: var(--shadow-sm);
}
.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon-wrap {
  width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.stat-icon-wrap.gold { background: var(--accent-bg); }
.stat-icon-wrap.profit { background: var(--profit-pos-bg); }
.stat-icon-wrap.avg { background: var(--accent-bg); }
.stat-icon-wrap.count { background: var(--accent-bg); }
.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.5px; }
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }

/* Form Card */
.form-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-md); transition: all var(--transition);
}
.form-card:hover { border-color: var(--border-strong); }
.form-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 18px;
  padding-bottom: 14px; border-bottom: 2px solid var(--accent-border);
}
.form-card-icon { font-size: 0.7rem; color: var(--accent); }
.form-card-header h2 { font-size: 0.95rem; font-weight: 600; color: var(--accent); letter-spacing: 1.5px; }

/* Form Layout */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 0; }
.form-row.three-col { grid-template-columns: 1fr 1fr 1fr; }
.form-group { margin-bottom: 12px; }
.form-group label { font-size: 0.72rem; color: var(--text-light); font-weight: 500; margin-bottom: 5px; display: block; letter-spacing: 0.3px; }
.form-group input, .form-group select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  font-size: 16px;
  font-family: inherit; color: var(--text); background: var(--card-alt);
  outline: none; transition: all var(--transition); font-variant-numeric: tabular-nums;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group input:focus, .form-group select:focus {
  border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-bg);
}

/* Source combo */
.source-combo { position: relative; }
.source-combo select { width: 100%; }
.source-combo input[type="text"] { margin-top: 6px; display: none; }
.source-combo input[type="text"].visible { display: block; }

/* Calc Display */
.calc-display { background: var(--bg-deep); border-radius: var(--radius-xs); padding: 12px 16px; margin: 4px 0 12px; }
.calc-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.calc-label { font-size: 0.72rem; color: var(--text-light); font-weight: 500; }
.calc-value { font-size: 0.95rem; font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.calc-value.highlight { color: var(--profit-pos); font-weight: 800; }
.calc-value.negative { color: var(--profit-neg); font-weight: 800; }
.calc-input { font-size: 0.95rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; width: 120px; text-align: right; border: 1px solid var(--accent-border); border-radius: 6px; padding: 4px 10px; background: var(--card); outline: none; transition: border-color 0.2s; }
.calc-input:focus { border-color: var(--accent); }
.calc-input::placeholder { color: var(--text-muted); font-weight: 400; font-size: 0.8rem; }
.profit-row { border-top: 1px dashed var(--border); margin-top: 3px; padding-top: 7px; }

/* Buttons */
.btn-primary {
  background: var(--gold-gradient); color: #fff; border: none; padding: 12px 24px;
  border-radius: var(--radius-xs); font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition); font-family: inherit; letter-spacing: 1px;
  display: inline-flex; align-items: center; gap: 6px; width: 100%; justify-content: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover { box-shadow: 0 2px 12px rgba(168,133,46,0.25); transform: translateY(-1px); }
.btn-icon { font-size: 0.65rem; opacity: 0.7; }
.btn-secondary {
  background: var(--card-alt); color: var(--text-light); border: 1px solid var(--border);
  padding: 12px 24px; border-radius: var(--radius-xs); font-size: 0.88rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition); font-family: inherit; width: 100%; text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:hover { background: var(--card); border-color: var(--border-strong); color: var(--text); }
.btn-text {
  background: none; border: none; color: var(--accent); font-size: 0.82rem; font-weight: 500;
  cursor: pointer; padding: 6px 12px; border-radius: var(--radius-xs);
  transition: all var(--transition); font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-text:hover { background: var(--accent-bg); }
.btn-sm {
  background: none; border: 1px solid var(--border); color: var(--text-light);
  padding: 4px 10px; border-radius: 6px; font-size: 0.72rem; cursor: pointer;
  transition: all var(--transition); font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.btn-sm.del:hover { border-color: var(--profit-neg); color: var(--profit-neg); background: var(--profit-neg-bg); }
.form-buttons { display: flex; gap: 8px; margin-top: 8px; }

/* ========== History Layout (Tab 2) ========== */
.history-layout {
  max-width: 960px; margin: 0 auto;
  padding: 20px 28px 40px;
}
.history-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.history-title-text { font-size: 0.88rem; font-weight: 600; color: var(--text-secondary); letter-spacing: 1px; }

/* ========== Date Group ========== */
.date-group { margin-bottom: 24px; animation: groupIn 0.3s ease; }
@keyframes groupIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.date-group:last-child { margin-bottom: 0; }

.date-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--accent-bg); border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
}
.date-header-left { display: flex; align-items: center; gap: 10px; }
.date-text { font-size: 1rem; font-weight: 700; color: var(--accent); letter-spacing: 0.3px; }
.date-badge { font-size: 0.68rem; color: var(--accent); background: rgba(168,133,46,0.12); padding: 2px 8px; border-radius: 5px; font-weight: 600; }
.date-summary-right { display: flex; align-items: center; gap: 16px; font-size: 0.82rem; }
.date-summary-item { color: var(--text-light); font-variant-numeric: tabular-nums; }
.date-summary-item span { font-weight: 700; color: var(--text); }
.date-summary-item.profit-item span { color: var(--profit-pos); }
.date-summary-item.profit-neg span { color: var(--profit-neg); }

/* ========== Transaction Table ========== */
.tx-table { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.tx-table thead th {
  font-size: 0.68rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.5px;
  padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tx-table thead th:first-child { text-align: center; width: 40px; }
.tx-table thead th.th-source { text-align: left; width: 80px; }
.tx-table thead th:last-child { text-align: center; width: 90px; }
.tx-table tbody tr { background: var(--card); transition: all var(--transition); }
.tx-table tbody tr:hover { background: var(--card-alt); box-shadow: var(--shadow-sm); }
.tx-table tbody td {
  padding: 10px 10px; font-size: 0.85rem; font-variant-numeric: tabular-nums;
  text-align: right; border-bottom: 1px solid rgba(168,133,46,0.05);
}
.tx-table tbody td:first-child { text-align: center; color: var(--text-muted); font-size: 0.78rem; font-weight: 600; }
.tx-table tbody td.td-source { text-align: left; font-weight: 500; color: var(--text-secondary); font-size: 0.82rem; }
.tx-table tbody td:last-child { text-align: center; }
.tx-profit { font-weight: 700; }
.tx-profit.positive { color: var(--profit-pos); }
.tx-profit.negative { color: var(--profit-neg); }
.tx-diff.positive { color: var(--profit-pos); font-weight: 600; }
.tx-diff.negative { color: var(--profit-neg); font-weight: 600; }

/* Summary row */
.tx-table tbody tr.summary-row { background: var(--accent-bg); font-weight: 600; }
.tx-table tbody tr.summary-row td { border-top: 2px solid var(--accent-border); font-size: 0.85rem; }
.tx-table tbody tr.summary-row td:first-child { color: var(--accent); font-weight: 700; }

/* ========== Transaction Card (mobile) ========== */
.tx-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 6px; transition: all var(--transition); position: relative;
}
.tx-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%;
  background: var(--accent); opacity: 0.2; border-radius: 2px;
}
.tx-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.tx-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tx-card-num { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.tx-card-source { font-size: 0.78rem; color: var(--accent); font-weight: 500; margin-left: 6px; }
.tx-card-profit { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tx-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tx-card-item { display: flex; justify-content: space-between; padding: 3px 0; font-size: 0.78rem; }
.tx-card-item .tcl { color: var(--text-muted); }
.tx-card-item .tcv { font-weight: 600; font-variant-numeric: tabular-nums; }
.tx-card-note { font-size: 0.72rem; color: var(--text-muted); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.tx-card-actions { display: flex; gap: 6px; margin-top: 10px; }

.tx-card-summary {
  background: var(--accent-bg); border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm); padding: 12px 16px; margin-top: 8px; font-weight: 600;
}
.tx-card-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tx-card-summary-item { display: flex; justify-content: space-between; font-size: 0.78rem; padding: 3px 0; }
.tx-card-summary-item .tcl { color: var(--text-light); }

/* No Records */
.no-records { display: flex; align-items: center; justify-content: center; padding: 60px 20px; }
.empty-state { text-align: center; }
.empty-icon { font-size: 1.5rem; color: var(--accent); opacity: 0.2; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; color: var(--text-light); font-weight: 500; margin-bottom: 6px; }
.empty-state p { font-size: 0.82rem; color: var(--text-muted); }

/* ========== Mobile Add Hint ========== */
.mobile-add-hint {
  display: none;
  align-items: center; justify-content: center; gap: 16px;
  padding: 40px 20px; text-align: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.hint-icon {
  font-size: 2rem; color: var(--accent); opacity: 0.3;
  animation: hintPulse 2s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}
.hint-title { font-size: 0.92rem; color: var(--text-secondary); font-weight: 600; margin-bottom: 4px; }
.hint-desc { font-size: 0.78rem; color: var(--text-muted); }

/* ========== Footer ========== */
.footer { margin-top: auto; padding: 16px 24px 20px; text-align: center; }
.footer-line { height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0.1; margin-bottom: 12px; }
.footer-text { font-size: 0.72rem; color: var(--text-muted); letter-spacing: 2px; opacity: 0.5; }

/* ========== Toast ========== */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--text); color: var(--gold-light);
  padding: 10px 24px; border-radius: var(--radius-xs); font-size: 0.82rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all 0.3s ease; z-index: 500;
  border: 1px solid rgba(168,133,46,0.15); box-shadow: 0 8px 24px rgba(30,18,6,0.15); letter-spacing: 0.3px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== FAB (mobile) ========== */
.fab {
  display: none; position: fixed; bottom: 24px; right: 24px;
  background: var(--gold-gradient); color: #fff; border: none; padding: 14px 24px;
  border-radius: 50px; font-size: 0.92rem; font-weight: 700; cursor: pointer;
  z-index: 900;
  box-shadow: 0 4px 20px rgba(168,133,46,0.35);
  transition: all var(--transition); font-family: inherit; letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto !important;
  right: calc(24px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
.fab:active { transform: scale(0.95); }

/* ========== Mobile Panel ========== */
.mobile-panel-overlay {
  position: fixed; inset: 0; background: rgba(30,18,6,0.4);
  z-index: 800; transition: opacity 0.3s ease; opacity: 0;
  pointer-events: none !important;
  visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.mobile-panel-overlay.active {
  opacity: 1;
  pointer-events: auto !important;
  visibility: visible;
}
.mobile-panel {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--sidebar-bg); border-top: 2px solid var(--accent-border);
  border-radius: var(--radius) var(--radius) 0 0; padding: 20px 20px 40px;
  z-index: 850; max-height: 85vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none !important;
  visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.mobile-panel.active {
  transform: translateY(0);
  pointer-events: auto !important;
  visibility: visible;
}
.mobile-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.mobile-panel-header h2 { font-size: 0.95rem; font-weight: 600; color: var(--accent); letter-spacing: 1.5px; }
.mobile-panel-close {
  background: none; border: none; font-size: 1.2rem; color: var(--text-light); cursor: pointer;
  padding: 4px 8px; border-radius: 6px; transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mobile-panel-close:hover { background: var(--accent-bg); color: var(--text); }
.mobile-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mobile-calc-display { background: var(--bg-deep); border-radius: var(--radius-xs); padding: 10px 14px; margin: 4px 0 10px; }

/* ========== Stats Strip (mobile) ========== */
.stats-strip {
  display: none; background: var(--sidebar-bg); border-bottom: 1px solid var(--border);
  padding: 10px 16px; gap: 0; align-items: center; justify-content: space-around;
  position: sticky; top: 98px; z-index: 90;
}
.strip-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.strip-label { font-size: 0.68rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.5px; }
.strip-value { font-size: 0.88rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.strip-divider { width: 1px; height: 24px; background: var(--border); }

/* ========== 云同步设置面板 ========== */
.sync-panel { max-height: 90vh; }
.sync-content { display: flex; flex-direction: column; gap: 16px; }

.sync-status-box {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border);
}
.sync-status-box.connected {
  background: rgba(26,122,46,0.06);
  border-color: rgba(26,122,46,0.2);
}
.sync-status-icon { font-size: 2rem; flex-shrink: 0; }
.sync-status-text { flex: 1; }
.sync-status-title { font-size: 0.92rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.sync-status-desc { font-size: 0.78rem; color: var(--text-muted); }

.sync-config-section { display: flex; flex-direction: column; gap: 8px; }

.sync-share-section { display: flex; flex-direction: column; gap: 12px; }
.share-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
}
.share-label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.share-link-row { display: flex; gap: 8px; }
.share-link-row input {
  flex: 1; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  font-size: 0.78rem; color: var(--text); background: var(--card-alt);
  font-family: monospace; outline: none;
}
.share-link-row input:focus { border-color: var(--accent); }

.sync-info {
  background: rgba(26,122,46,0.04); border: 1px solid rgba(26,122,46,0.12);
  border-radius: var(--radius-sm); padding: 14px;
}
.sync-info p { font-size: 0.78rem; color: var(--profit-pos); margin-bottom: 6px; }
.sync-info p:last-child { margin-bottom: 0; }

.sync-guide { margin-top: 8px; }
.sync-guide summary {
  font-size: 0.82rem; color: var(--accent); cursor: pointer; padding: 8px 0;
  font-weight: 500; user-select: none;
}
.sync-guide summary:hover { text-decoration: underline; }
.guide-content { padding: 12px 0; }
.guide-content ol { padding-left: 20px; }
.guide-content li { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 6px; line-height: 1.5; }
.guide-content a { color: var(--accent); }
.sql-block {
  background: var(--text); color: #e8c84a; padding: 12px; border-radius: var(--radius-xs);
  font-size: 0.72rem; font-family: "Consolas", "Monaco", monospace; line-height: 1.5;
  overflow-x: auto; margin: 8px 0; white-space: pre;
}

/* ========== Responsive ========== */
@media (max-width: 767px) {
  .stats-overview { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 0.95rem; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.three-col { grid-template-columns: 1fr; }
  .new-layout { padding: 16px 16px 100px; }
  .history-layout { padding: 16px 16px 100px; }
  .form-card { padding: 18px; }

  .tab-nav { padding: 0 16px; }
  .tab-btn { padding: 8px 16px; font-size: 0.78rem; }

  .stats-strip.active { display: flex; }
  .export-btn { display: none; }
  .form-card { display: none !important; }
  .mobile-add-hint { display: flex; }
  .fab { display: inline-flex !important; }

  .header-inner { height: 48px; padding: 0 16px; }
  .header { padding: 0; }
  .header-right { gap: 6px; }
  .title { font-size: 1rem; letter-spacing: 2px; }
  .title-sub { font-size: 0.68rem; }
  .header-date { font-size: 0.72rem; }

  .tx-table { display: none !important; }
  .tx-cards-mobile { display: flex; flex-direction: column; }
  .date-header { padding: 10px 14px; }
  .date-text { font-size: 0.88rem; }
  .date-summary-right { gap: 12px; font-size: 0.78rem; }
  .toast { bottom: 80px; }
  .history-toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }

  #syncStatusBtn { font-size: 0.68rem; padding: 3px 8px; }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .stats-overview { grid-template-columns: repeat(2, 1fr); }
  .form-row.three-col { grid-template-columns: 1fr 1fr; }
  .stats-strip { display: none; }
  .fab { display: none !important; }
  .mobile-add-hint { display: none !important; }
  .form-card { display: block !important; }
}

@media (min-width: 1025px) {
  .stats-strip { display: none; }
  .fab { display: none !important; }
  .mobile-add-hint { display: none !important; }
  .form-card { display: block !important; }
}

@media (min-width: 768px) {
  .tx-cards-mobile { display: none !important; }
}

@media print {
  body { background: #fff; }
  .fab, .mobile-panel, .mobile-panel-overlay, .gold-bar, .stats-strip, .tab-nav { display: none; }
  .tab-content.hidden { display: block; }
  .history-layout { padding: 0; max-width: 100%; }
  .header { position: static; }
}

/* ========== 持仓（未卖出）相关样式 ========== */
.stat-icon-wrap.holding { background: rgba(201,162,39,0.12); }
.stat-card .stat-sub { font-size: 0.68rem; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

.label-hint { font-size: 0.68rem; color: var(--text-muted); font-weight: 400; margin-left: 4px; }

.hold-badge {
  display: inline-block; font-size: 0.6rem; font-weight: 600; color: #8a6d1a;
  background: var(--gold-light); padding: 1px 6px; border-radius: 4px;
  margin-left: 6px; vertical-align: middle; white-space: nowrap;
}
.hold-text { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }

.gold-type-badge {
  display: inline-block; font-size: 0.6rem; font-weight: 600; color: #8a6d1a;
  background: rgba(212,166,74,0.15); padding: 1px 6px; border-radius: 4px;
  margin-left: 4px; vertical-align: middle; white-space: nowrap;
}
.gold-type-badge.k-gold {
  color: #534AB7; background: rgba(127,119,221,0.12);
}

.holding-row { background: rgba(252,233,184,0.15); }
.holding-row:hover { background: rgba(252,233,184,0.25); }

.tx-card-holding { border-left: 3px solid var(--gold); }

.hold-summary { font-size: 0.65rem; color: var(--gold); font-weight: 500; margin-top: 2px; }

.btn-sm.settle {
  border-color: var(--gold); color: #8a6d1a; background: var(--gold-light);
}
.btn-sm.settle:hover {
  background: var(--gold); color: #fff; border-color: var(--gold);
}

/* ========== 持仓/已结算 区域标题 ========== */
.settle-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin: 20px 0 12px;
  border-radius: var(--radius-sm);
}
.settle-section-header.holding {
  background: rgba(252,233,184,0.35);
  border: 1px solid rgba(201,162,39,0.25);
}
.settle-section-header.settled {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
}
.settle-section-icon { font-size: 1rem; }
.settle-section-title { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.settle-section-header.holding .settle-section-title { color: #8a6d1a; }
.settle-section-stat {
  font-size: 0.78rem; color: var(--text-muted); font-weight: 500;
}
.settle-section-stat b { color: #8a6d1a; font-weight: 700; }
.settle-section-stat:first-of-type { margin-left: auto; }
.settle-section-count {
  font-size: 0.72rem; color: var(--text-muted); font-weight: 500;
}
