/* ── Design tokens ───────────────────────────────────── */

:root {
  /* Base palette — rose gold */
  --bg:             #fdf5f4;
  --surface:        #ffffff;
  --border:         #ead4d0;
  --border-strong:  #d4b0aa;

  /* Text */
  --text:           #2a1418;
  --text-muted:     #8a6268;
  --text-placeholder: #c4a0a6;

  /* Header/nav — deep berry rose */
  --header-bg:      #4a1f2a;
  --header-text:    #fdeef0;
  --header-muted:   #c9a0aa;

  /* Brand accent — rose gold */
  --accent:         #b5686e;
  --accent-hover:   #9e545a;
  --accent-text:    #ffffff;

  /* Status tints */
  --tint-urgent-bg:   #fdf0ec;
  --tint-urgent-text: #8b3a1e;
  --tint-urgent-border: #f2c4b0;

  --tint-warn-bg:   #fdf8ec;
  --tint-warn-text: #6b5010;
  --tint-warn-border: #ecdda0;

  --tint-ok-bg:     #eef5f0;
  --tint-ok-text:   #2a5c30;
  --tint-ok-border: #b8d8bc;

  --tint-critical-bg:   #fde8ec;
  --tint-critical-text: #7a1a28;
  --tint-critical-border: #f2b0ba;

  /* Radii */
  --radius-card:    14px;
  --radius-inner:   8px;
  --radius-btn:     8px;
  --radius-input:   7px;
  --radius-tag:     999px;

  /* Shadows */
  --shadow-card:    0 1px 3px rgba(42, 20, 24, 0.08), 0 4px 12px rgba(42, 20, 24, 0.06);
  --shadow-modal:   0 8px 32px rgba(42, 20, 24, 0.18);
}

/* ── Reset ───────────────────────────────────────────── */

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

/* ── Base ────────────────────────────────────────────── */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue',
               Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────── */

header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0.5rem 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 2rem;
  min-height: 54px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
}

header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--header-text);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}

nav a {
  color: var(--header-muted);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.28rem 0.6rem;
  border-radius: var(--radius-btn);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

nav a:hover {
  color: var(--header-text);
  background: rgba(255,255,255,0.08);
}

nav a.active {
  color: var(--header-text);
  background: rgba(255,255,255,0.14);
  font-weight: 500;
}

/* ── Main layout ─────────────────────────────────────── */

main {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* ── Tables ──────────────────────────────────────────── */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-inner);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
  background: var(--bg);
}

thead th:first-child { border-radius: var(--radius-inner) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-inner) 0 0; }

tbody td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid #f3ede8;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #fdf9f7;
}

td.loading,
td.empty,
p.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-style: italic;
  font-size: 0.9rem;
}

.badge-low {
  color: var(--tint-urgent-text);
  font-weight: 600;
}

/* ── Order cards ─────────────────────────────────────── */

.orders-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.order-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-inner);
  padding: 0.9rem 1.1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.order-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(42, 20, 24, 0.07);
}

.order-card.overdue {
  background: var(--tint-critical-bg);
  border-color: var(--tint-critical-border);
}

.order-card.due-soon {
  background: var(--tint-urgent-bg);
  border-color: var(--tint-urgent-border);
}

.order-card-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-input);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.order-card.overdue .order-card-icon {
  background: var(--tint-critical-border);
  color: var(--tint-critical-text);
}

.order-card.due-soon .order-card-icon {
  background: var(--tint-urgent-border);
  color: var(--tint-urgent-text);
}

.order-card-main {
  flex: 1;
  min-width: 0;
}

.order-card-primary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.order-number {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.order-customer {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.order-card-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.order-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-tag);
  white-space: nowrap;
}

.order-card-due {
  flex-shrink: 0;
  text-align: right;
  min-width: 84px;
}

.due-label {
  display: block;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.1rem;
}

.due-date {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.order-card.overdue .due-date { color: var(--tint-critical-text); }
.order-card.due-soon .due-date { color: var(--tint-urgent-text); }

.order-card-status { flex-shrink: 0; }
.order-card-actions { flex-shrink: 0; }

/* Read-only status badge (queue page) */
.status-badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-tag);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  white-space: nowrap;
}

