* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: #e7ebf2;
  color: #0f172a;
  color-scheme: light;
  overflow-x: hidden;
}
body.app-loading .app-shell {
  visibility: hidden;
}
body.app-loading {
  overflow: hidden;
}
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}
body.sidebar-collapsed .app-shell {
  grid-template-columns: 72px 1fr;
}
.content,
.view {
  min-width: 0;
}
.content {
  background: linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
}
.view {
  color: #0f172a;
}
.auth-mode .app-shell {
  grid-template-columns: 1fr;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(34, 197, 94, .11), transparent 34%),
    linear-gradient(180deg, rgba(15, 23, 42, .98), rgba(8, 15, 30, .98));
  backdrop-filter: blur(16px);
  padding: 18px 16px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: width .22s ease, padding .22s ease, box-shadow .22s ease;
}
.sidebar-icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 16px;
}
body.sidebar-collapsed .sidebar-head {
  justify-content: center;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sidebar-brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, #34d399, #16a34a);
  color: #052e16;
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(34, 197, 94, .2);
}
.sidebar-brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.sidebar-brand-copy strong {
  color: #f8fafc;
  font-family: Georgia, serif;
  font-size: 1.05rem;
  letter-spacing: .02em;
}
.sidebar-brand-copy small {
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .04em;
}
body.sidebar-collapsed .sidebar-brand {
  display: none;
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 78px);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .25) transparent;
}
body.sidebar-collapsed .sidebar-inner {
  display: none;
}
.menu-toggle {
  display: inline-flex;
  width: 44px;
  height: 44px;
  padding: 0;
  background: rgba(255,255,255,.035);
  border: 1px solid var(--border);
  border-radius: 13px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 4px;
  flex-direction: column;
}
.menu-toggle:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.14);
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
}
.auth-mode .sidebar {
  display: none;
}
.ctx-card label, .topbar p { color: var(--muted); }
.topbar p:empty {
  display: none;
}
.content .ctx-card,
.content .card,
.content .view,
.content .topbar {
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .06);
  color: #0f172a;
}
.ctx-card { padding: 14px; margin-bottom: 20px; display: grid; gap: 8px; }
.sidebar-summary {
  display: grid;
  gap: 6px;
  padding: 11px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(255,255,255,.05), rgba(255,255,255,.018));
}
.sidebar-company-label {
  color: #94a3b8;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sidebar-company span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-company {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: .7rem;
}
.sidebar-company i {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .1);
}
.menu {
  display: grid;
  gap: 6px;
}
.menu svg,
.sidebar-actions svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.menu .menu-item,
.menu .menu-group-toggle,
.sidebar-actions button {
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 11px;
  box-shadow: none;
  color: #aebdd0;
  background: transparent;
  font-size: .79rem;
  line-height: 1.15;
}
.menu .menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  text-align: left;
}
.menu .menu-item:hover,
.menu .menu-group-toggle:hover,
.sidebar-actions button:hover {
  color: #f8fafc;
  background: rgba(255,255,255,.055);
}
.menu .menu-item.is-active {
  color: #dcfce7;
  background: linear-gradient(90deg, rgba(34,197,94,.17), rgba(34,197,94,.055));
  border-color: rgba(34,197,94,.16);
}
.menu .menu-item.is-active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 999px;
  background: #4ade80;
  box-shadow: 0 0 12px rgba(74,222,128,.4);
}
.menu-item-primary {
  margin-bottom: 2px;
}
.menu-group {
  display: grid;
  gap: 3px;
}
.menu .menu-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  color: #71839b;
  text-transform: uppercase;
  letter-spacing: .075em;
  font-size: .65rem;
  font-weight: 750;
}
.menu-group-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.menu-group-label svg {
  width: 16px;
  height: 16px;
}
.menu-chevron {
  width: 15px !important;
  height: 15px !important;
  transition: transform .18s ease;
}
.menu-group.is-open .menu-chevron {
  transform: rotate(90deg);
}
.menu-group-items {
  position: relative;
  display: grid;
  gap: 2px;
  margin: 0 0 3px 17px;
  padding-left: 10px;
  border-left: 1px solid rgba(148,163,184,.14);
}
.menu-group:not(.is-open) .menu-group-items {
  display: none;
}
.menu-group-items .menu-item {
  min-height: 36px;
  padding: 7px 9px;
}
.menu-group-items .menu-item svg {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}
.sidebar-actions {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-account {
  position: relative;
  display: block;
}
.sidebar-account > summary {
  list-style: none;
}
.sidebar-account > summary::-webkit-details-marker {
  display: none;
}
.sidebar-account-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  color: #e2e8f0;
  cursor: pointer;
}
.sidebar-account-trigger:hover {
  background: rgba(255,255,255,.065);
  border-color: rgba(148, 163, 184, .24);
}
.sidebar-account-avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(52, 211, 153, .18), rgba(34, 197, 94, .1));
  border: 1px solid rgba(34, 197, 94, .2);
  color: #86efac;
  font-size: .82rem;
  font-weight: 800;
}
.sidebar-account-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
  text-align: left;
}
.sidebar-account-copy strong,
.sidebar-account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-account-copy strong {
  color: #f8fafc;
  font-size: .86rem;
  line-height: 1.15;
}
.sidebar-account-copy small {
  color: #94a3b8;
  font-size: .68rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.sidebar-account-chevron {
  width: 14px !important;
  height: 14px !important;
  margin-left: auto;
  color: #94a3b8;
  transition: transform .18s ease;
}
.sidebar-account[open] .sidebar-account-chevron {
  transform: rotate(90deg);
}
.sidebar-account-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 12;
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, .12);
  border-radius: 14px;
  background: rgba(15, 23, 42, .72);
  box-shadow: 0 18px 38px rgba(2, 6, 23, .32);
  backdrop-filter: blur(14px);
}
.sidebar-account-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  text-align: left;
  border-radius: 12px;
  background: transparent;
  color: #cbd5e1;
  border: 0;
}
.sidebar-account-menu button:hover {
  color: #f8fafc;
  background: rgba(255,255,255,.06);
}
.sidebar-account-menu .sidebar-logout {
  color: #fecaca;
}
.sidebar-account-menu .sidebar-logout:hover {
  color: #fee2e2;
  background: rgba(239,68,68,.09);
}
.sidebar-actions button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
}
.sidebar-actions .sidebar-logout {
  color: #fca5a5;
}
.sidebar-actions .sidebar-logout:hover {
  color: #fecaca;
  background: rgba(239,68,68,.09);
}
.menu button, button {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: #e2e8f0;
  color: #0f172a;
  cursor: pointer;
}
.content { padding: 24px; }
.view { padding: 24px; }
.auth-mode .content {
  padding: 24px;
  display: grid;
  place-items: center;
}
.auth-mode #view-login {
  width: min(100%, 560px);
  min-height: calc(100vh - 48px);
  display: grid;
  align-content: center;
  justify-items: start;
}
.auth-mode #view-app {
  display: none !important;
}
.auth-mode #view-login .card {
  width: min(100%, 420px);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  margin-bottom: 12px;
  text-align: center;
}
.content .topbar p,
.content .empty,
.content .ctx-card label {
  color: #64748b;
}
.content h1,
.content h2,
.content h3,
.content h4,
.content strong,
.content th,
.content td {
  color: #0f172a;
}
.content input,
.content select,
.content textarea {
  background: #fff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, .12);
}
.content input::placeholder,
.content textarea::placeholder {
  color: #94a3b8;
}
.content .card button,
.content .view button {
  box-shadow: none;
}
.topbar > div {
  min-width: 0;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}
