/* ── Variables ── */
:root {
  --navy:         #1e3a5f;
  --navy-dark:    #152b48;
  --navy-light:   #e8edf4;
  --amber:        #c8870f;
  --amber-light:  #fef3c7;
  --amber-border: #fde68a;
  --green:        #16a34a;
  --green-light:  #dcfce7;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --gray-bg:      #f4f5f7;
  --gray-border:  #e2e5ea;
  --gray-mid:     #9ca3af;
  --gray-muted:   #d1d5db;
  --gray-text:    #374151;
  --gray-sub:     #4b5563;
  --white:        #ffffff;
  --shadow-xs:    0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --font:         'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;
  --radius:       3px;
  --radius-sm:    2px;
}

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

body {
  font-family: var(--font);
  background: var(--gray-bg);
  color: var(--gray-text);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.site-header {
  background: var(--white);
  border-bottom: 2px solid var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-logo {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.3px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-logo-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-mid);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.header-counts {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gray-mid);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

/* ── Search Bar ── */
.search-bar-wrap {
  background: var(--white);
  border-bottom: 1px solid var(--gray-border);
  position: sticky;
  top: 48px;
  z-index: 99;
  box-shadow: var(--shadow-sm);
}

.search-bar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 130px 0 14px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  outline: none;
  background: var(--gray-bg);
  color: var(--gray-text);
  transition: border-color 0.12s, background 0.12s;
}

.search-input:focus {
  border-color: var(--navy);
  background: var(--white);
}

.search-input::placeholder {
  color: var(--gray-muted);
  font-size: 13px;
}

.type-badge-inline {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.search-btn {
  height: 48px;
  padding: 0 22px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.1px;
}

.search-btn:hover {
  background: var(--navy-dark);
}

.clear-btn {
  height: 48px;
  padding: 0 16px;
  background: transparent;
  color: var(--gray-mid);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  flex-shrink: 0;
  display: none;
}

.clear-btn:hover {
  background: var(--red-light);
  color: var(--red);
  border-color: #fca5a5;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
  font-family: var(--font);
}

.badge-amber {
  background: var(--amber-light);
  color: #78350f;
  border: 1px solid var(--amber-border);
}

.badge-navy {
  background: var(--navy-light);
  color: var(--navy);
  border: 1px solid #c3cfe0;
}

.badge-gray {
  background: #f3f4f6;
  color: var(--gray-sub);
  border: 1px solid var(--gray-border);
}

/* Source badges used in row-bezeichnung */
.badge-sg {
  background: var(--amber-light);
  color: #78350f;
  border: 1px solid var(--amber-border);
}

.badge-lkq {
  background: var(--navy);
  color: var(--white);
}

/* ── Error Bar ── */
.error-bar {
  background: var(--red-light);
  border-left: 3px solid var(--red);
  color: var(--red);
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 500;
  display: none;
}

.error-bar.visible {
  display: block;
}

/* ── Loading ── */
.loading-indicator {
  display: none;
  text-align: center;
  padding: 18px;
  color: var(--gray-mid);
  font-size: 12px;
  font-family: var(--font);
}

.loading-indicator.visible {
  display: block;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.55s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Ambig Bar ── */
.ambig-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  font-size: 12px;
}

.ambig-bar.visible {
  display: flex;
}

.ambig-label {
  color: #78350f;
  font-weight: 600;
  font-family: var(--font);
}

.ambig-btn {
  padding: 4px 14px;
  border-radius: 3px;
  border: 1.5px solid transparent;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.12s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ambig-lkq {
  background: var(--navy-light);
  color: var(--navy);
  border-color: #c3cfe0;
}

.ambig-lkq:hover {
  background: var(--navy);
  color: var(--white);
}

.ambig-hersteller {
  background: #f3f4f6;
  color: var(--gray-text);
  border-color: var(--gray-border);
}

.ambig-hersteller:hover {
  background: var(--gray-text);
  color: var(--white);
}

/* ── Main Content ── */
.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

.empty-state {
  text-align: center;
  padding: 72px 20px;
  color: var(--gray-mid);
}

.empty-state-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-sub);
}

.empty-state-sub {
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.1px;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Result Card — Row Layout ── */
.result-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: stretch;
  min-height: 54px;
  overflow: hidden;
  transition: background 0.1s, border-left-color 0.15s;
}

.result-card:hover {
  background: #f8f9fb;
}

.result-card.newest {
  border-left-color: var(--navy);
}

/* ── Bezeichnung Cell ── */
.row-bezeichnung {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 8px 14px;
  width: 210px;
  min-width: 0;
  flex-shrink: 0;
  border-right: 1px solid var(--gray-border);
}

.bezeichnung-text {
  font-family: var(--font);
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.3;
}

.row-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ── Data Cells ── */
.row-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px 12px;
  border-right: 1px solid var(--gray-border);
  min-width: 0;
  flex-shrink: 0;
}

