@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   VARIABLES GLOBALES Y RESET
   ========================================================================== */
:root {
  --bg: #080b12;
  --surface: #111827;
  --surface2: #182235;
  --line: #29354b;
  --purple: #7547f5;
  --purple2: #8b5cf6;
  --green: #16a34a;
  --green2: #0b6b2b;
  --text: #f5f7fb;
  --muted: #9aa6ba;
  --danger: #ef4444;
  --orange: #f59e0b;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 15%, rgba(117, 71, 245, 0.16), transparent 34%),
              linear-gradient(145deg, #05070c, #0b101b);
}

.login-card {
  width: min(440px, 100%);
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid #2a3750;
  border-radius: 28px;
  padding: 42px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand-center {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 190px;
  height: auto;
  object-fit: contain;
  margin: 0 auto 12px;
  display: block;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #20a348;
  text-transform: uppercase;
}

.brand-center h1 {
  margin: 7px 0 2px;
  font-size: 36px;
  text-transform: uppercase;
  color: var(--purple2);
}

.brand-center p {
  margin: 0;
  color: var(--muted);
}

.login-card label {
  display: block;
  color: #d8deea;
  font-size: 13px;
  font-weight: 700;
  margin: 17px 0 7px;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #354259;
  background: #0e1522;
  border-radius: 12px;
  padding: 0 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--purple2);
  box-shadow: 0 0 0 3px rgba(117, 71, 245, 0.12);
}

.input-wrap input {
  border: 0 !important;
  background: transparent !important;
  padding: 14px 0 !important;
  box-shadow: none !important;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #354259;
  background: #101827;
  color: var(--text);
  border-radius: 10px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--purple2);
  box-shadow: 0 0 0 3px rgba(117, 71, 245, 0.12);
}

.login-help {
  text-align: center;
  color: #7f8ba0;
  font-size: 12px;
  margin-top: 16px;
}

/* ==========================================================================
   LAYOUT & ESTRUCTURA
   ========================================================================== */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 265px;
  background: #0c111b;
  border-right: 1px solid #202b3d;
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 25px;
  border-bottom: 1px solid #202b3d;
}

.side-brand img {
  width: 54px;
  height: 48px;
  object-fit: contain;
}

.side-brand strong {
  display: block;
  font-size: 20px;
}

.side-brand small {
  color: #758198;
  font-size: 10px;
}

.sidebar nav {
  padding-top: 18px;
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #aab4c6;
  text-align: left;
  padding: 13px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.nav-item span {
  width: 23px;
  text-align: center;
  font-size: 18px;
}

.nav-item:hover {
  background: #161f2e;
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, #7043e9, #7c50ef);
  color: #fff;
  box-shadow: 0 8px 20px rgba(117, 71, 245, 0.2);
}

.side-footer {
  margin-top: auto;
  border-top: 1px solid #202b3d;
  padding-top: 15px;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px;
}

.user-mini b {
  display: block;
  font-size: 13px;
}

.user-mini small {
  display: block;
  color: #778399;
  font-size: 11px;
}

.avatar, .top-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #26344b;
  color: #fff;
  font-weight: 800;
}

.avatar {
  width: 34px;
  height: 34px;
}

.logout {
  width: 100%;
  margin-top: 12px;
  border: 0;
  background: #161d2a;
  color: #d4d9e3;
  border-radius: 10px;
  padding: 11px;
  text-align: left;
  transition: background 0.2s;
}

.logout:hover {
  background: #202a3c;
}

.main {
  margin-left: 265px;
  width: calc(100% - 265px);
  min-width: 0;
}

