:root {
  --navy: #050510;
  --yellow: #ffe500;
  --sidebar: #050510;
  --sidebar-hover: #16162a;
  --primary: #050510;
  --page: #f3f4f8;
  --card: #ffffff;
  --text: #12122a;
  --muted: #6b6b82;
  --bs-primary: #050510;
  --bs-primary-rgb: 5, 5, 16;
}

html, body {
  height: 100%;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
}

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

.app-sidebar {
  width: 228px;
  background: var(--sidebar);
  color: #fff;
  flex-shrink: 0;
  padding: 1rem 0.75rem;
  border-right: 1px solid #16162a;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 0.35rem 1rem;
  border-bottom: 1px solid #1c1c32;
  margin-bottom: 0.85rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}

.brand-wordmark {
  height: 26px;
  width: auto;
  max-width: 132px;
  display: block;
  object-fit: contain;
}

.side-nav .nav-link,
.side-nav span.nav-link {
  color: #c8c8d8;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.side-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.side-nav .nav-link.active {
  background: rgba(255, 229, 0, 0.14);
  color: var(--yellow);
  font-weight: 600;
}

.side-nav .nav-link.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  background: #fff;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #dbe4f0;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.page-title h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 600;
}

.page-title i { color: var(--navy); font-size: 1.25rem; }

.btn-primary {
  --bs-btn-bg: var(--navy);
  --bs-btn-border-color: var(--navy);
  --bs-btn-hover-bg: var(--sidebar-hover);
  --bs-btn-hover-border-color: var(--sidebar-hover);
  --bs-btn-active-bg: var(--sidebar-hover);
  --bs-btn-active-border-color: var(--sidebar-hover);
  --bs-btn-disabled-bg: var(--navy);
  --bs-btn-disabled-border-color: var(--navy);
  background-color: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background-color: var(--sidebar-hover);
  border-color: var(--sidebar-hover);
  color: #fff;
}

.form-control:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 0.2rem rgba(5, 5, 16, 0.18);
}

.form-check-input:checked {
  background-color: var(--navy);
  border-color: var(--navy);
}

.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(5, 5, 16, 0.18);
}

.btn-outline-primary {
  --bs-btn-color: var(--navy);
  --bs-btn-border-color: var(--navy);
  --bs-btn-hover-bg: var(--navy);
  --bs-btn-hover-border-color: var(--navy);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--navy);
  --bs-btn-active-border-color: var(--navy);
  --bs-btn-active-color: #fff;
  --bs-btn-focus-shadow-rgb: 5, 5, 16;
  color: var(--navy);
  border-color: var(--navy);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
  background-color: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

a {
  color: var(--navy);
}

a:hover {
  color: var(--sidebar-hover);
}

.text-primary {
  color: var(--navy) !important;
}

.page-link {
  color: var(--navy);
}

.page-link:hover {
  color: var(--navy);
  background-color: #ececf2;
}

.page-item.active .page-link {
  background-color: var(--navy);
  border-color: var(--navy);
}

.nav-tabs .nav-link {
  color: var(--muted);
}

.nav-tabs .nav-link.active {
  color: var(--navy);
  border-color: #d7e2ef #d7e2ef #fff;
  font-weight: 600;
}

.user-box .btn {
  color: var(--text);
}

.sync-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 3000;
  pointer-events: none;
  opacity: 0;
  background: rgba(5, 5, 16, 0.08);
  overflow: hidden;
  transition: opacity 0.15s ease;
}

body.is-syncing .sync-progress {
  opacity: 1;
}

.sync-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffe500, #ffc400 70%, #fff6a8);
  border-radius: 0 2px 2px 0;
  transition: width 0.28s linear;
}

.sync-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.sync-bar .btn {
  white-space: nowrap;
}

.sync-bar-status {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 7.5rem;
}

.sync-mini-track {
  display: none;
  height: 4px;
  width: 100%;
  max-width: 8.5rem;
  background: #e6e8f0;
  border-radius: 99px;
  overflow: hidden;
}

body.is-syncing .sync-mini-track {
  display: block;
}

.sync-mini-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--yellow);
  transition: width 0.28s linear;
}

.sync-bar-meta {
  font-size: 11px;
  color: var(--muted);
  max-width: 9.5rem;
  line-height: 1.2;
}

body.is-syncing .sync-bar-icon {
  animation: sync-spin 0.8s linear infinite;
}

