:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #222b38;
  --border: #2f3a49;
  --text: #e6edf3;
  --muted: #93a1b1;
  --accent: #ff7a18;
  --accent-2: #f0a500;
  --green: #2ecc71;
  --yellow: #f4c430;
  --red: #ff5757;
  --blue: #4aa8ff;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 18px 60px; flex: 1; }

/* Top bar */
.topbar { background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 10px 18px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; }
.mainnav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.mainnav a.active { color: var(--text); background: var(--panel-2); }
.usermenu { display: flex; gap: 14px; align-items: center; color: var(--muted); }
.usermenu a { color: var(--muted); }
.usermenu a:hover { color: var(--text); }

/* Footer */
.footer { text-align: center; color: var(--muted); padding: 18px; font-size: 13px; border-top: 1px solid var(--border); }

/* Headings */
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 28px 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.subtle { color: var(--muted); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.btn:hover { background: #2b3543; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1008; }
.btn-primary:hover { background: var(--accent-2); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger { color: var(--red); border-color: #5a2b2b; background: #2a1c1c; }
.btn-danger:hover { background: #3a2323; }
.btn-link { background: none; border: none; color: var(--muted); padding: 0; cursor: pointer; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards / panels */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* Vehicle cards */
.vehicle-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.vehicle-card .photo { height: 150px; background: var(--panel-2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 40px; }
.vehicle-card .body { padding: 14px 16px; }
.vehicle-card .meta { color: var(--muted); font-size: 13px; }

/* Stats */
.stats { display: flex; gap: 22px; flex-wrap: wrap; margin: 10px 0; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; min-width: 120px; }
.stat .num { font-size: 22px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-overdue { background: #3a1c1c; color: var(--red); }
.badge-soon { background: #3a331c; color: var(--yellow); }
.badge-ok { background: #1c3a28; color: var(--green); }
.badge-unknown { background: var(--panel-2); color: var(--muted); }
.badge-maintenance { background: #1c2c3a; color: var(--blue); }
.badge-repair { background: #3a2a1c; color: var(--accent-2); }
.badge-active { background: #1c3a28; color: var(--green); }
.badge-expired { background: #2a2f38; color: var(--muted); }
.badge-planning { background: #2a2f38; color: var(--muted); }
.badge-in_progress { background: #1c2c3a; color: var(--blue); }
.badge-on_hold { background: #3a331c; color: var(--yellow); }
.badge-completed { background: #1c3a28; color: var(--green); }

/* Forms */
form .field { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.help { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Reminders list */
.reminder { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.reminder:last-child { border-bottom: none; }
.reminder .grow { flex: 1; }
.reminder .detail { color: var(--muted); font-size: 13px; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery .thumb { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.gallery .thumb img { width: 100%; height: 120px; object-fit: cover; display: block; }
.gallery .thumb .doc { height: 120px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.gallery .thumb .cap { padding: 5px 7px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }

/* Timeline (project logs) */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--border); padding: 0 0 18px 18px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.timeline .when { font-weight: 600; }
.timeline .when small { color: var(--muted); font-weight: 400; }

/* Inline forms / detail rows */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.muted-row td { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

details.inline { margin-top: 10px; }
details.inline > summary { cursor: pointer; color: var(--accent-2); font-size: 14px; }
details.inline[open] > summary { margin-bottom: 12px; }

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

/* Login */
.login-wrap { max-width: 360px; margin: 8vh auto 0; }
.login-wrap .brand-big { text-align: center; font-size: 34px; margin-bottom: 8px; }
.login-wrap h1 { text-align: center; }

/* Flashes */
.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); }
.flash-success { background: #15301f; border-color: #1f5132; color: #b8f0cf; }
.flash-danger { background: #311818; border-color: #5a2b2b; color: #f5c4c4; }
.flash-warning { background: #312c18; border-color: #5a522b; color: #f0e3b8; }
.flash-info { background: #16283a; border-color: #244a6b; color: #bfdcf5; }

@media (max-width: 600px) {
  .topbar-inner { gap: 10px; }
  .mainnav { order: 3; width: 100%; overflow-x: auto; }
  .stats { gap: 12px; }
}

/* Print report */
@media print {
  .topbar, .footer, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .container { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  a { color: #000; }
  th, td { border-color: #ccc; }
}