.row-cell-wide {
  min-width: 148px;
}

.row-cell-altteil {
  width: 68px;
  align-items: center;
  text-align: center;
}

.cell-label {
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--gray-muted);
  white-space: nowrap;
  margin-bottom: 4px;
  line-height: 1;
}

/* Number pills */
.cell-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  display: inline-block;
  line-height: 1.5;
}

.pill-amber {
  background: var(--amber-light);
  color: #78350f;
  border: 1px solid var(--amber-border);
}

.pill-navy {
  background: var(--navy);
  color: var(--white);
}

/* Monospace values (EAN, Hersteller-Nr.) */
.cell-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--gray-sub);
  white-space: nowrap;
  line-height: 1.5;
}

/* Text value (Marke) */
.cell-text {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-text);
  white-space: nowrap;
  line-height: 1.5;
}

/* Empty state within a cell */
.row-empty {
  color: var(--gray-muted);
  font-size: 12px;
  font-family: var(--font);
  line-height: 1.5;
}

/* Status badge */
.status-badge {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  display: inline-block;
  line-height: 1.5;
}

.status-normal {
  background: var(--green-light);
  color: #166534;
}

.status-other {
  background: #f3f4f6;
  color: #6b7280;
}

/* Pfandwert */
.row-pfand {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  white-space: nowrap;
  line-height: 1.5;
}

/* Altteil indicator dot */
.altteil-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.altteil-dot--on {
  background: var(--green);
}

.altteil-dot--off {
  background: transparent;
  border: 2px solid var(--gray-muted);
}

/* Timestamp */
.row-timestamp {
  margin-left: auto;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--gray-muted);
  white-space: nowrap;
  flex-shrink: 0;
  border-left: 1px solid var(--gray-border);
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 16px 20px 24px;
}

.footer-admin-link {
  font-size: 11px;
  color: var(--gray-muted);
  text-decoration: none;
  font-family: var(--font);
  transition: color 0.12s;
}

.footer-admin-link:hover {
  color: var(--navy);
}

/* ── Mobile Layout ── */
@media (max-width: 1100px) {
  .result-card {
    flex-wrap: wrap;
    min-height: auto;
  }

  .row-bezeichnung {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-right: none;
    border-bottom: 1px solid var(--gray-border);
  }

  .bezeichnung-text {
    flex: 1;
    min-width: 0;
  }

  .row-badges {
    flex-shrink: 0;
    margin-left: auto;
  }

  .row-cell {
    width: 50%;
    border-right: none;
    border-bottom: 1px solid #f0f1f3;
    flex-shrink: 0;
  }

  /* Right border on odd cells (left column) */
  .row-cell:nth-of-type(odd) {
    border-right: 1px solid #f0f1f3;
  }

  .row-cell-altteil {
    width: 50%;
    align-items: flex-start;
    text-align: left;
  }

  .row-timestamp {
    width: 100%;
    border-left: none;
    border-top: 1px solid #f0f1f3;
    justify-content: flex-end;
    margin-left: 0;
    padding: 5px 12px;
  }
}

@media (max-width: 640px) {
  .header-counts {
    display: none;
  }

  .search-bar-inner {
    flex-wrap: wrap;
    padding: 8px 12px;
  }

  .search-input-wrap {
    width: 100%;
    order: 0;
  }

  .search-btn {
    flex: 1;
  }

  .clear-btn {
    flex: 0 0 auto;
  }

  .main-content {
    padding: 12px 12px 40px;
  }
}

/* ── Admin Page ── */
.admin-page {
  min-height: 100vh;
  background: var(--gray-bg);
}

.admin-header {
  background: var(--white);
  border-bottom: 2px solid var(--navy);
}

.admin-header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-title {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
}

.admin-title span {
  color: var(--amber);
}

.admin-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ── Login Form ── */
.login-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 32px;
  max-width: 380px;
  margin: 60px auto 0;
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  font-family: var(--font);
  color: var(--navy);
}

