:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #666a73;
  --line: #d8d6d1;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --accent: #d000a8;
  --accent-dark: #85006f;
  --good: #1f7a4d;
  --warn: #9a5b00;
  --soft: #f1ede7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-header {
  align-items: center;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: white;
  display: flex;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 40px);
}

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

h1 {
  font-size: clamp(28px, 8vw, 52px);
  font-weight: 800;
  letter-spacing: 0;
}

h2 {
  font-size: 28px;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
}

.eyebrow {
  color: #ffe0fa;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 18px clamp(12px, 4vw, 32px) 48px;
}

.login-panel,
.section-heading,
.settings-panel,
.line-builder,
.summary-panel,
.metric,
.split-grid > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.role-box {
  display: grid;
  gap: 5px;
  min-width: 120px;
}

.role-box label {
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  font-weight: 700;
}

.role-box select {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.42);
  color: white;
  min-height: 36px;
}

.role-box select:focus {
  border-color: white;
  outline: 2px solid rgba(255, 255, 255, 0.28);
  outline-offset: 2px;
}

.role-box select option {
  color: var(--ink);
}

.login-panel {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr minmax(180px, 260px);
  margin-bottom: 14px;
  padding: 16px;
}

.login-panel p {
  color: var(--muted);
  margin-top: 4px;
}

.login-panel h2 {
  font-size: 20px;
  margin-top: 2px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 16px;
}

.tab,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  min-height: 42px;
  padding: 0 14px;
}

.tab {
  background: var(--soft);
  color: var(--ink);
  flex: 0 0 auto;
}

.tab.active,
.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.secondary-button {
  background: #202020;
  border-color: #202020;
  color: white;
}

.icon-button {
  background: white;
  color: var(--accent);
  min-height: 32px;
  padding: 0 10px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

body[data-role="stylist"] .admin-only {
  display: none;
}

.settings-panel {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr minmax(140px, 220px) auto;
  padding: 16px;
}

.settings-panel .helper-text {
  color: var(--muted);
  margin-top: 6px;
  max-width: 46rem;
}

.section-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 16px;
}

.section-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 5px;
}

.heading-actions,
.builder-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.item-count,
.context-chip {
  background: var(--soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

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

.form-grid.compact,
.product-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.formula-meta {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

body[data-role="stylist"] .stylist-picker {
  display: none;
}

body[data-role="stylist"] .formula-meta {
  grid-template-columns: minmax(220px, 360px);
}

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

input,
select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 0 10px;
  width: 100%;
}

.line-builder {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.line-builder-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.line-builder-head > div {
  align-items: center;
  display: flex;
  gap: 9px;
}

.step-number {
  align-items: center;
  background: var(--accent);
  border-radius: 50%;
  color: white;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  height: 25px;
  justify-content: center;
  width: 25px;
}

.builder-divider {
  border-top: 1px solid var(--line);
  margin: 2px 0;
}

.mixture-grid {
  grid-template-columns: 1.15fr 1.35fr 1fr 1fr;
}

.builder-actions {
  justify-content: space-between;
}

.text-button {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  padding-left: 0;
}

[hidden] {
  display: none !important;
}

.formula-empty-state {
  align-items: center;
  background: #f7f3ed;
  border: 1px dashed #c8c0b4;
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 24px 16px;
  text-align: center;
}

.formula-empty-state strong {
  color: var(--ink);
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

table {
  background: white;
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #ede7dd;
  font-size: 12px;
  text-transform: uppercase;
}

tr[data-edit-product] {
  cursor: pointer;
}

.status {
  border-radius: 8px;
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  text-transform: capitalize;
}

.status.priced {
  background: #e4f4ea;
  color: var(--good);
}

.status.needs_pricing {
  background: #fff2d8;
  color: var(--warn);
}

.status.needs_verification {
  background: #fff2d8;
  color: var(--warn);
}

.summary-panel {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 14px 16px;
}

.summary-title {
  align-items: baseline;
  display: flex;
  gap: 12px;
  margin-right: auto;
}

.summary-title span {
  color: var(--ink);
  font-weight: 800;
}

.summary-title strong {
  color: var(--accent);
  font-size: 25px;
}

.summary-panel span {
  color: var(--muted);
}

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

.metric {
  display: grid;
  gap: 8px;
  padding: 16px;
}

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

.metric strong {
  font-size: 28px;
}

.split-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

.split-grid > div {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.list-block {
  display: grid;
  gap: 8px;
}

.list-row {
  align-items: center;
  background: var(--soft);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 12px;
}

.list-row.tall {
  align-items: flex-start;
  gap: 10px;
}

.date-range {
  display: flex;
  gap: 8px;
}

.empty-state {
  color: var(--muted);
  padding: 12px 0;
}

@media (max-width: 820px) {
  .app-header,
  .login-panel,
  .section-heading,
  .settings-panel,
  .line-builder-head,
  .date-range {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header,
  .section-heading,
  .settings-panel,
  .line-builder-head,
  .date-range {
    display: flex;
  }

  .login-panel,
  .settings-panel,
  .form-grid,
  .form-grid.compact,
  .product-grid,
  .mixture-grid,
  .metric-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }

  h2 {
    font-size: 24px;
  }

  .role-box {
    align-self: flex-end;
  }

  .heading-actions,
  .builder-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .heading-actions .primary-button,
  .builder-actions .secondary-button {
    width: 100%;
  }

  .summary-panel,
  .summary-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
