/* EASAL shared component system, v2. Loaded after bootstrap.min.css, fonts.css and
   tokens.css in both apps. Reads tokens only. Portal-only layout lives in
   EASAL.Web/wwwroot/css/site.css; app-only screens in EASAL.Maui/wwwroot/css/survey.css. */

/* ---------- Base ---------- */
html, body { background: var(--e-bg); color: var(--e-ink); font-family: var(--e-font-family); font-size: var(--e-font-size); line-height: var(--e-line-height); }
*, *::before, *::after { box-sizing: border-box; }
h1, h2, h3, h4, .h1, .h2, .h3 { font-family: var(--e-font-family-heading); font-weight: var(--e-heading-weight); line-height: 1.2; color: var(--e-ink); letter-spacing: -0.01em; margin: 0; }
a { color: var(--e-primary); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--e-primary-hover); }
.e-num, time, .e-date { font-variant-numeric: var(--e-numeric); }
:focus-visible { outline: 3px solid var(--e-focus-ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Type scale */
.e-display { font-size: var(--e-font-size-display); font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: var(--e-numeric); }
.e-title { font-size: var(--e-font-size-xl); font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; }
.e-section-title { font-size: var(--e-font-size-lg); font-weight: 700; line-height: 1.25; }
.e-small { font-size: var(--e-font-size-sm); }
.e-caption { font-size: var(--e-font-size-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--e-ink-muted); }
.e-muted { color: var(--e-ink-muted); }

/* Icons: Lucide sprite */
.e-icon { width: var(--e-icon); height: var(--e-icon); flex-shrink: 0; display: inline-block; vertical-align: middle; }
.e-icon-sm { width: 16px; height: 16px; }

/* ---------- Buttons ---------- */
.e-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--e-control-h); padding: 0 16px; border-radius: var(--e-radius-sm);
  border: 1.5px solid var(--e-primary); background: var(--e-primary); color: var(--e-primary-contrast);
  font-family: inherit; font-size: var(--e-font-size-sm); font-weight: var(--e-weight-semibold); line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--e-motion), border-color var(--e-motion), color var(--e-motion), box-shadow var(--e-motion);
}
.e-btn:hover { background: var(--e-primary-hover); border-color: var(--e-primary-hover); color: var(--e-primary-contrast); }
.e-btn:active { transform: translateY(1px); }
.e-btn-secondary { background: var(--e-surface); color: var(--e-primary); border-color: var(--e-line); }
.e-btn-secondary:hover { background: var(--e-primary-soft); border-color: var(--e-primary); color: var(--e-primary); }
.e-btn-tertiary { background: transparent; border-color: transparent; color: var(--e-primary); padding: 0 10px; }
.e-btn-tertiary:hover { background: var(--e-primary-soft); border-color: transparent; color: var(--e-primary-hover); }
.e-btn-danger { background: var(--e-danger); border-color: var(--e-danger); }
.e-btn-danger:hover { background: var(--e-danger-hover); border-color: var(--e-danger-hover); }
.e-btn-lg { min-height: var(--e-control-h-lg); padding: 0 24px; font-size: var(--e-font-size); }
.e-btn-sm { min-height: 32px; padding: 0 10px; font-size: var(--e-font-size-xs); }
.e-btn-icon { width: var(--e-control-h); padding: 0; }
.e-btn:disabled, .e-btn[disabled], .e-btn[aria-disabled="true"] { background: var(--e-surface-sunken); border-color: var(--e-surface-sunken); color: var(--e-ink-faint); cursor: default; transform: none; }

