:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --soft-primary: #dbeafe;
  --soft-danger: #fee2e2;
  --soft-success: #dcfce7;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

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

.sidebar {
  width: 290px;
  background: #0f172a;
  color: white;
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 14px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #60a5fa, #fca5a5);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.brand h1 {
  font-size: 19px;
  margin: 0;
}

.brand p {
  margin: 3px 0 0;
  color: #cbd5e1;
  font-size: 13px;
}

.btn-candado {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  padding: 0;
  flex-shrink: 0;
}

.btn-candado:hover {
  background: #f1f5f9;
  color: #334155;
}

.btn-candado.active {
  color: #16a34a;
  border-color: #86efac;
  background: #f0fdf4;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-item,
.menu-parent {
  width: 100%;
  border: 0;
  text-align: left;
  padding: 12px 14px;
  border-radius: 13px;
  cursor: pointer;
  background: transparent;
  color: #e5e7eb;
  font-size: 15px;
}

.menu-parent {
  color: #93c5fd;
  font-weight: 700;
  margin-top: 8px;
}

.menu-parent::after {
  content: "▾";
  float: right;
}

.menu-item:hover,
.menu-parent:hover {
  background: rgba(255,255,255,.08);
}

.menu-item.active {
  background: #2563eb;
  color: #fff;
  font-weight: 700;
}

.submenu {
  display: none;
  padding-left: 10px;
}

.submenu.open {
  display: block;
}

.submenu .menu-item {
  font-size: 14px;
  padding: 10px 14px;
}

.main {
  flex: 1;
  min-width: 0;
}

.topbar {
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 22px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 {
  margin: 0;
  font-size: 25px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.status {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--soft-success);
  color: #166534;
  font-size: 13px;
  font-weight: 700;
}

.view {
  padding: 28px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  border: 1px solid rgba(15,23,42,.04);
}

.card h3 {
  margin: 0 0 14px;
}

.kpi {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi .label {
  color: var(--muted);
  font-size: 14px;
}

.kpi .value {
  font-size: 28px;
  font-weight: 900;
  margin-top: 8px;
}

.kpi .emoji {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: #f1f5f9;
  border-radius: 16px;
  font-size: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.field label {
  display: block;
  font-weight: 700;
  color: #374151;
  margin-bottom: 7px;
  font-size: 14px;
}

.input,
select,
textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 11px 12px;
  border-radius: 12px;
  outline: none;
  font-size: 14px;
}

.input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 15px;
  font-weight: 800;
  cursor: pointer;
  font-size: 14px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-light {
  background: #e5e7eb;
  color: #111827;
}

.btn-danger {
  background: var(--soft-danger);
  color: #991b1b;
}

.btn-success {
  background: var(--soft-success);
  color: #166534;
}

.btn-warning {
  background: #fef3c7;
  color: #92400e;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
}

table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
}

th {
  text-align: left;
  padding: 13px;
  font-size: 13px;
  color: #374151;
  background: #f9fafb;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 12px 13px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
}

.badge-blue {
  background: var(--soft-primary);
  color: #1d4ed8;
}

.badge-green {
  background: var(--soft-success);
  color: #166534;
}

.badge-red {
  background: var(--soft-danger);
  color: #991b1b;
}

.badge-yellow {
  background: #fef3c7;
  color: #92400e;
}

.doc-total {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.total-box {
  min-width: 330px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  margin: 8px 0;
}

.total-row.big {
  font-size: 24px;
  font-weight: 900;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #111827;
  color: white;
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 20;
  max-width: 430px;
}

.toast.show {
  display: block;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.comp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comp-item {
  display: grid;
  grid-template-columns: 1fr 120px 42px;
  gap: 8px;
  align-items: center;
}

.notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 16px;
}

@media (max-width: 1000px) {
  #app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .view {
    padding: 16px;
  }
}


.combo-comp-item {
  grid-template-columns: 1fr 120px minmax(220px, auto) 42px;
}

.combo-cost-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--muted);
  font-size: 13px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}

@media (max-width: 1000px) {
  .combo-comp-item {
    grid-template-columns: 1fr;
  }
}


.product-form-locked-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}


.notice-danger {
  border-color: #fecaca !important;
  background: #fff1f2 !important;
  color: #991b1b !important;
  margin-top: 14px;
}


.small-help {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}


.login-screen {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(15, 23, 42, 0.55);
  z-index: 9999;
}

.login-screen.show {
  display: grid;
}

.login-card {
  width: min(420px, calc(100vw - 28px));
  background: white;
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(15, 23, 42, 0.25);
  padding: 26px;
}

.login-card h2 {
  margin: 0 0 6px 0;
  color: var(--text);
}

.permisos-categorias {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.permisos-cat {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.permisos-cat-titulo {
  background: var(--sidebar);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 7px 14px;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0;
  padding: 6px 8px;
  background: #f8fafc;
}

.perm-check {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.perm-check:hover {
  background: #e8f0ff;
}

.perm-check input {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}


.client-search-wrap {
  position: relative;
}

.search-clear-btn {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 10px;
  background: #eef2f7;
  color: #334155;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}

.search-clear-btn:hover {
  background: #fee2e2;
  color: #991b1b;
}

.search-results {
  display: none;
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  padding: 6px;
}

.search-results.show {
  display: block;
}

.search-result-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 12px;
  background: white;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text);
}

.search-result-item:hover {
  background: #eff6ff;
}

.search-result-item span {
  color: var(--muted);
  font-size: 12px;
}

.search-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}


.btn:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}


.product-search-wrap {
  position: relative;
  min-width: 260px;
}

