/* =============================================================================
   CMS portal design tokens — one shell background + glass header + button scale

   Buttons (use these only; avoid one-off blue Tailwind on portal pages):
   - .cms-btn-primary     main actions (gradient indigo → violet)
   - .cms-btn-secondary   neutral / second row actions
   - .cms-btn-ghost       low-emphasis
   - .cms-btn-danger      destructive
   Modifiers: .cms-btn--sm  .cms-btn--block
   .cms-btn-nav — compact Home / Back / secondary header links (matches secondary sm)
   .cms-tabs-list + button.cms-tab — portal tab bars (Flowbite-compatible)
   Legacy alias: .btn-cms-primary == .cms-btn-primary
   ============================================================================= */
:root {
  --cms-link: #4f46e5;
  --cms-link-hover: #4338ca;
  --cms-shell-base: #eef2ff;
  --cms-header-bg: rgba(255, 255, 255, 0.52);
  --cms-header-border: rgba(148, 163, 184, 0.35);
  --cms-btn-radius: 0.625rem;
  --cms-btn-primary-from: #4f46e5;
  --cms-btn-primary-to: #6d28d9;
}

/* ----- Full-viewport background (header + main + footer share this) ----- */
.cms-site-shell {
  position: relative;
  isolation: isolate;
  background-color: var(--cms-shell-base);
  background-image:
    radial-gradient(ellipse 130% 90% at 0% -5%, rgba(224, 231, 255, 0.95), transparent 58%),
    radial-gradient(ellipse 100% 75% at 100% 0%, rgba(221, 214, 254, 0.88), transparent 52%),
    radial-gradient(ellipse 95% 70% at 45% 100%, rgba(199, 210, 254, 0.65), transparent 48%),
    radial-gradient(ellipse 55% 50% at 85% 45%, rgba(165, 180, 252, 0.35), transparent 62%);
}

.cms-site-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%23a5b4fc' stop-opacity='0.06'/%3E%3Cstop offset='100%25' stop-color='%238b5cf6' stop-opacity='0.05'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='120' height='120' fill='url(%23g)'/%3E%3Cpath d='M0 90 Q30 70 60 90 T120 85' fill='none' stroke='%2394a3b8' stroke-opacity='0.14' stroke-width='0.8'/%3E%3Cpath d='M0 40 Q40 20 80 40 T120 35' fill='none' stroke='%23a5b4fc' stroke-opacity='0.12' stroke-width='0.7'/%3E%3C/svg%3E");
  background-size: 420px 420px;
  opacity: 0.9;
}

@media (min-width: 1024px) {
  .cms-site-shell {
    background-attachment: fixed;
  }
}

/* ----- Frosted toolbar (replaces solid brand bar) ----- */
.cms-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--cms-header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--cms-header-border);
  color: #0f172a;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

.cms-header a,
.cms-header button {
  color: inherit;
}

.cms-header a:hover,
.cms-header button:hover {
  color: inherit;
}

/* Mobile drawer panel under glass header */
.cms-header-drawer {
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ----- Button scale: use .cms-btn + modifier (or legacy .btn-cms-primary) ----- */
.cms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: var(--cms-btn-radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.cms-btn:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

.cms-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

.cms-btn--block {
  width: 100%;
}

/* Primary: indigo → violet (single family site-wide) */
.cms-btn-primary,
.btn-cms-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-weight: 600;
  line-height: 1.25;
  border: none;
  border-radius: var(--cms-btn-radius);
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  color: #fff !important;
  cursor: pointer;
  text-decoration: none !important;
  background: linear-gradient(
    135deg,
    var(--cms-btn-primary-from) 0%,
    var(--cms-btn-primary-to) 100%
  );
  box-shadow:
    0 4px 14px -2px rgba(79, 70, 229, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.04);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}

.cms-btn-primary:hover,
.btn-cms-primary:hover {
  filter: brightness(1.06);
  box-shadow:
    0 6px 20px -2px rgba(79, 70, 229, 0.45),
    0 2px 4px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.cms-btn-primary:focus-visible,
.btn-cms-primary:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

.cms-btn-primary:disabled,
.btn-cms-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* Secondary: light surface + indigo border */
.cms-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: var(--cms-btn-radius);
  border-style: solid;
  border-width: 1px;
  padding: 0.625rem 1.2rem;
  font-size: 0.875rem;
  color: #312e81 !important;
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  text-decoration: none !important;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.cms-btn-secondary:hover {
  background: #fff;
  border-color: rgba(79, 70, 229, 0.5);
}

/* Ghost / neutral */
.cms-btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: var(--cms-btn-radius);
  border-style: solid;
  border-width: 1px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #334155 !important;
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(148, 163, 184, 0.45);
  cursor: pointer;
  text-decoration: none !important;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.cms-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.9);
}

