:root {
  --primary: #10b981; /* Emerald Green */
  --primary-rgb: 16, 185, 129;
  --accent: #f59e0b; /* Gratuity Gold */
  --accent-rgb: 245, 158, 11;
  --surface-border: rgba(16, 185, 129, 0.08);
  --surface-border-hover: rgba(16, 185, 129, 0.3);
  --gradient-main: linear-gradient(135deg, #10b981 0%, #059669 50%, #064e3b 100%);
  --gradient-hover: linear-gradient(135deg, #059669 0%, #047857 50%, #022c22 100%);
  --gradient-glow: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(245, 158, 11, 0.15) 100%);
  --shadow-glow: 0 20px 40px -15px rgba(16, 185, 129, 0.2), 0 0 0 1px rgba(16, 185, 129, 0.06);
  --bg-dots: rgba(16, 185, 129, 0.02);
}

/* Preset Tip Percentage Buttons Grid */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 480px) {
  .presets-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.preset-btn {
  background: #ffffff;
  border: 1px solid rgba(231, 19, 20, 0.15);
  color: var(--text-secondary);
  padding: 0.65rem 0.25rem;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  outline: none;
  text-align: center;
}

.preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(231, 19, 20, 0.03);
}

.preset-btn.active {
  background: var(--gradient-main);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(231, 19, 20, 0.2);
}

/* Split Totals Display Box */
.split-totals {
  background: rgba(0, 0, 0, 0.015);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.total-display {
  text-align: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px dashed var(--surface-border);
  padding-bottom: 1rem;
}

.total-label {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.total-val {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 7vw, 3rem);
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  overflow-wrap: break-word;
  word-break: break-word;
}

.sub-display {
  display: flex;
  flex-direction: column;
}

.sub-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.sub-val {
  font-family: var(--font-heading);
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-word;
}

/* Overall Summary Rows */
.overall-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.005);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.overall-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.overall-row strong {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-primary);
}

/* Donut Chart Visualizer */
.chart-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
}

@media (max-width: 480px) {
  .chart-container {
    flex-direction: column;
    gap: 1.5rem;
  }
}

.chart-wrapper {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}

#donut-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg); /* Start from 12 o'clock */
}

.chart-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 70%;
  height: 70%;
  background: var(--bg-color);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
  border: 1px solid var(--surface-border);
}

.center-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.center-val {
  font-family: var(--font-heading);
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-all;
}

/* Legends */
.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-grow: 1;
  min-width: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  gap: 0.5rem;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-name {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-val {
  font-weight: 600;
  color: var(--text-primary);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Calculate Summary Update Pulse Animation */
@keyframes calculatePulse {
  0% {
    transform: scale(1);
    box-shadow: var(--shadow-md);
  }
  50% {
    transform: scale(1.025);
    box-shadow: 0 20px 35px rgba(231, 19, 20, 0.15), 0 0 15px rgba(231, 19, 20, 0.1);
    border-color: rgba(231, 19, 20, 0.35);
  }
  100% {
    transform: scale(1);
    box-shadow: var(--shadow-md);
  }
}

.pulse-animation {
  animation: calculatePulse 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}
