:root {
  --color-bg: #f0f2f5;
  --color-surface: #ffffff;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-danger: #ef4444;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --spacing-md: 1rem;
  --spacing-lg: 2rem;
  --radius: 12px;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  padding: var(--spacing-lg);
}

#app-root {
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  flex-wrap: wrap;
  gap: var(--spacing-md);
}
.app-header h1 {
  font-size: 1.5rem;
}
/* ✅ Ensure header actions are always visible */
.header-actions {
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
  z-index: 10; /* Keep above other elements */
}

/* Buttons */
button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: all 0.2s;
}
.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--color-primary-hover);
}
.btn-text {
  background: transparent;
  color: var(--color-danger);
  font-size: 0.875rem;
  text-decoration: underline;
  /* ✅ Ensure always visible */
  display: inline-block;
  opacity: 1;
  pointer-events: auto;
}
.btn-text:hover {
  color: #b91c1c;
}
.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--spacing-lg);
}

/* Chart Card */
.chart-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chart-card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chart-card-header h3 {
  font-size: 1.1rem;
  color: var(--color-text-light);
}
.chart-actions {
  display: flex;
  gap: 0.5rem;
}
.chart-card-body {
  padding: 1rem 1.5rem;
  flex: 1;
}
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}
.chart-card-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.75rem;
  color: var(--color-text-light);
}

/* Status */
.status-msg {
  margin-top: var(--spacing-lg);
  font-size: 0.875rem;
  text-align: center;
  min-height: 1.25rem;
}
.status-msg.error {
  color: var(--color-danger);
}
.status-msg.success {
  color: var(--color-primary);
}

/* Modal for adding charts */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  width: 90%;
  max-width: 400px;
}
.modal h3 {
  margin-bottom: 1rem;
}
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.modal-form label {
  font-size: 0.875rem;
  font-weight: 500;
}
.modal-form select,
.modal-form input {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