.topbar-user {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.topbar-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px 0 9px;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 999px;
  background: rgba(15, 23, 42, .62);
  color: #e2e8f0;
  box-shadow: 0 10px 24px rgba(2, 6, 23, .18);
}
.topbar-user-trigger:hover {
  background: rgba(15, 23, 42, .78);
  border-color: rgba(148, 163, 184, .34);
}
.topbar-user-trigger svg,
.topbar-user-action svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.topbar-user-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(52, 211, 153, .18), rgba(34, 197, 94, .1));
  border: 1px solid rgba(34, 197, 94, .2);
  color: #86efac;
  flex: 0 0 28px;
}
.topbar-user-avatar svg {
  width: 16px;
  height: 16px;
}
.topbar-user-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
  text-align: left;
}
.topbar-user-name {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .84rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.1;
}
.topbar-user-role {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #94a3b8;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.topbar-user-chevron {
  width: 14px !important;
  height: 14px !important;
  color: #94a3b8;
  transition: transform .18s ease;
}
.topbar-user.is-open .topbar-user-chevron {
  transform: rotate(90deg);
}
.topbar-user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 220px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 16px;
  background: rgba(15, 23, 42, .98);
  box-shadow: 0 18px 38px rgba(2, 6, 23, .42);
  backdrop-filter: blur(14px);
}
.topbar-user-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
}
.topbar-user-action:hover {
  background: rgba(255,255,255,.06);
  color: #f8fafc;
}
.topbar-user-logout {
  color: #fecaca;
}
.topbar-user-logout:hover {
  background: rgba(239,68,68,.09);
  color: #fee2e2;
}
.topbar-action-btn {
  width: auto;
  min-width: 0;
  padding: 0 12px;
  min-height: 34px;
  font-size: 12px;
  line-height: 1;
  border-radius: 999px;
}
.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.15;
  letter-spacing: .01em;
}
.topbar p {
  margin: 3px 0 0;
  font-size: .84rem;
  line-height: 1.2;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.view #app-mount .app-modal .page-header {
  display: flex;
}
.fact-page-header,
.fact-section-head,
.fact-modal-head,
.fact-tercero-head,
.fact-summary-row,
.fact-tercero-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.fact-tercero-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.fact-tercero-field {
  display: grid;
  gap: 6px;
}
.fact-tercero-field > span {
  font-size: .92rem;
  color: var(--text);
}
.fact-summary-row {
  margin-top: 16px;
}
.fact-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 16px;
  align-items: start;
}
.fact-modal-main,
.fact-modal-detail {
  min-width: 0;
}
.fact-catalogo-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
}
.fact-catalogo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.fact-add-line-btn,
.fact-remove-line-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  align-self: flex-start;
  border-radius: 999px;
  line-height: 1;
}
.fact-add-product-btn {
  min-width: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  box-shadow: none;
  font-size: 13px;
  line-height: 1;
}
.fact-catalogo-results {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}
.fact-catalogo-item {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--text);
}
.fact-catalogo-item:hover {
  background: rgba(255,255,255,.09);
}
.fact-catalogo-item strong {
  font-size: .98rem;
}
.fact-catalogo-item span {
  color: var(--muted);
  font-size: .88rem;
}
.fact-form-flow {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "tercero tercero"
    "documento resumen"
    "detalle detalle";
}
.fact-flow-tercero {
  grid-area: tercero;
}
.fact-flow-documento {
  grid-area: documento;
}
.fact-flow-detalle {
  grid-area: detalle;
  color: #1e293b;
}
.fact-flow-detalle .fact-catalogo-head strong {
  color: #0f172a;
}
.fact-flow-detalle .fact-detail-meta {
  color: #475569 !important;
}
.fact-flow-detalle .fact-detail-meta > span {
  color: #475569;
}
.fact-flow-detalle .fact-detail-row {
  color: #1e293b;
}
.fact-flow-detalle .fact-catalogo-chip {
  background: rgba(15, 23, 42, .06) !important;
  color: #0f172a !important;
  border: 1px solid rgba(148, 163, 184, .35);
}
.fact-flow-detalle .fact-catalogo-chip span {
  color: #0f172a !important;
}
.fact-flow-resumen {
  grid-area: resumen;
  align-self: start;
  padding-block: 12px;
}
.fact-flow-resumen .fact-section-head.fact-summary-head {
  align-items: center;
  gap: 8px;
}
.fact-flow-resumen .fact-section-head.fact-summary-head strong {
  padding-top: 0;
}
.fact-summary-list {
  display: grid;
  gap: 0;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1;
}
.fact-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px auto;
  align-items: center;
  gap: 0;
  min-width: 0;
}
.fact-summary-row > span {
  min-width: 0;
}
.fact-summary-money {
  display: inline-flex;
  justify-content: flex-end;
  width: 92px;
  min-width: 92px;
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1;
}
.fact-summary-total {
  padding-top: 0;
  border-top: 1px solid rgba(148, 163, 184, .14);
}
.fact-summary-detraccion {
  grid-template-columns: minmax(0, 1fr) 92px auto;
}
.fact-flow-resumen .fact-section-head #fact-btn-configurar-pago {
  padding: 4px 8px;
  min-height: 30px;
  height: 30px;
  line-height: 1;
  font-size: 12px;
}
.guia-form-flow {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "tercero tercero"
    "documento documento"
    "detalle detalle";
}
.guia-flow-tercero {
  grid-area: tercero;
}
.guia-flow-documento {
  grid-area: documento;
}
.guia-flow-detalle {
  grid-area: detalle;
}
.guia-flow-documento .grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.guia-flow-documento .grid-2 > label,
.guia-flow-documento .grid-2 > div {
  min-width: 0;
}
@media (min-width: 1025px) {
  #guia-modal > .card {
    width: min(100%, 1240px);
  }
  #guia-modal .guia-flow-documento .grid-2 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  #guia-modal .guia-doc-motivo {
    grid-column: 2;
    grid-row: 2;
  }
  #guia-modal .guia-doc-modalidad {
    grid-column: 1;
    grid-row: 2;
  }
  #guia-modal .guia-doc-m1l {
    grid-column: 3;
    grid-row: 2;
    display: inline-flex;
    width: fit-content;
    justify-self: start;
    align-self: center;
    margin-top: 18px;
    gap: 3px;
  }
  #guia-modal .guia-doc-peso {
    grid-column: 4;
  }
  #guia-modal .guia-doc-bultos {
    grid-column: 4;
  }
  #guia-modal .guia-form-flow {
    gap: 12px;
    margin-top: 12px;
  }
  #guia-modal .guia-flow-tercero,
  #guia-modal .guia-flow-documento,
  #guia-modal .guia-flow-detalle {
    padding: 12px;
  }
  #guia-modal .fact-section-head {
    margin-bottom: 8px;
  }
  #guia-modal .guia-flow-documento .grid-2 {
    gap: 10px;
  }
}
.fact-tercero-search-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.fact-tercero-search-row input {
  flex: 1 1 auto;
  min-width: 0;
}
.fact-catalogo-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, .12);
  color: #cfe0ff;
  font-size: 12px;
}
.fact-detail-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.form-grid {
  display: grid;
  gap: 12px;
  max-width: 360px;
}
.password-field {
  position: relative;
  display: grid;
}
.password-field input {
  padding-right: 52px;
}
.password-field input::-ms-reveal,
.password-field input::-ms-clear {
  display: none;
}
.password-field input::-webkit-credentials-auto-fill-button,
.password-field input::-webkit-contacts-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
}
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  display: grid;
  place-items: center;
  color: #dbeafe;
  box-shadow: none;
}
.password-toggle:hover {
  background: rgba(148, 163, 184, .12);
}
.password-toggle:focus-visible {
  outline: 2px solid rgba(59, 130, 246, .55);
  outline-offset: 2px;
}
.password-toggle-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.password-toggle.is-visible .password-toggle-icon {
  transform: scale(1);
}
input, select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(36, 48, 66, .96);
  color: var(--text);
  padding: 12px 14px;
}
select {
  background-color: rgba(36, 48, 66, .96);
}
select option {
  background: #243042;
  color: #e5eefb;
}
select optgroup {
  background: #243042;
  color: #e5eefb;
}
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
}
.table-wrap th,
.table-wrap td {
  white-space: nowrap;
}
.table-wrap td:nth-child(3),
.table-wrap th:nth-child(3) {
  white-space: normal;
}
.table-wrap thead th {
  padding: 11px 12px;
  background: linear-gradient(180deg, rgba(226, 232, 240, .95), rgba(241, 245, 249, .98));
  color: #0f172a;
  border-bottom: 1px solid rgba(15, 23, 42, .12);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.table-wrap tbody tr td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  background: rgba(255,255,255,.82);
}
.table-wrap tbody tr:hover td {
  background: rgba(248, 250, 252, .98);
}
.table-wrap tbody tr:last-child td {
  border-bottom: 0;
}
.table-wrap tbody tr:nth-child(even) td {
  background: rgba(248, 250, 252, .9);
}
.table-wrap td:last-child button,
.table-wrap td[style*="justify-content:flex-end"] button,
.fact-lista-detail-actions button,
.fact-lista-wrap td:nth-child(9) button,
.fact-lista-wrap td:nth-child(8) button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(241,245,249,.92));
  color: #1e293b;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255,255,255,.72) inset;
}
.table-wrap td:last-child,
.table-wrap td[style*="justify-content:flex-end"],
.fact-lista-detail-actions,
.fact-lista-wrap td:nth-child(9),
.fact-lista-wrap td:nth-child(8) {
  text-align: left !important;
  justify-content: flex-start !important;
}
.table-wrap td:last-child,
.table-wrap td[style*="justify-content:flex-end"],
.fact-lista-detail-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.table-wrap td:last-child button:first-child,
.table-wrap td[style*="justify-content:flex-end"] button:first-child,
.fact-lista-detail-actions button:first-child {
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(241,245,249,.94));
  color: #0f172a;
}
.table-wrap td:last-child button:nth-child(2),
.table-wrap td[style*="justify-content:flex-end"] button:nth-child(2),
.fact-lista-detail-actions button:nth-child(2) {
  background: linear-gradient(180deg, rgba(239,246,255,.98), rgba(219,234,254,.9));
  border-color: rgba(59, 130, 246, .22);
  color: #1d4ed8;
}
.table-wrap td:last-child button:hover,
.table-wrap td[style*="justify-content:flex-end"] button:hover,
.fact-lista-detail-actions button:hover,
.fact-lista-wrap td:nth-child(9) button:hover,
.fact-lista-wrap td:nth-child(8) button:hover {
  background: linear-gradient(180deg, #ffffff, #e2e8f0);
  border-color: rgba(100, 116, 139, .35);
}
.table-wrap td:last-child button[style*="color:var(--danger)"],
.table-wrap td:last-child button[style*="color:#991b1b"],
.table-wrap td:last-child button:nth-child(3),
.table-wrap td[style*="justify-content:flex-end"] button:nth-child(3),
.fact-lista-detail-actions button[style*="color:var(--danger)"],
.fact-lista-detail-actions button[style*="color:#991b1b"] {
  background: linear-gradient(180deg, rgba(254, 242, 242, .98), rgba(254, 226, 226, .88));
  border-color: rgba(239, 68, 68, .28);
  color: #991b1b;
}
.table-wrap td:last-child button[style*="color:var(--danger)"]:hover,
.table-wrap td:last-child button[style*="color:#991b1b"]:hover,
.table-wrap td:last-child button:nth-child(3):hover,
.table-wrap td[style*="justify-content:flex-end"] button:nth-child(3):hover,
.fact-lista-detail-actions button[style*="color:var(--danger)"]:hover,
.fact-lista-detail-actions button[style*="color:#991b1b"]:hover {
  background: linear-gradient(180deg, rgba(254, 226, 226, .98), rgba(252, 165, 165, .82));
  border-color: rgba(239, 68, 68, .38);
}
.card,
.view,
.topbar,
.ctx-card {
  min-width: 0;
}
.fact-tercero-item {
  display: grid;
  gap: 4px;
  text-align: left;
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--text);
}
.fact-tercero-item:hover {
  background: rgba(255,255,255,.09);
}
.fact-tercero-search-row .is-selected {
  border-color: rgba(34,197,94,.38);
  background: rgba(34,197,94,.08);
  box-shadow: 0 0 0 1px rgba(34,197,94,.12) inset;
}
.cotizacion-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  gap: 6px;
  padding: 8px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: rgba(15,23,42,.98);
  box-shadow: 0 16px 40px rgba(0,0,0,.25);
}
.cotizacion-suggestion {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  color: #0f172a;
}
.cotizacion-suggestion:hover {
  background: rgba(255,255,255,.08);
}
.cotizacion-suggestion strong,
.cotizacion-suggestion span {
  color: #0f172a;
}
.cotizacion-suggestion span {
  opacity: .78;
}
.cotizacion-tercero-item {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  color: #0f172a;
}
.cotizacion-tercero-item:hover {
  background: rgba(255,255,255,.08);
}
.cotizacion-tercero-item strong,
.cotizacion-tercero-item span {
  color: #0f172a;
}
.cotizacion-tercero-item span {
  opacity: .78;
}
.cotizacion-line-results {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}
.cotizacion-detail-meta,
#cotizacion-detalles {
  min-width: 980px;
}
.cotizacion-detail-meta {
  grid-template-columns: minmax(0, 2fr) 86px 96px 96px 92px 92px 64px !important;
}
.cotizacion-detail-row {
  grid-template-columns: minmax(0, 2fr) 86px 96px 96px 92px 92px 64px !important;
  align-items: end;
}
.cotizacion-detail-row .fact-catalogo-chip {
  background: rgba(15, 23, 42, .06) !important;
  color: #0f172a !important;
  border: 1px solid rgba(148, 163, 184, .35);
}
.cotizacion-detail-row .fact-catalogo-chip span {
  color: #0f172a !important;
}
.cotizacion-detail-row input[data-cotizacion-item-buscar],
.cotizacion-detail-row input[data-cotizacion-descripcion],
.cotizacion-detail-row input[data-cotizacion-cantidad],
.cotizacion-detail-row input[data-cotizacion-valor],
.cotizacion-detail-row input[data-cotizacion-subtotal],
.cotizacion-detail-row input[data-cotizacion-igv],
.cotizacion-detail-row input[data-cotizacion-total] {
  min-height: 42px;
}
.fact-detail-row {
  display: grid;
  gap: 8px;
  align-items: end;
  grid-template-columns: 2fr 86px 120px 100px 100px 90px 1fr auto;
}
.fact-lista-detail-row {
  display: none;
}
.fact-lista-detail-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fact-lista-wrap thead th {
  background: linear-gradient(180deg, rgba(15, 23, 42, .95), rgba(30, 41, 59, .98));
  color: #f8fafc;
  border-bottom-color: rgba(148, 163, 184, .18);
}
.fact-lista-wrap tbody tr td {
  border-bottom-color: rgba(148, 163, 184, .22);
}
.fact-lista-wrap tbody tr:hover td {
  background: rgba(241, 245, 249, .98);
}
.fact-lista-detail-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.fact-lista-detail-meta > div {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
}
.fact-lista-detail-meta span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.fact-lista-detail-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.fact-lista-detail-state {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.fact-lista-detail-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.productos-filters {
  grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(0, .9fr));
}
.app-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .72);
  backdrop-filter: blur(6px);
  z-index: 90;
  padding: 24px;
  overflow: auto;
}
.app-modal-card {
  width: min(100%, 460px);
  margin: 48px auto;
}
.app-modal-wide {
  width: min(100%, 680px);
}
.app-modal-card,
#tercero-form-modal > .card,
#fact-tercero-modal > .card,
#productos-modal > .card {
  background: linear-gradient(180deg, rgba(17, 24, 39, .98), rgba(31, 41, 55, .96));
  border: 1px solid rgba(148, 163, 184, .16);
  box-shadow: 0 28px 80px rgba(2, 6, 23, .52);
  color: var(--text);
}
.app-modal-card .card,
#tercero-form-modal section.card,
#fact-tercero-modal section.card,
#productos-modal .productos-modal-body {
  background: rgba(255, 255, 255, .03);
  border-color: rgba(148, 163, 184, .12);
}

