/*
 * Front-facing role-based portals (/portal/*). Simple landing stub UI —
 * each portal gets a full Figma-fidelity build with its own EPIC.
 */

/* Dev-only PM inspector overlay. Fixed pill bottom-right; expands into
   a card with the page's EPIC / story list + a "draft story" form. Only
   rendered by the layout when owner+dev, so no prod styling risk. */
.pm-overlay {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  font: 500 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
}
.pm-overlay__toggle {
  background: #0f172a;
  color: #fff;
  border: 0;
  border-radius: 9999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15,23,42,0.25);
}
.pm-overlay__toggle:hover { background: #1f2937; }
.pm-overlay__panel {
  display: none;
  position: absolute;
  right: 0;
  bottom: 46px;
  width: 380px;
  max-height: 70vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15,23,42,0.20);
  padding: 14px 16px;
}
.pm-overlay[data-open="true"] .pm-overlay__panel { display: block; }
.pm-overlay__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.pm-overlay__path { font-size: 11px; color: #6b7280; background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }
.pm-overlay__meta { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; margin: 6px 0 10px; font-size: 12px; }
.pm-overlay__meta dt { color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; padding-top: 3px; }
.pm-overlay__meta dd { margin: 0; }
.pm-overlay__file { display: block; margin-top: 4px; font-size: 11px; color: #4b5563; }
.pm-overlay h4 { margin: 12px 0 6px; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: #6b7280; }
.pm-overlay__stories { list-style: none; padding: 0; margin: 0; }
.pm-story {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid #f1f5f9;
  font-size: 12px;
}
.pm-story:first-child { border-top: 0; }
.pm-story__dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; display: inline-block; }
.pm-story--done .pm-story__dot        { background: #10b981; }
.pm-story--in_progress .pm-story__dot { background: #f59e0b; }
.pm-story--not_started .pm-story__dot { background: #ef4444; }
.pm-story__id { font-weight: 700; color: #0f172a; min-width: 42px; }
.pm-story__title { color: #4b5563; text-transform: capitalize; }
.pm-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pm-status--stub    { background: #fef3c7; color: #92400e; }
.pm-status--partial { background: #dbeafe; color: #1e40af; }
.pm-status--done    { background: #d1fae5; color: #065f46; }
.pm-overlay__blockers { margin: 8px 0 4px; font-size: 12px; color: #4b5563; }
.pm-overlay__no-meta { font-size: 12px; color: #6b7280; }
.pm-overlay__no-meta code { background: #f3f4f6; padding: 1px 4px; border-radius: 3px; }
.pm-overlay__draft { margin-top: 12px; border-top: 1px solid #e5e7eb; padding-top: 10px; }
.pm-overlay__draft summary { cursor: pointer; font-weight: 700; color: #0f172a; font-size: 12px; }
.pm-overlay__draft form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.pm-overlay__draft label { display: block; font-size: 11px; color: #4b5563; font-weight: 600; }
.pm-overlay__draft input,
.pm-overlay__draft textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font: inherit;
  margin-top: 3px;
}
.pm-overlay__draft button {
  background: #0f172a;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-start;
}
.pm-overlay__status { font-size: 11px; margin-top: 4px; }
.pm-overlay__status--ok  { color: #065f46; }
.pm-overlay__status--err { color: #b91c1c; }
.pm-req { color: #b91c1c; font-weight: 700; }

/* Architect's target: Figma frame capture + optional live link */
.pm-figma { margin: 6px 0 4px; }
.pm-figma__thumb {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  max-height: 220px;
  object-fit: cover;
  object-position: top center;
}
.pm-figma__link {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
  text-decoration: none;
}
.pm-figma__link:hover { text-decoration: underline; }

/* Expandable story rows — lazy-load the .md content on open */
.pm-story details { width: 100%; }
.pm-story summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}
.pm-story summary::-webkit-details-marker { display: none; }
.pm-story__body {
  padding: 8px 0 10px 18px;
  border-left: 2px solid #f1f5f9;
  margin: 6px 0 6px 4px;
  font-size: 12px;
  color: #1f2937;
  line-height: 1.5;
}
.pm-story__body h1,
.pm-story__body h2,
.pm-story__body h3 { font-size: 13px; margin: 8px 0 4px; color: #0f172a; }
.pm-story__body h4,
.pm-story__body h5 { font-size: 12px; margin: 6px 0 3px; color: #374151; }
.pm-story__body p  { margin: 4px 0; }
.pm-story__body ul,
.pm-story__body ol { padding-left: 18px; margin: 4px 0; }
.pm-story__body li { margin: 2px 0; }
.pm-story__body code {
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.pm-story__body pre {
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 11px;
}
.pm-story__body a { color: #1d4ed8; }
.pm-story__loading, .pm-story__err { margin: 0; color: #6b7280; font-style: italic; }
.pm-story__err { color: #b91c1c; }

/* Blocked-by list — same visual language as story rows so the eye
   groups them, with a distinct amber-ish dot. Clickable rows lazy-load
   the referenced .md the same way stories do. */
.pm-overlay__blocked { list-style: none; padding: 0; margin: 0 0 8px; }
.pm-blocker {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid #f1f5f9;
  font-size: 12px;
}
.pm-blocker:first-child { border-top: 0; }
.pm-blocker__dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; display: inline-block; flex-shrink: 0; }
.pm-blocker--done .pm-blocker__dot        { background: #10b981; }
.pm-blocker--in_progress .pm-blocker__dot { background: #f59e0b; }
.pm-blocker--not_started .pm-blocker__dot { background: #ef4444; }
.pm-blocker--unknown .pm-blocker__dot     { background: #cbd5e1; }
.pm-blocker__details { width: 100%; }
.pm-blocker__details summary {
  cursor: pointer;
  color: #1d4ed8;
  font-weight: 600;
  list-style: none;
}
.pm-blocker__details summary::-webkit-details-marker { display: none; }
.pm-blocker__id { color: #4b5563; }

/* Inline AC editor + hygiene + review queue */
.pm-story__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 6px 18px;
  font-size: 11px;
}
.pm-story__edit-btn {
  background: #0f172a;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.pm-story__edit-btn:hover { background: #1f2937; }
.pm-story__examples { color: #6b7280; }
.pm-story__examples a { color: #1d4ed8; text-decoration: none; }
.pm-story__examples a:hover { text-decoration: underline; }

.pm-story__editor { padding: 0 0 6px 18px; margin-top: 4px; }
.pm-story__editor-label { display: block; font-size: 11px; color: #4b5563; margin-bottom: 4px; font-weight: 600; }
.pm-story__editor-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: 400 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  resize: vertical;
}
.pm-story__editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.pm-story__save-btn {
  background: #1d4ed8;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.pm-story__save-btn:hover { background: #1e40af; }
.pm-story__cancel-btn {
  background: transparent;
  color: #6b7280;
  border: 0;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
}
.pm-story__cancel-btn:hover { color: #0f172a; }
.pm-story__editor-status { font-size: 11px; color: #6b7280; }
.pm-story__editor-status--ok { color: #065f46; }
.pm-story__editor-status--err { color: #b91c1c; }

.pm-hygiene {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  font-size: 11px;
}
.pm-hygiene__item {
  padding: 3px 8px;
  border-radius: 4px;
  margin: 2px 0;
}
.pm-hygiene__item--ok  { background: #d1fae5; color: #065f46; }
.pm-hygiene__item--err { background: #fee2e2; color: #991b1b; }

.pm-story__review { margin-top: 10px; }
.pm-story__review summary { font-size: 11px; color: #1d4ed8; font-weight: 700; cursor: pointer; }
.pm-story__review summary::-webkit-details-marker { display: none; }
.pm-story__review-note {
  width: 100%;
  padding: 6px 8px;
  margin: 6px 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: inherit;
  font-size: 11px;
}
.pm-story__queue-btn {
  background: #7c3aed;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.pm-story__queue-btn:hover { background: #6d28d9; }
.pm-story__queue-status { font-size: 11px; margin-left: 8px; color: #6b7280; }
.pm-story__queue-status--ok { color: #065f46; }
.pm-story__queue-status--err { color: #b91c1c; }

/* Story groups — one per location value from pm_meta[:story_locations] */
.pm-story-group { margin: 6px 0 10px; }
.pm-story-group__label {
  margin: 6px 0 4px;
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  text-transform: none;
  letter-spacing: 0;
  padding: 3px 8px;
  background: #f1f5f9;
  border-radius: 4px;
  display: inline-block;
}
.pm-story-group__count { color: #6b7280; font-weight: 500; margin-left: 4px; }

/* Raw markdown fallback (kramdown not loaded) */
.pm-story__raw {
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}
.pm-story__hint { font-size: 11px; color: #b45309; margin: 4px 0 0; font-style: italic; }

/* Blank KPI placeholder — em dash in muted grey */
.portal-kpi__placeholder { color: #cbd5e1; font-weight: 400; }

.portal-body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f7f8fa;
  color: #1f2937;
}

.portal-header {
  background: linear-gradient(90deg, #1e293b 0%, #4338ca 100%);
  color: #fff;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
}
.portal-brand__ring {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 3px solid #ffd400;
  background: transparent;
  display: inline-block;
}
.portal-brand__earth  { color: #ffd400; font-weight: 700; }
.portal-brand__angels { color: #fff;    font-weight: 700; margin-left: 3px; }

.portal-header__slash { margin: 0 12px; opacity: 0.4; }
.portal-header__title { font-size: 15px; opacity: 0.85; }

.portal-header__actions {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px;
}
.portal-header__user { opacity: 0.8; }
.portal-btn-signout {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.14);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.portal-btn-signout:hover { background: rgba(255,255,255,0.14); }

.portal-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
}

/* Prominent back-to-home link at the top of every portal page — the
   escape hatch out of the portal into the main site. Big, obvious,
   sits above the hero. */
.portal-back { margin: 0 0 16px; }
.portal-back__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1e40af;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #c7d2fe;
  transition: background-color 120ms, transform 120ms;
}
.portal-back__link:hover {
  background: #c7d2fe;
  transform: translateX(-2px);
}

.portal-flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}
.portal-flash--notice { background: #dcfce7; color: #14532d; }
.portal-flash--alert  { background: #fee2e2; color: #7f1d1d; }

.portal-hero {
  margin-bottom: 28px;
}
.portal-hero__greeting {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 4px;
}
.portal-hero__label {
  color: #6b7280;
  margin: 0;
  font-size: 15px;
}

.portal-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.portal-kpi {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border: 1px solid #e5e7eb;
}
.portal-kpi__label {
  color: #6b7280;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 6px;
}
.portal-kpi__value {
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
}

.portal-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 10px;
  margin-bottom: 24px;
}
.portal-tab {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #374151;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.portal-tab--active {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

.portal-placeholder {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  border: 1px solid #e5e7eb;
  color: #374151;
  font-size: 14px;
  line-height: 1.6;
}
.portal-placeholder p { margin: 0 0 10px; }
.portal-placeholder p:last-child { margin: 0; }

.portal-link {
  color: #4f46e5;
  text-decoration: none;
  font-weight: 500;
}
.portal-link:hover { text-decoration: underline; }

/* Tools grid — cards linking to features that belong to this portal. */
.portal-section__title {
  font-size: 15px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin: 12px 0 12px;
}
.portal-tools {
  margin-bottom: 28px;
}
.portal-tools__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.portal-tool-card {
  display: block;
  padding: 16px 18px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.1s, transform 0.05s;
}
.portal-tool-card:hover {
  border-color: #4f46e5;
  transform: translateY(-1px);
  text-decoration: none;
}
.portal-tool-card__label {
  font-size: 16px;
  font-weight: 600;
  color: #4f46e5;
  margin-bottom: 4px;
}
.portal-tool-card__desc {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
}

/* Portal KPI cards for the EAN Admin dashboard — clickable variant links
   to admin pages; attention variant highlights pending review; stat variant
   shows a static number. */
.portal-kpis--overview .portal-kpi { padding: 18px; }
.portal-kpi--link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.1s;
}
.portal-kpi--link:hover { border-color: #4f46e5; text-decoration: none; color: inherit; }
.portal-kpi__cta {
  color: #4f46e5;
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}
.portal-kpi--attention { background: #fef3c7; border-color: #fbbf24; }
.portal-kpi--attention .portal-kpi__value { color: #b45309; }
.portal-kpi--stat { background: #f9fafb; }

/* Charts — donut + revenue line. Ported from admin.css. */
.portal-chart {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.portal-chart__title { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.portal-chart__subtitle { margin: 0 0 12px; color: #6b7280; font-size: 13px; }
.portal-chart__body { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.portal-chart__svg  { width: 200px; height: 200px; flex-shrink: 0; }
.portal-chart__legend { list-style: none; padding: 0; margin: 0; min-width: 220px; }
.portal-chart__legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
.portal-chart__swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.portal-chart__legend-label { flex: 1; }
.portal-chart__legend-value { color: #6b7280; font-size: 13px; }
.portal-chart__revenue { width: 100%; height: auto; max-height: 200px; }
