/* ═══════════════════════════════════════════════════════════════
   EvolvedSense components (2026-11-24) — load after tokens.css.
   Prefix es- so they never collide with Bootstrap or product CSS.
   Every product page and account-server page builds from these; product
   stylesheets add layout and marketing sections only.
   ═══════════════════════════════════════════════════════════════ */

/* Base */
.es-root, .es-root body { font-family: var(--es-font); color: var(--es-text); background: var(--es-bg); line-height: var(--es-leading); -webkit-font-smoothing: antialiased; }
.es-container { width: 100%; max-width: var(--es-container); margin-inline: auto; padding-inline: var(--es-space-4); }
.es-container--narrow { max-width: var(--es-container-narrow); }
.es-stack { display: flex; flex-direction: column; gap: var(--es-space-4); }
.es-row { display: flex; align-items: center; gap: var(--es-space-3); flex-wrap: wrap; }
.es-grid { display: grid; gap: var(--es-space-6); grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.es-muted { color: var(--es-text-3); }
.es-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.es-skip-link { position: absolute; left: var(--es-space-4); top: -100px; z-index: var(--es-z-toast); background: var(--es-surface); color: var(--es-text); padding: var(--es-space-2) var(--es-space-4); border-radius: var(--es-radius); box-shadow: var(--es-shadow-md); }
.es-skip-link:focus { top: var(--es-space-4); }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--es-focus); outline-offset: 2px; border-radius: var(--es-radius-sm); }

/* Headings */
.es-h1 { font-size: var(--es-text-4xl); line-height: var(--es-leading-tight); font-weight: 750; letter-spacing: -0.02em; }
.es-h2 { font-size: var(--es-text-2xl); line-height: var(--es-leading-tight); font-weight: 700; letter-spacing: -0.01em; }
.es-h3 { font-size: var(--es-text-lg); font-weight: 650; }
.es-eyebrow { font-size: var(--es-text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); }

/* Page header (portal pages) */
.es-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--es-space-4); flex-wrap: wrap; margin-bottom: var(--es-space-6); }
.es-page-header__title { font-size: var(--es-text-2xl); font-weight: 700; line-height: var(--es-leading-tight); }
.es-page-header__subtitle { color: var(--es-text-2); margin-top: var(--es-space-1); }
.es-breadcrumb { display: flex; gap: var(--es-space-2); font-size: var(--es-text-sm); color: var(--es-text-3); margin-bottom: var(--es-space-2); flex-wrap: wrap; }
.es-breadcrumb a { color: inherit; text-decoration: none; }
.es-breadcrumb a:hover { color: var(--es-text); }
.es-breadcrumb > * + *::before { content: "/"; margin-right: var(--es-space-2); color: var(--es-border-strong); }

/* Buttons */
.es-btn { --_bg: var(--es-surface); --_fg: var(--es-text); --_bd: var(--es-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--es-space-2);
  min-height: 40px; padding: 0 var(--es-space-4); border-radius: var(--es-radius); border: 1px solid var(--_bd);
  background: var(--_bg); color: var(--_fg); font: 600 var(--es-text-sm)/1 var(--es-font); text-decoration: none;
  cursor: pointer; transition: background var(--es-fast) var(--es-ease), border-color var(--es-fast) var(--es-ease), transform var(--es-fast) var(--es-ease); white-space: nowrap; }
