* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1e1e1e;
  color: #e0e0e0;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* HEADER */
header {
  position: sticky;
  top: 0;
  background: #2d2d2d;
  padding: 12px 16px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

header h1 { font-size: 18px; font-weight: 700; color: #fff; }

.header-actions { display: flex; gap: 8px; }

.header-actions button {
  background: #3d3d3d;
  border: 0;
  color: #4da3ff;
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
}

.header-actions button:active {
  background: #4da3ff;
  color: #fff;
  transform: scale(0.95);
}

/* SEARCH */
.search-wrap { position: relative; margin-bottom: 8px; }

#search {
  width: 100%;
  padding: 14px 44px 14px 16px;
  background: #3d3d3d;
  border: 2px solid #3d3d3d;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  outline: none;
}

#search:focus { border-color: #4da3ff; }
#search::placeholder { color: #888; }

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: #888;
  font-size: 18px;
  padding: 8px;
  cursor: pointer;
  display: none;
}
.clear-btn.visible { display: block; }

/* FILTERS */
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.filters select {
  padding: 10px 12px;
  background: #3d3d3d;
  border: 0;
  border-radius: 10px;
  color: #e0e0e0;
  font-size: 13px;
  outline: none;
}

#sortare { grid-column: 1 / -1; }

/* STATS */
.stats {
  margin-top: 10px;
  padding: 8px 12px;
  background: #252526;
  border-radius: 8px;
  font-size: 11px;
  color: #888;
  text-align: center;
}
.stats b { color: #4da3ff; }

/* LISTA */
main { padding: 8px; }

.loading, .empty {
  text-align: center;
  padding: 60px 20px;
  color: #888;
  font-style: italic;
}

/* CARD PRODUS */
.card {
  background: #252526;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border-left: 4px solid #555;
}

.card.status-ok { border-left-color: #22c55e; }
.card.status-discrepanta { border-left-color: #ef4444; }
.card.status-zero { border-left-color: #f59e0b; }
.card.status-negasit { border-left-color: #eab308; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 8px;
}

.card-info { flex: 1; min-width: 0; }

.card-cod {
  font-size: 14px;
  font-weight: 800;
  color: #4da3ff;
  margin-bottom: 4px;
  word-break: break-all;
}

.card-nume {
  font-size: 12px;
  color: #ccc;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-site-badge {
  flex-shrink: 0;
  text-align: center;
  padding: 6px 10px;
  background: #3d3d3d;
  border-radius: 8px;
  min-width: 55px;
}

.card-site-badge .label {
  font-size: 9px;
  text-transform: uppercase;
  color: #666;
  letter-spacing: 0.5px;
}

.card-site-badge .value {
  font-size: 18px;
  font-weight: 800;
  color: #4da3ff;
}

.card.status-discrepanta .card-site-badge .value { color: #ef4444; }
.card.status-zero .card-site-badge .value { color: #f59e0b; }
.card.status-negasit .card-site-badge .value { color: #888; }

/* STOC LOCATII */
.stoc-locatii {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.stoc-item {
  background: #3d3d3d;
  padding: 6px 8px;
  border-radius: 8px;
  text-align: center;
}

.stoc-item .loc {
  font-size: 9px;
  text-transform: uppercase;
  color: #666;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stoc-item .qty {
  font-size: 16px;
  font-weight: 800;
  color: #22c55e;
}

.stoc-item .qty.zero {
  color: #666;
  font-weight: 500;
}

.stoc-item.depozit { background: #1e3a8a; }
.stoc-item.depozit .loc { color: #93c5fd; }
.stoc-item.depozit .qty { color: #60a5fa; }

/* FOOTER */
footer {
  padding: 16px;
  text-align: center;
  color: #555;
  font-size: 11px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  padding: 20px;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
.modal.visible { display: flex; }

.modal-content {
  background: #2d2d2d;
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-content .close {
  position: absolute;
  right: 16px;
  top: 16px;
  font-size: 28px;
  color: #888;
  cursor: pointer;
  line-height: 1;
}

.modal-content h2 {
  color: #4da3ff;
  margin-bottom: 16px;
  font-size: 18px;
}

.modal-content h3 {
  color: #ccc;
  margin: 16px 0 8px 0;
  font-size: 14px;
}

.modal-content label {
  display: block;
  margin: 12px 0 4px 0;
  font-size: 13px;
  color: #aaa;
}

.modal-content input,
.modal-content select {
  width: 100%;
  padding: 12px;
  background: #3d3d3d;
  border: 2px solid #3d3d3d;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  outline: none;
  margin-bottom: 8px;
}

.modal-content input:focus,
.modal-content select:focus { border-color: #4da3ff; }

.btn-primary, .btn-secondary, .btn-danger {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.btn-primary { background: #4da3ff; color: #fff; }
.btn-primary:active { background: #2b7ed1; }

.btn-secondary { background: #3d3d3d; color: #e0e0e0; }
.btn-secondary:active { background: #4d4d4d; }

.btn-danger { background: #7f1d1d; color: #fca5a5; }
.btn-danger:active { background: #991b1b; }

.menu-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #3d3d3d;
}
.menu-section:last-child { border-bottom: 0; }

#lista-locatii {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.locatie-tag {
  background: #1e3a8a;
  color: #93c5fd;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.locatie-tag .remove {
  background: transparent;
  border: 0;
  color: #93c5fd;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}

#upload-status {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

#upload-status.success { background: #14532d; color: #86efac; }
#upload-status.error { background: #7f1d1d; color: #fca5a5; }
#upload-status.info { background: #1e3a8a; color: #93c5fd; }

@media (max-width: 480px) {
  header { padding: 10px 12px; }
  .filters { grid-template-columns: 1fr; }
  #sortare { grid-column: auto; }
}