.topbar {
  height: 78px;
  border-bottom: 1px solid #202b3d;
  background: rgba(8, 11, 18, 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-title {
  display: block;
  font-weight: 800;
  font-size: 17px;
}

.top-subtitle {
  color: #758198;
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.date-pill {
  color: #9ca8ba;
  font-size: 12px;
}

.top-avatar {
  width: 38px;
  height: 38px;
}

.menu-toggle {
  display: none;
}

.content {
  padding: 30px;
  max-width: 1600px;
  margin: auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.welcome, .page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 24px;
}

.welcome h2, .page-heading h2 {
  font-size: 29px;
  margin: 5px 0;
}

.welcome p, .page-heading p {
  margin: 0;
  color: var(--muted);
}

.primary-btn, .secondary-btn, .text-btn {
  border: 0;
  border-radius: 11px;
  padding: 12px 18px;
  font-weight: 800;
  transition: transform 0.15s, filter 0.15s;
}

.primary-btn {
  background: linear-gradient(135deg, #7446f1, #8858f7);
  color: #fff;
  box-shadow: 0 8px 20px rgba(117, 71, 245, 0.2);
}

.primary-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.secondary-btn {
  background: #1a2434;
  color: #d9deea;
  border: 1px solid #2e3b50;
}

.secondary-btn:hover {
  background: #223046;
}

.text-btn {
  background: transparent;
  color: #9c7cff;
  padding: 6px;
}

.full {
  width: 100%;
  margin-top: 24px;
  padding: 14px;
}

/* ==========================================================================
   DASHBOARD & GRÁFICOS
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat-card, .panel, .form-panel {
  background: linear-gradient(145deg, #111a29, #0f1724);
  border: 1px solid #243149;
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.stat-card {
  padding: 20px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.stat-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 21px;
}

.purple { background: rgba(117, 71, 245, 0.16); }
.green  { background: rgba(22, 163, 74, 0.15); }
.orange { background: rgba(245, 158, 11, 0.15); }
.blue   { background: rgba(59, 130, 246, 0.15); }

.stat-card small {
  display: block;
  color: #8490a4;
  font-size: 11px;
}

.stat-card strong {
  display: block;
  font-size: 24px;
  margin: 4px 0;
}

.trend {
  font-size: 10px;
  color: #738096;
}

.trend.up {
  color: #35c86b;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 17px;
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.panel-head small {
  color: #78859a;
}

.badge {
  font-size: 10px;
  background: #14261a;
  color: #43c86d;
  padding: 6px 9px;
  border-radius: 20px;
}

/* Gráfico de Barras */
.bars, #bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 235px;
  padding: 15px 10px 5px;
  gap: 12px;
}

.bar-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.bar-value {
  font-size: 11px;
  font-weight: 700;
  color: #38ef7d;
  margin-bottom: 6px;
  min-height: 15px;
}

.bar-wrapper {
  width: 100%;
  max-width: 28px;
  height: 160px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  position: relative;
}

.bar {
  width: 100%;
  height: var(--h, 0%);
  background: linear-gradient(180deg, #11998e 0%, #38ef7d 100%);
  border-radius: 8px 8px 0 0;
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(56, 239, 125, 0.3);
}

.bar-col:hover .bar {
  filter: brightness(1.2);
  box-shadow: 0 0 18px rgba(56, 239, 125, 0.6);
}

.bar-label, .bar-col small {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #aab4c6;
}

/* Rankings */
.ranking {
  display: grid;
  gap: 17px;
}

.ranking > div {
  display: grid;
  grid-template-columns: 32px 75px 1fr;
  align-items: center;
  gap: 8px;
}

.rank {
  font-size: 11px;
  color: #66748c;
}

.rank-info b {
  font-size: 12px;
}

.rank-info small {
  display: block;
  color: #738096;
  font-size: 10px;
}

.progress {
  height: 7px;
  background: #202c40;
  border-radius: 10px;
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: #7650e6;
  border-radius: 10px;
  transition: width 0.5s ease;
}

/* ==========================================================================
   FORMULARIOS
   ========================================================================== */
.form-panel {
  padding: 27px;
  max-width: 1050px;
}

.section-title {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid #26334a;
}

.section-title > span {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(117, 71, 245, 0.16);
  color: #9e82ff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.section-title h3 {
  margin: 0 0 3px;
}

.section-title small {
  color: #768399;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 17px;
}

.field label {
  display: block;
  color: #d9deea;
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 7px;
}

.field label span {
  color: #738096;
  font-weight: 400;
}

.field input[readonly] {
  color: #a7b1c1;
  background: #151f30;
}

.full-field {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #26334a;
}

.compact-form {
  max-width: 800px;
}

/* ==========================================================================
   TABLAS & FILTROS
   ========================================================================== */
.toolbar, .filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0d1522;
  border: 1px solid #29364b;
  border-radius: 10px;
  padding: 0 12px;
  flex: 1;
  min-width: 250px;
}

.search input {
  border: 0;
  background: transparent;
  padding: 12px 0;
}

.search span {
  color: #7e8ca2;
  font-size: 22px;
}

.search.large {
  max-width: 600px;
}

.quick-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-filters button {
  border: 1px solid #303e55;
  background: #121b29;
  color: #aeb7c7;
  border-radius: 8px;
  padding: 9px 11px;
}

.quick-filters button:hover {
  border-color: #7d55ee;
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

th {
  text-align: left;
  color: #738096;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 12px;
  border-bottom: 1px solid #29364a;
}

td {
  padding: 14px 12px;
  border-bottom: 1px solid #1f2a3b;
  color: #dce1ea;
  font-size: 12px;
}

tbody tr:hover {
  background: #121c2b;
}

.status {
  padding: 5px 9px;
  border-radius: 15px;
  font-size: 10px;
  font-weight: 800;
}

.status.ok {
  background: #13301d;
  color: #48d174;
}

.status.warn {
  background: #352914;
  color: #f5bb55;
}

.actions button {
  border: 0;
  background: #1b2637;
  color: #a996ff;
  border-radius: 7px;
  padding: 7px 9px;
  margin-right: 4px;
  transition: background 0.2s;
}

.actions button:hover {
  background: #25354d;
}

.filters input, .filters select {
  width: auto;
  min-width: 160px;
}

.filters .search {
  flex: 1;
}

/* ==========================================================================
   PERMISOS
   ========================================================================== */
.permission-panel {
  max-width: 950px;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
  margin-top: 20px;
}

.permission {
  position: relative;
  background: #111b2a;
  border: 1px solid #29374d;
  border-radius: 14px;
  padding: 18px;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 3px 10px;
  cursor: pointer;
}

.permission input {
  position: absolute;
  right: 13px;
  top: 13px;
  width: auto;
  accent-color: var(--purple);
}

.permission span {
  grid-row: 1 / 3;
  font-size: 23px;
}

.permission b {
  font-size: 13px;
}

.permission small {
  color: #718096;
  font-size: 10px;
}

/* ==========================================================================
   TOAST & MODALES
   ========================================================================== */
.toast {
  position: fixed;
  right: 25px;
  bottom: 25px;
  background: #1b293a;
  border: 1px solid #3b4b63;
  color: #fff;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transform: translateY(120px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 50;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-error {
  border-color: #ef4444;
  background: #2c1215;
}

.toast-success {
  border-color: #16a34a;
  background: #0f2918;
}

.edit-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(5px);
}

.edit-modal.hidden {
  display: none !important;
}

.edit-modal-card {
  width: min(520px, 100%);
  background: #111827;
  color: #fff;
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.45);
}

.edit-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.edit-modal-head h3 {
  margin: 0;
  color: #34d399;
  font-size: 19px;
}

.edit-close {
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 30px;
  line-height: 1;
}

.edit-close:hover {
  color: #fff;
}

.edit-modal-card .field {
  margin-bottom: 15px;
}

.edit-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #26334a;
}

.empty-state {
  color: #778399;
  text-align: center;
  padding: 25px;
  font-size: 12px;
}

/* ==========================================================================
   MEDIDOR Y TARJETA DE DIÉSEL (TANQUE PRINCIPAL)
   ========================================================================== */
.tank-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #111a29;
  border: 1px solid #243149;
  color: #ffffff;
  padding: 18px 22px;
  border-radius: var(--radius);
  gap: 16px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.tank-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tank-info h4 {
  margin: 0;
  font-size: 15px;
}

.tank-info p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.tank-gauge {
  text-align: center;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-text {
  font-size: 1rem;
  white-space: nowrap;
  margin-top: 4px;
  color: #ffffff;
}

.gauge-text small {
  color: var(--muted);
  font-size: 0.8rem;
}

.btn-reload {
  background: transparent;
  border: 1px solid #2e3b50;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s;
}

.btn-reload:hover {
  background: #1a2434;
  border-color: var(--purple2);
}

.diesel-gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.gauge-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  font-weight: 600;
}

.status-badge.reserva {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  animation: pulse-reserva 1.5s infinite;
}

@keyframes pulse-reserva {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

.gauge-wrapper {
  position: relative;
  width: 100%;
  max-width: 200px;
  margin: 5px 0;
}

.gauge-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.gauge-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 16;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: #8b5cf6;
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 251.2;
  stroke-dashoffset: 251.2;
  transition: stroke-dashoffset 1.2s ease, stroke 0.5s ease;
  filter: drop-shadow(0px 0px 6px rgba(139, 92, 246, 0.6));
}

.gauge-fill.reserva {
  stroke: #ef4444;
  filter: drop-shadow(0px 0px 8px rgba(239, 68, 68, 0.8));
}

.btn-refill {
  width: 100%;
  padding: 9px 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #7446f1, #8858f7);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-refill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(117, 71, 245, 0.35);
}

/* ==========================================================================
   RESPONSIVE DESIGN (MEDIA QUERIES)
   ========================================================================== */
@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 230px;
  }
  .main {
    margin-left: 230px;
    width: calc(100% - 230px);
  }
}

