/* H&V Factoring · Estructura: sidebar, header, contenido, portales */

.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--dur-3) var(--ease-out);
}
.app.is-collapsed { grid-template-columns: var(--side-w-collapsed) minmax(0, 1fr); }
.app.is-portal { grid-template-columns: minmax(0, 1fr); }
.app.is-portal .sidebar, .app.is-portal .sidebar-scrim { display: none; }

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  position: sticky; top: 0; z-index: var(--z-side);
  height: 100vh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(94, 122, 132, 0.18), transparent 60%),
    var(--c-side-bg);
  color: var(--c-side-text);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.side-brand {
  display: flex; align-items: center; gap: 12px;
  height: 84px; padding: 0 18px;
  flex: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.side-brand .mark {
  width: 36px; height: 36px; flex: none;
  border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.side-brand .mark img { width: 26px; height: 26px; }
/* Logotipo Dagda (versión para fondo oscuro) */
.side-brand .brand-logo { display: flex; align-items: center; width: 100%; height: 100%; padding: 6px 0; }
.side-brand .brand-logo img { height: 62px; width: auto; max-width: 100%; object-fit: contain; object-position: left center; }
.side-brand .brand-logo .logo-mark { display: none; height: auto; width: 38px; }
.app.is-collapsed .side-brand .brand-logo .logo-full { display: none; }
.app.is-collapsed .side-brand .brand-logo .logo-mark { display: block; }
.side-brand .wordmark { min-width: 0; line-height: 1.05; white-space: nowrap; }
.side-brand .wordmark b {
  display: block; font-family: var(--ff-display); font-weight: 600; font-size: 22px;
  color: var(--c-side-text-strong); letter-spacing: 0.01em;
}
.side-brand .wordmark span {
  display: block; margin-top: 3px;
  font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--c-side-text);
}

.side-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px 18px; }
.side-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); }

.side-section-label {
  padding: 14px 12px 6px; font-size: 10px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: rgba(169, 180, 184, 0.62);
  white-space: nowrap;
}

.nav-group { margin-bottom: 1px; }
.nav-group-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 9px; background: none;
  color: var(--c-side-text); font-size: 13.5px; font-weight: 500; text-align: left;
  white-space: nowrap;
  transition: background var(--dur-1) ease, color var(--dur-1) ease;
}
.nav-group-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--c-side-text-strong); }
.nav-group-btn .ico { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav-group-btn .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-group-btn .chev { width: 14px; height: 14px; flex: none; opacity: 0.5; transition: transform var(--dur-2) var(--ease-out); }
.nav-group.is-open > .nav-group-btn .chev { transform: rotate(90deg); }
.nav-group.has-active > .nav-group-btn { color: var(--c-side-text-strong); }
.nav-group.has-active > .nav-group-btn .ico { opacity: 1; color: var(--c-side-accent); }

.nav-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-3) var(--ease-out); }
.nav-group.is-open > .nav-items { grid-template-rows: 1fr; }
.nav-items > ul { overflow: hidden; list-style: none; position: relative; }
.nav-items > ul::before {
  content: ""; position: absolute; left: 19px; top: 4px; bottom: 6px; width: 1px;
  background: rgba(255, 255, 255, 0.08);
}
.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 38px; margin: 1px 0;
  border-radius: 7px;
  font-size: 13px; color: var(--c-side-text);
  white-space: nowrap;
  transition: background var(--dur-1) ease, color var(--dur-1) ease;
}
.nav-link span:first-child { overflow: hidden; text-overflow: ellipsis; }
.nav-link:hover { color: var(--c-side-text-strong); background: rgba(255, 255, 255, 0.04); }
.nav-link.is-active { color: var(--c-side-text-strong); background: rgba(141, 183, 196, 0.12); }
.nav-link.is-active::before {
  content: ""; position: absolute; left: 17px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px;
  border-radius: 50%; background: var(--c-side-accent); box-shadow: 0 0 0 3px rgba(141, 183, 196, 0.18);
}
.nav-link .plan {
  margin-left: auto; flex: none;
  font-size: 9.5px; letter-spacing: 0.06em; color: rgba(169, 180, 184, 0.55);
  border: 1px solid rgba(169, 180, 184, 0.18); border-radius: 4px; padding: 0 4px; line-height: 15px;
}

.nav-single { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.nav-single:hover { background: rgba(255, 255, 255, 0.05); color: var(--c-side-text-strong); }
.nav-single.is-active { background: rgba(141, 183, 196, 0.12); color: var(--c-side-text-strong); }
.nav-single .ico { width: 18px; height: 18px; flex: none; }

.side-foot {
  flex: none; padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; flex-direction: column; gap: 4px;
}
.side-foot .collapse-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px; background: none; color: var(--c-side-text);
  font-size: 12.5px; white-space: nowrap;
}
.side-foot .collapse-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--c-side-text-strong); }
.side-foot .collapse-btn .ico { width: 18px; height: 18px; flex: none; transition: transform var(--dur-3) var(--ease-out); }

