:root {
  color-scheme: light;
  --bg: #f7f7fb;
  --ink: #17171d;
  --muted: #686b78;
  --line: #dddfe7;
  --panel: #ffffff;
  --red: #d7252a;
  --yellow: #f4c430;
  --blue: #2f66d4;
  --green: #16845c;
  --shadow: 0 10px 30px rgba(24, 27, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  touch-action: manipulation;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
  background: rgba(247, 247, 251, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar h1,
h2,
p {
  margin: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1;
}

.eyebrow,
.label {
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

main {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px max(14px, env(safe-area-inset-right)) calc(94px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.panel,
.stock-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 0 0 14px;
  scroll-margin-top: 84px;
  min-width: 0;
}

.section-head,
.account-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.account-panel {
  border-top: 5px solid var(--red);
  align-items: stretch;
  flex-direction: column;
}

.account-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
}

.session-actions {
  display: flex;
}

.account-actions,
.session-actions {
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.account-actions a {
  width: 100%;
}

.account-panel > div,
.section-head > div {
  min-width: 0;
}

.primary,
.secondary,
.ghost,
.mini,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
  min-width: 0;
}

.primary:active,
.secondary:active,
.ghost:active,
.mini:active,
.icon-btn:active,
.bottom-nav button:active {
  transform: scale(0.98);
}

.primary {
  background: var(--red);
  border-color: var(--red);
  color: white;
  font-weight: 800;
}

.secondary {
  font-weight: 700;
}

.ghost {
  min-height: 36px;
  color: var(--muted);
}

.mini {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-btn {
  width: 40px;
  padding: 0;
  font-size: 20px;
}

.status-text {
  color: var(--muted);
  margin-top: 10px;
}

.managed-email {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border-radius: 8px;
  background: #fff8dc;
  border: 1px solid #ead688;
}

.managed-email strong {
  overflow-wrap: anywhere;
}

.checkout-actions {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
}

.profile-grid,
.report-grid,
.link-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 46px;
  margin-top: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  font-size: 16px;
}

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

.stock-list {
  display: grid;
  gap: 10px;
}

.link-form {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfd;
}

.check-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.check-strip span,
.retailer {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  width: fit-content;
  max-width: 100%;
  padding: 0 9px;
  border-radius: 999px;
  background: #f2f3f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stock-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stock-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.22;
}

.stock-card p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.pill.in {
  background: #e7f6ef;
  color: var(--green);
}

.pill.out {
  background: #f2f3f7;
  color: var(--muted);
}

.buy-stack {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.buy-stack .mini {
  width: 100%;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric strong {
  display: block;
  font-size: 24px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.submission-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.submission-list h3 {
  margin: 0;
  font-size: 16px;
}

.submission-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.submission-card strong,
.submission-card span,
.submission-card a {
  display: block;
  overflow-wrap: anywhere;
}

.submission-card span,
.submission-card a {
  color: var(--muted);
  font-size: 13px;
}

.submission-actions {
  display: grid;
  gap: 8px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.bottom-nav button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: #f0f2f8;
  color: var(--muted);
  font-weight: 800;
}

.bottom-nav button.active {
  background: var(--blue);
  color: white;
}

.hidden {
  display: none !important;
}

@media (max-width: 680px) {
  .topbar {
    align-items: center;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .session-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(70px, 1fr));
    justify-content: flex-end;
  }

  .session-actions .icon-btn {
    justify-self: end;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .account-actions a,
  .section-head button {
    flex: 1;
    width: 100%;
  }

  .profile-grid,
  .report-grid,
  .link-form,
  .metrics {
    grid-template-columns: 1fr;
  }

  .stock-card {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .buy-stack {
    grid-template-columns: 1fr 1fr;
    justify-items: stretch;
    align-items: center;
  }

  .buy-stack .pill,
  .buy-stack a,
  .buy-stack button {
    justify-content: center;
  }
}

@media (max-width: 430px) {
  .topbar {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .eyebrow {
    font-size: 11px;
  }

  main {
    padding-top: 12px;
  }

  .panel,
  .stock-section {
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: none;
  }

  .account-actions,
  .profile-grid,
  .report-grid,
  .link-form,
  .buy-stack {
    gap: 9px;
  }

  .submission-card {
    grid-template-columns: 1fr;
  }

  .submission-actions {
    grid-template-columns: 1fr 1fr;
  }

  .managed-email {
    grid-template-columns: 1fr auto;
  }

  .managed-email span {
    grid-column: 1 / -1;
  }

  .check-strip {
    display: grid;
  }

  .check-strip span {
    width: 100%;
    justify-content: center;
  }

  .stock-card h3 {
    font-size: 15px;
  }

  .bottom-nav {
    gap: 6px;
  }

  .bottom-nav button {
    font-size: 13px;
  }
}