.product-search-input {
  padding-right: 12px;
}

.product-search-results {
  display: none;
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 360px;
  max-height: 340px;
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  padding: 6px;
}

.product-search-results.show {
  display: block;
}

.product-search-result {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 12px;
  background: white;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text);
}

.product-search-result:hover {
  background: #eff6ff;
}

.product-search-result span {
  color: var(--muted);
  font-size: 12px;
}

.comp-item .product-search-wrap {
  min-width: 320px;
}

.table-wrap .product-search-results {
  min-width: 520px;
}

@media (max-width: 900px) {
  .product-search-results,
  .table-wrap .product-search-results {
    min-width: 100%;
  }
}


.tes-line {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) 42px;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  margin-bottom: 10px;
  background: #f8fafc;
}

.tes-line .tes-wide {
  grid-column: span 2;
}

@media (max-width: 1100px) {
  .tes-line {
    grid-template-columns: 1fr;
  }

  .tes-line .tes-wide {
    grid-column: auto;
  }
}


.search-count {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.inner-card {
  box-shadow: none;
  border: 1px solid var(--line);
  margin: 0;
}

.image-placeholder {
  min-height: 130px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #f8fafc;
  margin-bottom: 10px;
}

.product-photo-preview {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.product-photo-preview img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.product-thumb {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}


.searchable-select {
  position: relative;
}

.searchable-results {
  z-index: 120;
}

select.master-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 44px;
  padding: 0 12px;
  background: white;
  color: var(--text);
  font: inherit;
}


/* v1.25 menu horizontal */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar {
  width: 100%;
  background: #0f172a;
  color: white;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  height: auto;
  overflow: visible;
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
}

.brand {
  padding: 8px 6px 14px;
  margin-bottom: 12px;
}

.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.menu-group {
  position: relative;
}

.menu-item,
.menu-parent {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: left;
  padding: 11px 14px;
  white-space: nowrap;
}

.menu-parent {
  margin-top: 0;
  background: rgba(255,255,255,.04);
  color: #dbeafe;
}

.menu-parent::after {
  content: "▾";
  float: none;
  margin-left: 8px;
}

.menu-item {
  background: rgba(255,255,255,.02);
}

.menu-group.single .menu-item {
  background: transparent;
}

.submenu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  padding: 10px;
  border-radius: 14px;
  background: #0b1220;
  box-shadow: 0 18px 40px rgba(2,6,23,.35);
  border: 1px solid rgba(255,255,255,.10);
  z-index: 60;
}

.submenu.open {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.submenu .menu-item {
  width: 100%;
  justify-content: flex-start;
  font-size: 14px;
  padding: 10px 12px;
  background: transparent;
}

.main {
  width: 100%;
  flex: 1;
  min-width: 0;
}

.topbar {
  top: 112px;
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
  }
  .topbar {
    top: 0;
  }
  .menu {
    gap: 8px;
  }
  .menu-item,
  .menu-parent {
    font-size: 14px;
    padding: 10px 12px;
  }
}


/* v1.26 autocomplete over table */

.table-wrap-autocomplete {
  position: relative;
  overflow: visible;
  z-index: 1;
}

.table-wrap-autocomplete table,
.table-wrap-autocomplete tbody,
.table-wrap-autocomplete tr,
.table-wrap-autocomplete td,
.table-wrap-autocomplete th {
  overflow: visible;
}

.table-wrap-autocomplete td {
  position: relative;
}

.table-wrap-autocomplete .product-search-wrap {
  position: relative;
  z-index: 20;
}

.table-wrap-autocomplete .product-search-results {
  z-index: 5000;
  min-width: max(360px, 100%);
  max-width: 760px;
}

.table-wrap-autocomplete .product-search-results.show {
  display: block;
}


/* v1.27 menu tabs estilo escritorio */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar {
  width: 100%;
  height: auto;
  position: sticky;
  top: 0;
  z-index: 120;
  overflow: visible;
  padding: 0;
  background: linear-gradient(180deg, #5b5b5f 0%, #3f4146 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px 6px;
  margin: 0;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 18px;
}

.brand h1 {
  font-size: 16px;
  margin: 0;
  color: #ffffff;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #e5e7eb;
}

.menu {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 3px;
  padding: 6px 10px 0;
  overflow-x: auto;
  overflow-y: visible;
  background: linear-gradient(180deg, #4a4c51 0%, #3a3c41 100%);
}

.menu::-webkit-scrollbar {
  height: 7px;
}

.menu::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.2);
  border-radius: 999px;
}

.menu-group {
  position: relative;
  flex: 0 0 auto;
}

