:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --text: #25211c;
  --muted: #6c6257;
  --line: #e6ded3;
  --brand: #d66a3d;
  --brand-dark: #a94925;
  --ok: #207f55;
  --warn: #a15c00;
  --danger: #ad3434;
  --shadow: 0 20px 45px rgba(72, 53, 34, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(214, 106, 61, 0.13), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.55;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid rgba(230, 222, 211, 0.85);
  background: rgba(247, 244, 239, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 750;
}

.brand-mark {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border-radius: 0.85rem;
  background: var(--brand);
  color: white;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill,
.notification-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0.45rem 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.notification-pill.has-unread {
  border-color: rgba(214, 106, 61, 0.4);
  background: #fff3ed;
  color: var(--brand-dark);
  font-weight: 700;
}

.button {
  border: 0;
  border-radius: 0.8rem;
  padding: 0.72rem 1rem;
  font-weight: 750;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 10px 20px rgba(214, 106, 61, 0.22);
}

.button.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.button.danger {
  background: #fff1f1;
  color: var(--danger);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(20rem, 0.75fr);
  gap: 1.25rem;
  align-items: stretch;
}

.hero,
.card {
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.hero {
  padding: clamp(1.5rem, 4vw, 3rem);
}

.card {
  padding: 1.15rem;
}

.kicker {
  margin: 0 0 0.45rem;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.16;
}

h1 {
  max-width: 52rem;
  font-size: clamp(2rem, 5vw, 4.15rem);
  letter-spacing: -0.055em;
}

h2 {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  letter-spacing: -0.025em;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0.65rem 0 0;
  color: var(--muted);
}

.hero-copy {
  max-width: 46rem;
  margin-top: 1rem;
  font-size: 1.08rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface-soft);
  padding: 0.9rem;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  margin-top: 0.2rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.auth-actions,
.row-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.notice {
  border: 1px solid #f0d6b4;
  border-radius: 1rem;
  background: #fff7ea;
  padding: 0.85rem;
  color: #6e4100;
}

.notice.ok {
  border-color: #bfe4cf;
  background: #f0fff7;
  color: #185c3d;
}

.notice.error {
  border-color: #f0c7c7;
  background: #fff4f4;
  color: var(--danger);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  width: 100%;
  max-width: none;
  padding: 2rem;
  gap: 1.25rem;
  align-items: start;
}

.dashboard-grid > .stack:first-child {
  min-width: 0;
}

.dashboard-grid > aside {
  position: sticky;
  top: 5.5rem;
}

.dashboard-grid .hero {
  width: 100%;
}

.section-list,
.submission-list,
.notification-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.section-card,
.submission-card,
.notification-card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface-soft);
  padding: 1rem;
}

.section-card ul,
.checklist {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.section-card li + li,
.checklist li + li {
  margin-top: 0.35rem;
}

.form-field {
  display: grid;
  gap: 0.4rem;
  margin-top: 1rem;
}

.form-field label {
  font-weight: 750;
}

textarea {
  min-height: 9rem;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: white;
  padding: 0.85rem;
  color: var(--text);
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(214, 106, 61, 0.28);
  outline-offset: 2px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: white;
  padding: 0.75rem 0.85rem;
  color: var(--text);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  border-radius: 999px;
  padding: 0.28rem 0.58rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.status.submitted {
  background: #fff3dc;
  color: var(--warn);
}

.status.approved {
  background: #e9f8f0;
  color: var(--ok);
}

.status.needs_changes {
  background: #fff1f1;
  color: var(--danger);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.evidence {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-top: 0.75rem;
  border-left: 3px solid var(--line);
  padding-left: 0.8rem;
  color: var(--text);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 1rem;
  padding: 1rem;
  color: var(--muted);
}

.loading {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--muted);
}

/* Challenge portal — desktop-first, inspired by the reference product. */
.portal-layout {
  display: grid;
  grid-template-columns: 238px minmax(620px, 1fr) 300px;
  min-height: calc(100vh - 65px);
  background: #fff;
}

.portal-sidebar {
  position: sticky;
  top: 65px;
  height: calc(100vh - 65px);
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--line);
  background: #f4f1ec;
}

.workspace-name {
  margin: 0 0 2.25rem;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 800;
}

.nav-label {
  margin: 0 0 0.55rem;
  color: #8a8178;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.portal-nav {
  display: grid;
  gap: 0.3rem;
}

.portal-nav span {
  padding: 0.7rem 0.8rem;
  border-radius: 0.65rem;
  color: #645c54;
  font-size: 0.9rem;
  font-weight: 600;
}

.portal-nav .active {
  background: #fbe7dc;
  color: var(--brand-dark);
}

.sidebar-login {
  position: absolute;
  right: 1rem;
  bottom: 1.5rem;
  left: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: #fff;
}

.sidebar-login p { font-size: 0.8rem; }

.challenge-home {
  padding: 2.5rem 2rem;
  border-right: 1px solid var(--line);
}

.challenge-heading h1 {
  max-width: none;
  font-size: 2rem;
  letter-spacing: -0.035em;
}

.challenge-heading > p:last-child {
  margin-top: 0.2rem;
  font-size: 0.9rem;
}

.challenge-card {
  width: min(100%, 390px);
  margin-top: 1.5rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: #fff;
  box-shadow: 0 12px 35px rgba(55, 39, 23, 0.07);
}

.challenge-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.challenge-icon {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  border-radius: 0.7rem;
  background: var(--brand);
  color: #fff;
  font-weight: 850;
}

.status-live {
  border-radius: 999px;
  background: #e9f8f0;
  padding: 0.3rem 0.6rem;
  color: var(--ok);
  font-size: 0.72rem;
  font-weight: 800;
}

.challenge-card h2 {
  font-size: 1.2rem;
  line-height: 1.35;
}

.goal-box {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.9rem;
  padding: 0.8rem;
  border-radius: 0.65rem;
  background: #faf6f2;
}

.goal-box small {
  color: #8a8178;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.goal-box strong { color: var(--brand-dark); font-size: 0.88rem; }
.challenge-description { font-size: 0.85rem; }

.challenge-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 1rem;
}

.challenge-stats .metric {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.challenge-cta {
  display: block;
  width: 100%;
  margin-top: 1rem;
  text-align: center;
}

.text-button {
  width: 100%;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.portal-rail {
  display: grid;
  align-content: start;
  gap: 0.8rem;
  padding: 1rem;
  background: #fbfaf8;
}

.profile-card,
.rail-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: #fff;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-card p { margin-top: 0.1rem; font-size: 0.78rem; }

.profile-avatar {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  border-radius: 50%;
  background: #f5e7ff;
  color: #6c35a2;
  font-weight: 800;
}

.rail-progress {
  position: relative;
  height: 0.45rem;
  margin: 1rem 0 0.75rem;
  border-radius: 999px;
  background: #eee9e4;
}

.rail-progress span {
  position: absolute;
  top: -1.65rem;
  right: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.rail-progress i { display: block; width: 0; height: 100%; background: var(--brand); }
.rail-card small { color: var(--muted); }
.rail-list { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.82rem; }
.rail-list li + li { margin-top: 0.55rem; }

.auth-card {
  margin-top: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: rgba(255, 255, 255, 0.78);
  padding: 1rem;
}

.auth-tabs {
  display: inline-flex;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 0.25rem;
}

.tab-button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0.45rem 0.85rem;
  color: var(--muted);
  font-weight: 800;
}

.tab-button.active {
  background: var(--brand);
  color: white;
}

.auth-form {
  margin-top: 0.2rem;
}

.helper-text {
  font-size: 0.9rem;
}

.sop-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 1rem;
}

.sop-chip {
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.7rem;
  background: var(--surface-soft);
}

.sop-chip strong {
  font-size: 0.9rem;
}

.sop-chip span {
  color: var(--muted);
  font-size: 0.78rem;
}

.sop-chip.open {
  border-color: rgba(32, 127, 85, 0.25);
  background: #f0fff7;
}

.sop-chip.locked {
  opacity: 0.58;
}

.user-access-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.user-access-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(25rem, 0.8fr);
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface-soft);
  padding: 1rem;
}

.user-access-card.admin-account {
  grid-template-columns: 1fr;
}

.meta-line {
  margin-top: 0.2rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.access-form {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) 6rem auto;
  gap: 0.55rem;
  align-items: center;
}

@media (max-width: 1100px) {
  .portal-layout { grid-template-columns: 210px minmax(600px, 1fr); }
  .portal-rail { display: none; }
}

@media (max-width: 860px) {
  .login-layout,
  .dashboard-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand {
    min-width: 10rem;
  }
}

@media (max-width: 520px) {
  .container {
    width: min(100% - 1rem, 1180px);
    padding-top: 1rem;
  }

  .hero,
  .card {
    border-radius: 1rem;
  }

  .topbar-actions,
  .auth-actions,
  .row-actions {
    width: 100%;
  }

  .button {
    width: 100%;
  }
}