.status-badge.status-new          { color: var(--text-muted); }
.status-badge.status-ready        { background: #e8f4fc; color: #0a6694; border-color: #b8dcf4; }
.status-badge.status-cutting      { background: #fef4e8; color: #8a4a10; border-color: #f4d4a8; }
.status-badge.status-embroidering { background: #f4eef8; color: #5c3080; border-color: #d4b8ec; }
.status-badge.status-sewing       { background: #e8f4f4; color: #0a6660; border-color: #b8dcd8; }
.status-badge.status-finished     { background: var(--tint-ok-bg); color: var(--tint-ok-text); border-color: var(--tint-ok-border); }
.status-badge.status-shipped      { color: var(--text-muted); }

/* ── Forms ───────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.required {
  color: var(--tint-urgent-text);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  padding: 0.5rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-placeholder);
}

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181, 104, 110, 0.15);
}

button[type="submit"] {
  padding: 0.55rem 1.4rem;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-btn);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.01em;
}

button[type="submit"]:hover {
  background: var(--accent-hover);
}

button[type="submit"]:disabled {
  background: var(--border-strong);
  cursor: not-allowed;
}

/* ── Recipe cards ────────────────────────────────────── */

.recipe-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-inner);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  background: #fdfaf8;
}

.recipe-card:last-child {
  margin-bottom: 0;
}

.recipe-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.recipe-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.recipe-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--border);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-tag);
}

.recipe-notes {
  font-size: 0.83rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.9rem;
}

.requirements-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 0.9rem;
}

.requirements-table thead th {
  text-align: left;
  padding: 0.35rem 0.6rem;
  font-weight: 600;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.requirements-table thead th:first-child,
.requirements-table thead th:last-child {
  border-radius: 0;
}

.requirements-table tbody td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #f3ede8;
  vertical-align: middle;
}

.requirements-table tbody tr:last-child td {
  border-bottom: none;
}

.btn-remove {
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--tint-critical-border);
  border-radius: var(--radius-btn);
  color: var(--tint-critical-text);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-remove:hover {
  background: var(--tint-critical-bg);
}

.add-req-form {
  margin-top: 0.75rem;
}

.add-req-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.add-req-row select {
  padding: 0.4rem 0.6rem;
  flex: 1;
  min-width: 180px;
}

.add-req-row input[type="number"] {
  width: 80px;
  flex-shrink: 0;
}

.add-req-row button {
  padding: 0.45rem 1rem;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-btn);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.add-req-row button:hover   { background: var(--accent-hover); }
.add-req-row button:disabled { background: var(--border-strong); cursor: not-allowed; }

.req-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Row action buttons ──────────────────────────────── */

.btn-receive {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-muted);
  transition: background 0.15s, border-color 0.15s;
}

.btn-receive:hover {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-delete {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--surface);
  border: 1.5px solid var(--tint-critical-border);
  border-radius: var(--radius-btn);
  color: var(--tint-critical-text);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-delete:hover {
  background: var(--tint-critical-bg);
}

/* ── Status select (orders table) ────────────────────── */

.status-select {
  padding: 0.3rem 0.55rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 0.83rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  max-width: 160px;
  transition: border-color 0.15s;
}

.status-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181, 104, 110, 0.15);
}

