/* ─── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg: #FFFFFF;
  --bg-secondary: #F7F8FA;
  --border: #E5E7EB;
  --accent: #df283a;
  --accent-dark: #b81e2e;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --danger: #EF4444;
  --warning: #F59E0B;
  --success: #10B981;
  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-badge: 20px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --font: 'DM Sans', sans-serif;
  --nav-height: 64px;
  --sidebar-width: 240px;
}

/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

a { color: inherit; text-decoration: none; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: none;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo svg { width: 28px; height: 28px; }

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.sidebar-item.active { background: rgba(223,40,58,0.1); color: var(--accent); }
.sidebar-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.main-content {
  flex: 1;
  min-height: 100vh;
  padding-bottom: 80px;
  width: 100%;
}

/* ─── Bottom Navigation ─────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  min-height: 44px;
  color: var(--text-secondary);
  border: none;
  background: none;
  font-family: var(--font);
  transition: color 0.15s;
}

.nav-item svg { width: 24px; height: 24px; }
.nav-item span { font-size: 11px; font-weight: 500; }
.nav-item.active { color: var(--accent); }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.item-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.item-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.item-card__photo-wrap {
  position: relative;
  display: block;
}

.item-card__photo {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
  background: var(--bg-secondary);
  display: block;
}

.item-card__photo--placeholder {
  aspect-ratio: 1 / 1;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.item-card__photo--placeholder svg { width: 40px; height: 40px; }

.item-card__low-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.item-card__body { padding: 12px; }

.item-card__name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-card__meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.item-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.item-card__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.item-card__qty-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.item-card__qty-row .qty-stepper {
  flex: 1;
}
.item-card__btn-row {
  display: flex;
  gap: 4px;
  width: 100%;
}
.item-card__btn-row .compact-action-btn {
  flex: 1;
  justify-content: center;
}

/* List view card */
.item-list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s;
}

.item-list-card:hover { transform: translateX(2px); }

.item-list-card__thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
}

.item-list-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-list-card__thumb svg { width: 24px; height: 24px; }