.es-btn:hover { background: var(--es-surface-2); }
.es-btn:active { transform: translateY(1px); }
.es-btn[disabled], .es-btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
.es-btn--primary { --_bg: var(--brand); --_fg: var(--brand-contrast); --_bd: var(--brand); }
.es-btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.es-btn--ghost { --_bg: transparent; --_bd: transparent; }
.es-btn--danger { --_bg: var(--es-danger); --_fg: #fff; --_bd: var(--es-danger); }
.es-btn--danger:hover { background: color-mix(in srgb, var(--es-danger) 88%, #000); }
.es-btn--sm { min-height: 32px; padding: 0 var(--es-space-3); font-size: var(--es-text-xs); }
.es-btn--lg { min-height: 48px; padding: 0 var(--es-space-6); font-size: var(--es-text-md); border-radius: var(--es-radius-lg); }
.es-btn--block { width: 100%; }

/* Cards */
.es-card { background: var(--es-surface); border: 1px solid var(--es-border); border-radius: var(--es-radius-lg); box-shadow: var(--es-shadow-xs); }
.es-card__body { padding: var(--es-space-6); }
.es-card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--es-space-3); padding: var(--es-space-4) var(--es-space-6); border-bottom: 1px solid var(--es-border); }
.es-card__title { font-size: var(--es-text-md); font-weight: 650; }
.es-card__footer { padding: var(--es-space-4) var(--es-space-6); border-top: 1px solid var(--es-border); background: var(--es-surface-2); border-radius: 0 0 var(--es-radius-lg) var(--es-radius-lg); }
.es-card--link { transition: box-shadow var(--es-normal) var(--es-ease), border-color var(--es-normal) var(--es-ease), transform var(--es-normal) var(--es-ease); text-decoration: none; color: inherit; display: block; }
.es-card--link:hover { box-shadow: var(--es-shadow-md); border-color: var(--es-border-strong); transform: translateY(-2px); }

/* Stats */
.es-stat { display: flex; flex-direction: column; gap: var(--es-space-1); }
.es-stat__label { font-size: var(--es-text-sm); color: var(--es-text-3); }
.es-stat__value { font-size: var(--es-text-3xl); font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.es-stat__delta { font-size: var(--es-text-xs); font-weight: 600; }
.es-stat__delta--up { color: var(--es-success); }
.es-stat__delta--down { color: var(--es-danger); }

/* Forms */
.es-field { display: flex; flex-direction: column; gap: var(--es-space-1); }
.es-label { font-size: var(--es-text-sm); font-weight: 600; color: var(--es-text); }
.es-hint { font-size: var(--es-text-xs); color: var(--es-text-3); }
.es-error { font-size: var(--es-text-xs); color: var(--es-danger); }
.es-input, .es-select, .es-textarea { width: 100%; min-height: 40px; padding: var(--es-space-2) var(--es-space-3); border: 1px solid var(--es-border-strong); border-radius: var(--es-radius);
  background: var(--es-surface); color: var(--es-text); font: var(--es-text-sm)/1.4 var(--es-font); transition: border-color var(--es-fast) var(--es-ease), box-shadow var(--es-fast) var(--es-ease); }
.es-textarea { min-height: 120px; resize: vertical; }
.es-input:focus, .es-select:focus, .es-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--es-focus); }
.es-input[aria-invalid="true"] { border-color: var(--es-danger); }
.es-check { display: inline-flex; align-items: flex-start; gap: var(--es-space-2); font-size: var(--es-text-sm); }
.es-check input { accent-color: var(--brand); width: 16px; height: 16px; margin-top: 2px; }

/* Tables */
.es-table-wrap { overflow-x: auto; border: 1px solid var(--es-border); border-radius: var(--es-radius-lg); background: var(--es-surface); }
.es-table { width: 100%; border-collapse: collapse; font-size: var(--es-text-sm); }
.es-table th { text-align: left; font-weight: 600; color: var(--es-text-3); font-size: var(--es-text-xs); text-transform: uppercase; letter-spacing: 0.04em; padding: var(--es-space-3) var(--es-space-4); background: var(--es-surface-2); border-bottom: 1px solid var(--es-border); white-space: nowrap; }
.es-table td { padding: var(--es-space-3) var(--es-space-4); border-bottom: 1px solid var(--es-border); vertical-align: middle; }
.es-table tr:last-child td { border-bottom: 0; }
.es-table tbody tr:hover { background: color-mix(in srgb, var(--es-surface-2) 60%, transparent); }
.es-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badges */
.es-badge { display: inline-flex; align-items: center; gap: var(--es-space-1); padding: 2px var(--es-space-2); border-radius: var(--es-radius-full); font-size: var(--es-text-xs); font-weight: 600; background: var(--es-surface-2); color: var(--es-text-2); white-space: nowrap; }
.es-badge--brand { background: var(--brand-soft); color: var(--brand); }
.es-badge--success { background: var(--es-success-soft); color: var(--es-success); }
.es-badge--warning { background: var(--es-warning-soft); color: var(--es-warning); }
.es-badge--danger { background: var(--es-danger-soft); color: var(--es-danger); }
.es-badge--info { background: var(--es-info-soft); color: var(--es-info); }