.status-select.status-new          { color: var(--text-muted); }
.status-select.status-ready        { color: #0a6694; }
.status-select.status-cutting      { color: #8a4a10; }
.status-select.status-embroidering { color: #5c3080; }
.status-select.status-sewing       { color: #0a6660; }
.status-select.status-finished     { color: #246028; }
.status-select.status-shipped      { color: var(--text-muted); }

/* ── Modal ───────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 20, 24, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 1.75rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border);
}

.modal h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.modal-actions button[type="button"] {
  padding: 0.45rem 1.1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s;
}

.modal-actions button[type="button"]:hover {
  background: var(--bg);
  color: var(--text);
}

/* ── Queue controls ──────────────────────────────────── */

.queue-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.sort-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-group label {
  font-size: 0.83rem;
  color: var(--text-muted);
  font-weight: 600;
}

.sort-group select {
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.83rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toggle-group input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ── Color group sections ────────────────────────────── */

.color-group {
  margin-bottom: 1.5rem;
}

.color-group:last-child {
  margin-bottom: 0;
}

.color-group-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0.4rem 0;
  margin-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}

/* ── Status / feedback messages ──────────────────────── */

.status-message {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-input);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.status-message.success {
  background: var(--tint-ok-bg);
  color: var(--tint-ok-text);
  border-color: var(--tint-ok-border);
}

.status-message.error {
  background: var(--tint-critical-bg);
  color: var(--tint-critical-text);
  border-color: var(--tint-critical-border);
}

.status-message.warning {
  background: var(--tint-warn-bg);
  color: var(--tint-warn-text);
  border-color: var(--tint-warn-border);
}

.hidden {
  display: none;
}

/* ── Nav alert badge ─────────────────────────────────── */

#nav-alerts.has-alerts {
  color: #f4b8c0;
}

#nav-alerts.has-alerts::after {
  content: attr(data-count);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.35rem;
  background: #9e2838;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-tag);
  vertical-align: middle;
}

/* ── Reorder alert tiers ─────────────────────────────── */

.alerts-table tr.critical td {
  background: var(--tint-critical-bg);
}

.alerts-table tr.critical td.alert-available {
  color: var(--tint-critical-text);
  font-weight: 700;
}

.alerts-table tr.low td.alert-available {
  color: var(--tint-urgent-text);
  font-weight: 600;
}

.tier-label {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-tag);
  white-space: nowrap;
}

.tier-critical {
  background: var(--tint-critical-bg);
  color: var(--tint-critical-text);
  border: 1px solid var(--tint-critical-border);
}

.tier-low {
  background: var(--tint-urgent-bg);
  color: var(--tint-urgent-text);
  border: 1px solid var(--tint-urgent-border);
}

.all-clear {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--tint-ok-text);
  background: var(--tint-ok-bg);
  border: 1px solid var(--tint-ok-border);
  border-radius: var(--radius-inner);
  font-size: 0.95rem;
  font-weight: 500;
}

/* ── Orders two-panel layout ─────────────────────────── */

.orders-layout {
  display: flex;
  height: calc(100vh - 54px - 4rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.orders-left {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Page-level header (Orders title + Sync/Add buttons) — sits above the
   stage tabs now that the two-panel layout is only one of several tab
   views, not the whole page. */
.orders-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.orders-page-header h2 {
  margin-bottom: 0;
}

#tab-content {
  min-height: 200px;
}

#orders-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.orders-right {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

/* ── Left panel compact card ──────────────────────────── */

.order-list-card {
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-inner);
  border: 1.5px solid transparent;
  margin-bottom: 3px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.3s ease,
              max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  max-height: 300px;
  overflow: hidden;
}

.order-list-card.fading-out {
  opacity: 0;
  max-height: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
}

.order-list-card:hover {
  background: var(--bg);
  border-color: var(--border);
}

.order-list-card.selected {
  background: #fdf0f1;
  border-color: var(--accent);
}

.order-list-card.overdue {
  background: var(--tint-critical-bg);
  border-color: var(--tint-critical-border);
}

.order-list-card.overdue.selected {
  border-color: var(--tint-critical-text);
}

.order-list-card.due-soon {
  background: var(--tint-urgent-bg);
  border-color: var(--tint-urgent-border);
}

.order-list-card.due-soon.selected {
  border-color: var(--tint-urgent-text);
}

.olc-customer {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.olc-sub {
  font-size: 0.775rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.olc-due {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-weight: 500;
}

.olc-due.overdue  { color: var(--tint-critical-text); font-weight: 600; }
.olc-due.due-soon { color: var(--tint-urgent-text);   font-weight: 600; }

/* ── Right panel ──────────────────────────────────────── */

.order-detail-empty,
.order-detail-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.order-detail-content {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.order-detail-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.1rem;
}

.odh-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.odh-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.due-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-tag);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.due-badge.overdue  { background: var(--tint-critical-bg); border-color: var(--tint-critical-border); color: var(--tint-critical-text); }
.due-badge.due-soon { background: var(--tint-urgent-bg);   border-color: var(--tint-urgent-border);   color: var(--tint-urgent-text); }

.etsy-listing-link {
  font-size: 0.8rem;
  color: var(--tint-urgent-text);
  text-decoration: none;
}

.etsy-listing-link:hover {
  text-decoration: underline;
}

.order-detail-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.detail-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ── Stat grid ────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.stat-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  padding: 0.65rem 0.85rem;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.stat-placeholder {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

.ship-to-address {
  white-space: pre-line; /* preserve newlines in the address block */
  font-weight: 400;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ── Personalization / embroidery ─────────────────────── */

.embroidery-section {
  background: #fdf8f5;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-inner);
  padding: 0.85rem 1rem;
}

.embroidery-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.embroidery-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}

/* ── Detail panel footer ──────────────────────────────── */

.order-detail-actions {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* ── Add Order button ─────────────────────────────────── */

.btn-add {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-add:hover { background: var(--accent-hover); }

/* ── Wider modal for create-order form ────────────────── */

.modal-wide { max-width: 520px; }

/* ── Responsive — mobile (≤640px) ───────────────────── */

@media (max-width: 640px) {
  /* Header: let it grow tall enough for a second nav row */
  header {
    height: auto;
    min-height: 54px;
    padding: 0.6rem 1rem;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: flex-start;
  }

  header h1 {
    line-height: 2.2; /* vertically centers with the nav row below */
  }

  /* Nav: scroll horizontally so no link is ever clipped — flex-wrap must be
     forced back off here since the desktop base rule now wraps by default. */
  nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 3px; /* keeps descenders from clipping into scrollbar */
    scrollbar-width: none;
  }

  nav::-webkit-scrollbar {
    display: none;
  }

  nav a {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
  }

  /* Main layout: tighter margins on small screens */
  main {
    padding: 0 0.75rem;
    margin: 1rem auto;
    gap: 1.25rem;
  }

  section {
    padding: 1.1rem;
  }

  /* Order cards: wrap into a two-line layout
   *
   * Line 1: icon (36px, shrink:0) + main content (flex:1)  — natural, no change needed
   * Line 2: due date (full width, with a separator above)
   * Line 3: status dropdown (flex:1, full-width select) + delete button
   */
  .order-card {
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.85rem;
  }

  .order-card-due {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  /* due-label was display:block; make it inline so it sits beside the date */
  .due-label {
    display: inline;
    margin-bottom: 0;
  }

  .order-card-status {
    flex: 1; /* expand to fill the remaining width beside the delete button */
  }

  /* status select fills its flex parent on mobile */
  .order-card-status .status-select {
    width: 100%;
    max-width: none;
    font-size: 0.9rem;
    padding: 0.5rem 0.6rem; /* bigger tap target */
  }

  /* delete button: taller tap target */
  .btn-delete {
    padding: 0.5rem 1rem;
    white-space: nowrap;
  }

  /* ── Recipe cards on mobile ─────────────────────────── */

  .recipe-card {
    padding: 0.9rem;
  }

  /* recipe-header already wraps (it's flex with no fixed widths) */

  /* Requirements table → convert rows to inline flex groups.
   * Hides the header row and reflows each <tr> as a flex container
   * so column labels don't waste space on a narrow screen.       */
  .requirements-table thead {
    display: none;
  }

  .requirements-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3ede8;
  }

  .requirements-table tbody tr:last-child {
    border-bottom: none;
  }

  .requirements-table tbody td {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border-bottom: none;
    font-size: 0.875rem;
  }

  /* Material name gets its own full-width line */
  .requirements-table tbody td:first-child {
    width: 100%;
    font-weight: 600;
  }

  /* Color, qty, unit flow naturally on the second line */

  /* Remove button pushed to the right on that same second line */
  .requirements-table tbody td:last-child {
    margin-left: auto;
    padding: 0.25rem 0; /* larger tap target vertically */
  }

  /* Add-requirement row:
   * Select goes full-width on its own line;
   * qty input and Add button share the line below.             */
  .add-req-row select {
    min-width: 0;
    width: 100%;
  }

  .add-req-row input[type="number"] {
    flex: 1; /* expand to fill space beside the Add button */
  }

  .add-req-row button {
    padding: 0.5rem 1.1rem; /* taller tap target */
  }

}

/* ── Orders two-panel → stack vertically (≤768px) ───── */
/* Separate breakpoint from the general 640px block because
 * the two-column layout needs more width than a single-card
 * layout does before it breaks down.                        */

/* ── Orders: left-header actions group ───────────────────────────────────── */
.olh-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ── Orders: stage filter tabs ────────────────────────────────────────────── */
.stage-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.stage-tab {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-tag);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.stage-tab:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.stage-tab.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.stage-tab-count {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.08);
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-tag);
}

.stage-tab.active .stage-tab-count {
  background: rgba(255, 255, 255, 0.25);
}

.btn-sync {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1.5px solid var(--rose, #c17080);
  color: var(--rose, #c17080);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-sync:hover:not(:disabled) {
  background: var(--rose, #c17080);
  color: #fff;
}

.btn-sync:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Orders list card: top row (customer + badge + chevron) ─────────────── */
.olc-top {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Chevron hidden on desktop; CSS-driven content swap on mobile */
.olc-chevron {
  display: none;
}

.olc-review-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: #fff3e0;
  color: #92400e;
  border: 1px solid #fcd34d;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Order detail: Needs Review badge in header ──────────────────────────── */
.detail-review-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #fff3e0;
  color: #92400e;
  border: 1px solid #fcd34d;
  vertical-align: middle;
  margin-left: 0.4rem;
}

/* ── Confirm Details section ─────────────────────────────────────────────── */
.confirm-details-section {
  border: 1.5px solid #fcd34d;
  border-radius: 8px;
  background: #fffbf0;
  padding: 1rem;
}

.confirm-details-hint {
  font-size: 0.82rem;
  color: #92400e;
  margin: 0 0 0.85rem 0;
}

.confirm-details-section .etsy-listing-link {
  display: inline-block;
  margin-bottom: 0.85rem;
}

/* ── Searchable dropdown (confirm-details size / fabric fields) ─────────── */

.searchable-dropdown {
  position: relative;
  margin-top: 0.2rem;
}

.searchable-dropdown-input {
  font-size: 0.82rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 5px;
  background: #fff;
  color: var(--text-dark, #333);
  width: 100%;
  font-family: inherit;
}

.searchable-dropdown-input:focus {
  outline: none;
  border-color: #d97706;
}

.searchable-dropdown-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border, #ddd);
  border-radius: 5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.searchable-dropdown-option {
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.searchable-dropdown-option.highlighted,
.searchable-dropdown-option:hover {
  background: #fef3e2;
}

.searchable-dropdown-empty {
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted, #888);
  font-style: italic;
}

.confirm-details-actions {
  margin-top: 0.85rem;
}

.btn-confirm-details {
  padding: 0.5rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: #d97706;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn-confirm-details:hover:not(:disabled) {
  background: #b45309;
}

.btn-confirm-details:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ── Orders two-panel → stack vertically (≤768px) ───── */
/* Separate breakpoint from the general 640px block because
 * the two-column layout needs more width than a single-card
 * layout does before it breaks down.                        */

@media (max-width: 768px) {
  .orders-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  /* Left panel fills width, scrolls with the page — no fixed height */
  .orders-left {
    width: 100%;
    height: auto;
    overflow-y: visible;
    border-right: none;
    border-bottom: none;
  }

  /* Stage tabs: scroll horizontally instead of wrapping — same pattern as
     the nav bar, since 8 tabs won't fit on a phone screen. */
  .stage-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .stage-tabs::-webkit-scrollbar {
    display: none;
  }

  /* Right panel hidden — detail appears inline between cards instead */
  .orders-right {
    display: none;
  }

  /* Inline detail panel injected after the tapped card */
  .mobile-detail-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-top: none;      /* visually connects to the card above */
    border-radius: 0 0 10px 10px;
    padding: 1rem 1rem 1.25rem;
    margin-bottom: 0.5rem;
  }

  /* Chevron: ▾ by default, ▴ when card is expanded */
  .olc-chevron {
    display: inline-block;
    margin-left: auto;
    color: #bbb;
    font-size: 0.7rem;
    line-height: 1;
  }

  .olc-chevron::before               { content: '▾'; }
  .order-list-card.expanded .olc-chevron::before { content: '▴'; }

  /* Confirm-details: dropdowns stack vertically, full-width, easy to tap */
  .confirm-details-section .stat-grid {
    grid-template-columns: 1fr;
  }

  .confirm-details-section .searchable-dropdown-input {
    font-size: 1rem;    /* prevents iOS auto-zoom on focus */
    padding: 0.55rem 0.5rem;
  }

  .btn-confirm-details {
    width: 100%;
    padding: 0.7rem;
    font-size: 1rem;
  }
}

/* ── Cut list page ─────────────────────────────────────── */

.cutlist-empty-card {
  max-width: 420px;
  margin: 3rem auto;
  text-align: center;
  padding: 2.5rem 2rem;
}

.cutlist-empty-card h2 {
  margin-bottom: 0.5rem;
}

.cutlist-empty-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.cutlist-session-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.cutlist-session-info h2 {
  margin-bottom: 0.3rem;
}

.cutlist-session-range {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cutlist-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.cutlist-progress-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.cutlist-progress-bar {
  width: 140px;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-tag);
  overflow: hidden;
}

.cutlist-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.btn-complete-session {
  padding: 0.55rem 1.3rem;
  background: var(--tint-ok-text);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-complete-session:hover:not(:disabled) {
  background: #1e4623;
}

.btn-complete-session:disabled {
  background: var(--border-strong);
  cursor: not-allowed;
}

.cutlist-sync-indicator {
  font-size: 0.75rem;
  color: var(--text-placeholder);
  margin-bottom: 1rem;
}

.cut-group {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-inner);
  margin-bottom: 0.85rem;
  overflow: hidden;
}

.cut-group-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.cut-group.all-checked .cut-group-header {
  background: var(--tint-ok-bg);
  border-bottom-color: var(--tint-ok-border);
}

.cut-group.collapsed .cut-group-header {
  border-bottom: none;
}

.cut-group-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.cut-group-stats {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.cut-group.all-checked .cut-group-stats {
  color: var(--tint-ok-text);
}

.cut-group-items {
  display: flex;
  flex-direction: column;
}

.cut-group.collapsed .cut-group-items {
  display: none;
}

/* ── Size subgroup (within a material group) ──────────── */

.cut-size-group {
  border-top: 1px solid #f3ede8;
}

.cut-size-group:first-child {
  border-top: none;
}

.cut-size-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 1rem 0.4rem 1.5rem;
  background: #fdf9f7;
}

.cut-size-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.cut-size-yardage {
  font-size: 0.72rem;
  color: var(--text-placeholder);
  white-space: nowrap;
}

.cut-size-items {
  display: flex;
  flex-direction: column;
}

.cut-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
  border-bottom: 1px solid #f3ede8;
  cursor: pointer;
}

.cut-item:last-child {
  border-bottom: none;
}

.cut-item:hover {
  background: #fdf9f7;
}

.cut-item-checkbox {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  accent-color: var(--accent);
  cursor: pointer;
}

.cut-item-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
}

.cut-item-primary {
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 600;
}

.cut-customer-link {
  font-size: 0.83rem;
  color: var(--accent);
  text-decoration: none;
}

.cut-customer-link:hover {
  text-decoration: underline;
}

.cut-item-due {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.cut-item-due.overdue    { color: var(--tint-critical-text); font-weight: 600; }
.cut-item-due.due-soon   { color: var(--tint-urgent-text); font-weight: 600; }

.cut-item.checked-item .cut-item-primary,
.cut-item.checked-item .cut-customer-link,
.cut-item.checked-item .cut-item-due {
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: 0.6;
}

/* ── Toast (order moved to Cutting) ───────────────────── */

.cutlist-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--tint-ok-bg);
  color: var(--tint-ok-text);
  border: 1px solid var(--tint-ok-border);
  border-radius: var(--radius-btn);
  padding: 0.7rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-modal);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.cutlist-toast.visible {
  opacity: 1;
}

/* Undo button inside a toast — must opt back into pointer-events since the
   toast itself is pointer-events:none (so it never blocks clicks behind it
   while invisible/fading). display:inline-flex keeps it aligned with the
   toast's text on one line. */
.toast-undo-btn {
  display: inline-flex;
  align-items: center;
  pointer-events: auto;
  margin-left: 0.4rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  background: rgba(0, 0, 0, 0.1);
  color: inherit;
  border: none;
  border-radius: var(--radius-tag);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.toast-undo-btn:hover {
  background: rgba(0, 0, 0, 0.18);
}

/* ── Cut session create modal ─────────────────────────── */

.cutlist-date-range {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.cutlist-date-range .field { flex: 1; }

.cutlist-date-range-to {
  font-size: 0.83rem;
  color: var(--text-muted);
  padding-top: 1.2rem;
}

.modal-error {
  margin-top: 0.85rem;
}

/* ── Responsive — cut list (mobile) ───────────────────── */

@media (max-width: 640px) {
  .cutlist-session-header {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-complete-session {
    width: 100%;
  }

  .cut-item-checkbox {
    width: 28px;
    height: 28px;
  }

  .cutlist-date-range {
    flex-direction: column;
    align-items: stretch;
  }

  .cutlist-date-range-to {
    padding-top: 0;
  }
}

/* ── Embroidery queue page ────────────────────────────── */

.embroidery-page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.embroidery-page-header h2 {
  margin-bottom: 0;
}

.embroidery-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

#embroidery-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.embroidery-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease,
              padding 0.3s ease, border-width 0.3s ease;
  max-height: 600px;
  overflow: hidden;
}

.embroidery-card.fading-out {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding: 0 1.25rem;
  border-width: 0;
}

.embroidery-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.embroidery-card-customer {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.embroidery-card-spec {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.embroidery-card .etsy-listing-link {
  display: inline-block;
  margin-bottom: 0.85rem;
}

.embroider-side-block {
  background: var(--bg);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-inner);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.embroider-side-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.embroider-side-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.embroidery-details-block {
  background: #fdf8f5;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-inner);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.embroidery-details-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.embroidery-details-text {
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

.embroidery-details-empty {
  color: var(--text-placeholder);
  font-style: italic;
  font-size: 0.95rem;
}

.embroidery-card-error {
  font-size: 0.83rem;
  color: var(--tint-critical-text);
  background: var(--tint-critical-bg);
  border: 1px solid var(--tint-critical-border);
  border-radius: var(--radius-input);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.btn-done-embroidering,
.btn-done-sewing,
.btn-done-packaging,
.btn-mark-shipped {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  min-height: 48px;
  transition: background 0.15s;
}

.btn-done-embroidering:hover:not(:disabled),
.btn-done-sewing:hover:not(:disabled),
.btn-done-packaging:hover:not(:disabled),
.btn-mark-shipped:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-done-embroidering:disabled,
.btn-done-sewing:disabled,
.btn-done-packaging:disabled,
.btn-mark-shipped:disabled {
  background: var(--border-strong);
  cursor: not-allowed;
}

/* ── Shipping page ─────────────────────────────────────── */

.ship-summary-bar {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.ship-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.ship-panel {
  flex: 1;
  min-width: 0;
}

.ship-panel #recent-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recent-shipped-card {
  opacity: 0.72;
  border-color: var(--border);
  box-shadow: none;
}

.recent-shipped-card .embroidery-card-spec {
  color: var(--text-placeholder);
}

.recent-shipped-card.just-arrived {
  opacity: 1;
  outline: 2px solid var(--tint-ok-border);
  outline-offset: -2px;
  transition: outline-color 1.2s ease;
}

.ship-recent-time {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

@media (max-width: 768px) {
  .ship-layout {
    flex-direction: column;
  }

  .ship-panel {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .embroidery-card-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .embroidery-card {
    padding: 1rem;
  }
}

/* ── Inventory page ───────────────────────────────────── */

.inv-alert-bar {
  background: var(--tint-ok-bg);
  color: var(--tint-ok-text);
  border: 1px solid var(--tint-ok-border);
  border-radius: var(--radius-inner);
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: filter 0.15s;
}

.inv-alert-bar:hover {
  filter: brightness(0.97);
}

.inv-alert-bar.inv-alert-bar-warn {
  background: var(--tint-urgent-bg);
  color: var(--tint-urgent-text);
  border-color: var(--tint-urgent-border);
}

.inv-mode-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.inv-mode-tab {
  padding: 0.5rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.inv-mode-tab:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.inv-mode-tab.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* ── Category sections ─────────────────────────────────── */

.inv-category-section {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.inv-category-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.inv-category-section.collapsed .inv-category-header {
  border-bottom: none;
}

.inv-category-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.inv-category-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.inv-category-body {
  padding: 0.5rem;
}

.inv-category-section.collapsed .inv-category-body {
  display: none;
}

/* ── Fabric family subgroups ───────────────────────────── */

.inv-family-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.inv-family-group:last-child {
  margin-bottom: 0;
}

.inv-family-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  background: #fdf9f7;
  border-bottom: 1px solid #f3ede8;
  cursor: pointer;
  user-select: none;
}

.inv-family-group.collapsed .inv-family-header {
  border-bottom: none;
}

.inv-family-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.inv-family-count {
  font-size: 0.75rem;
  color: var(--text-placeholder);
  white-space: nowrap;
}

.inv-family-items {
  display: flex;
  flex-direction: column;
}

.inv-family-group.collapsed .inv-family-items {
  display: none;
}

/* ── Item rows ──────────────────────────────────────────── */

.inv-item-row {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid #f3ede8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
}

.inv-item-row:last-child {
  border-bottom: none;
}

.inv-item-row.stock-low {
  background: var(--tint-urgent-bg);
}

.inv-item-row.stock-critical {
  background: var(--tint-critical-bg);
}

.inv-item-row.inv-flash {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.inv-item-main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex: 1 1 220px;
  min-width: 0;
}

.inv-item-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.inv-item-color {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.inv-item-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  flex: 2 1 320px;
}

.inv-stat {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}

.inv-stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  margin-right: 0.3rem;
}

.inv-item-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.inv-item-actions button {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-btn);
  cursor: pointer;
  white-space: nowrap;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
}

.inv-item-actions button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-inv-receive:hover { border-color: var(--tint-ok-border); color: var(--tint-ok-text); }
.btn-inv-use:hover      { border-color: var(--tint-urgent-border); color: var(--tint-urgent-text); }

.inv-inline-slot:not(:empty) {
  flex-basis: 100%;
  margin-top: 0.5rem;
}

.inv-inline-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inv-inline-qty {
  padding: 0.4rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 0.85rem;
  font-family: inherit;
  width: 160px;
}

.btn-inline-confirm {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
}

.btn-inline-confirm:hover { background: var(--accent-hover); }

.btn-inline-cancel {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  cursor: pointer;
}

.btn-inline-cancel:hover { background: var(--bg); color: var(--text); }

.inv-edit-form {
  flex-basis: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  padding: 0.85rem;
}

.inv-edit-form .form-grid {
  margin-bottom: 0.75rem;
}

.inv-edit-actions {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .inv-item-row {
    flex-direction: column;
    align-items: stretch;
  }

  .inv-item-actions {
    flex-direction: column;
  }

  .inv-item-actions button {
    width: 100%;
    padding: 0.6rem;
  }

  .inv-inline-qty {
    width: 100%;
  }

  .inv-inline-form {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Auth: login/join pages, user chip, users page (2026-07-14) ───────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 1.5rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 380px;
}

.auth-brand {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--header-bg);
  margin-bottom: 0.35rem;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.auth-card .field { margin-bottom: 1rem; }

.auth-submit {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.6rem;
  font-size: 0.95rem;
}

.auth-error {
  color: var(--tint-critical-text, #8b1e1e);
  background: var(--tint-critical-bg, #fdecec);
  border: 1px solid var(--tint-critical-border, #f2b8b0);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  margin: 0.75rem 0;
}

.auth-footnote {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Right-edge chip in the header: display name + logout */
.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-user-name {
  color: var(--header-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.nav-logout {
  background: rgba(255, 255, 255, 0.08);
  color: var(--header-muted);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-btn);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}

.nav-logout:hover {
  color: var(--header-text);
  background: rgba(255, 255, 255, 0.14);
}

/* Users page */
.users-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.users-header h2 { margin-bottom: 0; }

.new-invite-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--tint-ok-bg, #eef7ee);
  border: 1px solid var(--tint-ok-border, #bfe3bf);
  border-radius: var(--radius-inner, 10px);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.25rem;
}
.nib-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.new-invite-banner code {
  font-size: 0.9rem;
  font-weight: 600;
  word-break: break-all;
}

.user-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-tag, 999px);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.user-badge.active {
  background: var(--tint-ok-bg, #eef7ee);
  border-color: var(--tint-ok-border, #bfe3bf);
  color: var(--tint-ok-text, #1e6b1e);
}
.user-badge.inactive {
  background: var(--tint-urgent-bg);
  border-color: var(--tint-urgent-border);
  color: var(--tint-urgent-text);
}

tr.user-inactive td { opacity: 0.55; }
.user-you { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }

.btn-toggle-active, .btn-revoke, .btn-copy-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn, 8px);
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text);
}
.btn-toggle-active:hover, .btn-copy-row:hover { border-color: var(--border-strong); }
.btn-revoke:hover {
  border-color: var(--tint-critical-border, #f2b8b0);
  color: var(--tint-critical-text, #8b1e1e);
}

/* ── Roles + profile (2026-07-14) ─────────────────────────────────────── */

a.nav-user-name { text-decoration: none; }
a.nav-user-name:hover { color: var(--header-text); text-decoration: underline; }

.invite-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.invite-actions select { font-size: 0.82rem; }

.profile-section { max-width: 480px; }
.profile-section .field { margin-bottom: 1rem; }
