:root {
  --brand-red: #d32f1e;
  --brand-red-dark: #a3200f;
  --brand-dark: #17181a;
  --brand-dark-2: #232427;
  --ink: #23262b;
  --muted: #7a7f87;
  --border: #e7e8ec;
  --bg: #f4f5f7;
  --radius: .7rem;
  --shadow-sm: 0 1px 2px rgba(20,20,30,.05), 0 1px 1px rgba(20,20,30,.04);
  --shadow-md: 0 4px 14px rgba(20,20,30,.08);
  --shadow-lg: 0 12px 28px rgba(20,20,30,.14);
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-dark) 0%, #0e0f10 100%);
  color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
  z-index: 10;
}
.sidebar-brand {
  padding: 1.4rem 1.2rem; display: flex; align-items: center; gap: .7rem;
  font-weight: 800; letter-spacing: .01em; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i {
  font-size: 1.5rem; color: #fff; background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(211,47,30,.4);
}
.sidebar-brand small { color: #9a9da3; font-weight: 500; letter-spacing: .06em; }
.sidebar-brand-logo { max-height: 48px; max-width: 100%; object-fit: contain; }
.sidebar-nav { flex: 1; padding: 1rem .7rem; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; margin-bottom: .15rem;
  color: #aeb1b6; text-decoration: none; font-size: .9rem; font-weight: 500;
  border-radius: .5rem; transition: background .15s, color .15s;
}
.sidebar-nav a i { width: 1.2rem; text-align: center; font-size: 1.02rem; }
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active {
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark)); color: #fff;
  box-shadow: 0 4px 10px rgba(211,47,30,.35);
}
.nav-badge {
  margin-left: auto; background: var(--brand-red); color: #fff; font-size: .7rem; font-weight: 700;
  line-height: 1; padding: .3em .5em; border-radius: 1rem; min-width: 1.4em; text-align: center;
}
.sidebar-user {
  padding: 1rem 1.1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; color: #cfd1d4;
}
.sidebar-user .btn { border-color: rgba(255,255,255,.25); color: #eee; }
.sidebar-user .btn:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- Layout ---------- */
.main-area { flex: 1; min-width: 0; }
.topbar { background: #fff; padding: .6rem 1rem; border-bottom: 1px solid var(--border); align-items: center; gap: .75rem; }
.content { padding: 1.75rem 2rem; max-width: 1400px; }

.page-head h4 { font-weight: 800; letter-spacing: -.01em; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); border-radius: var(--radius);
  transition: box-shadow .15s, transform .15s;
}
a.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-card {
  border-radius: var(--radius); padding: 1.1rem 1.3rem; color: #fff; position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.stat-card::after {
  content: ''; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.stat-card.red { background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark)); }