/* Alerts */
.es-alert { display: flex; gap: var(--es-space-3); padding: var(--es-space-3) var(--es-space-4); border-radius: var(--es-radius); border: 1px solid transparent; font-size: var(--es-text-sm); }
.es-alert--info { background: var(--es-info-soft); color: var(--es-text); border-color: color-mix(in srgb, var(--es-info) 25%, transparent); }
.es-alert--success { background: var(--es-success-soft); color: var(--es-text); border-color: color-mix(in srgb, var(--es-success) 25%, transparent); }
.es-alert--warning { background: var(--es-warning-soft); color: var(--es-text); border-color: color-mix(in srgb, var(--es-warning) 25%, transparent); }
.es-alert--danger { background: var(--es-danger-soft); color: var(--es-text); border-color: color-mix(in srgb, var(--es-danger) 25%, transparent); }

/* Empty state */
.es-empty { text-align: center; padding: var(--es-space-12) var(--es-space-6); color: var(--es-text-2); }
.es-empty__icon { font-size: 2.25rem; color: var(--es-text-3); margin-bottom: var(--es-space-3); }
.es-empty__title { font-size: var(--es-text-lg); font-weight: 650; color: var(--es-text); margin-bottom: var(--es-space-1); }

/* Tabs */
.es-tabs { display: flex; gap: var(--es-space-1); border-bottom: 1px solid var(--es-border); margin-bottom: var(--es-space-6); overflow-x: auto; }
.es-tab { padding: var(--es-space-3) var(--es-space-4); color: var(--es-text-2); text-decoration: none; font-size: var(--es-text-sm); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.es-tab:hover { color: var(--es-text); }
.es-tab[aria-current="page"], .es-tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }

/* Toasts */
.es-toast-region { position: fixed; right: var(--es-space-4); bottom: var(--es-space-4); z-index: var(--es-z-toast); display: flex; flex-direction: column; gap: var(--es-space-2); max-width: min(380px, calc(100vw - 2rem)); }
.es-toast { background: var(--es-surface-inverse); color: var(--es-text-inverse); padding: var(--es-space-3) var(--es-space-4); border-radius: var(--es-radius); box-shadow: var(--es-shadow-lg); font-size: var(--es-text-sm); }

/* Avatar and menu */
.es-avatar { width: 32px; height: 32px; border-radius: var(--es-radius-full); background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: var(--es-text-sm); overflow: hidden; flex: none; }
.es-avatar img { width: 100%; height: 100%; object-fit: cover; }
.es-menu { position: relative; }
.es-menu > summary { list-style: none; cursor: pointer; }
.es-menu > summary::-webkit-details-marker { display: none; }
.es-menu__panel { position: absolute; right: 0; top: calc(100% + var(--es-space-2)); min-width: 240px; background: var(--es-surface); border: 1px solid var(--es-border); border-radius: var(--es-radius-lg); box-shadow: var(--es-shadow-lg); padding: var(--es-space-2); z-index: var(--es-z-dropdown); }
.es-menu__item { display: flex; align-items: center; gap: var(--es-space-2); padding: var(--es-space-2) var(--es-space-3); border-radius: var(--es-radius-sm); color: var(--es-text); text-decoration: none; font-size: var(--es-text-sm); width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.es-menu__item:hover { background: var(--es-surface-2); }
.es-menu__sep { height: 1px; background: var(--es-border); margin: var(--es-space-2) 0; }

/* Progress / steps */
.es-steps { display: flex; gap: var(--es-space-2); counter-reset: step; flex-wrap: wrap; }
.es-step { display: flex; align-items: center; gap: var(--es-space-2); font-size: var(--es-text-sm); color: var(--es-text-3); }
.es-step::before { counter-increment: step; content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--es-surface-2); font-weight: 700; font-size: var(--es-text-xs); }
.es-step.is-done::before { content: "\2713"; background: var(--es-success-soft); color: var(--es-success); }
.es-step.is-current { color: var(--es-text); font-weight: 600; }
.es-step.is-current::before { background: var(--brand); color: var(--brand-contrast); }
.es-progress { height: 8px; background: var(--es-surface-2); border-radius: var(--es-radius-full); overflow: hidden; }
.es-progress > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }

/* Responsive helpers */
@media (max-width: 720px) {
  .es-h1 { font-size: var(--es-text-3xl); }
  .es-card__body { padding: var(--es-space-4); }
  .es-page-header__title { font-size: var(--es-text-xl); }
}
