:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --border: #e0ddd6;
  --text: #2a2a28;
  --muted: #767268;
  --accent: #a4462f;
  --accent-hover: #8a3a27;
  --badge-bg: #efeae2;
  --badge-active-bg: #a4462f;
  --badge-active-text: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 { margin-top: 0; font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; }

a { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.9rem; }

.topnav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topnav .brand { font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto; }
.topnav a { text-decoration: none; color: var(--text); }
.topnav a:hover { color: var(--accent); }
.logout-form { margin: 0; }

button, .link-button {
  cursor: pointer;
  font: inherit;
}
button[type="submit"]:not(.link-button):not(.flag-badge) {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
}
button[type="submit"]:not(.link-button):not(.flag-badge):hover {
  background: var(--accent-hover);
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
}

input, select, textarea {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
}

.login-page {
  max-width: 320px;
  margin-top: 4rem;
  text-align: center;
}
.login-form { display: flex; flex-direction: column; gap: 0.75rem; }
.error { color: #b3261e; }

.filter-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
  align-items: flex-end;
}
.filter-row label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--muted);
  gap: 0.25rem;
}

.result-count { color: var(--muted); font-size: 0.9rem; }

table { border-collapse: collapse; width: 100%; background: var(--panel); }
.vehicle-table, .kv-table { margin-bottom: 1rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
.kv-table th { color: var(--muted); font-weight: 500; width: 40%; }

.pagination { display: flex; gap: 0.4rem; margin: 1rem 0; }
.pagination a { padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 5px; text-decoration: none; }
.pagination a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
@media (max-width: 700px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.flag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.inline-form { display: inline; margin: 0; }
.flag-badge {
  border: 1px solid var(--border);
  background: var(--badge-bg);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
}
.flag-badge.active {
  background: var(--badge-active-bg);
  color: var(--badge-active-text);
  border-color: var(--badge-active-bg);
}

.contact-list { list-style: none; padding: 0; }
.contact-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }

.inline-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  align-items: center;
}

.stacked-form { display: flex; flex-direction: column; gap: 0.85rem; max-width: 480px; }
.stacked-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.stacked-form textarea { min-height: 80px; }

.status-badge {
  border: 1px solid var(--border);
  background: var(--badge-bg);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.8rem;
}
.status-badge.status-success { background: #e3efe3; border-color: #bfd9bf; color: #2b6b2b; }
.status-badge.status-failed { background: #f5e2e0; border-color: #e3b8b3; color: #a4462f; }
.status-badge.status-running { background: var(--badge-active-bg); color: var(--badge-active-text); border-color: var(--badge-active-bg); }
