/* Fixentra AI — shared design system (TASD-UX-001-R1).
   Built on the approved brand tokens in assets/brand/fixentra-theme.css (loaded first). Supporting
   neutrals and state colors were chosen for WCAG 2.2 AA text contrast on white (≥ 4.5:1).
   Loaded by every page before its own stylesheet (portal.css, agent.css, signin.css). */
:root {
  /* brand */
  --fx-navy: var(--fixentra-midnight-navy, #0B1F4B);
  --fx-blue: var(--fixentra-blue, #2563FF);
  --fx-cyan: var(--fixentra-ai-cyan, #06D6FF);
  --fx-teal: var(--fixentra-service-teal, #14B8A6);
  --fx-violet: var(--fixentra-intelligence-violet, #8B5CF6);
  --fx-cloud: var(--fixentra-cloud-gray, #E5EAF5);
  --fx-gradient: var(--fixentra-brand-gradient, linear-gradient(110deg, #06D6FF 0%, #2563FF 62%, #8B5CF6 100%));
  /* neutrals */
  --fx-text: #0B1F4B;            /* 15.6:1 on white */
  --fx-text-2: #44546f;          /* 7.5:1 */
  --fx-text-3: #5a6a85;          /* 5.6:1 */
  --fx-bg: #f4f6fb;
  --fx-surface: #ffffff;
  --fx-surface-2: #f8faff;
  --fx-surface-3: #eef2fa;
  --fx-border: #d9dfec;
  --fx-border-strong: #b6c0d6;
  /* actions and states */
  --fx-primary: #2563FF;         /* white text 4.9:1 */
  --fx-primary-hover: #1d4fd8;
  --fx-primary-soft: #eaf0ff;
  --fx-link: #1f55e0;
  --fx-success: #0b7a6d;  --fx-success-bg: #e3f7f4;  --fx-success-border: #9fe0d6;
  --fx-warning: #9a4b00;  --fx-warning-bg: #fff3e0;  --fx-warning-border: #f7c98c;
  --fx-danger: #c42b2f;   --fx-danger-bg: #fdecee;   --fx-danger-border: #f6b8bf;
  --fx-info: #1f55e0;     --fx-info-bg: #eaf0ff;     --fx-info-border: #bccdfd;
  --fx-ai: #6d3fe0;       --fx-ai-bg: #f4f0ff;       --fx-ai-border: #d8cafd;   /* violet text 6.3:1 */
  --fx-neutral: #4a5872;  --fx-neutral-bg: #eef1f6;  --fx-neutral-border: #d3d9e5;
  --fx-focus: #2563FF;
  /* type */
  --fx-font: var(--fixentra-font, "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --fx-fs-xs: 12px; --fx-fs-sm: 13px; --fx-fs-md: 14px; --fx-fs-lg: 16px; --fx-fs-xl: 18px; --fx-fs-2xl: 22px; --fx-fs-3xl: 28px;
  /* spacing, radius, elevation */
  --fx-s1: 4px; --fx-s2: 8px; --fx-s3: 12px; --fx-s4: 16px; --fx-s5: 20px; --fx-s6: 24px; --fx-s8: 32px; --fx-s10: 40px;
  --fx-r-sm: 6px; --fx-r-md: 8px; --fx-r-lg: 12px; --fx-r-pill: 999px;
  --fx-shadow-sm: 0 1px 2px rgba(11, 31, 75, 0.06);
  --fx-shadow-md: 0 1px 3px rgba(11, 31, 75, 0.06), 0 6px 16px rgba(11, 31, 75, 0.08);
  --fx-shadow-lg: 0 12px 40px rgba(11, 31, 75, 0.22);
  --fx-ease: 160ms ease;
}

/* ---------- accessibility foundations ---------- */
:focus-visible { outline: 2px solid var(--fx-focus); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
.fx-skip {
  position: absolute; left: 12px; top: -60px; z-index: 1000; padding: 10px 16px; border-radius: var(--fx-r-md);
  background: var(--fx-navy); color: #fff !important; font-weight: 600; text-decoration: none; box-shadow: var(--fx-shadow-md);
}
.fx-skip:focus { top: 12px; }
.sr-only, .fx-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- buttons ---------- */
.fx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--fx-border-strong); border-radius: var(--fx-r-md); background: var(--fx-surface);
  color: var(--fx-text); font: 600 var(--fx-fs-md)/1 var(--fx-font); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--fx-ease), border-color var(--fx-ease), box-shadow var(--fx-ease);
}
.fx-btn:hover { background: var(--fx-surface-2); border-color: var(--fx-text-3); color: var(--fx-text); }
.fx-btn svg { width: 16px; height: 16px; flex: none; }
.fx-btn-primary { background: var(--fx-primary); border-color: var(--fx-primary); color: #fff; }
.fx-btn-primary:hover { background: var(--fx-primary-hover); border-color: var(--fx-primary-hover); color: #fff; }
.fx-btn-danger { background: var(--fx-surface); border-color: var(--fx-danger-border); color: var(--fx-danger); }
.fx-btn-danger:hover { background: var(--fx-danger-bg); border-color: var(--fx-danger); color: var(--fx-danger); }
.fx-btn-danger.solid { background: var(--fx-danger); border-color: var(--fx-danger); color: #fff; }
.fx-btn-ai { background: var(--fx-ai-bg); border-color: var(--fx-ai-border); color: var(--fx-ai); }
.fx-btn-ai:hover { background: #ebe3ff; border-color: var(--fx-violet); color: var(--fx-ai); }
.fx-btn-ghost { background: transparent; border-color: transparent; }
.fx-btn-ghost:hover { background: var(--fx-surface-3); border-color: transparent; }
.fx-btn-sm { height: 30px; padding: 0 10px; font-size: var(--fx-fs-sm); }
.fx-btn-icon { width: 36px; padding: 0; }
.fx-btn:disabled, .fx-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.fx-link { border: 0; background: none; padding: 0; color: var(--fx-link); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.fx-link:hover { text-decoration: underline; }

/* ---------- form controls ---------- */
.fx-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--fx-s4); }
.fx-label { font-size: var(--fx-fs-sm); font-weight: 600; color: var(--fx-text); }
.fx-hint { font-size: var(--fx-fs-xs); color: var(--fx-text-3); }
.fx-input, .fx-select, .fx-textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--fx-border-strong); border-radius: var(--fx-r-md);
  background: var(--fx-surface); color: var(--fx-text); font: 400 var(--fx-fs-md)/1.4 var(--fx-font);
  transition: border-color var(--fx-ease), box-shadow var(--fx-ease);
}
.fx-textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.fx-input:hover, .fx-select:hover, .fx-textarea:hover { border-color: var(--fx-text-3); }
.fx-input:focus, .fx-select:focus, .fx-textarea:focus { border-color: var(--fx-primary); box-shadow: 0 0 0 3px rgba(37, 99, 255, 0.18); outline: none; }
.fx-input:disabled, .fx-select:disabled, .fx-textarea:disabled { background: var(--fx-surface-3); color: var(--fx-text-3); cursor: not-allowed; }
.fx-input[aria-invalid="true"] { border-color: var(--fx-danger); }
.fx-search { position: relative; display: flex; align-items: center; }
.fx-search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--fx-text-3); pointer-events: none; }
.fx-search .fx-input { padding-left: 34px; }
.fx-check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fx-fs-md); cursor: pointer; }
.fx-check input { width: 16px; height: 16px; accent-color: var(--fx-primary); }

/* ---------- cards, page headers ---------- */
.fx-card { background: var(--fx-surface); border: 1px solid var(--fx-border); border-radius: var(--fx-r-lg); box-shadow: var(--fx-shadow-sm); }
.fx-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--fx-s3); padding: var(--fx-s4) var(--fx-s5); border-bottom: 1px solid var(--fx-border); }
.fx-card-head h2, .fx-card-head h3 { margin: 0; font-size: var(--fx-fs-lg); font-weight: 600; }
.fx-card-body { padding: var(--fx-s4) var(--fx-s5); }
.fx-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--fx-s4); flex-wrap: wrap; margin-bottom: var(--fx-s5); }
.fx-page-head h1, .fx-page-head h2 { margin: 0; font-size: var(--fx-fs-2xl); line-height: 1.25; font-weight: 700; letter-spacing: -0.2px; }
.fx-page-head p { margin: 4px 0 0; color: var(--fx-text-2); }
.fx-breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; padding: 0; font-size: var(--fx-fs-sm); color: var(--fx-text-3); }
.fx-breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--fx-border-strong); }
.fx-breadcrumbs a { color: var(--fx-text-2); }
.fx-breadcrumbs [aria-current] { color: var(--fx-text); font-weight: 500; }

