:root {
  --bg: #f5f5f4;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.shell {
  width: min(1280px, 94vw);
  margin: 0 auto;
}

.topbar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #0f1117;
}

.topbar-inner {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-layout .topbar-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  gap: 0;
}

.topbar-brand {
  width: 240px;
  flex-shrink: 0;
  padding: 0 0.65rem;
  display: flex;
  align-items: center;
}

.topbar-nav {
  flex: 1;
  min-width: 0;
  max-width: 1200px;
  padding: 0 2rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.brand {
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  color: #f3f4f6;
  letter-spacing: -0.02em;
}

.nav-link,
.link-clean {
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-link:hover,
.link-clean:hover {
  color: #f3f4f6;
}

.portal-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

.portal-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #0f1117;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1rem 0.65rem;
  overflow: auto;
  height: calc(100vh - 56px);
  position: sticky;
  top: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-link,
.sidebar-section summary,
.sidebar-section a,
.sidebar-section span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 6px;
  color: #9ca3af;
  font-size: 0.88rem;
  padding: 0.45rem 0.5rem;
  text-decoration: none;
  transition: background 100ms ease, color 100ms ease;
}

.sidebar-link,
.sidebar-section a {
  color: #e5e7eb;
  font-weight: 500;
}

.sidebar-link:hover,
.sidebar-section a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar-link.active,
.sidebar-section a.active {
  background: rgba(59, 130, 246, 0.16);
  color: #fff;
}

.sidebar-section {
  margin-top: 0.1rem;
}

.sidebar-section summary {
  color: #6b7280;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  list-style: none;
  text-transform: uppercase;
}

.sidebar-section.active summary {
  color: #d1d5db;
}

.sidebar-section summary::-webkit-details-marker {
  display: none;
}

.sidebar-section summary::after {
  content: "";
  width: 0.35rem;
  height: 0.35rem;
  border-right: 1.5px solid #4b5563;
  border-bottom: 1.5px solid #4b5563;
  transform: translateY(-0.1rem) rotate(45deg);
}

.sidebar-section[open] summary::after {
  transform: translateY(0.1rem) rotate(225deg);
}

.sidebar-section em {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #6b7280;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.08rem 0.35rem;
}

.account-nav {
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.btn-link-muted {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

.portal-content-wrapper {
  flex: 1;
  min-width: 0;
  max-width: 1200px;
  padding: 0 2rem;
}

.portal-content {
  padding: 1.5rem 0 3rem;
}

.dash-shell {
  display: grid;
  gap: 1.25rem;
}

.dash-header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.health-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
}

.section-eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dash-header p,
.muted {
  color: var(--muted);
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.sync-card {
  min-width: 230px;
  border-radius: 10px;
  background: #f0f9ff;
  padding: 1rem;
}

.sync-card span,
.sync-card small {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.sync-card strong {
  display: block;
  margin: 0.2rem 0;
  color: var(--ink);
  font-size: 1.05rem;
}

.metric-overview-grid,
.mock-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.metric-overview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  min-height: 140px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 1rem;
}

.metric-card-featured {
  border-color: #bfdbfe;
  background: #f0f9ff;
}

.metric-card-mock {
  background: var(--panel);
}

.metric-card-header {
  display: grid;
  gap: 0.15rem;
}

.metric-card-header span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric-card-header strong {
  color: var(--ink);
  font-size: 1rem;
}

.metric-value {
  margin: 1rem 0 0.35rem;
  color: var(--ink);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.metric-card-link {
  display: inline-flex;
  margin-top: 0.5rem;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.88rem;
  text-decoration: none;
}

.metric-card-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.health-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.health-entry-panel {
  display: grid;
  align-content: start;
  gap: 0.4rem;
}

.health-form {
  display: grid;
  gap: 1rem;
  margin-top: 0.75rem;
}

.health-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.compact-submit {
  max-width: 220px;
}

.sleep-stage-bars {
  display: flex;
  align-items: stretch;
  min-height: 40px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
}

.sleep-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
}

.sleep-stage-awake {
  background: #f59e0b;
}

.sleep-stage-light {
  background: #06b6d4;
}

.sleep-stage-deep {
  background: #3b82f6;
}

.sleep-stage-rem {
  background: #8b5cf6;
}

.sleep-summary-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1rem 0 0;
}

.sleep-summary-list div {
  border-radius: 8px;
  background: var(--panel);
  padding: 0.7rem;
}

.sleep-summary-list dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sleep-summary-list dd {
  margin: 0.2rem 0 0;
  font-weight: 600;
}

.mock-metrics-section {
  display: grid;
  gap: 1rem;
}

.compact-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.inline-form {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  width: 100%;
}

.btn-primary {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 0.65rem 0.95rem;
  white-space: nowrap;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-link-danger {
  border: 0;
  background: transparent;
  color: var(--danger);
}

.alert-box {
  border: 1px dashed var(--muted);
  border-radius: 10px;
  background: var(--panel);
  padding: 0.8rem;
}

.verification-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #f0f9ff;
  color: #1e40af;
  padding: 0.8rem 1rem;
}

.verification-banner div {
  display: grid;
  gap: 0.15rem;
}

.verification-banner strong {
  color: var(--ink);
}

.verification-banner span {
  font-size: 0.92rem;
}

.verification-banner form {
  margin: 0;
}

.verification-banner button,
.account-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0.62rem 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}

.verification-banner button:hover,
.account-action:hover {
  background: var(--accent-hover);
  color: #fff;
}

.table-min {
  width: 100%;
  border-collapse: collapse;
}

.table-min th,
.table-min td {
  text-align: left;
  padding: 0.7rem 0.4rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.auth-body {
  min-height: 100vh;
  background: var(--bg);
}

.auth-shell {
  min-height: 100vh;
  width: min(100%, 1120px);
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: clamp(1.25rem, 4vw, 3rem);
}

.auth-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

.auth-wordmark {
  width: fit-content;
  margin-bottom: 2.1rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-header {
  margin-bottom: 1.75rem;
}

.auth-eyebrow {
  margin: 0 0 0.6rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 7vw, 2.65rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.auth-header p:not(.auth-eyebrow) {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.auth-field {
  display: grid;
  gap: 0.45rem;
}

.auth-field label,
.auth-check {
  color: #374151;
  font-size: 0.92rem;
  font-weight: 600;
}

.auth-field input {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0.85rem 1rem;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.auth-field input:focus {
  outline: 0;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.auth-field input::placeholder {
  color: #9ca3af;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  width: fit-content;
  margin: 0.15rem 0 0.25rem;
  cursor: pointer;
}

.auth-forgot {
  width: fit-content;
  margin-top: -0.35rem;
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.auth-forgot:hover {
  text-decoration: underline;
}

.auth-check input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.auth-submit {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
}

.auth-submit:hover {
  background: var(--accent-hover);
}

.auth-submit:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.2);
  outline-offset: 3px;
}

.auth-switch {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.auth-switch a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-notice {
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #f0f9ff;
  color: #1e40af;
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 0.9rem 1rem;
}

.auth-validation,
.auth-error,
.field-validation-error {
  color: var(--danger);
  font-size: 0.88rem;
}

.auth-validation ul {
  margin: 0;
  padding-left: 1.1rem;
}

.auth-validation:empty,
.auth-error:empty,
.field-validation-valid {
  display: none;
}

.account-shell {
  display: grid;
  gap: 1.25rem;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 1rem;
}

.account-profile-card h2,
.account-form-panel h2 {
  margin-top: 0;
}

.account-details {
  display: grid;
  gap: 0.85rem;
  margin: 1rem 0 0;
}

.account-details div {
  display: grid;
  gap: 0.2rem;
}

.account-details dt {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-details dd {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
}

.account-form-panel {
  max-width: 520px;
}

@media (max-width: 900px) {
  .portal-layout {
    flex-direction: column;
    min-height: auto;
  }

  .portal-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.75rem;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .sidebar-link {
    flex: 0 0 auto;
  }

  .sidebar-section {
    flex: 1 1 auto;
    min-width: 120px;
  }

  .portal-content-wrapper {
    max-width: none;
    padding: 0 1rem;
  }

  .health-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .metric-overview-grid,
  .mock-metric-grid,
  .health-workspace {
    grid-template-columns: 1fr;
  }

  .health-form-grid,
  .sleep-summary-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-form {
    flex-direction: column;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .verification-banner {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .topbar-inner,
  .account-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-layout .topbar-inner {
    flex-direction: row;
  }

  .topbar-brand {
    width: auto;
    padding: 0 0.85rem;
  }

  .topbar-nav {
    padding: 0 1rem;
  }

  .portal-sidebar {
    max-height: 40vh;
    overflow: auto;
  }

  .sidebar-nav {
    flex-direction: column;
  }

  .portal-content {
    padding: 1rem 0;
  }

  .account-nav {
    margin-left: 0;
  }

  .health-form-grid,
  .sleep-summary-list {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    align-items: start;
    padding: 1rem;
  }

  .auth-card {
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  }

  .auth-wordmark {
    margin-bottom: 1.5rem;
  }
}