.menu-item,
.menu-parent {
  width: auto;
  min-width: 112px;
  border: 1px solid rgba(255,255,255,.14);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 13px 16px;
  background: linear-gradient(180deg, #5d6065 0%, #43464b 100%);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.menu-group.single .menu-item {
  background: linear-gradient(180deg, #5d6065 0%, #43464b 100%);
}

.menu-item:hover,
.menu-parent:hover,
.menu-group:has(.submenu.open) > .menu-parent,
.menu-item.active {
  background: linear-gradient(180deg, #75b5e9 0%, #4d96d2 100%);
  color: #ffffff;
}

.menu-parent::after {
  content: "▼";
  float: none;
  margin-left: 9px;
  font-size: 10px;
  opacity: .95;
}

.submenu {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% - 1px);
  min-width: 235px;
  padding: 0;
  background: linear-gradient(180deg, #6cb0e0 0%, #4b97d2 100%);
  border: 1px solid #2f5f87;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 10px 18px rgba(0,0,0,.35);
  overflow: hidden;
  z-index: 160;
}

.submenu.open {
  display: block;
}

.submenu .menu-item {
  width: 100%;
  min-width: 0;
  display: block;
  text-align: left;
  border: none;
  border-top: 1px solid rgba(255,255,255,.22);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
}

.submenu .menu-item:first-child {
  border-top: none;
}

.submenu .menu-item:hover,
.submenu .menu-item.active {
  background: rgba(255,255,255,.16);
}

.main {
  width: 100%;
  flex: 1;
  min-width: 0;
}

.topbar {
  top: 112px;
}

@media (max-width: 1100px) {
  .sidebar {
    position: static;
  }

  .menu {
    padding-bottom: 6px;
  }

  .menu-item,
  .menu-parent {
    min-width: auto;
    padding: 11px 13px;
    font-size: 14px;
  }

  .topbar {
    top: 0;
  }
}

/* v1.28 vendedores */
.badge-yellow {
  background: #fef3c7;
  color: #92400e;
}


/* v1.29 fix menú horizontal con submenús verticales */
.menu {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 3px;
  overflow-x: auto;
  overflow-y: visible;
}

.menu-group {
  position: relative;
  display: block;
  flex: 0 0 auto;
}

.menu-parent,
.menu-group.single .menu-item {
  white-space: nowrap;
}

.submenu {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% - 1px);
  min-width: 240px;
  flex-direction: column;
  align-items: stretch;
  z-index: 9999;
}

.submenu.open {
  display: flex;
}

.submenu .menu-item {
  display: block;
  width: 100%;
  min-width: 0;
  text-align: left;
  white-space: nowrap;
  margin: 0;
}

.submenu .menu-item + .menu-item {
  margin-top: 0;
}


/* v1.30 menu dropdown estilo web */
#app {
  display: block;
  min-height: 100vh;
}

.sidebar {
  width: 100%;
  height: auto;
  position: sticky;
  top: 0;
  z-index: 80;
  overflow: visible;
  padding: 0;
  background: #ffffff;
  color: var(--text);
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

.brand {
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px 24px;
  border-bottom: 1px solid #eef2f7;
  color: var(--text);
}

.brand-icon {
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;
}

.brand p {
  color: #6b7280;
}

.menu {
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  overflow-x: auto;
  overflow-y: visible;
  background: #ffffff;
}

.menu-group,
.menu-group.single {
  position: relative;
  flex: 0 0 auto;
}

.menu-item,
.menu-parent {
  width: auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 16px 14px;
  background: transparent;
  color: #1f2937;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  position: relative;
}

.menu-parent {
  margin-top: 0;
  color: #1f2937;
}

.menu-parent::after {
  content: '▾';
  float: none;
  margin-left: 8px;
  color: #6b7280;
  font-size: 11px;
}

.menu-item:hover,
.menu-parent:hover,
.menu-item.active,
.menu-group:has(.submenu.open) > .menu-parent {
  background: transparent;
  color: #2563eb;
}

.menu-item.active::after,
.menu-parent:hover::before,
.menu-group:has(.submenu.open) > .menu-parent::before,
.menu-group.single .menu-item:hover::before,
.menu-group.single .menu-item.active::before {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  background: #2563eb;
  border-radius: 999px 999px 0 0;
}

.submenu {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  min-width: 260px;
  padding: 10px 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .16);
  z-index: 9999;
}

.submenu.open {
  display: block;
}

.submenu .menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 18px;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
}

.submenu .menu-item:hover,
.submenu .menu-item.active {
  background: #eff6ff;
  color: #1d4ed8;
}

.submenu .menu-item::after,
.submenu .menu-item::before {
  display: none !important;
}

.main {
  width: 100%;
}

.topbar {
  top: 118px;
  z-index: 40;
}

.view {
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
  }

  .menu {
    padding: 0 12px;
  }

  .topbar {
    top: 0;
  }
}


/* v1.34 documentos comerciales */
.document-type-card {
  margin-bottom: 18px;
}

.document-type-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.document-type-header h3 {
  margin-bottom: 6px;
}

.document-type-header p {
  margin: 0;
  color: var(--muted);
}

.document-type-groups {
  display: grid;
  gap: 16px;
}

.document-type-group h4 {
  margin: 0 0 10px;
  color: #1f2937;
}

.document-type-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.document-type-option {
  border: 1px solid #dbe3ef;
  background: #ffffff;
  border-radius: 14px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .05);
}

.document-type-option strong {
  display: block;
  color: #0f172a;
  margin-bottom: 4px;
}

.document-type-option span {
  display: block;
  color: #64748b;
  font-size: 13px;
}

.document-type-option:hover,
.document-type-option.selected {
  border-color: #2563eb;
  background: #eff6ff;
}

@media (max-width: 1100px) {
  .document-type-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .document-type-grid {
    grid-template-columns: 1fr;
  }
}


/* v1.35 pedidos y documentos comerciales */
.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.document-type-option[disabled],
.document-type-option.disabled {
  opacity: .55;
  cursor: not-allowed;
}

.login-screen.show {
  display: grid !important;
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(15, 23, 42, .55);
  place-items: center;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 26px;
  width: min(420px, calc(100vw - 24px));
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}



/* ==========================================================
   FIX FINAL V1.36 - MENÚ HORIZONTAL + DROPDOWN VISIBLE
   Incorporado sobre v1.35 para que no vuelva al menú vertical.
   ========================================================== */

#app {
  display: block !important;
  min-height: 100vh !important;
}

