:root {
  color: #172036;
  background: #f4f7fb;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body { margin: 0; }

button, input, select, textarea { font: inherit; }

button {
  border: 0;
  border-radius: 8px;
  background: #1e4ed8;
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: .7rem 1rem;
}

button:hover { background: #163aa8; }
button:disabled { cursor: wait; opacity: .65; }
.button-secondary { background: #e6ebf5; color: #23365e; }
.button-secondary:hover { background: #d7dfed; }
.button-row { align-items: center; display: flex; flex-wrap: wrap; gap: .55rem; }
.button-link { background: #edf3ff; border-radius: 8px; color: #1748a2; font-weight: 700; padding: .58rem .8rem; text-decoration: none; }

.app-shell { margin: 0 auto; max-width: 1120px; padding: 2rem 1.25rem 4rem; }

.hero {
  align-items: center;
  background: linear-gradient(135deg, #172a58, #1e4ed8);
  border-radius: 18px;
  color: white;
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  padding: 2.5rem;
}

.hero-copy { max-width: 680px; }
.hero h1, h2, h3, p { margin-top: 0; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); margin-bottom: .5rem; }
.hero p:last-child { color: #dbeafe; font-size: 1.1rem; margin-bottom: 0; max-width: 680px; }

.logo-card {
  background: white;
  border-radius: 14px;
  box-shadow: 0 18px 48px #0716314d;
  overflow: hidden;
  padding: .5rem;
}

.logo-card img { display: block; height: auto; width: 100%; }

.eyebrow { color: #4d68a5; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.hero .eyebrow { color: #bfdbfe; }

.notice {
  background: #e9f6ed;
  border-left: 4px solid #17864a;
  border-radius: 8px;
  color: #135f36;
  margin: 1.25rem 0;
  padding: 1rem;
}

.auth-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1.25rem; }
.auth-card { padding: 1.75rem; }
.sso-login { border-top: 1px solid #e3e8f2; margin-top: 1rem; padding-top: 1rem; }
.account-bar { align-items: center; background: white; border: 1px solid #e3e8f2; border-radius: 10px; display: flex; justify-content: space-between; margin-top: 1.25rem; padding: .85rem 1rem; }
.account-bar > div:first-child { display: grid; }
.account-bar span { color: #60708d; font-size: .86rem; }
.account-actions { align-items: center; display: flex; gap: .7rem; }
.domain-panel { margin-bottom: 1rem; }
.domain-row { align-items: center; background: #f6f8fc; border-radius: 9px; display: flex; gap: 1rem; justify-content: space-between; padding: 1rem; }
.domain-row > div { display: grid; gap: .3rem; }
.domain-row span { color: #60708d; font-size: .9rem; }
.domain-row code, .activation-result code { background: #e8eefb; border-radius: 5px; color: #173a79; overflow-wrap: anywhere; padding: .35rem .5rem; }
.verified-text { color: #17864a !important; font-weight: 700; }
.inline-form { display: grid; gap: .5rem; grid-template-columns: 1fr auto auto; }
.lower-workspace { margin-top: 1.25rem; }
.activation-result { background: #edf4ff; border: 1px solid #bed3fa; border-radius: 8px; display: grid; gap: .4rem; margin: 1rem 0; padding: .85rem; }
.activation-result a { color: #1748a2; overflow-wrap: anywhere; }
.compact-list { max-height: 310px; overflow: auto; }
.global-status { bottom: 1rem; color: #146c3b; margin: 0; position: fixed; right: 1rem; }
.global-status:not(:empty) { background: white; border: 1px solid #c8d2e4; border-radius: 8px; box-shadow: 0 8px 28px #17203624; padding: .7rem 1rem; }
.global-status.error { color: #b42318; }
.import-box { border-top: 1px solid #e3e8f2; margin-top: 1rem; padding-top: .8rem; }
.import-box summary { color: #1748a2; cursor: pointer; font-weight: 700; margin-bottom: .75rem; }
.security-block { display: grid; gap: .4rem; margin: .75rem 0; }
.security-block code, .security-block span { overflow-wrap: anywhere; }
.template-workspace { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); }
.template-preview { background: white; border: 1px solid #d6ddea; border-radius: 8px; height: 330px; width: 100%; }
.safety-note { background: #e9f6ed; border-radius: 8px; color: #135f36; font-size: .88rem; margin: 1rem 0 0; padding: .75rem; }

.learning-shell { margin: 0 auto; max-width: 860px; padding: 2rem 1.25rem 4rem; }
.learning-header { align-items: center; display: grid; gap: 1.5rem; grid-template-columns: 190px 1fr; margin-bottom: 1.25rem; }
.learning-header img { background: white; border-radius: 12px; box-shadow: 0 8px 28px #1720361f; height: auto; width: 100%; }
.learning-header h1 { color: #172a58; font-size: clamp(1.8rem, 5vw, 2.8rem); margin-bottom: .35rem; }
.learning-header p:last-child { color: #60708d; }
.lesson { padding: 1.75rem; }
.lesson-points { display: grid; gap: .8rem; padding-left: 1.4rem; }
.lesson-points li { background: #f6f8fc; border-radius: 8px; padding: .75rem; }
.lesson-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.success-message { color: #146c3b; font-weight: 700; }
.error-panel { border-left: 4px solid #b42318; }

.summary { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 1.5rem 0; }
.metric { background: #eef3ff; border-radius: 9px; display: grid; gap: .15rem; padding: .75rem; }
.summary > .metric { background: white; box-shadow: 0 4px 18px #17203612; padding: 1rem; }
.metric strong { color: #172a58; font-size: 1.4rem; }
.metric span { color: #52607a; font-size: .86rem; }

.workspace { display: grid; gap: 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1.25rem; }
.panel { background: white; border: 1px solid #e3e8f2; border-radius: 12px; padding: 1.4rem; }
.panel h2 { color: #172a58; font-size: 1.25rem; }

.stacked-form { display: grid; gap: .85rem; }
.stacked-form label { display: grid; font-weight: 700; gap: .35rem; }
.stacked-form .terms-check { align-items: start; display: grid; font-size: .88rem; font-weight: 500; gap: .55rem; grid-template-columns: auto 1fr; }
.terms-check input { margin-top: .25rem; }
.terms-check a { color: #1748a2; }
input, select { border: 1px solid #b9c4d8; border-radius: 7px; padding: .6rem .7rem; }
textarea { border: 1px solid #b9c4d8; border-radius: 7px; min-height: 7rem; padding: .6rem .7rem; resize: vertical; }
input:focus, select:focus { border-color: #1e4ed8; outline: 3px solid #bfdbfe; }

fieldset { border: 1px solid #d6ddea; border-radius: 8px; min-width: 0; padding: .75rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.recipient-options { display: grid; gap: .45rem; max-height: 140px; overflow: auto; }
.recipient-choice { align-items: center; display: flex !important; font-size: .92rem; font-weight: 500 !important; }

.data-list { display: grid; gap: .6rem; list-style: none; margin: 1.25rem 0 0; padding: 0; }
.data-list li { align-items: center; background: #f6f8fc; border-radius: 8px; display: grid; gap: .35rem; padding: .7rem; }
.data-list li > button { justify-self: start; margin-top: .3rem; }
.member-actions { align-items: center; display: flex; gap: .5rem; }
.data-list li:has(.member-actions) { align-items: center; grid-template-columns: 1fr auto; }
.data-list span { color: #52607a; font-size: .85rem; }
.empty { color: #66738d; font-style: italic; }

.section-heading { align-items: flex-start; display: flex; justify-content: space-between; }
.section-heading h2 { margin-bottom: 0; }
#status { color: #17864a; font-size: .9rem; max-width: 300px; text-align: right; }
#status.error { color: #b42318; }

.campaign-list { display: grid; gap: .9rem; }
.campaign { align-items: start; border: 1px solid #dce3ef; border-radius: 10px; display: grid; gap: 1rem; grid-template-columns: 1fr auto; padding: 1rem; }
.campaign h3 { color: #172a58; margin-bottom: .2rem; }
.campaign p { color: #52607a; margin-bottom: 0; }
.badge { border-radius: 999px; font-size: .78rem; font-weight: 800; padding: .35rem .65rem; }
.badge.draft { background: #fff3cf; color: #815d00; }
.badge.active, .badge.closed { background: #dff5e7; color: #146c3b; }
.campaign-metrics { display: grid; gap: .5rem; grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.campaign button { justify-self: start; }

@media (max-width: 760px) {
  .summary, .workspace, .auth-grid, .template-workspace { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; padding: 1.6rem; }
  .campaign { grid-template-columns: 1fr; }
  .campaign-metrics { grid-template-columns: 1fr; }
  #status { text-align: left; }
  .section-heading { display: grid; gap: .5rem; }
  .account-bar, .domain-row { align-items: stretch; display: grid; }
  .inline-form { grid-template-columns: 1fr; }
  .learning-header { grid-template-columns: 1fr; }
  .learning-header img { max-width: 220px; }
}

/* Modern application shell */
:root {
  --ink: #13213c;
  --muted: #68758d;
  --line: #e6eaf1;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --primary: #2457e6;
  --primary-dark: #173eb2;
  --success: #15945d;
  --sidebar: #0f1d3d;
  color: var(--ink);
  background: #f4f6fa;
}

html { scroll-behavior: smooth; }
body { min-width: 320px; }
body.is-authenticated { background: #f4f6fa; }
body.is-authenticated .app-shell { margin: 0; max-width: none; padding: 0; }
body.is-authenticated .hero, body.is-authenticated #auth-view { display: none !important; }

.dashboard-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  background: linear-gradient(180deg, #101f43 0%, #0b1732 100%);
  color: #dce6ff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 1.35rem 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.sidebar-brand {
  align-items: center;
  color: white;
  display: flex;
  gap: .75rem;
  padding: .25rem .45rem 1.7rem;
  text-decoration: none;
}
.sidebar-brand img {
  background: white;
  border-radius: 11px;
  height: 42px;
  object-fit: cover;
  object-position: center 32%;
  width: 42px;
}
.sidebar-brand span { display: grid; line-height: 1.1; }
.sidebar-brand strong { font-size: 1rem; letter-spacing: -.01em; }
.sidebar-brand small { color: #8fa5d3; font-size: .67rem; margin-top: .28rem; text-transform: uppercase; }

.sidebar-nav { display: grid; gap: .35rem; }
.sidebar-nav a {
  align-items: center;
  border-radius: 10px;
  color: #aebddd;
  display: flex;
  font-size: .88rem;
  font-weight: 650;
  gap: .7rem;
  padding: .72rem .78rem;
  text-decoration: none;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-nav a:hover { background: #ffffff12; color: white; transform: translateX(2px); }
.sidebar-nav a.active { background: linear-gradient(135deg, #2f62ee, #2451d3); box-shadow: 0 8px 24px #07122f66; color: white; }
.nav-icon { display: inline-grid; font-size: 1.05rem; place-items: center; width: 22px; }
.sidebar-footer {
  align-items: center;
  border-top: 1px solid #ffffff17;
  color: #8fa5d3;
  display: flex;
  font-size: .72rem;
  gap: .55rem;
  margin-top: auto;
  padding: 1rem .45rem .25rem;
}
.status-dot { background: #2bd387; border-radius: 50%; box-shadow: 0 0 0 4px #2bd3871f; display: inline-block; height: 8px; width: 8px; }

.dashboard-main { min-width: 0; padding-bottom: 4rem; }
.account-bar {
  align-items: center;
  backdrop-filter: blur(16px);
  background: #f4f6fae8;
  border: 0;
  border-bottom: 1px solid #e5e9f1;
  border-radius: 0;
  display: flex;
  justify-content: space-between;
  margin: 0;
  min-height: 76px;
  padding: .85rem clamp(1rem, 3vw, 2.5rem);
  position: sticky;
  top: 0;
  z-index: 30;
}
.account-identity { display: grid; line-height: 1.25; }
.account-identity strong { font-size: 1.05rem; }
.account-identity > span:last-child { color: var(--muted); font-size: .78rem; }
.account-kicker { color: #8994a8 !important; font-size: .66rem !important; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.icon-button { background: white; border: 1px solid var(--line); color: var(--ink); display: none; font-size: 1.1rem; height: 42px; padding: 0; width: 42px; }
.account-actions { align-items: center; display: flex; gap: .7rem; }

.page-section {
  margin: 0 auto 1.15rem;
  max-width: 1320px;
  scroll-margin-top: 96px;
  width: calc(100% - clamp(2rem, 6vw, 5rem));
}
.dashboard-overview { padding-top: 2rem; }
.page-heading { align-items: center; display: flex; justify-content: space-between; margin-bottom: 1.25rem; }
.page-heading h1 { font-size: clamp(1.55rem, 2.5vw, 2.15rem); letter-spacing: -.035em; margin: .15rem 0 0; }
.live-chip { align-items: center; background: #e8f8f0; border-radius: 999px; color: #147a4e; display: inline-flex; font-size: .76rem; font-weight: 700; gap: .5rem; padding: .48rem .72rem; }

.notice {
  align-items: center;
  background: linear-gradient(90deg, #eaf8f1, #f2fbf7);
  border: 1px solid #d5efe1;
  border-left: 0;
  border-radius: 12px;
  color: #236345;
  display: flex;
  font-size: .86rem;
  gap: .7rem;
  margin: 0 0 1rem;
  padding: .82rem 1rem;
}
.notice-icon { background: var(--success); border-radius: 50%; color: white; display: inline-grid; flex: 0 0 auto; font-size: .75rem; height: 24px; place-items: center; width: 24px; }

.summary { gap: .85rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 1rem; }
.summary > .metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px #18366d0a;
  gap: .25rem;
  min-height: 104px;
  padding: 1.1rem 1.15rem;
  position: relative;
  transition: transform .18s ease, box-shadow .18s ease;
}
.summary > .metric:hover { box-shadow: 0 13px 34px #18366d16; transform: translateY(-2px); }
.summary > .metric::after { background: #2d5ce8; border-radius: 99px; content: ""; height: 4px; left: 1.15rem; position: absolute; top: 0; width: 34px; }
.summary > .metric:nth-child(2)::after { background: #19a974; }
.summary > .metric:nth-child(3)::after { background: #f4a523; }
.summary > .metric:nth-child(4)::after { background: #8b5cf6; }
.metric strong { font-size: 1.65rem; letter-spacing: -.03em; }

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 30px #18366d0a;
  padding: 1.4rem;
}
.panel h2 { font-size: 1.12rem; letter-spacing: -.015em; }
.domain-panel { margin-bottom: 0; }
.domain-row { background: var(--surface-soft); border: 1px solid #edf0f5; }

.workspace { gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1.15rem; }
.settings-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-grid > .workspace { grid-column: 1 / -1; margin: 0; width: 100%; }
.settings-grid > #platform-panel { grid-column: 1 / -1; }

button, .button-link {
  align-items: center;
  background: linear-gradient(135deg, #2f62ee, var(--primary));
  border: 1px solid transparent;
  border-radius: 9px;
  box-shadow: 0 5px 14px #2457e625;
  display: inline-flex;
  justify-content: center;
  min-height: 40px;
  padding: .58rem .9rem;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
button:hover, .button-link:hover { background: linear-gradient(135deg, #2457e6, #173eb2); box-shadow: 0 8px 18px #2457e638; transform: translateY(-1px); }
button:active, .button-link:active { transform: translateY(0); }
.button-secondary { background: white; border-color: #dfe4ed; box-shadow: none; color: #31405b; }
.button-secondary:hover { background: #f3f6fa; box-shadow: none; }

input, select, textarea {
  background: #fff;
  border: 1px solid #dce2ec;
  border-radius: 9px;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: #4f75e9; box-shadow: 0 0 0 4px #2457e612; outline: 0; }
.stacked-form { gap: .78rem; }
.stacked-form label { color: #33415c; font-size: .83rem; }
fieldset { background: #fafbfe; border-color: #e4e8f0; }

.template-workspace { gap: 1rem; }
.template-preview { border-color: var(--line); border-radius: 12px; }
.safety-note { border: 1px solid #d5efe1; }

.data-list li { background: #f8f9fc; border: 1px solid #edf0f5; border-radius: 10px; }
.campaign { background: #fff; border-color: var(--line); border-radius: 13px; transition: border-color .16s ease, box-shadow .16s ease; }
.campaign:hover { border-color: #cfd9ef; box-shadow: 0 8px 24px #18366d0d; }
.campaign-metrics .metric { border: 1px solid #e7ebf3; }
.badge { align-items: center; display: inline-flex; white-space: nowrap; }
.badge.active { background: #e3f7ed; color: #147a4e; }

.global-status { bottom: 1.25rem; right: 1.25rem; z-index: 100; }
.global-status:not(:empty) { animation: toast-in .22s ease-out; border: 0; border-left: 4px solid var(--success); border-radius: 10px; box-shadow: 0 16px 44px #1526492b; max-width: min(420px, calc(100vw - 2rem)); }
.global-status.error:not(:empty) { border-left-color: #d23b3b; }

@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes section-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.page-section { animation: section-in .28s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (max-width: 1050px) {
  .dashboard-shell { grid-template-columns: 1fr; }
  .app-sidebar { box-shadow: 16px 0 48px #06112c4d; left: 0; position: fixed; transform: translateX(-105%); transition: transform .22s ease; width: 252px; }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .dashboard-shell::before { background: #07132973; content: ""; inset: 0; opacity: 0; pointer-events: none; position: fixed; transition: opacity .2s ease; z-index: 35; }
  body.sidebar-open .dashboard-shell::before { opacity: 1; pointer-events: auto; }
  .icon-button { display: inline-grid; place-items: center; }
  .account-bar { justify-content: initial; gap: .8rem; }
  .account-actions { margin-left: auto; }
}

@media (max-width: 760px) {
  .account-bar { min-height: 68px; padding: .7rem .85rem; }
  .account-kicker, #account-name { display: none; }
  .account-actions .badge { display: none; }
  #logout-button { font-size: 0; height: 40px; padding: 0; width: 40px; }
  #logout-button::after { content: "↪"; font-size: 1rem; }
  .page-section { width: calc(100% - 1.5rem); }
  .dashboard-overview { padding-top: 1.25rem; }
  .page-heading { align-items: flex-start; gap: .75rem; }
  .page-heading h1 { font-size: 1.5rem; }
  .live-chip { display: none; }
  .summary, .workspace, .settings-grid, .template-workspace { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary > .metric { min-height: 90px; padding: .9rem; }
  .panel { border-radius: 13px; padding: 1rem; }
  .section-heading { align-items: flex-start; display: grid; gap: .55rem; }
  .section-heading > span { font-size: .72rem; overflow-wrap: anywhere; }
}

@media (max-width: 420px) {
  .notice { align-items: flex-start; }
  .button-row > * { flex: 1 1 auto; }
}