/* Danger (destructive) */
.cms-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: var(--cms-btn-radius);
  border-style: solid;
  border-width: 1px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #9f1239 !important;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(251, 113, 133, 0.55);
  cursor: pointer;
  text-decoration: none !important;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.cms-btn-danger:hover {
  background: #fff1f2;
  border-color: #fb7185;
}

/* Small primary (toolbar login, compact CTAs) */
.cms-btn-primary.cms-btn--sm,
.btn-cms-primary.cms-btn--sm {
  padding: 0.45rem 1rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}

.cms-btn--sm.cms-btn-secondary,
.cms-btn--sm.cms-btn-ghost,
.cms-btn--sm.cms-btn-danger {
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}

/* Marketing hero CTAs (pilot, wide primary actions) */
.cms-btn-primary.cms-btn--lg,
.btn-cms-primary.cms-btn--lg {
  padding: 0.875rem 2rem;
  font-size: 1rem;
  border-radius: 0.75rem;
}

.cms-btn-secondary.cms-btn--lg {
  padding: 0.875rem 2rem;
  font-size: 1rem;
  border-radius: 0.75rem;
}

/* Compact “Home / Back / My loans” — same visual as secondary sm */
.cms-btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: 0.5rem;
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 0.45rem 1rem;
  font-size: 0.8125rem;
  color: #312e81 !important;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  text-decoration: none !important;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.cms-btn-nav:hover {
  background: #fff;
  border-color: rgba(79, 70, 229, 0.5);
}

.cms-btn-nav:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

button.cms-btn-nav {
  font-family: inherit;
}

/* Portal tab strip (Flowbite tabs; active state via aria-selected) */
ul.cms-tabs-list {
  display: flex;
  width: max-content;
  flex-wrap: nowrap;
  gap: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

button.cms-tab {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  margin-bottom: -1px;
  border-radius: 0.5rem 0.5rem 0 0;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  color: #64748b;
  background: transparent;
  cursor: pointer;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

button.cms-tab:hover {
  color: #0f172a;
  border-bottom-color: #cbd5e1;
}

button.cms-tab[aria-selected="true"] {
  color: #312e81;
  border-bottom-color: #4f46e5;
}

a { color: var(--cms-link); }
a:hover { color: var(--cms-link-hover); }

/* Rich page body (TinyMCE): readable typography on the portal */
.cms-prose {
  line-height: 1.65;
  color: #334155;
}
.cms-prose > * + * {
  margin-top: 1em;
}
.cms-prose h2 {
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #0f172a;
  line-height: 1.25;
}
.cms-prose h3 {
  margin-top: 1.35rem;
  margin-bottom: 0.4rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: #0f172a;
}
.cms-prose p {
  margin-top: 0;
  margin-bottom: 0;
}
.cms-prose ul,
.cms-prose ol {
  margin: 0.75rem 0;
  padding-left: 1.35rem;
}
.cms-prose li + li {
  margin-top: 0.35rem;
}
.cms-prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cms-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}
.cms-prose th,
.cms-prose td {
  border: 1px solid #e2e8f0;
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.cms-prose th {
  background: #f8fafc;
  font-weight: 600;
}

.content-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
}

.content-images {
  margin: 1rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.content-images figure {
  margin: 0;
}

.img-caption {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: #6b7280;
}

.attachments {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

.header-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: #ef4444;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  padding: 0 0.2rem;
}

.cms-header .header-badge {
  border: 2px solid rgba(255, 255, 255, 0.85);
}

/* Header CTA login: same as primary, forced white label */
header a.header-cta,
header a.header-cta:hover {
  color: #fff !important;
}

.form-input,
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
textarea,
select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  background: #fff;
}

input[type='file'] {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.65rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.9rem;
  background: #f8fafc;
  color: #334155;
}

input[type='file']::file-selector-button {
  margin-left: 0.1rem;
  margin-right: 0.7rem;
  border: 0;
  border-radius: 0.5rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--cms-btn-primary-from), var(--cms-btn-primary-to));
  cursor: pointer;
  vertical-align: middle;
}