/* Barra superior completa */
.sidebar {
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 10000 !important;
  overflow: visible !important;
  padding: 0 !important;
  background: #ffffff !important;
  color: #172033 !important;
  border-bottom: 1px solid #e5e7eb !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08) !important;
}

/* Encabezado con logo */
.brand {
  max-width: none !important;
  margin: 0 !important;
  padding: 14px 24px !important;
  border-bottom: 1px solid #eef2f7 !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  color: #172033 !important;
}

.brand-icon {
  width: 44px !important;
  height: 44px !important;
  border-radius: 14px !important;
  background: linear-gradient(135deg, #2563eb, #60a5fa) !important;
  color: #ffffff !important;
  display: grid !important;
  place-items: center !important;
  font-weight: 900 !important;
}

.brand h1 {
  margin: 0 !important;
  font-size: 18px !important;
  color: #172033 !important;
}

.brand p {
  margin: 3px 0 0 !important;
  color: #6b7280 !important;
  font-size: 13px !important;
}

/* Contenedor del menú principal */
.menu {
  max-width: none !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  padding: 0 18px !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  background: #ffffff !important;
  position: relative !important;
  z-index: 5000 !important;
}

/* Cada categoría principal queda una al lado de la otra */
.menu-group,
.menu-group.single {
  position: relative !important;
  display: inline-block !important;
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 0 !important;
  overflow: visible !important;
}

/* Botones principales */
.menu-item,
.menu-parent {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 0 !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 16px 13px !important;
  background: transparent !important;
  color: #1f2937 !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  position: relative !important;
  text-align: center !important;
  box-shadow: none !important;
}

.menu-parent {
  margin-top: 0 !important;
}

/* Flechita de desplegable */
.menu-parent::after {
  content: "▾" !important;
  display: inline-block !important;
  float: none !important;
  margin-left: 8px !important;
  color: #6b7280 !important;
  font-size: 11px !important;
  opacity: 1 !important;
}

/* Hover / activo */
.menu-item:hover,
.menu-parent:hover,
.menu-item.active,
.menu-group:has(.submenu.open) > .menu-parent {
  background: transparent !important;
  color: #2563eb !important;
}

/* Línea inferior azul */
.menu-group.single .menu-item:hover::before,
.menu-group.single .menu-item.active::before,
.menu-parent:hover::before,
.menu-group:has(.submenu.open) > .menu-parent::before {
  content: "" !important;
  position: absolute !important;
  left: 12px !important;
  right: 12px !important;
  bottom: 0 !important;
  height: 3px !important;
  background: #2563eb !important;
  border-radius: 999px 999px 0 0 !important;
}

/* Dropdown visible por click y por hover */
.menu-group:hover > .submenu,
.submenu.open {
  display: block !important;
}

/* Dropdown */
.submenu {
  display: none !important;
  position: absolute !important;
  left: 0 !important;
  top: calc(100% + 1px) !important;
  min-width: 255px !important;
  width: max-content !important;
  max-width: 380px !important;
  padding: 8px 0 !important;
  background: #ffffff !important;
  border: 1px solid #dbe3ef !important;
  border-radius: 0 0 14px 14px !important;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .22) !important;
  z-index: 999999 !important;
  overflow: visible !important;
}

/* Opciones internas una debajo de otra */
.submenu .menu-item {
  display: block !important;
  width: 100% !important;
  min-width: 255px !important;
  text-align: left !important;
  justify-content: flex-start !important;
  padding: 13px 18px !important;
  color: #374151 !important;
  background: #ffffff !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}

/* Hover en opciones del dropdown */
.submenu .menu-item:hover,
.submenu .menu-item.active {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
}

/* Evita líneas decorativas dentro del dropdown */
.submenu .menu-item::before,
.submenu .menu-item::after {
  display: none !important;
  content: none !important;
}

/* Contenido principal */
.main {
  width: 100% !important;
  min-width: 0 !important;
}

/* La barra de título no debe tapar los dropdown */
.topbar {
  position: sticky !important;
  top: 116px !important;
  z-index: 20 !important;
}

/* Vista centrada */
.view {
  max-width: 1440px !important;
  margin: 0 auto !important;
}

/* Responsive */
@media (max-width: 1100px) {
  .sidebar {
    position: static !important;
  }

  .brand {
    padding: 12px 16px !important;
  }

  .menu {
    padding: 0 10px !important;
    overflow-x: auto !important;
  }

  .menu-item,
  .menu-parent {
    padding: 14px 12px !important;
    font-size: 14px !important;
  }

  .topbar {
    top: 0 !important;
  }
}


/* v1.37 selector resumido de documentos comerciales */
.document-type-card-compact {
  margin-top: 4px;
}

.document-type-grid-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.document-type-card-compact .document-type-option {
  min-height: 88px;
}

@media (max-width: 1100px) {
  .document-type-grid-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .document-type-grid-compact {
    grid-template-columns: 1fr !important;
  }
}


/* v1.38 fix buscador de productos sobre documentos */
.product-search-wrap {
  position: relative !important;
  z-index: 60 !important;
}

.product-search-results {
  position: absolute !important;
  top: calc(100% + 6px) !important;
  left: 0 !important;
  right: auto !important;
  min-width: max(360px, 100%) !important;
  max-width: 720px !important;
  max-height: 320px !important;
  overflow-y: auto !important;
  z-index: 999999 !important;
  background: #ffffff !important;
  border: 1px solid #dbe3ef !important;
  border-radius: 14px !important;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18) !important;
}

.product-search-results.show {
  display: block !important;
}

