/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #1D9E75;
  --green-dark: #0F6E56;
  --green-light: #E1F5EE;
  --green-text: #085041;
  --amber: #EF9F27;
  --amber-dark: #BA7517;
  --amber-light: #FAEEDA;
  --red: #E24B4A;
  --red-dark: #A32D2D;
  --red-light: #FCEBEB;
  --blue: #378ADD;
  --blue-light: #E6F1FB;
  --gray-50: #F8F7F4;
  --gray-100: #EEEDE8;
  --gray-200: #D3D1C7;
  --gray-400: #888780;
  --gray-600: #5F5E5A;
  --gray-800: #2C2C2A;
  --text: #1a1a18;
  --text-muted: #6b6a65;
  --text-hint: #9c9a92;
  --border: rgba(0,0,0,0.09);
  --border-strong: rgba(0,0,0,0.16);
  --surface: #ffffff;
  --surface-2: #F8F7F4;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
}

html { font-size: 16px; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.logo-icon {
  width: 34px; height: 34px;
  background: var(--green);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.logo-text { font-size: 17px; font-weight: 600; color: var(--text); letter-spacing: -0.3px; }

.header-center { flex: 1; }
.nav { display: flex; gap: 2px; }
.nav-btn {
  background: none; border: none; cursor: pointer;
  padding: 6px 14px;
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  border-radius: 8px;
  transition: all 0.15s;
  font-family: inherit;
}
.nav-btn:hover { background: var(--gray-100); color: var(--text); }
.nav-btn.active { background: var(--green-light); color: var(--green-dark); }

.friday-badge {
  font-size: 12px; font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--green-light);
  color: var(--green-text);
  white-space: nowrap;
}
.friday-badge:empty { display: none; }

/* ===== MAIN ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ===== SECTIONS ===== */
.section { display: none; animation: fadeIn 0.2s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.section-title { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; color: var(--text); }
.section-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ===== SUMMARY GRID ===== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }
.metric-value { font-size: 28px; font-weight: 600; color: var(--text); line-height: 1; }
.metric-value.green { color: var(--green); }
.metric-value.amber { color: var(--amber-dark); }
.metric-value.red { color: var(--red-dark); }

/* ===== VEHICLE GRID ===== */
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.vehicle-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.vehicle-card.has-alert { border-left: 3px solid var(--amber); }
.vehicle-card.has-damage { border-left: 3px solid var(--red); }

.vehicle-card-header {
  padding: 16px 18px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.vehicle-plate {
  font-family: 'DM Mono', monospace;
  font-size: 16px; font-weight: 500;
  letter-spacing: 1.5px;
  color: var(--text);
}
.vehicle-tags { display: flex; gap: 6px; align-items: center; }
.tag {
  font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 20px;
}
.tag-owned { background: var(--blue-light); color: #185FA5; }
.tag-rented { background: var(--amber-light); color: var(--amber-dark); }
.tag-damage { background: var(--red-light); color: var(--red-dark); }

.vehicle-card-body { padding: 14px 18px; }
.vehicle-model { font-size: 15px; font-weight: 600; color: var(--text); }
.vehicle-year { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }

.km-bar-wrap { margin-bottom: 4px; }
.km-bar-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.km-current { font-size: 14px; font-weight: 600; }
.km-next-label { font-size: 11px; color: var(--text-muted); }
.km-bar { height: 5px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.km-fill { height: 100%; border-radius: 3px; background: var(--green); transition: width 0.4s ease; }
.km-fill.amber { background: var(--amber); }
.km-fill.red { background: var(--red); }

.vehicle-card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.driver-info { font-size: 13px; color: var(--text-muted); }
.driver-info strong { color: var(--text); font-weight: 500; }
.last-inspection { font-size: 11px; color: var(--text-hint); }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.card-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ===== INSPECTION ===== */
.inspection-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 768px) {
  .inspection-layout { grid-template-columns: 1fr; }
}
.inspection-form { display: flex; flex-direction: column; gap: 4px; }

.angles-section { margin: 8px 0 16px; }
.angles-title {
  font-size: 14px; font-weight: 600;
  margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.angles-count {
  font-size: 12px; font-weight: 500;
  background: var(--green-light); color: var(--green-text);
  padding: 2px 8px; border-radius: 20px;
}
.angles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.angle-slot {
  aspect-ratio: 1;
  border: 1.5px dashed var(--gray-200);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.angle-slot:hover { border-color: var(--green); background: var(--green-light); }
.angle-slot.filled { border-style: solid; border-color: var(--green); }
.angle-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.angle-icon { font-size: 18px; }
.angle-label { font-size: 10px; color: var(--text-muted); text-align: center; line-height: 1.2; }
.angle-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.angle-check {
  position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px;
  background: var(--green); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: white; font-weight: 700;
}

/* ===== RESULT ===== */
.inspection-result { display: flex; flex-direction: column; }
.result-card { }
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.result-title { font-size: 15px; font-weight: 600; }
.ai-badge {
  font-size: 11px; font-weight: 500;
  background: linear-gradient(135deg, #E1F5EE, #E6F1FB);
  color: var(--green-dark);
  padding: 3px 10px; border-radius: 20px;
  border: 1px solid rgba(29,158,117,0.2);
}

.result-ok { display: flex; align-items: center; gap: 10px; padding: 14px; background: var(--green-light); border-radius: 8px; color: var(--green-text); font-size: 14px; font-weight: 500; }
.result-summary { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

.damage-item {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.damage-item:last-child { border-bottom: none; padding-bottom: 0; }
.damage-severity {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px;
  white-space: nowrap; align-self: flex-start; margin-top: 2px;
}
.sev-leve { background: var(--amber-light); color: var(--amber-dark); }
.sev-moderada { background: #FAECE7; color: #712B13; }
.sev-grave { background: var(--red-light); color: var(--red-dark); }
.damage-body { flex: 1; }
.damage-angle { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.damage-desc { font-size: 13px; color: var(--text); }
.damage-new { font-size: 11px; color: var(--red-dark); font-weight: 500; }

/* ===== ALERTS ===== */
.alert-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.alert-item.warn { border-left: 4px solid var(--amber); }
.alert-item.danger { border-left: 4px solid var(--red); }
.alert-dot { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.alert-dot.warn { background: var(--amber-light); }
.alert-dot.danger { background: var(--red-light); }
.alert-body { flex: 1; }
.alert-title { font-size: 15px; font-weight: 600; }
.alert-sub { font-size: 13px; color: var(--text-muted); }
.alert-remaining { font-size: 14px; font-weight: 600; color: var(--amber-dark); white-space: nowrap; }
.alert-remaining.danger { color: var(--red-dark); }

/* ===== DRIVERS ===== */
.driver-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.driver-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}
.driver-body { flex: 1; }
.driver-name { font-size: 15px; font-weight: 600; }
.driver-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.driver-vehicles { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.plate-tag {
  font-family: 'DM Mono', monospace;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}
.cnh-expired { color: var(--red-dark); }
.cnh-ok { color: var(--green-dark); }

/* ===== CONFIG ===== */
.config-layout { display: flex; flex-direction: column; gap: 16px; max-width: 600px; }
.config-hint {
  font-size: 12px; color: var(--text-muted);
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  line-height: 1.6;
}
.api-status { font-size: 13px; margin-top: 8px; }
.api-status.ok { color: var(--green-dark); }
.api-status.error { color: var(--red-dark); }
.danger-card { border-color: rgba(226,75,74,0.2); }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,158,117,0.12); }
.form-input.mono { font-family: 'DM Mono', monospace; letter-spacing: 1px; }
textarea.form-input { resize: vertical; }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6a65' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--green);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--green-dark); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-top: 4px; }
.btn-primary:disabled { background: var(--gray-200); cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-danger {
  background: var(--red-light);
  color: var(--red-dark);
  border: 1px solid rgba(226,75,74,0.2);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn-danger:hover { background: var(--red); color: white; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ===== LOADING ===== */
.loading { display: flex; align-items: center; gap: 10px; padding: 16px; font-size: 13px; color: var(--text-muted); }
.dots { display: flex; gap: 4px; }
.dots span { width: 6px; height: 6px; background: var(--green); border-radius: 50%; animation: dotBounce 1s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { color: var(--text-muted); font-size: 15px; margin-bottom: 20px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--gray-800); color: white;
  padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  z-index: 999;
  transition: transform 0.3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green-dark); }
.toast.error { background: var(--red-dark); }

/* ===== CARD ACTION BUTTONS ===== */
.vehicle-card-actions, .driver-actions {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.btn-card-action {
  flex: 1;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: all 0.15s;
}
.btn-card-action:hover { background: var(--gray-100); }
.btn-card-action.danger { color: var(--red-dark); background: var(--red-light); border-color: rgba(226,75,74,0.2); }
.btn-card-action.danger:hover { background: var(--red); color: white; }

/* ===== HISTORY ===== */
.history-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.history-item:last-child { border-bottom: none; }
.history-date { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.history-detail { color: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .main { padding: 20px 16px; }
  .header-inner { padding: 0 16px; }
  .nav-btn { padding: 6px 10px; font-size: 13px; }
  .vehicle-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .angles-grid { grid-template-columns: repeat(4, 1fr); }
}
