/* ============ Portal theme tokens ============ */
:root {
  --lg-emerald: #059669;
  --lg-emerald-dark: #047857;
  --lg-ink: #0f172a;
}

/* App background: subtle gradient instead of flat gray */
#app-shell { background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%); min-height: 100vh; }

/* ============ Mobile responsiveness safeguards ============ */
/* Never allow the page to scroll sideways on small screens. */
html, body { max-width: 100%; overflow-x: hidden; }
@media (max-width: 640px) {
  /* Wide data tables become horizontally scrollable instead of breaking layout.
     (Report tables have their own .report-doc table rule — exclude them here.) */
  #app-shell table:not(.report-doc table) { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Modal/drawer body: let long words/URLs wrap instead of forcing overflow. */
  #modal-body, #drawer-content { word-break: break-word; overflow-wrap: anywhere; }
  /* Comfortable tap targets for nav + primary buttons. */
  .mtab { min-height: 52px; }
}

/* ============ Contrast safety net ============
   Guard against "invisible text" bugs: form fields must always render dark text
   on their light background, even if a global reset or stray class strips color.
   Inputs/selects/textareas live on white cards throughout the app. */
input, select, textarea, .lg-input { color: #0f172a; }
input::placeholder, textarea::placeholder { color: #94a3b8; }
select option { color: #0f172a; background: #fff; }
/* Gradient-clipped headings can collapse to transparent on browsers that fail to
   support background-clip:text — give them a solid fallback color so text never
   disappears. The gradient still shows where supported. */
.lg-gradient-text, .lg-violet-text { color: #0f766e; }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .lg-gradient-text, .lg-violet-text { color: transparent; }
}
/* Any element that explicitly opts into a white text color is fine; this only
   protects elements that accidentally end up with no readable color on white. */

/* ============ Tab navigation (desktop pill nav) ============ */
.tab-btn {
  color: #64748b;
  background: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: 0.625rem;
  transition: color .2s ease, background .2s ease;
}
.tab-btn:hover { background: #f1f5f9; color: #334155; }
.tab-active {
  background: linear-gradient(135deg, #059669, #0d9488) !important;
  color: #fff !important;
  box-shadow: 0 6px 16px -6px rgba(5, 150, 105, .55);
}
.tab-active .tab-count { background: rgba(255,255,255,.25) !important; color: #fff !important; }

/* Mobile bottom nav */
.mtab { color: #94a3b8; transition: color .2s ease; }
.mtab.tab-active-m { color: #059669; }
.mtab.tab-active-m i { transform: translateY(-2px); }

/* ============ Cards ============ */
.lg-pcard {
  background: #fff;
  border: 1px solid #e9eef5;
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px -16px rgba(15,23,42,.12);
}
.lg-pcard-hover { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.lg-pcard-hover:hover { transform: translateY(-2px); box-shadow: 0 12px 32px -16px rgba(15,23,42,.22); border-color: #cde9dd; }

/* Stat tile */
.lg-stat {
  background: #fff;
  border: 1px solid #e9eef5;
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  transition: transform .2s ease, box-shadow .2s ease;
}
.lg-stat:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -18px rgba(15,23,42,.25); }

/* ============ Inputs ============ */
.lg-input {
  width: 100%;
  border: 1px solid #d8e0ea;
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
  outline: none;
}
.lg-input:focus { border-color: #34d399; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.lg-input::placeholder { color: #94a3b8; }

/* Primary button shimmer */
.lg-btn-primary {
  background: linear-gradient(135deg, #059669, #0d9488);
  color: #fff;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
  box-shadow: 0 8px 20px -10px rgba(5,150,105,.7);
}
.lg-btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 12px 26px -10px rgba(5,150,105,.75); }
.lg-btn-primary:active { transform: translateY(0); }

/* ============ Drawer ============ */
#drawer { transition: transform .28s cubic-bezier(.22,.7,.3,1); }

/* ============ Custom scrollbar ============ */
#drawer::-webkit-scrollbar, #modal-body::-webkit-scrollbar, .lg-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
#drawer::-webkit-scrollbar-thumb, #modal-body::-webkit-scrollbar-thumb, .lg-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
#drawer::-webkit-scrollbar-thumb:hover, #modal-body::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Skeleton shimmer for loading states */
.lg-skeleton { background: linear-gradient(90deg,#eef2f7 25%,#e2e8f0 37%,#eef2f7 63%); background-size: 400% 100%; animation: lgshimmer 1.4s ease infinite; border-radius: .5rem; }
@keyframes lgshimmer { 0%{background-position:100% 50%} 100%{background-position:0 50%} }

/* Fade-in for view sections */
.lg-fade { animation: lgfadein .35s ease both; }
@keyframes lgfadein { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ============ Prose (legacy AI reports) ============ */
.prose h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: .5rem; }
.prose h2 { font-size: 1.1rem; font-weight: 600; margin-top: 1rem; margin-bottom: .4rem; color: #047857; }
.prose ul { list-style: disc; padding-left: 1.25rem; margin: .5rem 0; }
.prose ol { list-style: decimal; padding-left: 1.25rem; margin: .5rem 0; }
.prose blockquote { border-left: 3px solid #10b981; padding-left: .75rem; color: #475569; font-style: italic; margin: .75rem 0; }
.prose code { background: #f1f5f9; padding: 0 .25rem; border-radius: .25rem; }
.prose hr { margin: 1rem 0; border-color: #e2e8f0; }
.prose p { margin: .5rem 0; }
table { border-collapse: collapse; }
html { scroll-behavior: smooth; }

/* ============ Agency report document ============ */
.report-doc {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1e293b;
  font-size: 14px;
  line-height: 1.65;
}
.report-doc > *:first-child { margin-top: 0; }
.report-doc h1 {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em;
  color: #0f172a; margin: 0 0 .35rem;
}
.report-doc h2 {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em;
  color: #047857; margin: 1.6rem 0 .65rem;
  padding-bottom: .4rem; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; gap: .5rem;
}
.report-doc h2::before {
  content: ""; width: 4px; height: 1.05rem; border-radius: 2px;
  background: linear-gradient(180deg,#059669,#0d9488); flex: none;
}
.report-doc h3 { font-size: .92rem; font-weight: 700; color: #334155; margin: 1.1rem 0 .4rem; }
.report-doc p { margin: .6rem 0; color: #334155; }
.report-doc strong { color: #0f172a; font-weight: 700; }
.report-doc ul { list-style: none; padding-left: 0; margin: .6rem 0; }
.report-doc ul li {
  position: relative; padding-left: 1.5rem; margin: .45rem 0; color: #334155;
}
.report-doc ul li::before {
  content: "\f058"; font-family: "Font Awesome 6 Free"; font-weight: 900;
  position: absolute; left: 0; top: .12rem; color: #10b981; font-size: .82rem;
}
.report-doc ol { counter-reset: rd; list-style: none; padding-left: 0; margin: .6rem 0; }
.report-doc ol li {
  position: relative; padding-left: 2.1rem; margin: .6rem 0; color: #334155;
}
.report-doc ol li::before {
  counter-increment: rd; content: counter(rd);
  position: absolute; left: 0; top: .05rem;
  width: 1.45rem; height: 1.45rem; border-radius: .5rem;
  background: linear-gradient(135deg,#059669,#0d9488); color: #fff;
  font-size: .72rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px -4px rgba(5,150,105,.6);
}
.report-doc blockquote {
  margin: 1rem 0; padding: .85rem 1rem; border: 0;
  border-left: 4px solid #10b981; border-radius: 0 .6rem .6rem 0;
  background: #ecfdf5; color: #065f46; font-style: normal;
}
.report-doc blockquote p { margin: 0; color: #065f46; }
.report-doc code { background: #f1f5f9; padding: .08rem .35rem; border-radius: .3rem; font-size: .85em; color: #0f766e; }
.report-doc hr { margin: 1.4rem 0; border: 0; border-top: 1px dashed #cbd5e1; }
.report-doc table { width: 100%; border-collapse: collapse; margin: .8rem 0; font-size: .85rem; display: table; }
@media (max-width: 640px) {
  .report-doc table { display: block; overflow-x: auto; white-space: nowrap; }
}
.report-doc th { background: #f0fdf4; color: #065f46; text-align: left; font-weight: 700; padding: .55rem .7rem; border: 1px solid #d1fae5; }
.report-doc td { padding: .5rem .7rem; border: 1px solid #e2e8f0; color: #334155; }
.report-doc tr:nth-child(even) td { background: #f8fafc; }
.report-doc em { color: #64748b; }
.report-doc a { color: #047857; text-decoration: underline; }

/* Report header band (score + meta) */
.report-hero {
  border-radius: .9rem; padding: 1rem 1.15rem; margin-bottom: 1rem;
  background: linear-gradient(135deg,#0f172a,#134e4a);
  color: #e2e8f0; position: relative; overflow: hidden;
}
.report-hero::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,.35), transparent 70%);
}
.report-score-ring {
  width: 58px; height: 58px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem; color: #fff;
}

/* On-screen report "document frame": white page on a tinted backdrop with
   generous padding so the report reads like a polished deliverable, not cramped
   modal content. The negative margins pull it to the modal-body edges so the
   tinted backdrop spans the full width. */
.report-frame {
  margin: -1.25rem;            /* cancel modal-body p-5 padding */
  padding: 1.5rem 1.25rem;
  background: #eef2f6;
}
.report-page {
  max-width: 680px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 1rem;
  padding: 1.75rem 2rem;
  box-shadow: 0 10px 30px rgba(15,23,42,.08);
}
@media (max-width: 640px) {
  .report-frame { padding: 1rem .6rem; }
  .report-page { padding: 1.25rem 1.15rem; border-radius: .85rem; }
}

/* Print: clean white document */
@media print {
  body * { visibility: hidden; }
  #report-print, #report-print * { visibility: visible; }
  #report-print { position: absolute; left: 0; top: 0; width: 100%; padding: 24px; background: #fff; }
  .report-frame { margin: 0; padding: 0; background: #fff; }
  .report-page { max-width: none; box-shadow: none; border-radius: 0; padding: 0; }
  .no-print { display: none !important; }
}
