:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface-2: #252525;
  --border: #2c2c2e;
  --accent: #00e5ff;
  --accent-soft: rgba(0, 229, 255, 0.12);
  --success: #32d74b;
  --danger: #ff453a;
  --danger-bg: #3a1c1c;
  --text: #ffffff;
  --muted: #98989d;
  --radius: 16px;
  --space: 8px;
  --sidebar-w: 260px;
  --font: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

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

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

.sidebar {
  width: var(--sidebar-w);
  background: #161616;
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 0 8px;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #0088aa);
  display: grid; place-items: center;
  font-weight: 700; color: #001418;
}
.brand-name { font-weight: 600; font-size: 18px; }
.brand-sub { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 18, 18, 0.9);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--muted);
}
.search input {
  border: 0; outline: 0; background: transparent;
  color: var(--text); width: 100%; font: inherit;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700;
}
.user-meta { text-align: right; }
.user-meta strong { display: block; font-size: 13px; }
.user-meta span { color: var(--muted); font-size: 12px; }

.content { padding: 24px; }

.page-header {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.page-header p { margin: 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
/* Solo apilar margen en cards consecutivas fuera de grillas */
.content > .card + .card,
.stack > .card + .card {
  margin-top: 16px;
}
.card-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
.grid-equal { grid-template-columns: 1fr 1fr; }
.grid-12 { grid-template-columns: repeat(12, 1fr); }

.kpi-grid {
  align-items: stretch;
  margin-bottom: 16px;
}
.kpi-grid > .card {
  margin-top: 0 !important;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 140px;
}
.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
}
.kpi-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}
.kpi-top .badge {
  max-width: 58%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}
.kpi-label {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}
.kpi-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: auto;
  line-height: 1.1;
  min-height: 32px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.chart-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chart-filters select {
  width: auto;
  min-width: 110px;
  padding: 8px 12px;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge-success { background: rgba(50, 215, 75, 0.15); color: var(--success); }
.badge-danger { background: rgba(255, 69, 58, 0.15); color: var(--danger); }
.badge-info { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse;
}
table.data th, table.data td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
table.data tbody tr:hover { background: var(--surface-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  font: inherit; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn-primary { background: var(--accent); color: #001418; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"], select, textarea {
  width: 100%;
  background: #181818;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 11px 14px;
  font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(0, 229, 255, 0.35);
  border-color: var(--accent);
}

.alert {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}
.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-left: 4px solid var(--danger);
}
.alert-success {
  background: rgba(50, 215, 75, 0.12);
  color: var(--success);
  border-left: 4px solid var(--success);
}

. progressive {
  height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
}
.progress > span {
  display: block; height: 100%; background: var(--accent); border-radius: inherit;
}
.stack-row {
  display: grid; grid-template-columns: 1fr 2fr auto;
  gap: 12px; align-items: center;
  margin-bottom: 12px;
}
.stack-row span:last-child { font-family: var(--mono); color: var(--muted); }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(0, 229, 255, 0.08), transparent 50%),
    var(--bg);
}
.auth-card { width: min(420px, 100%); }
.auth-card h1 { margin: 0 0 8px; font-size: 24px; }
.auth-card p { margin: 0 0 24px; color: var(--muted); }

.menu-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 40px; height: 40px;
  cursor: pointer;
}

.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 30;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 16px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.modal-card h3 { margin: 0 0 8px; font-size: 18px; }

