:root {
  --bg: #0e1726;
  --surface: #1a2540;
  --surface-2: #243355;
  --border: #2f4373;
  --text: #e7ecf5;
  --muted: #98a8c5;
  --accent: #4f9eff;
  --accent-hover: #3585f0;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 40px 20px 18px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
}

header .subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.db-status {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.db-status.ready { color: var(--success); }
.db-status.error { color: var(--error); }

/* Tabs */
.tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }

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

.tab-panel { display: none; }
.tab-panel.active { display: block; }

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

main > .tab-panel {
  display: none;
  flex-direction: column;
  gap: 24px;
}
main > .tab-panel.active { display: flex; }

.input-card, .result-card, .info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.input-card label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

#hin-input,
#bulk-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.15rem;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#hin-input {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#bulk-input {
  font-size: 0.95rem;
  resize: vertical;
  min-height: 140px;
}

#hin-input:focus, #bulk-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 158, 255, 0.18);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

button {
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: var(--surface-2);
  color: var(--text);
}

button.secondary:hover { background: var(--border); }

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 12px 0 0;
}

.result-card.hidden { display: none; }

.result-card .status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  margin-bottom: 16px;
  font-size: 1.05rem;
  flex-wrap: wrap;
}

.result-card .status.ok { color: var(--success); }
.result-card .status.warn { color: var(--warning); }
.result-card .status.err { color: var(--error); }

.result-card .status .badge {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.field {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  position: relative;
}

.field .label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.field .value {
  font-size: 1.05rem;
  font-weight: 600;
  word-break: break-word;
}

.field .value.mono {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
}

.field .value.muted { color: var(--muted); font-weight: 400; }

.field .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.field:hover .copy-btn { opacity: 1; }
.field .copy-btn:hover { color: var(--accent); }
.field .copy-btn.copied { color: var(--success); opacity: 1; }

.breakdown {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.breakdown h3 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.breakdown .hin-visual {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.25rem;
  letter-spacing: 0.15em;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.breakdown .seg {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.seg-country { background: rgba(251, 191, 36, 0.15); border-color: var(--warning); }
.seg-mic     { background: rgba(79, 158, 255, 0.18); border-color: var(--accent); }
.seg-serial  { background: rgba(148, 163, 184, 0.15); }
.seg-date    { background: rgba(74, 222, 128, 0.18); border-color: var(--success); }
.seg-myear   { background: rgba(248, 113, 113, 0.18); border-color: var(--error); }

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.errors {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
}

.errors ul { margin: 6px 0 0 18px; padding: 0; }

.warnings {
  background: rgba(251, 191, 36, 0.10);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
}

.warnings ul { margin: 6px 0 0 18px; padding: 0; }

/* Bulk results table */
.bulk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.bulk-table th, .bulk-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.bulk-table th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  position: sticky;
  top: 0;
}

.bulk-table tr.valid td { color: var(--text); }
.bulk-table tr.invalid td { color: var(--error); }
.bulk-table .mono {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.bulk-summary {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.bulk-summary .stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}

.bulk-summary .stat .lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.bulk-summary .stat .val {
  font-size: 1.3rem;
  font-weight: 700;
}

.bulk-summary .stat.ok .val { color: var(--success); }
.bulk-summary .stat.err .val { color: var(--error); }

.bulk-table-wrap {
  overflow-x: auto;
  max-height: 60vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* History list */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--surface-2); }

.history-item .hin {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 600;
}

.history-item .meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.history-item .time {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

/* Info card */
.info-card h2 { margin-top: 0; font-size: 1.2rem; }
.info-card h3 { margin: 18px 0 8px; font-size: 1rem; color: var(--muted); }
.info-card p  { margin: 8px 0; }
.info-card ul { padding-left: 20px; }
.info-card li { margin: 4px 0; }

.info-card a { color: var(--accent); text-decoration: none; }
.info-card a:hover { text-decoration: underline; }

.format-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
  font-size: 0.9rem;
}

.format-table th, .format-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.format-table th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.format-table tr:last-child td { border-bottom: none; }

.month-codes {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.info-card code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.hin-location-diagram {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 10px 0;
  display: flex;
  justify-content: center;
}

.hin-location-diagram svg { max-width: 100%; height: auto; }

.registry-link {
  background: rgba(79, 158, 255, 0.10);
  border: 1px solid rgba(79, 158, 255, 0.35);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
}

.registry-link a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 8px;
  font-weight: 600;
}

.registry-link a:hover { text-decoration: underline; }
.registry-link .hint { margin-top: 6px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 100;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ─── Ad slots ─── */
.ad-slot {
  max-width: 820px;
  margin: 16px auto;
  padding: 0 20px;
  min-height: 0;
}

.ad-slot:empty { display: none; }

.ad-slot-top    { margin-top: 16px; }
.ad-slot-inline { margin-top: 8px; margin-bottom: 0; }
.ad-slot-footer { margin-bottom: 24px; }

.ad-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

/* Affiliate banner */
.affiliate-banner {
  display: block;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--banner-accent, var(--accent));
  border-radius: var(--radius);
  padding: 16px 20px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  position: relative;
  box-shadow: var(--shadow);
}

.affiliate-banner:hover {
  transform: translateY(-1px);
  border-color: var(--banner-accent, var(--accent));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.affiliate-banner .affiliate-badge {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.affiliate-banner .affiliate-title {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
  padding-right: 70px;
}

.affiliate-banner .affiliate-text {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.affiliate-banner .affiliate-cta {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--banner-accent, var(--accent));
}

/* ─── Language switcher ─── */
.lang-switcher {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  gap: 6px;
  z-index: 50;
}

.lang-switcher a {
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color 0.15s, background 0.15s;
}

.lang-switcher a.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.lang-switcher a:hover { color: var(--text); }
.lang-switcher a.active:hover { color: white; }

/* ─── Cookie consent banner ─── */
.consent-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  z-index: 200;
  padding: 16px 20px;
}

.consent-content {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.consent-text { flex: 1; min-width: 250px; }
.consent-text strong { display: block; margin-bottom: 4px; }
.consent-text p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}
.consent-text a {
  color: var(--accent);
  text-decoration: none;
}
.consent-text a:hover { text-decoration: underline; }

.consent-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.consent-actions button {
  white-space: nowrap;
}

.consent-essential {
  background: var(--surface-2);
  color: var(--text);
}
.consent-essential:hover { background: var(--border); }

@media (max-width: 540px) {
  .consent-content { flex-direction: column; align-items: stretch; }
  .consent-actions { justify-content: stretch; }
  .consent-actions button { flex: 1; }
}

/* ─── Legal pages (Impressum / Datenschutz) ─── */
.legal-page {
  max-width: 820px;
  margin: 0 auto;
}

.legal-page h2 {
  margin: 24px 0 8px;
  font-size: 1.1rem;
  color: var(--text);
}

.warning-box {
  background: rgba(251, 191, 36, 0.10);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

/* ─── Footer ─── */
footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-links {
  margin-top: 8px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  margin: 0 4px;
}

.footer-links a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 540px) {
  header { padding: 28px 16px 16px; }
  main { padding: 20px 14px 60px; }
  .input-card, .result-card, .info-card { padding: 18px; }
  #hin-input { font-size: 1rem; }
  .breakdown .hin-visual { font-size: 1rem; }
  .tab { padding: 12px 14px; font-size: 0.85rem; }
}