/* Sidebar colapsado */
.app.is-collapsed .side-brand .wordmark,
.app.is-collapsed .nav-group-btn .txt,
.app.is-collapsed .nav-group-btn .chev,
.app.is-collapsed .nav-items,
.app.is-collapsed .side-section-label,
.app.is-collapsed .nav-single .txt,
.app.is-collapsed .side-foot .txt { display: none; }
.app.is-collapsed .side-brand { padding: 0 18px; }
.app.is-collapsed .nav-group-btn, .app.is-collapsed .nav-single, .app.is-collapsed .side-foot .collapse-btn { justify-content: center; padding: 10px 0; }
.app.is-collapsed .side-foot .collapse-btn .ico { transform: rotate(180deg); }

.sidebar-scrim { display: none; }

/* ── Columna principal ─────────────────────────────────── */
.main-col { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-header);
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--c-bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--c-line);
}
.topbar .menu-btn { display: none; }
.topbar .crumbs { min-width: 120px; flex: 1; }
.topbar .tools { display: flex; align-items: center; gap: 8px; }

.crumbs ol { display: flex; align-items: center; gap: 6px; list-style: none; font-size: 13px; color: var(--c-text-3); white-space: nowrap; overflow: hidden; }
.crumbs li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--c-line-strong); }
.crumbs a:hover { color: var(--c-text); text-decoration: underline; text-underline-offset: 3px; }
.crumbs li:last-child { color: var(--c-text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.search-trigger {
  display: flex; align-items: center; gap: 10px;
  width: 300px; height: 38px; padding: 0 10px 0 12px;
  border: 1px solid var(--c-line); border-radius: var(--r-md);
  background: var(--c-panel); color: var(--c-text-3); font-size: 13px;
  transition: border-color var(--dur-1) ease, box-shadow var(--dur-1) ease;
}
.search-trigger:hover { border-color: var(--c-line-strong); box-shadow: var(--sh-1); }
.search-trigger .ico { width: 16px; height: 16px; }
.search-trigger .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-trigger kbd { white-space: nowrap; }
.search-trigger kbd { margin-left: auto; }

.demo-flag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--c-warn-soft); color: var(--c-warn);
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--c-warn) 25%, transparent);
}
.demo-flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse-dot 2.4s ease-in-out infinite; }

.content {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: 26px 28px 56px;
  flex: 1;
}
.content:focus { outline: none; }

.app-foot {
  max-width: var(--content-max); width: 100%; margin: 0 auto; padding: 18px 28px 28px;
  display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between;
  color: var(--c-text-3); font-size: 12px; border-top: 1px solid var(--c-line);
}

/* ── Cabecera de página ───────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.page-title { font-family: var(--ff-display); font-weight: 600; font-size: var(--t-3xl); line-height: 1.05; letter-spacing: -0.005em; }
.page-sub { margin-top: 6px; color: var(--c-text-2); font-size: 14px; max-width: 760px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 12px; }
.section-title h2 { font-family: var(--ff-display); font-weight: 600; font-size: 22px; }

/* ── Grillas ──────────────────────────────────────────── */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.grid + .grid { margin-top: 16px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; } .span-12 { grid-column: span 12; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ── Portales (cliente / pagador) ─────────────────────── */
.portal-shell { max-width: 1240px; margin: 0 auto; }
.portal-hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl); padding: 28px 30px;
  background:
    radial-gradient(90% 140% at 100% 0%, rgba(141, 183, 196, 0.22), transparent 55%),
    linear-gradient(135deg, #111B1E, #26343A);
  color: #fff;
  box-shadow: var(--sh-2);
}
.portal-hero .label { color: rgba(255, 255, 255, 0.62); }
.portal-hero h1 { font-family: var(--ff-display); font-weight: 600; font-size: 32px; margin-top: 6px; }
.portal-hero p { color: rgba(255, 255, 255, 0.72); margin-top: 6px; max-width: 640px; }
.portal-tabs { display: flex; gap: 4px; margin: 18px 0 20px; overflow-x: auto; overflow-y: hidden; }
.portal-hero .portal-logo { position: absolute; right: 28px; top: 22px; height: 74px; width: auto; opacity: 0.95; }
@media (max-width: 760px) { .portal-hero .portal-logo { position: static; height: 52px; margin-bottom: 12px; } }
