/* Member portal design system. Modern Zoho-style surfaces: light neutral app
   background, white cards with hairline borders and soft shadows, a white
   icon sidebar, brand-navy (#0b3d63) as the single accent. Status chips
   always pair a dot with a text label (never color alone). */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e3e8ee;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #8b95a3;
  --accent: #0b3d63;
  --accent-hover: #0d4a78;
  --accent-soft: #eaf1f7;
  --good: #1a7a3c;
  --good-soft: #e7f4ec;
  --warn: #8a6d1c;
  --warn-soft: #fdf4dd;
  --bad: #b3261e;
  --bad-soft: #fbeae9;
  --info: #1a5f9e;
  --info-soft: #e8f1fa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 51, 0.04), 0 2px 8px rgba(16, 32, 51, 0.05);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.5; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
/* An explicit display beats the browser's [hidden] rule, so restate it —
   otherwise the empty shell (sidebar + 100vh height) renders for logged-out
   visitors and pushes the login gate a full screen down. */
.shell[hidden] { display: none; }
.sidebar { width: 232px; flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 1.1rem 0.75rem; display: flex; flex-direction: column; gap: 1.25rem; }
.sidebar-brand { font-weight: 700; font-size: 1.02rem; color: var(--accent); padding: 0.25rem 0.75rem; letter-spacing: 0.01em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.75rem; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.sidebar-nav a svg { width: 18px; height: 18px; flex: none; }
.sidebar-nav a:hover { background: var(--bg); color: var(--ink); }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-title { font-weight: 650; font-size: 1.05rem; }
.topbar-user { display: flex; align-items: center; gap: 0.6rem; color: var(--ink-2); font-size: 0.9rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 650; }

.content { padding: 1.5rem; max-width: 1060px; width: 100%; }

/* ---------- Gate (loading / error states) ---------- */
#gate { max-width: 560px; margin: 14vh auto 0; padding: 0 1rem; }
.state-banner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; text-align: center; color: var(--ink-2); }
.state-banner.error { border-color: #ecc8c5; background: var(--bad-soft); color: var(--bad); }
.state-banner p { margin: 0; }

/* Catalyst's embedded-auth iframe fills its container, and the default
   container height leaves the form scrolling inside a letterbox. Give it
   room for the whole email/password flow. */
#loginDivElementId { height: 480px; }
#loginDivElementId iframe { width: 100%; height: 100%; border: 0; }

/* ---------- Cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; }
.card h2 { margin: 0 0 1rem; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-head h2 { margin: 0; }

.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.tile .tile-label { font-size: 0.82rem; color: var(--ink-3); font-weight: 500; }
.tile .tile-value { font-size: 1.45rem; font-weight: 650; margin-top: 0.2rem; }
.tile .tile-sub { font-size: 0.8rem; color: var(--ink-3); margin-top: 0.15rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } .sidebar { width: 64px; } .sidebar-brand, .sidebar-nav a span { display: none; } }

/* ---------- Chips (status = dot + label, never color alone) ---------- */
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.13rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.chip.good { background: var(--good-soft); color: var(--good); } .chip.good::before { background: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.warn::before { background: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.bad::before { background: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); } .chip.info::before { background: var(--info); }
.chip.plain::before { display: none; }

/* ---------- Forms ---------- */
fieldset { border: none; padding: 0; margin: 1.25rem 0 0; }
fieldset legend { font-weight: 650; font-size: 0.92rem; color: var(--accent); padding: 0; margin-bottom: 0.6rem; }
.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--ink-2); }
.field input[type="text"], .field input[type="email"], .field input[type="tel"],
.field input[type="url"], .field input[type="date"], .field select, .field textarea {
  width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field textarea { min-height: 5.5rem; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.toggle-row label { margin: 0; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.35rem 1rem; }
.category-grid label, .role-options label { display: flex; align-items: center; gap: 0.45rem; font-weight: 400; font-size: 0.88rem; color: var(--ink); }
.role-options { display: flex; gap: 1.25rem; flex-wrap: wrap; }

.actions { margin-top: 1.4rem; display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
button.primary { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 0.55rem 1.3rem; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.6; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 1.1rem; font-weight: 600; color: var(--ink-2); }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.link { background: none; border: none; padding: 0.2rem 0.4rem; color: var(--info); font-weight: 600; font-size: 0.85rem; border-radius: 6px; }
button.link:hover { background: var(--info-soft); }
button.link.danger { color: var(--bad); }
button.link.danger:hover { background: var(--bad-soft); }

.save-status { font-size: 0.9rem; }
.save-status.success { color: var(--good); }
.save-status.error { color: var(--bad); }
.rejected-note { font-size: 0.82rem; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 0.5rem 0.75rem; margin-top: 0.75rem; }
.form-error { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 0.5rem 0.75rem; margin: 0 0 0.9rem; font-size: 0.88rem; }

/* ---------- Tables / list rows ---------- */
.row-list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 0.2rem; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { font-size: 0.83rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 0.25rem; flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; }
.tabs button { background: none; border: none; padding: 0.5rem 0.9rem; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-3); }
.empty svg { width: 42px; height: 42px; margin-bottom: 0.6rem; color: var(--ink-3); opacity: 0.7; }
.empty .empty-title { font-weight: 650; color: var(--ink-2); margin-bottom: 0.2rem; }
.empty p { margin: 0.15rem 0; font-size: 0.9rem; }

/* ---------- Feed cards ---------- */
.feed-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.9rem 1.1rem; margin-bottom: 0.8rem; }
.feed-meta { display: flex; align-items: center; gap: 0.6rem; font-size: 0.8rem; color: var(--ink-3); margin-bottom: 0.3rem; flex-wrap: wrap; }
.feed-title { font-weight: 650; margin-bottom: 0.25rem; }
.feed-body { font-size: 0.9rem; color: var(--ink-2); white-space: pre-line; }

/* ---------- ROI dashboard ---------- */
.hero-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.hero-figure { font-size: 2.7rem; font-weight: 700; line-height: 1.05; color: var(--ink); }
.hero-label { font-size: 0.82rem; color: var(--ink-3); font-weight: 600; }
.hero-sub { font-size: 0.85rem; color: var(--ink-2); margin-top: 0.35rem; }
.hero-spark { flex: none; }
.spark-svg .spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-svg .spark-area { fill: var(--accent-soft); }
.spark-svg .spark-dot { fill: var(--accent); }

.meter { height: 10px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.4rem; }
.meter-head .meter-pct { font-weight: 650; }
.completeness-missing { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }

.bar-list { display: flex; flex-direction: column; gap: 0.55rem; }
.bar-row { display: grid; grid-template-columns: 88px 1fr 34px; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.bar-row .bar-track { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.bar-row .bar-track > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar-row .bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar-row .bar-label { color: var(--ink-2); text-transform: capitalize; }

.muted { color: var(--ink-3); font-size: 0.85rem; }

/* ---------- Media library ---------- */
.media-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .media-layout { grid-template-columns: 1fr; } }
.media-rail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.6rem; display: flex; flex-direction: column; gap: 2px; }
.media-cat { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; border-radius: 8px; cursor: pointer; font-size: 0.9rem; color: var(--ink-2); }
.media-cat:hover { background: var(--bg); }
.media-cat.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.media-cat.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.media-cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-cat-count { font-size: 0.75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.media-cat-actions { display: none; gap: 0; }
.media-cat:hover .media-cat-actions { display: inline-flex; }
.media-new-cat { margin-top: 0.5rem; font-size: 0.85rem; }
.media-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.media-toolbar select, .media-toolbar input[type="search"] { padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); }
.media-toolbar input[type="search"] { flex: 1; min-width: 160px; max-width: 320px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.9rem; }
.media-tile { position: relative; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; cursor: pointer; }
.media-tile:hover { border-color: var(--accent); }
.media-tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--bg); }
.media-tile figcaption { padding: 0.4rem 0.55rem; display: flex; flex-direction: column; gap: 0.2rem; }
.media-tile-name { font-size: 0.76rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-tile-kind { align-self: flex-start; font-size: 0.68rem; }
.media-alt-warn { position: absolute; top: 6px; right: 6px; background: var(--warn-soft); color: var(--warn); font-size: 0.66rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 999px; }
.media-overlay { position: fixed; inset: 0; background: rgba(15, 26, 39, 0.45); display: flex; align-items: center; justify-content: center; padding: 1.5rem; z-index: 50; }
.media-editor { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; }
.media-editor-preview { width: 100%; max-height: 260px; object-fit: contain; background: var(--bg); border-radius: 8px; margin-bottom: 1rem; }
.definition-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.5rem; font-size: 0.92rem; }
.definition-list dt { color: var(--ink-3); }
.definition-list dd { margin: 0; font-weight: 550; }
