:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-muted: #edf4f2;
  --text: #22201d;
  --muted: #6f716f;
  --line: #dedbd2;
  --line-strong: #c9c5b9;
  --teal: #2a746d;
  --teal-dark: #1c5550;
  --brass: #b48a3b;
  --warning: #b45a27;
  --danger: #9f332d;
  --ok: #2f7a4f;
  --shadow: 0 12px 34px rgba(28, 41, 34, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", Avenir, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 82px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: #fffdfa;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #d6c496;
  border-radius: 50%;
  color: var(--brass);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
  background: #fffaf0;
}

.topbar h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  line-height: 1;
  font-weight: 500;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-nav,
.settings-tabs,
.settings-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-button,
.tab-button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fffdfa;
  color: var(--teal-dark);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
}

.nav-button.active,
.tab-button.active {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  color: white;
}

.icon-button,
.primary-button,
.secondary-button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  min-height: 38px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  font-size: 18px;
}

.primary-button {
  padding: 0 16px;
  background: var(--teal);
  color: white;
  border-color: var(--teal);
  font-weight: 700;
}

.secondary-button {
  width: 100%;
  padding: 0 12px;
  background: #fffdfa;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 760;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.brand-story {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(90deg, #ffffff 0%, #f6fbfa 100%);
  box-shadow: var(--shadow);
}

.brand-story h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 500;
}

.brand-story p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.brand-story a {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 780;
  text-decoration: none;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 262px minmax(560px, 1fr) 282px;
  gap: 14px;
  padding: 16px;
  min-width: 0;
}

.page-view {
  display: none;
}

.page-view.active {
  display: grid;
}

.assumptions,
.detail-panel,
.content-area {
  min-width: 0;
}

.panel,
.table-panel,
.metrics article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 15px;
  margin-bottom: 12px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 13px;
}

.section-title h2,
.table-toolbar h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.1;
}

.section-title span {
  color: var(--teal);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: 0;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field input,
.search-field input,
td input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--text);
}

.field input {
  height: 34px;
  padding: 0 10px;
  text-align: right;
}

.settings-form {
  display: grid;
  gap: 10px;
}

.settings-form .field input {
  text-align: left;
}

.settings-message {
  min-height: 32px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-page {
  padding: 16px;
}

.settings-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-header h2 {
  margin: 0;
  font-size: 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.settings-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-header span {
  color: var(--teal);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
  white-space: nowrap;
}

.settings-tabs {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.settings-tab-panel {
  display: none;
  padding: 18px;
}

.settings-tab-panel.active {
  display: block;
}

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

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

.material-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdfa;
}

.material-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}

.material-card.gold .material-swatch {
  background: #d8b75c;
}

.material-card.silver .material-swatch {
  background: #d9dde0;
}

.material-card.copper .material-swatch {
  background: #b86b42;
}

.settings-actions {
  margin-top: 14px;
}

.settings-actions .secondary-button,
.settings-save-button {
  width: auto;
  min-width: 178px;
}

.fee-summary {
  display: grid;
  gap: 9px;
}

.fee-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.fee-summary div:last-child {
  border-bottom: 0;
}

.fee-summary span,
.detail-list dt {
  color: var(--muted);
  font-size: 12px;
}

.fee-summary strong {
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.product-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.product-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 4px 10px;
  align-items: center;
  min-height: 74px;
  padding: 8px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.product-card img {
  grid-row: 1 / 3;
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 6px;
  background: #eee9df;
}

.product-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 740;
}

.product-card strong {
  color: var(--teal-dark);
  font-size: 13px;
}

.metrics article {
  padding: 14px;
  min-height: 78px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1;
}

.table-panel {
  overflow: hidden;
}

.table-toolbar {
  min-height: 68px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 200px 220px auto;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.search-field,
.collection-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0;
}

.search-field input,
.collection-field select {
  height: 34px;
  padding: 0 10px;
  text-transform: none;
}

.collection-field select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--text);
}

.for-sale-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.for-sale-toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--teal);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 196px);
}

table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
  table-layout: fixed;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  background: var(--surface-muted);
  color: #2e3936;
  border-bottom: 1px solid var(--line-strong);
  font-size: 10px;
  line-height: 1.2;
  font-weight: 800;
  padding: 8px 7px;
  white-space: nowrap;
}

td {
  border-bottom: 1px solid var(--line);
  padding: 6px 7px;
  vertical-align: middle;
  background: var(--surface);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover td,
tbody tr.active td {
  background: #f3f8f6;
}

tbody tr.under td {
  background: #fff8f1;
}

tbody tr.under.active td {
  background: #f8eee2;
}

.item-col {
  width: 270px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 78px;
}

th:nth-child(3),
td:nth-child(3),
th:nth-child(9),
td:nth-child(9),
th:nth-child(10),
td:nth-child(10),
th:nth-child(11),
td:nth-child(11) {
  width: 88px;
}

th:nth-child(4),
td:nth-child(4),
th:nth-child(5),
td:nth-child(5),
th:nth-child(6),
td:nth-child(6),
th:nth-child(7),
td:nth-child(7) {
  width: 92px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 86px;
}

.product-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 760;
}

td span {
  color: var(--muted);
  font-size: 11px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 24px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.status-pill.live {
  color: var(--teal-dark);
  background: #e4f2ef;
}

.status-pill.sold {
  color: #7b431f;
  background: #f7e7d4;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

td input {
  height: 32px;
  padding: 0 8px;
}

td input[type="number"] {
  text-align: right;
}

.money,
.percent,
.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.margin-good {
  color: var(--ok);
  font-weight: 760;
}

.margin-warn {
  color: var(--warning);
  font-weight: 760;
}

.margin-bad {
  color: var(--danger);
  font-weight: 760;
}

.selected h3 {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.22;
}

.selected-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  background: #eee9df;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.detail-list div:last-child {
  border-bottom: 0;
}

.detail-list dd {
  margin: 0;
  font-weight: 790;
  font-variant-numeric: tabular-nums;
}

.recommendation {
  margin-top: 14px;
  padding: 12px;
  border-radius: 7px;
  background: #f1f6f4;
  border: 1px solid #d1dfd9;
  color: var(--teal-dark);
  font-size: 13px;
}

.recommendation.warn {
  background: #fff7ec;
  border-color: #ead3b6;
  color: #7b431f;
}

.formula-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.formula-list li + li {
  margin-top: 8px;
}

@media (max-width: 1360px) {
  .workspace {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .detail-panel .panel {
    margin-bottom: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
  }

  .workspace,
  .detail-panel {
    display: block;
    padding: 12px;
  }

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

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 13px;
  }

  .topbar h1 {
    font-size: 23px;
    line-height: 1.05;
  }

  .brand-story {
    display: grid;
  }

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

  .product-strip {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .settings-header,
  .settings-actions,
  .settings-tabs {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-grid,
  .material-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions .secondary-button,
  .settings-save-button {
    width: 100%;
  }

  .search-field {
    width: 100%;
  }
}