input[type='file']::file-selector-button:hover {
  filter: brightness(1.05);
}

.poll-form ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.poll-form li label {
  display: flex;
  gap: 0.5rem;
  align-items: start;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

@media (max-width: 640px) {
  .content-images {
    grid-template-columns: 1fr;
  }
}

/* =============================================================================
   Marketing site (standalone) — layout + polish
   ============================================================================= */
.marketing-site {
  position: relative;
  isolation: isolate;
  background-color: #f1f5f9;
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(99, 102, 241, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 20%, rgba(167, 139, 250, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 45% at 0% 90%, rgba(59, 130, 246, 0.1), transparent 50%);
}

/* Subtle wash only — avoid fixed grid lines that read as “cracks” through cards/sections */
.marketing-site::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(99, 102, 241, 0.07), transparent 60%);
}

.marketing-header.cms-header {
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.marketing-nav-link {
  color: #475569;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.marketing-nav-link:hover {
  color: #4338ca;
  background-color: rgba(99, 102, 241, 0.08);
}

.marketing-footer {
  border-top: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
}

/*
 * Panel shell: holds headings + inner .marketing-card tiles without double “card on card” frames.
 */
.marketing-panel {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  border-radius: 1.5rem;
  border: 1px solid rgba(226, 232, 240, 0.98);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  padding: 1.5rem 1.5rem 1.75rem;
}

@media (min-width: 640px) {
  .marketing-panel {
    padding: 2rem 2rem 2.25rem;
  }
}

.marketing-card {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  border-radius: 1rem;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  z-index: 0;
}

.marketing-card:hover {
  box-shadow: 0 8px 24px -10px rgba(15, 23, 42, 0.12);
  border-color: rgba(199, 210, 254, 0.85);
}

/*
 * Colored marketing panels: base .marketing-card forces a white fill; without this,
 * utility gradients can lose to that rule and “white” text sits on a near-white card.
 */
.marketing-card--brand {
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 52%, #5b21b6 100%);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  box-shadow:
    0 18px 48px -14px rgba(49, 46, 129, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.06);
}

.marketing-card--brand:hover {
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow:
    0 22px 52px -14px rgba(49, 46, 129, 0.58),
    0 2px 4px rgba(0, 0, 0, 0.07);
}

.marketing-card--brand h2 {
  color: #ffffff;
}

.marketing-lang-panel {
  background: linear-gradient(165deg, #3730a3 0%, #5b21b6 45%, #4c1d95 100%);
  color: #ffffff;
}

.marketing-lang-panel .marketing-lang-panel__title {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.marketing-lang-panel .marketing-lang-panel__body {
  color: #f8fafc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

@media (prefers-reduced-motion: reduce) {
  .marketing-card:hover {
    transform: none;
  }
}

.brand-wordmark {
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.28em;
}

/* Hero imagery: subtle blend into card */
.marketing-hero-photo {
  box-shadow:
    0 12px 32px -12px rgba(30, 27, 75, 0.14),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

/*
 * Gradient headline: Tailwind bg-clip-text alone can fail in WebKit without text-fill.
 */
.marketing-gradient-tagline {
  background-image: linear-gradient(105deg, #4338ca 0%, #6d28d9 45%, #4f46e5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