.table-wrap,
.table-wrap table,
.table-wrap tbody,
.table-wrap tr,
.table-wrap td {
  overflow: visible !important;
}


/* v1.38 pestañas internas de navegación — estilo Chrome v1.58 */
.open-tabs {
  max-width: none !important;
  margin: 0 !important;
  display: flex !important;
  align-items: flex-end !important;
  gap: 2px !important;
  padding: 6px 18px 0 18px !important;
  border-top: 1px solid #d4d9e0 !important;
  background: #d6dbe3 !important;
  overflow-x: auto !important;
  min-height: 42px !important;
}

.open-tab {
  position: relative !important;
  border: none !important;
  background: #c4cad4 !important;
  border-radius: 10px 10px 0 0 !important;
  padding: 9px 14px 10px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #475569 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  margin-bottom: 0 !important;
  max-width: 240px !important;
  min-width: 110px !important;
  transition: background .15s ease, color .15s ease !important;
}

.open-tab:hover {
  background: #d2d7e0 !important;
  color: #1e293b !important;
}

.open-tab.active {
  background: #1e3a8a !important;
  color: #ffffff !important;
  box-shadow: 0 -2px 0 #1e3a8a inset, 0 -1px 8px rgba(30,58,138,0.25) !important;
  z-index: 2 !important;
}

.open-tab.active:hover {
  background: #1e40af !important;
  color: #ffffff !important;
}

.tab-close {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-left: 8px !important;
  width: 18px !important;
  height: 18px !important;
  border-radius: 50% !important;
  font-weight: 700 !important;
  font-size: 14px !important;
  line-height: 1 !important;
  opacity: .75 !important;
  transition: background .15s ease, opacity .15s ease !important;
}

.tab-close:hover {
  background: rgba(0,0,0,0.12) !important;
  opacity: 1 !important;
}

.open-tab.active .tab-close {
  color: #ffffff !important;
  opacity: .9 !important;
}

.open-tab.active .tab-close:hover {
  background: rgba(255,255,255,0.22) !important;
  opacity: 1 !important;
}

.topbar {
  top: 156px !important;
}

@media (max-width: 1100px) {
  .topbar {
    top: 0 !important;
  }
}


/* v1.39 validación CUIT único */
.input.duplicated-cuit {
  border-color: #dc2626 !important;
  background: #fff1f2 !important;
}


/* v1.40 buscador de productos flotante en documentos */
.product-floating-results {
  display: none;
  max-height: 340px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .24);
  padding: 6px;
}

.product-floating-results.show {
  display: block !important;
}

.product-floating-results .product-search-result {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 12px;
  background: white;
  padding: 11px 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #0f172a;
}

.product-floating-results .product-search-result:hover {
  background: #eff6ff;
}

.product-floating-results .product-search-result span {
  color: #64748b;
  font-size: 12px;
}


/* v1.41 cancelar documento / confirmar salida */
.document-selected-notice {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
}

.doc-cancel-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.doc-cancel-btn:hover {
  background: #fecaca;
}


/* v1.42 líneas libres + buscador de producto */
.product-search-wrap .small-help {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}

.product-floating-results {
  display: none;
  max-height: 360px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .28);
  padding: 6px;
  z-index: 99999999 !important;
}

.product-floating-results.show {
  display: block !important;
}

.product-floating-results .product-search-result {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 12px;
  background: #ffffff;
  padding: 11px 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #0f172a;
}

.product-floating-results .product-search-result:hover {
  background: #eff6ff;
}

.product-floating-results .product-search-result span {
  color: #64748b;
  font-size: 12px;
}


/* v1.44 selección de producto confiable */
.product-floating-result {
  user-select: none;
  pointer-events: auto !important;
}

.product-floating-result strong,
.product-floating-result span {
  pointer-events: none;
}

.product-floating-results {
  pointer-events: auto !important;
}


/* v1.45 producto seleccionable + botón usar producto */
.product-floating-result {
  cursor: pointer !important;
}

.product-floating-result em {
  margin-top: 4px;
  color: #2563eb;
  font-style: normal;
  font-weight: 800;
  font-size: 12px;
}

.product-search-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.btn-mini {
  padding: 6px 9px !important;
  font-size: 12px !important;
  border-radius: 10px !important;
}


/* v1.46 selector inline de productos: sin datalist ni desplegable duplicado */
.product-search-wrap {
  position: relative !important;
}

.inline-product-results {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  width: min(560px, 82vw);
  z-index: 999999;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .20);
  padding: 8px;
}

.inline-product-results.show {
  display: block !important;
}

.product-inline-select {
  width: 100%;
  border: 0;
  outline: none;
  background: #ffffff;
  font-size: 14px;
}

.product-inline-select option {
  padding: 9px;
}

.product-search-results:not(.inline-product-results),
.product-floating-results {
  display: none !important;
}


/* v1.47 líneas de documentos estables */
.inline-product-results {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  width: min(620px, 86vw);
  max-height: 360px;
  overflow-y: auto;
  z-index: 9999999;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .22);
  padding: 8px;
}

.inline-product-results.show {
  display: block !important;
}

.product-result-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  border: 0;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.product-result-btn:hover {
  background: #eff6ff;
}

.product-result-btn strong {
  color: #0f172a;
}

.product-result-btn span {
  color: #64748b;
  font-size: 12px;
}

.product-result-btn b {
  grid-row: 1 / span 2;
  grid-column: 2;
  color: #2563eb;
  font-size: 13px;
}

.product-search-results:not(.inline-product-results),
.product-floating-results {
  display: none !important;
}