.item-list-card__info { flex: 1; min-width: 0; }
.item-list-card__name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-list-card__meta { font-size: 12px; color: var(--text-secondary); }
.item-list-card__right { text-align: right; flex-shrink: 0; }
.item-list-card__qty { font-weight: 700; font-size: 16px; }
.item-list-card__unit { font-size: 12px; color: var(--text-secondary); }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-badge);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge--type-finished_product { background: #DBEAFE; color: #1D4ED8; }
.badge--type-raw_material { background: #D1FAE5; color: #065F46; }
.badge--type-wip { background: #FEF3C7; color: #92400E; }
.badge--type-packaging { background: #F3E8FF; color: #7C3AED; }
.badge--low-stock { background: #FEE2E2; color: #DC2626; }
.badge--margin-green { background: #D1FAE5; color: #065F46; }
.badge--margin-yellow { background: #FEF3C7; color: #92400E; }
.badge--margin-red { background: #FEE2E2; color: #DC2626; }
.badge--kit { background: #E0F2FE; color: #0369A1; }
.badge--status-draft { background: #F3F4F6; color: #374151; }
.badge--status-ordered { background: #DBEAFE; color: #1D4ED8; }
.badge--status-received { background: #D1FAE5; color: #065F46; }

/* ─── Tag colors ─────────────────────────────────────────────────────────────── */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.tag--0 { background: #EDE9FE; color: #5B21B6; }
.tag--1 { background: #FCE7F3; color: #9D174D; }
.tag--2 { background: #D1FAE5; color: #065F46; }
.tag--3 { background: #FEF3C7; color: #92400E; }
.tag--4 { background: #DBEAFE; color: #1E40AF; }
.tag--5 { background: #FFE4E6; color: #9F1239; }
.tag--6 { background: #F0FDF4; color: #166534; }
.tag--7 { background: #F5F3FF; color: #6D28D9; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius-btn);
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #DC2626; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-secondary); }

.btn-success { background: var(--success); color: white; }

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--border); }
.btn-icon svg { width: 20px; height: 20px; }

.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; }

.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 28px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(223,40,58,0.4);
  z-index: 100;
  transition: all 0.15s;
}
.fab:hover { transform: scale(1.05); background: var(--accent-dark); }
.fab svg { width: 28px; height: 28px; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

input[type=checkbox], input[type=radio] {
  -webkit-appearance: auto;
  appearance: auto;
  width: auto;
  min-height: auto;
  border-radius: 4px;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

.input-error { border-color: var(--danger) !important; }
.error-message { font-size: 13px; color: var(--danger); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Type pill selector */
.type-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.type-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.type-pill.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Tags chip input */
.tags-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 44px;
  cursor: text;
  background: var(--bg);
}

.tags-input:focus-within { border-color: var(--accent); }

.tags-input input {
  border: none;
  outline: none;
  padding: 0;
  min-width: 100px;
  flex: 1;
  font-size: 14px;
  border-radius: 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(223,40,58,0.1);
  color: var(--accent);
}

.tag-chip button {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  width: auto;
  min-height: auto;
  border-radius: 0;
  display: flex;
}

/* Photo upload */
.photo-upload {
  border: 2px dashed var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
  transition: border-color 0.15s;
  padding: 12px 16px;
  min-height: 80px;
}

.photo-upload:hover { border-color: var(--accent); }
.photo-upload.drag-over { border-color: var(--accent); background: rgba(223,40,58,0.05); }
.photo-upload input[type=file] { display: none; }

.photo-upload__thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-muted);
}

.photo-upload__thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-upload__thumb svg { width: 28px; height: 28px; }

.photo-upload__hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-muted);
  z-index: 1;
}

.photo-upload__hint span { font-size: 13px; }

/* Field label with icon */
.form-label-icon {
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-label-icon svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }

/* ─── Inventory Grid / List ──────────────────────────────────────────────────── */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.inventory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

/* ─── Compact view ───────────────────────────────────────────────────────────── */
.inventory-compact {
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
}

.item-compact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.item-compact-row:last-child { border-bottom: none; }
.item-compact-row:hover { background: var(--bg-secondary); }

.item-compact-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-compact-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-compact-thumb svg { width: 20px; height: 20px; color: var(--text-muted); }

.item-compact-info {
  flex: 1;
  min-width: 0;
}
.item-compact-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.item-compact-sub {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-compact-qty {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.qty-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
  flex-shrink: 0;
}
.qty-btn:hover { background: var(--border); }
.qty-val {
  min-width: 36px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  padding: 0 2px;
  user-select: none;
}
.qty-static {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
}

.compact-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}
.compact-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.1s;
}
.compact-action-btn svg { width: 11px; height: 11px; }
.compact-action-btn:hover { background: var(--bg-secondary); }
.compact-reorder { color: #1D4ED8; border-color: #BFDBFE; background: #EFF6FF; }
.compact-reorder:hover { background: #DBEAFE; }
.compact-build { color: #065F46; border-color: #A7F3D0; background: #ECFDF5; }
.compact-build:hover { background: #D1FAE5; }
.compact-ship { color: #fff; border-color: var(--accent-dark); background: var(--accent); }
.compact-ship:hover { background: var(--accent-dark); }

.compact-undo-btn {
  display: none;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  animation: fadeIn 0.15s ease;
  white-space: nowrap;
}
.compact-undo-btn:hover { background: var(--bg-secondary); }

/* Compact settings dropdown */
.compact-settings-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  min-width: 170px;
}
.compact-settings-title {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.compact-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  cursor: pointer;
  color: var(--text-primary);
}
.compact-toggle-row:hover { color: var(--accent); }

/* ─── BOM Grouped View ───────────────────────────────────────────────────────── */
.inventory-grid .bom-group {
  grid-column: 1 / -1;
}

.bom-group__grid-body {
  display: flex;
  gap: 0;
}

.bom-group__kit-card {
  width: 200px;
  flex-shrink: 0;
  padding: 8px;
}

.bom-group__kit-card .item-card {
  height: 100%;
}

.bom-group__grid-body .bom-group__components {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  padding: 8px;
  background: transparent;
}

.bom-group {
  border: 2px solid var(--accent);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(223,40,58,0.08);
}
.bom-group__header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(223,40,58,0.06);
  border-bottom: 1px solid rgba(223,40,58,0.15);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.bom-group > .item-compact-row,
.bom-group > .card {
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}
.bom-group__components {
  background: var(--bg-secondary);
}
.bom-group__components .item-compact-row {
  border-radius: 0;
  padding-left: 20px;
  border-bottom: 1px solid var(--border);
}
.bom-group__components .item-compact-row:last-child {
  border-bottom: none;
}
.item-compact-row--component .item-compact-thumb {
  width: 32px;
  height: 32px;
}
.item-compact-row--component .item-compact-name {
  font-size: 12px;
}
.item-compact-row--component .item-compact-sub {
  font-size: 10px;
}

/* ─── Stock Widget ───────────────────────────────────────────────────────────── */
.stock-widget {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0 16px;
}

.stock-qty {
  font-size: 52px;
  font-weight: 700;
  text-align: center;
  flex: 1;
  line-height: 1;
  color: var(--text-primary);
}

.stock-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  font-size: 30px;
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
  transition: all 0.15s;
  color: var(--text-primary);
}

.stock-btn:hover { background: var(--border); }
.stock-btn:active { transform: scale(0.95); }

.stock-unit {
  font-size: 16px;
  color: var(--text-secondary);
  text-align: center;
}

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 24px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.modal-actions .btn { flex: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── Skeleton / Shimmer ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.skeleton-card {
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--bg);
  box-shadow: var(--shadow-card);
}

.skeleton-card .skeleton-img { width: 100%; aspect-ratio: 1/1; }
.skeleton-card .skeleton-body { padding: 12px; }
.skeleton-card .skeleton-line { height: 14px; margin-bottom: 8px; border-radius: 6px; }
.skeleton-card .skeleton-line.w-60 { width: 60%; }
.skeleton-card .skeleton-line.w-80 { width: 80%; }

/* ─── Page Headers ───────────────────────────────────────────────────────────── */
.page-header {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
}

/* ─── Dashboard Grid ─────────────────────────────────────────────────────────── */
/* Base styles — dashboard.js injects its own scoped <style> that overrides these */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 0 16px 80px;
}

.pinned-row:hover {
  background: var(--bg-secondary);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 16px 16px;
}

.stat-card {
  background: var(--bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 14px;
  text-align: center;
}

.stat-card__value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card__label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Filter Bar ─────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar { display: none; }

.inv-filter-row {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
}
.inv-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  height: 38px;
}
.inv-filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.inv-filter-select {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font);
  cursor: pointer;
  min-height: unset;
  height: auto;
  padding: 0;
  outline: none;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-secondary);
  font-family: var(--font);
  transition: all 0.15s;
}

.filter-pill.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.search-bar {
  padding: 0 16px;
  margin-bottom: 12px;
  position: relative;
}

.search-bar input {
  padding-left: 40px;
}

.search-bar svg {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  height: 18px;
  width: 18px;
  color: var(--text-muted);
}

/* ─── Item Detail ────────────────────────────────────────────────────────────── */
.item-hero {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg-secondary);
  display: block;
  border-radius: 0 0 20px 20px;
  max-height: 280px;
}

.item-hero--placeholder {
  width: 100%;
  height: 140px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 0 0 20px 20px;
}

.item-hero--placeholder svg { width: 80px; height: 80px; }

.detail-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin: 0 12px 10px;
}

.detail-section:last-child { margin-bottom: 0; }

.detail-section--alt { background: var(--bg); }

.detail-section h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 14px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

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

.detail-row__label { color: var(--text-secondary); }
.detail-row__value { font-weight: 500; }

.item-name-large {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 10px;
}

.item-meta-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* ─── BOM Table ──────────────────────────────────────────────────────────────── */
.bom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.bom-table th {
  text-align: left;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.bom-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

/* ─── Log entries ────────────────────────────────────────────────────────────── */
.log-entry {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.log-entry:last-child { border-bottom: none; }

.log-entry__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.log-entry__icon--in { background: #D1FAE5; color: #065F46; }
.log-entry__icon--out, .log-entry__icon--ship { background: #FEE2E2; color: #DC2626; }
.log-entry__icon--adjust { background: #DBEAFE; color: #1D4ED8; }
.log-entry__icon--import { background: #F3E8FF; color: #7C3AED; }
.log-entry__icon--assemble { background: #FEF3C7; color: #92400E; }

.log-entry__info { flex: 1; min-width: 0; }
.log-entry__desc { font-weight: 500; }
.log-entry__time { color: var(--text-muted); font-size: 12px; }
.log-entry__delta { font-weight: 700; white-space: nowrap; }
.log-entry__delta--pos { color: var(--success); }
.log-entry__delta--neg { color: var(--danger); }

/* ─── Workspace Avatar ───────────────────────────────────────────────────────── */
.workspace-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.sidebar-footer-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer-text {
  min-width: 0;
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 12px 16px;
  min-width: 240px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  pointer-events: all;
  animation: slideInRight 0.2s ease;
}

.toast--success { border-left: 4px solid var(--success); }
.toast--error { border-left: 4px solid var(--danger); }
.toast--warning { border-left: 4px solid var(--warning); }

@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.toast-action-btn {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.85;
  flex-shrink: 0;
}

.toast-action-btn:hover { opacity: 1; }

/* ─── Empty States ───────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-state__title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
}

.empty-state__subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 24px;
}

/* ─── Login Page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  padding: 16px;
}

.login-card {
  background: var(--bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-logo svg { width: 36px; height: 36px; }

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* ─── Sections and utilities ─────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  padding-bottom: 8px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 0 16px;
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

.p-16 { padding: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

.w-full { width: 100%; }

.collapsible-content { display: none; }
.collapsible-content.open { display: block; }

/* ─── Action Sheet ───────────────────────────────────────────────────────────── */
.action-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  z-index: 300;
  padding: 16px;
  animation: slideUp 0.2s ease;
}

.action-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  color: var(--text-primary);
}

.action-sheet-item:hover { background: var(--bg-secondary); }
.action-sheet-item.danger { color: var(--danger); }
.action-sheet-item svg { width: 22px; height: 22px; }

.action-sheet-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 12px 8px;
}

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.tab {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
  border-top: none;
  border-left: none;
  border-right: none;
  background: none;
  font-family: var(--font);
}

.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:hover td { background: var(--bg-secondary); }

.table-wrap { overflow-x: auto; padding: 0 16px 16px; }

/* ─── Scanner ────────────────────────────────────────────────────────────────── */
.scanner-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.scanner-video {
  width: 100%;
  max-width: 360px;
  border-radius: 12px;
  border: 3px solid var(--accent);
  background: black;
}

.scanner-result {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

/* ─── Purchase Orders ────────────────────────────────────────────────────────── */
.po-card {
  background: var(--bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s;
  margin-bottom: 8px;
}

.po-card:hover { transform: translateY(-2px); }

.po-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

/* ─── Settings ───────────────────────────────────────────────────────────────── */
.settings-section {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.settings-section h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 16px;
}

/* ─── Dashboard Activity ─────────────────────────────────────────────────────── */
.activity-feed {
  padding: 0 16px;
}

.low-stock-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.low-stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
}

/* ─── Margin display ─────────────────────────────────────────────────────────── */
.margin-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
  margin-top: 12px;
  font-size: 14px;
}

/* ─── Dashboard Welcome ──────────────────────────────────────────────────────── */
.dash-welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 16px;
}

.dash-welcome__greeting {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.dash-welcome__date {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dash-welcome__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.pinned-card:hover {
  box-shadow: var(--shadow-card);
}

/* ─── Scan Action Row ────────────────────────────────────────────────────────── */
.scan-action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ─── Labels Page ────────────────────────────────────────────────────────────── */
.labels-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.label-row__swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.label-row__icon {
  font-size: 18px;
  min-width: 22px;
  text-align: center;
}

.label-row__name {
  font-weight: 500;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Detail Action Buttons (Edit / More) ────────────────────────────────────── */
.btn-detail-action {
  height: 36px;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-detail-action:hover { background: var(--accent-dark); }
.btn-detail-action svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-detail-action .btn-label { display: none; }

/* ─── Responsive (Desktop) ───────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .sidebar { display: flex; }
  .main-content {
    margin-left: var(--sidebar-width);
    padding-bottom: 0;
    background: var(--bg-secondary);
    min-height: 100vh;
  }
  .inventory-grid { grid-template-columns: repeat(3, 1fr); }
  .fab { bottom: 24px; }
  .modal-overlay { align-items: center; }
  .modal {
    border-radius: 24px;
    max-width: 520px;
    width: 90%;
  }
  .stats-row { grid-template-columns: repeat(4, 1fr); }
  .form-row { grid-template-columns: 1fr 1fr; }
  .item-hero { max-height: 320px; aspect-ratio: unset; border-radius: 0 0 24px 24px; }
  .item-hero--placeholder { height: 180px; border-radius: 0 0 24px 24px; }
  .detail-section { margin: 0 20px 12px; padding: 24px; }

  /* Desktop: show text labels on action buttons */
  .btn-detail-action { gap: 6px; padding: 0 14px; }
  .btn-detail-action .btn-label { display: inline; }

  /* Desktop: page content max-width + centering */
  #app-content > div {
    max-width: 1280px;
    margin: 0 auto;
  }

  /* Desktop: page headers get a white bar that sits above the gray bg */
  .page-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 18px 28px;
    margin-bottom: 0;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .page-title { font-size: 22px; }

  /* Desktop: section cards */
  .settings-section {
    margin: 20px 28px;
    border-radius: 16px;
    border: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: 24px;
    box-shadow: none;
  }

  /* Desktop: inventory/reports padding */
  .filter-bar { padding: 16px 28px 12px; }
  .search-bar { padding: 0 28px; margin-top: 12px; margin-bottom: 12px; }
  .search-bar svg { left: 40px; }
  .inventory-grid, .inventory-compact { padding: 16px 28px; }

  /* Desktop: stats row */
  .stats-row { padding: 20px 28px 20px; }

  /* Desktop: sidebar divider between main nav and bottom items */
  .sidebar-nav { padding: 12px; }
}

@media (min-width: 1200px) {
  .inventory-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ─── Bulk select mode ───────────────────────────────────────────────────────── */
.inv-select-cb {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.inv-selected {
  outline: 2px solid var(--accent, #df283a) !important;
  outline-offset: -2px;
}
#inv-bulk-bar {
  display: none;
  gap: 6px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
}
#select-toggle-btn.active {
  background: var(--accent, #df283a);
  color: #fff;
  border-radius: 10px;
}

/* ─── Trash page ─────────────────────────────────────────────────────────────── */
.trash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.trash-row:last-child { border-bottom: none; }
.trash-row__name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-row__meta { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }

/* ─── Responsive button rows ─────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-direction: column;
}
.btn-row .btn { flex: 1; }
@media (min-width: 768px) {
  .btn-row { flex-direction: row; }
}

/* ─── Print ──────────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .bottom-nav, .fab, .toast-container { display: none !important; }
  .main-content { margin-left: 0 !important; }
}
