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

:root {
  --sidebar-bg: #1e2130;
  --sidebar-text: #c8ccd8;
  --sidebar-active: #e8922a;
  --accent: #e8922a;
  --accent-dark: #c97820;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --border: #e0e3ea;
  --text: #1e2130;
  --text-muted: #7a8299;
  --status-new: #3b82f6;
  --status-inprogress: #f59e0b;
  --status-completed: #10b981;
  --danger: #ef4444;
  --sidebar-width: 220px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo-img {
  display: block;
  height: 48px;
  width: auto;
  margin-bottom: 0.3rem;
}
.logo-sub  { font-size: 0.65rem; font-weight: 400; color: var(--sidebar-text);
             letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }

.nav-links { list-style: none; flex: 1; padding: 0.75rem 0; }
.nav-links li a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
}
.nav-links li a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-links li a.active { color: var(--accent); background: rgba(232,146,42,0.1); }
.nav-svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  border-radius: 50%; min-width: 18px; height: 18px;
  font-size: 0.65rem; font-weight: 700; padding: 0 3px;
  margin-left: auto;
}
.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 0.5rem 1.25rem; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
}
.user-info { color: #fff; font-weight: 600; margin-bottom: 0.35rem; }
.logout-link { color: var(--sidebar-text); text-decoration: none; }
.logout-link:hover { color: var(--accent); }

/* ── CONTENT ────────────────────────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
}

/* ── LOGIN ──────────────────────────────────────────────────────────────── */
.login-body { background: var(--sidebar-bg); display: flex; align-items: center;
              justify-content: center; min-height: 100vh; margin: 0; }
.login-card {
  background: var(--card-bg); border-radius: 12px; padding: 2.5rem;
  width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-logo { text-align: center; margin-bottom: 2rem; font-size: 1.5rem; font-weight: 800; }
.login-logo img { display: block; margin: 0 auto 0.75rem; height: 80px; width: auto; }
.login-form label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.login-form select, .login-form input {
  width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; margin-bottom: 1rem;
}
.btn-full { width: 100%; }

/* ── PAGE HEADER ────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-meta { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.25rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; }

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: 10px;
  border: 1px solid var(--border); margin-bottom: 1.25rem;
  overflow: hidden;
}
.card-header {
  padding: 0.75rem 1.25rem; font-weight: 600; font-size: 0.875rem;
  border-bottom: 1px solid var(--border); background: #fafbfc;
}

/* ── STAT GRID ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card-bg); border-radius: 10px; padding: 1.25rem 1.5rem;
  border-left: 4px solid transparent;
}
.stat-new         { border-color: var(--status-new); }
.stat-inprogress  { border-color: var(--status-inprogress); }
.stat-completed   { border-color: var(--status-completed); }
.stat-jobs        { border-color: var(--accent); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.25rem; }

.dashboard-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

/* ── TABLES ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 0.65rem 1rem; text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase;
            letter-spacing: 0.5px; color: var(--text-muted); background: #fafbfc; }
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: none; }
.table-sm th, .table-sm td { padding: 0.4rem 0.75rem; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
.sort-ind { font-size: 0.7rem; opacity: 0.6; }

/* ── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 0.2rem 0.55rem; border-radius: 12px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-new           { background: #dbeafe; color: #1d4ed8; }
.badge-in-progress   { background: #fef3c7; color: #92400e; }
.badge-completed     { background: #d1fae5; color: #065f46; }
.badge-info          { background: #e0e7ff; color: #3730a3; }
.badge-archived      { background: #f3f4f6; color: var(--text-muted); }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block; padding: 0.5rem 1rem; border-radius: 6px; border: none;
  font-size: 0.875rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.btn-xs {
  display: inline-block; padding: 0.2rem 0.55rem; border-radius: 4px; border: none;
  font-size: 0.75rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-xs.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-xs.btn-secondary:hover { background: #d1d5db; }
.btn-xs.btn-danger    { background: #fee2e2; color: var(--danger); }
.btn-xs.btn-danger:hover { background: #fecaca; }
.btn-xs.btn-inprogress { background: #fef3c7; color: #92400e; }
.btn-xs.btn-inprogress:hover { background: #fde68a; }
.btn-xs.btn-completed { background: #d1fae5; color: #065f46; }
.btn-xs.btn-completed:hover { background: #a7f3d0; }
.btn-xs.btn-new { background: #dbeafe; color: #1d4ed8; }
.btn-xs.btn-new:hover { background: #bfdbfe; }
.btn-xs.btn-primary { background: var(--accent); color: #fff; }

/* ── FILTER BAR (queue page) ────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.25rem;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.75rem 1rem;
}
.filter-group { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.filter-label { font-weight: 600; font-size: 0.8rem; color: var(--text-muted);
                margin-right: 0.25rem; white-space: nowrap; }
.filter-btn {
  padding: 0.25rem 0.65rem; border-radius: 20px; border: 1px solid var(--border);
  background: #fff; color: var(--text-muted); font-size: 0.8rem; text-decoration: none;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── TABLE FILTER BAR (filaments page) ─────────────────────────────────── */
.table-filter-bar {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: #fafbfc;
}
.fil-input {
  flex: 1; min-width: 200px; padding: 0.4rem 0.65rem;
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;
}
.fil-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,146,42,0.1); }
.fil-select {
  padding: 0.4rem 0.65rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.85rem; background: #fff;
}
.fil-fav-label {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
  cursor: pointer; white-space: nowrap;
}
.fil-count { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* ── QUEUE TABLE ────────────────────────────────────────────────────────── */
.queue-table {
  table-layout: fixed;
  width: 100%;
}
.queue-table th:nth-child(1),
.queue-table td:nth-child(1) { width: 90px; }
.queue-table th:nth-child(2),
.queue-table td:nth-child(2) { width: 170px; }
.queue-table th:nth-child(3),
.queue-table td:nth-child(3) { width: auto; text-align: center; }
.queue-table th:nth-child(4),
.queue-table td:nth-child(4) { width: 230px; white-space: nowrap; }
.queue-table .actions { white-space: nowrap; }
.printer-select {
  padding: 0.25rem 0.4rem; border: 1px solid var(--border); border-radius: 4px;
  font-size: 0.8rem; background: #fff; width: 100%;
}
.item-pill { max-width: 100%; }
.item-pill-filament { flex-wrap: wrap; }
.item-list { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; }
.item-pill {
  display: inline-flex; flex-direction: column; gap: 0.15rem;
  background: #f3f4f6; border-radius: 4px; padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}
.item-pill-row {
  display: flex; align-items: center; gap: 0.35rem;
}
.item-pill-name { font-weight: 500; }
.item-pill-filament {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.75rem; color: var(--text-muted);
}
.queue-copy-btn {
  background: none; border: none; cursor: pointer; font-size: 0.78rem;
  color: var(--text-muted); padding: 0; flex-shrink: 0; transition: color 0.15s;
}
.queue-copy-btn:hover { color: var(--accent); }
.color-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0;
}
.status-cell { display: flex; flex-direction: column; gap: 0.3rem; }
.status-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }

/* ── FILAMENTS TABLE ────────────────────────────────────────────────────── */
.color-cell { display: flex; align-items: center; gap: 0.5rem; }
.color-swatch {
  width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}
.fav-btn {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  color: #d1d5db; padding: 0;
}
.fav-btn.fav-on { color: #f59e0b; }
.fav-btn:hover { color: #f59e0b; }

/* ── FORMS ──────────────────────────────────────────────────────────────── */
.form-section { padding: 1.25rem; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; }
.form-section h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 1rem;
                   text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.section-header { display: flex; align-items: center; justify-content: space-between;
                  margin-bottom: 0.75rem; }
.section-header h3 { margin-bottom: 0; }

.form-row { display: flex; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 160px; }
.form-group.flex-2 { flex: 2; }
.form-group-check { justify-content: flex-end; min-width: auto; flex: 0; white-space: nowrap; }

label { font-weight: 600; font-size: 0.8rem; color: var(--text); }
input[type=text], input[type=number], input[type=url], input[type=email],
select, textarea {
  padding: 0.45rem 0.65rem; border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.875rem; background: #fff; color: var(--text);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,146,42,0.1);
}
textarea { resize: vertical; }
.req { color: var(--danger); }
.help-text { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.form-actions { padding: 1.25rem; }
.inline-form-stack { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.inline-form select, .inline-form input { flex: 1; min-width: 120px; }

/* ── PLATE ITEMS TABLE (job detail) ────────────────────────────────────── */
.plate-items .table th:nth-child(1),
.plate-items .table td:nth-child(1) { width: 28%; }
.plate-items .table th:nth-child(2),
.plate-items .table td:nth-child(2) { width: 54%; }
.plate-items .table th:nth-child(3),
.plate-items .table td:nth-child(3) { width: 60px; text-align: center; }
.plate-items .table th:nth-child(4),
.plate-items .table td:nth-child(4) { width: 90px; text-align: right; }

/* ── MODEL RUNS TABLE (add job) ─────────────────────────────────────────── */
.model-runs-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.model-runs-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.model-runs-table thead th {
  padding: 0.45rem 0.85rem; text-align: left; white-space: nowrap;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
  border-bottom: 2px solid var(--border); background: var(--card-bg);
}
.model-runs-table .col-num { width: 88px; text-align: center; }
.model-runs-table thead .col-num { text-align: center; }
.model-runs-table .col-del { width: 36px; }
.model-run td {
  padding: 0.65rem 0.85rem; vertical-align: top;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.model-run:last-child td { border-bottom: none; }
.run-td-num { text-align: center; }
.run-td-num input[type="number"] { width: 100%; text-align: center; }
.run-td-del { text-align: center; vertical-align: middle !important; }
.plates-calc {
  font-size: 0.85rem; font-weight: 700; color: var(--accent);
  padding-top: 0.5rem; text-align: center; white-space: nowrap;
}
.run-model-notes { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }
.run-size-input {
  width: 100%; margin-top: 0.3rem; font-size: 0.78rem;
  padding: 0.22rem 0.45rem; border-radius: 4px; border: 1px solid var(--border);
  background: var(--card-bg); color: var(--text);
}
.run-size-input::placeholder { color: var(--text-muted); opacity: 0.7; }
.filament-col { display: flex; flex-direction: column; gap: 0.3rem; min-width: 180px; }
.filament-row { display: flex; gap: 0.3rem; align-items: center; }
.filament-row select { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.remove-fil-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 0.8rem; padding: 0 0.2rem; flex-shrink: 0; }
.remove-fil-btn:hover { color: var(--danger); }
.add-fil-btn { align-self: flex-start; margin-top: 0.1rem; }
.remove-run {
  background: none; border: 1px solid #fca5a5; color: var(--danger);
  border-radius: 4px; width: 28px; height: 28px; cursor: pointer; font-size: 0.8rem;
}
.remove-run:hover { background: #fee2e2; }
.empty-runs { color: var(--text-muted); font-size: 0.875rem; padding: 1rem 0; }

/* ── JOB DETAIL PLATES ──────────────────────────────────────────────────── */
.plate-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 1rem; overflow: hidden;
}
.plate-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; background: #fafbfc; border-bottom: 1px solid var(--border);
  gap: 0.75rem; flex-wrap: wrap;
}
.plate-title { display: flex; align-items: center; gap: 0.5rem; }
.plate-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.plate-items { padding: 0.75rem 1rem; }

details.add-item-form { margin-top: 0.75rem; }
details.add-item-form summary { cursor: pointer; list-style: none; }
details.add-item-form summary::-webkit-details-marker { display: none; }
details.add-item-form .inline-form { margin-top: 0.5rem; }

/* ── MODALS ─────────────────────────────────────────────────────────────── */
.modal {
  display: none; position: fixed; inset: 0; z-index: 1000;
  align-items: center; justify-content: center;
}
.modal.active { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.45);
}
.modal-box {
  position: relative; background: var(--card-bg); border-radius: 12px;
  padding: 0; width: 500px; max-width: 95vw; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; font-weight: 700; border-bottom: 1px solid var(--border);
}
.modal-close {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  color: var(--text-muted); padding: 0;
}
.modal-close:hover { color: var(--text); }

/* ── MODELS PAGE ────────────────────────────────────────────────────────── */
.sku-tag {
  font-family: monospace; font-size: 0.75rem; background: #f0f2f5;
  border: 1px solid var(--border); border-radius: 4px; padding: 0.1rem 0.4rem;
  color: var(--text-muted);
}
.sku-readonly {
  font-family: monospace; font-size: 0.85rem; background: #f9fafb;
  border: 1px solid var(--border); border-radius: 6px; padding: 0.45rem 0.65rem;
  color: var(--text-muted);
}
.model-archived td { opacity: 0.6; }

.archived-section { margin-bottom: 1.25rem; }
.archived-section-header {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; list-style: none;
  font-size: 0.875rem; font-weight: 600; color: var(--text-muted);
  padding: 0.5rem 0;
  user-select: none;
}
.archived-section-header::-webkit-details-marker { display: none; }
.archived-section-header:hover { color: var(--text); }
.archived-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: #f3f4f6; border: 1px solid var(--border);
  border-radius: 50%; width: 20px; height: 20px; font-size: 0.7rem;
}

/* ── SYNC TOAST ─────────────────────────────────────────────────────────── */
.sync-toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 2000;
  background: #16a34a; color: #fff; border-radius: 8px;
  padding: 0.75rem 1.25rem; font-size: 0.875rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.sync-toast.visible { opacity: 1; transform: translateY(0); }

/* ── CONSIGNMENT ORDERS PAGE ────────────────────────────────────────────── */
.consignment-order-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 1.25rem; overflow: hidden;
}
.consignment-card-header {
  padding: 0.9rem 1.25rem; background: #fafbfc;
  border-bottom: 1px solid var(--border);
}
.consignment-order-meta {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  font-size: 0.9rem; margin-bottom: 0.2rem;
}
.consignment-card-body { padding: 1.25rem; }
.consignment-items-table { margin-bottom: 1rem; }
.consignment-items-table select { min-width: 0; }
.consignment-card-actions {
  display: flex; gap: 0.75rem; align-items: center;
  padding-top: 0.75rem; border-top: 1px solid var(--border);
}
.match-warning {
  color: var(--accent); font-size: 0.9rem; margin-left: 0.2rem;
}
.consignment-model-select { width: 100%; }
.consignment-color-dots { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 0.35rem; min-height: 0; }
.filament-list { display: flex; flex-direction: column; gap: 0.2rem; }
.filament-list-row { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; }
.consignment-filament-cell { display: flex; align-items: center; gap: 0.4rem; }
.consignment-filament-cell .consignment-filament { flex: 1; min-width: 0; }
.consignment-fil-swatch {
  width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15); background: #e5e7eb;
}
.order-note-col { width: 160px; }
.order-note-text {
  font-size: 0.82rem; color: var(--text-muted); font-style: italic;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── MISC ───────────────────────────────────────────────────────────────── */
.actions { white-space: nowrap; }
.text-muted { color: var(--text-muted); }
.empty-msg { padding: 1.25rem; color: var(--text-muted); }
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.link-external { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.link-external:hover { text-decoration: underline; }
.network-path { font-family: monospace; font-size: 0.78rem; color: var(--text-muted); }
.network-path-cell { display: flex; align-items: center; gap: 0.4rem; }
.copy-btn {
  background: none; border: none; cursor: pointer; font-size: 0.85rem;
  color: var(--text-muted); padding: 0; flex-shrink: 0;
  transition: color 0.15s;
}
.copy-btn:hover { color: var(--accent); }

.default-colors { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; max-width: 280px; }
.models-table td:nth-child(9) { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.default-color-tag {
  display: inline-flex; align-items: center; gap: 0.2rem;
  border-radius: 50px; padding: 0.15rem 0.3rem;
  border: 1px solid var(--border); background: #f9fafb;
}
.color-dot-lg {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0;
}
.remove-color-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 0.8rem; line-height: 1; padding: 0;
}
.remove-color-btn:hover { color: var(--danger); }

.hex-rows { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.5rem; }
.hex-row { display: flex; align-items: center; gap: 0.5rem; }
.hex-row input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.hex-row .hex-text { width: 90px; font-family: monospace; }
.remove-hex-btn { background: none; border: 1px solid #fca5a5; color: var(--danger); border-radius: 4px; width: 28px; height: 28px; cursor: pointer; font-size: 0.8rem; flex-shrink: 0; }
.remove-hex-btn:hover { background: #fee2e2; }

/* ── MODEL FILAMENT ROWS (add model form) ───────────────────────────────── */
.model-filament-rows { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.5rem; }
.model-filament-row { display: flex; align-items: center; gap: 0.5rem; }
.model-filament-row select { flex: 1; }

/* ── INLINE QTY EDIT ────────────────────────────────────────────────────── */
.qty-edit {
  cursor: pointer; border-bottom: 1px dashed var(--text-muted);
  padding-bottom: 1px;
}
.qty-edit:hover { border-bottom-color: var(--accent); color: var(--accent); }

/* ── MODEL MODALS ───────────────────────────────────────────────────────── */
#add-model-modal .modal-box,
#edit-model-modal .modal-box { width: 700px; }
.modal-loading {
  padding: 2rem; text-align: center; color: var(--text-muted); font-size: 0.875rem;
}
.default-color-entry {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0; border-bottom: 1px dashed var(--border);
  font-size: 0.82rem;
}
.default-color-entry:last-child { border-bottom: none; }
.default-color-entry-label { flex: 1; }
#edit-model-defaults { min-height: 0.5rem; margin-bottom: 0.5rem; }
.add-color-inline { display: flex; gap: 0.5rem; align-items: center; }
.add-color-inline select { flex: 1; }

.model-parent td:first-child { font-weight: 600; }
.model-part { background: #fafbfc; }
.model-part td:first-child { padding-left: 1.5rem; }
.part-indent { color: var(--text-muted); margin-right: 0.3rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

.flash-container { margin-bottom: 1rem; }
.flash {
  background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
  border-radius: 6px; padding: 0.6rem 1rem; margin-bottom: 0.5rem; font-size: 0.875rem;
}
.flash.flash-success {
  background: #f0fff4; color: #276749; border-color: #9ae6b4;
}
.flash.flash-warning {
  background: #fffbeb; color: #92400e; border-color: #fcd34d;
}

/* ── SEARCHABLE SELECT ──────────────────────────────────────────────────────── */
.model-search-wrapper { position: relative; flex: 1; min-width: 0; }
.model-search-input {
  width: 100%; padding: 0.45rem 0.65rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.875rem; background: var(--card-bg); color: var(--text);
}
.model-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,146,42,0.1); }
.model-search-dropdown {
  display: none; position: fixed;
  max-height: 220px; overflow-y: auto; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: 6px; z-index: 9999;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.model-search-opt {
  padding: 0.4rem 0.75rem; cursor: pointer; font-size: 0.85rem; color: var(--text);
}
.model-search-opt:hover { background: var(--bg); }
.model-search-empty { padding: 0.5rem 0.75rem; color: var(--text-muted); font-size: 0.85rem; }

/* ── DARK MODE ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #16181f;
  --card-bg: #1e2130;
  --border: #2e3347;
  --text: #e2e8f0;
  --text-muted: #8892a4;
}

[data-theme="dark"] body { background: var(--bg); color: var(--text); }

[data-theme="dark"] .card-header,
[data-theme="dark"] .table th,
[data-theme="dark"] .table-filter-bar,
[data-theme="dark"] .plate-header,
[data-theme="dark"] .consignment-card-header { background: #252839; }

[data-theme="dark"] .table tbody tr:hover { background: #252839; }

[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=number],
[data-theme="dark"] input[type=url],
[data-theme="dark"] input[type=email],
[data-theme="dark"] input[type=date],
[data-theme="dark"] input[type=password],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #252839; color: var(--text); border-color: var(--border);
}

[data-theme="dark"] .filter-btn { background: #252839; color: var(--text-muted); }
[data-theme="dark"] .filter-btn:hover { color: var(--accent); }

[data-theme="dark"] .btn-secondary { background: #2e3347; color: var(--text); }
[data-theme="dark"] .btn-secondary:hover { background: #3a3f55; }
[data-theme="dark"] .btn-xs.btn-secondary { background: #2e3347; color: var(--text); }
[data-theme="dark"] .btn-xs.btn-secondary:hover { background: #3a3f55; }

[data-theme="dark"] .printer-select,
[data-theme="dark"] .fil-select { background: #252839; color: var(--text); }

[data-theme="dark"] .item-pill { background: #252839; }
[data-theme="dark"] .model-run td { background: #252839; }
[data-theme="dark"] .run-size-input { background: #252839; border-color: var(--border); }
[data-theme="dark"] .sku-tag { background: #252839; }
[data-theme="dark"] .sku-readonly { background: #252839; color: var(--text-muted); }
[data-theme="dark"] .model-part { background: #1a1c27; }
[data-theme="dark"] .archived-count { background: #252839; }
[data-theme="dark"] .default-color-tag { background: #252839; }
[data-theme="dark"] .loc-tab { background: #252839; color: var(--text-muted); }
[data-theme="dark"] .loc-tab:hover { background: #2e3347; color: var(--text); }

[data-theme="dark"] .flash { background: #3b1e1e; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .flash.flash-success { background: #1c4532; color: #9ae6b4; border-color: #276749; }
[data-theme="dark"] .flash.flash-warning { background: #2d2008; color: #fcd34d; border-color: #92400e; }

/* ── DUE DATE BADGES ──────────────────────────────────────────────────────── */
.due-badge {
  display: inline-flex; align-items: center; gap: 0.2rem;
  padding: 0.18rem 0.55rem; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 700; white-space: nowrap; line-height: 1.4;
}
.due-badge.due-asap    { background: #fee2e2; color: #991b1b; }
.due-badge.due-next    { background: #dbeafe; color: #1e40af; }
.due-badge.due-date    { background: #fff7ed; color: #c2410c; }
.due-badge.due-soon    { background: #ffedd5; color: #9a3412; }
.due-badge.due-overdue { background: #fee2e2; color: #7f1d1d; }
.due-badge.due-none    { background: #f1f5f9; color: #64748b; }

[data-theme="dark"] .due-badge.due-asap    { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .due-badge.due-next    { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .due-badge.due-date    { background: #431407; color: #fdba74; }
[data-theme="dark"] .due-badge.due-soon    { background: #431407; color: #fb923c; }
[data-theme="dark"] .due-badge.due-overdue { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .due-badge.due-none    { background: #1e293b; color: #94a3b8; }

/* ── QUEUE GROUP HEADERS ─────────────────────────────────────────────────── */
.queue-group-hdr {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0 0.3rem; margin-top: 0.5rem;
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.queue-group-hdr .due-badge { font-size: 0.68rem; }

/* ── DUE DATE PILL PICKER (add job form) ─────────────────────────────────── */
.due-picker-section { margin-bottom: 1.25rem; }
.due-picker-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
                    letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.4rem; }
.due-pill-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.due-pill {
  padding: 0.32rem 0.85rem; border-radius: 9999px; font-size: 0.82rem; font-weight: 600;
  border: 2px solid var(--border); background: var(--card-bg); color: var(--text-muted);
  cursor: pointer; transition: all 0.15s; line-height: 1.3;
}
.due-pill:hover { border-color: var(--accent); color: var(--accent); }
.due-pill.active[data-type="none"]           { background: #f1f5f9; color: #475569; border-color: #94a3b8; }
.due-pill.active[data-type="asap"]           { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.due-pill.active[data-type="next_available"] { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.due-pill.active[data-type="date"]           { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.due-date-input-wrap { margin-top: 0.5rem; display: none; }
.due-date-input-wrap.visible { display: block; }
#due_date_input { max-width: 180px; }

[data-theme="dark"] .due-pill { background: #252839; border-color: var(--border); }
[data-theme="dark"] .due-pill.active[data-type="none"]           { background: #1e293b; color: #94a3b8; border-color: #475569; }
[data-theme="dark"] .due-pill.active[data-type="asap"]           { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .due-pill.active[data-type="next_available"] { background: #1e3a5f; color: #93c5fd; border-color: #1d4ed8; }
[data-theme="dark"] .due-pill.active[data-type="date"]           { background: #431407; color: #fdba74; border-color: #c2410c; }

/* ── SIZE TAG & INPUT ────────────────────────────────────────────────────── */
.size-tag {
  display: inline-block; font-size: 0.68rem; font-weight: 600;
  padding: 0.1rem 0.4rem; border-radius: 4px;
  background: var(--border); color: var(--text-muted); margin-left: 0.3rem;
  vertical-align: middle;
}
.run-size-input {
  width: 100%; margin-top: 0.3rem; font-size: 0.78rem;
  padding: 0.22rem 0.45rem; border-radius: 4px; border: 1px solid var(--border);
  background: var(--card-bg); color: var(--text);
}
.run-size-input::placeholder { color: var(--text-muted); opacity: 0.7; }
[data-theme="dark"] .run-size-input { background: #252839; border-color: var(--border); }

/* ── URGENT JOBS STRIP (dashboard) ──────────────────────────────────────── */
.urgent-strip {
  background: #fff7ed; border: 1px solid #fdba74; border-radius: 10px;
  padding: 0.75rem 1rem; margin-bottom: 1.25rem;
  display: flex; align-items: flex-start; gap: 0.6rem;
}
.urgent-strip-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.05rem; }
.urgent-strip-body { flex: 1; min-width: 0; }
.urgent-strip-title { font-weight: 700; font-size: 0.85rem; color: #92400e; margin-bottom: 0.3rem; }
.urgent-strip-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
[data-theme="dark"] .urgent-strip { background: #2d1a00; border-color: #92400e; }
[data-theme="dark"] .urgent-strip-title { color: #fbbf24; }

/* Dark mode toggle button */
.theme-toggle {
  background: none; border: none; cursor: pointer; padding: 0.4rem;
  color: var(--sidebar-text); border-radius: 6px; display: flex; align-items: center;
  margin-left: auto; transition: color 0.15s;
}
.theme-toggle:hover { color: #fff; }

/* ── HAMBURGER BUTTON ───────────────────────────────────────────────────── */
.nav-toggle {
  display: none;
  position: fixed;
  top: 0.75rem; left: 0.75rem;
  z-index: 200;
  background: var(--sidebar-bg);
  border: none; border-radius: 6px;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  flex-direction: column; gap: 4px;
}
.nav-toggle span {
  display: block; width: 20px; height: 2px;
  background: var(--sidebar-text); border-radius: 2px;
}
.nav-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 149;
}
.nav-overlay.visible { display: block; }

/* ── MOBILE (≤768px) ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Show hamburger */
  .nav-toggle { display: flex; }

  /* Sidebar: hidden off-screen, slides in when .open */
  .sidebar {
    transform: translateX(-240px);
    transition: transform 0.25s ease;
    z-index: 150;
  }
  .sidebar.open { transform: translateX(0); }

  /* Content fills full width; top padding clears the hamburger button */
  .content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 3.5rem;
  }

  /* Global layout helpers */
  .page-header { flex-wrap: wrap; }
  .page-header h1 { font-size: 1.25rem; }
  .header-actions { flex-wrap: wrap; }
  .card { padding: 1rem; }
  .form-row { flex-direction: column; }

  /* Tables: scroll horizontally rather than overflow */
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Form elements: never exceed viewport */
  input, select, textarea { max-width: 100%; }

  /* Slightly smaller buttons on mobile */
  .btn { font-size: 0.82rem; padding: 0.45rem 0.85rem; }

  /* Images don't overflow */
  img { max-width: 100%; height: auto; }

  /* Section headers with action buttons */
  .section-header { flex-wrap: wrap; gap: 0.5rem; }

  /* Any flex row inside a page header wraps on mobile */
  .page-header > div { flex-wrap: wrap; }

  /* Stat grid: 2 columns on mobile */
  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  /* Dashboard 2-col row stacks to 1 col */
  .dashboard-row { grid-template-columns: 1fr; }

  /* Dash stat row already wraps, just tighten gap */
  .dash-stat-row { gap: 0.5rem; }
  .dash-stat { min-width: 120px; }

  /* Queue: allow job card header + meta to wrap onto two lines on narrow screens */
  .job-card-header { flex-wrap: wrap; }
  .job-card-meta { flex-wrap: wrap; flex-shrink: unset; }

  /* Add Job: model-runs table scrolls horizontally */
  .model-runs-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Models table: hide low-priority columns (Creator, Network Path, Notes) */
  .models-table th:nth-child(3), .models-table td:nth-child(3),
  .models-table th:nth-child(8), .models-table td:nth-child(8),
  .models-table th:nth-child(9), .models-table td:nth-child(9) { display: none; }
}