.login-sub {
  font-size: 12px;
  color: var(--gray-mid);
  margin-bottom: 24px;
  font-family: var(--font);
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-text);
  margin-bottom: 6px;
  font-family: var(--font);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  outline: none;
  background: var(--gray-bg);
  transition: border-color 0.12s;
  font-family: var(--font);
  color: var(--gray-text);
}

.form-input:focus {
  border-color: var(--navy);
  background: var(--white);
}

.btn-primary {
  width: 100%;
  padding: 11px 20px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  font-family: var(--font);
}

.btn-primary:hover {
  background: var(--navy-dark);
}

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

.login-error {
  background: var(--red-light);
  color: var(--red);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-top: 12px;
  display: none;
  font-family: var(--font);
}

.login-error.visible {
  display: block;
}

/* ── Upload Panel ── */
.admin-panel {
  display: none;
}

.admin-panel.visible {
  display: block;
}

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

.admin-panel-title {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  color: var(--navy);
}

.btn-logout {
  padding: 6px 14px;
  background: transparent;
  color: var(--gray-mid);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.12s;
}

.btn-logout:hover {
  background: var(--red-light);
  color: var(--red);
  border-color: #fca5a5;
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.upload-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 20px;
}

.upload-card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  font-family: var(--font);
  color: var(--gray-text);
}

.upload-card-desc {
  font-size: 11px;
  color: var(--gray-mid);
  margin-bottom: 16px;
  font-family: var(--font);
}

.drop-zone {
  border: 2px dashed var(--gray-border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.12s;
  position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--navy);
  background: var(--navy-light);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto 10px;
  color: var(--gray-mid);
}

.drop-zone-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-text);
  margin-bottom: 3px;
  font-family: var(--font);
}

.drop-zone-sub {
  font-size: 11px;
  color: var(--gray-mid);
  font-family: var(--font);
}

.drop-zone-filename {
  font-size: 11px;
  color: var(--navy);
  font-weight: 600;
  margin-top: 6px;
  word-break: break-all;
  font-family: var(--font-mono);
}

.upload-progress-wrap {
  margin-top: 14px;
  display: none;
}

.progress-bar-bg {
  background: var(--gray-border);
  border-radius: 2px;
  height: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  background: var(--navy);
  height: 100%;
  width: 0%;
  transition: width 0.2s;
  border-radius: 2px;
}

.progress-label {
  font-size: 10px;
  color: var(--gray-mid);
  margin-top: 4px;
  text-align: right;
  font-family: var(--font-mono);
}

.upload-result {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  display: none;
  font-family: var(--font);
}

.upload-result.success {
  background: var(--green-light);
  color: #166534;
  display: block;
}

.upload-result.error {
  background: var(--red-light);
  color: var(--red);
  display: block;
}

.btn-upload {
  margin-top: 12px;
  width: 100%;
  padding: 9px 16px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.12s;
}

.btn-upload:hover {
  background: var(--navy-dark);
}

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

@media (max-width: 600px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .admin-header-inner {
    gap: 10px;
  }
}

/* ── Copy Button ── */
.copy-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  color: #9ca3af;
  cursor: pointer;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  vertical-align: middle;
}
.result-card:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
.copy-btn.copied { background: #16a34a; color: #fff; border-color: #16a34a; opacity: 1; }

/* ── Etikett Button ── */
.etikett-btn {
  display: inline-block;
  margin-left: 10px;
  padding: 3px 10px;
  background: #c8870f;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s;
}
.etikett-btn:hover { background: #a36a08; }

.pill-green {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.footer-update {
  font-size: 11px;
  color: #9ca3af;
}

/* ── Größere Schrift (Lesbarkeit) ── */
body { font-size: 15px !important; }
.cell-label { font-size: 11px !important; }
.cell-pill { font-size: 14px !important; padding: 3px 10px !important; }
.cell-mono { font-size: 14px !important; }
.cell-text { font-size: 14px !important; }
.bezeichnung-text { font-size: 15px !important; font-weight: 600 !important; }
.row-cell { padding: 8px 12px !important; gap: 6px !important; }
.result-card { margin-bottom: 8px !important; }
.row-timestamp { font-size: 13px !important; padding: 6px 12px !important; }
.status-badge { font-size: 12px !important; padding: 3px 9px !important; }
.row-pfand { font-size: 14px !important; font-weight: 700 !important; }
.badge-sg, .badge-lkq { font-size: 12px !important; padding: 3px 8px !important; }
.search-input { font-size: 17px !important; height: 52px !important; }
.altteil-dot { width: 14px !important; height: 14px !important; }
