:root {
  --accent: #b5121b;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #6c6c70;
  --separator: #d1d1d6;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #ff453a;
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f2f2f7;
    --text-secondary: #98989f;
    --separator: #38383a;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: -apple-system-body;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

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

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 32px) calc(env(safe-area-inset-left) + 16px);
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.hero-icon {
  border-radius: 16px;
  display: block;
  margin: 0 auto 12px;
}

h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
}

.subtitle {
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.group {
  margin-bottom: 24px;
}

.group-title {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0 16px 6px;
  text-transform: uppercase;
}

.list {
  background: var(--surface);
  border-radius: var(--radius);
  list-style: none;
  margin: 0;
  overflow: hidden;
  padding: 0;
}

.row {
  align-items: center;
  display: flex;
  min-height: 44px;
  padding: 11px 16px;
  position: relative;
}

.row + .row::before {
  border-top: 0.5px solid var(--separator);
  content: "";
  left: 16px;
  position: absolute;
  right: 0;
  top: 0;
}

.row-text {
  display: flex;
  flex-direction: column;
}

.row-title {
  font-size: 17px;
}

.row-detail {
  color: var(--text-secondary);
  font-size: 15px;
}

.footnote {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

/* Signed-in pages leave room for the tab bar. */
.page.has-tabs {
  padding-bottom: calc(env(safe-area-inset-bottom) + 96px);
}

.page-header {
  margin: 8px 0 20px;
}

.page-header h1 {
  font-size: 34px;
}

.back {
  color: var(--accent);
  display: inline-block;
  font-size: 17px;
  margin-bottom: 4px;
  text-decoration: none;
}

h2 {
  font-size: 22px;
  margin: 0;
}

.center {
  text-align: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack p {
  margin: 0;
}

.top-gap {
  margin-top: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

/* Buttons: full width and at least 44pt tall, the iOS minimum tap target. */
.button {
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  display: block;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  min-height: 50px;
  padding: 14px 16px;
  text-align: center;
  text-decoration: none;
  width: 100%;
}

.card .button {
  background: var(--bg);
}

.button.primary {
  background: var(--accent);
  color: #fff;
}

.button.destructive {
  color: #d70015;
}

.button:disabled {
  opacity: 0.5;
}

.status {
  color: var(--text-secondary);
  font-size: 15px;
  min-height: 1.4em;
  text-align: center;
}

/* Forms. Inputs use 17px text: below 16px, iPhone Safari zooms in on focus. */
.field {
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.field > label:not(.choice),
.field > legend {
  color: var(--text-secondary);
  font-size: 13px;
  padding: 0;
  text-transform: uppercase;
}

input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
textarea {
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--separator);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  padding: 12px;
  width: 100%;
}

.choice {
  align-items: flex-start;
  background: var(--bg);
  border-radius: 10px;
  display: flex;
  gap: 12px;
  padding: 12px;
}

.choice input {
  accent-color: var(--accent);
  flex: none;
  height: 20px;
  margin: 2px 0 0;
  width: 20px;
}

.choice-text {
  display: flex;
  flex-direction: column;
}

.choice + .choice {
  margin-top: 8px;
}

.link-field {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 15px !important;
}

/* List rows that link somewhere, and label/value rows. */
.row-link {
  align-items: center;
  color: inherit;
  display: flex;
  flex: 1;
  justify-content: space-between;
  margin: -11px -16px;
  padding: 11px 16px;
  text-decoration: none;
}

.chevron {
  color: var(--text-secondary);
  font-size: 22px;
}

.row.detail {
  justify-content: space-between;
}

.row-value {
  color: var(--text-secondary);
  font-size: 17px;
}

/* The tab bar, pinned above the iPhone's home indicator. */
.tabbar {
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border-top: 0.5px solid var(--separator);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 6px 16px calc(env(safe-area-inset-bottom) + 6px);
  position: fixed;
  right: 0;
}

.tab {
  color: var(--text-secondary);
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  max-width: 160px;
  padding: 10px 0;
  text-align: center;
  text-decoration: none;
}

.tab.current {
  color: var(--accent);
}

.hint {
  color: var(--text-secondary);
  font-size: 13px;
}

.footnote.left {
  text-align: left;
}

.empty-note {
  color: var(--text-secondary);
  margin: 8px 16px;
}

/* A row of numbers at the top of Inventory and a size's page. */
.summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
}

.tile {
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.tile-link {
  color: inherit;
  text-decoration: none;
}

.tile-value {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.tile-label {
  color: var(--text-secondary);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.actions .button {
  flex: 1;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  text-decoration: none;
}

.product-head {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.product-name {
  font-size: 17px;
  font-weight: 600;
}

.product-price {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.product-card .badges {
  margin-bottom: 0;
}

.badge {
  background: var(--bg);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 2px 8px;
}

/* Size chips: the size, then how many can be sold. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  align-items: baseline;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-radius: 8px;
  display: inline-flex;
  gap: 6px;
  padding: 4px 10px;
}

.chip.empty {
  background: var(--bg);
  color: var(--text-secondary);
}

.chip-size {
  font-weight: 600;
}

.chip-count {
  font-variant-numeric: tabular-nums;
}

.chip-held,
.chip-note {
  color: var(--text-secondary);
  font-size: 12px;
  margin: 0;
}

.stock-table {
  background: var(--surface);
  border-collapse: collapse;
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  width: 100%;
}

.stock-table th {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 400;
  padding: 10px 12px 6px;
  text-align: right;
}

.stock-table td {
  border-top: 0.5px solid var(--separator);
  font-size: 17px;
  padding: 10px 12px;
  text-align: right;
}

.stock-table th:first-child,
.stock-table td:first-child {
  text-align: left;
}

.stock-table td a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.stock-table .zero {
  color: var(--text-secondary);
}

.inline-form {
  display: flex;
  gap: 8px;
}

.inline-form input {
  flex: 1;
}

.inline-form .button {
  width: auto;
}

/* Receive and Count: a small number field per size. */
.qty-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
}

.qty {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  gap: 4px;
}

.qty input {
  text-align: center;
}

.toggle {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 36px;
}

.toggle input {
  accent-color: var(--accent);
  height: 22px;
  width: 22px;
}

/* Two or more side-by-side choices, like iOS's segmented control. */
.segmented {
  background: var(--bg);
  border-radius: 10px;
  display: flex;
  padding: 3px;
}

.segmented label {
  flex: 1;
  position: relative;
}

.segmented input {
  opacity: 0;
  position: absolute;
}

.segmented span {
  border-radius: 8px;
  cursor: pointer;
  display: block;
  font-size: 15px;
  padding: 8px 4px;
  text-align: center;
}

.segmented input:checked + span {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  font-weight: 600;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
}

.row.hold {
  gap: 12px;
  justify-content: space-between;
}

.small-button {
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg);
  border: 0;
  border-radius: 8px;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 12px;
}

.row.arrange {
  gap: 12px;
  justify-content: space-between;
}

.arrange-buttons {
  display: flex;
  gap: 6px;
}

.icon-button {
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg);
  border: 0;
  border-radius: 8px;
  color: var(--accent);
  font-size: 20px;
  height: 44px;
  width: 44px;
}

.icon-button:disabled {
  color: var(--text-secondary);
  opacity: 0.4;
}

textarea {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 15px !important;
  resize: vertical;
}

input[type="file"] {
  font-size: 15px;
}

/* Pull to refresh: a circle that follows the finger down from the top. */
.pull-indicator {
  align-items: center;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  color: var(--text-secondary);
  display: flex;
  font-size: 18px;
  height: 36px;
  justify-content: center;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  top: calc(env(safe-area-inset-top) - 28px);
  transform: translate(-50%, 0);
  transition: opacity 0.15s;
  width: 36px;
  z-index: 10;
}

.pull-indicator.ready {
  color: var(--accent);
}

.pull-indicator.ready,
.pull-indicator.refreshing {
  font-size: 0;
}

.pull-indicator.ready::after,
.pull-indicator.refreshing::after {
  border: 2.5px solid currentColor;
  border-radius: 50%;
  border-right-color: transparent;
  content: "";
  height: 16px;
  width: 16px;
}

.pull-indicator.refreshing::after {
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* "Viewing as" banner, at the top of every page while an admin tries another role. */
.viewing-as {
  align-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-radius: var(--radius);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 10px 12px 10px 16px;
}

.search {
  margin-bottom: 12px;
}

/* A first/last name pair on the family form. */
.person-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.person-row + .person-row {
  border-top: 0.5px solid var(--separator);
  padding-top: 12px;
}

.row-label {
  color: var(--text-secondary);
  font-size: 13px;
}

.name-pair {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.toggle.small {
  color: var(--text-secondary);
  font-size: 15px;
  min-height: 28px;
}

.link-button {
  -webkit-appearance: none;
  appearance: none;
  align-self: flex-start;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 4px 0;
}

.problem {
  border: 1.5px solid var(--accent);
}

.plain-list {
  margin: 0;
  padding-left: 20px;
}
