:root {
  --bg: #f2eee6;
  --panel: #fffdf8;
  --ink: #252621;
  --muted: #726d64;
  --line: #ded5c8;
  --green: #5a705f;
  --green-strong: #2f5f3d;
  --green-soft: #dff2e8;
  --red: #c9302c;
  --red-soft: #fde6e3;
  --amber: #b7791f;
  --amber-soft: #fff2cf;
  --shadow: 0 18px 50px rgba(53, 45, 32, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at top left, #faf7ef 0, var(--bg) 46%, #ebe6dc 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.sidebar {
  position: fixed;
  inset: 24px auto 24px 24px;
  width: 274px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: rgba(255, 253, 248, .92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand, .install-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand strong, .install-brand h1 {
  display: block;
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.brand small, .install-brand p {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin: 4px 0 0;
}

.brand-mark {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffbf4;
}

.brand-mark img { width: 46px; height: 46px; object-fit: contain; }

nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

nav a {
  position: relative;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 7px;
  font-weight: 800;
  color: #34352f;
}

nav a:hover, nav a.active { background: #d2d7ca; }
.nav-dot {
  position: absolute;
  right: 15px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--red);
}

.logout {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.logout button {
  width: 100%;
  min-height: 44px;
  color: #9b1c23;
  background: #fff6f5;
  border: 1px solid #ecc7c4;
}

.copyright {
  display: block;
  color: #8c867b;
  font-weight: 800;
  text-align: center;
}

.main {
  margin-left: 326px;
  padding: 40px 36px 80px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 30px;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 34px; line-height: 1.05; }
h2 { font-size: 21px; margin-bottom: 18px; }
h3 { font-size: 17px; margin: 18px 0 12px; }
p { margin: 0; }
.page-head p, .muted, small { color: var(--muted); }

.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.panel, .stat, .vehicle-hero, .login-card, .install-card {
  background: rgba(255, 253, 248, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel { padding: 22px; margin-bottom: 22px; }
.table-panel { overflow-x: auto; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat {
  padding: 18px;
  min-height: 86px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.stat.danger { border-color: #ec8f87; background: var(--red-soft); }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 13px 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

td strong { font-weight: 900; }
td small, .timeline small {
  display: block;
  margin-top: 3px;
  font-weight: 650;
}

.vehicle-plate {
  display: block;
  font-size: 22px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

form.actions, td form, .list-line { display: inline-flex; }

button, .button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  color: var(--ink);
  background: #fffbf4;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

button:hover, .button:hover { border-color: #bfb4a4; }
.primary, button.primary {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  font-weight: 900;
}

.danger, button.danger {
  color: var(--red);
  background: #fff8f7;
  border-color: #f0aaa4;
}

.badge {
  display: inline-flex;
  min-width: 60px;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 7px;
  font-weight: 900;
  font-size: 13px;
  background: #ece7dc;
}

.badge.ok { color: #087246; background: var(--green-soft); }
.badge.warn { color: var(--amber); background: var(--amber-soft); }
.badge.danger { color: var(--red); background: var(--red-soft); }

.deadline { color: var(--red); font-weight: 950; }
.deadline.overdue { text-decoration: underline; }

.blink { animation: blink 1.05s infinite; }
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.alert {
  padding: 14px 16px;
  border-radius: 7px;
  margin-bottom: 16px;
  background: #eef1ea;
  font-weight: 750;
}
.alert.ok { color: #0c6c45; background: #e2f3ea; }
.alert.warn { color: var(--amber); background: var(--amber-soft); }
.alert.danger { color: var(--red); background: var(--red-soft); }
.flash-stack { margin-bottom: 18px; }

.alert-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.alert-list a, .tile {
  display: block;
  padding: 16px;
  background: #fff9ed;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.alert-list span, .tile span { display: block; color: var(--muted); margin-top: 5px; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.wide, .mysql-fields { grid-column: 1 / -1; }
.mysql-fields {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
body.show-mysql .mysql-fields { display: grid; }

label span {
  display: block;
  margin-bottom: 7px;
  color: #666158;
  font-weight: 850;
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}

textarea { min-height: 112px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(90, 112, 95, .14);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}
.check input { width: auto; min-height: 0; }

.filters { margin-bottom: 16px; max-width: 380px; }
.empty {
  padding: 15px;
  border-radius: 8px;
  background: #fff3cf;
}

.vehicle-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px;
  background: linear-gradient(135deg, #142235, #5a705f);
  color: #fff;
}
.vehicle-hero p { color: rgba(255,255,255,.78); margin-top: 4px; }
.vehicle-hero .badge { background: rgba(255,255,255,.18); color: #fff; }
.vehicle-hero strong { display: block; margin-top: 8px; font-size: 24px; }

.timeline article {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.timeline time {
  color: var(--green-strong);
  font-weight: 900;
}
.file-link {
  display: inline-flex;
  margin: 8px 8px 0 0;
  padding: 7px 10px;
  background: #edf2ea;
  border-radius: 7px;
  font-weight: 800;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.inline-form, .list-line {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}
.list-line span { flex: 1; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.login-body, .install-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card, .install-card {
  width: min(760px, 100%);
  padding: 34px;
}

.login-card {
  width: min(520px, 100%);
}

.install-brand {
  justify-content: center;
  flex-direction: column;
  text-align: center;
  margin-bottom: 28px;
}

.login-card label { display: block; margin-bottom: 16px; }
.login-card button, .login-card .button { width: 100%; margin-top: 10px; }
.login-links { text-align: center; margin-top: 18px; font-weight: 900; color: var(--green); }
.auth-status { margin-top: 12px; color: var(--muted); font-weight: 750; }

.print-body {
  background: #fff;
  padding: 24px;
}
.print-toolbar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  background: #fff;
  padding-bottom: 12px;
}
.print-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0;
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
    margin: 14px;
  }
  .main {
    margin-left: 0;
    padding: 18px 14px 60px;
  }
  .stats, .settings-grid, .grid-form {
    grid-template-columns: 1fr;
  }
  .mysql-fields { grid-template-columns: 1fr; }
  .page-head {
    flex-direction: column;
  }
  .head-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  h1 { font-size: 28px; }
  .panel { padding: 16px; }
  .timeline article { grid-template-columns: 1fr; }
  table { min-width: 720px; }
  .brand strong { font-size: 24px; }
}

@media print {
  body { background: #fff; }
  .print-toolbar, .sidebar, .head-actions, button, .button { display: none !important; }
  .main { margin: 0; padding: 0; }
  .panel, .stat, .vehicle-hero { box-shadow: none; break-inside: avoid; }
  table { min-width: 0; }
}
