:root {
  --bg: #fafafa;
  --bg-2: #fff;
  --card: #fff;
  --line: #e8e8e8;
  --text: #111;
  --muted: #6b6b6b;
  --accent: #cc0000;
  --accent-hover: #b00000;
  --accent-dim: rgba(204, 0, 0, 0.1);
  --gold: #111;
  --danger: #cc0000;
  --warn: #b45309;
  --ok: #047857;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --safe-b: env(safe-area-inset-bottom);
  --nav-h: calc(64px + var(--safe-b));
  --top-h: 64px;
  --font: Poppins, Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, #fff 0 72px, transparent 72px),
    var(--bg);
}
.login-body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--accent);
}
.login-card, .card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.login-card { width: min(440px, 100%); padding: 32px; }
.brand, .brand-mini { display: flex; align-items: center; gap: 12px; }
.brand-login {
  display: block;
  text-align: center;
  margin-bottom: 8px;
}
.logo-login {
  width: min(280px, 100%);
  height: auto;
  margin: 0 auto;
}
.logo-header {
  height: 44px;
  width: auto;
  display: block;
}
.brand h1, .brand-mini {
  margin: 0;
  letter-spacing: -0.04em;
  font-weight: 800;
  color: #111;
}
.brand-mini { color: #111; text-transform: uppercase; }
.brand-mini span { line-height: 1; }
.brand-mini small {
  display: block;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 600;
}
.eyebrow, .hint, .muted, .who { color: var(--muted); }
.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
}
.login-copy { color: var(--muted); line-height: 1.5; }
.hint { font-size: 13px; margin-top: 16px; }