/* ---------- tables ---------- */
.fx-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--fx-border); border-radius: var(--fx-r-lg); background: var(--fx-surface); }
.fx-table { width: 100%; border-collapse: collapse; font-size: var(--fx-fs-md); }
.fx-table th, .fx-table td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--fx-border); }
.fx-table thead th { position: sticky; top: 0; background: var(--fx-surface-2); color: var(--fx-text-2); font-size: var(--fx-fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
.fx-table tbody tr:last-child td { border-bottom: 0; }
.fx-table tbody tr:hover { background: var(--fx-surface-2); }
.fx-sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.fx-sort::after { content: "↕"; font-size: 11px; opacity: 0.5; }
th[aria-sort="ascending"] .fx-sort::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .fx-sort::after { content: "↓"; opacity: 1; }

/* ---------- status indicators ---------- */
.pill, .fx-badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--fx-r-pill);
  border: 1px solid transparent; font-size: var(--fx-fs-xs); font-weight: 600; line-height: 1; white-space: nowrap; text-transform: none;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-open, .pill-medium, .fx-badge-info { background: var(--fx-info-bg); color: var(--fx-info); border-color: var(--fx-info-border); }
.pill-pending, .pill-high, .fx-badge-warning { background: var(--fx-warning-bg); color: var(--fx-warning); border-color: var(--fx-warning-border); }
.pill-resolved, .fx-badge-success { background: var(--fx-success-bg); color: var(--fx-success); border-color: var(--fx-success-border); }
.pill-closed, .pill-low, .fx-badge-neutral { background: var(--fx-neutral-bg); color: var(--fx-neutral); border-color: var(--fx-neutral-border); }
.pill-urgent, .fx-badge-danger { background: var(--fx-danger-bg); color: var(--fx-danger); border-color: var(--fx-danger-border); }
.fx-badge-ai { background: var(--fx-ai-bg); color: var(--fx-ai); border-color: var(--fx-ai-border); }
.fx-id { font: 600 var(--fx-fs-sm)/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--fx-text-2); white-space: nowrap; }

