:root {
  --brand: #0f766e;
  --ink: #13201f;
  --muted: #60706d;
  --surface: #ffffff;
  --page: #f6f8f7;
  --border: #dfe7e5;
  --chip: #edf5f3;
  --panel-soft: #f6f8f7;
}

[data-theme="dark"] {
  --brand: #2dd4bf;
  --ink: #edf7f5;
  --muted: #9fb4b0;
  --surface: #17211f;
  --page: #0f1514;
  --border: #2a3a37;
  --chip: #203330;
  --panel-soft: #111c1a;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--brand); }

.app-shell {
  max-width: 760px;
  padding-top: 4.25rem !important;
  padding-bottom: 5.75rem !important;
}

.app-topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1030;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.app-brand,
.profile-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.profile-link {
  color: var(--brand);
  font-size: .95rem;
}

.app-tabbar {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.app-tabbar .nav-link {
  color: var(--ink);
  font-size: .72rem;
  min-width: 4.4rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  font-weight: 700;
}

.app-tabbar .nav-link svg {
  width: 21px;
  height: 21px;
  stroke-width: 2.2;
}

.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: #115e59;
  --bs-btn-hover-border-color: #115e59;
}

.auth-panel {
  min-height: calc(100dvh - 7rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-panel h1,
.eyebrow {
  letter-spacing: 0;
}

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  font-size: .76rem;
  font-weight: 700;
}

.register-flow {
  justify-content: start;
  padding-top: 1rem;
}

.register-slide {
  display: none;
  min-height: 19rem;
}

.register-slide.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric-panel {
  background: linear-gradient(135deg, #0f766e, #155e75);
  color: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  display: grid;
  gap: .35rem;
}

.metric-panel strong {
  font-size: clamp(2.4rem, 14vw, 4rem);
  line-height: 1;
}

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

.dashboard-wide {
  grid-column: 1 / -1;
}

.dashboard-metrics .metric-panel {
  min-width: 0;
}

.dashboard-metrics .metric-panel strong {
  font-size: clamp(1.55rem, 9vw, 2.6rem);
  overflow-wrap: anywhere;
}

.dashboard-metrics .dashboard-wide strong {
  font-size: clamp(2.4rem, 14vw, 4rem);
}

.metric-panel-light {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.metric-panel-light span,
.metric-panel-light small {
  color: var(--muted);
}

.trend-panel {
  gap: .75rem;
}

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

.trend-item {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .45rem;
  min-width: 0;
}

.trend-item strong {
  display: block;
  margin: .15rem 0;
  font-size: clamp(.72rem, 3vw, .95rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.dashboard-metrics .trend-panel .trend-item strong {
  font-size: clamp(.5rem, 2vw, 2.5rem);
  overflow-wrap: normal;
  white-space: nowrap;
}

.trend-item em {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-style: normal;
  font-weight: 700;
  text-transform: capitalize;
}

.trend-good strong {
  color: var(--brand);
}

.trend-bad strong {
  color: #dc2626;
}

.category-scale {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem;
}

.category-scale-bar {
  position: relative;
  display: flex;
  min-height: 3.25rem;
  overflow: hidden;
  border-radius: 8px;
  font-weight: 700;
}

.category-band {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  align-items: end;
  justify-content: center;
  padding: .4rem .2rem;
  font-size: .68rem;
  text-align: center;
}

.category-band em {
  font-style: normal;
  color: color-mix(in srgb, var(--ink) 74%, transparent);
}

.category-band small {
  font-size: .62rem;
  color: color-mix(in srgb, var(--ink) 62%, transparent);
}

.band-1 { background: rgba(14, 165, 233, .2); }
.band-2 { background: rgba(34, 197, 94, .2); }
.band-3 { background: rgba(132, 204, 22, .24); }
.band-4 { background: rgba(245, 158, 11, .24); }
.band-5 { background: rgba(239, 68, 68, .22); }

.category-marker {
  position: absolute;
  inset: 0 auto 0 var(--marker);
  width: 3px;
  background: var(--ink);
  transform: translateX(-50%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--surface) 70%, transparent);
}

.comparison-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem;
}

.goal-category-grid {
  display: grid;
  gap: 1rem;
}

.goal-category-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .55rem .65rem;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.goal-category-row.current-sex {
  border-color: var(--brand);
}

.goal-category-row span {
  color: var(--muted);
}

@media (min-width: 560px) {
  .goal-category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.comparison-table {
  min-width: 420px;
}

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

.quick-action,
.history-item,
.reference-card,
.site-field,
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.quick-action {
  min-height: 5.5rem;
  padding: 1rem;
  display: flex;
  align-items: end;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

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

.more-action {
  min-height: 6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.more-action svg {
  width: 26px;
  height: 26px;
  color: var(--brand);
}

button svg {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  margin-right: .35rem;
}

.site-field {
  padding: 1rem;
}

.formula-guide {
  display: grid;
  gap: .5rem;
}

.formula-guide-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
}

.formula-guide-details summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--brand);
}

.formula-guide-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
  opacity: .68;
}

.formula-guide-item.active {
  border-color: var(--brand);
  box-shadow: inset 4px 0 0 var(--brand);
  opacity: 1;
}

.site-field legend {
  float: none;
  width: auto;
  font-size: 1rem;
  font-weight: 700;
}

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

.reading-grid label {
  font-size: .82rem;
  color: var(--muted);
}

.sticky-action {
  position: static;
  box-shadow: none;
}

.history-item {
  margin: .75rem 0;
  padding: 1rem;
}

.client-actions {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: .35rem;
}

.client-actions form {
  margin: 0 !important;
}

.site-chips {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .6rem;
}

.site-chips span {
  background: var(--chip);
  border-radius: 999px;
  padding: .25rem .55rem;
  font-size: .78rem;
}

.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.data-table {
  min-width: 900px;
  margin-bottom: 0;
}

.flagged-row {
  box-shadow: inset 4px 0 0 #f59e0b;
}

.data-measures {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.data-measures span {
  background: var(--chip);
  border-radius: 999px;
  padding: .2rem .5rem;
  font-size: .78rem;
  white-space: nowrap;
}

.flag-list {
  margin: 0;
  padding-left: 1rem;
  font-size: .82rem;
}

.chart-box {
  height: 320px;
  margin: 0;
  padding: .75rem;
}

.progress-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: .35rem;
  padding-bottom: .2rem;
}

.progress-tabs .nav-link {
  white-space: nowrap;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
}

.progress-tabs .nav-link.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.reference-card {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: .9rem;
  margin: .75rem 0;
  padding: .85rem;
}

.site-image {
  width: 104px;
  height: 148px;
  object-fit: cover;
  border-radius: 8px;
  background: #e8f3ef;
}

.technique-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1rem 1rem 2rem;
}

@media (min-width: 720px) {
  .app-tabbar {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 0;
    width: min(520px, 52vw);
    transform: translateX(-50%);
    border: 0;
    background: transparent;
  }

  .app-shell {
    padding-top: 5rem !important;
    padding-bottom: 2rem !important;
  }

}