/* ---------- Badges: exactly two families ---------- */
.e-badge, .e-grade-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px;
  border-radius: var(--e-radius-pill); font-size: var(--e-font-size-xs); font-weight: 700; line-height: 1; white-space: nowrap;
}
.e-badge::before, .e-grade-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
/* Grade badge: soft fill in the grade colour, dot + word in the grade colour */
.e-grade-badge-outstanding { background: var(--e-grade-outstanding-soft); color: var(--e-grade-outstanding); }
.e-grade-badge-good        { background: var(--e-grade-good-soft);        color: var(--e-grade-good); }
.e-grade-badge-improve     { background: var(--e-grade-improve-soft);     color: var(--e-grade-improve); }
.e-grade-badge-inadequate  { background: var(--e-grade-inadequate-soft);  color: var(--e-grade-inadequate); }
.e-grade-badge-na          { background: var(--e-grade-na-soft);          color: var(--e-grade-na); }
.e-grade-badge-lg { height: 36px; padding: 0 14px 0 12px; font-size: var(--e-font-size-sm); }
.e-grade-text-outstanding { color: var(--e-grade-outstanding); } .e-grade-text-good { color: var(--e-grade-good); }
.e-grade-text-improve { color: var(--e-grade-improve); } .e-grade-text-inadequate { color: var(--e-grade-inadequate); } .e-grade-text-na { color: var(--e-grade-na); }
/* Grade tint: soft grade fill with the grade colour, for icon discs (audit detail, results). */
.e-tint-outstanding { background: var(--e-grade-outstanding-soft); color: var(--e-grade-outstanding); }
.e-tint-good { background: var(--e-grade-good-soft); color: var(--e-grade-good); }
.e-tint-improve { background: var(--e-grade-improve-soft); color: var(--e-grade-improve); }
.e-tint-inadequate { background: var(--e-grade-inadequate-soft); color: var(--e-grade-inadequate); }
.e-tint-na { background: var(--e-grade-na-soft); color: var(--e-grade-na); }
/* Status badge: neutral fill, muted text, dot carries the status colour */
.e-badge { background: var(--e-surface-sunken); color: var(--e-ink-muted); }
.e-badge::before { background: var(--e-ink-faint); }
.e-badge-success::before { background: var(--e-success); }
.e-badge-info::before    { background: var(--e-info); }
.e-badge-warning::before { background: var(--e-warning); }
.e-badge-danger::before  { background: var(--e-danger); }

/* ---------- Cards ---------- */
.e-card { background: var(--e-surface); border: 1px solid var(--e-line); border-radius: var(--e-radius); box-shadow: var(--e-shadow); padding: var(--e-space-4); }
.e-card-flush { padding: 0; overflow: hidden; }
.e-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--e-space-3); padding: var(--e-space-3) var(--e-space-4); border-bottom: 1px solid var(--e-line-soft); }
.e-card-link { display: block; color: inherit; text-decoration: none; transition: box-shadow var(--e-motion), border-color var(--e-motion), transform var(--e-motion); }
.e-card-link:hover { box-shadow: var(--e-shadow-raised); border-color: var(--e-line-strong); color: inherit; }

/* ---------- Stat tile ---------- */
.e-stat { display: grid; grid-template-columns: minmax(0,1fr) 40px; gap: 4px 12px; align-items: start; }
.e-stat-label { grid-column: 1; font-size: var(--e-font-size-sm); font-weight: 600; color: var(--e-ink-muted); }
.e-stat-icon { grid-column: 2; grid-row: 1 / span 3; width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--e-ink); }
.e-stat-icon-yellow { background: var(--e-brand-yellow-tint); } .e-stat-icon-orange { background: var(--e-brand-orange-tint); }
.e-stat-icon-magenta { background: var(--e-brand-magenta-tint); } .e-stat-icon-teal { background: var(--e-brand-teal-tint); } .e-stat-icon-green { background: var(--e-brand-green-tint); }
.e-stat-value { grid-column: 1; font-size: var(--e-font-size-display); font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: var(--e-numeric); margin-top: 6px; }
.e-stat-value-word { font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.01em; margin-top: 10px; }
.e-stat-context { grid-column: 1; font-size: var(--e-font-size-xs); color: var(--e-ink-muted); margin-top: 6px; }
.e-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--e-space-3); }