#cotizacion-modal > .card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fbfdff 0%, #eef4fb 100%);
  border: 1px solid rgba(148, 163, 184, .24);
  box-shadow: 0 22px 70px rgba(15, 23, 42, .16);
  color: #0f172a;
}
#cotizacion-modal > .card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, #22c55e 0%, #3b82f6 100%);
}
#cotizacion-modal .card {
  background: rgba(255, 255, 255, .92);
  border-color: rgba(148, 163, 184, .2);
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
  color: #0f172a;
}
#cotizacion-modal .fact-modal-head {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
}
#cotizacion-modal .fact-modal-head h3 {
  font-size: 1.18rem;
  letter-spacing: -.02em;
  color: #0f172a;
}
#cotizacion-modal .fact-modal-head p {
  color: #64748b;
}
#cotizacion-modal .fact-section-head strong {
  color: #0f172a;
}
#cotizacion-modal .fact-section-head .empty {
  color: #64748b;
}
#cotizacion-modal .cotizacion-summary-card,
#cotizacion-modal .cotizacion-detail-card {
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, .18);
  box-shadow: 0 12px 32px rgba(15, 23, 42, .05);
}
#cotizacion-modal .cotizacion-summary-card .fact-section-head,
#cotizacion-modal .cotizacion-detail-card .fact-section-head {
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, .16);
}
#cotizacion-modal .empty {
  color: #64748b;
}
#cotizacion-modal input,
#cotizacion-modal select,
#cotizacion-modal textarea {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(148, 163, 184, .35);
}
#cotizacion-modal input::placeholder,
#cotizacion-modal textarea::placeholder {
  color: #94a3b8;
}
#cotizacion-modal .fact-catalogo-results,
#cotizacion-modal .cotizacion-line-results {
  background: #ffffff;
  border-color: rgba(148, 163, 184, .28);
}
#cotizacion-modal .fact-detail-meta {
  color: #64748b !important;
  font-weight: 600;
  letter-spacing: .03em;
}
#cotizacion-modal .cotizacion-detail-row {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .04);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
#cotizacion-modal .cotizacion-detail-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .07);
  border-color: rgba(59, 130, 246, .18);
}
#cotizacion-modal .cotizacion-detail-row input[data-cotizacion-item-buscar],
#cotizacion-modal .cotizacion-detail-row input[data-cotizacion-descripcion],
#cotizacion-modal .cotizacion-detail-row input[data-cotizacion-cantidad],
#cotizacion-modal .cotizacion-detail-row input[data-cotizacion-valor],
#cotizacion-modal .cotizacion-detail-row input[data-cotizacion-subtotal],
#cotizacion-modal .cotizacion-detail-row input[data-cotizacion-igv],
#cotizacion-modal .cotizacion-detail-row input[data-cotizacion-total] {
  background: #ffffff;
  border-color: rgba(148, 163, 184, .32);
}
#cotizacion-modal .fact-catalogo-chip {
  background: rgba(59, 130, 246, .10) !important;
  color: #1d4ed8 !important;
  border: 1px solid rgba(59, 130, 246, .16);
}
#cotizacion-modal .fact-catalogo-chip span {
  color: #1d4ed8 !important;
}
#cotizacion-modal .cotizacion-summary-card .fact-section-head strong,
#cotizacion-modal .cotizacion-detail-card .fact-section-head strong {
  letter-spacing: -.01em;
}
#cotizacion-modal .cotizacion-summary-card strong[id^="cotizacion-"] {
  color: #0f172a;
}
#cotizacion-modal .cotizacion-summary-card > div:last-child > div {
  padding: 10px 0;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
}
#cotizacion-modal .cotizacion-summary-card > div:last-child > div:last-child {
  border-bottom: 0;
}
#tercero-form-modal section.card {
  border: 1px solid rgba(148, 163, 184, .12);
  border-radius: 14px;
}
.productos-modal-card {
  width: min(100%, 980px);
}
.productos-modal-body {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}
.productos-modal-form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.productos-field {
  display: grid;
  gap: 6px;
}
.productos-field > span {
  font-size: .92rem;
  color: var(--text);
}
.productos-field-wide {
  grid-column: span 2;
}
.productos-modal-switch {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px dashed rgba(148, 163, 184, .25);
  background: rgba(255, 255, 255, .025);
}
.productos-switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.2;
}
.productos-switch-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}
.productos-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.productos-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  width: fit-content;
}
.modal-list {
  display: grid;
  gap: 10px;
  max-height: min(55vh, 520px);
  overflow: auto;
}
.modal-company-item {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--text);
}
.modal-company-item strong {
  font-size: 1rem;
}
.modal-company-item span {
  color: var(--muted);
  font-size: .92rem;
}
@media (max-width: 1024px) {
  .fact-modal-grid {
    grid-template-columns: 1fr;
  }
  #cotizacion-modal .grid-2 {
    grid-template-columns: 1fr;
  }
  #cotizacion-modal .cotizacion-summary-card,
  #cotizacion-modal .cotizacion-detail-card {
    width: 100%;
  }
  .guia-form-flow {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tercero"
      "documento"
      "detalle";
  }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: block;
    position: fixed;
    inset: 0 auto 0 0;
    width: 0;
    height: 100dvh;
    padding: 0;
    background:
      radial-gradient(circle at 20% 0%, rgba(34, 197, 94, .11), transparent 34%),
      linear-gradient(180deg, rgba(15, 23, 42, .98), rgba(8, 15, 30, .98));
    border-right: 1px solid var(--border);
    z-index: 70;
    overflow: visible;
  }
  body.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    overflow: visible;
    background:
      radial-gradient(circle at 20% 0%, rgba(34, 197, 94, .11), transparent 34%),
      linear-gradient(180deg, rgba(15, 23, 42, .98), rgba(8, 15, 30, .98));
    border-right: 1px solid var(--border);
    box-shadow: none;
  }
  body:not(.sidebar-collapsed) .sidebar {
    width: min(86vw, 320px);
    padding: 18px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background:
      radial-gradient(circle at 20% 0%, rgba(34, 197, 94, .11), transparent 34%),
      linear-gradient(180deg, rgba(15, 23, 42, .98), rgba(8, 15, 30, .98));
    border-right: 1px solid var(--border);
    box-shadow: 20px 0 60px rgba(0, 0, 0, .45);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .sidebar-head {
    margin-bottom: 0;
  }
  body.sidebar-collapsed .sidebar-head {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 120;
    margin-bottom: 0;
  }
  body:not(.sidebar-collapsed) .sidebar-head {
    position: static;
    margin-bottom: 14px;
  }
  body.sidebar-collapsed .sidebar-inner {
    display: none;
  }
  body:not(.sidebar-collapsed) .sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
  }
  body.auth-mode::before {
    content: none;
    display: none;
  }
  body:not(.sidebar-collapsed)::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .58);
    z-index: 60;
  }
  body.auth-mode {
    overflow: auto;
  }
  body.sidebar-collapsed .menu-toggle {
    background: rgba(15, 23, 42, .88);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
  }
  .sidebar-actions {
    margin-top: auto;
    padding-top: 14px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(8, 15, 30, .62));
    backdrop-filter: blur(8px);
  }
  .sidebar-account-menu {
    max-height: min(42vh, 320px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .content {
    padding: 16px;
    margin-left: 0;
    width: 100%;
  }
  body:not(.sidebar-collapsed) .content {
    margin-left: 0;
    width: 100%;
  }
  .view {
    padding: 16px;
  }
  .topbar,
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar {
    padding: 10px 14px;
    margin-bottom: 10px;
  }
  .topbar-controls {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    gap: 8px;
  }
  .topbar > div {
    width: 100%;
  }
  .topbar h1 {
    font-size: 1rem;
  }
  .topbar p {
    font-size: .78rem;
  }
  .fact-page-header,
  .fact-section-head,
  .fact-modal-head,
  .fact-tercero-head,
  .fact-summary-row,
  .fact-tercero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  body.facturacion-header-inline .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  body.facturacion-header-inline .topbar > div {
    width: auto;
    flex: 1 1 auto;
  }
  body.facturacion-header-inline .topbar-controls {
    width: auto;
    flex: 0 0 auto;
    margin-left: 0;
  }
  body.facturacion-header-inline .topbar-actions {
    width: auto;
    flex: 0 0 auto;
  }
  body.facturacion-header-inline .topbar button {
    width: auto;
  }
  body.facturacion-header-inline .topbar-action-btn {
    min-height: 32px;
    padding: 0 10px;
    font-size: 11px;
  }
  .fact-section-head.fact-summary-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .topbar button,
  .page-header button,
  .fact-page-header button,
  .fact-section-head button,
  .fact-modal-head button,
  .fact-tercero-head button,
  .fact-summary-row button,
  .fact-tercero-actions button {
    width: 100%;
  }
  .fact-section-head .fact-icon-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    align-self: flex-start;
  }
  .fact-section-head #fact-btn-configurar-pago {
    width: auto;
    min-width: 0;
    align-self: flex-start;
    padding-inline: 8px;
  }
  .fact-section-head.fact-summary-head #fact-btn-configurar-pago {
    align-self: center;
  }
  .fact-modal-head .fact-modal-close-icon {
    width: 42px;
    min-width: 42px;
    padding: 0;
    align-self: flex-end;
    border-radius: 999px;
    font-size: 24px;
    line-height: 1;
  }
  .fact-modal-head-main {
    flex-direction: row;
    align-items: flex-start;
  }
  .fact-modal-head-main .fact-modal-close-icon {
    width: 40px;
    min-width: 40px;
    height: 40px;
    margin-left: 12px;
    margin-top: 0;
    align-self: flex-start;
  }
  .fact-icon-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    align-self: flex-start;
    border-radius: 999px;
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border);
    box-shadow: none;
    font-size: 18px;
    line-height: 1;
  }
  .fact-add-product-btn {
    min-width: 0;
    width: auto;
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
    align-self: flex-start;
  }
  .fact-tercero-search-row {
    gap: 8px;
  }
  .fact-tercero-search-row .fact-tercero-add {
    width: 42px;
    min-width: 42px;
    height: 42px;
    align-self: stretch;
    font-size: 20px;
  }
  .fact-tercero-modal-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .fact-tercero-field > span {
    font-size: .88rem;
  }
  .fact-add-line-btn,
  .fact-remove-line-btn {
    width: 32px;
    min-width: 32px;
    height: 32px;
    font-size: 18px;
  }
  .fact-form-flow {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tercero"
      "documento"
      "detalle"
      "resumen";
  }
  .guia-form-flow {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tercero"
      "documento"
      "detalle";
  }
  .fact-modal-grid {
    grid-template-columns: 1fr;
  }
  #cotizacion-modal .grid-2 {
    grid-template-columns: 1fr;
  }
  .productos-filters {
    grid-template-columns: 1fr 1fr;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .form-grid {
    max-width: 100%;
  }
  .auth-mode #view-login {
    width: 100%;
    min-height: auto;
  }
  .auth-mode #view-login .card {
    width: 100%;
  }
  .auth-mode .content {
    padding: 16px;
    margin-left: 0;
    width: 100%;
  }
  .menu {
    grid-template-columns: 1fr;
  }
  .ctx-card {
    margin-bottom: 16px;
  }
  body:not(.sidebar-collapsed) {
    overflow: hidden;
  }
  .table-wrap table {
    min-width: 680px;
  }
  .fact-flow-detalle {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .fact-detail-meta,
  .cotizacion-detail-meta,
  #fact-detalles {
    min-width: 760px;
  }
  .fact-detail-meta {
    grid-template-columns: minmax(220px, 2fr) 86px 92px 92px 64px !important;
  }
  .cotizacion-detail-meta {
    grid-template-columns: minmax(220px, 2fr) 86px 92px 92px 92px 92px 64px !important;
  }
  .fact-detail-row {
    grid-template-columns: minmax(220px, 2fr) 86px 92px 92px 64px !important;
  }
  .cotizacion-detail-row {
    grid-template-columns: minmax(220px, 2fr) 86px 92px 92px 92px 92px 64px !important;
  }
  #cotizacion-detalles {
    min-width: 760px;
  }
  #cotizacion-modal .cotizacion-summary-card,
  #cotizacion-modal .cotizacion-detail-card {
    padding: 12px;
  }
  .fact-catalogo-head {
    flex-direction: column;
    align-items: stretch;
  }
  .app-modal {
    padding: 12px;
  }
  .app-modal-card {
    width: 100%;
    margin: 16px auto;
  }
  .app-modal-wide {
    width: 100%;
  }
  .productos-modal-body {
    margin-top: 12px;
  }
  .productos-modal-form-grid {
    grid-template-columns: 1fr;
  }
  .productos-field-wide {
    grid-column: auto;
  }
  .productos-modal-footer {
    margin-top: 2px;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 14px;
  }
  .content {
    padding: 12px;
  }
  .view {
    padding: 12px;
  }
  .topbar,
  .page-header {
    margin-bottom: 12px;
  }
  .topbar-controls {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }
  .topbar-user-name {
    max-width: 92px;
  }
  .topbar-user-role {
    max-width: 92px;
  }
  .topbar-user-menu {
    min-width: 200px;
  }
  .card {
    padding: 14px;
  }
  input, select, button {
    min-height: 44px;
  }
  .table-wrap table {
    min-width: 600px;
  }
  .fact-flow-detalle {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .fact-detail-meta,
  #fact-detalles {
    min-width: 760px;
  }
  .fact-detail-meta {
    grid-template-columns: minmax(220px, 2fr) 86px 92px 92px 64px !important;
  }
  .fact-detail-row {
    grid-template-columns: minmax(220px, 2fr) 86px 92px 92px 64px !important;
  }
  #fact-modal > .card,
  #fact-tercero-modal > .card {
    margin: 12px auto;
    width: min(100%, 100%);
  }
  .app-modal-card {
    margin: 12px auto;
  }
  .productos-filters {
    grid-template-columns: 1fr;
  }

  .fact-page-header {
    gap: 10px;
  }

  .fact-page-header h2 {
    font-size: 1.1rem;
  }

  .fact-page-header p {
    font-size: .9rem;
    line-height: 1.4;
  }
  #cotizacion-modal .cotizacion-detail-row {
    padding: 4px;
  }
}