/* v1.48 corrección total/documentos + selector directo */
.product-direct-select {
  max-width: 150px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  padding: 6px 8px;
  background: #ffffff;
  font-size: 12px;
}

.product-search-actions {
  flex-wrap: wrap;
}

.total-box [data-total-total],
.total-box .total-row.big strong {
  color: #0f172a;
}


/* v1.49 ventas reconstruido estable */
.simple-product-cell {
  position: relative;
  min-width: 300px;
}
.inline-product-results {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  width: min(620px, 86vw);
  max-height: 360px;
  overflow-y: auto;
  z-index: 9999999;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .22);
  padding: 8px;
}
.inline-product-results.show {
  display: block !important;
}
.product-result-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  border: 0;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.product-result-btn:hover {
  background: #eff6ff;
}
.product-result-btn strong { color: #0f172a; }
.product-result-btn span { color: #64748b; font-size: 12px; }
.product-result-btn b {
  grid-row: 1 / span 2;
  grid-column: 2;
  color: #2563eb;
  font-size: 13px;
}
.product-search-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.product-direct-select {
  max-width: 180px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  padding: 6px 8px;
  background: #ffffff;
  font-size: 12px;
}

.table-wrap-autocomplete .simple-product-cell,
.compra-lines-card .simple-product-cell {
  min-width: 300px;
  max-width: 360px;
}

.table-wrap-autocomplete .inline-product-results,
.compra-lines-card .inline-product-results {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
}

.compra-doc-card {
  width: 100%;
}

.compra-doc-switch {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px !important;
}

.lista-precio-form {
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

.lista-precio-editor {
  margin-top: 14px;
}

.lista-precio-search {
  max-width: 360px;
}


/* v1.50 clientes/vendedores fix */
#venta-cliente-results,
.search-results {
  z-index: 9999999 !important;
}

#venta-cliente-results.show {
  display: block !important;
  max-height: 360px !important;
  overflow-y: auto !important;
  background: #ffffff !important;
  border: 1px solid #dbe3ef !important;
  border-radius: 14px !important;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .22) !important;
}

#venta-cliente-results .search-result-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: #ffffff;
  padding: 12px 14px;
  display: block;
  cursor: pointer;
}

#venta-cliente-results .search-result-item:hover {
  background: #eff6ff;
}

#venta-cliente-results .search-result-item strong {
  display: block;
}

#venta-cliente-results .search-result-item span {
  color: #64748b;
  font-size: 12px;
}


/* v1.51 vendedores y zonas */
.master-field {
  width: 100%;
}


/* v1.53 botón agregar línea abajo */
.line-actions-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  margin-top: 14px;
  margin-bottom: 10px;
}

.line-actions-bottom .btn {
  min-width: 160px;
}


/* v1.55 numeración automática */
.readonly-number,
input[readonly].readonly-number {
  background: #f8fafc;
  color: #475569;
  cursor: not-allowed;
}


/* archivos maestros */
.global-master-search {
  position: relative;
  width: min(360px, 34vw);
  min-width: 260px;
}

.global-master-search .input {
  border-radius: 999px;
  padding-left: 16px;
  padding-right: 16px;
  background: #ffffff;
}

.global-master-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(520px, 92vw);
  max-height: 420px;
  overflow-y: auto;
  z-index: 10000000;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .22);
  padding: 8px;
}

.global-master-results.show {
  display: block;
}