/* ---------- Grade bars (CSS only) ---------- */
.e-bar { display: block; height: 8px; border-radius: var(--e-radius-pill); background: var(--e-surface-sunken); overflow: hidden; }
.e-bar > span { display: block; height: 100%; border-radius: inherit; transition: width var(--e-motion); }
.e-bar-outstanding > span { background: var(--e-grade-outstanding); } .e-bar-good > span { background: var(--e-grade-good); }
.e-bar-improve > span { background: var(--e-grade-improve); } .e-bar-inadequate > span { background: var(--e-grade-inadequate); } .e-bar-na > span { background: var(--e-grade-na); }
/* Row: label | bar | grade word + secondary figure */
.e-bar-row { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0,1fr) auto; gap: var(--e-space-3); align-items: center; min-height: 36px; }
.e-bar-row-label { font-size: var(--e-font-size-sm); font-weight: 600; }
.e-bar-row-value { display: flex; align-items: baseline; gap: 8px; font-size: var(--e-font-size-sm); font-weight: 700; white-space: nowrap; }
.e-bar-row-value small { font-weight: 400; color: var(--e-ink-muted); font-variant-numeric: var(--e-numeric); }
.e-bar-mini { grid-template-columns: 5.5rem minmax(0,1fr); min-height: 22px; gap: 10px; }
.e-bar-mini .e-bar { height: 6px; }
.e-bar-mini .e-bar-row-label { font-size: var(--e-font-size-xs); color: var(--e-ink-muted); }
/* Distribution: one stacked bar with a legend */
.e-dist { display: flex; height: 16px; border-radius: var(--e-radius-pill); overflow: hidden; background: var(--e-surface-sunken); }
.e-dist > span { display: block; height: 100%; }
.e-dist-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; font-size: var(--e-font-size-sm); }
.e-dist-legend > span { display: inline-flex; align-items: center; gap: 8px; }
.e-dist-legend i { width: 10px; height: 10px; border-radius: 50%; }
.e-dist-legend strong { font-variant-numeric: var(--e-numeric); }

/* ---------- Tables ---------- */
.e-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--e-surface); }
.e-table th { position: sticky; top: 0; z-index: 1; padding: 10px 16px; background: var(--e-surface-sunken); font-size: var(--e-font-size-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--e-ink-muted); text-align: left; white-space: nowrap; }
.e-table td { height: 56px; padding: 8px 16px; border-bottom: 1px solid var(--e-line-soft); font-size: var(--e-font-size-sm); vertical-align: middle; }
.e-table tr:last-child td { border-bottom: 0; }
.e-table .e-num { text-align: right; }
.e-table .e-sub { display: block; font-size: var(--e-font-size-xs); color: var(--e-ink-muted); margin-top: 2px; }
.e-table .e-primary-cell { font-weight: 700; }
.e-table tbody tr.e-row-link { cursor: pointer; transition: background var(--e-motion); }
.e-table tbody tr.e-row-link:hover td { background: var(--e-bg); }
.e-table tbody tr.e-row-link:focus-within td { background: var(--e-primary-soft); }
.e-table .e-row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.e-table th.e-sortable { cursor: pointer; } .e-table th.e-sortable .e-icon-sm { margin-left: 4px; vertical-align: -3px; }
.e-table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--e-line-soft); }
.e-table-toolbar .e-search { flex: 1 1 240px; }
.e-table-toolbar .e-count { margin-left: auto; font-size: var(--e-font-size-sm); color: var(--e-ink-muted); font-variant-numeric: var(--e-numeric); }
.e-table-wrap { overflow-x: auto; }

/* ---------- Banners and alerts ---------- */
.e-alert { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-radius: var(--e-radius-sm); border: 1px solid transparent; font-size: var(--e-font-size-sm); line-height: 1.45; background: var(--e-info-soft); color: var(--e-ink); }
.e-alert .e-icon { color: var(--e-info); margin-top: 1px; }
.e-alert-body { flex: 1; min-width: 0; }
.e-alert-body strong { font-weight: 700; }
.e-alert-action { flex-shrink: 0; align-self: center; }
.e-alert-success { background: var(--e-success-soft); } .e-alert-success .e-icon { color: var(--e-success); }
.e-alert-warning { background: var(--e-warning-soft); } .e-alert-warning .e-icon { color: var(--e-warning); }
.e-alert-danger  { background: var(--e-danger-soft); }  .e-alert-danger .e-icon  { color: var(--e-danger); }
.e-banner { border-radius: var(--e-radius); padding: 14px 16px 14px 20px; }

