:root {
  --epri-navy: #0b1f35;
  --epri-navy-2: #123455;
  --epri-blue: #1768b5;
  --epri-blue-dark: #0f4f8d;
  --epri-sky: #eaf4ff;
  --epri-green: #0f8a5f;
  --epri-green-dark: #087049;
  --epri-red: #b42318;
  --epri-ink: #14263a;
  --epri-muted: #587087;
  --epri-line: #cddbe8;
  --epri-paper: #ffffff;
  --epri-canvas: #f3f7fb;
  --epri-radius: 12px;
  --epri-shadow: 0 10px 28px rgba(11, 31, 53, .09);
  --epri-font: "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --epri-mono: "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

html { scroll-behavior: smooth; }
body.epri-ui { font-family: var(--epri-font); color: var(--epri-ink); background: var(--epri-canvas); }
body.epri-ui *, body.epri-ui *::before, body.epri-ui *::after { box-sizing: border-box; }
body.epri-ui :where(button, input, select, textarea, a) { font: inherit; }
body.epri-ui :where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid rgba(23, 104, 181, .38) !important;
  outline-offset: 2px;
}
body.epri-ui :where(button, [role="button"], select) { min-height: 44px; }
body.epri-ui button { cursor: pointer; }
body.epri-ui button:disabled { cursor: not-allowed; opacity: .58; }

.epri-skip-link {
  position: fixed; z-index: 100000; top: 8px; left: 12px; transform: translateY(-160%);
  padding: 10px 16px; border-radius: 8px; background: var(--epri-navy); color: #fff;
  font-weight: 700; text-decoration: none;
}
.epri-skip-link:focus { transform: translateY(0); }
.epri-visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
  margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}

