:root {
  --bg: #19191a;
  --surface: #242529;
  --surface2: #2c2d31;
  --primary: #5181B8;
  --primary-hover: #3f6a99;
  --text: #e4e5e8;
  --text2: #858688;
  --border: #36373b;
  --radius: 8px;
  --font-scale: 1;
}
html.theme-light {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface2: #e8ecf0;
  --text: #1c1e21;
  --text2: #65676b;
  --border: #d0d5dd;
  --primary: #527AA7;
  --primary-hover: #41699a;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  padding: 40px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.login-card h1 { text-align: center; margin-bottom: 8px; font-size: 24px; }
.login-card p { text-align: center; color: var(--text2); margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text2); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-size: 14px; outline: none; transition: border .2s;
}
#sellServicesList input[type="checkbox"] { width:18px; height:18px; min-width:18px; min-height:18px; padding:0; margin:0; cursor:pointer; accent-color:var(--primary); background:none; border:none; appearance:auto; -webkit-appearance:checkbox; flex-shrink:0; }
#sellServicesList input[type="number"] { width:90px; padding:6px 8px; font-size:13px; border:1px solid var(--border); border-radius:6px; background:var(--bg); color:var(--text); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  font-size: 14px; cursor: pointer; transition: all .2s;
}
.btn-primary, .btn-secondary, .btn-outline, .btn-danger { background: var(--primary); color: #fff; border: none; }
.btn-primary:hover, .btn-secondary:hover, .btn-outline:hover, .btn-danger:hover { background: var(--primary-hover); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* App layout */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.header {
  background: var(--surface); padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.header h1 { font-size: 18px; display:flex; flex-direction:column; line-height:1.2; }
.header h1 .brand { font-size: 20px; color: var(--text); }
.header h1 .sub { font-size: 12px; font-weight: 400; color: var(--text2); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.user-info { font-size: 13px; color: var(--text2); }

.notif-wrap { position: relative; }
.notif-bell { background: none; border: none; cursor: pointer; font-size: 20px; position: relative; padding: 4px; line-height: 1; color: var(--text2); }
.notif-bell:hover { color: var(--text); }
.notif-badge { position: absolute; top: -4px; right: -6px; background: #e94560; color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 3px; font-weight: 700; }
.notif-panel { position: absolute; top: 100%; right: 0; width: 360px; max-height: 480px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.3); z-index: 9999; display: flex; flex-direction: column; overflow: hidden; }
.notif-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.notif-clear { background: none; border: none; cursor: pointer; font-size: 16px; opacity: .6; padding: 2px 4px; }
.notif-clear:hover { opacity: 1; }
.notif-list { overflow-y: auto; max-height: 420px; }
.notif-item { padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: rgba(233,69,96,.08); }
.notif-item-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-item-msg { font-size: 12px; color: var(--text2); line-height: 1.4; }
.notif-item-time { font-size: 10px; color: var(--text2); margin-top: 3px; opacity: .7; }
.notif-item-type { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; margin-right: 4px; font-weight: 600; }
.notif-item-type.shift { background: #3b82f6; color: #fff; }
.notif-item-type.receipt { background: #22c55e; color: #fff; }
.notif-item-type.error { background: #e94560; color: #fff; }
.notif-item-type.info { background: #6b7280; color: #fff; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--text2); font-size: 13px; }
.notif-table-modal { max-width: 1500px; width: calc(100vw - 40px); }
.notif-table-body { padding: 0; }
.notif-table-scroll { width: 100%; overflow-x: auto; }
.notif-table { width: 100%; min-width: 1250px; border-collapse: collapse; font-size: 12px; }
.notif-table th { position: sticky; top: 0; background: var(--surface); color: var(--text2); text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.notif-table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.notif-table tr.unread { background: rgba(233,69,96,.08); }
.notif-table tr:hover { background: var(--bg); }
.notif-table tbody tr { cursor: pointer; }
.notif-sale-id { font-weight: 700; color: var(--primary); }
.notif-table-thumb { width: 56px; height: 42px; border-radius: 5px; object-fit: cover; display: block; }
.notif-price { font-weight: 700; white-space: nowrap; }
.notif-note { max-width: 240px; white-space: normal; }

@media (max-width: 600px) {
  .notif-panel { width: calc(100vw - 20px); right: -10px; }
}

.settings-overlay { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,.5); z-index:9000; opacity:0; pointer-events:none; transition:opacity .3s; }
.settings-overlay.active { opacity:1; pointer-events:auto; }
.settings-drawer { position:fixed; top:0; right:-820px; bottom:0; width:820px; max-width:100vw; background:var(--surface); z-index:9001; display:flex; flex-direction:column; transition:right .3s ease; box-shadow:-4px 0 24px rgba(0,0,0,.3); }
.settings-drawer.active { right:0; }
.settings-drawer-header { padding:14px 20px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; flex-shrink:0; }
.settings-drawer-header h2 { margin:0; }
.settings-drawer-body { display:flex; flex:1; overflow:hidden; }
.settings-sidebar { width:200px; border-left:1px solid var(--border); overflow-y:auto; padding:8px 0; flex-shrink:0; order:2; }
.settings-content { flex:1; overflow-y:auto; padding:20px 24px; order:1; }
.settings-sidebar-item { padding:10px 16px; cursor:pointer; display:flex; align-items:center; gap:8px; border-radius:6px; margin:2px 8px; color:var(--text2); font-size:13px; transition:background .15s, color .15s; white-space:nowrap; }
.settings-sidebar-item:hover { background:var(--bg); color:var(--text); }
.settings-sidebar-item.active { background:var(--primary); color:#fff; }
.settings-section { animation:fadeIn .15s; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.header-icon-btn { background:none; border:none; cursor:pointer; font-size:22px; color:var(--text2); padding:4px 6px; line-height:1; border-radius:6px; transition:background .15s; }
.header-icon-btn:hover { background:var(--bg); color:var(--text); }

@media (max-width:600px) {
  .settings-drawer { width:100vw; }
  .settings-sidebar { width:48px; }
  .settings-sidebar-item span { display:none; }
  .settings-content { padding:12px; }
}

/* Toolbar */
.toolbar {
  background: var(--surface); padding: 10px 24px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}
.toolbar-group {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--surface2);
  border-radius: 8px;
}
.toolbar-group:empty { display: none; }
.toolbar-search { flex: 1; min-width: 200px; background: transparent; padding: 0; }
.toolbar .search-select {
  width: 100%; padding: 8px 28px 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 13px;
  appearance: auto; cursor: pointer;
}
.toolbar .search-select:focus { border-color: var(--primary); outline: none; }
.toolbar-filters select {
  padding: 8px 28px 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 12px; width: 130px;
  appearance: auto; cursor: pointer;
}
.toolbar-filters select:focus { border-color: var(--primary); outline: none; }
.toolbar-input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 12px; width: 110px;
  transition: border-color 0.2s;
}
.toolbar-input:focus { border-color: var(--primary); outline: none; }

/* Autocomplete */
.autocomplete-wrap { position: relative; display: inline-block; }
.autocomplete-input {
  padding: 8px 28px 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 12px; width: 240px;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: text;
}
.autocomplete-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(81,129,184,0.15);
  outline: none;
}
.autocomplete-wrap::after {
  content: '▼'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 9px; color: var(--text2); pointer-events: none;
}
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; margin-top: 4px; max-height: 200px; overflow-y: auto;
  display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 6px 10px; font-size: 12px; color: var(--text);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.autocomplete-item:hover, .autocomplete-item.active {
  background: var(--primary); color: #fff;
}
.autocomplete-item.empty {
  color: var(--text2); cursor: default;
}
.autocomplete-item.empty:hover { background: transparent; color: var(--text2); }

/* Toggle switches */
.switch-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text2); cursor: pointer;
  white-space: nowrap; user-select: none;
}
.switch-label input[type="checkbox"] { display: none; }
.switch {
  position: relative; width: 32px; height: 18px;
  background: var(--border); border-radius: 9px;
  transition: background 0.2s; flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; background: #fff;
  border-radius: 50%; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch-label input:checked + .switch {
  background: var(--primary);
}
.switch-label input:checked + .switch::after {
  transform: translateX(14px);
}

/* Sort group */
.toolbar-sort { gap: 4px; }
.toolbar .toolbar-select {
  padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 11px;
  cursor: pointer;
}
.sort-dir-btn {
  padding: 6px 10px !important; font-size: 14px !important;
  font-weight: 700; min-width: 32px;
}
.view-btn {
  padding: 6px 10px !important; font-size: 15px !important;
  min-width: 32px;
}

/* Legacy toggle-label for other places */
.toggle-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text2); cursor: pointer; white-space: nowrap;
}

/* Content */
.content { flex: 1; padding: 20px 24px 80px 24px; }
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-bottom: 20px; font-size: 13px; color: var(--text2);
}
.pagination .btn { min-width: 36px; justify-content: center; }

/* Parts Grid */
.parts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.part-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  cursor: pointer;
}
.part-card-sold {
  opacity: .6;
  border-color: #555;
}
.part-card-sold:hover {
  transform: none;
  box-shadow: none;
}
.badge {
  font-size: 10px; font-weight: 400;
  padding: 1px 6px; border-radius: 3px; margin-left: 4px;
}
.badge-sold {
  color: #fff; background: #27ae60;
}
.badge-off {
  color: #aaa; background: #444;
}
.part-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(233,69,96,.15);
}
.part-card .photos {
  display: flex; gap: 2px; overflow-x: auto; background: var(--surface); min-height: 200px; justify-content:center;
}
.part-card .photos img {
  width: auto; height: 200px; object-fit: contain; flex-shrink: 0;
}
.part-card .photos .no-photo {
  width: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text2); font-size: 12px;
}
.part-card .info { padding: 12px; }
.part-card .info .name {
  font-size: 14px; font-weight: 600; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.part-card .info .meta {
  display: flex; flex-wrap: wrap; gap: 4px 8px;
  font-size: 11px; color: var(--text2); margin-bottom: 8px;
}
.part-card .info .meta span { background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.part-card .info .price {
  font-size: 16px; font-weight: 700; color: var(--text);
}
.part-card .info .code { font-size: 11px; color: var(--text2); }

/* View modes */
.parts-grid.list0 { grid-template-columns: 1fr; }
.parts-grid.list0 .part-card { display:flex; flex-direction:row; align-items:center; border-radius:0; border-left:none; border-right:none; }
.parts-grid.list0 .part-card:first-child { border-top:none; }
.parts-grid.list0 .part-card .part-card-inner { display:flex; flex-direction:row; align-items:center; flex:1; width:100%; }
.parts-grid.list0 .part-card .info { display:flex; flex-direction:row; align-items:center; gap:12px; flex:1; padding:6px 12px; flex-wrap:nowrap; overflow:hidden; }
.parts-grid.list0 .part-card .info .name { font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:120px; flex-shrink:1; }
.parts-grid.list0 .part-card .info .meta { display:flex; flex-direction:row; gap:8px; font-size:11px; margin:0; flex-shrink:0; }
.parts-grid.list0 .part-card .info .meta span { background:none; padding:0; }
.parts-grid.list0 .part-card .info .price { font-size:12px; flex-shrink:0; }
.parts-grid.list0 .part-card .info .code { font-size:11px; flex-shrink:0; }
.parts-grid.list0 .part-card .photos { display:none; }
.parts-grid.list0 .part-card { position:relative; }
.parts-grid.list0 .part-card:hover { z-index:200; }
.parts-grid.list0 .part-card:hover .photos { display:flex; position:absolute; left:0; bottom:100%; min-height:auto; background:rgba(0,0,0,.95); border-radius:8px; padding:8px; gap:4px; box-shadow:0 4px 20px rgba(0,0,0,.5); }
.parts-grid.list0 .part-card:hover .photos img { height:220px; width:auto; border-radius:4px; }

.parts-grid.list1 { grid-template-columns: 1fr; }
.parts-grid.list1 .part-card { display:flex; flex-direction:row; }
.parts-grid.list1 .part-card .photos { min-height:80px; flex-shrink:0; }
.parts-grid.list1 .part-card .photos img { height:80px; }
.parts-grid.list1 .part-card .info { flex:1; padding:8px 12px; }
.parts-grid.list1 .part-card .info .name { font-size:13px; }
.parts-grid.list1 .part-card .info .meta { margin-bottom:2px; }
.parts-grid.list1 .part-card .info .price { font-size:14px; }

.parts-grid.list2 { grid-template-columns: 1fr; }
.parts-grid.list0 .part-card .photos img:not(:first-child) { display:none; }
.parts-grid.list1 .part-card .photos img:not(:first-child) { display:none; }

.parts-grid.grid2 { grid-template-columns: repeat(2,1fr); }
.parts-grid.grid3 { grid-template-columns: repeat(3,1fr); }
.parts-grid.grid4 { grid-template-columns: repeat(4,1fr); }
.parts-grid.grid2 .part-card .photos { overflow:hidden; }
.parts-grid.grid2 .part-card .photos img:not(:first-child) { display:none; }
.parts-grid.grid3 .part-card .photos { overflow:hidden; }
.parts-grid.grid3 .part-card .photos img:not(:first-child) { display:none; }
.parts-grid.grid4 .part-card .photos { overflow:hidden; min-height:180px; }
.parts-grid.grid4 .part-card .photos img { height:180px; }
.parts-grid.grid4 .part-card .photos img:not(:first-child) { display:none; }
.parts-grid.grid4 .part-card .photos img:not(:first-child) { display:none; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 800px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  background: none; border: none; color: var(--text2); font-size: 24px;
  cursor: pointer; padding: 4px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border);
}

/* Photo upload */
.photo-gallery {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; min-height: 40px;
}
.photo-gallery-empty {
  width: 100%; color: var(--text2); font-size: 13px; padding: 8px 0;
}
.photo-gallery-item {
  position: relative; width: 100px; height: 80px; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border); cursor: pointer; flex-shrink: 0;
}
.photo-gallery-item[draggable="true"] { cursor: grab; }
.photo-gallery-item.drag-over { border-color: var(--primary); border-width: 2px; }
.photo-gallery-item img {
  width: 100%; height: 100%; object-fit: cover;
}
.photo-gallery-item:hover img {
  opacity: .8;
}
.photo-gallery-remove {
  position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.7);
  color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px;
  cursor: pointer; font-size: 14px; display: none; align-items: center; justify-content: center;
  line-height: 1; padding: 0;
}
.photo-gallery-item:hover .photo-gallery-remove { display: flex; }
.photo-gallery-num {
  position: absolute; bottom: 2px; left: 2px; background: rgba(0,0,0,.6);
  color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 3px;
}

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

