:root {
  --primary: #C16E41;
  --primary-dark: #A3572E;
  --primary-light: #FBF4EF;
  --primary-gradient: linear-gradient(135deg, #C97A4E 0%, #B85F31 100%);
  --accent-green: #3D7A60;
  --accent-green-light: #EBF4F0;
  --accent-gold: #D48806;
  --accent-gold-light: #FFFBE6;
  --accent-blue: #1D6FB8;
  --accent-blue-light: #E8F3FF;
  --bg-page: #F7F5F0;
  --bg-card: #FFFFFF;
  --text-main: #242928;
  --text-sub: #67716E;
  --text-muted: #9BA4A1;
  --border-color: #EBE7DF;
  --border-light: #F2EFE9;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: 84px;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: var(--primary-gradient);
  color: #fff;
  padding: 16px 20px 20px;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(184, 95, 49, 0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.store-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.store-badge {
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
}

.header-date {
  font-size: 13px;
  opacity: 0.9;
}

/* Container */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 16px;
}

/* AI Voice Quick Memo Card */
.ai-memo-hero {
  background: linear-gradient(135deg, #FFFFFF 0%, #FFFDF9 100%);
  border: 1.5px solid #F1E5DA;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.ai-memo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ai-memo-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
}

.voice-input-box {
  position: relative;
  margin-bottom: 10px;
}

.voice-textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-main);
  background: #FCFBF8;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.voice-textarea:focus {
  border-color: var(--primary);
  background: #FFF;
}

.preset-tags {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
  scrollbar-width: none;
}

.preset-tags::-webkit-scrollbar {
  display: none;
}

.preset-tag {
  flex-shrink: 0;
  background: #F4F1EA;
  color: #555E5B;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.preset-tag:active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.ai-parse-btn {
  width: 100%;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(193, 110, 65, 0.3);
}

.ai-parse-btn:active {
  transform: scale(0.98);
}

/* Card styles */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.card-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

/* Tabs in page */
.sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.sub-tab {
  background: #EDEAE2;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  transition: all 0.2s;
}

.sub-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(193, 110, 65, 0.25);
}

/* Todo Item Card */
.todo-item {
  background: #FFF;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: all 0.2s;
}

.todo-item.completed {
  opacity: 0.55;
  background: #F9F8F5;
}

.todo-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #C4CDC8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all 0.2s;
}

.todo-item.completed .todo-check {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

.todo-content {
  flex: 1;
}

.todo-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.todo-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.todo-item.completed .todo-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.tag-birthday { background: #FFF0F0; color: #E03E3E; border: 1px solid #FFD4D4; }
.tag-construction { background: var(--accent-blue-light); color: var(--accent-blue); border: 1px solid #D0E5FF; }
.tag-finance { background: var(--accent-gold-light); color: var(--accent-gold); border: 1px solid #FFE58F; }
.tag-follow_up { background: var(--accent-green-light); color: var(--accent-green); border: 1px solid #D2ECE0; }

.todo-meta {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.todo-action-box {
  background: #FDF9F5;
  border: 1px dashed #E8D3C4;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: #7A4B2E;
  line-height: 1.4;
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.action-btn-mini {
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

/* Customer Card */
.customer-card {
  background: #FFF;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.customer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.customer-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.birthday-pill {
  background: #FFF2E8;
  color: #D4380D;
  border: 1px solid #FFBB96;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.customer-info-row {
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 5px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.customer-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid var(--border-light);
  padding-top: 10px;
}

.btn-outline {
  flex: 1;
  background: #FFF;
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

.btn-primary-sm {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

/* Calculator Form */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

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

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  display: block;
}

.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-main);
  background: #FFF;
  outline: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
}

.calc-result-box {
  background: #FDF9F5;
  border: 1.5px solid #F1DEC9;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 14px;
}

.result-headline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px dashed #E2D3C4;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.result-price {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}

.result-specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 14px;
  color: #5D544C;
  margin-bottom: 12px;
}

/* Construction Tasks */
.task-card {
  background: #FFF;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 16px;
  margin-bottom: 14px;
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.task-no {
  font-size: 13px;
  color: var(--text-muted);
  font-family: monospace;
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

.status-pending_accept { background: #FFF7E6; color: #D48806; }
.status-confirmed { background: var(--accent-blue-light); color: var(--accent-blue); }
.status-in_progress { background: #F0F5FF; color: #2F54EB; }
.status-completed { background: var(--accent-green-light); color: var(--accent-green); }
.status-settled { background: #F5F5F5; color: #8C8C8C; }

.photos-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.photo-thumb {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #EEE;
  cursor: pointer;
}

/* Finance Stats Cards */
.finance-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: #FFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
}

.stat-value.income { color: var(--accent-green); }
.stat-value.cost { color: #D4380D; }
.stat-value.profit { color: var(--primary); }
.stat-value.receivable { color: var(--accent-blue); }

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #FFFFFF;
  border-top: 1px solid #E5E1D8;
  display: flex;
  justify-content: space-around;
  padding: 8px 0 12px;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  width: 20%;
  border: none;
  background: transparent;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 20px;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  z-index: 2000;
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: #FFF;
  width: 100%;
  max-height: 88vh;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 20px;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal-overlay.active .modal-sheet {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.close-btn {
  background: #F0EDE5;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-sub);
}

/* Toast Notification */
#toast {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  background: rgba(36, 41, 40, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 3000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  pointer-events: none;
  white-space: nowrap;
}

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