:root {
  --bg: #020713;
  --bg-soft: #061024;
  --panel: rgba(7, 20, 46, 0.86);
  --panel-strong: rgba(8, 25, 58, 0.96);
  --line: rgba(75, 175, 255, 0.25);
  --line-soft: rgba(255, 255, 255, 0.10);
  --text: #f7fbff;
  --muted: #9db0cb;
  --blue: #087bff;
  --cyan: #00d9ff;
  --green: #39d98a;
  --yellow: #ffc857;
  --red: #ff5f7a;
  --shadow: 0 24px 75px rgba(0, 84, 255, 0.22);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(0, 119, 255, 0.25), transparent 34%),
    radial-gradient(circle at 85% 15%, rgba(0, 217, 255, 0.12), transparent 28%),
    linear-gradient(180deg, #020713 0%, #040916 52%, #01030a 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.023) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.023) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.72), transparent 82%);
  z-index: -2;
}

a { color: inherit; text-decoration: none; transition: color .18s ease; }
a:not(.button):hover, a:not(.button):focus-visible { color: var(--cyan); }
button, input, select { font: inherit; }

.ambient {
  position: fixed;
  pointer-events: none;
  filter: blur(80px);
  opacity: .36;
  z-index: -1;
}
.ambient-one { width: 320px; height: 320px; background: #0068ff; top: 16%; left: -150px; }
.ambient-two { width: 360px; height: 360px; background: #00cfff; right: -190px; bottom: 10%; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 76px;
  padding: 10px clamp(18px, 4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(2, 7, 19, .80);
  backdrop-filter: blur(18px);
}

.brand img {
  width: 116px;
  display: block;
  filter: drop-shadow(0 0 18px rgba(0, 119, 255, .38));
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.top-nav a:hover, .top-nav a:focus-visible { color: var(--cyan); }

.health-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  border: 1px solid var(--line-soft);
}
.health-loading { color: var(--muted); }
.health-online, .status-approved, .status-active { color: var(--green); background: rgba(57, 217, 138, .09); }
.health-offline, .status-rejected, .status-suspended, .status-failed, .status-refunded, .status-chargeback, .status-restricted { color: var(--red); background: rgba(255, 95, 122, .10); }
.status-pending, .status-pending-review, .status-approved:not(.status-active), .status-partially-refunded, .status-disputed, .status-expired { color: var(--yellow); background: rgba(255, 200, 87, .10); }
.status-draft, .status-paused, .status-completed, .status-available { color: #a9c8ff; background: rgba(8, 123, 255, .10); }

.mono-reference {
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

main { width: min(1280px, calc(100% - 30px)); margin: 0 auto; }

.auth-layout {
  min-height: calc(100vh - 158px);
  padding: 72px 0;
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  gap: clamp(30px, 6vw, 82px);
  align-items: center;
}

.auth-intro h1 {
  margin: 12px 0 22px;
  max-width: 780px;
  font-size: clamp(44px, 7vw, 78px);
  line-height: .98;
  letter-spacing: -.055em;
  background: linear-gradient(135deg, #fff 12%, #76c7ff 52%, #00e5ff);
  -webkit-background-clip: text;
  color: transparent;
}

.auth-intro > p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.75;
}

.eyebrow {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.feature-list {
  display: grid;
  gap: 12px;
  margin-top: 32px;
}

.feature-list > div {
  padding: 15px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
}
.feature-list strong { display: block; margin-bottom: 4px; }
.feature-list span { color: var(--muted); line-height: 1.5; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.065), rgba(255,255,255,.025));
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-panel { padding: 26px; }

.tab-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  margin-bottom: 20px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(0,0,0,.18);
}

.tab {
  border: 0;
  border-radius: 10px;
  padding: 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 850;
}
.tab.active {
  color: white;
  background: linear-gradient(135deg, rgba(0,104,255,.86), rgba(0,207,255,.68));
}

.form-stack { display: grid; gap: 16px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px;
}
.field-span { grid-column: 1 / -1; }

.access-code-fields {
  grid-template-columns: 1fr 1fr;
  gap: 17px;
  padding: 16px;
  border: 1px solid rgba(0, 217, 255, .22);
  border-radius: 14px;
  background: rgba(0, 217, 255, .045);
}
.access-code-fields:not(.hidden) { display: grid; }


label {
  display: block;
  margin-bottom: 7px;
  color: #dceaff;
  font-size: 13px;
  font-weight: 800;
}

input, select {
  width: 100%;
  min-height: 47px;
  padding: 11px 13px;
  color: white;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  outline: 0;
  background: rgba(1, 5, 16, .76);
}
input:focus, select:focus {
  border-color: rgba(0,217,255,.72);
  box-shadow: 0 0 0 4px rgba(0,217,255,.10);
}
input:disabled { opacity: .65; cursor: not-allowed; }

small, .fine-print {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.checkbox-line {
  min-height: 47px;
  margin: 0;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: rgba(1, 5, 16, .76);
  color: var(--muted);
}
.checkbox-line input { width: 18px; min-height: auto; accent-color: var(--blue); }

.button {
  min-height: 46px;
  padding: 0 19px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  color: white;
  cursor: pointer;
  font-weight: 900;
  transition: transform .16s ease, opacity .16s ease, border-color .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .58; transform: none; }
.button-primary {
  background: linear-gradient(135deg, #0068ff, #00cfff);
  box-shadow: 0 12px 30px rgba(0, 105, 255, .26);
}
.button-ghost { background: rgba(255,255,255,.04); color: #dceaff; }
.button-danger { background: linear-gradient(135deg, #a81737, #ef3156); }
.button.compact { min-height: 38px; padding: 0 14px; font-size: 12px; }

.status-message {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}
.status-message.error { color: #ff9aac; }
.status-message.success { color: var(--green); }

.center-state {
  min-height: calc(100vh - 158px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255,255,255,.14);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.portal-shell {
  min-height: calc(100vh - 150px);
  padding: 32px 0 58px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 108px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: rgba(5, 15, 36, .82);
}

.account-summary {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 8px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.account-summary strong, .account-summary span { display: block; }
.account-summary span { margin-top: 2px; color: var(--muted); font-size: 12px; text-transform: capitalize; }
.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  background: linear-gradient(135deg, #0068ff, #00cfff);
  font-size: 18px;
  font-weight: 950;
}

.side-link {
  width: 100%;
  min-height: 43px;
  padding: 0 13px;
  margin: 3px 0;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}
.side-link:hover, .side-link.active {
  color: white;
  border-color: var(--line);
  background: rgba(0, 119, 255, .10);
}

.portal-content { min-width: 0; }

.portal-section { display: none; }
.portal-section.active { display: block; }

.section-heading,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.section-heading { margin-bottom: 20px; }
.section-heading h2, .panel-heading h3 { margin: 6px 0 0; }
.section-heading h2 { font-size: clamp(30px, 4vw, 44px); letter-spacing: -.035em; }
.panel-heading { margin-bottom: 18px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 13px;
  margin-bottom: 20px;
}
.metric-card {
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 17px;
  background: rgba(255,255,255,.035);
}
.metric-card span, .metric-card strong, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 800; }
.metric-card strong { margin: 10px 0 7px; font-size: clamp(20px, 3vw, 29px); }
.metric-card small { color: var(--muted); }

.notice {
  margin-bottom: 18px;
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #dff8ff;
  background: rgba(0, 148, 255, .10);
  line-height: 1.55;
}
.notice.error { color: #ffe3e8; border-color: rgba(255,95,122,.45); background: rgba(255,95,122,.09); }
.notice.success { color: #dfffee; border-color: rgba(57,217,138,.40); background: rgba(57,217,138,.08); }
.notice.warning { color: #fff2c9; border-color: rgba(255,200,87,.40); background: rgba(255,200,87,.08); }

.application-card { margin-top: 20px; }
.application-card h3 { margin-top: 0; }

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 15px;
}
.campaign-card {
  padding: 19px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: rgba(255,255,255,.035);
}
.campaign-card h3 { margin: 11px 0 7px; }
.campaign-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.campaign-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 16px 0;
}
.campaign-meta div {
  padding: 9px;
  border-radius: 11px;
  background: rgba(0,0,0,.17);
}
.campaign-meta span, .campaign-meta strong { display: block; }
.campaign-meta span { color: var(--muted); font-size: 11px; }
.campaign-meta strong { margin-top: 4px; }
.card-actions, .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}
.form-actions { margin-top: 4px; }

.detail-grid, .analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 11px;
  margin: 17px 0;
}
.detail-item {
  padding: 13px;
  border-radius: 13px;
  background: rgba(0,0,0,.18);
}
.detail-item span, .detail-item strong { display: block; }
.detail-item span { color: var(--muted); font-size: 11px; }
.detail-item strong { margin-top: 5px; word-break: break-word; }
.url-link { color: var(--cyan); word-break: break-all; }

.inline-form {
  display: flex;
  align-items: end;
  gap: 12px;
}
.inline-form > div { flex: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 9px; text-align: left; border-bottom: 1px solid var(--line-soft); }
th { color: var(--muted); }
td { color: #eaf4ff; }

.details-list { margin: 0; }
.details-list > div {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.details-list dt { color: var(--muted); }
.details-list dd { margin: 0; font-weight: 850; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(430px, calc(100% - 44px));
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: white;
  background: #0a1c40;
  box-shadow: var(--shadow);
  line-height: 1.45;
}
.toast.error { border-color: rgba(255,95,122,.55); background: #401021; }
.toast.success { border-color: rgba(57,217,138,.45); background: #0a3826; }

.site-footer {
  min-height: 74px;
  padding: 18px clamp(18px, 4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 13px;
}
.site-footer div { display: flex; gap: 16px; }
.site-footer a:hover { color: white; }

.hidden { display: none !important; }

@media (max-width: 980px) {
  .auth-layout { grid-template-columns: 1fr; padding-top: 48px; }
  .portal-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: 5px;
  }
  .account-summary { min-width: 210px; margin: 0; padding: 6px 12px 6px 4px; border: 0; }
  .side-link { width: auto; min-width: max-content; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 680px) {
  main { width: min(100% - 20px, 1280px); }
  .site-header { min-height: 68px; padding-inline: 12px; }
  .brand img { width: 90px; }
  .top-nav a, .health-pill { display: none; }
  .auth-layout { padding: 38px 0; }
  .auth-intro h1 { font-size: 43px; }
  .form-grid, .campaign-grid, .detail-grid, .analytics-grid, .metric-grid { grid-template-columns: 1fr; }
  .field-span { grid-column: auto; }
  .section-heading, .panel-heading, .inline-form, .site-footer { align-items: stretch; flex-direction: column; }
  .details-list > div { grid-template-columns: 1fr; gap: 4px; }
  .panel { padding: 18px; }
}


/* Phase 5 analytics hardening */
.analytics-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) minmax(320px, 1.5fr) auto;
  gap: 14px;
  align-items: end;
  margin: 20px 0 10px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: rgba(0, 0, 0, .17);
}

.analytics-date-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.analytics-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 1px;
}

.analytics-period-label {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.analytics-section {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 17px;
  background: rgba(255, 255, 255, .025);
}

.analytics-section h4 {
  margin: 0 0 14px;
  color: #eaf5ff;
  font-size: 16px;
}

.analytics-table-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.data-quality {
  margin: 18px 0;
  padding: 13px 15px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.55;
}

.data-quality.healthy {
  color: #dfffee;
  border: 1px solid rgba(57, 217, 138, .4);
  background: rgba(57, 217, 138, .08);
}

.data-quality.warning {
  color: #fff2c9;
  border: 1px solid rgba(255, 200, 87, .4);
  background: rgba(255, 200, 87, .08);
}

@media (max-width: 900px) {
  .analytics-toolbar,
  .analytics-table-grid {
    grid-template-columns: 1fr;
  }

  .analytics-toolbar-actions {
    padding-bottom: 0;
  }
}

@media (max-width: 560px) {
  .analytics-date-fields,
  .analytics-toolbar-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}

/* Phase 6C-A/B: live-funding and account-security additions */
.inline-link {
  color: #8fc9ff;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.status-test,
.status-internal {
  background: rgba(116, 164, 255, 0.14);
  border-color: rgba(116, 164, 255, 0.36);
  color: #b9d4ff;
}
.status-live {
  background: rgba(72, 213, 151, 0.14);
  border-color: rgba(72, 213, 151, 0.38);
  color: #9ff0c8;
}
.status-verified,
.status-enabled,
.status-available {
  background: rgba(72, 213, 151, 0.14);
  border-color: rgba(72, 213, 151, 0.38);
  color: #9ff0c8;
}
.status-not-verified,
.status-not-enabled,
.status-blocked,
.status-restricted {
  background: rgba(255, 191, 71, 0.12);
  border-color: rgba(255, 191, 71, 0.38);
  color: #ffd98d;
}
#fundingPolicyPanel .details-list dd {
  overflow-wrap: anywhere;
}


/* Phase 7 Lite campaign fields */
.field-help { margin: 6px 0 0; color: var(--muted, #667085); font-size: 0.82rem; line-height: 1.45; }
.feature-check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; }
.poll-builder { padding: 16px; border: 1px solid rgba(16, 185, 129, .25); border-radius: 14px; background: rgba(16, 185, 129, .04); }
.form-grid textarea { width: 100%; box-sizing: border-box; resize: vertical; }

/* Phase 7 Campaign Lifecycle Management v0.7.2 */
.campaign-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 16px 18px;
}
.campaign-toolbar > div:first-child { min-width: 220px; }
.campaign-toolbar-summary { display: grid; gap: 4px; text-align: right; }
.campaign-toolbar-summary span { color: var(--muted); font-size: 12px; }
.campaign-card-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.campaign-card.campaign-archived { opacity: .82; border-style: dashed; }
.status-archived { color: #b7c4dc; background: rgba(183,196,220,.1); }
.status-changes-pending-review { color: var(--yellow); background: rgba(255,200,87,.1); }
@media (max-width: 720px) {
  .campaign-toolbar { align-items: stretch; flex-direction: column; }
  .campaign-toolbar-summary { text-align: left; }
}

/* Phase 8 native livestream onboarding and legal links */
.legal-confirmation { padding: 14px 16px; border: 1px solid rgba(0,221,255,.25); border-radius: 14px; background: rgba(0,119,255,.06); }
.stream-steps { margin: 12px 0 18px; color: var(--muted); line-height: 1.65; }
.stream-steps li { margin-bottom: 7px; }
.credential-row dd { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.credential-value { overflow-wrap: anywhere; word-break: break-all; }
.credential-sensitive { color: #ffd98d; }
.native-live-instructions { grid-column: 1 / -1; margin-top: 8px; padding: 13px 15px; border: 1px solid rgba(0,221,255,.22); border-radius: 13px; background: rgba(0,119,255,.06); color: var(--muted); line-height: 1.55; }
@media (max-width:680px){.credential-row dd{justify-content:flex-start}.copy-credential{width:100%}}

.audience-growth-list{display:grid;gap:8px}.audience-growth-row{display:grid;grid-template-columns:minmax(100px,1fr) repeat(3,minmax(70px,.6fr));gap:10px;padding:10px 12px;border:1px solid var(--border);border-radius:12px;background:rgba(6,16,34,.6)}.audience-growth-row span:not(:first-child){text-align:right}.growth-positive{color:#63e6be}.growth-negative{color:#ff8787}@media(max-width:650px){.audience-growth-row{grid-template-columns:1fr 1fr}.audience-growth-row span:not(:first-child){text-align:left}}
