:root {
  --ink: #1b1a17;
  --cabinet: #24312e;
  --porcelain: #f7f4ec;
  --paper: #fffaf0;
  --thread: #b3432b;
  --mint: #8fb8a8;
  --brass: #d2a449;
  --blueprint: #2f5d7c;
  --shadow: 0 22px 60px rgba(27, 26, 23, 0.16);
  --radius: 8px;
  --font-body: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --font-utility: "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
  font-family: var(--font-body);
  background: var(--porcelain);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(36, 49, 46, 0.045) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(180deg, rgba(179, 67, 43, 0.035) 1px, transparent 1px) 0 0 / 100% 32px,
    var(--porcelain);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.photo-drop:focus-within {
  outline: 3px solid rgba(47, 93, 124, 0.34);
  outline-offset: 3px;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar {
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(390px, 0.82fr) minmax(320px, 0.65fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.brand-lockup,
.stats-strip,
.auth-panel,
.admin-panel,
.intake-panel,
.catalog-panel {
  border: 1px solid rgba(27, 26, 23, 0.13);
  background: rgba(255, 250, 240, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  gap: 18px;
  align-items: center;
  min-height: 132px;
  padding: 22px;
  border-radius: var(--radius);
}

.brand-mark {
  display: grid;
  gap: 6px;
  width: 58px;
  min-width: 58px;
  padding: 10px;
  border-radius: 7px;
  background: var(--cabinet);
  box-shadow: inset 0 -8px 0 rgba(255, 255, 255, 0.06);
}

a.brand-lockup {
  color: inherit;
  text-decoration: none;
}

.admin-page-header {
  margin-bottom: 18px;
}

.admin-brand {
  width: min(620px, 100%);
}

.brand-mark span {
  display: block;
  height: 8px;
  border-radius: 2px;
  background: var(--brass);
}

.brand-mark span:nth-child(2) {
  background: var(--mint);
}

.brand-mark span:nth-child(3) {
  background: var(--thread);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blueprint);
  font-family: var(--font-utility);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 3.7vw, 3.9rem);
  line-height: 1.02;
}

h2 {
  font-size: clamp(1.65rem, 2.5vw, 2.7rem);
  line-height: 1;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-radius: var(--radius);
  overflow: hidden;
}

.auth-panel {
  position: relative;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 18px;
  border-radius: var(--radius);
  overflow: visible;
}

.auth-summary {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.auth-summary h2 {
  font-size: 1.72rem;
}

.auth-tools {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: end;
  gap: 8px;
  z-index: 10;
}

.mode-badge {
  display: inline-grid;
  place-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(143, 184, 168, 0.22);
  color: var(--cabinet);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.mode-badge.is-pro {
  background: rgba(143, 184, 168, 0.34);
  color: var(--cabinet);
}

.plan-popover {
  position: relative;
}

.plan-popover::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  display: block;
  width: 100%;
  height: 10px;
}

.plan-trigger {
  min-height: 36px;
  padding: 0 13px;
  background: var(--cabinet);
  color: var(--paper);
  font-weight: 800;
}

.plan-popover-card {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(280px, 1fr);
  gap: 12px;
  width: min(640px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid rgba(27, 26, 23, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 24px 60px rgba(27, 26, 23, 0.20);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}

.plan-popover-card::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 26px;
  width: 12px;
  height: 12px;
  border-top: 1px solid rgba(27, 26, 23, 0.13);
  border-left: 1px solid rgba(27, 26, 23, 0.13);
  background: rgba(255, 250, 240, 0.96);
  transform: rotate(45deg);
}

.plan-popover-heading {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 2px 2px 0;
}

.plan-popover-heading h3 {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-size: 1.28rem;
  line-height: 1;
}

.plan-popover:hover .plan-popover-card,
.plan-popover:focus-within .plan-popover-card {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#authStatus {
  min-height: 1.35em;
  margin-bottom: 0;
  color: rgba(27, 26, 23, 0.68);
  font-size: 0.88rem;
  line-height: 1.35;
}

.account-action {
  justify-self: start;
  min-height: 38px;
  padding: 0 15px;
  background: var(--cabinet);
  color: var(--paper);
  font-weight: 800;
}

.auth-modal[hidden] {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: rgba(27, 26, 23, 0.38);
  cursor: default;
}

.auth-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  max-height: min(680px, calc(100vh - 40px));
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(27, 26, 23, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.98);
  box-shadow: 0 30px 90px rgba(27, 26, 23, 0.28);
}

.auth-dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.auth-dialog-heading h2 {
  font-size: 1.82rem;
}

.auth-close-button {
  display: grid;
  place-items: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  background: rgba(36, 49, 46, 0.09);
  color: var(--cabinet);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.auth-modal-status {
  min-height: 1.35em;
  margin-bottom: 0;
  color: rgba(27, 26, 23, 0.68);
  font-size: 0.9rem;
  line-height: 1.45;
}

.modal-open {
  overflow: hidden;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.auth-actions button,
#logoutButton {
  min-height: 36px;
  padding: 0 13px;
  background: rgba(36, 49, 46, 0.09);
  color: var(--cabinet);
  font-weight: 800;
}

#loginButton,
#verifyButton {
  background: var(--cabinet);
  color: var(--paper);
}

.stats-strip article {
  padding: 24px 20px;
  border-left: 1px solid rgba(27, 26, 23, 0.12);
}

.stats-strip article:first-child {
  border-left: 0;
}

.stats-strip span {
  display: block;
  margin-bottom: 8px;
  color: var(--cabinet);
  font-family: var(--font-utility);
  font-size: clamp(1.5rem, 3vw, 2.6rem);
  font-weight: 800;
  line-height: 1;
}

.stats-strip p {
  margin-bottom: 0;
  color: rgba(27, 26, 23, 0.68);
}

.plan-card {
  display: grid;
  gap: 12px;
  align-items: start;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(27, 26, 23, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.72);
}

.plan-card p {
  margin-bottom: 0;
  color: rgba(27, 26, 23, 0.68);
  line-height: 1.55;
}

.plan-heading h3 {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1;
}

.pro-plan {
  border-color: rgba(179, 67, 43, 0.24);
  background:
    linear-gradient(90deg, rgba(179, 67, 43, 0.10), transparent 34%),
    rgba(255, 250, 240, 0.86);
}

.coming-soon {
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(179, 67, 43, 0.10);
  color: var(--thread);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.25;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: start;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(36, 49, 46, 0.09);
  color: var(--cabinet);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.25;
}

.pro-plan .feature-list li {
  background: rgba(179, 67, 43, 0.10);
  color: var(--thread);
}

.admin-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border-radius: var(--radius);
}

.admin-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.admin-heading h2 {
  font-size: clamp(1.55rem, 2.2vw, 2.35rem);
}

.admin-controls {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.admin-actions {
  display: flex;
  gap: 9px;
  min-width: 190px;
}

.admin-actions button {
  min-height: 42px;
}

.admin-status {
  min-height: 1.35em;
  margin-bottom: 0;
  color: rgba(27, 26, 23, 0.68);
  font-size: 0.88rem;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(27, 26, 23, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.58);
}

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

.admin-table th,
.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(27, 26, 23, 0.10);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: rgba(27, 26, 23, 0.68);
  font-size: 0.78rem;
  font-weight: 800;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-email {
  font-family: var(--font-utility);
  font-size: 0.84rem;
}

.admin-table select {
  min-width: 112px;
}

.admin-table button {
  min-height: 34px;
  padding: 0 12px;
  background: rgba(36, 49, 46, 0.09);
  color: var(--cabinet);
  font-weight: 800;
}

.admin-table .save-plan-button {
  background: var(--cabinet);
  color: var(--paper);
}

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.intake-panel,
.catalog-panel {
  align-self: stretch;
  border-radius: var(--radius);
}

.intake-panel {
  position: sticky;
  top: 18px;
  min-height: 620px;
  padding: 18px;
}

.panel-heading,
.rail-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.photo-drop {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px dashed rgba(36, 49, 46, 0.42);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(143, 184, 168, 0.26), transparent 42%),
    linear-gradient(315deg, rgba(210, 164, 73, 0.20), transparent 44%),
    rgba(255, 255, 255, 0.62);
  cursor: pointer;
}

.photo-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#photoPreview {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-drop.has-image #photoPreview {
  display: block;
}

.photo-drop.has-image .photo-empty {
  display: none;
}

.photo-empty {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 16px;
  text-align: center;
}

.photo-empty strong {
  font-size: 1.1rem;
}

.photo-empty small {
  color: rgba(27, 26, 23, 0.62);
}

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

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: rgba(27, 26, 23, 0.72);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(27, 26, 23, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.wide-field {
  margin-top: 12px;
}

.form-actions,
.data-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.form-actions {
  margin-top: 16px;
}

.primary-action,
.ghost-action,
.data-actions button,
.card-actions button {
  min-height: 38px;
  padding: 0 15px;
  font-weight: 800;
}

.primary-action {
  flex: 1;
  background: var(--thread);
  color: #fffaf0;
}

.ghost-action,
.data-actions button,
.card-actions button {
  background: rgba(36, 49, 46, 0.09);
  color: var(--cabinet);
}

.catalog-panel {
  min-height: 620px;
  padding: 18px;
  overflow: hidden;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(116px, 0.24fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.rail {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 26px;
  margin: 2px 0 18px;
  border-top: 4px solid var(--cabinet);
}

.rail::before {
  content: "";
  position: absolute;
  inset: -4px 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--thread) 0 18%, var(--brass) 18% 33%, var(--cabinet) 33% 100%);
}

.rail span {
  border-left: 1px solid rgba(36, 49, 46, 0.32);
}

.rail span:last-child {
  border-right: 1px solid rgba(36, 49, 46, 0.32);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.garment-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(27, 26, 23, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 16px 32px rgba(27, 26, 23, 0.10);
}

.garment-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22px;
  width: 2px;
  height: 18px;
  background: var(--cabinet);
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(135deg, rgba(47, 93, 124, 0.16), transparent 50%),
    rgba(143, 184, 168, 0.2);
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-status {
  position: absolute;
  right: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(27, 26, 23, 0.78);
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 800;
}

.card-body {
  padding: 13px;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.card-title-row h3 {
  margin-bottom: 6px;
  font-size: 1.02rem;
  line-height: 1.25;
}

.card-price {
  color: var(--thread);
  font-family: var(--font-utility);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.card-meta,
.card-notes {
  color: rgba(27, 26, 23, 0.68);
  font-size: 0.88rem;
  line-height: 1.45;
}

.card-meta {
  margin-bottom: 10px;
}

.card-notes {
  display: -webkit-box;
  min-height: 2.5em;
  margin: 9px 0 12px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-row span {
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(143, 184, 168, 0.25);
  color: var(--cabinet);
  font-size: 0.76rem;
  font-weight: 800;
}

.delete-button {
  color: var(--thread) !important;
}

.empty-state {
  display: none;
  max-width: 580px;
  padding: 34px 10px;
}

.empty-state h3 {
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2.8rem);
  line-height: 1.04;
}

.empty-state p:last-child {
  color: rgba(27, 26, 23, 0.68);
  line-height: 1.6;
}

.empty-state.is-visible {
  display: block;
}

@media (max-width: 980px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .admin-controls {
    grid-template-columns: 1fr 1fr;
  }

  .admin-actions {
    grid-column: 1 / -1;
    min-width: 0;
  }

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

  .plan-card {
    gap: 10px;
  }

  .intake-panel {
    position: static;
    min-height: 0;
  }

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

  .search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

  .brand-lockup {
    align-items: start;
  }

  .stats-strip,
  .field-grid,
  .admin-controls,
  .filters {
    grid-template-columns: 1fr;
  }

  .stats-strip article {
    border-left: 0;
    border-top: 1px solid rgba(27, 26, 23, 0.12);
    padding: 16px;
  }

  .stats-strip article:first-child {
    border-top: 0;
  }

  .panel-heading,
  .rail-header,
  .admin-heading,
  .card-title-row {
    align-items: start;
    flex-direction: column;
  }

  .data-actions,
  .data-actions button,
  .admin-actions,
  .admin-actions button {
    width: 100%;
  }

  .data-actions button,
  .admin-actions button {
    display: grid;
    place-items: center;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .plan-popover-card {
    transition: opacity 160ms ease, transform 160ms ease;
  }

  .garment-card {
    transition: transform 180ms ease, box-shadow 180ms ease;
  }

  .garment-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 44px rgba(27, 26, 23, 0.14);
  }
}