body.is-syncing .sync-bar-meta {
  color: #3a3a52;
  font-weight: 600;
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 767.98px) {
  .sync-bar-meta { display: none; }
  .sync-bar .btn span { display: none; }
  .sync-bar-status { min-width: 0; }
  body.is-syncing .sync-mini-track { display: none; }
}

.app-content {
  padding: 1rem 1.25rem 2rem;
}

.validation-summary-valid {
  display: none !important;
}

.card-panel {
  background: var(--card);
  border: 1px solid #d7e2ef;
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(16, 42, 80, 0.04);
}

.section-label {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.badge-estado {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border-radius: 0;
  padding: 0;
  font-weight: 600;
  font-size: 12.5px;
  line-height: 1.2;
}

.badge-estado::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-abierto,
.badge-cerrada,
.badge-porlinea,
.badge-estcont-ok {
  color: var(--navy);
}

.badge-pendiente,
.badge-masiva,
.badge-preliq,
.badge-estcont-pend {
  color: #8a7600;
}

.badge-cerrado {
  color: var(--muted);
}

.badge-rechazada,
.badge-estcont-no {
  color: #8a3038;
}

.table-app {
  font-size: 13px;
}

.table-app thead th {
  background: #f3f7fc;
  color: #4a5b70;
  font-weight: 600;
  white-space: nowrap;
}

#previewMasiva th,
#previewMasiva td {
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

#previewMasiva th:nth-child(4),
#previewMasiva td:nth-child(4),
#previewMasiva th:nth-child(6),
#previewMasiva td:nth-child(6),
#previewMasiva th:nth-child(8),
#previewMasiva td:nth-child(8) {
  border-left: 1px solid #d7e2ef;
}

#previewMasiva th:nth-child(5),
#previewMasiva td:nth-child(5),
#previewMasiva th:nth-child(7),
#previewMasiva td:nth-child(7),
#previewMasiva th:nth-child(9),
#previewMasiva td:nth-child(9) {
  background: #eef3ff;
}

.table-cambios-lineas thead th {
  text-align: center;
  vertical-align: middle;
}

.table-cambios-lineas tbody td {
  vertical-align: middle;
}

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

.tipo-card {
  border: 1px solid #d7e2ef;
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  height: 100%;
}

.tipo-card.active {
  border-color: var(--yellow);
  background: #fffce6;
  box-shadow: 0 0 0 1px var(--yellow);
}

.dropzone {
  border: 1px dashed #8aa4c4;
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  background: #f8fbff;
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #eef5ff;
}

.sustento-card {
  border: 1px solid #d7e2ef;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.sustento-thumb {
  height: 140px;
  width: 100%;
  object-fit: contain;
  background: #f4f7fb;
  display: block;
}

.sustento-thumb-pdf {
  height: 140px;
  width: 100%;
  border: 0;
  background: #f4f7fb;
  pointer-events: none;
}

.preview-frame {
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: #f4f7fb;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: #fff;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--sidebar);
  color: #fff;
  border-radius: 18px;
  padding: 2rem 1.75rem 1.5rem;
  box-shadow: 0 18px 50px rgba(5, 5, 16, 0.22);
  border-top: 6px solid var(--yellow);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.35rem;
}

.login-isologo {
  width: 84px;
  height: 84px;
  object-fit: contain;
  margin-bottom: 0.55rem;
}

.login-wordmark {
  width: auto;
  height: 34px;
  max-width: 200px;
  object-fit: contain;
  margin-bottom: 0.35rem;
}

.login-brand small,
.login-card .form-label,
.login-card .form-check-label {
  color: rgba(255, 255, 255, 0.88);
}

.login-card .form-control {
  background: #fff;
  color: var(--navy);
  border-color: #d8d8ea;
}

.login-card .form-control:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 0.2rem rgba(255, 229, 0, 0.28);
}

.login-card .form-check-input:checked {
  background-color: var(--yellow);
  border-color: var(--yellow);
}

.login-submit {
  background: var(--yellow);
  border: 1px solid var(--yellow);
  color: var(--navy);
  font-weight: 700;
  padding: 0.55rem 1rem;
}

.login-submit:hover,
.login-submit:focus {
  background: #ffe96a;
  border-color: #ffe96a;
  color: var(--navy);
}

.login-hint {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  margin: 1rem 0 0;
}

.login-card .text-danger {
  color: #ffc4c4;
}

.detalle-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.detalle-docnum {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.detalle-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem 1.25rem;
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px solid #e6eef6;
}

.detalle-kv span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.detalle-kv strong {
  font-weight: 600;
}