/* ---------- loading, empty, error, feedback ---------- */
.fx-loading { display: flex; align-items: center; gap: 10px; padding: var(--fx-s6); color: var(--fx-text-2); }
.fx-spinner { width: 18px; height: 18px; border: 2px solid var(--fx-cloud); border-top-color: var(--fx-blue); border-radius: 50%; animation: fx-spin 0.8s linear infinite; flex: none; }
@keyframes fx-spin { to { transform: rotate(360deg); } }
.fx-skeleton { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--fx-surface-3), #f7f9fd, var(--fx-surface-3)); background-size: 200% 100%; animation: fx-shimmer 1.2s ease infinite; }
@keyframes fx-shimmer { to { background-position: -200% 0; } }
.fx-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: var(--fx-s8) var(--fx-s4); color: var(--fx-text-2); }
.fx-empty-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--fx-surface-3); display: grid; place-items: center; color: var(--fx-text-3); }
.fx-empty-icon svg { width: 20px; height: 20px; }
.fx-empty strong { color: var(--fx-text); font-size: var(--fx-fs-md); }
.fx-empty p { margin: 0; max-width: 420px; font-size: var(--fx-fs-sm); }
.fx-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid; border-radius: var(--fx-r-md); font-size: var(--fx-fs-md); }
.fx-alert-error { background: var(--fx-danger-bg); border-color: var(--fx-danger-border); color: #8f1d21; }
.fx-alert-warning { background: var(--fx-warning-bg); border-color: var(--fx-warning-border); color: #7a3b00; }
.fx-alert-success { background: var(--fx-success-bg); border-color: var(--fx-success-border); color: #075e54; }
.fx-alert-info { background: var(--fx-info-bg); border-color: var(--fx-info-border); color: #173f9e; }
.fx-alert-ai { background: var(--fx-ai-bg); border-color: var(--fx-ai-border); color: #4c2aa8; }
.fx-alert:empty { display: none; }
.fx-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 900; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.fx-toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--fx-r-md); background: var(--fx-navy); color: #fff; box-shadow: var(--fx-shadow-lg); font-size: var(--fx-fs-md); animation: fx-in 180ms ease; }
.fx-toast.error { background: #8f1d21; }
.fx-toast button { margin-left: auto; border: 0; background: none; color: #fff; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
@keyframes fx-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- dialogs ---------- */
dialog.fx-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: var(--fx-r-lg); box-shadow: var(--fx-shadow-lg); color: var(--fx-text); font-family: var(--fx-font); }
dialog.fx-dialog::backdrop { background: rgba(11, 31, 75, 0.45); }
.fx-dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.fx-dialog-head { padding: 18px 20px 0; }
.fx-dialog-head h2 { margin: 0; font-size: var(--fx-fs-xl); font-weight: 700; }
.fx-dialog-body { padding: 12px 20px 4px; overflow: auto; color: var(--fx-text-2); }
.fx-dialog-body p { margin: 0 0 10px; }
.fx-dialog-body ul { margin: 0 0 10px; padding-left: 18px; color: var(--fx-text); }
.fx-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; flex-wrap: wrap; }
@media (max-width: 480px) { .fx-dialog-foot .fx-btn { flex: 1; } }

/* ---------- dropdown menus ---------- */
.fx-menu-wrap { position: relative; }
.fx-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 300; min-width: 240px; max-width: min(360px, calc(100vw - 24px));
  padding: 6px; background: var(--fx-surface); border: 1px solid var(--fx-border); border-radius: var(--fx-r-md); box-shadow: var(--fx-shadow-lg);
}
.fx-menu[hidden] { display: none; }
.fx-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--fx-border); margin-bottom: 6px; }
.fx-menu-head strong { display: block; font-size: var(--fx-fs-md); }
.fx-menu-head span { display: block; font-size: var(--fx-fs-xs); color: var(--fx-text-3); overflow: hidden; text-overflow: ellipsis; }
.fx-menu a, .fx-menu button.fx-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--fx-r-sm);
  background: none; color: var(--fx-text); font: 500 var(--fx-fs-md)/1.3 var(--fx-font); text-align: left; cursor: pointer; text-decoration: none;
}
.fx-menu a:hover, .fx-menu button.fx-menu-item:hover, .fx-menu a:focus-visible, .fx-menu button.fx-menu-item:focus-visible { background: var(--fx-surface-3); outline-offset: -2px; }
.fx-menu svg { width: 16px; height: 16px; color: var(--fx-text-3); flex: none; }
.fx-menu hr { border: 0; border-top: 1px solid var(--fx-border); margin: 6px 0; }