@media (max-width: 780px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 270px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
    width: 100%;
  }
  .menu-toggle {
    display: block;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 22px;
    margin-right: 12px;
  }
  .topbar {
    padding: 0 16px;
  }
  .topbar > div:first-of-type {
    margin-right: auto;
  }
  .date-pill {
    display: none;
  }
  .content {
    padding: 20px 14px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .full-field {
    grid-column: auto;
  }
  .welcome, .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .permissions-grid {
    grid-template-columns: 1fr 1fr;
  }
  .tank-card {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .tank-info {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .login-card {
    padding: 28px 20px;
  }
  .permissions-grid {
    grid-template-columns: 1fr;
  }
  .top-subtitle {
    display: none;
  }
  .panel, .form-panel {
    padding: 17px;
  }
}

/* ==========================================================================
   MEJORAS DE USABILIDAD - CELULAR E HISTORIAL
   ========================================================================== */
.history-filter-panel { margin-bottom: 18px; }
.history-filter-title { display:flex; align-items:center; gap:12px; margin-bottom:18px; }
.history-filter-title h3 { margin:0 0 3px; font-size:17px; }
.history-filter-title small { color:var(--muted); }
.filter-icon { width:44px; height:44px; border-radius:13px; display:grid; place-items:center; background:rgba(117,71,245,.16); font-size:20px; }
.history-date-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.history-unit-actions { display:grid; grid-template-columns:auto minmax(220px,1fr) auto; gap:10px; align-items:end; margin-top:15px; }
.history-choice { min-height:48px; padding:12px 16px; border-radius:12px; border:1px solid #354259; background:#101827; color:#dce1ea; font-weight:800; cursor:pointer; }
.history-choice.active { border-color:#8058f2; background:rgba(117,71,245,.16); color:#fff; }
.history-unit-picker select { min-height:48px; }
.history-search-btn { min-height:48px; white-space:nowrap; }
.history-quick-search { margin-top:12px; }
.history-quick-search .search { min-width:0; }
.history-hint { margin-top:14px; padding:12px 14px; border-radius:11px; background:#0d1522; border:1px dashed #354259; color:#8f9bad; font-size:12px; }
.history-export-actions { display:flex; gap:8px; flex-wrap:wrap; }
.history-results-head { margin-bottom:12px; }
.history-page-size { color:#778399; font-size:11px; font-weight:700; }
.history-pagination { display:flex; align-items:center; justify-content:center; gap:6px; flex-wrap:wrap; margin-top:16px; padding-top:14px; border-top:1px solid #243149; }
.page-btn { min-width:42px; min-height:40px; padding:8px 12px; border-radius:10px; border:1px solid #2e3b50; background:#121b29; color:#cbd3df; font-weight:800; cursor:pointer; }
.page-btn.active { background:#7446f1; border-color:#7446f1; color:#fff; }
.page-btn:disabled { opacity:.4; cursor:not-allowed; }

@media (max-width: 780px) {
  body { font-size:15px; }
  .content { padding:16px 12px 28px; }
  .topbar { min-height:64px; }
  .top-title { font-size:16px; }
  .welcome h2, .page-heading h2 { font-size:24px; }
  .primary-btn, .secondary-btn { min-height:48px; padding:12px 16px; font-size:14px; border-radius:13px; }
  .text-btn { min-height:44px; padding:10px 12px; }
  input, select, textarea { min-height:48px; padding:13px 14px; font-size:16px; border-radius:12px; }
  .form-actions { flex-direction:column; }
  .form-actions button, .form-panel .full { width:100%; min-height:52px; }
  .history-date-grid { grid-template-columns:1fr; }
  .history-unit-actions { grid-template-columns:1fr; }
  .history-choice, .history-search-btn { width:100%; min-height:52px; }
  .history-export-actions { width:100%; display:grid; grid-template-columns:1fr; }
  .history-export-actions button { width:100%; }
  .panel, .form-panel { border-radius:16px; }
  .stat-card { min-height:86px; }
  .table-wrap { margin-left:-2px; margin-right:-2px; border-radius:10px; }
  th { padding:11px 10px; }
  td { padding:13px 10px; }
  .history-pagination { position:sticky; bottom:0; background:#0f1724; padding-bottom:8px; }
}

@media (max-width: 520px) {
  .content { padding-left:10px; padding-right:10px; }
  .page-heading { gap:14px; }
  .history-filter-title { align-items:flex-start; }
  .filter-icon { flex:0 0 44px; }
  .stats-grid { grid-template-columns:1fr; }
  .stat-card { padding:16px; }
  .btn-refill { min-height:50px; font-size:14px; }
  .history-hint { line-height:1.5; }
}


/* ==========================================================================\n   AJUSTE MOVIL REAL - MENU Y CONTROLES TACTILES\n   ========================================================================== */
.mobile-overlay { display:none; }
@media (max-width:780px) {
 html,body{width:100%;max-width:100%;overflow-x:hidden} body{min-width:0}
 .app{width:100%;min-width:0}
 .sidebar{width:min(86vw,310px)!important;max-width:310px;padding:16px 12px;transform:translateX(-105%)!important;box-shadow:18px 0 45px rgba(0,0,0,.45);overflow-y:auto;-webkit-overflow-scrolling:touch;z-index:1001}
 .sidebar.open{transform:translateX(0)!important}
 .mobile-overlay{display:block;position:fixed;inset:0;background:rgba(0,0,0,.58);backdrop-filter:blur(2px);opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease,visibility .2s ease;z-index:1000}
 .mobile-overlay.show{opacity:1;visibility:visible;pointer-events:auto}
 .side-brand{padding:4px 8px 18px}.side-brand img{width:50px;height:44px}.side-brand strong{font-size:19px}
 .sidebar nav{gap:5px;padding-top:14px}.nav-item{min-height:54px;padding:13px 14px;border-radius:13px;font-size:14px;-webkit-tap-highlight-color:transparent}.nav-item span{width:28px;font-size:20px}.logout{min-height:52px;width:100%}
 .main{margin-left:0!important;width:100%!important;min-width:0}.topbar{position:sticky;top:0;z-index:50;min-height:64px;padding:8px 12px;gap:8px}
 .menu-toggle{display:grid!important;place-items:center;flex:0 0 48px;width:48px;height:48px;margin:0 4px 0 0;border-radius:13px;background:#182235;border:1px solid #2d3b53;color:#fff;font-size:25px;line-height:1;box-shadow:0 5px 16px rgba(0,0,0,.18)}
 .top-actions{gap:6px}.top-avatar{width:40px;height:40px}.content{width:100%;min-width:0}
 button,.primary-btn,.secondary-btn,.btn-refill,.history-choice,.history-search-btn{min-height:50px;touch-action:manipulation}.primary-btn,.secondary-btn{padding:13px 18px}
 .table-wrap{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
}
@media (max-width:520px){
 .top-title{font-size:15px}.content{padding:12px 10px 28px}.welcome,.page-heading{width:100%}.welcome .primary-btn,.page-heading .primary-btn{width:100%}
 .panel,.form-panel{padding:15px}.form-actions button,.form-panel .full{min-height:54px;font-size:15px}.nav-item{min-height:56px;font-size:15px}
}

/* ========================================================================== 
   MEJORAS 2026-08-31: CAMPOS INTERNOS, LOGO DASHBOARD Y TEMA CLARO/OSCURO
   ========================================================================== */
/* Se ocultan solamente en pantalla. Los datos siguen existiendo y el backend
   los conserva en registros_combustible para reportes. */
.registro-interno { display: none !important; }

.brand-dashboard-link {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.brand-dashboard-link:hover { background: rgba(117,71,245,.08); border-radius: 12px; }

.theme-toggle {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  font-size: 19px;
  padding: 0;
}
.theme-toggle:hover { transform: translateY(-1px); }

:root[data-theme="light"] {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface2: #eef2f7;
  --line: #d9e1ec;
  --text: #172033;
  --muted: #69768a;
  --shadow: 0 16px 38px rgba(34, 50, 75, 0.12);
}

:root[data-theme="light"] body { background: var(--bg); color: var(--text); }
:root[data-theme="light"] .sidebar { background: #ffffff; border-right-color: var(--line); }
:root[data-theme="light"] .side-brand { border-bottom-color: var(--line); }
:root[data-theme="light"] .side-brand small,
:root[data-theme="light"] .user-mini small,
:root[data-theme="light"] .top-subtitle,
:root[data-theme="light"] .date-pill { color: var(--muted); }
:root[data-theme="light"] .nav-item { color: #536176; }
:root[data-theme="light"] .nav-item:hover { background: #eef2f7; color: #172033; }
:root[data-theme="light"] .nav-item.active { color: #fff; }
:root[data-theme="light"] .side-footer { border-top-color: var(--line); }
:root[data-theme="light"] .logout { background: #eef2f7; color: #374357; }
:root[data-theme="light"] .logout:hover { background: #e3e9f1; }
:root[data-theme="light"] .topbar { background: rgba(255,255,255,.9); border-bottom-color: var(--line); }
:root[data-theme="light"] .panel,
:root[data-theme="light"] .form-panel,
:root[data-theme="light"] .stat-card { background: #ffffff; border-color: var(--line); box-shadow: var(--shadow); }
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea { background: #ffffff; color: #172033; border-color: #cfd8e5; }
:root[data-theme="light"] input[readonly],
:root[data-theme="light"] textarea[readonly] { background: #f1f5f9; color: #334155; }
:root[data-theme="light"] .input-wrap { background: #ffffff; border-color: #cfd8e5; }
:root[data-theme="light"] .login-screen { background: radial-gradient(circle at 50% 15%, rgba(117,71,245,.10), transparent 34%), linear-gradient(145deg,#eef3f9,#ffffff); }
:root[data-theme="light"] .login-card { background: rgba(255,255,255,.96); border-color: #d7e0eb; }
:root[data-theme="light"] .login-card label { color: #334155; }
:root[data-theme="light"] .table-wrap,
:root[data-theme="light"] table { background: #ffffff; color: #172033; }
:root[data-theme="light"] th { color: #526176; }
:root[data-theme="light"] td,
:root[data-theme="light"] th { border-color: #e2e8f0; }
:root[data-theme="light"] .history-choice,
:root[data-theme="light"] .page-btn { background: #ffffff; color: #334155; border-color: #d3dce8; }
:root[data-theme="light"] .history-hint { background: #f8fafc; border-color: #cfd8e5; color: #66758a; }
:root[data-theme="light"] .menu-toggle { background: #eef2f7; border-color: #d5deea; color: #172033; }
:root[data-theme="light"] .history-pagination { background: transparent; }

@media (max-width: 780px) {
  .theme-toggle { width: 40px; height: 40px; flex: 0 0 40px; }
  .date-pill { display: none; }
  :root[data-theme="light"] .history-pagination { background: #ffffff; }
}


/* ==========================================================================
   FORMULARIO DE REGISTRO DE COMBUSTIBLE - ORDEN Y FECHA/HORA
   ========================================================================== */
.fuel-form-grid {
  align-items: start;
}

.datetime-box {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface2);
}

.datetime-title {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
}

.datetime-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.datetime-fields label {
  margin-bottom: 7px;
}

.datetime-fields input {
  width: 100%;
}

/* Los campos internos continúan presentes para cálculos, guardado y reportes. */
.fuel-origin-field {
  margin-top: 2px;
}

@media (max-width: 780px) {
  .datetime-fields {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .datetime-box {
    padding: 13px;
  }
  .datetime-fields {
    grid-template-columns: 1fr;
  }
}

/* ========================================================================== 
   AJUSTES SOLICITADOS 2026-09-02
   ========================================================================== */

/* Registro de combustible: editable = naranja / automático = verde. */
#fuelForm .field input:not([readonly]),
#fuelForm .field select,
#fuelForm .field textarea {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.72);
  color: var(--text);
}

#fuelForm .field input[readonly] {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.62);
  color: var(--text);
}

#fuelForm .field input:not([readonly]):focus,
#fuelForm .field select:focus,
#fuelForm .field textarea:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}

#fuelForm .field input[readonly]:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

/* El medidor queda visualmente centrado y usa el verde del gráfico de consumo. */
.diesel-gauge-card { text-align: center; }
.diesel-gauge-card .gauge-header {
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.gauge-fill {
  stroke: #38ef7d;
  filter: drop-shadow(0 0 6px rgba(56, 239, 125, 0.48));
}

/* Dashboard: bordes un poco más claros y textos adaptables a ambos temas. */
#page-dashboard .stat-card,
#page-dashboard .panel {
  border-color: #3c4960;
}

#page-dashboard .stat-title {
  display: block;
  color: var(--text);
  font-size: clamp(0.88rem, 0.72rem + 0.35vw, 1.08rem);
  font-weight: 700;
  line-height: 1.25;
}

#page-dashboard .stat-card strong {
  color: var(--text);
  font-size: clamp(1.25rem, 1.05rem + 0.6vw, 1.55rem);
}

#page-dashboard .panel-head h3,
#page-dashboard .kpi-title,
#page-dashboard td {
  color: var(--text);
}

#page-dashboard .panel-head small,
#page-dashboard .stat-card small:not(.stat-title),
#page-dashboard .rank-info small,
#page-dashboard .trend:not(.up) {
  color: var(--muted);
}

:root[data-theme="light"] #fuelForm .field input:not([readonly]),
:root[data-theme="light"] #fuelForm .field select,
:root[data-theme="light"] #fuelForm .field textarea {
  background: #fff7e6;
  border-color: #f0a62a;
  color: #172033;
}

:root[data-theme="light"] #fuelForm .field input[readonly] {
  background: #eaf8ee;
  border-color: #70c98b;
  color: #173322;
}

:root[data-theme="light"] #page-dashboard .stat-card,
:root[data-theme="light"] #page-dashboard .panel {
  border-color: #c5cfdb;
}

@media (max-width: 780px) {
  #page-dashboard .stat-card { padding: 16px; }
  #page-dashboard .stat-title { font-size: clamp(.84rem, 3.7vw, 1rem); }
  #page-dashboard .stat-card strong { font-size: clamp(1.18rem, 5.2vw, 1.45rem); }
}


/* ==========================================================================
   AJUSTES SOLICITADOS - LEGIBILIDAD Y ENCABEZADOS
   ========================================================================== */

/* Los textos de clasificación y descripciones repetidas de los formularios
   ya no se muestran: el nombre del módulo es suficiente. */
.page-heading .eyebrow,
.page-heading p {
  display: none;
}

/* MODO CLARO: textos principales y subtítulos con contraste alto. */
:root[data-theme="light"] {
  --text: #111827;
  --muted: #475569;
}

:root[data-theme="light"] .field label,
:root[data-theme="light"] .field label span,
:root[data-theme="light"] .datetime-title,
:root[data-theme="light"] .section-title h3,
:root[data-theme="light"] .section-title small,
:root[data-theme="light"] .permission b,
:root[data-theme="light"] .permission small {
  color: #111827;
}

:root[data-theme="light"] .section-title small,
:root[data-theme="light"] .permission small,
:root[data-theme="light"] .top-subtitle,
:root[data-theme="light"] .date-pill {
  color: #475569;
}

/* MODO OSCURO: mantener los textos claramente blancos/legibles. */
:root:not([data-theme="light"]) .field label,
:root:not([data-theme="light"]) .section-title h3,
:root:not([data-theme="light"]) .section-title small,
:root:not([data-theme="light"]) .permission b,
:root:not([data-theme="light"]) .permission small {
  color: #f5f7fb;
}


/* ========================================================================== 
   AJUSTES FINALES 2026-09-02 — DASHBOARD, MODO CLARO Y FORMULARIO
   ========================================================================== */

/* Botones principales en verde para mantener la identidad visual del sistema. */
.primary-btn,
.btn-refill,
.btn-action-edit {
  background: linear-gradient(135deg, #11998e, #22c55e) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.22);
}

.primary-btn:hover,
.btn-refill:hover,
.btn-action-edit:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 24px rgba(22, 163, 74, 0.28);
}

/* El botón de eliminar conserva rojo para que la acción peligrosa sea clara. */
.btn-action-delete {
  background: #b91c1c !important;
  color: #fff !important;
  border-color: #b91c1c !important;
}

/* Medidor: mismo acabado verde del modo oscuro en ambos temas. */
.diesel-gauge-card {
  justify-content: center;
  align-items: center;
}
.diesel-gauge-card .gauge-wrapper {
  margin: 8px auto 12px;
}
.diesel-gauge-card .gauge-bg {
  stroke: rgba(148, 163, 184, 0.20);
}
.diesel-gauge-card .gauge-fill {
  stroke: #38ef7d !important;
  filter: drop-shadow(0 0 7px rgba(56, 239, 125, 0.50)) !important;
}
.diesel-gauge-card .gauge-value-display,
.diesel-gauge-card .gauge-capacity {
  color: var(--text) !important;
}

/* Contraste fuerte en modo claro: evita textos blancos sobre fondo blanco. */
:root[data-theme="light"] body,
:root[data-theme="light"] .content,
:root[data-theme="light"] .page,
:root[data-theme="light"] .welcome h2,
:root[data-theme="light"] .page-heading h2,
:root[data-theme="light"] .panel-head h3,
:root[data-theme="light"] .stat-card strong,
:root[data-theme="light"] .stat-card .stat-title,
:root[data-theme="light"] .field label,
:root[data-theme="light"] .section-title h3,
:root[data-theme="light"] .datetime-title {
  color: #111827 !important;
}

:root[data-theme="light"] .welcome p,
:root[data-theme="light"] .page-heading p,
:root[data-theme="light"] .panel-head small,
:root[data-theme="light"] .stat-card small,
:root[data-theme="light"] .trend,
:root[data-theme="light"] .rank,
:root[data-theme="light"] .rank-info small,
:root[data-theme="light"] .date-pill,
:root[data-theme="light"] .top-subtitle,
:root[data-theme="light"] .section-title small,
:root[data-theme="light"] .field label span {
  color: #475569 !important;
}

/* Tablas de administración: texto visible y bordes definidos en modo claro. */
:root[data-theme="light"] table,
:root[data-theme="light"] .table-wrap {
  color: #111827 !important;
  background: #ffffff !important;
}
:root[data-theme="light"] th {
  color: #334155 !important;
  border-bottom-color: #cbd5e1 !important;
}
:root[data-theme="light"] td {
  color: #334155 !important;
  border-bottom-color: #dbe3ec !important;
}
:root[data-theme="light"] td b {
  color: #172033 !important;
}
:root[data-theme="light"] tbody tr:hover {
  background: #f1f5f9 !important;
}

/* Buscadores y controles en modo claro. */
:root[data-theme="light"] .search {
  background: #ffffff !important;
  border-color: #c5d0df !important;
}
:root[data-theme="light"] .search input {
  color: #111827 !important;
  background: transparent !important;
}
:root[data-theme="light"] .search input::placeholder {
  color: #64748b !important;
  opacity: 1;
}
:root[data-theme="light"] input::placeholder,
:root[data-theme="light"] textarea::placeholder,
:root[data-theme="light"] select::placeholder {
  color: #64748b !important;
  opacity: 1;
}

/* Iconos y botones secundarios visibles en ambos temas. */
:root[data-theme="light"] .stat-icon,
:root[data-theme="light"] .filter-icon,
:root[data-theme="light"] .section-title > span {
  color: #0f172a !important;
}
:root[data-theme="light"] .theme-toggle {
  color: #111827 !important;
  background: #eef2f7 !important;
  border-color: #cbd5e1 !important;
}
:root[data-theme="light"] .secondary-btn {
  background: #f0fdf4 !important;
  color: #166534 !important;
  border-color: #86efac !important;
}
:root[data-theme="light"] .text-btn {
  color: #15803d !important;
}

/* Estados de las tablas con contraste alto. */
:root[data-theme="light"] .status.ok,
:root[data-theme="light"] .status-pill.green {
  background: #dcfce7 !important;
  color: #166534 !important;
}
:root[data-theme="light"] .status.warn,
:root[data-theme="light"] .status-pill.red {
  background: #fef3c7 !important;
  color: #92400e !important;
}

/* Formularios: sin textos de ayuda dentro de las casillas; quedan listas para escribir. */
#fuelForm input:not([readonly]),
#fuelForm select,
#fuelForm textarea {
  min-height: 46px;
}
#fuelForm input:not([readonly]),
#fuelForm select,
#fuelForm textarea {
  background: rgba(245, 158, 11, 0.16) !important;
  border-color: rgba(245, 158, 11, 0.72) !important;
}
#fuelForm input[readonly] {
  background: rgba(34, 197, 94, 0.14) !important;
  border-color: rgba(34, 197, 94, 0.62) !important;
}
:root[data-theme="light"] #fuelForm input:not([readonly]),
:root[data-theme="light"] #fuelForm select,
:root[data-theme="light"] #fuelForm textarea {
  color: #111827 !important;
  background: #fff7e6 !important;
  border-color: #e6a23c !important;
}
:root[data-theme="light"] #fuelForm input[readonly] {
  color: #14532d !important;
  background: #eaf8ee !important;
  border-color: #70c98b !important;
}

/* Todas las etiquetas del formulario quedan visibles en modo claro. */
:root[data-theme="light"] #fuelForm label,
:root[data-theme="light"] #fuelForm .datetime-title {
  color: #111827 !important;
}

/* La tarjeta de estadísticas mantiene el contraste de sus iconos. */
:root[data-theme="light"] #page-dashboard .stat-icon {
  color: #111827 !important;
  border: 1px solid #dbe3ec;
}
:root[data-theme="light"] #page-dashboard .bar-label,
:root[data-theme="light"] #page-dashboard .bar-col small {
  color: #475569 !important;
}
:root[data-theme="light"] #page-dashboard .bar-wrapper {
  background: #e2e8f0 !important;
}
:root[data-theme="light"] #page-dashboard .badge {
  background: #dcfce7 !important;
  color: #166534 !important;
}

/* El título del medidor y el estado siempre contrastan. */
:root[data-theme="light"] .diesel-gauge-card .kpi-title {
  color: #111827 !important;
}
:root[data-theme="light"] .diesel-gauge-card .status-badge {
  background: #dcfce7 !important;
  color: #166534 !important;
}

/* ========================================================================== 
   CORRECCION 2026-09-03 — PERMISOS EN MODO CLARO
   ========================================================================== */
/* En modo claro las tarjetas de permisos deben usar fondo claro y textos oscuros. */
:root[data-theme="light"] #page-permisos .permission-panel {
  background: #ffffff !important;
  border-color: #d7e0eb !important;
}

:root[data-theme="light"] #page-permisos .permission {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #111827 !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

:root[data-theme="light"] #page-permisos .permission b {
  color: #111827 !important;
}

:root[data-theme="light"] #page-permisos .permission small {
  color: #475569 !important;
}

:root[data-theme="light"] #page-permisos .permission input[type="checkbox"] {
  opacity: 1 !important;
  filter: none !important;
}

:root[data-theme="light"] #page-permisos .form-actions,
:root[data-theme="light"] #page-permisos .form-actions label {
  color: #111827 !important;
}

:root[data-theme="light"] #page-permisos #permUser,
:root[data-theme="light"] #page-permisos #permRole {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: #cbd5e1 !important;
}

/* Administración: controles y legibilidad en modo claro */
.rows-control{display:flex;align-items:center;gap:8px;font-weight:700}.rows-control select{min-width:82px;padding:9px 12px;border:1px solid var(--border);border-radius:10px;background:var(--panel);color:var(--text)}
.table-footer{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:14px 0 0}.pagination{display:flex;align-items:center;gap:8px}.page-info{font-size:.9rem;opacity:.8}
:root[data-theme="light"] .btn-action-edit{background:#168a5b !important;color:#fff !important;text-shadow:none !important;opacity:1 !important}
:root[data-theme="light"] .btn-action-edit *{color:#fff !important;opacity:1 !important}
@media(max-width:700px){.toolbar,.table-footer{align-items:flex-start;flex-direction:column}.rows-control{width:100%;justify-content:space-between}}


/* ==========================================================================
   CORRECCION 2026-09-04 — EDITAR CHOFER Y ADMINISTRACION
   ========================================================================== */

/* En Editar Chofer solo deben aparecer: Código, Nombre y Estado. */
#modalEditar .hidden {
  display: none !important;
}

/* Etiquetas/subtítulos visibles y con alto contraste en ambos temas. */
#modalEditar .field > label,
#page-adminChoferes .rows-control label,
#page-adminUnidades .rows-control label {
  color: #e5e7eb !important;
  font-weight: 800 !important;
  opacity: 1 !important;
}

#page-adminChoferes .panel,
#page-adminUnidades .panel {
  color: #e5e7eb;
}

#page-adminChoferes th,
#page-adminUnidades th {
  color: #f8fafc !important;
  font-weight: 800 !important;
}

#page-adminChoferes td,
#page-adminUnidades td {
  color: #e5e7eb;
}

/* Modo claro: textos negros/oscuros para que ningún subtítulo desaparezca. */
:root[data-theme="light"] #modalEditar .field > label,
:root[data-theme="light"] #page-adminChoferes .rows-control label,
:root[data-theme="light"] #page-adminUnidades .rows-control label,
:root[data-theme="light"] #page-adminChoferes th,
:root[data-theme="light"] #page-adminUnidades th {
  color: #111827 !important;
  opacity: 1 !important;
  text-shadow: none !important;
}

:root[data-theme="light"] #page-adminChoferes td,
:root[data-theme="light"] #page-adminUnidades td {
  color: #1f2937 !important;
}

:root[data-theme="light"] #modalEditar .edit-modal-head h3 {
  color: #111827 !important;
}

:root[data-theme="light"] #modalEditar .field input,
:root[data-theme="light"] #modalEditar .field select {
  color: #111827 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

:root[data-theme="light"] #page-adminChoferes .search input,
:root[data-theme="light"] #page-adminUnidades .search input,
:root[data-theme="light"] #page-adminChoferes .rows-control select,
:root[data-theme="light"] #page-adminUnidades .rows-control select {
  color: #111827 !important;
  background: #ffffff !important;
}

:root[data-theme="light"] #page-adminChoferes .search,
:root[data-theme="light"] #page-adminUnidades .search {
  color: #111827 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}


/* ==========================================================================
   CORRECCION FINAL 2026-09-04 — EDITAR CHOFER RESPONSIVO + CONTRASTE
   ========================================================================== */

/* El modal de edición usa siempre una estructura cómoda para teclado/táctil. */
#modalEditar {
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#modalEditar .edit-modal-card {
  box-sizing: border-box;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#modalEditar .field {
  width: 100%;
}

#modalEditar .field > label {
  display: block !important;
  margin-bottom: 7px;
  line-height: 1.3;
  font-size: 13px;
}