.stat-card.dark { background: linear-gradient(135deg, #34363a, #0f1011); }
.stat-card.green { background: linear-gradient(135deg, #43a047, #1b5e20); }
.stat-card.blue { background: linear-gradient(135deg, #1e88e5, #0d47a1); }
.stat-card .small { opacity: .85; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; font-size: .72rem; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; letter-spacing: .01em; padding: .4em .65em; border-radius: .4rem; }
.badge-estado-disponible { background: #e6f4ea; color: #1b5e20; }
.badge-estado-rentado { background: #fdeae7; color: var(--brand-red-dark); }
.badge-estado-mantenimiento { background: #fff3cd; color: #7a5b00; }
.badge-estado-reservado { background: #eceef1; color: #495057; }
.badge-estado-entregado { background: #e3f0fd; color: #0d47a1; }
.badge-estado-devuelto { background: #e6f4ea; color: #1b5e20; }
.badge-estado-cancelado { background: #eceef1; color: #6c757d; }

/* ---------- Buttons ---------- */
.btn { border-radius: .55rem; font-weight: 600; font-size: .875rem; }
.btn-danger { background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark)); border: none; box-shadow: 0 3px 8px rgba(211,47,30,.3); }
.btn-danger:hover { background: linear-gradient(135deg, #e0392a, var(--brand-red-dark)); box-shadow: 0 4px 12px rgba(211,47,30,.4); }
.btn-outline-secondary, .btn-outline-danger, .btn-outline-primary, .btn-outline-success, .btn-outline-dark { border-width: 1.4px; }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border-bottom: 1px solid var(--border); background: #fbfbfc; font-weight: 700; padding: .85rem 1rem;
}
.table td { padding: .75rem 1rem; vertical-align: middle; border-color: var(--border); }
.table tbody tr:hover { background: #fafbfc; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .82rem; color: #444; }
.form-control, .form-select { border-radius: .5rem; border-color: #dcdde1; }
.form-control:focus, .form-select:focus { border-color: var(--brand-red); box-shadow: 0 0 0 .2rem rgba(211,47,30,.12); }

/* ---------- Modal sections ---------- */
.section-block { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.section-block:last-of-type { border-bottom: none; }
.section-heading {
  font-weight: 700; color: var(--brand-red-dark); font-size: .85rem; text-transform: uppercase;
  letter-spacing: .03em; display: flex; align-items: center; gap: .45rem; margin-bottom: .75rem;
}
.modal-content { border-radius: 1rem; border: none; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }

/* ---------- Vehiculo card ---------- */
.vehiculo-foto { width: 100%; height: 150px; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; background: #e9e9e9; }

/* ---------- Buscador de vehiculo ---------- */
.vehiculo-dropdown {
  display: none; position: absolute; z-index: 40; left: 0; right: 0; top: 100%; margin-top: 4px;
  background: #fff; border: 1px solid var(--border); border-radius: .6rem; box-shadow: var(--shadow-lg);
  max-height: 280px; overflow-y: auto;
}
.vehiculo-dropdown.show { display: block; }
.vehiculo-dropdown-item {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; cursor: pointer; font-size: .85rem;
}
.vehiculo-dropdown-item:hover { background: #fbeceb; }
.vehiculo-dropdown-item img {
  width: 42px; height: 32px; object-fit: cover; border-radius: .3rem; background: #eee; flex-shrink: 0;
}
.vehiculo-dropdown-empty { padding: .75rem; color: var(--muted); font-size: .85rem; text-align: center; }

/* ---------- Diagrama de danos ---------- */
.cd-layout { display:flex; flex-direction:column; gap:12px; }
.cd-row-full { display:grid; }
.cd-row-three { display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px; }
.cd-cell { border:1px solid var(--border); border-radius:.6rem; padding:.6rem; background:#fafbfc; }
.cd-label { font-size:.7rem; font-weight:700; color:#777; text-transform:uppercase; letter-spacing:.03em; margin-bottom:.4rem; text-align:left; }
.cd-imgwrap { position:relative; width:100%; height:0; overflow:hidden; border-radius:.4rem; background:#fff; }
.cd-baseimg { position:absolute; left:0; top:0; width:100%; height:100%; object-fit:contain; user-select:none; pointer-events:none; }
.cd-interactive { cursor: crosshair; transition: outline .1s; outline: 2px solid transparent; outline-offset: 2px; }
.cd-interactive:hover { outline-color: var(--brand-red); }
.cd-mark {
  position:absolute; width:18px; height:18px; margin-left:-9px; margin-top:-9px; border-radius:50%;
  color:#fff; font-size:.68rem; font-weight:700; text-align:center; line-height:18px;
  box-shadow:0 0 0 2px #fff, 0 1px 3px rgba(0,0,0,.4); cursor:help;
}
.cd-toolbar { display:flex; gap:.5rem; margin-bottom:.5rem; }
.cd-legend { display:flex; gap:1rem; font-size:.78rem; margin-top:.5rem; color:#555; }
.cd-legend span { display:inline-flex; align-items:center; gap:.3rem; }
.cd-legend i { width:10px; height:10px; border-radius:50%; display:inline-block; }

.cd-notes-panel { font-size:.82rem; margin-top:.5rem; }
.cd-notes-list { margin:0; padding-left:1.15rem; }
.cd-notes-list li { margin-bottom:.3rem; }
.cd-notes-title { font-weight:700; font-size:.78rem; margin-bottom:.3rem; }

.cd-note-popup {
  position:fixed; z-index:3000; background:#fff; border:1px solid var(--border); border-radius:.6rem;
  box-shadow:var(--shadow-lg); padding:.65rem; width:230px;
}
.cd-note-popup-label { font-size:.72rem; font-weight:700; color:#666; margin-bottom:.35rem; text-transform:uppercase; letter-spacing:.02em; }
.cd-note-popup input { margin-bottom:.5rem; }
.cd-note-popup-actions { display:flex; justify-content:flex-end; gap:.4rem; }

/* ---------- Nav tabs ---------- */
.nav-tabs { border-bottom: 1px solid var(--border); gap: .25rem; }
.nav-tabs .nav-link {
  border: none; color: var(--muted); font-weight: 600; font-size: .87rem; padding: .6rem 1rem;
  border-radius: .5rem .5rem 0 0; margin-bottom: -1px;
}
.nav-tabs .nav-link:hover { color: var(--brand-red-dark); background: #fbeceb; border-color: transparent; }
.nav-tabs .nav-link.active {
  color: var(--brand-red-dark); background: #fff; border: 1px solid var(--border); border-bottom-color: #fff;
}

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.2rem; opacity: .35; display: block; margin-bottom: .5rem; }

/* ---------- Misc ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d3d5da; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 991px) {
  .sidebar { position: fixed; left: -240px; z-index: 1050; transition: left .2s; }
  .sidebar.open { left: 0; }
  .content { padding: 1.25rem; }
}

/* ---------- Portal publico ---------- */
.portal-body { background: var(--bg); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.portal-header { background: linear-gradient(180deg, var(--brand-dark) 0%, #0e0f10 100%); padding: 1rem 1.5rem; }
.portal-header-inner { max-width: 1100px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.portal-brand { color: #fff; font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.portal-brand i { color: var(--brand-red); font-size: 1.4rem; }
.portal-brand small { color: #9a9da3; font-weight: 500; margin-left: .25rem; }
.portal-brand-logo { max-height: 40px; max-width: 200px; object-fit: contain; }
.portal-hero { background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark)); color: #fff; text-align: center; padding: 2.5rem 1.5rem; }
.portal-hero h1 { font-weight: 800; margin-bottom: .5rem; }
.portal-hero p { opacity: .9; margin: 0; }
.portal-content { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.portal-footer { text-align: center; padding: 1.5rem; color: var(--muted); font-size: .85rem; }
.portal-card { overflow: hidden; }
.portal-foto { width: 100%; height: 190px; object-fit: cover; background: #e9e9e9; }
.portal-foto-count {
  position: absolute; bottom: .5rem; right: .5rem; background: rgba(0,0,0,.65); color: #fff;
  font-size: .75rem; padding: .2rem .55rem; border-radius: 1rem;
}
.portal-resumen { background: #fbfbfc; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.portal-resumen .section-heading { margin-bottom: .6rem; }

.portal-galeria-main {
  position: relative; cursor: pointer; border-radius: .6rem; overflow: hidden; background: #e9e9e9;
}
.portal-galeria-main img { width: 100%; height: 230px; object-fit: cover; display: block; transition: transform .2s; }
.portal-galeria-main:hover img { transform: scale(1.02); }
.portal-galeria-main .portal-galeria-count {
  position: absolute; bottom: .5rem; right: .5rem; background: rgba(0,0,0,.65); color: #fff;
  font-size: .75rem; padding: .2rem .55rem; border-radius: 1rem; display: flex; align-items: center; gap: .3rem;
}
.portal-galeria-strip {
  display: flex; gap: .5rem; overflow-x: auto; padding: .6rem 0 .2rem; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.portal-galeria-strip::-webkit-scrollbar { height: 6px; }
.portal-galeria-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.portal-galeria-thumb {
  flex: 0 0 auto; width: 76px; height: 56px; border-radius: .45rem; overflow: hidden; cursor: pointer;
  scroll-snap-align: start; border: 2px solid transparent; transition: border-color .15s;
}
.portal-galeria-thumb:hover, .portal-galeria-thumb.active { border-color: var(--brand-red); }
.portal-galeria-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
#fotoModal .modal-content { background: #111; }
#fotoModal .carousel-item img { max-height: 82vh; width: 100%; object-fit: contain; }
#fotoModal .btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: .9; }

/* ---------- Portal publico: sitio principal completo ---------- */
.portal-header { position: sticky; top: 0; z-index: 100; }
.portal-nav { display: flex; align-items: center; gap: 1.5rem; }
.portal-nav a { color: #cfd1d4; text-decoration: none; font-weight: 600; font-size: .88rem; transition: color .15s; }
.portal-nav a:hover { color: #fff; }
.portal-nav-call { display: flex; align-items: center; gap: .4rem; color: #fff !important; background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark)); padding: .45rem .9rem; border-radius: .5rem; }
.portal-nav-call:hover { color: #fff !important; opacity: .92; }
.portal-nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.4rem; }

.portal-hero-full {
  position: relative; min-height: 78vh; display: flex; align-items: center; overflow: hidden;
  background: linear-gradient(135deg, rgba(23,24,26,.86), rgba(163,32,15,.78)), url('https://images.unsplash.com/photo-1502877338535-766e1452684a?auto=format&fit=crop&w=1600&q=70') center/cover no-repeat;
}
.portal-hero-full-inner { max-width: 1100px; margin: 0 auto; padding: 3rem 1.5rem; color: #fff; width: 100%; }
.portal-hero-full h1 { font-weight: 800; font-size: clamp(1.8rem, 4vw, 3rem); margin-bottom: .9rem; letter-spacing: -.02em; }
.portal-hero-full p.lead { opacity: .92; font-size: 1.1rem; max-width: 560px; margin-bottom: 1.6rem; }
.portal-hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: 2.2rem; }
.portal-hero-cta .btn { padding: .7rem 1.4rem; font-size: .95rem; }
.portal-hero-stats { display: flex; gap: 2.2rem; flex-wrap: wrap; }
.portal-hero-stats div { display: flex; flex-direction: column; }
.portal-hero-stats strong { font-size: 1.6rem; font-weight: 800; }
.portal-hero-stats span { font-size: .78rem; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }

.portal-section { max-width: 1100px; margin: 0 auto; padding: 3.5rem 1.5rem; }
.portal-section-head { text-align: center; margin-bottom: 2.2rem; }
.portal-section-head .eyebrow { color: var(--brand-red); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.portal-section-head h2 { font-weight: 800; letter-spacing: -.01em; margin: .3rem 0 .5rem; }
.portal-section-head p { color: var(--muted); max-width: 560px; margin: 0 auto; }
.portal-section-alt { background: #fff; }

.portal-why-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; }
.portal-why-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.portal-why-card i { font-size: 1.6rem; color: #fff; background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark)); width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; box-shadow: 0 4px 10px rgba(211,47,30,.3); }
.portal-why-card h5 { font-weight: 700; font-size: 1rem; margin-bottom: .4rem; }
.portal-why-card p { color: var(--muted); font-size: .88rem; margin: 0; }

.portal-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; }
.portal-step { text-align: center; position: relative; }
.portal-step .num {
  width: 46px; height: 46px; border-radius: 50%; background: var(--brand-dark); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; margin: 0 auto .9rem; font-size: 1.1rem;
}
.portal-step h5 { font-weight: 700; font-size: .95rem; margin-bottom: .35rem; }
.portal-step p { color: var(--muted); font-size: .85rem; margin: 0; }

.portal-cta-band {
  background: linear-gradient(135deg, var(--brand-dark), #0e0f10); color: #fff; text-align: center; padding: 3rem 1.5rem;
}
.portal-cta-band h3 { font-weight: 800; margin-bottom: .5rem; }
.portal-cta-band p { opacity: .85; margin-bottom: 1.4rem; }

.portal-contact-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; }
.portal-contact-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; text-align: center; box-shadow: var(--shadow-sm); }
.portal-contact-card i { font-size: 1.4rem; color: var(--brand-red); margin-bottom: .6rem; display: block; }
.portal-contact-card .label { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: .3rem; }
.portal-contact-card a, .portal-contact-card .value { color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem; }
.portal-contact-card a:hover { color: var(--brand-red); }

.portal-footer-full { background: var(--brand-dark); color: #b9bcc1; padding: 2.5rem 1.5rem 1.2rem; }
.portal-footer-inner { max-width: 1100px; margin: 0 auto; display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.portal-footer-inner .portal-brand { margin-bottom: .6rem; }
.portal-footer-col h6 { color: #fff; font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .8rem; }
.portal-footer-col a { color: #b9bcc1; text-decoration: none; display: block; margin-bottom: .5rem; font-size: .87rem; }
.portal-footer-col a:hover { color: #fff; }
.portal-footer-bottom { text-align: center; padding-top: 1.5rem; margin-top: 1.5rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .8rem; color: #8a8d93; }

@media (max-width: 767px) {
  .portal-why-grid, .portal-steps, .portal-contact-grid { grid-template-columns: 1fr; }
  .portal-nav { position: fixed; inset: 56px 0 auto 0; background: var(--brand-dark); flex-direction: column; align-items: flex-start; padding: 1rem 1.5rem; gap: .9rem; display: none; box-shadow: var(--shadow-lg); }
  .portal-nav.open { display: flex; }
  .portal-nav-toggle { display: block; }
  .portal-hero-full { min-height: 60vh; text-align: center; }
  .portal-hero-cta, .portal-hero-stats { justify-content: center; }
}