/* ---------- Forms ---------- */
.e-field { display: flex; flex-direction: column; gap: 6px; }
.e-field > label, .e-label { font-size: var(--e-font-size-sm); font-weight: 600; color: var(--e-ink); }
.e-hint { font-size: var(--e-font-size-xs); color: var(--e-ink-muted); }
.e-error { display: flex; align-items: center; gap: 6px; color: var(--e-danger); font-size: var(--e-font-size-xs); font-weight: 700; }
.e-input, .e-field input:not([type="checkbox"]):not([type="radio"]), .e-field select, .e-field textarea {
  width: 100%; min-height: var(--e-control-h); padding: 8px 12px; border: 1.5px solid var(--e-line); border-radius: var(--e-radius-sm);
  background: var(--e-surface); color: var(--e-ink); font-family: inherit; font-size: var(--e-font-size); line-height: 1.4;
  transition: border-color var(--e-motion), box-shadow var(--e-motion);
}
.e-input:hover, .e-field input:hover, .e-field select:hover, .e-field textarea:hover { border-color: var(--e-ink-faint); }
.e-input:focus, .e-field input:focus, .e-field select:focus, .e-field textarea:focus { outline: none; border-color: var(--e-primary); box-shadow: 0 0 0 3px var(--e-primary-soft); }
.e-field.is-invalid input, .e-field.is-invalid textarea, .e-input.is-invalid { border-color: var(--e-danger); }
.e-field input:disabled, .e-input:disabled { background: var(--e-surface-sunken); border-color: var(--e-line); color: var(--e-ink-faint); }
.e-field textarea { min-height: 88px; resize: vertical; }
.e-check { display: flex; gap: 12px; align-items: center; min-height: var(--e-touch-min); font-size: var(--e-font-size-sm); cursor: pointer; }
.e-check input { width: 22px; height: 22px; margin: 0; accent-color: var(--e-primary); }
/* Every single-choice dropdown gets the chevron, including plain selects inside .e-field
   (whose background reset above would otherwise wipe it). */
.e-select, .e-field select:not([multiple]) { padding-right: 36px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--e-ink-muted) 50%), linear-gradient(135deg, var(--e-ink-muted) 50%, transparent 50%); background-repeat: no-repeat; background-position: right 18px center, right 13px center; background-size: 5px 5px; }
.e-search { position: relative; } .e-search .e-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--e-ink-faint); } .e-search .e-input { padding-left: 40px; }
.e-code-input { min-height: var(--e-control-h-lg); text-align: center; font-size: 1.5rem; font-weight: 700; letter-spacing: .4em; font-variant-numeric: var(--e-numeric); }
/* Code box with a clear button inside it. Padded both sides so the digits stay centred;
   the button shows only when there is something to clear (the input carries placeholder=" "). */
.e-code-wrap { position: relative; }
.e-code-wrap .e-code-input { padding-inline: 52px; }
.e-code-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--e-radius-sm); background: transparent; color: var(--e-ink-faint); cursor: pointer; }
.e-code-clear:hover, .e-code-clear:focus-visible { color: var(--e-ink); background: var(--e-surface-sunken); }
.e-code-input:placeholder-shown + .e-code-clear { display: none; }

/* ---------- Tabs ---------- */
.e-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--e-line); }
.e-tab { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; color: var(--e-ink-muted); text-decoration: none; font-weight: 600; font-size: var(--e-font-size-sm); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--e-motion), background var(--e-motion); border-radius: var(--e-radius-sm) var(--e-radius-sm) 0 0; }
.e-tab:hover { color: var(--e-ink); background: var(--e-bg); }
.e-tab.active, .e-tab[aria-current="page"] { color: var(--e-ink); border-bottom-color: var(--e-accent); }

/* ---------- Empty state ---------- */
.e-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: var(--e-space-5) var(--e-space-4); text-align: center; background: var(--e-surface); border: 1px dashed var(--e-line); border-radius: var(--e-radius); }
.e-empty img { width: 160px; height: auto; margin-bottom: 4px; }
.e-empty h3 { font-size: var(--e-font-size-lg); font-weight: 700; }
.e-empty p { margin: 0; max-width: 36ch; font-size: var(--e-font-size-sm); color: var(--e-ink-muted); }