.muted { color: var(--muted); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.text-right { text-align: right; }

/* ——— Calendario agenda ——— */
.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.cal-main { overflow: hidden; }
.cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.cal-views, .cal-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-label { font-size: 15px; min-width: 140px; text-align: center; }
.cal-hint { margin: 12px 0 0; font-size: 12px; }
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}
.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cal-legend-item i {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.cal-time-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.cal-time-grid {
  display: grid;
  grid-template-columns: 56px repeat(var(--cal-cols), minmax(120px, 1fr));
  min-width: max(100%, calc(56px + var(--cal-cols) * 140px));
}
.cal-time-gutter { background: var(--surface); border-right: 1px solid var(--border); }
.cal-time-corner { height: 44px; border-bottom: 1px solid var(--border); }
.cal-hour-label {
  height: var(--cal-hour);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 6px 0 0;
  text-align: right;
  border-bottom: 1px solid transparent;
  box-shadow: inset 0 -1px 0 var(--border);
}
.cal-day-col { border-right: 1px solid var(--border); min-width: 0; }
.cal-day-col:last-child { border-right: 0; }
.cal-day-col.is-today .cal-day-head { color: var(--accent); }
.cal-day-head {
  height: 44px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
  font-size: 13px;
}
.cal-day-head a { color: inherit; text-decoration: none; }
.cal-day-head a:hover { color: var(--accent); }
.cal-day-body { position: relative; background: repeating-linear-gradient(
  to bottom,
  transparent 0,
  transparent calc(var(--cal-hour) - 1px),
  var(--border) calc(var(--cal-hour) - 1px),
  var(--border) var(--cal-hour)
); }
.cal-slot {
  position: absolute;
  left: 0; right: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 1;
  padding: 0;
}
.cal-slot:hover { background: var(--accent-soft); }

.cal-event {
  position: absolute;
  z-index: 2;
  border-radius: 8px;
  padding: 4px 8px 4px 8px;
  overflow: hidden;
  border: 1px solid transparent;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
  font-size: 11px;
  line-height: 1.25;
}
.cal-event-time { font-family: var(--mono); opacity: .85; font-size: 10px; }
.cal-event-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event-meta { color: inherit; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event-del {
  position: absolute;
  top: 2px; right: 2px;
  margin: 0;
}
.cal-event-del button {
  border: 0;
  background: rgba(0,0,0,.25);
  color: #fff;
  width: 18px; height: 18px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  font-size: 14px;
  padding: 0;
  opacity: 0;
}
.cal-event:hover .cal-event-del button { opacity: 1; }

.cal-ev--plan { background: rgba(0, 229, 255, 0.22); border-color: rgba(0, 229, 255, 0.45); color: #b8f7ff; }
.cal-ev--ok { background: rgba(50, 215, 75, 0.22); border-color: rgba(50, 215, 75, 0.45); color: #b8f7c4; }
.cal-ev--done { background: rgba(152, 152, 157, 0.2); border-color: rgba(152, 152, 157, 0.4); color: #d0d0d4; }
.cal-ev--cancel { background: rgba(255, 69, 58, 0.2); border-color: rgba(255, 69, 58, 0.4); color: #ffb4af; }

.cal-month-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  font-weight: 600;
}
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-month-cell {
  min-height: 96px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-month-cell.is-out { opacity: .4; }
.cal-month-cell.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-month-day {
  font-weight: 700;
  font-size: 13px;
  color: inherit;
  text-decoration: none;
  align-self: flex-start;
}
.cal-month-day:hover { color: var(--accent); }
.cal-month-events { display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.cal-chip {
  font-size: 10px;
  border-radius: 6px;
  padding: 2px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 0;
  text-align: left;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
}
.cal-chip span { font-family: var(--mono); }
.cal-more { font-size: 10px; color: var(--muted); text-decoration: none; }
.cal-more:hover { color: var(--accent); }

.cal-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.cal-form-head .card-title { margin: 0; }
.cal-side .cal-form { grid-template-columns: 1fr; }
.cal-upcoming {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.cal-upcoming:hover { background: var(--surface-2); }
.cal-upcoming:last-child { border-bottom: 0; }
.cal-event { cursor: pointer; }

/* ——— Recepción vehículo OT ——— */
.recep-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.recep-map-card {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.recep-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.recep-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid transparent;
}
.recep-legend .dot.ok { background: rgba(50, 215, 75, 0.85); border-color: #32d74b; }
.recep-legend .dot.issue { background: rgba(255, 69, 58, 0.85); border-color: #ff453a; }
.recep-legend .dot.idle { background: transparent; border-color: #98989d; }

.recep-views {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}
.recep-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #161616;
  color: #c8c8cc;
  cursor: pointer;
  font: inherit;
  width: 100%;
  min-height: 128px;
  box-sizing: border-box;
  transition: border-color .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
}
.recep-view:hover {
  border-color: var(--accent);
  color: var(--text);
}
.recep-view-img {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
}
.recep-view-img img {
  width: 100%;
  height: auto;
  max-height: 92px;
  object-fit: contain;
  display: block;
}
.recep-view[data-zona="techo"] .recep-view-img {
  min-height: 100px;
}
.recep-view[data-zona="techo"] .recep-view-img img {
  max-height: 108px;
  max-width: 72px;
  width: auto;
  height: auto;
}
.recep-view[data-zona="costado_izq"] .recep-view-img img,
.recep-view[data-zona="costado_der"] .recep-view-img img {
  max-height: 72px;
  max-width: 100%;
  width: auto;
}
.recep-view-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}
.recep-view.is-idle {
  border-color: #3a3a3c;
  color: #98989d;
}
.recep-view.is-ok {
  border-color: rgba(50, 215, 75, 0.75);
  background: rgba(50, 215, 75, 0.1);
  color: #b8f7c4;
}
.recep-view.has-issue {
  border-color: rgba(255, 69, 58, 0.85);
  background: rgba(255, 69, 58, 0.12);
  color: #ffb4af;
}
.recep-view.is-active {
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.55);
}
.recep-view.is-active.is-idle {
  border-color: var(--accent);
  color: var(--text);
}

.recep-panels { min-width: 0; }
.recep-panel[hidden] { display: none !important; }

.recep-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.recep-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.recep-thumb {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  aspect-ratio: 1;
}
.recep-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.recep-thumb form {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
}
.recep-thumb .btn {
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 1;
}

@media (min-width: 961px) {
  .recep-views {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .recep-view {
    grid-column: auto;
    min-height: 140px;
  }
  .recep-view[data-zona="frente"] { order: 1; }
  .recep-view[data-zona="trasera"] { order: 2; }
  .recep-view[data-zona="techo"] { order: 3; }
  .recep-view[data-zona="costado_izq"] { order: 4; }
  .recep-view[data-zona="costado_der"] { order: 5; }
}

@media (max-width: 960px) {
  .recep-layout { grid-template-columns: 1fr; }
  .recep-map-card {
    position: static;
    max-height: none;
  }
  .recep-views {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .recep-view {
    grid-column: auto;
    min-height: 120px;
    order: 0;
  }
  .recep-view[data-zona="frente"] { order: 1; }
  .recep-view[data-zona="trasera"] { order: 2; }
  .recep-view[data-zona="costado_izq"] { order: 3; }
  .recep-view[data-zona="costado_der"] { order: 4; }
  .recep-view[data-zona="techo"] {
    order: 5;
    grid-column: 1 / -1;
    max-width: 160px;
    width: 100%;
    justify-self: center;
  }
}

@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-equal { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-105%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: grid; place-items: center; }
  .overlay.show { display: block; }
  .user-meta { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .chart-head { align-items: flex-start; }
  .chart-filters { width: 100%; }
  .chart-filters select { flex: 1; min-width: 0; }
}