.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
textarea { min-height: 90px; resize: vertical; }
.row-2, .row-3 { display: grid; gap: 12px; }
@media (min-width: 720px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .row-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 18px;
  background: #111;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: var(--accent-dim); color: var(--accent); }
.btn.gold { background: #111; color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.banner {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--accent-dim);
  color: var(--accent);
}
.banner.danger { background: #fde8e8; color: #8a0000; }
.banner.ok { background: #e8f6ef; color: var(--ok); }

.app-body { padding-bottom: var(--nav-h); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar-meta { display: grid; text-align: right; }
#page-title { font-weight: 700; }
.who { font-size: 12px; }

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav a {
  color: var(--muted);
  text-align: center;
  padding: 12px 4px 10px;
  font-size: 12px;
  font-weight: 600;
}
.nav a.active { color: var(--accent); }

.view { width: min(1100px, 100%); margin: 0 auto; padding: 18px; }
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.search { min-width: min(280px, 100%); }
.car-picker { position: relative; flex: 1; min-width: min(280px, 100%); }
.car-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 8;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow: auto;
  padding: 6px;
}
.car-suggest button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.car-suggest button:hover,
.car-suggest button:focus {
  background: var(--accent-dim);
}
.car-suggest button span { color: var(--muted); font-size: 13px; }
.car-suggest-empty { padding: 12px; color: var(--muted); font-size: 13px; }
.occupancy { padding: 16px; margin-bottom: 16px; display: grid; gap: 12px; }
.occupancy-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.gap-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f7f7f7;
  margin-bottom: 8px;
}
.gap-item.free { border-left: 4px solid var(--ok); }
.gap-item.busy { border-left: 4px solid var(--accent); }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.car-card {
  overflow: hidden;
  cursor: pointer;
  min-height: 240px;
  background: #111;
  position: relative;
  border: 0;
}
.car-card-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.car-card-photo.placeholder {
  background:
    linear-gradient(180deg, rgba(204, 0, 0, 0.28), rgba(0, 0, 0, 0.55)),
    #fff url("../icons/logo.png") center 40% / auto 58% no-repeat;
}
.car-card-overlay {
  position: relative;
  z-index: 1;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px;
  color: #fff;
  background: linear-gradient(180deg, rgba(0,0,0,0.08) 28%, rgba(0,0,0,0.82) 100%);
}
.car-card.is-busy .car-card-photo {
  filter: blur(2px);
  transform: scale(1.02);
  opacity: 0.97;
}
.car-card.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(255, 252, 245, 0.14);
  pointer-events: none;
}
.car-card.is-busy .car-card-overlay {
  z-index: 2;
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 40%, rgba(17,17,17,0.62) 100%);
}
.busy-flag {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
}
.car-card-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.car-card .muted { color: rgba(255,255,255,0.78); }
.car-body { padding: 14px; display: grid; gap: 8px; }
.car-title { margin: 0; font-size: 18px; font-weight: 700; }
.doc-row { display: flex; gap: 6px; flex-wrap: wrap; }
.plate-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.year-badge {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 5px 9px;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

.plate {
  display: inline-flex;
  align-items: stretch;
  background: #fff;
  color: #111;
  border-radius: 4px;
  overflow: hidden;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.plate b {
  background: #1a4b9c;
  color: #fff;
  padding: 6px 7px;
  font-size: 10px;
  display: grid;
  place-items: center;
}
.plate span { padding: 6px 10px; font-size: 14px; }

.badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f3f3;
  color: #444;
}
.car-card .badge { background: rgba(255,255,255,0.16); color: #fff; }
.badge.ok { background: #e8f6ef; color: var(--ok); }
.badge.warn { background: #fff4e5; color: var(--warn); }
.badge.danger { background: #fde8e8; color: var(--accent); }
.badge.empty { opacity: 0.75; }
.car-card .badge.ok { background: var(--accent); color: #fff; }

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}
.empty h2 { color: var(--text); margin-bottom: 8px; }

.form-page { display: grid; gap: 14px; }
.form-page h2, .section-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.photo-pick {
  display: grid;
  gap: 10px;
  justify-items: start;
}
.photo-pick img, .thumb {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  background: #eee;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.today-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 800px) { .today-grid { grid-template-columns: 1fr 1fr; } }
.item-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.item-line:last-child { border-bottom: 0; }

.gantt-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}
.gantt {
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
.gantt th, .gantt td {
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  padding: 0;
}
.gantt thead th {
  position: sticky;
  top: 0;
  background: #111;
  padding: 10px 4px;
  font-weight: 600;
  color: #fff;
}
.gantt .lab {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 132px;
  max-width: 132px;
  background: #fff;
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
}
.gantt tbody tr.is-focus td { background: rgba(204, 0, 0, 0.05); }
.gantt tbody tr.is-focus .lab {
  background: #fff5f5;
  box-shadow: inset 4px 0 0 var(--accent);
}
.gantt tbody tr.is-dim { opacity: 0.38; }
.gantt thead .lab { background: #111; color: #fff; }
.gantt .day { min-width: 46px; text-align: center; cursor: pointer; }
.gantt .day:hover { background: rgba(204, 0, 0, 0.25); }
.gantt .day.today { color: #fff; }
.gantt .day.selected { background: var(--accent); color: #fff; }
.gantt thead th.today { box-shadow: inset 0 -3px 0 #fff; }
.track { position: relative; height: 42px; }
.today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(204, 0, 0, 0.55);
  z-index: 2;
  pointer-events: none;
}
.bar {
  position: absolute;
  top: 8px;
  height: 26px;
  border-radius: 6px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}
.bar.rezervat { background: #111; }
.bar.in_derulare { background: var(--accent); }
.bar.finalizat { background: #888; }
.bar.overlap { outline: 2px solid var(--danger); }

.list { display: grid; gap: 10px; }
.list-item {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  color: inherit;
}
.mini-photo {
  width: 96px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius);
  background: #eee;
}

.car-preview {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 12px;
}
.car-preview img { height: 80px; width: 120px; object-fit: cover; border-radius: var(--radius); background: #eee; }

.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.photo-tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #eee;
}
.photo-tile img { height: 140px; width: 100%; object-fit: cover; }
.photo-tile button {
  position: absolute;
  top: 6px;
  right: 6px;
}

.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button.active { background: var(--accent); color: #fff; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 12px);
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  border: 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  z-index: 50;
  max-width: min(92vw, 420px);
}
.toast.danger { background: var(--accent); }

.install-banner {
  margin: 0 0 14px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

@media (min-width: 960px) {
  .app-body { padding: 0 0 0 220px; }
  .nav {
    left: 0; top: 0; bottom: 0; right: auto;
    width: 220px;
    grid-template-columns: 1fr;
    align-content: start;
    padding: 80px 12px 16px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }
  .nav a { text-align: left; padding: 12px 14px; border-radius: var(--radius); font-size: 13px; }
  .nav a.active { background: var(--accent); color: #fff; }
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card { padding: 16px; }
.kpi-card strong {
  display: block;
  font-size: 26px;
  letter-spacing: -0.04em;
  margin: 4px 0 2px;
}
.report-section { padding: 16px; margin-bottom: 16px; }
.report-sub { font-size: 14px; margin: 16px 0 8px; }
.report-list { display: grid; gap: 8px; }
.report-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.report-row:last-child { border-bottom: 0; }
.report-row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.report-row-meta { text-align: right; }
.report-thumb {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: #111;
}
.report-thumb.placeholder {
  background: #111 url("../icons/logo.png") center/60% no-repeat;
}
.report-row:has(.report-rank) {
  grid-template-columns: 24px auto 1fr auto;
}
.status-stats { margin-bottom: 8px; }