.epri-suite-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px;
  padding: 9px 14px; border: 1px solid rgba(255,255,255,.32); border-radius: 9px;
  color: #fff; background: rgba(255,255,255,.08); font-weight: 700; text-decoration: none;
  white-space: nowrap;
}
.epri-suite-link:hover { background: rgba(255,255,255,.16); }
.epri-native-nav {
  position: fixed; z-index: 9998; top: 14px; right: 16px; display: flex; gap: 8px; padding: 6px;
  border: 1px solid var(--epri-line); border-radius: 11px; background: rgba(255,255,255,.96);
  box-shadow: var(--epri-shadow); backdrop-filter: blur(8px);
}
.epri-native-nav a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 12px;
  border-radius: 8px; color: var(--epri-navy); font-weight: 750; text-decoration: none;
}
.epri-native-nav a:last-child { color: #fff; background: var(--epri-blue); }
.epri-native-nav a:hover { background: var(--epri-sky); }
.epri-native-nav a:last-child:hover { background: var(--epri-blue-dark); }

body.epri-ui :where(.appbar, .topbar) {
  background: linear-gradient(115deg, var(--epri-navy), var(--epri-navy-2));
  border-bottom: 3px solid var(--epri-blue);
}
body.epri-ui :where(.appbar, .topbar) :where(.file-actions, .top-actions) { gap: 8px; }
body.epri-ui :where(.appbar, .topbar) button {
  border-radius: 8px; border: 1px solid rgba(255,255,255,.26); font-weight: 700;
}
body.epri-ui :where(.appbar, .topbar) button[data-action="demo"],
body.epri-ui button.demo, body.epri-ui button.demo-inline {
  color: #fff !important; background: var(--epri-green) !important; border-color: var(--epri-green) !important;
}
body.epri-ui :where(.appbar, .topbar) button[data-action="demo"]:hover,
body.epri-ui button.demo:hover, body.epri-ui button.demo-inline:hover { background: var(--epri-green-dark) !important; }
body.epri-ui button.calculate, body.epri-ui button.primary {
  color: #fff !important; background: var(--epri-blue) !important; border-color: var(--epri-blue) !important;
  font-weight: 750;
}
body.epri-ui button.calculate:hover, body.epri-ui button.primary:hover { background: var(--epri-blue-dark) !important; }
body.epri-ui button.danger { color: var(--epri-red); border-color: #f1aaa3; background: #fff7f6; }

body.epri-ui :where(.card, .inputs-card, .model-card, .results-card, .chart-card, .report-card) {
  border-color: var(--epri-line); border-radius: var(--epri-radius); box-shadow: var(--epri-shadow);
}
body.epri-ui :where(.heading, .title-strip) { border-radius: var(--epri-radius); }
body.epri-ui :where(.heading, .title-strip) h1 { color: var(--epri-navy); letter-spacing: -.02em; }
body.epri-ui :where(.heading, .title-strip) > b,
body.epri-ui .web-badge { background: var(--epri-sky); color: var(--epri-blue-dark); border-color: #afd4f5; }

body.epri-ui :where(label, .select-label) { color: var(--epri-ink); font-weight: 650; }
body.epri-ui :where(input:not([type="file"]), select, textarea) {
  min-height: 44px; border: 1px solid #aebfd0; border-radius: 8px; background: #fff; color: var(--epri-ink);
}
body.epri-ui :where(input:not([type="file"]), select, textarea):hover { border-color: #7896b2; }
body.epri-ui :where(input:not([type="file"]), select, textarea)[aria-invalid="true"] {
  border-color: var(--epri-red); box-shadow: 0 0 0 3px rgba(180,35,24,.12);
}
body.epri-ui .epri-field-error { display: block; margin-top: 4px; color: var(--epri-red); font-size: .82rem; font-weight: 650; }

body.epri-ui :where(.table-scroll, .table-wrap) { overflow: auto; border-radius: 9px; }
body.epri-ui table { width: 100%; border-collapse: collapse; }
body.epri-ui th { position: sticky; top: 0; z-index: 1; background: #e9f1f8; color: var(--epri-navy); }
body.epri-ui th, body.epri-ui td { border-color: var(--epri-line); }
body.epri-ui td { font-variant-numeric: tabular-nums; }
body.epri-ui :where(#status, #rowCount, #objectCount) { color: var(--epri-muted); font-weight: 700; }

body.epri-ui dialog { max-width: min(1120px, calc(100vw - 32px)); max-height: 92dvh; border-radius: 14px; border-color: var(--epri-line); }
body.epri-ui dialog::backdrop { background: rgba(5, 18, 32, .68); backdrop-filter: blur(3px); }
body.epri-ui :where(.dialog-head, dialog > header) { position: sticky; top: 0; z-index: 3; background: #fff; }
body.epri-ui .help-dialog iframe, body.epri-ui #helpDialog iframe { min-height: min(68dvh, 760px); background: #fff; }
body.epri-ui .help-note { border-left: 4px solid var(--epri-blue); background: var(--epri-sky); color: var(--epri-muted); padding: 10px 14px; }

/* Portada React: se decora con atributos estables añadidos por epri-ui-system.js. */
body.epri-ui [data-epri-card] {
  border: 1px solid var(--epri-line) !important; border-radius: var(--epri-radius) !important;
  background: var(--epri-paper) !important; box-shadow: 0 5px 18px rgba(11,31,53,.06) !important;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
body.epri-ui [data-epri-card]:hover { transform: translateY(-2px); border-color: #8cb9df !important; box-shadow: var(--epri-shadow) !important; }
body.epri-ui [data-epri-card] h4 { color: var(--epri-navy); }
body.epri-ui [data-epri-card] a { min-height: 44px; }

@media (max-width: 900px) {
  body.epri-ui :where(.appbar, .topbar) { align-items: flex-start; gap: 10px; }
  body.epri-ui :where(.file-actions, .top-actions) { flex-wrap: wrap; }
  .epri-suite-link { width: auto; }
  body.epri-ui dialog { max-width: calc(100vw - 20px); }
}
@media (max-width: 640px) {
  html { scroll-behavior: auto; }
  body.epri-ui { overflow-x: hidden; }
  body.epri-ui :where(.appbar, .topbar) { padding: 12px; }
  body.epri-ui :where(.file-actions, .top-actions) { width: 100%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  body.epri-ui :where(.file-actions, .top-actions) > * { width: 100%; }
  body.epri-ui :where(input:not([type="file"]), select, textarea) { font-size: 16px; }
  body.epri-ui :where(.heading, .title-strip) { padding: 16px; }
  body.epri-ui :where(.heading, .title-strip) h1 { font-size: clamp(1.35rem, 7vw, 1.8rem); }
  body.epri-ui dialog { margin: auto; padding: 0; max-height: 94dvh; }
  .epri-native-nav { position: sticky; top: 0; right: auto; width: 100%; justify-content: stretch; border-radius: 0; }
  .epri-native-nav a { flex: 1; }
  body.epri-ui .help-dialog iframe, body.epri-ui #helpDialog iframe { min-height: 72dvh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