#modalEditar input,
#modalEditar select {
  width: 100%;
  min-height: 46px;
  box-sizing: border-box;
  font-size: 16px; /* evita zoom automático en iPhone */
}

#modalEditar .edit-modal-actions {
  position: sticky;
  bottom: 0;
  background: inherit;
  z-index: 2;
}

#modalEditar .edit-modal-actions button {
  min-height: 46px;
  touch-action: manipulation;
}

/* Modo oscuro: títulos, subtítulos y etiquetas siempre visibles. */
:root:not([data-theme="light"]) #modalEditar .edit-modal-card {
  background: #111827 !important;
  color: #f8fafc !important;
}

:root:not([data-theme="light"]) #modalEditar .field > label,
:root:not([data-theme="light"]) #modalEditar .edit-modal-head h3 {
  color: #f8fafc !important;
}

/* Modo claro: el formulario deja de parecer un formulario oscuro y mantiene
   exactamente la misma jerarquía visual, con contraste alto. */
:root[data-theme="light"] #modalEditar {
  background: rgba(15, 23, 42, 0.45) !important;
}

:root[data-theme="light"] #modalEditar .edit-modal-card {
  background: #ffffff !important;
  color: #111827 !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24) !important;
}

:root[data-theme="light"] #modalEditar .edit-modal-head {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 12px;
}