.detalle-motivo {
  margin-top: 1rem;
  background: #f5f8fc;
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.detalle-motivo span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.detalle-motivo p {
  margin: 0;
  line-height: 1.45;
}

.detalle-rechazo {
  margin-top: 0.75rem;
  background: #fff4f4;
  border: 1px solid #f0c8c8;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  color: #8a2424;
}

.detalle-rechazo span {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.detalle-rechazo p {
  margin: 0;
  line-height: 1.45;
}

.detalle-resolver {
  border-color: #c5d8f5;
  background: #f7faff;
}

.detalle-tabs {
  gap: 0;
  border-bottom: 1px solid #d7e2ef;
}

.detalle-tabs .nav-link {
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  padding: 0.55rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.detalle-tabs .nav-link:hover {
  color: var(--navy);
  border-color: transparent;
  isolation: isolate;
}

.detalle-tabs .nav-link.active {
  background: #fff;
  color: var(--navy);
  border-color: #d7e2ef #d7e2ef #fff;
  font-weight: 600;
}

.detalle-count {
  display: inline-flex;
  min-width: 1.25rem;
  height: 1.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #d7e2ef;
  color: #4a5b70;
  font-size: 0.7rem;
  font-weight: 700;
}

.detalle-tabs .nav-link.active .detalle-count {
  background: var(--navy);
  color: #fff;
}

.detalle-linea {
  display: inline-flex;
  min-width: 1.6rem;
  justify-content: center;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: #eef3f9;
  font-weight: 600;
  color: #3d5168;
}

.detalle-nuevo {
  display: inline-block;
  background: #e8f1ff;
  color: var(--navy);
  font-weight: 600;
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
}

.detalle-doc {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid #d7e2ef;
  border-radius: 10px;
  padding: 0.75rem;
  background: #fff;
  height: 100%;
}

.detalle-doc-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  background: #eef5ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.detalle-doc-body {
  min-width: 0;
  flex: 1;
}

.detalle-doc-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.detalle-empty {
  color: var(--muted);
  padding: 1.5rem 0.5rem;
  text-align: center;
}

.detalle-timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.85rem;
  border-left: 2px solid #d7e2ef;
}

.detalle-timeline li {
  position: relative;
  padding: 0 0 1.1rem 1.1rem;
}

.detalle-timeline li:last-child {
  padding-bottom: 0;
}

.detalle-timeline-dot {
  position: absolute;
  left: -0.95rem;
  top: 0.3rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #c5d8f5;
}

.sidebar-backdrop {
  display: none;
}

.disp-wrap {
  max-height: calc(100vh - 280px);
  overflow: auto;
}

.disp-grid {
  border-collapse: separate;
  border-spacing: 0;
}

.disp-grid th,
.disp-grid td {
  border: 1px solid #e6eef6;
}

.disp-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.disp-placa {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
  min-width: 92px;
  font-weight: 600;
}

.disp-grid thead th.disp-placa {
  z-index: 4;
  background: #f3f7fc;
}

.disp-fecha {
  min-width: 132px;
  text-align: center;
  font-size: 11px;
  line-height: 1.15;
  padding: 0.35rem 0.4rem !important;
}

.disp-fecha span {
  color: #8a9bb0;
  font-weight: 500;
}

.disp-cell {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  min-width: 132px;
  max-width: 220px;
  padding: 0.35rem 0.45rem !important;
  cursor: default;
  white-space: normal;
  line-height: 1.25;
  vertical-align: top;
}

.disp-ok { background: #c8f0d4; color: #1b6b38; }
.disp-c { background: #ffe9a8; color: #8a6d00; }
.disp-ot { background: #ffd8b5; color: #9a4b12; }
.disp-und { background: #ffd0d0; color: #a32020; }
.disp-otro { background: #e2e8f0; color: #334155; }
.disp-na { background: #f4f7fb; color: #8a9bb0; }

.disp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  font-size: 12px;
  color: var(--muted);
}

.disp-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 0.3rem;
  vertical-align: -1px;
  border: 1px solid #d7e2ef;
}

.disp-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1rem;
}

.disp-pager-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.disp-pager .pagination .page-link {
  color: var(--navy);
  min-width: 2rem;
  text-align: center;
}

.disp-pager .pagination .page-item.active .page-link {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.disp-pager-goto {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.35rem;
}

.disp-pager-goto input[type="number"] {
  width: 4.4rem;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    z-index: 1040;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1030;
  }
}
