/* ================================================================
   群记账本 — 全局样式
   主色 #F18D24 | 清爽白底 | 响应式
   ================================================================ */

:root {
  --primary: #F18D24;
  --primary-hover: #e07d1a;
  --primary-light: #FFF7ED;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --success: #10B981;
  --danger: #EF4444;
  --income: #10B981;
  --expense: #EF4444;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Header ---- */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.header-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}
.header-group { display: flex; align-items: center; gap: 8px; }
.group-label { font-size: 14px; color: var(--text-secondary); white-space: nowrap; }
.group-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--card);
  min-width: 180px;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.tab {
  padding: 12px 24px;
  border: none;
  background: none;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ---- Main ---- */
.main { max-width: 1100px; margin: 24px auto; padding: 0 24px; }
.view { display: none; }
.view.active { display: block; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Form Elements ---- */
.input, .select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(241,141,36,.12);
}
.select { min-width: 120px; }

/* ---- Buttons ---- */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--bg); border-color: #ccc; }
.btn-danger {
  background: var(--card);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---- Overview Cards ---- */
.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.oc-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.oc-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.oc-value { font-size: 24px; font-weight: 700; }
.oc-value.income { color: var(--income); }
.oc-value.expense { color: var(--expense); }
.oc-value.balance { color: var(--text); }

/* ---- Quick Time Filter ---- */
.gb-quick-time.active, .ov-quick-time.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---- Overview Page Cards ---- */
.overview-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.ov-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.ov-value { font-size: 24px; font-weight: 700; }

/* ---- Table ---- */
.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  background: var(--primary-light);
  color: var(--text);
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody tr:hover { background: #FAFAFA; }
.table tbody tr:last-child td { border-bottom: none; }

.type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.type-badge.income { background: #ECFDF5; color: var(--income); }
.type-badge.expense { background: #FEF2F2; color: var(--expense); }

.amount-income { color: var(--income); font-weight: 600; }
.amount-expense { color: var(--expense); font-weight: 600; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 15px;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}
.pagination .btn { min-width: 36px; text-align: center; }
.page-info { font-size: 13px; color: var(--text-secondary); margin: 0 8px; }

/* ---- Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 460px;
  animation: slideDown .2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; }
.modal-close {
  border: none;
  background: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-group .input, .form-group .select { width: 100%; }
.required { color: var(--danger); }

/* ---- Summary Grid ---- */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .summary-grid { grid-template-columns: 1fr; }
}

/* ---- Card ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ---- Pie Chart ---- */
.pie-chart { text-align: center; margin-bottom: 12px; }
#pieSvg { width: 220px; height: 220px; }
.chart-legend { list-style: none; font-size: 13px; }
.chart-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-secondary);
}
.chart-legend .legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chart-legend .legend-value { margin-left: auto; font-weight: 600; color: var(--text); }

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.fadeout { animation: toastOut .3s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(40px); } }

/* ---- Loading ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.6);
  z-index: 3000;
  display: flex;
  justify-content: center;
  align-items: center;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 使用指南 ---- */
.guide-panel {
  background: linear-gradient(135deg, #fff8f0 0%, #fff3e0 100%);
  border-bottom: 2px solid #F18D24;
  padding: 20px 24px;
  position: relative;
  animation: guideSlideIn 0.3s ease;
}
@keyframes guideSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.guide-content h2 {
  margin: 0 0 16px;
  font-size: 18px;
  color: #333;
}
.guide-cols {
  display: flex;
  gap: 32px;
}
.guide-col {
  flex: 1;
  min-width: 0;
}
.guide-col h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #F18D24;
}
.guide-col ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
  color: #555;
  font-size: 14px;
}
.guide-col code {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 13px;
  color: #F18D24;
}
.guide-hint {
  margin-top: 12px;
  color: #999;
  font-size: 13px;
  font-style: italic;
}
.guide-dismiss {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 18px;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.guide-dismiss:hover {
  color: #333;
  background: rgba(0,0,0,0.05);
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .main { padding: 0 12px; margin: 16px auto; }
  .header { padding: 12px 16px; }
  .tabs { padding: 0 12px; }
  .tab { padding: 10px 16px; font-size: 14px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-direction: column; }
  .filter-group .input, .filter-group .select { width: 100%; }
  .overview-cards { grid-template-columns: 1fr 1fr; }
  .modal { max-width: 95%; }
  .guide-cols { flex-direction: column; gap: 16px; }
  .guide-panel { padding: 16px; }
}

/* ---- Footer hint ---- */
.version-hint {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---- Dashboard Grid ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ---- Settings Row ---- */
.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.settings-row .input { width: 160px; }

/* ---- Group Bill Member Net ---- */
.net-positive { color: var(--income); font-weight: 600; }
.net-negative { color: var(--expense); font-weight: 600; }
.settle-hint { font-size: 12px; color: var(--text-secondary); }
