:root {
  --bg: #f3efe7;
  --panel: rgba(255, 252, 247, 0.84);
  --panel-strong: #fffaf2;
  --ink: #1f2937;
  --muted: #667085;
  --line: rgba(15, 23, 42, 0.08);
  --accent: #14746f;
  --accent-strong: #0f5b57;
  --warn: #b54708;
  --shadow: 0 24px 50px rgba(29, 39, 56, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Instrument Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(20, 116, 111, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(180, 71, 8, 0.12), transparent 24%),
    linear-gradient(180deg, #f8f3eb 0%, #efe9dd 100%);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

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

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(520px, 100%);
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  border-radius: 32px;
  padding: clamp(1.5rem, 4vw, 2.4rem);
}

.auth-card h1 {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.03em;
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 0.95;
  max-width: 10ch;
}

.auth-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.auth-form > div {
  display: grid;
  gap: 0.85rem;
}

.auth-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(520px, 1fr);
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.hero h1,
.section-heading h2 {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.03em;
  margin: 0;
}

.hero h1 {
  font-size: clamp(1.9rem, 4vw, 3.4rem);
  line-height: 1;
  max-width: none;
  white-space: nowrap;
}

.hero-copy {
  max-width: 52ch;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 1rem;
}

.hero-panel,
.card {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.hero-panel {
  padding: 1.4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}

.hero-panel > div {
  min-width: 0;
}

.hero-panel span,
.eyebrow,
th,
.stat-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--muted);
}

.hero-panel strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-panel .ghost-button {
  justify-self: end;
  align-self: center;
  min-height: 0;
  padding-inline: 1.4rem;
}

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

.card {
  padding: 1.35rem;
}

.stats-card {
  padding: 1.05rem;
}

.stats-card,
.inventory-card {
  grid-column: span 12;
}

.grid > .card:nth-child(2),
.grid > .card:nth-child(4),
.grid > .card:nth-child(5),
.grid > .card:nth-child(6) {
  grid-column: span 6;
}

.grid > .card:nth-child(2) {
  grid-column: span 12;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  font-size: 1.5rem;
}

.stats-card .section-heading {
  margin-bottom: 0.7rem;
}

.stats-card .section-heading h2 {
  font-size: 1.2rem;
}

.stats-card .eyebrow {
  font-size: 0.66rem;
}

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

.stats-card .stats-grid {
  gap: 0.7rem;
}

.stat {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
}

.stats-card .stat {
  border-radius: 16px;
  padding: 0.75rem 0.85rem;
}

.stat-value {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 2rem;
  margin-top: 0.4rem;
}

.stats-card .stat-value {
  font-size: 1.5rem;
  margin-top: 0.25rem;
}

.toolbar,
.checkbox {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.list-meta,
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.list-meta {
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.toolbar {
  flex-wrap: wrap;
}

.size-search-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0.65rem;
  flex: 1 1 520px;
}

.size-search-field {
  display: grid;
  gap: 0.25rem;
}

.size-search-field span {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}

.size-search-field input {
  padding: 0.72rem 0.85rem;
}

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

#item-form.form-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: center;
}

#item-form.form-grid .primary-button {
  width: 100%;
  margin-top: 0;
  align-self: stretch;
}

input,
select {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.78);
}

input:focus,
select:focus {
  outline: 2px solid rgba(20, 116, 111, 0.18);
  border-color: var(--accent);
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

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

.ghost-button {
  background: rgba(20, 116, 111, 0.08);
  color: var(--accent-strong);
}

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

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 0.95rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

td strong {
  display: block;
}

.item-title-line {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.item-info-inline {
  font-size: 0.84rem;
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 0.45rem;
  min-width: 240px;
}

.size-grid-compact {
  margin-top: 0.55rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  min-width: 0;
  max-width: 460px;
}

.size-chip {
  padding: 0.55rem 0.65rem;
  border-radius: 14px;
  background: rgba(20, 116, 111, 0.08);
  border: 1px solid rgba(20, 116, 111, 0.16);
}

.size-chip-empty {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.08);
}

.size-chip-label {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.size-chip strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
}

.size-grid-compact .size-chip {
  padding: 0.35rem 0.45rem;
  border-radius: 12px;
}

.size-grid-compact .size-chip-label {
  margin-bottom: 0.1rem;
  font-size: 0.62rem;
}

.size-grid-compact .size-chip strong {
  font-size: 0.84rem;
}

.subtle {
  color: var(--muted);
  font-size: 0.92rem;
}

.sku-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.sku-link:hover {
  color: var(--accent);
}

.photo-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.45rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(20, 116, 111, 0.12);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-ok {
  background: rgba(20, 116, 111, 0.12);
  color: var(--accent-strong);
}

.badge-warn {
  background: rgba(180, 71, 8, 0.14);
  color: var(--warn);
}

.action-group {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.mini-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

.stack-list {
  display: grid;
  gap: 0.8rem;
}

.stack-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.stack-item strong {
  display: block;
  margin-bottom: 0.2rem;
}

.stack-item time {
  color: var(--muted);
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #1f2937;
  color: white;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: start;
  gap: 0.75rem;
  max-width: min(420px, calc(100vw - 2rem));
}

.toast-body {
  line-height: 1.5;
  white-space: pre-line;
}

.toast-close {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.detail-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(6px);
}

.detail-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  border-radius: 28px;
  padding: 1.25rem;
}

.detail-close {
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.04);
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  margin-left: auto;
  display: block;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1.05fr) minmax(260px, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.detail-photo-wrap {
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--line);
  border-radius: 22px;
  min-height: 320px;
  display: grid;
  place-items: center;
  padding: 0.8rem;
}

.detail-photo {
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  border-radius: 18px;
}

.detail-copy h2 {
  font-family: "Space Grotesk", sans-serif;
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 4vw, 2.3rem);
  line-height: 1.02;
}

.detail-meta {
  display: grid;
  gap: 0.55rem;
}

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

.detail-row {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.52rem 0.65rem;
  border-radius: 12px;
  background: rgba(20, 116, 111, 0.04);
  border: 1px solid rgba(20, 116, 111, 0.08);
}

.detail-row-wide {
  gap: 0.35rem;
}

.detail-row-empty {
  visibility: hidden;
}

.detail-label {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-row strong {
  font-size: 0.9rem;
  line-height: 1.2;
}

.detail-photo-empty {
  text-align: center;
  max-width: 24ch;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .hero,
  .grid > .card:nth-child(2),
  .grid > .card:nth-child(4),
  .grid > .card:nth-child(5),
  .grid > .card:nth-child(6) {
    grid-column: span 12;
  }

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

  .hero h1 {
    white-space: normal;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .size-search-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .size-grid {
    min-width: 220px;
  }

  .size-grid-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .section-heading {
    flex-direction: column;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-row {
    flex-direction: column;
    gap: 0.3rem;
  }

  .detail-group-grid {
    grid-template-columns: 1fr;
  }
}