:root[data-theme="light"] #modalEditar .edit-modal-head h3,
:root[data-theme="light"] #modalEditar .field > label {
  color: #111827 !important;
  font-weight: 800 !important;
  opacity: 1 !important;
}

:root[data-theme="light"] #modalEditar .field > label::after {
  content: "";
}

:root[data-theme="light"] #modalEditar input,
:root[data-theme="light"] #modalEditar select {
  background: #ffffff !important;
  color: #111827 !important;
  border: 1px solid #b8c4d4 !important;
}

:root[data-theme="light"] #modalEditar input:focus,
:root[data-theme="light"] #modalEditar select:focus {
  outline: none;
  border-color: #168a5b !important;
  box-shadow: 0 0 0 3px rgba(22, 138, 91, 0.13) !important;
}

:root[data-theme="light"] #modalEditar .edit-close {
  color: #334155 !important;
}

:root[data-theme="light"] #modalEditar .edit-modal-actions {
  background: #ffffff !important;
  border-top-color: #e2e8f0 !important;
}

/* Administración: encabezados, subtítulos de controles y textos visibles. */
#page-adminChoferes .toolbar,
#page-adminUnidades .toolbar {
  gap: 12px;
}

#page-adminChoferes .rows-control label,
#page-adminUnidades .rows-control label {
  display: inline-block !important;
  font-size: 13px;
  line-height: 1.3;
  opacity: 1 !important;
}

