:root {
  --bg: #0a0e17;
  --panel: #111827;
  --panel-soft: #1a2234;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #10b981;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #f85149;
  --border: rgba(255, 255, 255, 0.08);
  --field-bg: #0f1625;
  --field-text: #e5e7eb;
  --field-placeholder: #7c8797;
  --code-bg: #0f1625;
  --brand-900: #0a0e17;
  --brand-800: #111827;
  --brand-700: #1a2234;
  --sidebar-bg: #0f172a;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: #9ca3af;
  --sidebar-item-bg: rgba(255, 255, 255, 0.08);
  --sidebar-item-hover: rgba(255, 255, 255, 0.14);
  --sidebar-item-active: #10b981;
}

body.theme-light {
  --bg: #f7faf9;
  --panel: #ffffff;
  --panel-soft: #ecfdf5;
  --text: #0f172a;
  --muted: #475569;
  --primary: #10b981;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --border: #d1d5db;
  --field-bg: #ffffff;
  --field-text: #0f172a;
  --field-placeholder: #64748b;
  --code-bg: #f0fdf4;
  --brand-900: #d1fae5;
  --brand-800: #a7f3d0;
  --brand-700: #6ee7b7;
  --sidebar-bg: #ecfdf5;
  --sidebar-text: #064e3b;
  --sidebar-muted: #047857;
  --sidebar-item-bg: #d1fae5;
  --sidebar-item-hover: #a7f3d0;
  --sidebar-item-active: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.center-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
}

.title {
  margin: 0 0 14px;
  font-size: 22px;
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d4ed8, #60a5fa);
  color: #fff;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
}