/* Progress overlay */
.progress-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.progress-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; text-align: center; max-width: 300px; }
.progress-box p { margin-top: 16px; color: var(--text2); font-size: 14px; }

.progress-bar-wrap { margin-top: 20px; display: flex; align-items: center; gap: 10px; }
.progress-bar { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s ease; }
.progress-percent { color: var(--text2); font-size: 13px; min-width: 36px; text-align: right; }

/* Loading & Empty */
.loading, .empty {
  text-align: center; padding: 60px 20px; color: var(--text2);
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .6s linear infinite; margin: 0 auto 12px;
}
/* Bulk actions bar */
.bulk-bar { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; background: var(--primary); color: #fff; border-radius: 8px; flex-wrap: wrap; box-shadow: 0 4px 12px rgba(0,0,0,.3); white-space: nowrap; }
.bulk-bar span { font-size: 13px; font-weight: 600; margin-right: 4px; }
.bulk-bar .btn { background: rgba(255,255,255,.2); color: #fff; border: none; font-size: 12px; padding: 4px 10px; }
.bulk-bar .btn:hover { background: rgba(255,255,255,.35); }
.bulk-bar .bulk-clear { font-size: 16px; padding: 2px 8px; }
/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.95); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.lb-img-wrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: default; }
.lb-img { max-width: 90vw; max-height: 90vh; object-fit: contain; transition: transform .1s; user-select: none; -webkit-user-select: none; }
.lb-close { position: fixed; top: 16px; right: 20px; font-size: 32px; color: #fff; cursor: pointer; z-index: 2; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.5); border-radius: 50%; }
.lb-prev, .lb-next { position: fixed; top: 50%; transform: translateY(-50%); font-size: 48px; color: #fff; cursor: pointer; z-index: 2; width: 50px; height: 80px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.3); border-radius: 8px; user-select: none; }
.lb-controls { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2; display: flex; align-items: center; gap: 8px; background: rgba(30,30,30,.9); padding: 10px 16px; border-radius: 16px; flex-wrap: wrap; justify-content: center; max-width: 95vw; }
.lb-ctrl-btn { background: rgba(255,255,255,.15); color: #fff; border: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; white-space: nowrap; transition: background .15s; }
.lb-ctrl-btn:hover { background: rgba(255,255,255,.3); }
.lb-ctrl-danger:hover { background: #c0392b; color: #fff; }
.lb-ctrl-primary { background: var(--primary); color: #fff; }
.lb-ctrl-primary:hover { background: var(--primary-hover); color: #fff; }
.lb-range-label { display: flex; align-items: center; gap: 4px; color: #fff; font-size: 12px; white-space: nowrap; }
.lb-range-label input[type="range"] { width: 80px; accent-color: var(--primary); cursor: pointer; }
.lb-brightness-val, .lb-contrast-val { min-width: 24px; text-align: center; color: #fff; font-size: 11px; }
.lb-edit-btn { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2; background: var(--primary); color: #fff; border: none; padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 14px; transition: background .15s; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.lb-edit-btn:hover { background: var(--primary-hover); }
.lb-prev:hover, .lb-next:hover, .lb-close:hover { background: rgba(255,255,255,.2); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-counter { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); color: #aaa; font-size: 13px; background: rgba(0,0,0,.6); padding: 4px 12px; border-radius: 20px; z-index: 2; }

/* Catalog detail table */
.detail-table { display: table; width: 100%; border-collapse: collapse; }
.detail-row { display: table-row; }
.detail-row span { display: table-cell; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.detail-row span:first-child { color: var(--text2); font-weight: 600; width: 40%; white-space: nowrap; }
.detail-row span:last-child { color: var(--text); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Responsive */
@media (max-width: 768px) {
  .parts-grid, .parts-grid.grid2, .parts-grid.grid3, .parts-grid.grid4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .photo-gallery-item { width: 80px; height: 64px; }
  
  /* Mobile toolbar: compact, no scroll */
  .toolbar {
    flex-wrap: wrap;
    overflow: visible;
    padding: 6px 8px;
    gap: 4px;
    justify-content: flex-start;
  }
  .toolbar-group {
    flex-shrink: 0;
    padding: 2px 4px;
    gap: 3px;
  }
  .toolbar-search { flex: 1 1 auto; min-width: 0; }
  .toolbar .autocomplete-input { width: 100%; min-width: 120px; padding: 6px 8px; font-size: 12px; }
  .toolbar .toolbar-input { width: 50px; padding: 5px 6px; font-size: 11px; }
  .toolbar .btn { font-size: 10px; padding: 4px 6px; white-space: nowrap; }
  .toolbar .toolbar-select { font-size: 11px; padding: 5px 8px; min-width: 85px; max-width: none; width: auto; }
  .switch-label { font-size: 10px; white-space: nowrap; }
  .switch { width: 22px; height: 12px; }
  .switch::after { width: 8px; height: 8px; }
  .switch-label input:checked + .switch::after { transform: translateX(10px); }
  .sort-dir-btn, .view-btn { padding: 4px 6px !important; font-size: 11px !important; }
  
  /* Hide on mobile */
  .toolbar-status { display: none !important; }
  #selectAll { display: none; }
  #selectAll + .switch + span { display: none; }
  #btnBulkQR { display: none; }
  #viewToggle { display: none; }
  .toolbar-filters { order: 2; }
  .toolbar-sort { order: 3; width: 100%; }
  .toolbar-actions { order: 4; }
  .toolbar .autocomplete-input { width: 100%; min-width: 0; padding: 7px 8px; font-size: 13px; }
  .autocomplete-list { left: -8px; right: auto; min-width: calc(100vw - 32px); }
  
  .header { flex-wrap: wrap; padding: 6px 10px; gap: 4px; }
  .header h1 { font-size: 15px; line-height: 1.2; }
  .header h1 .sub { display: none; }
  .header-actions { display: flex; flex-wrap: nowrap; gap: 3px; width: 100%; justify-content: flex-end; }
  .header-actions .btn { font-size: 10px; padding: 3px 6px; white-space: nowrap; }
  .hide-mobile { display: none !important; }
  .user-info { font-size: 10px; }
  .parts-grid.list0 .part-card .info { flex-wrap:wrap; }
  .parts-grid.list1 .part-card .photos { min-height:60px; }
  .parts-grid.list1 .part-card .photos img { height:60px; }
  .parts-grid.grid2 .part-card .photos { min-height:80px; }
  .parts-grid.grid3 .part-card .photos { min-height:80px; }
  .parts-grid.grid4 .part-card .photos { min-height:140px; }
  .parts-grid.grid4 .part-card .photos img { height:140px; }
  .header h1 { width: 100%; }
  .modal { margin: 10px; padding: 12px; max-height: calc(100vh - 20px); overflow-y: auto; }
  .users-table { font-size: 11px; }
  .users-table td, .users-table th { padding: 4px; }
  .modal-footer { flex-wrap: wrap; justify-content: center; }
  .modal-footer .btn { font-size: 11px; padding: 5px 8px; }
  .lb-controls { display: none; }
  .lb-edit-btn { display: none; }
  .lb-range-label { flex-basis: 100%; justify-content: center; }
  .card-thumb-actions { display: none; }
  .bulk-bar { padding: 6px 10px; gap: 4px; bottom: 8px; }
  .bulk-bar .btn { font-size: 11px; padding: 3px 7px; }
}

.part-card { position: relative; }
.part-card-check { position: absolute; top: 6px; right: 6px; z-index: 2; }
.part-card-check input { width: 18px; height: 18px; cursor: pointer; }

#barcodePrintArea { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #fff; z-index: 9999; overflow: auto; display: none; }
/* Table view */
.parts-grid.table { display:block; width:100%; }
.parts-table { width:100%; border-collapse:separate; border-spacing:0; font-size:13px; table-layout:fixed; }
.parts-table thead th { position:sticky; top:0; z-index:10; background:var(--surface2); color:var(--text2); font-weight:600; padding:8px 10px; text-align:left; border-bottom:2px solid var(--border); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sort-arrow { font-size:11px; margin-left:2px; color:var(--primary); font-weight:700; }
.parts-table tbody tr { cursor:pointer; transition:background .15s; height:53px; }
.parts-table tbody tr:hover { background:var(--surface2); }
.parts-table tbody tr.part-row-done { opacity:.55; }
.parts-table td { padding:4px 10px; border-bottom:1px solid var(--border); vertical-align:middle; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.table-thumb { width:60px; height:45px; object-fit:cover; border-radius:4px; display:block; }
.td-code { font-weight:600; white-space:nowrap; }
.td-num { color:var(--text2); font-size:12px; display:inline; }
.td-price { font-weight:700; text-align:right; white-space:nowrap; }
@media (max-width:768px) {
  .parts-table thead th:nth-child(n+5) { display:none; }
  .parts-table td:nth-child(n+5) { display:none; }
}

#barcodeContainer { text-align: center; }
#barcodeLabel { font-size: 14px; color: #333; margin-top: 8px; }
#barcodeContainer canvas { max-width: 100%; height: auto; }


@media print {
  body > *:not(#barcodePrintArea) { display: none !important; }
  #barcodePrintArea { display: block !important; padding: 20px; position: static; background: none; }
  #barcodeContainer { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; align-items: flex-start; }
  .barcode-item { text-align: center; page-break-inside: avoid; break-inside: avoid; }
  #barcodeContainer canvas { display: block; margin: 0 auto; }
}

/* Full-screen part card */
.card-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.card-container {
  position: relative; width: 95vw; height: 90vh; max-width: 1400px;
  background: var(--surface); color: var(--text);
  border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: row;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.card-close {
  position: absolute; top: 10px; right: 16px; z-index: 10;
  background: rgba(0,0,0,0.5); color: #fff; border: none;
  font-size: 28px; width: 40px; height: 40px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0;
}
.card-close:hover { background: rgba(0,0,0,0.7); }
.card-left {
  flex: 1; min-width: 0; background: #000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.card-main-photo {
  flex: 1; width: 100%; display: flex; align-items: center; justify-content: center;
  padding: 12px; min-height: 0; overflow: hidden;
}
.card-main-photo img {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; border-radius: 6px; cursor: pointer;
  background: #111;
}
.card-thumbs {
  width: 100%; display: flex; gap: 6px; padding: 8px 12px;
  overflow-x: auto; background: rgba(0,0,0,0.6);
  justify-content: center; flex-shrink: 0;
}
.card-thumbs img {
  width: 56px; height: 56px; object-fit: cover; border-radius: 4px;
  cursor: pointer; border: 2px solid transparent; opacity: 0.7;
  transition: opacity 0.15s, border-color 0.15s; flex-shrink: 0; display: block;
}
.card-thumbs img:hover, .card-thumbs img.active {
  opacity: 1; border-color: var(--primary);
}
.card-thumb-wrap { position: relative; display: inline-block; cursor: pointer; }
.card-thumb-wrap[draggable="true"] { cursor: grab; }
.card-thumb-wrap[draggable="true"]:active { cursor: grabbing; }
.card-thumb-wrap.active img { opacity: 1; border-color: var(--primary); }
.card-thumb-wrap.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }
.card-thumb-wrap.drag-over img { opacity: 1; border-color: var(--primary); transform: scale(1.05); }
.card-thumb-actions { position: absolute; bottom: 1px; left: 1px; right: 1px; display: flex; gap: 1px; }
.card-thumb-actions button { flex: 1; background: rgba(0,0,0,.7); color: #fff; border: none; font-size: 11px; padding: 1px 0; cursor: pointer; border-radius: 0; }
.card-thumb-actions button:hover { background: rgba(0,0,0,.9); }
.card-right {
  width: 420px; flex-shrink: 0; overflow-y: auto;
  padding: 60px 28px 28px 28px; display: flex; flex-direction: column;
  background: var(--surface); gap: 16px;
}
.card-right .form-group { margin-bottom: 8px; }
.card-right .form-group label { font-size: 11px; display: block; margin-bottom: 2px; color: var(--text2); }
.card-right .form-group input,
.card-right .form-group select,
.card-right .form-group textarea {
  width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface2); color: var(--text);
}
.card-right .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card-right .form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
#cardForm { display: flex; flex-direction: column; gap: 8px; }
.card-info-table { display: flex; flex-direction: column; gap: 8px; }
.card-info-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.card-info-row span:first-child { color: var(--text2); min-width: 100px; }
.card-info-row span:last-child { text-align: right; font-weight: 500; word-break: break-word; max-width: 60%; }
.card-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.card-status-badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; }
.card-status-badge.sold { background: #e74c3c20; color: #e74c3c; }
.card-status-badge.off { background: #f39c1220; color: #f39c12; }
.card-price { font-size: 22px; font-weight: 700; color: var(--primary); margin: 8px 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.card-actions .btn { font-size: 12px; padding: 6px 14px; }

@media (max-width: 900px) {
  .card-container { flex-direction: column; width: 100vw; height: 100vh; border-radius: 0; }
  .card-left { height: 45vh; flex-shrink: 0; order: -1; }
  .card-right { width: 100%; height: 55vh; padding: 20px 16px 80px 16px; }
  .card-close { top: 8px; right: 10px; font-size: 24px; width: 34px; height: 34px; }
}

select option {
  background: var(--surface2);
  color: var(--text);
}

input[list]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
}

.autocomplete-list {
  background: var(--surface2);
  color: var(--text);
}

.sale-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.sale-table th { text-align: left; padding: 8px 6px; color: var(--text2); font-size: 12px; border-bottom: 2px solid var(--border); }
.sale-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.sale-table input[type="number"] { width: 70px; padding: 4px 6px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font-size: 14px; }
.sale-summary { margin-top: 16px; padding: 12px; background: var(--surface2); border-radius: 8px; }
.sale-summary-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.sale-summary-row.total { font-weight: 700; font-size: 18px; border-top: 2px solid var(--border); padding-top: 8px; margin-top: 4px; }
.sale-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s; }
.sale-card:hover { border-color: var(--primary); }
.sale-card-header { display: flex; justify-content: space-between; align-items: center; }
.sale-badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; }
.sale-badge.new { background: #3498db20; color: #3498db; }
.sale-badge.completed { background: #2ecc7120; color: #2ecc71; }
.sale-badge.cancelled { background: #e74c3c20; color: #e74c3c; }