@media (max-width: 1100px) {
  .fact-lista-wrap {
    margin: 0;
    overflow: hidden;
  }
  .fact-lista-wrap table,
  .fact-lista-wrap thead,
  .fact-lista-wrap tbody,
  .fact-lista-wrap tr,
  .fact-lista-wrap td {
    display: revert;
  }
  .fact-lista-wrap thead {
    display: table-header-group;
  }
  .fact-lista-wrap table {
    table-layout: fixed;
    min-width: 0 !important;
    width: 100%;
  }
  .fact-lista-wrap tbody tr {
    display: table-row;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-sizing: border-box;
    width: 100%;
  }
  .fact-lista-wrap td {
    padding: 8px 6px;
    border: 0;
    min-width: 0;
    display: table-cell;
    vertical-align: top;
  }
  .fact-lista-wrap td:nth-child(1),
  .fact-lista-wrap td:nth-child(2),
  .fact-lista-wrap td:nth-child(3),
  .fact-lista-wrap td:nth-child(6),
  .fact-lista-wrap td:nth-child(7),
  .fact-lista-wrap th:nth-child(1),
  .fact-lista-wrap th:nth-child(2),
  .fact-lista-wrap th:nth-child(3),
  .fact-lista-wrap th:nth-child(6),
  .fact-lista-wrap th:nth-child(7) {
    display: none;
  }
  .fact-lista-wrap th:nth-child(4),
  .fact-lista-wrap td:nth-child(4) {
    display: table-cell;
    width: 72%;
    min-width: 0;
    padding-left: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .fact-lista-wrap td:nth-child(4) strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .fact-lista-wrap th:nth-child(5),
  .fact-lista-wrap td:nth-child(5) {
    display: table-cell;
    width: 28%;
    min-width: 0;
    padding-right: 0;
    white-space: nowrap;
    text-align: right !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .fact-lista-main-row {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  .fact-lista-main-row.is-open + .fact-lista-detail-row {
    display: table-row !important;
  }
  .fact-lista-detail-row td[colspan] {
    display: table-cell !important;
    width: auto;
    max-width: none;
    padding: 6px 0 10px;
    white-space: normal;
    overflow: visible;
  }
  .fact-lista-detail-content {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .fact-lista-detail-meta {
    grid-template-columns: 1fr;
  }
  .fact-lista-detail-meta > div {
    padding: 8px 10px;
  }
  .fact-lista-detail-actions {
    justify-content: flex-start;
  }
  .fact-lista-detail-actions button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }
  #fact-lista-paginacion {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }
  #fact-lista-paginacion button {
    width: auto;
    min-width: 40px;
    padding: 0 10px;
  }
}

@media (min-width: 861px) and (max-width: 1100px) {
  .fact-lista-detail-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .fact-documento-grid,
  .fact-nota-grid {
    grid-template-columns: 1fr !important;
  }
  #fact-modal .fact-section-head {
    gap: 8px;
  }
  #fact-modal .fact-section-head > div {
    width: 100%;
  }

  #fact-ver-modal .fact-ver-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }
  #fact-ver-modal .fact-ver-actions button {
    width: 100%;
    min-width: 0;
    padding: 0 10px;
    min-height: 34px;
    font-size: 12px;
  }
  #fact-ver-modal .grid-2 {
    grid-template-columns: 1fr;
  }
  #fact-ver-modal .fact-historial-head {
    display: none !important;
  }
  #fact-ver-modal .fact-historial-grid {
    grid-template-columns: 1fr !important;
    gap: 4px;
  }
  #fact-ver-modal .fact-historial-row {
    padding: 10px;
  }
  #fact-ver-modal .fact-historial-row > .fact-historial-grid > div {
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
  }

  #fact-baja-modal .fact-modal-head,
  #fact-integraciones-modal .fact-modal-head,
  #fact-tercero-modal .fact-modal-head {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
  }
  #fact-baja-modal .fact-modal-head > div,
  #fact-integraciones-modal .fact-modal-head > div,
  #fact-tercero-modal .fact-modal-head > div {
    min-width: 0;
    flex: 1 1 auto;
  }
  #fact-baja-modal .fact-modal-close-icon,
  #fact-integraciones-modal .fact-modal-close-icon,
  #fact-tercero-modal .fact-modal-close-icon {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    flex: 0 0 38px;
  }
  #fact-integraciones-modal .fact-section-head,
  #fact-baja-modal .grid-2,
  #fact-tercero-modal .fact-tercero-modal-grid {
    grid-template-columns: 1fr;
  }

  #fact-modal > .card,
  .app-modal-card,
  .app-modal-wide {
    width: calc(100% - 12px);
    margin: 10px auto;
    border-radius: 16px;
  }

  #fact-modal .card,
  #fact-tercero-modal .card,
  #fact-pago-modal .card,
  #fact-detraccion-modal .card,
  #fact-vista-modal .card,
  #fact-baja-modal .card,
  #fact-integraciones-modal .card {
    padding: 12px;
  }

  .fact-modal-head,
  .fact-section-head,
  .fact-catalogo-head {
    gap: 8px;
  }

  .fact-modal-head h3,
  .fact-section-head strong,
  .fact-catalogo-head strong {
    font-size: .98rem;
  }

  .fact-modal-head p,
  .fact-section-head .empty {
    font-size: .86rem;
    line-height: 1.35;
  }

  #fact-pago-modal .fact-modal-head {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
  }
  #fact-pago-modal .fact-modal-head > div {
    min-width: 0;
    flex: 1 1 auto;
  }
  #fact-pago-modal .fact-modal-head h3 {
    font-size: 1rem;
  }
  #fact-pago-modal .fact-modal-head p {
    margin-top: 4px !important;
    font-size: .82rem;
  }
  #fact-pago-modal .fact-modal-close-icon {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    flex: 0 0 38px;
    align-self: flex-start;
  }
  #fact-pago-modal .fact-pago-top-grid {
    grid-template-columns: 1fr;
  }
  #fact-pago-modal .fact-pago-list-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  #fact-pago-modal .fact-pago-list-head button {
    width: auto;
    min-width: 0;
    padding: 0 10px;
    height: 34px;
    min-height: 34px;
    font-size: 12px;
    align-self: center;
  }
  #fact-pago-modal .fact-pago-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #fact-pago-modal .fact-detail-meta {
    display: none;
  }
  #fact-pago-modal .fact-pago-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
    padding: 10px 0;
  }
  #fact-pago-modal .fact-pago-row > label:nth-child(1) {
    grid-column: 1 / -1;
  }
  #fact-pago-modal .fact-pago-row > label:nth-child(2),
  #fact-pago-modal .fact-pago-row > label:nth-child(3) {
    grid-column: span 1;
  }
  #fact-pago-modal .fact-pago-row > div:last-child {
    grid-column: 1 / -1;
    justify-content: space-between;
    gap: 8px;
  }
  #fact-pago-modal .fact-pago-remover {
    min-width: 88px;
    padding-inline: 10px;
  }
  #fact-pago-modal .fact-pago-credito-tag {
    padding: 5px 8px !important;
  }

  .grid-2 {
    gap: 12px;
  }

  .fact-modal-grid {
    gap: 12px;
  }

  .fact-catalogo-panel {
    padding: 10px;
  }

  .fact-catalogo-results {
    max-height: 200px;
  }

  .fact-detail-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 0;
    font-size: 11px;
  }
  .cotizacion-detail-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 0;
    font-size: 11px;
  }
  #guia-modal .guia-form-flow {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tercero"
      "documento"
      "detalle";
  }
  #guia-modal .guia-flow-documento .grid-2 {
    grid-template-columns: 1fr;
  }
  #guia-modal .table-wrap table {
    min-width: 760px;
  }

  .fact-detail-meta > span {
    line-height: 1.2;
  }
  .cotizacion-detail-meta > span {
    line-height: 1.2;
  }

  .table-wrap {
    margin: 0 -2px;
  }

  .table-wrap table {
    min-width: 560px;
  }

  .table-wrap th,
  .table-wrap td {
    padding: 10px 8px;
    font-size: .92rem;
  }

  .table-wrap td:nth-child(3),
  .table-wrap th:nth-child(3) {
    white-space: nowrap;
  }

  input,
  select,
  button {
    min-height: 42px;
  }

  .app-modal {
    padding: 10px;
  }

  .fact-page-header button,
  .fact-section-head button,
  .fact-modal-head button,
  .fact-catalogo-head button {
    min-width: 0;
  }
  .fact-section-head .fact-icon-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    align-self: flex-start;
  }
  .fact-modal-head .fact-modal-close-icon {
    width: 40px;
    min-width: 40px;
    padding: 0;
    align-self: flex-end;
  }
  .fact-modal-head-main {
    flex-direction: row;
    align-items: flex-start;
  }
  .fact-modal-head-main .fact-modal-close-icon {
    width: 38px;
    min-width: 38px;
    height: 38px;
    margin-left: 10px;
    align-self: flex-start;
  }
  .fact-icon-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    align-self: flex-start;
    border-radius: 999px;
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border);
    box-shadow: none;
    font-size: 18px;
    line-height: 1;
  }
  .fact-add-product-btn {
    min-width: 0;
    width: auto;
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
    align-self: flex-start;
  }
  .fact-tercero-search-row {
    gap: 8px;
  }
  .fact-tercero-search-row .fact-tercero-add {
    width: 42px;
    min-width: 42px;
    height: 42px;
    align-self: stretch;
    font-size: 20px;
  }
  .fact-add-line-btn,
  .fact-remove-line-btn {
    width: 32px;
    min-width: 32px;
    height: 32px;
    font-size: 18px;
  }
  .fact-form-flow {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tercero"
      "documento"
      "detalle"
      "resumen";
  }
}