@media (max-width: 700px) {
  /* El listado sigue siendo desplazable horizontalmente sin romper la página. */
  #page-adminChoferes .table-wrap,
  #page-adminUnidades .table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #page-adminChoferes table,
  #page-adminUnidades table {
    min-width: 620px;
  }

  /* Botón Editar cómodo para tocar desde el teléfono. */
  #page-adminChoferes .btn-action-edit,
  #page-adminUnidades .btn-action-edit,
  #page-adminChoferes .btn-action-delete,
  #page-adminUnidades .btn-action-delete {
    min-height: 42px;
    min-width: 82px;
    padding: 9px 12px;
    touch-action: manipulation;
  }

  /* Modal: ocupa la pantalla disponible, sin cortar Código/Nombre/Estado. */
  #modalEditar {
    align-items: flex-start !important;
    justify-content: center !important;
    padding: 10px !important;
  }

  #modalEditar .edit-modal-card {
    width: 100% !important;
    max-width: 520px !important;
    max-height: calc(100dvh - 20px) !important;
    margin: 0 auto;
    padding: 18px !important;
    border-radius: 16px !important;
  }

  #modalEditar .edit-modal-head {
    margin-bottom: 15px;
  }

  #modalEditar .edit-modal-head h3 {
    font-size: 18px;
  }

  #modalEditar form {
    width: 100%;
  }

  #modalEditar .field {
    margin-bottom: 13px;
  }

  #modalEditar .edit-modal-actions {
    flex-direction: column-reverse;
    gap: 9px;
    margin-top: 16px;
    padding-top: 14px;
  }

  #modalEditar .edit-modal-actions button {
    width: 100%;
  }
}

@media (max-width: 380px) {
  #modalEditar {
    padding: 6px !important;
  }

  #modalEditar .edit-modal-card {
    max-height: calc(100dvh - 12px) !important;
    padding: 15px !important;
    border-radius: 14px !important;
  }

  #modalEditar .field > label {
    font-size: 12px;
  }
}