/* ---------- tabs ---------- */
.fx-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--fx-border); overflow-x: auto; scrollbar-width: thin; }
.fx-tab {
  position: relative; flex: none; padding: 10px 14px; border: 0; background: none; color: var(--fx-text-2);
  font: 600 var(--fx-fs-md)/1.2 var(--fx-font); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.fx-tab:hover { color: var(--fx-text); }
.fx-tab[aria-selected="true"], .fx-tab[aria-pressed="true"], .fx-tab.on { color: var(--fx-primary); }
.fx-tab[aria-selected="true"]::after, .fx-tab[aria-pressed="true"]::after, .fx-tab.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--fx-primary); }
.fx-tab .fx-count { margin-left: 6px; padding: 1px 7px; border-radius: var(--fx-r-pill); background: var(--fx-surface-3); color: var(--fx-text-2); font-size: 11px; }
.fx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-chip {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--fx-border); border-radius: var(--fx-r-pill);
  background: var(--fx-surface); color: var(--fx-text-2); font: 500 var(--fx-fs-sm)/1 var(--fx-font); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.fx-chip:hover { border-color: var(--fx-border-strong); color: var(--fx-text); }
.fx-chip[aria-pressed="true"], .fx-chip[aria-current="true"] { background: var(--fx-navy); border-color: var(--fx-navy); color: #fff; }

/* ---------- metric tiles and charts ---------- */
.fx-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--fx-s3); }
.fx-kpi {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--fx-border);
  border-radius: var(--fx-r-lg); background: var(--fx-surface); color: var(--fx-text); text-decoration: none; box-shadow: var(--fx-shadow-sm);
  transition: border-color var(--fx-ease), box-shadow var(--fx-ease), transform var(--fx-ease);
}
a.fx-kpi:hover { border-color: var(--fx-blue); box-shadow: var(--fx-shadow-md); color: var(--fx-text); }
.fx-kpi-label { font-size: var(--fx-fs-sm); color: var(--fx-text-2); font-weight: 500; }
.fx-kpi-value { font-size: var(--fx-fs-3xl); font-weight: 700; line-height: 1.1; letter-spacing: -0.5px; }
.fx-kpi-note { font-size: var(--fx-fs-xs); color: var(--fx-text-3); }
.fx-kpi::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--fx-kpi-accent, var(--fx-blue)); }
.fx-kpi.danger { --fx-kpi-accent: var(--fx-danger); }
.fx-kpi.danger .fx-kpi-value { color: var(--fx-danger); }
.fx-kpi.warning { --fx-kpi-accent: #e28a00; }
.fx-kpi.teal { --fx-kpi-accent: var(--fx-teal); }
.fx-kpi.violet { --fx-kpi-accent: var(--fx-violet); }
.fx-kpi.neutral { --fx-kpi-accent: var(--fx-border-strong); }
.fx-bars { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.fx-bar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 36px; align-items: center; gap: 10px; font-size: var(--fx-fs-sm); }
.fx-bar > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fx-text); }
.fx-bar-track { height: 10px; border-radius: 5px; background: var(--fx-surface-3); overflow: hidden; }
.fx-bar-fill { display: block; height: 100%; border-radius: 5px; background: var(--fx-bar, var(--fx-blue)); min-width: 3px; }
.fx-bar > :last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
a.fx-bar { text-decoration: none; color: inherit; border-radius: var(--fx-r-sm); }
a.fx-bar:hover > :first-child { color: var(--fx-link); text-decoration: underline; }
.fx-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fx-fs-xs); color: var(--fx-text-2); }
.fx-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.fx-chart { width: 100%; height: auto; display: block; }
.fx-chart text { font: 500 10px var(--fx-font); fill: var(--fx-text-3); }