.home-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.home-hero-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.home-kicker {
  color: var(--accent);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.home-hero-copy h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.1;
}

.home-hero-copy p {
  margin: 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.45;
}

.home-status-card,
.home-quick-card {
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,250,252,.94));
  box-shadow: 0 12px 30px rgba(15, 23, 42, .05);
}

.home-status-card span,
.home-quick-card span {
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.35;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.home-quick-card {
  width: 100%;
  padding: 16px;
  display: grid;
  gap: 8px;
  text-align: left;
  color: #0f172a;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.home-quick-card:hover {
  transform: translateY(-1px);
  border-color: rgba(34, 197, 94, .26);
  box-shadow: 0 16px 34px rgba(15, 23, 42, .08);
}

.home-quick-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: rgba(34, 197, 94, .12);
  color: #16a34a;
}

.home-quick-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-quick-card strong {
  font-size: .98rem;
  line-height: 1.25;
}

.home-quick-card span {
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.4;
}

.home-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.home-status-card {
  padding: 14px 16px;
  display: grid;
  gap: 5px;
}

.home-status-card strong {
  font-size: 1rem;
  line-height: 1.25;
}

.home-status-card small {
  color: var(--muted);
  font-size: .83rem;
  line-height: 1.4;
}

@media (max-width: 1100px) {
  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-hero {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .home-grid,
  .home-status-grid {
    grid-template-columns: 1fr;
  }
  .home-hero-copy h2 {
    font-size: 1.25rem;
  }
  .home-quick-card {
    padding: 14px;
  }
}