/* ---------- Toast, modal, menu ---------- */
.e-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--e-radius-sm); background: var(--e-ink); color: var(--e-primary-contrast); font-size: var(--e-font-size-sm); font-weight: 600; box-shadow: var(--e-shadow-raised); z-index: 60; }
.e-toast .e-icon { color: var(--e-brand-green); }
.e-modal { max-width: 440px; padding: var(--e-space-4); border-radius: var(--e-radius); background: var(--e-surface); box-shadow: var(--e-shadow-raised); display: flex; flex-direction: column; gap: 12px; }
.e-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.e-menu { min-width: 220px; padding: 6px; border: 1px solid var(--e-line); border-radius: var(--e-radius); background: var(--e-surface); box-shadow: var(--e-shadow-raised); }
.e-menu-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: var(--e-radius-sm); color: var(--e-ink); font-size: var(--e-font-size-sm); font-weight: 600; text-decoration: none; background: transparent; border: 0; width: 100%; cursor: pointer; }
.e-menu-item:hover { background: var(--e-bg); color: var(--e-ink); }
.e-menu-head { padding: 8px 10px 6px; display: flex; flex-direction: column; gap: 2px; }
.e-menu-divider { height: 1px; background: var(--e-line-soft); margin: 6px 0; }

/* ---------- Avatar, page header, brand bar ---------- */
.e-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--e-brand-teal-tint); color: var(--e-brand-1); display: inline-flex; align-items: center; justify-content: center; font-size: var(--e-font-size-xs); font-weight: 800; letter-spacing: .02em; flex-shrink: 0; }
.e-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--e-space-3); flex-wrap: wrap; }
.e-page-header-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.e-page-header p { margin: 0; font-size: var(--e-font-size-sm); color: var(--e-ink-muted); }
.e-page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.e-brand-bar { height: 4px; background: var(--e-brand-gradient); }
.e-breadcrumb { display: inline-flex; align-items: center; gap: 6px; font-size: var(--e-font-size-sm); font-weight: 600; color: var(--e-ink-muted); text-decoration: none; }
.e-breadcrumb:hover { color: var(--e-primary); }

/* Graded statement cards (handover pack v2): radio disc, grade badge, full text. Shared by
   the tablet (element, step and sections modes) and the portal template preview. */
.e-statements { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; max-width: 70ch; }
.e-statement { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px 14px; margin: 0; padding: 16px; border: 1.5px solid var(--e-line); border-radius: var(--e-radius); background: var(--e-surface); cursor: pointer; transition: border-color var(--e-motion), background var(--e-motion); }
.e-statement.is-selected { padding: 15px; border: 2.5px solid var(--e-primary); background: var(--e-primary-soft); }
.e-statement:focus-within { outline: 3px solid var(--e-focus-ring); outline-offset: 3px; }
.e-statement-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.e-statement-head { display: contents; }
.e-statement-check { grid-column: 1; grid-row: 1; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--e-ink-faint); background: var(--e-surface); display: inline-flex; align-items: center; justify-content: center; color: var(--e-primary-contrast); }
.e-statement-check .e-icon { width: 18px; height: 18px; }
.e-statement.is-selected .e-statement-check { border-color: var(--e-primary); background: var(--e-primary); }
.e-statement-tags { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 10px; min-height: 28px; }
.e-statement-chosen { font-size: var(--e-font-size-xs); font-weight: 700; color: var(--e-primary); }
.e-statement-body { grid-column: 2; font-size: var(--e-font-size); line-height: var(--e-line-height); color: var(--e-ink); }

/* ---------- Authenticator recovery codes ---------- */
.e-recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.e-recovery-codes code { display: block; padding: 8px 12px; border: 1px solid var(--e-line); border-radius: var(--e-radius-sm); background: var(--e-surface-sunken); font-size: var(--e-font-size-sm); letter-spacing: 0.04em; }

/* Present for copy buttons and screen readers, not on screen. */
.e-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
