:root,
html[data-theme='light'] {
  --crm-bg: #f5f6f8;
  --crm-surface: #ffffff;
  --crm-surface-alt: #f7f7f8;
  --crm-border: #e6e7eb;
  --crm-text: #20232a;
  --crm-text-muted: #686e79;
  --crm-primary: #f97316;
  --crm-primary-hover: #ea650b;
  --crm-primary-light: #fff0e5;
  --crm-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --crm-radius-sm: 8px;
  --crm-radius-md: 12px;
  --crm-radius-lg: 16px;
  --crm-font-ui: 'Poppins', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --crm-font-display: 'Poppins', var(--crm-font-ui);

  --el-bg-color: var(--crm-surface);
  --el-bg-color-page: var(--crm-bg);
  --el-text-color-primary: var(--crm-text);
  --el-text-color-regular: var(--crm-text);
  --el-border-color: var(--crm-border);
  --el-color-primary: var(--crm-primary);
  --el-font-size-base: 13px;
  --el-font-size-small: 12px;
  --el-border-radius-base: 8px;
}

html.dark[data-theme='dark'] {
  --crm-bg: #14161c;
  --crm-surface: #1b1e27;
  --crm-surface-alt: #23262f;
  --crm-border: #2e3240;
  --crm-text: #e6e8ec;
  --crm-text-muted: #9aa0ac;
  --crm-primary: #ff8c3a;
  --crm-primary-hover: #ff9f5b;
  --crm-primary-light: #3a2a1c;
  --crm-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);

  --el-bg-color: var(--crm-surface);
  --el-bg-color-page: var(--crm-bg);
  --el-text-color-primary: var(--crm-text);
  --el-text-color-regular: var(--crm-text);
  --el-border-color: var(--crm-border);
  --el-color-primary: var(--crm-primary);
  color-scheme: dark;
}

html {
  font-size: 14px;
}

html,
body {
  background: var(--crm-bg);
  color: var(--crm-text);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
button,
input,
select,
textarea {
  font-family: var(--crm-font-ui);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0;
}

/* Jerarquía tipográfica consistente en toda la app — antes cada página
   repetía sus propios tamaños ad-hoc con poco contraste entre título y
   texto normal. */
h1, .page-title {
  font-family: var(--crm-font-display);
  font-size: clamp(22px, 2vw, 28px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.035em;
  margin: 0 0 4px;
  color: var(--crm-text);
}

h2 {
  font-family: var(--crm-font-display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--crm-text);
}

h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
  margin: 0 0 8px;
}

p, .page-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--crm-text-muted);
  line-height: 1.5;
  margin: 0;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-text-muted);
}

/* Element Plus trae su propia tipografía por defecto en headers de card,
   dialog, etc. — homologarla a la escala de arriba. */
.el-card__header,
.el-dialog__title,
.el-drawer__title {
  font-family: var(--crm-font-display);
  font-size: 15px !important;
  font-weight: 600 !important;
}

.el-table {
  --el-table-header-bg-color: var(--crm-surface-alt);
  --el-table-row-hover-bg-color: var(--crm-primary-light);
  border-radius: var(--crm-radius-md);
  font-size: 13px;
  overflow: hidden;
}

.el-button {
  min-height: 36px;
  border-radius: var(--crm-radius-sm);
  font-weight: 600;
}

.el-card {
  border-color: var(--crm-border);
  border-radius: var(--crm-radius-md);
  box-shadow: var(--crm-shadow);
}

.el-input__wrapper,
.el-select__wrapper,
.el-textarea__inner {
  border-radius: var(--crm-radius-sm);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-header .page-subtitle {
  margin-top: 6px;
}

.header-actions,
.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.filters {
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-md);
  background: var(--crm-surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.pagination {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--crm-primary) 24%, transparent);
  outline-offset: 2px;
}

:where(button, a, .el-card, .el-button, .el-input__wrapper) {
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

@media (max-width: 700px) {
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions > * {
    flex: 1;
  }
}