.muted {
  color: var(--muted);
  margin: 0 0 18px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select,
button {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  color: var(--field-text);
  padding: 10px 12px;
}

input::placeholder {
  color: var(--field-placeholder);
}

input,
select {
  margin-bottom: 12px;
}

.password-wrap {
  position: relative;
  margin-bottom: 12px;
}

.password-wrap input {
  margin-bottom: 0;
  padding-right: 44px;
}

.toggle-pass {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.date-wrap {
  position: relative;
  margin-bottom: 12px;
}

.date-wrap input[type='text'] {
  margin-bottom: 0;
  padding-right: 44px;
}

.native-date-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  margin: 0;
  padding: 0;
  border: 0;
}

.date-popover {
  position: fixed;
  z-index: 2000;
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.date-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.date-head strong {
  font-size: 13px;
  text-transform: capitalize;
}

.date-week,
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.date-week span {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.date-empty {
  display: block;
  height: 28px;
}

.date-day {
  width: 100%;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  padding: 0;
}

.date-day:hover {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
}

.date-day.is-selected {
  background: var(--primary);
  color: #fff;
}

button {
  background: var(--primary);
  border: none;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

.login-intro-restricted {
  margin-bottom: 4px;
}

.error-access-denied {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  line-height: 1.45;
}

.error-access-denied strong {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
}

.error-access-detail {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.ok-text {
  margin-top: 12px;
  color: #7ee787;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--sidebar-bg), color-mix(in srgb, var(--sidebar-bg) 70%, #ffffff));
  padding: 16px;
  color: var(--sidebar-text);
}

.brand {
  font-size: 20px;
  margin: 0 0 4px;
  color: var(--sidebar-text);
}

.user {
  color: var(--sidebar-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu button {
  text-align: left;
  background: var(--sidebar-item-bg);
  color: var(--sidebar-text);
  border: 1px solid color-mix(in srgb, var(--sidebar-text) 14%, transparent);
}

.menu button.active {
  background: var(--sidebar-item-active);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.menu button:hover {
  background: var(--sidebar-item-hover);
}

body.theme-light .sidebar {
  border-right: 1px solid #a7f3d0;
}

.main {
  padding: 18px;
  /* Columna 1fr de .layout: sin esto crece con la tabla más ancha y la página se desborda en
     celulares; con esto las tablas hacen scroll dentro de su tarjeta. */
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.topbar h2 {
  margin: 0;
}

.topbar .actions {
  display: flex;
  gap: 10px;
}

.topbar .actions button {
  width: auto;
  padding: 8px 12px;
  border-radius: 10px;
}

.ghost {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.btn-xs {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.metric .k {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric .v {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
}

.metric::after {
  content: '';
  position: absolute;
  right: -24px;
  top: -24px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  pointer-events: none;
}

.block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.block h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

form .form-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px 12px;
  margin: 0 0 12px;
}

form .form-section legend {
  padding: 0 6px;
  font-weight: 600;
  font-size: 14px;
}

.b2b-master-subtitle {
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.modal-eq-form .modal-eq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 14px;
  margin-bottom: 12px;
}

.modal-eq-form .modal-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--muted, #9aa4b2);
}

.modal-eq-form .modal-field input,
.modal-eq-form .modal-field select {
  width: 100%;
  box-sizing: border-box;
}

.modal-eq-form .modal-field-hint {
  margin: 4px 0 0;
  font-size: 11px;
}

.modal-eq-form .obra-pt-new-row {
  text-align: right;
  margin-bottom: 8px;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.role-badge-adm {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.role-badge-jef {
  background: rgba(34, 211, 238, 0.15);
  color: #67e8f9;
}

.role-badge-op {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
}

.fuel-rep-shell .fuel-rep-kpis {
  margin: 12px 0 8px;
}

.fuel-rep-toolbar {
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.fuel-rep-toolbar input[type='date'] {
  min-width: 140px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 180px;
  margin: 0;
}

.toolbar button {
  width: auto;
  padding: 8px 12px;
}

pre {
  white-space: pre-wrap;
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  max-height: 460px;
  overflow: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal {
  width: min(760px, 92vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
}

.rv-detalle-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.rv-detalle-seccion {
  margin-bottom: 14px;
}

.rv-detalle-seccion h4 {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--muted, #999);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.rv-detalle-item {
  padding: 8px 10px;
  background: var(--bg, #0a0e17);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.88rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-soft);
  color: var(--text);
}

/* Equipos monitoreados: encabezados en dos líneas para no ensanchar la tabla */
th.bo-eq-th-stack {
  white-space: normal;
  line-height: 1.25;
  max-width: 6.75rem;
  vertical-align: bottom;
  font-weight: 600;
}

th.bo-eq-th-stack .muted {
  display: inline-block;
  font-weight: 500;
  font-size: 11px;
  margin-top: 2px;
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.ok {
  background: color-mix(in srgb, var(--ok) 30%, transparent);
}

.warn {
  background: color-mix(in srgb, var(--warn) 28%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent);
}

.danger {
  background: color-mix(in srgb, var(--danger) 28%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
}

.ok {
  border: 1px solid color-mix(in srgb, var(--ok) 55%, transparent);
}

.table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.b2b-master {
  background: color-mix(in srgb, var(--panel) 90%, #000 10%);
}

.b2b-master-shell {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-900) 62%, transparent), color-mix(in srgb, var(--panel) 96%, #000 4%));
  padding: 12px;
}

.b2b-master-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.b2b-master-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.b2b-master-user {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
}

.b2b-master-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.b2b-master-toolbar input,
.b2b-master-toolbar select {
  width: auto;
  min-width: 210px;
  margin: 0;
}

.b2b-master-toolbar button {
  width: auto;
  min-width: 120px;
  padding: 8px 14px;
  border-radius: 10px;
}

.b2b-master-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.b2b-page-top {
  display: flex;
  /* En el teléfono el botón "+ Nueva empresa" baja a su propia fila en vez de salirse. */
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 4px 4px 0;
}
.b2b-page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.b2b-btn-new {
  flex-shrink: 0;
  border: none;
  background: var(--primary);
  color: #04120c;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.b2b-btn-new:hover {
  filter: brightness(1.08);
}
body.theme-light .b2b-btn-new {
  color: #fff;
}
.b2b-toolbar-filters {
  align-items: center;
}
.b2b-co-block {
  padding: 0;
  overflow: hidden;
}
.b2b-co-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.b2b-co-table th {
  text-align: left;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}
.b2b-co-table td {
  padding: 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.b2b-co-name {
  font-weight: 600;
}
.b2b-co-rut {
  font-size: 0.8rem;
  margin-top: 4px;
}
.b2b-th-fleet,
.b2b-td-fleet {
  background: color-mix(in srgb, var(--panel-soft) 55%, transparent);
}
.b2b-fleet-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.b2b-td-mrr {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.b2b-plan-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
}
.b2b-plan-pill--none {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}
.b2b-plan-pill--pro {
  background: color-mix(in srgb, #38bdf8 22%, transparent);
  border-color: color-mix(in srgb, #38bdf8 45%, transparent);
  color: #7dd3fc;
}
.b2b-plan-pill--basic {
  background: color-mix(in srgb, #6366f1 22%, transparent);
  border-color: color-mix(in srgb, #6366f1 45%, transparent);
  color: #a5b4fc;
}
.b2b-plan-pill--default {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
  color: var(--primary);
}
.b2b-pay-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.b2b-pay--ok {
  background: rgba(34, 197, 94, 0.2);
  color: var(--ok);
}
.b2b-pay--danger {
  background: rgba(248, 81, 73, 0.2);
  color: var(--danger);
}
.b2b-pay--warn {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warn);
}
.b2b-pay--none {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
.b2b-footer-links {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.linklike {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
}

/* —— Planes & suscripciones —— */
.sub-shell {
  max-width: 1280px;
  margin: 0 auto;
}
.sub-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.sub-page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}
.sub-kpis {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.sub-metric .v {
  font-size: 1.25rem;
  font-weight: 700;
}
.sub-section {
  margin-bottom: 26px;
}
.sub-section-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 600;
}
.sub-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.sub-plan-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}
.sub-plan-card--popular {
  border-color: color-mix(in srgb, #38bdf8 55%, var(--border));
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.25);
}
.sub-plan-popular {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, #38bdf8 35%, transparent);
  color: #7dd3fc;
}
.sub-plan-card--custom {
  border-style: dashed;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  min-height: 200px;
  background: transparent;
}
.sub-plan-name {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
}
.sub-plan-price {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
}
.sub-plan-price-suf {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 4px;
}
.sub-plan-limits {
  margin: 14px 0 10px;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}
.sub-plan-lim-n {
  color: var(--text);
  font-weight: 700;
}
.sub-plan-count {
  margin: 0 0 14px;
  font-size: 0.82rem;
}
.sub-plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}
.sub-plan-custom-hint {
  margin: 0 0 14px;
  font-size: 0.88rem;
  line-height: 1.4;
}
.sub-plan-custom-btn {
  border: 1px dashed var(--border);
  background: color-mix(in srgb, var(--panel-soft) 80%, transparent);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.sub-plan-custom-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.sub-plan-empty {
  grid-column: 1 / -1;
  margin: 0;
}
.sub-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.sub-table-head .sub-section-title {
  margin-bottom: 0;
}
.sub-table-wrap {
  padding: 0;
  overflow: hidden;
}
.sub-co-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.sub-co-table th {
  text-align: left;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}
.sub-co-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.sub-td-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
body.theme-light .sub-plan-card--popular {
  box-shadow: 0 0 0 1px rgba(2, 132, 199, 0.35);
}

.plan-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary) 24%, transparent);
}

.plan-badge-premium {
  border-color: color-mix(in srgb, #93c5fd 70%, transparent);
  background: color-mix(in srgb, #93c5fd 28%, transparent);
}

.state-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.state-badge-ok {
  color: #d1fae5;
  background: color-mix(in srgb, var(--ok) 34%, transparent);
  border-color: color-mix(in srgb, var(--ok) 60%, transparent);
}

.state-badge-danger {
  color: #fecaca;
  background: color-mix(in srgb, var(--danger) 28%, transparent);
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
}

.state-badge-warn {
  color: #fef3c7;
  background: color-mix(in srgb, var(--warn) 34%, transparent);
  border-color: color-mix(in srgb, var(--warn) 60%, transparent);
}

.b2b-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.b2b-actions .btn-xs {
  border-radius: 999px;
}

.kpi-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 30%, transparent);
  font-size: 11px;
}

.global-config-hero {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-900) 55%, transparent), transparent 35%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.global-config-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.global-config-toolbar input {
  margin: 0;
  min-width: 320px;
  height: 38px;
}

.global-config-toolbar button {
  width: auto;
  white-space: nowrap;
}

.global-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.gc-card {
  background: color-mix(in srgb, var(--panel) 86%, var(--brand-900) 14%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.gc-card h3 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.gc-card p {
  margin: 10px 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 20px;
}

.gc-card p strong {
  color: var(--text);
  margin-right: 6px;
}

.gc-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  color: #dbeafe;
  background: color-mix(in srgb, var(--primary) 45%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 70%, transparent);
}

.gc-chip-ok {
  color: #d1fae5;
  background: color-mix(in srgb, var(--ok) 42%, transparent);
  border-color: color-mix(in srgb, var(--ok) 70%, transparent);
}

.gc-chip-warn {
  color: #fef3c7;
  background: color-mix(in srgb, var(--warn) 42%, transparent);
  border-color: color-mix(in srgb, var(--warn) 70%, transparent);
}

body.theme-light .global-config-hero {
  background: linear-gradient(180deg, #dbeafe, #f7fbff 45%);
}

body.theme-light .gc-card {
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

body.theme-light .gc-card h3 {
  color: #142850;
}

body.theme-light .gc-card p {
  color: #334155;
}

body.theme-light .gc-chip {
  color: #1e3a8a;
  background: #dbeafe;
  border-color: #bfdbfe;
}

body.theme-light .gc-chip-ok {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

body.theme-light .gc-chip-warn {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}

/* Panel super admin — configuración global */
.global-config-super {
  padding: 16px;
}

.global-config-top {
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.gc-head-text {
  flex: 1;
  min-width: 220px;
}

.gc-page-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.gc-page-date {
  margin-top: 6px;
  font-size: 0.9rem;
  text-transform: capitalize;
}

.gc-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.gc-toolbar-actions input[type='search'] {
  margin: 0;
  min-width: 200px;
  height: 38px;
  border-radius: 10px;
}

.gc-profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  font-size: 0.85rem;
}

.gc-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}

.btn-gc-save {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  height: 38px;
  font-weight: 600;
  cursor: pointer;
}

.btn-gc-save:hover {
  filter: brightness(1.08);
}

.btn-gc-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.gc-super-grid {
  /* auto-fit en vez de 2 columnas fijas: a 1280px da 3, a 1920px da 4, a 900px una sola.
     Antes se quedaba en 2 incluso en 4K, y el contenido se apilaba hacia abajo. */
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
}

/* Las cards con tabla ocupan la fila completa: su ancho no debe depender de cuantas
   columnas tenga la grilla, o la tabla scrollea al ganar columnas. */
.gc-card--wide {
  grid-column: 1 / -1;
}

.gc-card .gc-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 14px;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--text);
}

.gc-metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.gc-metric {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.gc-metric-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gc-metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 4px;
}

.gc-spark {
  height: 28px;
  margin-top: 8px;
  border-radius: 4px;
  opacity: 0.85;
}

.gc-spark-blue {
  background: linear-gradient(90deg, transparent, #3b82f6 40%, #60a5fa 100%);
}

.gc-spark-mix {
  background: linear-gradient(90deg, transparent, #f97316 35%, #3b82f6 100%);
}

.gc-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gc-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.gc-toggle-row-pad {
  margin-top: 8px;
}

.gc-toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.88rem;
  line-height: 1.3;
}

.gc-toggle-sub {
  display: block;
  font-weight: 400;
  font-size: 0.78rem;
}

.gc-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.gc-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.gc-toggle-ui {
  position: absolute;
  inset: 0;
  background: #374151;
  border-radius: 999px;
  pointer-events: none;
  transition: background 0.2s;
}

.gc-toggle-ui::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.gc-toggle input:checked + .gc-toggle-ui {
  background: #2563eb;
}

.gc-toggle input:checked + .gc-toggle-ui::after {
  transform: translateX(20px);
}

.gc-toggle-warn input:checked + .gc-toggle-ui {
  background: #ea580c;
}

.gc-toggle-ok input:checked + .gc-toggle-ui {
  background: #22c55e;
}

.gc-field {
  margin-bottom: 14px;
}

.gc-field label,
.gc-field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.gc-field select {
  width: 100%;
  margin: 0;
}

.gc-countries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gc-chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  font-size: 0.85rem;
  cursor: pointer;
}

.gc-chip-toggle input {
  margin: 0;
}

.gc-plan-status {
  font-size: 0.8rem;
  margin: 8px 0 12px;
}

.gc-btn-block {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.gc-btn-block:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.gc-btn-download {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.gc-btn-download:hover {
  filter: brightness(1.06);
}

.gc-api-status {
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.gc-api-ok {
  color: #22c55e;
}

.gc-api-warn {
  color: #f59e0b;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .gc-metrics-row {
    grid-template-columns: 1fr;
  }
}

/* Facturación (panel estilo FLOTIX SPA) */
.billing-shell {
  background: #121212;
  color: #f3f4f6;
  border-radius: 16px;
  padding: 22px 24px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.billing-brand {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9ca3af;
  font-weight: 600;
  margin-bottom: 6px;
}

.billing-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.billing-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.billing-export-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.bill-btn-outline {
  background: transparent;
  color: #f9fafb;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.bill-btn-outline:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.billing-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 22px 0 18px;
}

.billing-kpi {
  background: #1e1e1e;
  border-radius: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.billing-kpi-label {
  font-size: 0.78rem;
  color: #9ca3af;
  margin-bottom: 8px;
}

.billing-kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.billing-kpi-danger {
  color: #f87171;
}

.billing-toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.billing-toolbar input,
.billing-toolbar select,
.billing-toolbar button {
  margin: 0 !important;
  width: auto !important;
  flex: 0 0 auto;
  min-width: 0;
  box-sizing: border-box;
}

.billing-toolbar select {
  min-width: 148px;
}

.billing-toolbar input[data-filter-key='search'] {
  flex: 1 1 220px;
  min-width: 200px;
  max-width: 380px;
}

.billing-toolbar > button#btnApplyFilter {
  white-space: nowrap;
  min-width: 104px;
}

.billing-table-wrap {
  background: #1a1a1a;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: auto;
}

.billing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.billing-table th {
  text-align: left;
  padding: 12px 14px;
  color: #9ca3af;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.billing-table td {
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.billing-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.bill-amount {
  font-weight: 600;
  white-space: nowrap;
}

.bill-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.bill-pill-ok {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.bill-pill-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.bill-pill-danger {
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.bill-pill-info {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.bill-pay-text {
  color: #e5e7eb;
  font-weight: 500;
}

.billing-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  font-size: 0.85rem;
  color: #9ca3af;
}

body.theme-light .billing-shell {
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
}

body.theme-light .billing-kpi {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .billing-table-wrap {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .billing-table th {
  color: #64748b;
  border-bottom-color: #e2e8f0;
}

body.theme-light .billing-table td {
  border-bottom-color: #e2e8f0;
}

body.theme-light .bill-btn-outline {
  color: #0f172a;
  border-color: #94a3b8;
}

body.theme-light .bill-btn-outline:hover {
  background: #f1f5f9;
}

@media print {
  .sidebar,
  .topbar,
  .billing-no-print,
  #notif {
    display: none !important;
  }

  .layout {
    display: block !important;
  }

  .main {
    padding: 0 !important;
  }

  .billing-shell {
    border: none;
    border-radius: 0;
    background: #fff !important;
    color: #111 !important;
  }

  .billing-kpi {
    background: #f4f4f5 !important;
    border: 1px solid #ddd !important;
  }

  .billing-table-wrap {
    background: #fff !important;
    border: 1px solid #ddd !important;
  }

  .bill-pill-ok {
    background: #dcfce7 !important;
    color: #166534 !important;
    border-color: #86efac !important;
  }

  .bill-pill-warn {
    background: #fef3c7 !important;
    color: #92400e !important;
  }

  .bill-pill-danger {
    background: #fee2e2 !important;
    color: #991b1b !important;
  }

  .bill-pill-info {
    background: #dbeafe !important;
    color: #1e40af !important;
  }
}

@media (max-width: 768px) {
  .billing-kpis {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar .actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar .actions button {
    flex: 1 1 calc(50% - 8px);
    min-width: 120px;
  }

  .billing-shell {
    padding: 14px 12px;
  }

  .billing-toolbar {
    flex-direction: column;
    flex-wrap: wrap;
    align-items: stretch;
    overflow-x: visible;
  }

  .billing-toolbar input,
  .billing-toolbar select,
  .billing-toolbar button {
    width: 100% !important;
    max-width: none;
    flex: none;
    min-width: 0 !important;
  }

  .billing-toolbar input[data-filter-key='search'] {
    max-width: none;
  }

  .billing-table th,
  .billing-table td {
    white-space: nowrap;
  }
}
@media (max-width: 480px) {
  .topbar .actions button {
    flex: 1 1 100%;
    min-width: 0;
  }

  .toolbar {
    gap: 6px;
  }

  .toolbar button,
  .toolbar select,
  .toolbar input {
    font-size: 0.95rem;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 220px 1fr;
  }

  .sidebar {
    padding: 12px;
  }

  .menu button {
    font-size: 13px;
    padding: 9px 10px;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
  }

  .b2b-master-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .gc-head-text {
    min-width: 0;
    width: 100%;
  }

  .gc-toolbar-actions {
    width: 100%;
  }

  .gc-toolbar-actions input[type='search'],
  .gc-toolbar-actions button {
    width: 100%;
    min-width: 0;
  }

  .b2b-master-toolbar input,
  .b2b-master-toolbar select,
  .b2b-master-toolbar button,
  .toolbar input,
  .toolbar select,
  .toolbar button {
    width: 100%;
    min-width: 0;
  }

  .bo-live-auto {
    width: 100%;
    justify-content: flex-start;
  }

  .bo-live-prefs-saved {
    min-width: 0;
    width: 100%;
  }
}

/* Mantenimiento de flota */
.mant-page .mant-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.mant-layout {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 1024px) {
  .mant-layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .mant-col-stacked {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }
}
.mant-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  color: var(--text);
}
.mant-alert-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}
.mant-alert-card .mant-alert-title {
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}
.mant-alert-card .mant-alert-meta {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 0.5rem 0;
}
.mant-alert-card .btn-mant-resolve {
  width: 100%;
  margin-top: 0.65rem;
  font-size: 0.875rem;
  padding: 0.45rem 0.75rem;
}
.mant-rule-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}
.mant-rule-card .mant-rule-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
/* Global y no acotado a .mant-rule-card: .link-edit/.link-del se usan como botones-enlace
   en varias tablas y listas del backoffice (Tipos de Mantención, Tipos de Equipo, usuarios,
   estanques de combustible, GPS por empresa). Estaba acotado por accidente a esta card; fuera
   de ese scope heredaban width:100% de la regla generica `button`, mostrandose como botones
   solidos a ancho completo en vez de enlaces de texto. */
.link-edit {
  width: auto;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  font-family: inherit;
}
.link-del {
  width: auto;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  font-family: inherit;
}
.btn-mant-primary {
  background: var(--primary);
  color: #0a0e17;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-mant-primary:hover {
  filter: brightness(1.08);
}
.mant-search-input {
  width: 100%;
  max-width: 22rem;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.mant-search-input::placeholder {
  color: var(--muted);
}
.mant-rules-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.mant-rules-scroll {
  max-height: 30rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.mant-completed {
  color: var(--primary);
  font-weight: 500;
}

/* Gestión de obras: botón + nueva obra */
.b2b-obra-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.btn-obra-plus {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 1.85rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: inherit;
  padding: 0;
}
.btn-obra-plus:hover {
  border-color: var(--primary);
  background: var(--panel-soft);
}

/* Mi empresa (dueño) */
.mi-empresa-shell {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.mi-empresa-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}
.mi-empresa-obra-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: min(100%, 280px);
}
.mi-empresa-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
/* Sin obras (plan sin el servicio 'obras') el selector se reemplaza por la empresa. */
.mi-empresa-empresa-nombre {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.mi-empresa-empresa-datos {
  font-size: 0.8rem;
  color: var(--muted);
}
.mi-empresa-select-obra {
  min-width: 220px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
}
.mi-empresa-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}
.mi-empresa-date-pair {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.mi-empresa-date-pair input[type='date'] {
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
}
.mi-empresa-presets {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.mi-empresa-preset {
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
}
.mi-empresa-preset:hover {
  border-color: var(--primary);
}
.mi-empresa-preset.active {
  background: var(--primary);
  color: #0a0e17;
  border-color: var(--primary);
  font-weight: 600;
}
.mi-empresa-err {
  margin: 0;
}
.mi-empresa-kpis {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.mi-empresa-metric--consumo .mi-empresa-fuel-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.4rem 0 0.55rem 0;
  width: 100%;
  position: relative;
  z-index: 1;
}
.mi-empresa-fuel-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
}
.mi-empresa-fuel-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.mi-empresa-kpi-unit {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.mi-empresa-charts {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 900px) {
  .mi-empresa-charts {
    grid-template-columns: 1fr 1fr;
  }
}
.mi-empresa-chart {
  text-align: center;
}
.mi-empresa-chart h3 {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
}
.mi-empresa-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 7.5rem) 1fr auto;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto 0.5rem auto;
  max-width: 26rem;
  font-size: 0.875rem;
  text-align: initial;
}
.mi-empresa-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.mi-empresa-bar-track {
  height: 10px;
  background: var(--panel-soft);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.mi-empresa-bar-fill {
  height: 100%;
  border-radius: 5px;
  min-width: 0;
  transition: width 0.2s ease;
}
.mi-empresa-bar-fill--camion {
  background: #3b82f6;
}
.mi-empresa-bar-fill--maquina {
  background: #f97316;
}
.mi-empresa-bar-fill--pickup {
  background: var(--primary);
}
.mi-empresa-bar-val {
  font-variant-numeric: tabular-nums;
  min-width: 4rem;
  text-align: right;
  color: var(--text);
}
.mi-empresa-empty {
  margin: 0;
  font-size: 0.9rem;
}

/* Rendimiento histórico (dueño) */
.rh-shell {
  max-width: 100%;
}
.rh-intro {
  margin: 0 0 1rem 0;
  max-width: 48rem;
}
.rh-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius, 8px);
  background: var(--panel, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.rh-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 7.5rem;
}
.rh-field--grow {
  flex: 1 1 10rem;
  min-width: 10rem;
}
.rh-field--filters-dual {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}
.rh-field--filters-dual > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 10rem;
}
.rh-field.rh-dates-wrap {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: flex-end;
}
.rh-dates-wrap input[type='date'] {
  min-width: 140px;
}
.toolbar.rh-toolbar-pag {
  justify-content: center;
  align-items: center;
  width: 100%;
  gap: 1rem;
}
.rh-toolbar-pag .rh-pag-meta {
  text-align: center;
  flex: 1 1 auto;
  min-width: 12rem;
}
.rh-field .rh-tl + select,
.rh-field .rh-tl + input {
  min-width: 0;
}
@media (max-width: 600px) {
  .rh-field--filters-dual > div {
    min-width: 0;
    width: 100%;
  }
  .rh-dates-wrap input[type='date'] {
    min-width: 0;
    width: 100%;
  }
}
.rh-tl {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #94a3b8);
}
.rh-apply {
  align-self: flex-end;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary, #22c55e);
  color: #0f172a;
}
.rh-apply:hover {
  filter: brightness(1.06);
}
.rh-kpis {
  margin-bottom: 1.25rem;
}
.rh-metric .rh-subk {
  font-size: 0.78rem;
  color: var(--muted, #94a3b8);
  margin-top: 0.2rem;
}
.rh-block h3 {
  margin-bottom: 0.25rem;
}
.rh-list-sub {
  margin: 0 0 0.75rem 0;
}
.rh-table-wrap {
  overflow-x: auto;
}
.rh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.rh-table th,
.rh-table td {
  padding: 0.55rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.rh-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted, #94a3b8);
}
.rh-table th.rh-tc,
.rh-table td.rh-tc {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.rh-table .rh-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rh-rend-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 7rem;
}
.rh-table td.rh-td-rend .rh-rend-cell {
  align-items: center;
  max-width: 9.5rem;
  margin: 0 auto;
}
.rh-table td.rh-td-rend .rh-bar-track {
  width: 100%;
}
.rh-bar-track {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.rh-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.2s ease;
}
.rh-bar-fill--opt {
  background: #22c55e;
}
.rh-bar-fill--reg {
  background: #eab308;
}
.rh-bar-fill--low {
  background: #ef4444;
}
.rh-badge {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}
.rh-badge--opt {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}
.rh-badge--reg {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
}
.rh-badge--low {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}
.rh-money--opt {
  color: #4ade80;
}
.rh-money--reg {
  color: #facc15;
}
.rh-money--low {
  color: #f87171;
}
.rh-tfoot td {
  border-bottom: none;
  padding-top: 0.75rem;
  font-weight: 600;
}
body.theme-light .rh-toolbar {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.1);
}
body.theme-light .rh-bar-track {
  background: rgba(15, 23, 42, 0.08);
}

/* —— Resumen global (super admin) —— */
.sg-dash {
  max-width: 1280px;
  margin: 0 auto;
}
.sg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.sg-brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.sg-date {
  margin: 6px 0 0;
  font-size: 0.9rem;
  text-transform: capitalize;
}
.sg-user-chip {
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--text);
  align-self: center;
}
.sg-kpis {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.sg-metric .v {
  font-size: 1.35rem;
  font-weight: 700;
}
.sg-kpi-delta {
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}
.sg-kpi-delta--up {
  color: var(--ok);
}
.sg-kpi-delta--down {
  color: var(--danger);
}
.sg-kpi-hint,
.sg-kpi-sub {
  margin-top: 8px;
  font-size: 0.8rem;
  line-height: 1.35;
}
.sg-mid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}
.sg-mid--second {
  margin-top: 16px;
}
@media (max-width: 960px) {
  .sg-mid {
    grid-template-columns: 1fr;
  }
}
.sg-panel h3 {
  margin-top: 0;
}
.sg-panel-sub {
  margin: -6px 0 14px;
  font-size: 0.85rem;
}
.sg-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  min-height: 160px;
  padding: 8px 4px 0;
}
.sg-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  height: 150px;
}
.sg-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 6px 6px 2px 2px;
  background: rgba(255, 255, 255, 0.12);
  transition: height 0.25s ease;
}
.sg-bar--current {
  background: linear-gradient(180deg, var(--primary), #059669);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}
.sg-bar-lbl {
  display: block;
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
  text-align: center;
}
.sg-alerts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sg-alert-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.sg-alert-item:last-child {
  border-bottom: none;
}
.sg-alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.sg-alert-dot--danger {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(248, 81, 73, 0.45);
}
.sg-alert-dot--warn {
  background: var(--warn);
}
.sg-alert-dot--info {
  background: #38bdf8;
}
.sg-alert-detail {
  margin: 4px 0 0;
  font-size: 0.85rem;
}
.sg-alert-empty {
  padding: 12px 0;
}
.sg-plan-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 2fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.sg-plan-name {
  font-size: 0.88rem;
  font-weight: 600;
}
.sg-plan-track {
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.sg-plan-fill {
  height: 100%;
  border-radius: 6px;
  min-width: 4px;
  transition: width 0.3s ease;
}
.sg-plan-fill--a {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}
.sg-plan-fill--b {
  background: linear-gradient(90deg, #6366f1, #a5b4fc);
}
.sg-plan-count {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.sg-renewals {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sg-ren-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.sg-ren-row:last-child {
  border-bottom: none;
}
.sg-ren-co {
  font-weight: 600;
}
.sg-ren-date {
  font-size: 0.8rem;
}
.sg-ren-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.sg-ren-badge--ok {
  background: rgba(16, 185, 129, 0.2);
  color: var(--ok);
}
.sg-ren-badge--bad {
  background: rgba(248, 81, 73, 0.2);
  color: var(--danger);
}
.sg-ren-empty {
  margin: 0;
  padding: 8px 0;
}
.sg-table-block {
  margin-top: 18px;
}
.sg-co-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.sg-co-table th,
.sg-co-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.sg-plan-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.35);
}
body.theme-light .sg-bar {
  background: rgba(15, 23, 42, 0.08);
}
body.theme-light .sg-plan-track {
  background: rgba(15, 23, 42, 0.08);
}

.bo-live-sync {
  font-size: 0.92rem;
}
.bo-live-row-selected td {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}
.bo-live-detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start;
}
.bo-live-detail p {
  margin: 0 0 8px;
}
.bo-live-value-updated {
  animation: boLiveValuePulse 0.95s ease;
}
.bo-live-still-badge,
.bo-live-moving-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}
.bo-live-still-badge {
  color: #fff;
  background: color-mix(in srgb, var(--danger) 86%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 72%, transparent);
}
.bo-live-moving-badge {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 38%, transparent);
}
@keyframes boLiveValuePulse {
  0% {
    background: color-mix(in srgb, var(--primary) 38%, transparent);
    color: #fff;
    border-radius: 4px;
  }
  100% {
    background: transparent;
    color: inherit;
  }
}
.bo-live-map {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 8px;
}
.bo-live-map-caption {
  margin: 0 0 6px;
  font-size: 0.85rem;
}
.bo-live-map-caption-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 0 0 6px;
  font-size: 0.85rem;
  line-height: 1.4;
}
.bo-live-map-caption-row .bo-live-map-caption-text {
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
}
.bo-live-map-caption-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 1 auto;
  justify-content: flex-end;
  align-items: center;
}
.bo-live-map-caption-actions .ghost.btn-xs {
  width: auto;
  margin: 0;
}
.bo-live-track-summary {
  margin: 0 0 12px;
  line-height: 1.45;
  max-width: 72ch;
}
#boLiveMap.bo-live-map,
.bo-live-map.leaflet-container {
  min-height: 320px;
  background: var(--surface-2, #0f172a);
  z-index: 1;
}
.leaflet-container a {
  color: var(--primary, #10b981);
}
.bo-live-auto {
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-right: 0;
}
.bo-live-auto input {
  width: auto;
  margin: 0;
}
.bo-live-prefs-saved {
  min-width: 150px;
  margin: 0;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.bo-live-prefs-saved.bo-live-prefs-saved-show {
  opacity: 1;
  transform: translateY(0);
}
.bo-live-sus-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  padding: 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  vertical-align: middle;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  cursor: help;
}
.bo-live-sus-hint {
  margin: 0 0 10px;
  padding: 8px 10px;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 8%, transparent);
}
.bo-live-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.bo-live-table .bo-live-th-short {
  display: none;
}
.bo-live-table .bo-live-th-full {
  display: inline;
}
@media (max-width: 1280px) {
  .bo-live-table .bo-live-th-short {
    display: inline;
  }
  .bo-live-table .bo-live-th-full {
    display: none;
  }
}
@media (max-width: 640px) {
  .global-config-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .global-config-toolbar input {
    min-width: 0;
    width: 100%;
  }
  .global-config-toolbar button {
    width: 100%;
  }
}

/* Traslados del plan GPS Bermann: filas alternas para seguir la línea de un vistazo.
   Solo cuentan las filas (.rv-tr) porque el encabezado va fuera del contenedor. */
#rvSecTrasladosRows .rv-tr-bermann:nth-child(odd) {
  background: rgba(255, 255, 255, 0.035);
}
#rvSecTrasladosRows .rv-tr-bermann:nth-child(even) {
  background: rgba(255, 255, 255, 0.08);
}

/* Vista previa de tickets: se abre desde el folio en Reportes operativos. */
.tickets-folio {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, #00e5c4);
  font: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
}
.tickets-tabla {
  width: 100%;
  border-collapse: collapse;
}
.tickets-tabla th {
  text-align: left;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0 0.6rem 0.4rem;
  white-space: nowrap;
}
.tickets-tabla td {
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  white-space: nowrap;
}
.tickets-tabla tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.035);
}
.tickets-tabla tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.08);
}

/* Propio / Arrendado (formulario de equipo, solo con el servicio de plan 'arrendado') */
.eq-owner-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--field-bg);
}
.eq-owner-toggle label {
  position: relative;
  cursor: pointer;
}
.eq-owner-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.eq-owner-toggle span {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
}
.eq-owner-toggle input:checked + span {
  color: #fff;
  background: var(--primary);
}
.eq-owner-toggle input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.eq-leased-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 60%, transparent);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  vertical-align: middle;
}

/* Visor del ticket de un traslado (plan GPS Bermann): foto con zoom + datos digitados. */
.visor-ticket {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.visor-ticket-caja {
  display: flex;
  gap: 1rem;
  width: min(1200px, 100%);
  height: min(90vh, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.visor-ticket-marco {
  flex: 1;
  overflow: auto;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  display: block;
}
.visor-ticket-marco img {
  width: 100%;
  display: block;
  cursor: zoom-in;
}
.visor-ticket-lado {
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.visor-ticket-lado h4 {
  margin: 0 0 0.25rem;
}
.visor-ticket-dato {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
}
.visor-ticket-dato strong {
  font-size: 1.05rem;
}
.visor-ticket-lado p {
  font-size: 0.78rem;
  margin: auto 0 0;
}
@media (max-width: 760px) {
  .visor-ticket-caja {
    flex-direction: column;
    height: 95vh;
  }
  .visor-ticket-lado {
    width: auto;
  }
}

/* ===== Módulo KPI ===== */
.kpi-shell { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
/* Sin esto, una tabla ancha estira el contenedor en vez de hacer scroll dentro de su tarjeta. */
.kpi-shell > *, .kpi-grid-2 > *, .kpi-cards > * { min-width: 0; }
.kpi-shell .table-wrap { overflow-x: auto; max-width: 100%; }
.kpi-filtros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
  gap: 0.75rem;
}
.kpi-filtros-grid label,
.kpi-sub-select { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.kpi-filtros-acciones { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem; margin-top: 0.85rem; }
.kpi-sub-select { margin-left: auto; min-width: 230px; }
.kpi-nota { font-size: 0.78rem; margin: 0.75rem 0 0; }
.kpi-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 0.85rem; }
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.kpi-card-top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.kpi-card-titulo { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--primary); }
.kpi-card-valor { font-size: 2rem; font-weight: 800; line-height: 1.15; margin-top: 0.35rem; }
.kpi-card-valor small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.kpi-card-unidad { font-size: 0.85rem; color: var(--muted); }
.kpi-var { font-size: 0.78rem; margin-top: 0.45rem; font-weight: 600; }
.kpi-var--buena { color: var(--ok); }
.kpi-var--mala { color: var(--danger); }
.kpi-var--neutral { color: var(--muted); font-weight: 500; }
.kpi-ayuda {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kpi-def {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}
.kpi-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 1rem; }
.kpi-chart h3, .kpi-shell .block h3 { display: flex; align-items: center; gap: 0.5rem; }
.kpi-canvas { position: relative; height: 280px; }
.kpi-canvas--alto { height: 360px; }
.kpi-vacio { padding: 1rem 0; text-align: center; }
.kpi-inline { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.6rem; }
.kpi-inline input { width: 80px; }
.kpi-detalle-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.kpi-paginas { display: flex; justify-content: center; align-items: center; gap: 0.8rem; margin-top: 0.75rem; }
.kpi-shell td.num, .kpi-shell th.num { text-align: right; }
@media (max-width: 640px) {
  .kpi-card-valor { font-size: 1.6rem; }
  .kpi-sub-select { margin-left: 0; width: 100%; }
  .kpi-canvas { height: 240px; }
}
.kpi-filtros-acciones > button { width: auto; min-width: 120px; }
.kpi-aviso {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.kpi-punto { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; }
.kpi-punto--verde { background: var(--ok); }
.kpi-punto--amarillo { background: var(--warn); }
.kpi-punto--rojo { background: var(--danger); }
.kpi-semaforo-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; font-size: 1rem; font-weight: 600; }
.kpi-semaforo-fila button { margin-left: auto; }
.kpi-insights ul, .kpi-lista { margin: 0.25rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.45rem; }
.kpi-insights li { line-height: 1.45; }
.kpi-pesos { margin-top: 0.85rem; }
.kpi-pesos summary { cursor: pointer; color: var(--primary); font-size: 0.85rem; font-weight: 600; }
.kpi-pesos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; margin: 0.6rem 0; }
.kpi-pesos-grid label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.kpi-subtitulo { margin: 1rem 0 0.4rem; font-size: 0.95rem; }
.kpi-parametros { display: flex; flex-wrap: wrap; gap: 1rem; }
.kpi-parametros label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); min-width: 220px; }
.kpi-shell tr.kpi-fila-alerta td { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* Enlaces legales bajo el formulario de ingreso (Ley 21.719). */
.login-legal { margin: 14px 0 0; text-align: center; font-size: 12px; }
.login-legal a { color: inherit; opacity: 0.75; }

/* Enlaces del modal de Términos: con el color por defecto del navegador (morado al visitarlos)
   casi no se leían sobre el fondo oscuro. */
[data-terminos] a,
[data-terminos] a:visited { color: var(--primary); }


/* Documentación vehicular: badges de estado que no cubren .ok/.warn/.danger, selector y tarjetas. */
.doc-pendiente {
  background: color-mix(in srgb, var(--muted) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--muted) 50%, transparent);
}

.doc-falta-fecha {
  background: color-mix(in srgb, #3b82f6 26%, transparent);
  border: 1px solid color-mix(in srgb, #3b82f6 55%, transparent);
}

.doc-no-aplica {
  background: transparent;
  border: 1px dashed var(--muted);
  color: var(--muted);
}

.doc-selector {
  display: grid;
  gap: 4px;
  max-width: 420px;
  margin-top: 8px;
}

.doc-selector .doc-veh-search {
  border-radius: 6px 6px 0 0;
}

.doc-selector .doc-veh-select {
  border-radius: 0 0 6px 6px;
  border-top: none;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.doc-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.doc-linea {
  font-size: 0.85rem;
}

.doc-fecha {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  font-size: 0.85rem;
}

.doc-acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.doc-noaplica {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Torre de Control: contador en el menú, badges propios y detalle del evento. */
.menu-count {
  float: right;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.torre-info {
  background: color-mix(in srgb, #3b82f6 26%, transparent);
  border: 1px solid color-mix(in srgb, #3b82f6 55%, transparent);
}

.torre-nuevo {
  background: color-mix(in srgb, var(--primary) 30%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 60%, transparent);
}

.torre-descartado {
  background: transparent;
  border: 1px dashed var(--muted);
  color: var(--muted);
}

.torre-tabla tr.torre-fila-nueva td { font-weight: 600; }

.torre-datos {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.torre-datos dt { color: var(--muted); }
.torre-datos dd { margin: 0; }
.torre-evidencia th { text-align: left; text-transform: capitalize; color: var(--muted); font-weight: 500; }
.torre-historial { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; display: grid; gap: 6px; }
.torre-revision { display: grid; gap: 8px; margin-top: 1rem; }
.torre-revision textarea { width: 100%; resize: vertical; }
.torre-acciones { display: flex; gap: 8px; flex-wrap: wrap; }

/* Torre de Control: pestañas internas y editor de alertas. */
.torre-tabs { display: flex; gap: 4px; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.torre-tab {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 14px;
  font-weight: 600;
}
.torre-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.torre-param { display: inline-flex; align-items: center; gap: 6px; margin: 2px 12px 2px 0; font-size: 0.85rem; }
.torre-param input { width: 90px; }
.torre-acciones-regla { white-space: nowrap; }
.torre-editor { display: grid; gap: 8px; }
.torre-cond { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.torre-cond select[data-cond-campo] { min-width: 240px; flex: 1; }
.torre-cond-valor { display: inline-flex; align-items: center; gap: 4px; }
.torre-cond-valor input { width: 120px; }
.torre-equipos { display: flex; flex-wrap: wrap; gap: 4px 14px; max-height: 160px; overflow: auto; }
.torre-equipo { font-size: 0.85rem; }
.torre-resumen {
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 50%, transparent);
  font-size: 0.9rem;
}
