:root {
  /* ── Core Tokens ── */
  --p: 217, 91%, 60%;      /* Primary (Blue) */
  --p-d: 217, 91%, 45%;
  --s: 210, 40%, 96%;      /* Surface (Gray) */
  --s-2: 210, 40%, 92%;
  --s-3: 210, 40%, 88%;
  --t: 217, 33%, 17%;      /* Text */
  --t-m: 217, 20%, 45%;    /* Text Muted */
  
  --success: 145, 65%, 40%;
  --warning: 38, 95%, 45%;
  --danger: 0, 75%, 55%;
  
  --border: 210, 30%, 90%;
  --surface: 0, 0%, 100%;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.12);
  
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background-color: hsl(var(--s));
  color: hsl(var(--t));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Layout ── */
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid hsl(var(--border));
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.main {
  padding: 2rem 3rem;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

/* ── Navigation ── */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  color: hsl(var(--t-m));
  font-weight: 600;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.nav-button:hover {
  background: hsl(var(--s-2));
  color: hsl(var(--t));
}

.nav-button.is-active {
  background: hsla(var(--p), 0.1);
  color: hsl(var(--p));
}

/* ── Components ── */
.panel {
  background: var(--surface);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.panel-heading {
  padding: 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-heading h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Metric Cards ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.metric-card strong {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.metric-card .label {
  color: hsl(var(--t-m));
  font-weight: 600;
  font-size: 0.875rem;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  padding: 1rem 1.5rem;
  background: hsl(var(--s));
  color: hsl(var(--t-m));
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}

tr:hover {
  background: hsl(var(--s));
}

tr.is-selected {
  background: hsla(var(--p), 0.05);
}

/* ── Grids ── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.orders-layout {
  display: grid;
  grid-template-columns: 1fr 450px;
  gap: 2rem;
  align-items: start;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

/* ── Progress ── */
.prog-track {
  height: 8px;
  background: hsl(var(--s-2));
  border-radius: 4px;
  overflow: hidden;
  flex: 1;
}

.prog-fill {
  height: 100%;
  background: hsl(var(--p));
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.prog-fill.final { background: hsl(var(--success)); }
.prog-fill.greige { background: hsl(var(--warning)); }

/* ── Status Stack ── */
.status-stack {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.status-stack-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.875rem;
}

.status-stack-row strong {
  width: 120px;
  flex-shrink: 0;
}

/* ── Utilities ── */
.muted { color: hsl(var(--t-m)); font-size: 0.875rem; }
.brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.brand-mark { background: hsl(var(--p)); color: white; width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 1.25rem; }

.primary-button {
  background: hsl(var(--p));
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: none;
}

.primary-button:hover { background: hsl(var(--p-d)); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.secondary-button {
  background: white;
  border: 1px solid hsl(var(--border));
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
}

.secondary-button:hover { background: hsl(var(--s)); }

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .orders-layout, .content-grid { grid-template-columns: 1fr; }
}

/* -- PI Detail -- */
.pi-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
  background: hsl(var(--s));
  border-bottom: 1px solid hsl(var(--border));
}

.pi-summary div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pi-summary span { font-size: 0.75rem; color: hsl(var(--t-m)); text-transform: uppercase; font-weight: 600; }
.pi-summary strong { font-size: 1.125rem; font-weight: 700; }

.colour-bar {
  padding: 1rem 1.5rem;
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid hsl(var(--border));
}

.colour-chip {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid hsl(var(--border));
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition);
}

.colour-chip.is-active {
  background: hsl(var(--p));
  color: white;
  border-color: hsl(var(--p));
}

.fabric-group {
  border-bottom: 1px solid hsl(var(--border));
}

.fabric-group-header {
  width: 100%;
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: var(--surface);
  transition: var(--transition);
}

.fabric-group-header:hover { background: hsl(var(--s)); }

.fg-left { display: flex; gap: 1rem; align-items: center; text-align: left; }
.fg-meta { display: block; font-size: 0.8125rem; color: hsl(var(--t-m)); }

.fg-right { display: flex; align-items: center; gap: 1.5rem; }
.fg-progress { width: 120px; }


/* -- Workflow -- */
.workflow-panel { padding: 1.5rem; }
.workflow-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }

.workflow-button {
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  background: hsl(var(--s-2));
  color: hsl(var(--t-m));
  font-weight: 600;
  font-size: 0.875rem;
  transition: var(--transition);
  border: none;
  cursor: pointer;
}

.workflow-button.is-active {
  background: hsl(var(--p));
  color: white;
}

.stack-form { display: flex; flex-direction: column; gap: 1.5rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }

label { display: flex; flex-direction: column; gap: 0.5rem; }
label span { font-size: 0.75rem; color: hsl(var(--t-m)); font-weight: 600; }

input, select {
  padding: 0.625rem 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: white;
  transition: var(--transition);
}

input:focus, select:focus {
  outline: none;
  border-color: hsl(var(--p));
  box-shadow: 0 0 0 3px hsla(var(--p), 0.1);
}


/* -- Chips -- */
.chip {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: hsl(var(--s-2));
  color: hsl(var(--t-m));
}

.chip.good { background: hsla(var(--success), 0.1); color: hsl(var(--success)); }
.chip.warn { background: hsla(var(--warning), 0.1); color: hsl(var(--warning)); }
.chip.bad { background: hsla(var(--danger), 0.1); color: hsl(var(--danger)); }

