:root {
  --bg: #f3f0e8;
  --panel: #ffffff;
  --text: #1f2b21;
  --subtext: #5c675f;
  --accent: #a0451a;
  --accent-2: #2b5b44;
  --danger: #b72f2f;
  --border: #d8d1c4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", sans-serif;
  background: radial-gradient(circle at top right, #efe6d2 0%, var(--bg) 45%, #e7e0d2 100%);
  color: var(--text);
}

.page-header {
  padding: 1.4rem 1rem;
  border-bottom: 2px solid #d7ccb9;
  background: linear-gradient(120deg, #f6f0e1, #ece2cd);
}

.header-actions {
  margin-top: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.login-panel {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 43, 33, 0.48);
  z-index: 1000;
  padding: 1rem;
}

.login-panel.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 1rem;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
}

.page-header h1 {
  margin: 0;
  font-size: 1.7rem;
}

.page-header p {
  margin: 0.4rem 0 0;
  color: var(--subtext);
}

.grid {
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  box-shadow: 0 6px 20px rgba(80, 68, 48, 0.08);
}

.card.wide {
  grid-column: 1 / -1;
}

h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

label {
  display: block;
  margin-bottom: 0.7rem;
  font-size: 0.9rem;
  color: var(--subtext);
}

input,
select,
button {
  width: 100%;
  padding: 0.58rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #c5bcac;
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid #f4c37b;
  border-color: #c58f42;
}

button {
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button.secondary {
  background: var(--accent-2);
}

button:hover {
  opacity: 0.92;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.actions-inline {
  margin-bottom: 0.65rem;
}

button.small {
  width: auto;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.toggle input {
  width: auto;
}

.hint {
  color: var(--subtext);
  font-size: 0.85rem;
  margin-bottom: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  padding: 0.38rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #d4a28f;
  color: #71351c;
  background: #f7e1d8;
  cursor: pointer;
}

.table-wrap {
  overflow: auto;
}

.analysis-preview {
  display: grid;
  gap: 0.7rem;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.analysis-item {
  border: 1px solid #d9d2c4;
  border-radius: 10px;
  background: #faf7f0;
  padding: 0.45rem;
}

.analysis-item h4 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: #4e5a4f;
}

.analysis-item img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e7dfd0;
}

.analysis-attempts {
  max-height: 180px;
  overflow: auto;
  border: 1px solid #ddd6c8;
  border-radius: 8px;
  background: #fff;
  padding: 0.45rem;
  font-size: 0.82rem;
  color: #304034;
}

.analysis-attempts p {
  margin: 0.15rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid #ebe4d8;
  text-align: left;
  padding: 0.5rem;
  font-size: 0.9rem;
}

.status-new {
  color: var(--danger);
  font-weight: 700;
}

.status-known {
  color: var(--accent-2);
  font-weight: 700;
}

.plate-popup {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 950;
  max-width: min(420px, calc(100vw - 2rem));
}

.plate-popup.hidden {
  display: none;
}

.plate-popup-card {
  border: 1px solid #d4b48a;
  border-radius: 12px;
  background: linear-gradient(140deg, #fff7e7, #f7ebd4);
  box-shadow: 0 12px 30px rgba(50, 36, 14, 0.28);
  padding: 0.8rem;
}

.plate-popup-title {
  margin: 0;
  font-weight: 700;
  color: #654120;
}

.plate-popup-plate {
  margin: 0.35rem 0;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #1b1f1b;
}

.plate-popup-meta {
  margin: 0 0 0.65rem;
  color: #4b564c;
  font-size: 0.9rem;
}

@media (max-width: 700px) {
  .page-header h1 {
    font-size: 1.35rem;
  }

  .row {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 640px;
  }

  .header-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .plate-popup {
    right: 0.7rem;
    left: 0.7rem;
    bottom: 0.7rem;
    max-width: none;
  }
}
