:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-border: #e4e6eb;
  --color-text: #1a1d23;
  --color-muted: #6b7280;
  --color-accent: #4f46e5;
  --color-accent-hover: #4338ca;
  --color-accent-soft: #eef0ff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-hover: 0 8px 20px rgba(16, 24, 40, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  padding: 2rem clamp(1rem, 4vw, 3rem) 3rem;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

main {
  max-width: 1400px;
  margin: 0 auto;
}

a {
  color: var(--color-accent);
}

.logout-form {
  display: inline;
}

.logout-form button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--color-accent);
  cursor: pointer;
  font: inherit;
}

.login-page {
  max-width: 28rem;
  margin: 8vh auto 0;
}

.login-card {
  padding: 2rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.account-card {
  max-width: 32rem;
  margin: 0 auto;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
}

.login-error {
  color: #b42318;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

th, td {
  text-align: left;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

th {
  background: var(--color-bg);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--color-accent-soft);
}

.plate-text {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.04em;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  max-width: 1400px;
  margin: 0 auto 2rem;
  padding: 1.25rem 1.75rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.header-title h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.main-nav {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.65rem;
}

.main-nav a {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.main-nav a:hover {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.main-nav a.active {
  background: var(--color-accent);
  color: #fff;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  color: var(--color-muted);
}

.status-item strong {
  color: var(--color-text);
  font-weight: 700;
}

.status-dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-ok {
  background: #22a55e;
}

.status-warn {
  background: #f2a90c;
}

.status-critical {
  background: #e13b3b;
}

.status-unknown {
  background: #bbb;
}

.page-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.refresh-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.refresh-control select {
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--color-text);
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
}

.search-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
  gap: 0.35rem;
}

.search-form input,
.search-form select {
  /* Explicit width so every field lines up the same size -- without this,
     a <select> shrinks to fit its own option text (e.g. "Farbe"'s short
     color names) while <input>s size differently by type, so the row
     looked visibly uneven despite sharing the same padding/border. */
  width: 170px;
  height: 2.35rem;
  box-sizing: border-box;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
}

.search-form select {
  /* Browsers render a <select>'s native dropdown chrome a couple of px
     taller than a same-CSS <input> by default even with an explicit
     height above -- appearance: none replaces it with a plain box so both
     element types actually render identically instead of just being told
     the same numbers. */
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2371717a' stroke-width='1.5'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 1rem;
  padding-right: 1.9rem;
}

.search-form input:focus,
.search-form select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.search-form button {
  padding: 0.55rem 1.3rem;
  border: none;
  border-radius: 8px;
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-form button:hover {
  background: var(--color-accent-hover);
}

.search-form a {
  font-size: 0.85rem;
  color: var(--color-muted);
  text-decoration: none;
  padding-bottom: 0.55rem;
}

.search-form a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.active-filters {
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--color-accent-soft);
  border-radius: var(--radius);
  padding: 0.65rem 1.25rem;
  margin-bottom: 1.25rem;
}

.active-filters strong {
  color: var(--color-accent);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.result-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.result-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.card-img {
  display: block;
  width: 100%;
  height: auto;
}

.card-body {
  padding: 0.9rem 1.1rem;
}

.card-plate {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.card-meta {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.2rem;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
}

.source-local {
  background: #eef0f2;
  color: #52525b;
}

.source-unresolved {
  background: #fef2f2;
  color: #b91c1c;
}

.source-vision {
  background: #ede9fe;
  color: #6d28d9;
}

.source-manual {
  background: #ecfdf5;
  color: #047857;
}

.source-recheck {
  background: #eff6ff;
  color: #1d4ed8;
}

.stats-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
  min-width: 10rem;
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--color-accent);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: 0.3rem;
}

.gallery-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 900px;
  margin: 0 auto;
}

.gallery-img {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
}

.gallery-info {
  padding: 1.25rem 1.5rem;
}

.gallery-plate {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.gallery-meta {
  font-size: 0.95rem;
  color: var(--color-muted);
  margin-bottom: 0.25rem;
}

.gallery-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

.gallery-nav a {
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.gallery-nav a:hover {
  background: var(--color-accent-hover);
}

.gallery-nav .disabled {
  padding: 0.5rem 1.1rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.gallery-position {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.alert-section {
  margin-bottom: 2.5rem;
}

.alert-section h2 {
  font-size: 1.15rem;
  margin-bottom: 1rem;
}

.alert-window {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--color-muted);
}

.danger-button {
  padding: 0.35rem 0.8rem;
  border: none;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
}

.danger-button:hover {
  background: #fee2e2;
}

.repeat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
}

.repeat-groups {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.repeat-group {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1rem;
}

.repeat-group-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
}

.watch-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: #fef2f2;
  color: #b91c1c;
}