.global-master-count,
.global-master-empty {
  padding: 8px 10px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.global-master-result {
  width: 100%;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 3px 12px;
  align-items: center;
  border: 0;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.global-master-result:hover {
  background: #eff6ff;
}

.global-master-result span {
  grid-row: 1 / span 2;
  color: #2563eb;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.global-master-result strong {
  color: #0f172a;
  min-width: 0;
  overflow-wrap: anywhere;
}

.global-master-result small {
  color: #64748b;
  min-width: 0;
  overflow-wrap: anywhere;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-title-row h3 {
  margin: 0;
}

.confirm-dialog-backdrop {
  z-index: 10000010;
}

.confirm-dialog {
  width: min(440px, 92vw);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 28px 60px rgba(15, 23, 42, .32);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.confirm-dialog-header {
  padding: 14px 18px;
  background: #eef6ff;
  border-bottom: 1px solid #cbd5e1;
}

.confirm-dialog-header h3 {
  margin: 0;
  font-size: 17px;
  color: #0f172a;
}

.confirm-dialog-body {
  padding: 18px;
  font-size: 15px;
  color: #1f2937;
  line-height: 1.45;
}

.confirm-dialog-footer {
  padding: 12px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
}

.bulk-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000001;
  background: rgba(15, 23, 42, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.bulk-modal {
  width: min(1320px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .34);
  overflow: hidden;
}

.bulk-modal-header,
.bulk-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: #eef6ff;
  border-bottom: 1px solid #cbd5e1;
}

.bulk-modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.bulk-modal-header p {
  margin: 3px 0 0;
  color: #64748b;
  font-size: 13px;
}

.bulk-toolbar {
  display: grid;
  grid-template-columns: 1fr 180px 210px;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.bulk-table-wrap {
  overflow: auto;
  min-height: 280px;
}

.bulk-table-wrap table {
  min-width: 860px;
}

.bulk-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.bulk-product-row:hover {
  background: #eff6ff;
}

.bulk-product-check,
#bulk-select-visible {
  width: 18px;
  height: 18px;
}

.bulk-stock-danger {
  color: #dc2626;
  font-weight: 800;
}

.bulk-stock-warning {
  color: #d97706;
  font-weight: 800;
}

.bulk-footer {
  border-top: 1px solid #cbd5e1;
  border-bottom: 0;
}

#bulk-visible-count {
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

.product-editor-modal {
  width: min(1560px, 98vw);
  max-height: 94vh;
}

.product-editor-header {
  flex-shrink: 0;
}

.product-modal-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px 0;
  background: #f8fafc;
  border-bottom: 1px solid #dbe3ef;
  flex-wrap: wrap;
}

.product-modal-tab {
  border: 1px solid #cbd5e1;
  border-bottom: 0;
  background: #eef2f7;
  color: #334155;
  border-radius: 8px 8px 0 0;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.product-modal-tab.active {
  background: #ffffff;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.product-editor-body {
  overflow: auto;
  padding: 16px;
  background: #ffffff;
}

.product-editor-section,
.product-analysis-section {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.product-editor-notice {
  margin-bottom: 12px;
}

.product-editor-panels,
.product-analysis-columns {
  margin-top: 14px;
}

.product-editor-panel {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.product-editor-panel h3,
.product-analysis-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.product-editor-actions {
  justify-content: flex-end;
  margin-top: 18px;
  position: sticky;
  bottom: -16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 12px 0 0;
}

.product-analysis-empty {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: #64748b;
  font-weight: 800;
  background: #f8fafc;
}

.product-analysis-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.product-analysis-kpi {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  min-height: 104px;
}

.product-analysis-kpi span,
.product-analysis-kpi small {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.product-analysis-kpi strong {
  display: block;
  margin: 7px 0 5px;
  color: #0f172a;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.product-cost-chart {
  height: 190px;
  display: grid;
  grid-template-columns: repeat(12, minmax(44px, 1fr));
  gap: 8px;
  align-items: end;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  overflow-x: auto;
}

.product-cost-point {
  min-width: 44px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.product-cost-point span {
  font-size: 11px;
  color: #475569;
  font-weight: 800;
  white-space: nowrap;
}

.product-cost-bar {
  width: 100%;
  min-height: 12px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
}

.product-cost-point small {
  font-size: 11px;
  color: #64748b;
  font-weight: 800;
}

.product-analysis-lines {
  display: grid;
  gap: 9px;
}

.product-analysis-lines div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 9px;
}

.product-analysis-lines div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.product-analysis-lines span {
  color: #64748b;
  font-weight: 800;
}

.product-analysis-lines strong {
  text-align: right;
  color: #0f172a;
}

.table-wrap.product-analysis-table {
  overflow-x: auto !important;
}

.table-wrap.product-analysis-table table {
  min-width: 760px !important;
}

.master-editor-card {
  overflow: hidden;
}

.master-editor-tabs {
  margin: 12px -16px 14px;
}

.master-editor-panel {
  padding-top: 2px;
}

.master-editor-modal .master-code-kpi {
  width: min(260px, 100%);
  min-height: auto;
  margin-bottom: 12px;
}

.client-account-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.cc-access-table table {
  min-width: 920px;
}

.cc-access-table .actions {
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .global-master-search {
    width: 100%;
    min-width: 0;
    order: -1;
  }

  .global-master-results {
    left: 0;
    right: auto;
    width: min(100%, 92vw);
  }

  .bulk-toolbar {
    grid-template-columns: 1fr;
  }

  .bulk-modal-backdrop {
    align-items: stretch;
    padding: 10px;
  }

  .bulk-modal {
    max-height: 96vh;
  }

  .product-analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-editor-panels,
  .product-analysis-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .product-analysis-grid {
    grid-template-columns: 1fr;
  }

  .product-modal-tab {
    flex: 1 1 100%;
  }
}

/* Ajuste de grillas para trabajar a pantalla completa con bases grandes. */
.view {
  width: 100% !important;
  max-width: none !important;
  padding: 18px 14px !important;
}

.card {
  border-radius: 8px !important;
  padding: 16px !important;
}

.table-wrap {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
  border-radius: 8px !important;
}

.table-wrap table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}

.table-wrap.table-wrap-autocomplete {
  overflow: visible !important;
}

.table-wrap.table-wrap-autocomplete table {
  table-layout: auto !important;
}

.table-wrap th,
.table-wrap td {
  padding: 8px 9px !important;
  font-size: 13px !important;
  line-height: 1.25 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: normal !important;
}

.table-wrap th {
  font-size: 12px !important;
}

.table-wrap td.actions {
  display: table-cell !important;
  white-space: normal !important;
}

.table-wrap td.actions .btn {
  width: 100%;
  margin: 2px 0;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.table-wrap .badge {
  padding: 4px 7px;
  font-size: 11px;
}

.product-list-table th:nth-child(1),
.product-list-table td:nth-child(1) {
  width: 10%;
}

.product-list-table th:nth-child(2),
.product-list-table td:nth-child(2) {
  width: 9%;
}

.product-list-table th:nth-child(3),
.product-list-table td:nth-child(3) {
  width: 24%;
}

.product-list-table th:nth-child(4),
.product-list-table td:nth-child(4) {
  width: 6%;
}

.product-list-table th:nth-child(5),
.product-list-table td:nth-child(5),
.product-list-table th:nth-child(6),
.product-list-table td:nth-child(6),
.product-list-table th:nth-child(7),
.product-list-table td:nth-child(7) {
  width: 9%;
}

.product-list-table th:nth-child(8),
.product-list-table td:nth-child(8) {
  width: 8%;
}

.product-list-table th:nth-child(9),
.product-list-table td:nth-child(9),
.product-list-table th:nth-child(10),
.product-list-table td:nth-child(10) {
  width: 6%;
}

.product-list-table th:nth-child(11),
.product-list-table td:nth-child(11) {
  width: 10%;
}

@media (max-width: 1100px) {
  .view {
    padding: 12px 8px !important;
  }

  .card {
    padding: 12px !important;
  }

  .table-wrap th,
  .table-wrap td {
    padding: 7px 6px !important;
    font-size: 12px !important;
  }
}

/* ── Módulo Ofertas ──────────────────────────────────────────────────── */
.of-check-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--bg, #f4f7fb);
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
}

.of-check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
}

.of-check-row:hover {
  background: var(--soft-primary, #eff6ff);
}

.of-check-row input[type="checkbox"] {
  flex-shrink: 0;
}


/* Dashboard v1.56 — KPIs, notas y agenda */
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .dashboard-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.2;
}

/* Notas */
.notas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.nota-item {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 10px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
}

.nota-color-amarillo { background: linear-gradient(160deg, #fef3c7, #fde68a); border-color: #f59e0b; }
.nota-color-rosa     { background: linear-gradient(160deg, #fce7f3, #fbcfe8); border-color: #ec4899; }
.nota-color-verde    { background: linear-gradient(160deg, #d1fae5, #a7f3d0); border-color: #10b981; }
.nota-color-azul     { background: linear-gradient(160deg, #dbeafe, #bfdbfe); border-color: #3b82f6; }
.nota-color-naranja  { background: linear-gradient(160deg, #ffedd5, #fed7aa); border-color: #f97316; }
.nota-color-violeta  { background: linear-gradient(160deg, #ede9fe, #ddd6fe); border-color: #8b5cf6; }

.nota-item {
  position: relative;
  transition: transform .15s ease, box-shadow .15s ease;
}

.nota-item:hover {
  transform: translateY(-2px) rotate(-.4deg);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .12);
}

.nota-colors {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  opacity: .55;
  transition: opacity .15s ease;
}

.nota-item:hover .nota-colors { opacity: 1; }

.nota-color-chip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, .15);
  cursor: pointer;
  padding: 0;
  transition: transform .1s ease, box-shadow .1s ease;
}

.nota-color-chip:hover {
  transform: scale(1.25);
}

.nota-color-chip.active {
  border-color: #1f2937;
  border-width: 2.5px;
  box-shadow: 0 0 0 2px #ffffff inset, 0 1px 4px rgba(0, 0, 0, .2);
}

/* Color picker grande dentro del modal */
.nota-colors-pick {
  display: flex;
  gap: 10px;
}

.nota-colors-pick .nota-color-chip {
  width: 32px;
  height: 32px;
}

.btn-icon-x {
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.btn-icon-x:hover {
  background: rgba(0, 0, 0, .08);
  color: #1f2937;
}

.nota-texto {
  flex: 1;
  white-space: pre-wrap;
  outline: none;
  font-size: 13px;
  color: #1f2937;
  margin-bottom: 6px;
  min-height: 60px;
}

.nota-texto:focus {
  background: rgba(255, 255, 255, .6);
  border-radius: 4px;
}

.nota-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed rgba(0, 0, 0, .12);
  padding-top: 5px;
  font-size: 11px;
  color: #6b7280;
  gap: 6px;
}

/* Agenda */
.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.agenda-item {
  display: grid;
  grid-template-columns: auto 92px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
}

.agenda-item.hoy {
  background: #eff6ff;
  border-color: #93c5fd;
}

.agenda-item.vencido {
  background: #fef2f2;
  border-color: #fca5a5;
}

.agenda-item.completado {
  opacity: .6;
}

.agenda-item.completado .agenda-titulo {
  text-decoration: line-through;
}

.agenda-fecha {
  text-align: center;
}

.agenda-dia {
  font-weight: 600;
  font-size: 12px;
  color: #374151;
}

.agenda-hora {
  font-size: 11px;
  color: #6b7280;
}

.agenda-titulo {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
}

.agenda-desc {
  color: #6b7280;
  margin-top: 2px;
}

.agenda-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Dashboard modules — drag & drop */
.dashboard-modules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .dashboard-modules { grid-template-columns: 1fr; }
}

.dashboard-module {
  position: relative;
  transition: opacity .15s ease, transform .15s ease;
}

.dashboard-module.dragging {
  opacity: .5;
  transform: scale(.99);
}

.dashboard-module-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.dashboard-drag-handle {
  cursor: grab;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: -2px;
  font-size: 18px;
  user-select: none;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background .1s ease, color .1s ease;
}

.dashboard-drag-handle:hover {
  background: #e5e7eb;
  color: #475569;
}

.dashboard-drag-handle:active { cursor: grabbing; }

/* KPI alert + sub label */
.kpi-alert {
  border-left: 4px solid #b91c1c;
  background: linear-gradient(135deg, #fff, #fef2f2);
}

.kpi-alert .value { color: #991b1b; }

.kpi-sub {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* Modal */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999999;
  animation: appModalFadeIn .15s ease;
}

@keyframes appModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.app-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .35);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: appModalSlideIn .2s ease;
}

@keyframes appModalSlideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.app-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.app-modal-header h3 { margin: 0; font-size: 16px; }

.app-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.app-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
}

.ref-comprobante,
.ref-cliente,
.ref-proveedor {
  color: #1d4ed8;
  text-decoration: underline;
  cursor: pointer;
}
.ref-comprobante:hover,
.ref-cliente:hover,
.ref-proveedor:hover {
  color: #1e3a8a;
}
