:root {
  --red: #e51400;
  --red2: #e51400;
  --ink: #23262b;
  --muted: #747982;
  --line: #e7e9ed;
  --bg: #fff;
  --white: #fff;
  --soft: #fff3f3;
  --good: #1f8a4c;
  --warning: #b26a00;
  --shadow: none;
  --radius: 0;
  --header: 56px;
}

/* Tablas responsive de Obras/Servicios, Unidades y Rubros */
#module-obras .table-wrap table,
#module-unidades .table-wrap table,
:is(#module-rubros, .budget-rubro-picker) .table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.costo-ref {
  display: block;
  width: 100%;
  background: #eaf8ef;
  border-color: #b7dfc8;
  color: #176b3e;
  padding: 6px 4px;
  border: 1px solid #dce1e6;
  border-radius: 0;
  font-size: 11px;
}

#module-obras td,
#module-obras th,
#module-unidades td,
#module-unidades th,
:is(#module-rubros, .budget-rubro-picker) td,
:is(#module-rubros, .budget-rubro-picker) th {
  overflow-wrap: anywhere;
  min-width: 0;
}

:is(#module-rubros, .budget-rubro-picker) th {
  font-size: 0.7rem !important;
  font-weight: bolder;
}

#module-obras th:last-child,
#module-unidades th:last-child {
  width: 150px;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-column-number {
  width: 4%;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-column-name {
  width: 30%;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-column-stage {
  width: 7%;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-column-unit {
  width: 5%;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-column-materials,
:is(#module-rubros, .budget-rubro-picker) .rubro-column-labor,
:is(#module-rubros, .budget-rubro-picker) .rubro-column-expenses {
  width: 9%;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-column-price {
  width: 11%;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-column-status {
  width: 6%;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-column-actions {
  width: 10%;
}

.budget-rubro-picker .rubro-column-quantity,
.budget-rubro-picker .rubro-column-select {
  width: 8%;
}

@media (min-width: 769px) {
  :is(#module-rubros, .budget-rubro-picker) .table-wrap table {
    font-size: 10.5px;
  }

  :is(#module-rubros, .budget-rubro-picker) .table-wrap th {
    padding: 8px 4px;
    font-size: 9.5px;
  }

  :is(#module-rubros, .budget-rubro-picker) .table-wrap td {
    padding: 8px 4px;
  }

  :is(#module-rubros, .budget-rubro-picker) .table-wrap .hint {
    font-size: 9px;
  }

  :is(#module-rubros, .budget-rubro-picker) .rubro-total-btn {
    padding: 6px 4px;
  }

  :is(#module-rubros, .budget-rubro-picker) .rubro-total-btn strong {
    font-size: 10.5px;
  }

  #module-rubros .rubro-utility-control {
    max-width: 76px;
    height: 30px;
  }

  #module-rubros .rubro-utility-control > span {
    padding-right: 5px;
    font-size: 10px;
  }

  #module-rubros .actions {
    gap: 3px;
  }

  #module-rubros .actions .row-btn {
    width: 30px;
    height: 30px;
  }
}

.rubro-stage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 7px;
  border-radius: 0;
  background: #f1f3f5;
  color: #505762;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

#module-rubros .rubro-stage-select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 5px 2px;
  border: 1px solid var(--line);
  border-radius: 0;
  background-color: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

#module-rubros .rubro-column-number {
  width: 3%;
}
#module-rubros .rubro-column-category {
  width: 14%;
}
#module-rubros .rubro-column-name {
  width: 24%;
}
#module-rubros .rubro-column-unit {
  width: 4%;
}
#module-rubros .rubro-column-materials,
#module-rubros .rubro-column-labor,
#module-rubros .rubro-column-expenses {
  width: 8%;
}
#module-rubros .rubro-column-price {
  width: 10%;
}
#module-rubros .rubro-column-actions {
  width: 8%;
}

#module-rubros .rubro-category-select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 5px 2px;
  border: 1px solid var(--line);
  border-radius: 0;
  background-color: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
#module-rubros .rubro-category-select:focus {
  outline: 2px solid #b7dfc8;
  outline-offset: 1px;
}
#module-rubros .rubro-category-select:disabled {
  cursor: default;
  opacity: 0.65;
}
#module-rubros .rubro-category-select[aria-busy="true"] {
  cursor: wait;
}

#module-rubros .rubro-stage-select:focus {
  outline: 2px solid #b7dfc8;
  outline-offset: 1px;
}

#module-rubros .rubro-stage-select:disabled {
  cursor: default;
  opacity: 0.65;
}

#module-rubros .rubro-stage-select[aria-busy="true"] {
  cursor: wait;
}

.rubro-total-btn {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #dce1e6;
  border-radius: 0;
  background: #f7f8f9;
  color: #353a42;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    transform 0.16s ease;
}

.rubro-total-btn:hover {
  border-color: #c2c8ce;
  background: #fff;
  transform: translateY(-1px);
}

.rubro-total-btn strong {
  overflow-wrap: normal;
  white-space: nowrap;
  font-size: 12px;
}

#module-rubros .rubro-admin-cell {
  cursor: pointer;
  transition:
    background-color 0.16s ease,
    box-shadow 0.16s ease;
}

#module-rubros .rubro-admin-cell:hover {
  background-color: #fff5f5;
  box-shadow: none;
}

#module-rubros .rubro-admin-cell:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: -3px;
  background-color: #fff5f5;
}

.rubro-utility-control {
  width: 100%;
  max-width: 92px;
  height: 34px;
  border: 1px solid #d9dde2;
  border-radius: 0;
  background: #fff;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.rubro-utility-control .rubro-utility-input,
.field .rubro-utility-control input {
  width: 100%;
  min-width: 0;
  max-width: none;
  height: 100%;
  padding: 0 4px 0 8px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: right;
}

.rubro-utility-control > span {
  flex: 0 0 auto;
  padding-right: 8px;
  color: #717780;
  font-size: 12px;
  font-weight: 800;
}

.rubro-utility-control:focus-within {
  border-color: var(--red);
  box-shadow: none;
}

.rubro-utility-control .rubro-utility-input:focus,
.field .rubro-utility-control input:focus {
  outline: none;
  box-shadow: none;
}

.rubro-utility-input.saved {
  background: #f2fbf6;
}

.rubro-utility-input.invalid {
  background: #fff4f4;
}

.rubro-expense-setting {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 11px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  white-space: nowrap;
}

.rubro-expense-setting > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rubro-expense-setting label {
  height: 32px;
  display: flex;
  align-items: center;
  border: 1px solid #d9dde2;
  border-radius: 0;
  overflow: hidden;
}

.rubro-expense-setting label:focus-within {
  border-color: var(--red);
  box-shadow: none;
}

.rubro-expense-setting input {
  width: 64px;
  height: 100%;
  padding: 0 4px 0 8px;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: right;
  font-weight: 800;
}

.rubro-expense-setting input[readonly] {
  color: var(--muted);
}

.rubro-expense-setting label strong {
  padding-right: 8px;
  color: var(--muted);
  font-size: 12px;
}

.rubro-expense-setting .row-btn {
  width: 32px;
  height: 32px;
}

.rubro-expense-setting .row-btn.good {
  color: #1d7b4a;
}

.rubro-expense-setting [hidden] {
  display: none !important;
}

.field .rubro-utility-control.form-control {
  max-width: none;
  height: 44px;
  margin: 0;
  text-transform: none;
}

.rubro-total-btn.mat {
  background: #f2f7ff;
  border-color: #d9e6fa;
  color: #315d91;
}

.rubro-gasto {
  background: #f1bdbd;
  border-color: #f1bdbd;
  color: #951313;
  font-size: 10.5px;
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #f1bdbd;
  border-radius: 0;
  display: flex;
  align-items: center;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    transform 0.16s ease;
}

.rubro-total-btn.mdo {
  background: #fff8ea;
  border-color: #f1dfbd;
  color: #956313;
}

.rubro-total-btn.gas {
  background: #fff2f3;
  border-color: #efd8da;
  color: #971b23;
}

/* Presupuestos */
#module-presupuestos .table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

#module-presupuestos th,
#module-presupuestos td {
  min-width: 0;
  overflow-wrap: anywhere;
}

#module-presupuestos th:nth-child(1) {
  width: 14%;
}

#module-presupuestos th:nth-child(2) {
  width: 5%;
}

#module-presupuestos th:nth-child(3) {
  width: 10%;
}

#module-presupuestos th:nth-child(4) {
  width: 12%;
}

#module-presupuestos th:nth-child(5),
#module-presupuestos th:nth-child(6),
#module-presupuestos th:nth-child(7) {
  width: 10%;
}

#module-presupuestos th:nth-child(8) {
  width: 10%;
}

#module-presupuestos th:nth-child(9) {
  width: 7%;
}

#module-presupuestos th:last-child {
  width: 12%;
}

.budget-breakdown-cell {
  display: grid;
  gap: 2px;
  justify-items: end;
  text-align: right;
}

.budget-breakdown-cell span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.budget-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid #eadfe0;
  border-radius: 0;
  background: #fffafa;
}

.budget-detail-head > div:first-child {
  min-width: 0;
}

.budget-detail-head span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.budget-detail-head h4 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 19px;
  overflow-wrap: anywhere;
}

.budget-detail-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.budget-meta-grid {
  display: grid;
  grid-template-columns: 0.65fr 1.25fr 1.3fr 1fr;
  gap: 9px;
  margin-top: 10px;
}

.budget-meta-grid > div {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
}

.budget-meta-grid small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.budget-meta-grid strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.budget-meta-grid .budget-total-card {
  border-color: #ead7d9;
  background: #fff7f7;
}

.budget-meta-grid .budget-total-card strong {
  color: var(--red);
  font-size: 18px;
}

.budget-items-wrap {
  max-height: min(62vh, 650px);
}

.budget-items-table th:first-child {
  min-width: 48px;
}

.budget-items-table th:nth-child(2) {
  min-width: 130px;
}

.budget-items-table th:nth-child(3) {
  min-width: 210px;
}

.budget-items-table th:nth-child(n + 6):nth-child(-n + 14) {
  min-width: 82px;
}

.budget-items-table th:last-child {
  min-width: 92px;
}

.budget-stage-row td {
  padding: 8px 10px !important;
  border-top: 2px solid #e5d6d8 !important;
  background: #f7f1f2;
}

.budget-stage-row strong {
  color: var(--red2);
  font-size: 12px;
}

.budget-stage-row .budget-stage-total {
  color: var(--red2);
  text-align: right;
  white-space: nowrap;
}

.budget-stage-row td:not(:first-child) {
  text-align: right;
}

.budget-stage-percentage {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 68px;
  height: 25px;
  overflow: hidden;
  border: 1px solid #d8dade;
  border-radius: 0;
  background: #fff;
  vertical-align: middle;
}

.budget-stage-percentage:focus-within {
  border-color: var(--red);
  box-shadow: none;
}

.budget-stage-percentage input {
  width: 48px;
  min-width: 0;
  height: 23px;
  padding: 0 2px 0 5px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 10px;
  text-align: right;
}

.budget-stage-percentage span {
  padding-right: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.budget-general-percentage {
  display: flex;
  align-items: center;
  gap: 4px;
}

.budget-stage-editor {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

.budget-stage-editor .budget-stage-percentage {
  width: 56px;
}

.budget-stage-editor .budget-stage-percentage input {
  width: 37px;
}

.budget-general-percentage .row-btn {
  width: 25px;
  height: 25px;
  min-width: 25px;
  padding: 0;
  border-radius: 0;
  font-size: 10px;
}

#mainModal .modal-card.budget-detail-modal,
#subModal .modal-card.budget-item-editor-modal {
  width: calc(100vw - 20px);
  max-width: none;
  max-height: calc(100dvh - 20px);
}

.budget-detail-modal .modal-head,
.budget-item-editor-modal .modal-head {
  height: 48px;
  padding: 0 13px;
}

.budget-detail-modal .modal-head h3,
.budget-item-editor-modal .modal-head h3 {
  font-size: 16px;
}

.budget-detail-modal .modal-body,
.budget-item-editor-modal .modal-body {
  padding: 9px 11px;
}

.budget-detail-modal .budget-detail-head {
  padding: 7px 9px;
  border-radius: 0;
}

.budget-detail-modal .budget-detail-head h4 {
  margin-top: 1px;
  font-size: 15px;
}

.budget-detail-modal .budget-detail-actions .btn,
.budget-item-editor-modal .btn {
  height: 34px;
  padding: 0 10px;
  font-size: 11px;
}

.budget-detail-modal .budget-meta-grid {
  grid-template-columns: 0.45fr 1fr 1fr 0.8fr 0.8fr 0.75fr;
  gap: 6px;
  margin-top: 6px;
}

.budget-detail-modal .budget-meta-grid > div {
  gap: 1px;
  padding: 5px 8px;
  border-radius: 0;
}

.budget-detail-modal .budget-meta-grid strong {
  font-size: 11px;
}

.budget-detail-modal .budget-meta-grid .budget-total-card strong {
  font-size: 14px;
}

.budget-detail-modal .history-table-wrap {
  margin-top: 6px;
  border-radius: 0;
}

.budget-detail-modal .budget-items-table th,
.budget-detail-modal .budget-items-table td {
  padding: 5px 6px;
  font-size: 10px;
  white-space: nowrap;
}

.budget-detail-modal .budget-items-table td:nth-child(2),
.budget-detail-modal .budget-items-table td:nth-child(3) {
  white-space: normal;
}

.budget-detail-modal .budget-items-table th:nth-child(n + 5):nth-child(-n + 14),
.budget-detail-modal
  .budget-items-table
  td:nth-child(n + 5):nth-child(-n + 14) {
  text-align: right;
}

.budget-detail-modal .budget-stage-row td {
  padding: 5px 7px !important;
}

.budget-detail-modal .budget-stage-row .budget-stage-actions-spacer {
  text-align: center;
}

.budget-detail-modal .budget-items-table .actions {
  gap: 3px;
}

.budget-detail-modal .budget-items-table .row-btn {
  width: 25px;
  height: 25px;
  min-width: 25px;
  padding: 0;
  border-radius: 0;
  font-size: 10px;
}

.budget-detail-modal > .modal-body > .form-actions {
  margin-top: 7px;
}

@media (min-width: 761px) {
  .budget-item-editor-form .form-grid {
    grid-template-columns: minmax(250px, 2fr) repeat(4, minmax(105px, 1fr));
    gap: 7px 9px;
  }

  .budget-item-editor-form .budget-rubro-search-field {
    grid-column: span 2;
  }
}

.budget-item-editor-form .field label {
  margin-bottom: 3px;
  font-size: 9px;
}

.budget-item-editor-form .field input,
.budget-item-editor-form .field select,
.budget-item-editor-form .form-control {
  height: 34px;
  border-radius: 0;
  font-size: 11px;
}

.budget-item-editor-form .rubro-item-total {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 0;
  font-size: 12px;
}

.budget-item-editor-form .form-actions {
  margin-top: 8px;
}

.budget-item-editor-form .autocomplete-list {
  max-height: min(48vh, 300px);
}

@media (max-width: 760px) {
  #module-presupuestos .table-wrap table,
  #module-presupuestos .table-wrap thead,
  #module-presupuestos .table-wrap tbody,
  #module-presupuestos .table-wrap tr,
  #module-presupuestos .table-wrap th,
  #module-presupuestos .table-wrap td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }

  #module-presupuestos .table-wrap thead {
    display: none;
  }

  #module-presupuestos .table-wrap tbody {
    padding: 7px;
    display: grid;
    gap: 8px;
  }

  #module-presupuestos .table-wrap tr {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
  }

  #module-presupuestos .table-wrap td {
    padding: 4px 2px;
    border: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
    font-size: 11px;
  }

  #module-presupuestos .table-wrap td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    color: #858a92;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
  }

  #module-presupuestos .table-wrap td.empty {
    display: block;
    padding: 18px 8px;
    text-align: center;
  }

  #module-presupuestos .table-wrap td.empty::before {
    content: none;
  }

  #module-presupuestos .budget-breakdown-cell {
    margin-left: auto;
  }

  #module-presupuestos .actions {
    margin-left: auto;
    flex-wrap: wrap;
  }

  #module-presupuestos .row-btn {
    width: 32px;
    height: 32px;
  }

  #module-obras .table-wrap table,
  #module-obras .table-wrap thead,
  #module-obras .table-wrap tbody,
  #module-obras .table-wrap tr,
  #module-obras .table-wrap th,
  #module-obras .table-wrap td,
  #module-unidades .table-wrap table,
  #module-unidades .table-wrap thead,
  #module-unidades .table-wrap tbody,
  #module-unidades .table-wrap tr,
  #module-unidades .table-wrap th,
  #module-unidades .table-wrap td,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap table,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap thead,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap tbody,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap tr,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap th,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }

  #module-obras .table-wrap thead,
  #module-unidades .table-wrap thead,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap thead {
    display: none;
  }

  #module-obras .table-wrap tbody,
  #module-unidades .table-wrap tbody,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap tbody {
    padding: 7px;
    display: grid;
    gap: 8px;
  }

  #module-obras .table-wrap tr,
  #module-unidades .table-wrap tr,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 8px;
    background: #fff;
  }

  #module-obras .table-wrap td,
  #module-unidades .table-wrap td,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap td {
    border: 0;
    padding: 4px 2px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
    font-size: 11px;
  }

  #module-obras .table-wrap td::before,
  #module-unidades .table-wrap td::before,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #858a92;
    font-weight: 900;
    text-align: left;
  }

  #module-obras .table-wrap td.empty,
  #module-unidades .table-wrap td.empty,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap td.empty {
    display: block;
    text-align: center;
    padding: 18px 8px;
  }

  #module-obras .table-wrap td.empty::before,
  #module-unidades .table-wrap td.empty::before,
  :is(#module-rubros, .budget-rubro-picker) .table-wrap td.empty::before {
    display: none;
    content: none;
  }

  #module-obras .actions,
  #module-unidades .actions,
  #module-rubros .actions {
    margin-left: auto;
    flex-wrap: wrap;
  }

  #module-obras .row-btn,
  #module-unidades .row-btn,
  #module-rubros .row-btn {
    width: 32px;
    height: 32px;
  }

  :is(#module-rubros, .budget-rubro-picker) .rubro-total-btn {
    width: min(190px, 64%);
    margin-left: auto;
  }

  #module-rubros .rubro-utility-control {
    width: min(190px, 64%);
    max-width: none;
    margin-left: auto;
  }

  #module-obras .obra-progress-cell {
    width: min(150px, 62%);
    display: grid;
    justify-items: end;
    gap: 3px;
  }

  #module-obras .progress {
    width: 100%;
  }
}

@media (max-width: 640px) {
  #module-obras .module-head {
    gap: 8px;
  }

  #module-obras #btnAddObra {
    width: 42px;
    min-width: 42px;
    padding: 0;
    font-size: 0;
  }

  #module-obras #btnAddObra i {
    font-size: 14px;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: Inter, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

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

.login-body {
  overflow: hidden;
  background: #fff;
}

.login-shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  max-width: 1180px;
  margin: auto;
  padding: 30px;
  gap: 30px;
  align-items: stretch;
}

.brand-panel {
  border-radius: 0;
  background: #fff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: 50px;
  box-shadow: none;
}

.brand-panel p {
  max-width: 420px;
  line-height: 1.5;
  opacity: 0.9;
}

.brand-title {
  font-weight: 900;
  font-size: 56px;
  letter-spacing: -2px;
}

.brand-subtitle {
  font-size: 18px;
  letter-spacing: 8px;
  font-weight: 800;
  opacity: 0.92;
}

.brand-mark {
  width: 72px;
  height: 72px;
  color: var(--red);
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-mark-xl {
  width: 150px;
  height: 150px;
  color: #fff;
}

.brand-mark-sm {
  width: 45px;
  height: 45px;
}

.login-card {
  align-self: center;
  background: #fff;
  border-radius: 0;
  padding: 42px;
  box-shadow: none;
  max-width: 470px;
  width: 100%;
  justify-self: center;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 34px;
}

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

.login-card input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 14px;
  outline: none;
}

.login-card input:focus {
  border-color: var(--red);
  box-shadow: none;
}

.login-foot {
  margin-top: 22px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.mobile-brand {
  display: none;
  align-items: center;
  gap: 10px;
  color: var(--red);
  margin-bottom: 20px;
}

.mobile-brand .brand-mark {
  width: 42px;
  height: 42px;
}

.company-login-title {
  margin: 28px 0 10px;
  color: #363a40;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.company-login-grid {
  display: grid;
  gap: 10px;
  width: min(460px, 100%);
}

.company-login-option {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  padding: 10px 14px;
  display: grid;
  /*grid-template-columns: 54px minmax(0, 1fr) 20px;*/
  align-items: center;
  gap: 12px;
  color: #363a40;
  text-align: left;
  transition: 0.16s;
}

.company-login-option:hover,
.company-login-option.selected {
  border-color: var(--red);
  background: #fff5f5;
  box-shadow: none;
}

.company-login-logo {
  width: 100%;
  /*height: 54px;*/
  border-radius: 0;
  /*border: 1px solid #eceef0;*/
  /*background: #fff;*/
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--red);
  font-size: 22px;
}

.company-login-logo img {
  /*width: 100%;*/
  height: 80px;
  object-fit: contain;
  padding: 4px;
}

.company-login-check {
  color: var(--red);
  opacity: 0;
}

.company-login-option.selected .company-login-check {
  opacity: 1;
}

.selected-company-mobile {
  display: none;
  border: 1px solid #ead7d9;
  background: #fff5f5;
  color: var(--red);
  border-radius: 0;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn {
  border: 0;
  border-radius: 0;
  height: 44px;
  padding: 0 16px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: 0.16s;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--red2);
  transform: translateY(-1px);
}

.btn-outline {
  background: #fff;
  color: var(--red);
  border: 1px solid rgba(229, 20, 0, 0.25);
}

.btn-danger {
  background: #fff0f0;
  color: #a40d14;
}

.btn-block {
  width: 100%;
  margin-top: 22px;
}

.btn-sm {
  height: 34px;
  padding: 0 11px;
  border-radius: 0;
  font-size: 12px;
}

.form-msg {
  min-height: 22px;
  margin-top: 12px;
  font-size: 13px;
  text-align: center;
}

.form-msg.loading {
  color: var(--muted);
}

.form-msg.error {
  color: var(--red);
}

.app-body {
  overflow: hidden;
  background: #fff;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: relative;
  z-index: 10;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}

.app-brand-button:focus-visible {
  outline: 3px solid rgba(229, 20, 0, 0.2);
  outline-offset: 4px;
}

.app-brand strong {
  font-size: 22px;
  display: block;
  line-height: 1;
}

.app-brand span {
  font-size: 10px;
  letter-spacing: 4px;
  font-weight: 900;
  color: var(--red);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-btn {
  height: 40px;
  border: 1px solid #ead7d9;
  background: #fff5f5;
  color: var(--red);
  border-radius: 0;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
}

.home-btn:hover {
  background: #ffecef;
  border-color: #e4bcc0;
}

.home-btn i {
  font-size: 13px;
}

.user-pill {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 9px;
  align-items: center;
  background: #f5f6f7;
  border-radius: 0;
  padding: 7px 12px;
}

.user-pill i {
  grid-row: 1/3;
  color: var(--red);
}

.user-pill span {
  font-size: 12px;
  font-weight: 800;
}

.user-pill small {
  color: var(--muted);
  font-size: 10px;
}

.company-pill {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 9px;
  align-items: center;
  border: 1px solid #ead5d7;
  background: #fff7f7;
  color: var(--text);
  border-radius: 0;
  padding: 7px 12px;
  cursor: pointer;
  text-align: left;
}

.company-pill i {
  grid-row: 1/3;
  color: var(--red);
}

.company-pill span {
  font-size: 12px;
  font-weight: 900;
}

.company-pill small {
  color: var(--red);
  font-size: 9px;
  font-weight: 800;
}

.company-list-text {
  display: block;
  max-width: 230px;
  color: #4f545b;
  font-size: 11px;
  line-height: 1.35;
}

.company-editor {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.company-editor-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.company-editor-heading h4 {
  margin: 0 0 3px;
}

.company-editor-heading span {
  color: var(--muted);
  font-size: 11px;
}

.company-logo-preview,
.company-table-logo {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--red);
}

.company-logo-preview {
  width: 72px;
  height: 54px;
  border-radius: 0;
  font-size: 22px;
}

.company-table-logo {
  width: 52px;
  height: 38px;
  border-radius: 0;
}

.company-logo-preview img,
.company-table-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.row-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn,
.back-btn,
.modal-x {
  border: 0;
  background: #f4f5f6;
  width: 40px;
  height: 40px;
  border-radius: 0;
  color: var(--ink);
  display: grid;
  place-items: center;
}

.icon-btn:hover,
.back-btn:hover {
  background: #eee;
}

.dashboard-main {
  height: calc(100dvh - var(--header));
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 22px 24px 14px;
  overflow: hidden;
  max-width: 1400px;
  margin: auto;
}

.dashboard-copy h1 {
  margin: 0;
  font-size: 27px;
}

.dashboard-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.menu-grid {
  align-self: center;
  display: grid;
  grid-template-columns: repeat(8, minmax(140px, 1fr));
  gap: 16px;
  width: 100%;
  margin: 0 auto;
}

.menu-card {
  min-height: 145px;
  border: 1px solid #eceef1;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ink);
  font-weight: 900;
  font-size: 15px;
  transition: 0.18s;
}

.menu-card i {
  font-size: 34px;
  color: var(--red);
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: none;
  border-color: rgba(229, 20, 0, 0.18);
}

.dash-foot {
  display: flex;
  justify-content: space-between;
  color: #8a8f97;
  font-size: 11px;
  padding-top: 10px;
}

.module-screen {
  position: fixed;
  z-index: 20;
  inset: var(--header) 0 0;
  background: var(--bg);
  padding: 1px 22px 18px 22px;
  display: none;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.module-screen.open {
  display: grid;
}

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

.module-head > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.module-head h2 {
  margin: 0;
  font-size: 18px;
}

.head-actions {
  display: flex;
  gap: 8px;
}

#module-rubros .head-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#module-rubros .head-actions .btn {
  white-space: nowrap;
}

#module-rubros .module-toolbar {
  flex-wrap: wrap;
}

.catalog-admin-select {
  height: 42px;
  min-width: 180px;
  max-width: 240px;
  padding: 0 38px 0 13px;
  border: 1px solid var(--line);
  border-radius: 0;
  background-color: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.catalog-admin-select:focus {
  border-color: var(--red);
  box-shadow: none;
}

.rubro-city-expense-row {
  background: #fff7f7;
}

@media (max-width: 640px) {
  #module-rubros .module-head {
    align-items: stretch;
    flex-direction: column;
  }

  #module-rubros .head-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #module-rubros .head-actions .btn {
    min-width: 0;
    justify-content: center;
    white-space: normal;
  }

  .catalog-admin-select {
    width: 100%;
    max-width: none;
  }
}

.module-toolbar,
.filters-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.search-box {
  height: 42px;
  flex: 1;
  min-width: 180px;
  max-width: 430px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 9px;
}

.search-box i {
  color: #9ca1a8;
}

.search-box input {
  border: 0;
  outline: 0;
  width: 100%;
  background: transparent;
}

.module-toolbar .category-filter-box {
  flex: 0 1 220px;
  min-width: 180px;
  max-width: 240px;
}

.module-toolbar select,
.filters-row select,
.filters-row input {
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0;
  padding: 0 12px;
  outline: 0;
  min-width: 135px;
}

.summary-chip {
  background: #fff;
  border: 1px solid var(--line);
  height: 42px;
  border-radius: 0;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  white-space: nowrap;
}

.summary-chip strong {
  font-size: 13px;
}

.danger-lite {
  background: #fff7f7;
  border-color: #f2d8da;
  color: #8d1117;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.table-wrap th {
  position: sticky;
  top: 0;
  background: #f7f8f9;
  z-index: 1;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #727780;
  padding: 5px;
  border-bottom: 1px solid var(--line);
}

.table-wrap td {
  padding: 11px 12px;
  border-bottom: 1px solid #eff0f2;
  font-size: 13px;
  vertical-align: middle;
}

.table-wrap tr:hover td {
  background: #fcfcfd;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.row-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 0;
  background: #f3f4f5;
  color: #444;
}

.row-btn:hover {
  background: #e8eaed;
}

.row-btn.red {
  color: var(--red);
  background: #fff2f2;
}

.badge {
  display: inline-flex;
  height: 26px;
  padding: 0 9px;
  border-radius: 0;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
}

.badge.active {
  background: #eaf7ef;
  color: #1c7b43;
}

.badge.inactive {
  background: #f0f1f2;
  color: #777;
}

.badge.mat {
  background: #eef3ff;
  color: #3456a4;
}

.badge.mdo {
  background: #f5efff;
  color: #6e3ca5;
}

.badge.gas {
  background: #fff3df;
  color: #9a5d00;
}

.badge.rub {
  background: #e9f7f0;
  color: #23734a;
}

.badge.sub {
  background: #e8f5f3;
  color: #156b63;
}

.badge.emp {
  background: #eef3ff;
  color: #3456a4;
}

.badge.work-type.obra {
  background: #eef3ff;
  color: #3456a4;
  border: 1px solid #cdd9f4;
}

.badge.work-type.servicio {
  background: #f5efff;
  color: #6e3ca5;
  border: 1px solid #ddd0ef;
}

.progress {
  height: 8px;
  background: #eceef0;
  border-radius: 0;
  overflow: hidden;
  width: 130px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--red);
  border-radius: 0;
}

.report-total {
  position: absolute;
  right: 22px;
  top: 76px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 13px;
  font-size: 12px;
}

.report-total strong {
  color: var(--red);
  font-size: 15px;
}

.modal {
  position: fixed;
  z-index: 60;
  inset: 0;
  background: rgba(17, 20, 24, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100dvh - 32px);
  background: #fff;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.modal-card.wide {
  width: min(1040px, 100%);
}

.modal-head {
  height: 62px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  margin: 0;
  font-size: 19px;
}

.modal-x {
  font-size: 25px;
}

.modal-body {
  padding: 16px 18px;
  overflow: auto;
}

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

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

.field label {
  font-size: 11px;
  font-weight: 800;
  color: #666c75;
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 12px;
  outline: 0;
  background: #fff;
}

.field textarea {
  min-height: 78px;
  padding: 10px 12px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--red);
  box-shadow: none;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  width: 48px;
  height: 27px;
  border-radius: 0;
  background: #cfd3d7;
  position: relative;
  border: 0;
}

.switch span {
  position: absolute;
  width: 21px;
  height: 21px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 0;
  transition: 0.15s;
}

.switch.on {
  background: var(--red);
}

.switch.on span {
  left: 24px;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
}

.lookup-status {
  min-height: 19px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #ddd;
  border-top-color: var(--red);
  border-radius: 0;
  animation: spin 0.7s linear infinite;
}

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

.invoice-items {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
}

.invoice-items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f8f9fa;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table th,
.mini-table td {
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  text-align: left;
}

.invoice-total {
  font-size: 17px;
  font-weight: 900;
  color: var(--red);
}

.autocomplete {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  max-height: 190px;
  overflow: auto;
  display: none;
}

.autocomplete-list.open {
  display: block;
}

.autocomplete-item {
  padding: 10px 11px;
  border-bottom: 1px solid #f1f2f3;
  cursor: pointer;
  font-size: 12px;
}

.autocomplete-item:hover {
  background: #fff5f5;
}

.autocomplete-item small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

/* Buscador de materiales del módulo Pedidos. */
#orderMaterialSuggestions.autocomplete-list {
  max-height: min(46vh, 320px);
  padding: 6px;
  overflow-x: hidden;
}

#orderMaterialSuggestions.autocomplete-list.open {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#orderMaterialSuggestions .autocomplete-item {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 9px 11px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  white-space: normal;
}

#orderMaterialSuggestions .order-material-option {
  cursor: pointer;
}

#orderMaterialSuggestions .order-material-option:hover,
#orderMaterialSuggestions .order-material-option:focus-visible {
  background: #fff3f3;
  outline: none;
}

#orderMaterialSuggestions .order-material-category {
  display: block;
  margin-bottom: 2px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1.25;
  text-transform: uppercase;
}

#orderMaterialSuggestions strong {
  display: block;
  width: 100%;
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

#orderMaterialSuggestions small {
  font-size: 10px;
  line-height: 1.25;
}

#orderMaterialSuggestions .order-material-empty {
  cursor: default;
}

@media (max-width: 600px) {
  #orderMaterialSuggestions.autocomplete-list {
    max-height: min(42vh, 260px);
  }

  #orderMaterialSuggestions .autocomplete-item {
    padding: 8px 10px;
  }
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #24282e;
  color: #fff;
  border-radius: 0;
  padding: 11px 15px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--red);
}

.charts-filters {
  padding-right: 0;
}

.charts-filters {
  padding-right: 0;
}

.charts-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  overflow: hidden;
}

.chart-card {
  min-height: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.chart-card h3 {
  font-size: 12px;
  margin: 0 0 7px;
  color: #555b63;
}

.chart-card canvas {
  max-width: 100%;
  max-height: 100%;
}

.chart-card[data-chart-card="budget"] {
  grid-column: 1/3;
  grid-row: 1;
}

.chart-card[data-chart-card="daily"] {
  grid-column: 3/5;
  grid-row: 1;
}

.chart-card[data-chart-card="expenses"] {
  grid-column: 5/7;
  grid-row: 1;
}

.chart-card[data-chart-card="materials"] {
  grid-column: 1/4;
  grid-row: 2;
}

.chart-card[data-chart-card="labor"] {
  grid-column: 4/7;
  grid-row: 2;
}

#chartMobileSelect {
  display: none;
}

.roles-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  min-height: 360px;
}

.roles-list {
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: auto;
}

.role-item {
  padding: 11px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.role-item.active {
  background: #fff2f2;
  color: var(--red);
  font-weight: 800;
}

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

.perm-check {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.empty {
  padding: 28px !important;
  text-align: center;
  color: #969aa1 !important;
}

@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    padding: 16px;
    gap: 14px;
  }

  .brand-panel {
    display: flex;
    padding: 18px;
    border-radius: 0;
  }

  .brand-panel > div > img,
  .brand-panel p {
    display: none;
  }

  .company-login-title {
    margin-top: 0;
  }

  .company-login-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .company-login-option {
    min-height: 82px;
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 8px;
    text-align: center;
    font-size: 11px;
  }

  .company-login-logo {
    width: 42px;
    height: 42px;
  }

  .company-login-check {
    display: none;
  }

  .mobile-brand {
    display: flex;
  }

  .login-card {
    padding: 28px;
  }

  .login-body {
    overflow: auto;
  }

  .selected-company-mobile {
    display: block;
  }

  .menu-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
  }

  .menu-card {
    min-height: 120px;
  }

  .module-toolbar {
    flex-wrap: wrap;
  }

  .summary-chip {
    display: none;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-card {
    display: none !important;
  }

  .chart-card.mobile-active {
    display: grid !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  .charts-grid {
    grid-template-rows: 1fr;
  }

  .charts-filters #chartMobileSelect {
    display: block;
  }

  .report-total {
    display: none;
  }
}

@media (max-width: 640px) {
  :root {
    --header: 62px;
  }

  .app-header {
    padding: 0 12px;
  }

  .header-right {
    gap: 6px;
  }

  .home-btn {
    height: 38px;
    padding: 0 9px;
    font-size: 11px;
    gap: 5px;
  }

  .app-brand {
    gap: 8px;
  }

  .app-brand strong {
    font-size: 17px;
  }

  .app-brand span {
    font-size: 8px;
    letter-spacing: 3px;
  }

  .brand-mark-sm {
    width: 38px;
    height: 38px;
  }

  .user-pill {
    padding: 6px 8px;
  }

  .user-pill small {
    display: none;
  }

  .user-pill span {
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .company-pill {
    padding: 6px 8px;
    column-gap: 6px;
  }

  .company-pill small {
    display: none;
  }

  .company-pill span {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dashboard-main {
    padding: 12px 12px 8px;
  }

  .dashboard-copy h1 {
    font-size: 21px;
  }

  .dashboard-copy p {
    font-size: 11px;
  }

  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    height: calc(100% - 10px);
    gap: 8px;
    margin-top: 8px;
  }

  .menu-card {
    min-height: 0;
    border-radius: 0;
    gap: 7px;
    font-size: 13px;
  }

  .menu-card i {
    font-size: 27px;
  }

  .dash-foot {
    display: none;
  }

  .module-screen {
    padding: 1px 5px;
    gap: 8px;
  }

  .module-head h2 {
    font-size: 18px;
  }

  .module-head .btn {
    height: 38px;
    padding: 0 10px;
    font-size: 12px;
  }

  .module-toolbar,
  .filters-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .search-box {
    min-width: 210px;
    height: 39px;
  }

  .module-toolbar select,
  .filters-row select,
  .filters-row input {
    height: 39px;
    min-width: 130px;
  }

  .table-wrap {
    border-radius: 0;
  }

  .table-wrap th {
    padding: 10px;
    font-size: 10px;
  }

  .table-wrap td {
    padding: 9px 10px;
    font-size: 12px;
  }

  .modal {
    padding: 8px;
  }

  .modal-card {
    max-height: calc(100dvh - 16px);
    border-radius: 0;
  }

  .modal-head {
    height: 54px;
  }

  .modal-body {
    padding: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .form-grid .full {
    grid-column: 1;
  }

  .roles-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .roles-list {
    max-height: 130px;
  }

  .permission-grid {
    grid-template-columns: 1fr;
  }

  .head-actions .btn {
    padding: 0 9px;
  }

  .head-actions .btn i {
    margin: 0;
  }

  .head-actions .btn {
    font-size: 0;
  }

  .head-actions .btn i {
    font-size: 14px;
  }

  .login-card {
    max-width: 100%;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .dashboard-copy {
    display: none;
  }

  .menu-grid {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(2, 1fr);
    height: calc(100% - 10px);
  }

  .menu-card {
    min-height: 0;
  }

  .dashboard-main {
    padding-top: 10px;
  }
}

/* V1.3 - vista de factura e historial de precios */
.row-btn.view {
  background: #eef3ff;
  color: #3456a4;
}

.row-btn.history {
  background: #fff4e8;
  color: #9a5d00;
}

.invoice-paper {
  background: #fff;
  border: 1px solid #dfe2e6;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}

.invoice-letterhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 3px solid var(--red);
  background: #fff;
  align-items: center;
  gap: 10px;
  color: var(--red);
}

.invoice-letter-logo svg {
  width: 48px;
  height: 48px;
}

.invoice-letter-logo > div {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.invoice-letter-logo strong {
  font-size: 24px;
  letter-spacing: -0.5px;
}

.invoice-letter-logo span {
  font-size: 9px;
  letter-spacing: 4px;
  margin-top: 5px;
  color: #545961;
  font-weight: 900;
}

.invoice-doc-title {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.invoice-doc-title strong {
  font-size: 16px;
  color: #33383f;
}

.invoice-doc-title span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.invoice-meta {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  padding: 16px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
}

.invoice-meta > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.invoice-meta small,
.invoice-paper-foot small,
.current-price small {
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #8a8f97;
  font-size: 9px;
  font-weight: 900;
}

.invoice-meta strong {
  font-size: 14px;
}

.invoice-meta span {
  font-size: 11px;
  color: #666c75;
}

.invoice-paper-items {
  overflow: auto;
}

.invoice-paper-items table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.invoice-paper-items th {
  background: #f3f4f6;
  color: #686e76;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 10px 12px;
}

.invoice-paper-items td {
  border-top: 1px solid #eceef1;
  padding: 11px 12px;
  font-size: 11px;
}

.obra-chip {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  background: #f4f5f6;
  border-radius: 0;
  padding: 5px 7px;
  font-weight: 800;
  color: #4d535b;
}

.invoice-paper-foot {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  align-items: flex-end;
}

.invoice-paper-foot > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 65%;
  font-size: 11px;
  color: #666;
}

.invoice-grand-total {
  text-align: right;
  display: flex;
  flex-direction: column;
}

.invoice-grand-total strong {
  font-size: 24px;
  color: var(--red);
}

.price-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 13px 15px;
  background: #fafbfc;
}

.price-history-head > div:first-child {
  min-width: 0;
}

.price-history-head h4 {
  margin: 5px 0 0;
  font-size: 17px;
}

.price-type {
  display: inline-block;
}

.current-price {
  display: flex;
  flex-direction: column;
  text-align: right;
  white-space: nowrap;
}

.current-price strong {
  font-size: 21px;
  color: var(--red);
  margin-top: 3px;
}

.price-chart-box {
  height: 250px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px;
  background: #fff;
}

.history-table-wrap {
  margin-top: 12px;
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 0;
}

.history-table-wrap .mini-table th {
  position: sticky;
  top: 0;
  background: #f7f8f9;
  z-index: 1;
}

.city-admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.city-admin-toolbar .search-box {
  max-width: 520px;
}

.city-admin-toolbar .catalog-admin-category-filter {
  flex: 0 1 240px;
  min-width: 180px;
  max-width: 240px;
}

.catalog-admin-toolbar,
.city-admin-filter-toolbar {
  flex-wrap: wrap;
}

.city-admin-filter-toolbar .catalog-admin-select {
  flex: 0 1 230px;
  min-width: 0;
  width: 230px;
}

.catalog-admin-toolbar .catalog-admin-source-filter {
  flex: 0 0 170px;
  min-width: 0;
  max-width: 190px;
}

.city-admin-wrap {
  max-height: 52vh;
}

.city-admin-table {
  min-width: 820px;
}

.subcontractor-admin-table {
  min-width: 760px;
}

.company-info-admin-table {
  min-width: 940px;
}

.company-info-admin-table td {
  overflow-wrap: anywhere;
}

.company-info-admin-toolbar .search-box:not(.catalog-admin-category-filter) {
  flex: 1 1 270px;
}

.city-admin-editor {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.city-admin-editor h4 {
  margin: 0 0 13px;
}

.city-admin-editor.modal-editor {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

@media (max-width: 640px) {
  .city-admin-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .city-admin-toolbar .search-box,
  .city-admin-toolbar .btn {
    width: 100%;
    max-width: none;
  }

  .city-admin-toolbar .catalog-admin-category-filter {
    flex: none;
    min-width: 0;
  }

  .city-admin-filter-toolbar .catalog-admin-select {
    flex: none;
    width: 100%;
    max-width: none;
  }

  .catalog-admin-toolbar .catalog-admin-source-filter {
    flex: none;
    width: 100%;
    max-width: none;
  }
}

/* Paginación común de las grillas ABM. Los datos se solicitan al servidor en
   bloques de 100; estos controles nunca dependen de tener todas las filas en DOM. */
.table-loading-cell {
  height: 150px;
  text-align: center !important;
}

.table-loading-cell::before {
  display: none !important;
  content: none !important;
}

.table-loading {
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-loading .spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-width: 3px;
}

.table-pagination {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.table-pagination-summary strong,
.table-page-current strong {
  color: var(--ink);
}

.table-pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.table-page-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--red);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

.table-page-btn:hover:not(:disabled) {
  border-color: var(--red);
  background: #fff4f4;
  transform: translateY(-1px);
}

.table-page-btn:disabled {
  color: #b9bcc1;
  background: #f4f5f6;
  cursor: default;
}

.table-page-current {
  min-width: 112px;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .table-loading-row,
  .table-loading-cell {
    display: block !important;
    width: 100% !important;
  }

  .table-loading-row {
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none;
  }

  .table-loading-cell {
    height: auto;
    padding: 18px 8px !important;
  }

  .table-pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 11px;
  }

  .table-pagination-summary {
    text-align: center;
    line-height: 1.45;
  }

  .table-pagination-controls {
    justify-content: center;
  }

  .table-page-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
  }

  .table-page-current {
    min-width: 98px;
    font-size: 11px;
  }
}

.rubro-items-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid #eadfe0;
  border-radius: 0;
  background: #fffafa;
}

.rubro-items-summary > div {
  display: grid;
  gap: 2px;
}

.rubro-items-summary span,
.rubro-items-summary small {
  color: var(--muted);
  font-size: 10px;
}

.rubro-items-summary span {
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rubro-items-summary strong {
  color: var(--red);
  font-size: 22px;
}

.rubro-items-wrap {
  max-height: min(50vh, 440px);
}

.rubro-items-table th:first-child {
  min-width: 210px;
}

.rubro-items-table th:last-child {
  min-width: 92px;
}

.rubro-item-total {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #ead7d9;
  border-radius: 0;
  background: #fff7f7;
  color: var(--red);
  font-size: 18px;
  font-weight: 900;
}

@media (max-width: 640px) {
  .rubro-items-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .rubro-items-summary .btn {
    width: 100%;
  }

  .rubro-items-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
  }

  .rubro-items-table,
  .rubro-items-table thead,
  .rubro-items-table tbody,
  .rubro-items-table tr,
  .rubro-items-table th,
  .rubro-items-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .rubro-items-table thead {
    display: none;
  }

  .rubro-items-table tbody {
    display: grid;
    gap: 8px;
  }

  .rubro-items-table tr {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
  }

  .rubro-items-table td {
    border: 0;
    padding: 5px 2px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
  }

  .rubro-items-table td::before {
    content: attr(data-label);
    flex: 0 0 35%;
    color: #858a92;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
  }

  .rubro-items-table td.empty {
    display: block;
    padding: 18px 8px;
    text-align: center;
  }

  .rubro-items-table td.empty::before {
    content: none;
  }

  .rubro-items-table .actions {
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  .budget-detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .budget-detail-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .budget-detail-actions .btn {
    width: 100%;
  }

  .budget-meta-grid,
  .budget-detail-modal .budget-meta-grid {
    grid-template-columns: 1fr 1fr;
  }

  .budget-items-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
  }

  .budget-items-table,
  .budget-items-table thead,
  .budget-items-table tbody,
  .budget-items-table tr,
  .budget-items-table th,
  .budget-items-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .budget-items-table thead {
    display: none;
  }

  .budget-items-table tbody {
    display: grid;
    gap: 8px;
  }

  .budget-items-table tr {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
  }

  .budget-items-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 2px;
    border: 0;
    text-align: right;
  }

  .budget-items-table td::before {
    content: attr(data-label);
    flex: 0 0 35%;
    color: #858a92;
    font-size: 9px;
    font-weight: 900;
    text-align: left;
    text-transform: uppercase;
  }

  .budget-items-table td.empty {
    display: block;
    padding: 18px 8px;
    text-align: center;
  }

  .budget-items-table td.empty::before,
  .budget-items-table .budget-stage-row td:first-child::before {
    content: none;
  }

  .budget-items-table .budget-stage-row {
    padding: 0;
    border-color: #e5d6d8;
    overflow: hidden;
  }

  .budget-items-table .budget-stage-row td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px !important;
    text-align: right;
  }

  .budget-items-table .budget-stage-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
  }

  .budget-items-table .budget-stage-row td:first-child {
    display: block;
    grid-column: 1/-1;
    text-align: left;
  }

  .budget-items-table .budget-stage-row td:not(:first-child)::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: #858a92;
    font-size: 8px;
    font-weight: 900;
    text-align: left;
    text-transform: uppercase;
  }

  .budget-items-table .budget-stage-row .budget-stage-total {
    text-align: right;
  }

  .budget-items-table .budget-stage-row .budget-stage-actions-spacer {
    display: none;
  }

  .budget-items-table .actions {
    margin-left: auto;
  }
}

.history-origin {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 0;
  background: #eef0f2;
  font-size: 9px;
  font-weight: 900;
}

.history-origin.factura {
  background: #eef3ff;
  color: #3456a4;
}

.history-origin.manual {
  background: #fff3df;
  color: #9a5d00;
}

.history-origin.alta,
.history-origin.inicial {
  background: #eaf7ef;
  color: #1c7b43;
}

.item-price-tools {
  display: flex;
  align-items: center;
}

@media (max-width: 640px) {
  .invoice-letterhead {
    padding: 13px;
  }

  .invoice-letter-logo svg {
    width: 38px;
    height: 38px;
  }

  .invoice-letter-logo strong {
    font-size: 19px;
  }

  .invoice-letter-logo span {
    font-size: 7px;
    letter-spacing: 3px;
  }

  .invoice-doc-title strong {
    font-size: 12px;
  }

  .invoice-meta {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    gap: 10px;
  }

  .invoice-paper-foot {
    padding: 12px;
  }

  .invoice-grand-total strong {
    font-size: 19px;
  }

  .price-history-head {
    align-items: flex-start;
  }

  .price-chart-box {
    height: 220px;
  }

  .history-table-wrap {
    max-height: 190px;
  }

  .form-actions {
    flex-wrap: wrap;
  }
}

/* V1.3.3 - pantallas sin scroll horizontal + flujo rápido de factura */
html,
body,
.app-body,
.module-screen {
  overflow-x: hidden;
}

#module-facturas .table-wrap {
  overflow-x: hidden;
}

#module-facturas .table-wrap table {
  min-width: 0;
  table-layout: fixed;
}

#module-facturas .invoice-col-date {
  width: 92px;
}

#module-facturas .invoice-col-provider {
  width: auto;
  overflow-wrap: anywhere;
}

#module-facturas .invoice-col-ruc {
  width: 112px;
}

#module-facturas .invoice-col-number {
  width: 142px;
}

#module-facturas .invoice-col-count {
  width: 64px;
  text-align: center;
}

#module-facturas .invoice-col-total {
  width: 128px;
  white-space: nowrap;
}

#module-facturas .invoice-col-actions {
  width: 120px;
}

.invoice-mobile-meta {
  display: none;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.25;
}

.invoice-paper-items {
  overflow-x: hidden;
}

.invoice-paper-items table {
  min-width: 0;
  table-layout: fixed;
}

.invoice-paper-items th:nth-child(1) {
  width: 72px;
}

.invoice-paper-items th:nth-child(2) {
  width: 24%;
}

.invoice-paper-items th:nth-child(3) {
  width: 27%;
}

.invoice-paper-items th:nth-child(4) {
  width: 64px;
}

.invoice-paper-items th:nth-child(5) {
  width: 118px;
}

.invoice-paper-items th:nth-child(6) {
  width: 120px;
}

.invoice-paper-items td {
  overflow-wrap: anywhere;
}

.invoice-items {
  overflow-x: hidden;
}

.invoice-items .mini-table {
  table-layout: fixed;
}

.invoice-items .mini-table th,
.invoice-items .mini-table td {
  overflow-wrap: anywhere;
}

.item-desc-first {
  order: -1;
}

@media (max-width: 900px) {
  #module-facturas .invoice-col-ruc,
  #module-facturas .invoice-col-count {
    display: none;
  }

  #module-facturas .invoice-col-date {
    width: 86px;
  }

  #module-facturas .invoice-col-number {
    width: 125px;
  }

  #module-facturas .invoice-col-total {
    width: 112px;
  }

  #module-facturas .invoice-col-actions {
    width: 112px;
  }
}

@media (max-width: 640px) {
  .module-screen {
    overflow: hidden;
  }

  #module-facturas .module-toolbar {
    overflow: hidden;
  }

  #module-facturas .search-box {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  #module-facturas .table-wrap {
    overflow-y: auto;
    overflow-x: hidden;
  }

  #module-facturas .table-wrap table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  #module-facturas .table-wrap th:nth-child(3),
  #module-facturas .table-wrap td:nth-child(3),
  #module-facturas .table-wrap th:nth-child(4),
  #module-facturas .table-wrap td:nth-child(4),
  #module-facturas .table-wrap th:nth-child(5),
  #module-facturas .table-wrap td:nth-child(5) {
    display: none;
  }

  #module-facturas .invoice-col-date {
    width: 62px;
    font-size: 10px;
    padding-left: 7px;
    padding-right: 5px;
  }

  #module-facturas .invoice-col-provider {
    width: auto;
    padding-left: 5px;
    padding-right: 5px;
  }

  #module-facturas .invoice-col-provider strong {
    display: block;
    font-size: 11px;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #module-facturas .invoice-desktop-detail {
    display: none;
  }

  #module-facturas .invoice-mobile-meta {
    display: block;
  }

  #module-facturas .invoice-col-total {
    width: 74px;
    font-size: 10px;
    padding-left: 4px;
    padding-right: 4px;
    white-space: normal;
    text-align: right;
  }

  #module-facturas .invoice-col-actions {
    width: 82px;
    padding-left: 3px;
    padding-right: 3px;
  }

  #module-facturas .actions {
    gap: 2px;
    justify-content: center;
  }

  #module-facturas .row-btn {
    width: 25px;
    height: 31px;
    border-radius: 0;
    font-size: 10px;
  }

  #module-facturas .table-wrap th {
    padding-left: 5px;
    padding-right: 5px;
    font-size: 8px;
    letter-spacing: 0;
  }

  .invoice-paper-items table,
  .invoice-paper-items thead,
  .invoice-paper-items tbody,
  .invoice-paper-items tr,
  .invoice-paper-items th,
  .invoice-paper-items td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }

  .invoice-paper-items thead {
    display: none;
  }

  .invoice-paper-items tbody {
    padding: 8px;
    display: grid;
    gap: 8px;
  }

  .invoice-paper-items tr {
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 8px;
    background: #fff;
  }

  .invoice-paper-items td {
    border: 0;
    padding: 4px 2px;
    font-size: 11px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .invoice-paper-items td::before {
    content: attr(data-label);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #848991;
    font-weight: 900;
    text-align: left;
    flex: 0 0 36%;
  }

  .invoice-paper-items td > * {
    max-width: 62%;
  }

  .invoice-paper-items .obra-chip {
    white-space: normal;
    justify-content: flex-end;
  }

  .invoice-items .mini-table,
  .invoice-items .mini-table thead,
  .invoice-items .mini-table tbody,
  .invoice-items .mini-table tr,
  .invoice-items .mini-table th,
  .invoice-items .mini-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .invoice-items .mini-table thead {
    display: none;
  }

  .invoice-items .mini-table tbody {
    padding: 7px;
    display: grid;
    gap: 7px;
  }

  .invoice-items .mini-table tr {
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 7px;
  }

  .invoice-items .mini-table td {
    border: 0;
    padding: 4px 2px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
  }

  .invoice-items .mini-table td::before {
    content: attr(data-label);
    font-size: 9px;
    text-transform: uppercase;
    color: #858a92;
    font-weight: 900;
    text-align: left;
  }

  .invoice-items .mini-table td .actions {
    margin-left: auto;
  }

  .invoice-items-head {
    gap: 8px;
    align-items: center;
  }

  .invoice-items-head > div {
    min-width: 0;
  }

  .invoice-items-head .btn {
    white-space: nowrap;
    padding: 0 9px;
  }

  .item-form-grid .item-desc-first {
    grid-column: 1;
  }
}

/* V1.3.4 - modales apilados seguros */
.sub-modal {
  z-index: 85;
  background: rgba(17, 20, 24, 0.58);
}

.sub-modal .modal-card {
  box-shadow: none;
}

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

#subModal .modal-body {
  overscroll-behavior: contain;
}

@media (max-width: 640px) {
  #subModal {
    padding: 8px;
  }

  #subModal .modal-card {
    max-height: calc(100dvh - 16px);
  }
}

/* V1.3.5 - resumen diario + navegación segura entre modales */
.dashboard-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.today-loaded-card {
  border: 1px solid #ead7d9;
  background: #fff;
  border-radius: 0;
  min-width: 250px;
  height: 58px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  box-shadow: none;
}

.today-loaded-card > i:first-child {
  width: 34px;
  height: 34px;
  border-radius: 0;
  background: #fff1f2;
  color: var(--red);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.today-loaded-card > i:last-child {
  color: #a6aab0;
  font-size: 11px;
  margin-left: auto;
}

.today-loaded-card span {
  display: grid;
  grid-template-columns: auto auto;
  align-items: end;
  column-gap: 8px;
  min-width: 0;
  text-align: left;
}

.today-loaded-card small {
  grid-column: 1/-1;
  color: #777d85;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.today-loaded-card strong {
  font-size: 15px;
  color: var(--red);
  white-space: nowrap;
}

.today-loaded-card em {
  font-style: normal;
  color: #90959d;
  font-size: 9px;
  white-space: nowrap;
}

.today-loaded-card:hover {
  border-color: #deb9bd;
  background: #fffafa;
}

.today-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fff5f5;
  border: 1px solid #f0dadd;
  border-radius: 0;
  padding: 12px 14px;
}

.today-detail-head > div {
  display: flex;
  flex-direction: column;
}

.today-detail-head small {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 900;
  color: #7c8289;
  letter-spacing: 0.05em;
}

.today-detail-head strong {
  font-size: 24px;
  color: var(--red);
  margin-top: 2px;
}

.today-detail-head > span {
  font-size: 11px;
  font-weight: 800;
  color: #6e747c;
}

.today-detail-list {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: auto;
  max-height: 55dvh;
}

.today-detail-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) minmax(150px, 0.65fr);
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid #eef0f2;
}

.today-detail-row:last-child {
  border-bottom: 0;
}

.today-time {
  font-size: 12px;
  font-weight: 900;
  color: var(--red);
}

.today-desc {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.today-desc strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.today-desc span,
.today-desc small {
  font-size: 10px;
  color: var(--muted);
}

.today-work {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
  min-width: 0;
}

.today-work span {
  font-size: 10px;
  color: #5d636b;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.today-work strong {
  font-size: 12px;
  color: var(--red);
}

@media (max-width: 640px) {
  .dashboard-copy {
    gap: 8px;
  }

  .dashboard-copy p {
    display: none;
  }

  .today-loaded-card {
    min-width: 165px;
    height: 48px;
    padding: 0 8px;
    gap: 7px;
    border-radius: 0;
  }

  .today-loaded-card > i:first-child {
    width: 30px;
    height: 30px;
  }

  .today-loaded-card span {
    display: block;
  }

  .today-loaded-card small {
    display: block;
    font-size: 7px;
  }

  .today-loaded-card strong {
    display: block;
    font-size: 12px;
  }

  .today-loaded-card em {
    display: none;
  }

  .today-loaded-card > i:last-child {
    display: none;
  }

  .today-detail-list {
    max-height: 58dvh;
  }

  .today-detail-row {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    padding: 9px;
  }

  .today-work {
    grid-column: 2;
    align-items: flex-start;
    text-align: left;
    border-top: 1px dashed #eceef0;
    padding-top: 6px;
  }
}

/* V1.3.6 - cero scroll horizontal en módulos + total gastado hoy destacado */
.dashboard-copy-total {
  display: block;
  width: 100%;
}

.today-loaded-card-primary {
  width: 100%;
  min-width: 0;
  height: 68px;
  padding: 0 18px;
  border: 0;
  background: #fff;
  color: #fff;
  box-shadow: none;
}

.today-loaded-card-primary:hover {
  background: #fff;
  border: 0;
}

.today-loaded-card-primary > i:first-child {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.today-loaded-card-primary > i:last-child {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.today-loaded-card-primary span {
  grid-template-columns: auto auto;
  column-gap: 10px;
}

.today-loaded-card-primary small {
  color: rgba(255, 255, 255, 0.82);
}

.today-loaded-card-primary strong {
  color: #fff;
  font-size: 20px;
}

.today-loaded-card-primary em {
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
}

/* Ninguna pantalla funcional debe generar desplazamiento horizontal. */
.module-screen,
.module-toolbar,
.filters-row,
.table-wrap,
.charts-grid,
.chart-card {
  min-width: 0;
  max-width: 100%;
}

.module-screen {
  overflow-x: hidden;
}

.module-screen .table-wrap {
  overflow-x: hidden;
  overflow-y: auto;
}

#module-categorias .table-wrap table,
#module-materiales .table-wrap table,
#module-mano_obra .table-wrap table,
#module-reportes .table-wrap table,
#module-usuarios .table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

#module-categorias td,
#module-categorias th,
#module-materiales td,
#module-materiales th,
#module-mano_obra td,
#module-mano_obra th,
#module-reportes td,
#module-reportes th,
#module-usuarios td,
#module-usuarios th {
  overflow-wrap: anywhere;
  word-break: normal;
  min-width: 0;
}

#module-categorias th:last-child {
  width: 142px;
}

#module-materiales th:last-child,
#module-mano_obra th:last-child {
  width: 178px;
}

#module-usuarios th:last-child {
  width: 135px;
}

#module-reportes th:nth-child(1) {
  width: 88px;
}

#module-reportes th:nth-child(3) {
  width: 74px;
}

#module-reportes th:nth-child(6) {
  width: 72px;
}

#module-reportes th:nth-child(7),
#module-reportes th:nth-child(8) {
  width: 115px;
}

#module-graficos .charts-grid {
  overflow: hidden;
}

#module-graficos .chart-card {
  overflow: hidden;
}

#module-graficos canvas {
  width: 100% !important;
  max-width: 100% !important;
}

@media (max-width: 640px) {
  .today-loaded-card-primary {
    height: 58px;
    padding: 0 12px;
    min-width: 0;
    border-radius: 0;
  }

  .today-loaded-card-primary > i:first-child {
    width: 34px;
    height: 34px;
  }

  .today-loaded-card-primary span {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    width: 100%;
  }

  .today-loaded-card-primary small {
    display: block;
    grid-column: 1/-1;
    font-size: 8px;
  }

  .today-loaded-card-primary strong {
    display: block;
    font-size: 16px;
  }

  .today-loaded-card-primary em {
    display: block;
    font-size: 9px;
  }

  .today-loaded-card-primary > i:last-child {
    display: block;
  }

  /* Filtros y buscadores se reacomodan; nunca deslizan lateralmente. */
  .module-toolbar,
  .filters-row {
    overflow-x: hidden !important;
    overflow-y: visible;
    flex-wrap: wrap;
    padding-bottom: 0;
  }

  .module-toolbar .search-box {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .module-toolbar select {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0 !important;
  }

  #module-rubros .rubro-expense-setting {
    flex: 1 1 100%;
    width: 100%;
  }

  #module-rubros .rubro-expense-setting > span {
    margin-right: auto;
  }

  .filters-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .filters-row > * {
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
  }

  #module-reportes #btnApplyReport {
    grid-column: 1/-1;
  }

  #module-graficos #chartMobileSelect {
    display: block;
    grid-column: 1/-1;
  }

  #module-graficos #btnApplyCharts {
    grid-column: 1/-1;
  }

  /* Categorías en tarjetas responsivas. */
  #module-categorias .table-wrap table,
  #module-categorias .table-wrap thead,
  #module-categorias .table-wrap tbody,
  #module-categorias .table-wrap tr,
  #module-categorias .table-wrap th,
  #module-categorias .table-wrap td,
  #module-materiales .table-wrap table,
  #module-materiales .table-wrap thead,
  #module-materiales .table-wrap tbody,
  #module-materiales .table-wrap tr,
  #module-materiales .table-wrap th,
  #module-materiales .table-wrap td,
  #module-mano_obra .table-wrap table,
  #module-mano_obra .table-wrap thead,
  #module-mano_obra .table-wrap tbody,
  #module-mano_obra .table-wrap tr,
  #module-mano_obra .table-wrap th,
  #module-mano_obra .table-wrap td,
  #module-reportes .table-wrap table,
  #module-reportes .table-wrap thead,
  #module-reportes .table-wrap tbody,
  #module-reportes .table-wrap tr,
  #module-reportes .table-wrap th,
  #module-reportes .table-wrap td,
  #module-usuarios .table-wrap table,
  #module-usuarios .table-wrap thead,
  #module-usuarios .table-wrap tbody,
  #module-usuarios .table-wrap tr,
  #module-usuarios .table-wrap th,
  #module-usuarios .table-wrap td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }

  #module-categorias .table-wrap thead,
  #module-materiales .table-wrap thead,
  #module-mano_obra .table-wrap thead,
  #module-reportes .table-wrap thead,
  #module-usuarios .table-wrap thead {
    display: none;
  }

  #module-categorias .table-wrap tbody,
  #module-materiales .table-wrap tbody,
  #module-mano_obra .table-wrap tbody,
  #module-reportes .table-wrap tbody,
  #module-usuarios .table-wrap tbody {
    padding: 7px;
    display: grid;
    gap: 8px;
  }

  #module-categorias .table-wrap tr,
  #module-materiales .table-wrap tr,
  #module-mano_obra .table-wrap tr,
  #module-reportes .table-wrap tr,
  #module-usuarios .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 8px;
    background: #fff;
  }

  #module-categorias .table-wrap td,
  #module-materiales .table-wrap td,
  #module-mano_obra .table-wrap td,
  #module-reportes .table-wrap td,
  #module-usuarios .table-wrap td {
    border: 0;
    padding: 4px 2px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
    font-size: 11px;
  }

  #module-categorias .table-wrap td::before,
  #module-materiales .table-wrap td::before,
  #module-mano_obra .table-wrap td::before,
  #module-reportes .table-wrap td::before,
  #module-usuarios .table-wrap td::before {
    flex: 0 0 34%;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #858a92;
    font-weight: 900;
    text-align: left;
  }

  #module-categorias td:nth-child(1)::before {
    content: "Categoría";
  }

  #module-categorias td:nth-child(2)::before {
    content: "Tipo";
  }

  #module-categorias td:nth-child(3)::before {
    content: "Estado";
  }

  #module-categorias td:nth-child(4)::before {
    content: "Acciones";
  }

  #module-materiales td:nth-child(1)::before {
    content: "Categoría";
  }

  #module-materiales td:nth-child(2)::before {
    content: "Material";
  }

  #module-materiales td:nth-child(3)::before {
    content: "Unidad";
  }

  #module-materiales td:nth-child(4)::before {
    content: "Precio ref.";
  }

  #module-materiales td:nth-child(5)::before {
    content: "Coeficiente";
  }

  #module-materiales td:nth-child(6)::before {
    content: "Estado";
  }

  #module-materiales td:nth-child(7)::before {
    content: "Acciones";
  }

  #module-mano_obra td:nth-child(1)::before {
    content: "Categoría";
  }

  #module-mano_obra td:nth-child(2)::before {
    content: "Descripción";
  }

  #module-mano_obra td:nth-child(3)::before {
    content: "Unidad";
  }

  #module-mano_obra td:nth-child(4)::before {
    content: "Precio ref.";
  }

  #module-mano_obra td:nth-child(5)::before {
    content: "Coeficiente";
  }

  #module-mano_obra td:nth-child(6)::before {
    content: "Estado";
  }

  #module-mano_obra td:nth-child(7)::before {
    content: "Acciones";
  }

  #module-materiales .catalog-description,
  #module-mano_obra .catalog-description,
  #module-gastos .catalog-description {
    min-width: 0;
    max-width: 66%;
    margin-left: auto;
    text-align: right;
    overflow-wrap: anywhere;
  }

  #module-materiales .catalog-description strong,
  #module-mano_obra .catalog-description strong,
  #module-gastos .catalog-description strong {
    display: block;
    font-weight: 700;
  }

  #module-materiales .catalog-description .hint,
  #module-mano_obra .catalog-description .hint,
  #module-gastos .catalog-description .hint {
    display: block;
    margin-top: 3px;
  }

  #module-reportes td:nth-child(1)::before {
    content: "Fecha";
  }

  #module-reportes td:nth-child(2)::before {
    content: "Obra";
  }

  #module-reportes td:nth-child(3)::before {
    content: "Tipo";
  }

  #module-reportes td:nth-child(4)::before {
    content: "Descripción";
  }

  #module-reportes td:nth-child(5)::before {
    content: "Proveedor";
  }

  #module-reportes td:nth-child(6)::before {
    content: "Cantidad";
  }

  #module-reportes td:nth-child(7)::before {
    content: "P. unit.";
  }

  #module-reportes td:nth-child(8)::before {
    content: "Subtotal";
  }

  #module-usuarios td:nth-child(1)::before {
    content: "Nombre";
  }

  #module-usuarios td:nth-child(2)::before {
    content: "Usuario";
  }

  #module-usuarios td:nth-child(3)::before {
    content: "Email";
  }

  #module-usuarios td:nth-child(4)::before {
    content: "Rol";
  }

  #module-usuarios td:nth-child(5)::before {
    content: "Estado";
  }

  #module-usuarios td:nth-child(6)::before {
    content: "Acciones";
  }

  #module-categorias .table-wrap td.empty::before,
  #module-materiales .table-wrap td.empty::before,
  #module-mano_obra .table-wrap td.empty::before,
  #module-reportes .table-wrap td.empty::before,
  #module-usuarios .table-wrap td.empty::before {
    display: none;
    content: none;
  }

  #module-categorias .table-wrap td.empty,
  #module-materiales .table-wrap td.empty,
  #module-mano_obra .table-wrap td.empty,
  #module-reportes .table-wrap td.empty,
  #module-usuarios .table-wrap td.empty {
    display: block;
    text-align: center;
    padding: 18px 8px;
  }

  #module-categorias .actions,
  #module-materiales .actions,
  #module-mano_obra .actions,
  #module-usuarios .actions {
    margin-left: auto;
    flex-wrap: wrap;
  }

  #module-materiales .row-btn,
  #module-mano_obra .row-btn,
  #module-usuarios .row-btn,
  #module-categorias .row-btn {
    width: 32px;
    height: 32px;
  }

  /* Gráficos: un gráfico por vez y filtros en el ancho disponible. */
  #module-graficos .charts-grid {
    width: 100%;
    min-width: 0;
  }

  #module-graficos .chart-card {
    width: 100%;
    min-width: 0;
  }
}

/* V1.4.0 - captura de factura por foto / OCR */
#module-facturas {
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
}

.invoice-toolbar {
  flex-wrap: nowrap;
  gap: 10px;
}

#module-facturas .invoice-toolbar .search-box {
  flex: 1 1 280px;
  min-width: 0;
  max-width: none;
}

.invoice-admin-nav {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  margin: 0;
}

.invoice-admin-nav .btn {
  min-width: 135px;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  #module-facturas .invoice-toolbar {
    flex-wrap: wrap;
  }

  #module-facturas .invoice-toolbar .search-box {
    flex: 1 1 100%;
    width: 100%;
  }

  .invoice-admin-nav {
    display: grid;
    flex: 1 1 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .invoice-admin-nav .btn {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .invoice-admin-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.scan-start,
.scan-review {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.scan-camera {
  border: 2px dashed #d9dde2;
  border-radius: 0;
  padding: 22px;
  text-align: center;
  background: #fafbfc;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.scan-camera > i {
  font-size: 34px;
  color: var(--red);
}

.scan-camera strong {
  font-size: 16px;
}

.scan-camera p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  max-width: 520px;
}

.scan-pick {
  position: relative;
  overflow: hidden;
}

.scan-pick input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.scan-stage {
  min-width: 0;
}

.scan-tips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.scan-tips span {
  background: #f4f5f6;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 8px;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.scan-tips i {
  color: #18864b;
  margin-right: 4px;
}

.scan-working {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
}

.scan-working img {
  width: 100%;
  max-height: 210px;
  object-fit: contain;
  border-radius: 0;
  background: #f0f1f2;
}

.scan-working > div {
  display: grid;
  gap: 8px;
}

.scan-working strong {
  font-size: 13px;
}

.scan-working small {
  font-size: 10px;
  color: var(--muted);
}

.scan-progress {
  height: 9px;
  border-radius: 0;
  background: #eceef0;
  overflow: hidden;
}

.scan-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--red);
  transition: width 0.15s ease;
}

.scan-error {
  padding: 18px;
  border: 1px solid #efb8bc;
  background: #fff5f6;
  border-radius: 0;
  display: grid;
  gap: 5px;
  text-align: center;
  color: #8d1118;
}

.scan-error i {
  font-size: 25px;
}

.scan-review-top {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 9px;
  min-width: 0;
}

.scan-review-top > img {
  width: 100%;
  height: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 0;
  background: #f2f3f4;
  border: 1px solid var(--line);
}

.scan-header-form {
  min-width: 0;
}

.scan-review {
  gap: 8px;
}

.scan-header-form .scan-header-grid {
  gap: 5px 7px;
}

.scan-review .field label {
  margin-bottom: 2px;
  font-size: 8px;
  line-height: 1.15;
}

.scan-review .field input,
.scan-review .field select {
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 0;
  font-size: 11px;
}

.scan-review .field textarea {
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 0;
  font-size: 10px;
  line-height: 1.25;
}

.scan-detected-note {
  margin-top: 5px;
  padding: 6px 8px;
  border-radius: 0;
  background: #f5f6f7;
  color: #555d66;
  font-size: 9px;
  line-height: 1.3;
}

.scan-items-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.scan-items-title > div {
  display: grid;
  gap: 2px;
}

.scan-items-title small,
.scan-items-title span {
  font-size: 9px;
  color: var(--muted);
}

.scan-items-title > div:last-child {
  text-align: right;
}

.scan-items-title > div:last-child strong {
  color: var(--red);
  font-size: 16px;
}

.scan-items,
#scanItems {
  display: grid;
  gap: 6px;
}

.scan-item {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 7px;
  background: #fff;
  min-width: 0;
}

.scan-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.scan-item-head strong {
  font-size: 11px;
  color: #555d66;
}

.scan-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.3fr) minmax(0, 1.25fr) minmax(
      0,
      0.9fr
    ) minmax(80px, 0.55fr) minmax(110px, 0.8fr) minmax(110px, 0.75fr);
  gap: 5px;
  align-items: end;
  min-width: 0;
}

.scan-grid .field {
  min-width: 0;
}

.scan-grid label {
  font-size: 8px;
}

.scan-sub strong {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  border-radius: 0;
  background: #f6f7f8;
  color: var(--red);
  font-size: 11px;
  white-space: nowrap;
}

.scan-actions {
  position: sticky;
  bottom: -1px;
  background: #fff;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  z-index: 2;
}

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

  .scan-desc {
    grid-column: 1/-1;
  }

  .scan-sub strong {
    justify-content: flex-start;
  }

  .scan-review-top {
    grid-template-columns: 130px 1fr;
  }

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

@media (max-width: 560px) {
  .scan-review-top {
    grid-template-columns: 1fr;
  }

  .scan-review-top > img {
    max-height: 150px;
  }

  .scan-grid {
    grid-template-columns: 1fr 1fr;
  }

  .scan-desc,
  .scan-grid .field:nth-child(2) {
    grid-column: 1/-1;
  }

  .scan-working {
    grid-template-columns: 90px 1fr;
  }

  .scan-working img {
    max-height: 130px;
  }

  .scan-items-title {
    align-items: center;
  }

  .scan-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .scan-actions #scanLoad {
    grid-column: 1/-1;
    grid-row: 1;
  }

  .scan-camera {
    padding: 16px 10px;
  }

  .scan-tips {
    grid-template-columns: 1fr 1fr;
  }
}

/* V1.5.0 - pagos, proveedores, factura fiscal/OCR y foto original */
.badge.pending {
  background: #fff4df;
  color: #986000;
  border: 1px solid #f0d5a2;
}

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

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

.good-lite {
  background: #eef9f2 !important;
  color: #17753f !important;
  border-color: #cae9d7 !important;
}

.today-cards-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.today-paid-card {
  width: 100%;
  min-width: 0;
  height: 68px;
  padding: 0 18px;
  border: 0;
  background: #fff;
  color: #fff;
  box-shadow: none;
}

.today-paid-card:hover {
  background: #fff;
  border: 0;
}

.today-paid-card > i:first-child {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.today-paid-card > i:last-child {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.today-paid-card small {
  color: rgba(255, 255, 255, 0.82);
}

.today-paid-card strong {
  color: #fff;
  font-size: 20px;
}

.today-paid-card em {
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
}

.paid-head {
  background: #effaf4;
  border-color: #ccebd9;
}

.paid-head strong,
.paid-time,
.paid-amount {
  color: var(--good) !important;
}

.invoice-meta-rich {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.invoice-meta-rich > div {
  min-width: 0;
}

.cdc-text {
  overflow-wrap: anywhere;
  font-family: Inter, sans-serif;
  font-size: 9px !important;
}

.invoice-taxes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-top: 8px;
}

.invoice-taxes span {
  display: grid;
  gap: 2px;
  background: #f7f8f9;
  border-radius: 0;
  padding: 7px;
  font-size: 9px;
  color: var(--muted);
}

.invoice-taxes strong {
  font-size: 11px;
  color: var(--ink);
}

.invoice-payments {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 10px;
}

.invoice-photo-view {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.invoice-photo-view img {
  max-width: 100%;
  max-height: 70dvh;
  object-fit: contain;
  border-radius: 0;
  border: 1px solid var(--line);
  background: #f5f6f7;
}

.invoice-status-strip {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
  padding: 8px;
  background: #f6f7f8;
  border-radius: 0;
  font-size: 10px;
}

.check-line {
  display: flex !important;
  align-items: center;
  gap: 8px;
  height: 38px;
}

.check-line input {
  width: 18px;
  height: 18px;
}

.row-btn.photo {
  color: #5d4aa8;
  background: #f1effc;
}

.payment-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f1f2f4;
  border-radius: 0;
  padding: 5px;
}

.pay-tab {
  border: 0;
  border-radius: 0;
  background: transparent;
  height: 38px;
  font-weight: 900;
  color: #6d737b;
}

.pay-tab.active {
  background: #fff;
  color: var(--red);
  box-shadow: none;
}

.payment-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
}

.payment-summary span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 800;
}

.payment-summary strong {
  font-size: 18px;
  color: var(--red);
  margin-left: auto;
}

.payment-summary em {
  font-style: normal;
  font-size: 9px;
  color: var(--muted);
}

.payment-list {
  margin-top: 9px;
  display: grid;
  gap: 7px;
  max-height: 56dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

.payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 9px 10px;
}

.payment-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.payment-main strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.payment-main span,
.payment-main small {
  font-size: 9px;
  color: var(--muted);
}

.payment-balance {
  display: grid;
  gap: 2px;
  text-align: right;
}

.payment-balance small {
  font-size: 8px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 900;
}

.payment-balance strong {
  font-size: 12px;
  color: var(--red);
}

.pay-target {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: #f7f8f9;
  border-radius: 0;
  margin-bottom: 10px;
}

.pay-target small {
  font-size: 8px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 900;
}

.pay-target strong {
  font-size: 14px;
}

.pay-target span {
  font-size: 11px;
  color: var(--red);
  font-weight: 900;
}

#module-proveedores .table-wrap {
  overflow-x: hidden;
}

#module-proveedores .table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

#module-proveedores th:last-child {
  width: 125px;
}

#module-proveedores td,
#module-proveedores th {
  overflow-wrap: anywhere;
  min-width: 0;
}

.supplier-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
}

.supplier-history-head > div {
  display: grid;
  gap: 2px;
}

.supplier-history-head small {
  font-size: 8px;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.supplier-history-head strong {
  font-size: 14px;
}

.supplier-history-head > span {
  font-size: 10px;
  color: var(--muted);
}

.supplier-history-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
  max-height: 58dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

.supplier-move {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 38px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 0;
  padding: 8px;
}

.supplier-move.credit {
  border-left-color: var(--good);
}

.supplier-move > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.supplier-move > div:nth-child(2) {
  text-align: right;
}

.supplier-move span,
.supplier-move small {
  font-size: 9px;
  color: var(--muted);
}

.supplier-move strong {
  font-size: 11px;
}

.supplier-move.credit > div:nth-child(2) > strong {
  color: var(--good);
}

.supplier-move.debit > div:nth-child(2) > strong {
  color: var(--red);
}

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

.scan-header-grid .full {
  grid-column: 1/-1;
}

.scan-header-grid .scan-cdc-field {
  grid-column: span 2;
}

.scan-header-grid .scan-qr-field {
  grid-column: span 3;
}

.scan-header-grid .scan-qr-field textarea {
  height: 32px;
  min-height: 32px;
}

.scan-header-grid textarea {
  resize: vertical;
  min-height: 46px;
}

.scan-detected-note strong {
  color: var(--ink);
}

#module-reportes td::before {
  content: attr(data-label) !important;
}

@media (max-width: 900px) {
  .invoice-taxes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .scan-header-grid .scan-cdc-field,
  .scan-header-grid .scan-qr-field {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .today-cards-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .today-paid-card,
  .today-loaded-card-primary {
    height: 58px;
    padding: 0 8px;
    border-radius: 0;
  }

  .today-paid-card > i:first-child,
  .today-loaded-card-primary > i:first-child {
    width: 30px;
    height: 30px;
  }

  .today-paid-card span,
  .today-loaded-card-primary span {
    display: block !important;
  }

  .today-paid-card small,
  .today-loaded-card-primary small {
    display: block;
    font-size: 12px;
  }

  .today-paid-card strong,
  .today-loaded-card-primary strong {
    display: block;
    font-size: 12px;
  }

  .today-paid-card em,
  .today-loaded-card-primary em,
  .today-paid-card > i:last-child,
  .today-loaded-card-primary > i:last-child {
    display: none;
  }

  .menu-grid {
    grid-template-rows: repeat(8, 1fr);
  }

  .invoice-meta-rich {
    grid-template-columns: 1fr;
  }

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

  .invoice-photo-view img {
    max-height: 65dvh;
  }

  .payment-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }

  .payment-balance {
    grid-column: 1;
    text-align: left;
  }

  .payment-row > .actions {
    grid-column: 2;
    grid-row: 1/3;
    display: grid;
    align-content: center;
  }

  .payment-summary {
    flex-wrap: wrap;
  }

  .payment-summary strong {
    margin-left: 0;
    width: 100%;
  }

  #module-proveedores .table-wrap table,
  #module-proveedores .table-wrap thead,
  #module-proveedores .table-wrap tbody,
  #module-proveedores .table-wrap tr,
  #module-proveedores .table-wrap th,
  #module-proveedores .table-wrap td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }

  #module-proveedores .table-wrap thead {
    display: none;
  }

  #module-proveedores .table-wrap tbody {
    padding: 7px;
    display: grid;
    gap: 8px;
  }

  #module-proveedores .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 8px;
    background: #fff;
  }

  #module-proveedores .table-wrap td {
    border: 0;
    padding: 4px 2px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
    font-size: 11px;
  }

  #module-proveedores .table-wrap td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #858a92;
    font-weight: 900;
    text-align: left;
  }

  #module-proveedores .table-wrap td.empty::before {
    display: none;
  }

  #module-proveedores .table-wrap td.empty {
    display: block;
    text-align: center;
    padding: 18px 8px;
  }

  .supplier-move {
    grid-template-columns: minmax(0, 1fr) 105px 34px;
  }

  .scan-header-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .scan-header-grid {
    grid-template-columns: 1fr;
  }

  .scan-header-grid .full {
    grid-column: 1;
  }

  .scan-header-grid .scan-cdc-field,
  .scan-header-grid .scan-qr-field {
    grid-column: 1;
  }

  .today-cards-grid {
    gap: 5px;
  }

  .today-paid-card > i:first-child,
  .today-loaded-card-primary > i:first-child {
    display: none;
  }

  .today-paid-card,
  .today-loaded-card-primary {
    padding: 0 9px;
  }

  .supplier-move {
    grid-template-columns: minmax(0, 1fr) 92px;
  }

  .supplier-move > .row-btn {
    display: none;
  }
}

/* V1.6.0 - Gastos, cabecera compacta de factura e informe PDF por obra */
.row-btn.pdf {
  background: #fff0f1;
  color: #e51400;
}

.row-btn.pdf:hover {
  background: #f9dfe2;
}

#module-gastos .table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

#module-gastos td,
#module-gastos th {
  overflow-wrap: anywhere;
  min-width: 0;
}

#module-gastos th:last-child {
  width: 178px;
}

.invoice-header-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 11px;
}

.invoice-header-grid .full {
  grid-column: 1/-1;
}

.invoice-header-grid .span-2 {
  grid-column: span 2;
}

.invoice-header-grid .span-3 {
  grid-column: span 3;
}

.invoice-ruc-field {
  grid-column: span 1;
}

.invoice-provider-field {
  grid-column: span 3;
}

.invoice-tax-line {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 0;
  background: #f7f8f9;
  border: 1px solid #eceef1;
  color: #686d74;
  font-size: 10px;
}

.invoice-tax-line strong {
  color: #2f3338;
}

.total-field input[readonly] {
  background: #fff1f2;
  color: var(--red);
  font-weight: 900;
  border-color: #e7bfc2;
}

.electronic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.electronic-extras {
  padding: 9px;
  border: 1px dashed #e2c7ca;
  border-radius: 0;
  background: #fffafa;
}

.compact-status {
  min-height: 12px;
  height: 12px;
  font-size: 9px;
  margin-top: 2px;
}

.compact-status .spinner {
  width: 10px;
  height: 10px;
}

.invoice-save-hint {
  margin: 7px 0 0;
}

.invoice-compact-form .form-actions {
  margin-top: 10px;
}

@media (min-width: 761px) {
  #mainModal .modal-card.invoice-compact {
    width: min(1120px, calc(100vw - 28px));
    max-height: calc(100dvh - 24px);
  }

  #mainModal .modal-card.invoice-compact .modal-head {
    height: 54px;
  }

  #mainModal .modal-card.invoice-compact .modal-body {
    overflow: hidden;
    padding: 11px 16px 12px;
  }

  #mainModal .modal-card.invoice-compact .field label {
    font-size: 9px;
    margin-bottom: 4px;
  }

  #mainModal .modal-card.invoice-compact .field input,
  #mainModal .modal-card.invoice-compact .field select {
    height: 36px;
    border-radius: 0;
    padding: 0 10px;
    font-size: 12px;
  }

  #mainModal .modal-card.invoice-compact .form-grid {
    gap: 7px 10px;
  }

  #mainModal .modal-card.invoice-compact .form-actions {
    margin-top: 9px;
  }

  #mainModal .modal-card.invoice-compact .btn {
    height: 38px;
  }
}

/* Contenedores Highcharts usados solo durante la generación del PDF. */
.obra-pdf-charts-stage {
  position: fixed;
  left: -12000px;
  top: 0;
  width: 1100px;
  background: #fff;
  z-index: 1;
  pointer-events: none;
}

.obra-pdf-charts-stage > div {
  width: 520px;
  height: 310px;
  display: inline-block;
  vertical-align: top;
  background: #fff;
}

.obra-pdf-charts-stage > #pdfChartDaily {
  display: block;
  width: 1060px;
  height: 330px;
  margin-top: 10px;
}

@media (max-width: 760px) {
  .invoice-header-grid {
    grid-template-columns: 1fr 1fr;
  }

  .invoice-header-grid .span-2,
  .invoice-header-grid .span-3,
  .invoice-ruc-field,
  .invoice-provider-field {
    grid-column: 1/-1;
  }

  .invoice-tax-line {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .electronic-grid {
    grid-template-columns: 1fr;
  }

  #module-gastos .table-wrap table,
  #module-gastos .table-wrap thead,
  #module-gastos .table-wrap tbody,
  #module-gastos .table-wrap tr,
  #module-gastos .table-wrap th,
  #module-gastos .table-wrap td {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }

  #module-gastos .table-wrap thead {
    display: none;
  }

  #module-gastos .table-wrap tbody {
    padding: 7px;
    display: grid;
    gap: 8px;
  }

  #module-gastos .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 8px;
    background: #fff;
  }

  #module-gastos .table-wrap td {
    border: 0;
    padding: 4px 2px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
    font-size: 11px;
  }

  #module-gastos .table-wrap td::before {
    flex: 0 0 34%;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #858a92;
    font-weight: 900;
    text-align: left;
  }

  #module-gastos td:nth-child(1)::before {
    content: "Categoría";
  }

  #module-gastos td:nth-child(2)::before {
    content: "Gasto";
  }

  #module-gastos td:nth-child(3)::before {
    content: "Unidad";
  }

  #module-gastos td:nth-child(4)::before {
    content: "Precio ref.";
  }

  #module-gastos td:nth-child(5)::before {
    content: "Coeficiente";
  }

  #module-gastos td:nth-child(6)::before {
    content: "Estado";
  }

  #module-gastos td:nth-child(7)::before {
    content: "Acciones";
  }

  #module-gastos .table-wrap td.empty::before {
    display: none;
    content: none;
  }
}

@media (max-width: 640px) {
  .dashboard-main {
    overflow: hidden;
  }

  .menu-grid {
    grid-template-rows: none !important;
    /*grid-auto-rows: minmax(78px, 1fr);*/
    height: auto !important;
    max-height: 100%;
    overflow-y: auto;
    padding-right: 2px;
    align-self: stretch;
  }

  .menu-card {
    /*min-height: 78px*/
    /* Calcular para que quepan 8 filas en el view height */
    height: calc((100dvh - 220px) / 8);
  }
}

.invoice-provider-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr);
  gap: 10px;
}

@media (max-width: 760px) {
  .invoice-provider-row {
    grid-template-columns: 1fr;
  }
}

/* Login por pasos */
.login-body {
  min-height: 100%;
  overflow: auto;
  background:
    radial-gradient(circle at 15% 15%, rgba(229, 20, 0, 0.09), transparent 32%),
    #fff;
  display: grid;
  place-items: center;
  padding: clamp(18px, 5vw, 56px);
}

.login-step-card {
  width: min(760px, 100%);
  background: #fff;
  border: 1px solid rgba(35, 38, 43, 0.06);
  border-radius: 0;
  padding: clamp(28px, 5vw, 48px);
  box-shadow: none;
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.login-step-card.step-visible {
  opacity: 1;
  transform: none;
}

.login-step-card[hidden] {
  display: none;
}

.login-step-card h1 {
  margin: 8px 0;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -0.035em;
}

.login-step-card > .muted {
  margin: 0 0 28px;
  line-height: 1.5;
}

.login-step-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.login-step-kicker span {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 0;
  color: #fff;
  background: var(--red);
  letter-spacing: 0;
}

.company-selection-card .company-login-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.company-selection-card .company-login-option {
  width: 100%;
  height: 126px;
  min-height: 0;
  display: block;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--red);
  text-align: center;
  transition:
    border-color 0.16s,
    box-shadow 0.16s,
    transform 0.16s;
}

.company-selection-card .company-login-option:hover,
.company-selection-card .company-login-option:focus-visible {
  border-color: var(--red);
  outline: none;
  box-shadow: none;
  transform: translateY(-2px);
}

.company-selection-card .company-login-logo {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  font-size: 28px;
}

.company-selection-card .company-login-logo img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: center;
  padding: 6px;
}

.login-empty-companies {
  grid-column: 1/-1;
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: 0;
  color: var(--muted);
  text-align: center;
}

.credentials-step {
  width: min(480px, 100%);
}

.credentials-step label {
  display: block;
  margin: 17px 0 7px;
  font-size: 13px;
  font-weight: 800;
}

.credentials-step input:not([type="hidden"]) {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
}

.credentials-step input:focus {
  border-color: var(--red);
  box-shadow: none;
}

.login-back-button {
  width: 100%;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--red);
  border-radius: 0;
  background: #fff;
  color: var(--red);
  padding: 0 16px;
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 800;
}

.login-back-button:hover {
  background: var(--soft);
}

.selected-company-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 1px;
  margin-bottom: 24px;
  justify-content: center;
  /*border: 1px solid var(--line);
  border-radius:0;
  background: #fafafb*/
}

.selected-company-logo {
  flex: 0 0 200px;
  width: 200px;
  height: 100px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 0;
  background: #fff;
  color: var(--red);
  font-size: 22px;
}

.selected-company-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.selected-company-heading span,
.selected-company-heading strong {
  display: block;
}

.selected-company-heading span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.selected-company-heading strong {
  font-size: 15px;
}

@media (max-width: 720px) {
  .login-steps-shell {
    padding: 14px;
  }

  .login-step-card {
    padding: 25px 20px;
    border-radius: 0;
  }

  .company-selection-card {
    width: min(470px, 100%);
  }

  .company-selection-card .company-login-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
  }

  .company-selection-card .company-login-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 3 / 1;
    padding: 8px;
    overflow: hidden;
    border-radius: 0;
  }

  .login-step-card > .muted {
    margin-bottom: 20px;
  }

  .selected-company-logo {
    flex-basis: 96px;
    width: 96px;
    height: 60px;
  }

  .company-selection-card .company-login-logo img {
    display: block;
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center;
    padding: 6px;
  }

  .company-selection-card .company-login-logo {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
  }

  .login-step-kicker {
    align-items: flex-start;
    line-height: 1.35;
    white-space: normal;
  }

  .login-step-kicker span {
    flex: 0 0 25px;
  }
}

@media (max-width: 720px) and (orientation: landscape) {
  .company-selection-card .company-login-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .company-selection-card .company-login-option {
    height: auto;
    aspect-ratio: 2 / 1;
  }
}

@media (max-width: 380px) {
  .login-step-card {
    padding: 22px 16px;
  }

  .company-selection-card .company-login-option {
    aspect-ratio: 2.7 / 1;
    padding: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-step-card,
  .company-selection-card .company-login-option {
    transition: none;
  }
}

/* Selector de ubicación de Obras/Servicios */
.obra-address-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.obra-address-row .btn {
  white-space: nowrap;
}

.obra-address-row input[readonly] {
  background: #f4f5f6;
  color: var(--text);
  cursor: default;
}

.obra-location-picker {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fafbfc;
}

.obra-location-map {
  width: 100%;
  height: 330px;
  margin-top: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #eef0f2;
}

.obra-location-map.unavailable {
  display: grid;
  place-items: center;
  padding: 22px;
  text-align: center;
}

.obra-location-map.unavailable > div {
  display: grid;
  justify-items: center;
  gap: 7px;
  max-width: 430px;
  color: var(--muted);
}

.obra-location-map.unavailable i {
  color: var(--red);
  font-size: 30px;
}

.obra-location-map.unavailable strong {
  color: var(--text);
}

.obra-map-status {
  min-height: 18px;
  margin: 7px 2px 10px;
  color: var(--muted);
  font-size: 11px;
}

.obra-map-status.error {
  color: var(--red);
}

.obra-coordinate-summary {
  padding: 8px 10px;
  border-radius: 0;
  background: #eef0f2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.obra-coordinate-summary.selected {
  background: rgba(229, 20, 0, 0.08);
  color: var(--red);
}

@media (max-width: 640px) {
  .obra-address-row {
    grid-template-columns: 1fr;
  }

  .obra-address-row input {
    grid-column: 1;
  }

  .obra-address-row .btn {
    width: 100%;
    padding-inline: 8px;
  }

  .obra-location-picker {
    padding: 8px;
  }

  .obra-location-map {
    height: 245px;
  }
}

/* Página independiente de edición de presupuestos */
.budget-editor-page {
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  background: #f4f5f7;
}

.budget-page-header {
  position: sticky;
  top: 0;
  z-index: 40;
}

.budget-page-header-left {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.budget-page-header-left .back-btn {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.budget-page-header-left img {
  width: auto;
  max-width: 120px;
  object-fit: contain;
}

.budget-page-header-left > div:last-child {
  display: grid;
  min-width: 0;
}

.budget-page-header-left small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.budget-page-header-left strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-page-main {
  display: grid;
  width: 100%;
  max-width: none;
  gap: 10px;
  padding: 10px;
}

.budget-page-panel {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.budget-page-section-head,
.budget-items-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.budget-page-section-head > div,
.budget-items-page-head > div:first-child {
  min-width: 0;
}

.budget-page-section-head span:not(.badge),
.budget-items-page-head > div:first-child > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.budget-page-section-head h1,
.budget-items-page-head h2 {
  margin: 1px 0 0;
  color: var(--ink);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.budget-information-form {
  display: grid;
  grid-template-columns: minmax(210px, 2fr) 82px 135px minmax(
      210px,
      1.5fr
    ) minmax(170px, 1.2fr) 105px auto;
  align-items: end;
  gap: 8px;
  margin-top: 9px;
}

.budget-information-form .field label {
  margin-bottom: 3px;
  font-size: 9px;
}

.budget-information-form .field input,
.budget-information-form .field select,
.budget-information-form > .btn {
  height: 36px;
  border-radius: 0;
  font-size: 11px;
}

.budget-month-input {
  display: flex;
  align-items: center;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
}

.budget-month-input:focus-within {
  border-color: var(--red);
  box-shadow: none;
}

.budget-month-input input {
  min-width: 0;
  height: 34px !important;
  border: 0 !important;
  border-radius: 0;
  outline: 0;
}

.budget-month-input span {
  padding-right: 9px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.budget-information-form > .btn {
  padding-inline: 12px;
  white-space: nowrap;
}

.budget-items-page-tools {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 7px;
}

.budget-page-percentage-card,
.budget-page-total {
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 38px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fafbfc;
}

.budget-page-percentage-card small,
.budget-page-total small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.budget-page-total {
  min-width: 110px;
  border-color: #ead7d9;
  background: #fff7f7;
  text-align: right;
}

.budget-page-total strong {
  color: var(--red);
  font-size: 14px;
  white-space: nowrap;
}

.budget-items-page-tools > .btn {
  height: auto;
  min-height: 38px;
  padding: 0 12px;
  font-size: 11px;
  white-space: nowrap;
}

.budget-page-table-wrap {
  max-height: calc(100dvh - 270px);
  margin-top: 8px;
  border-radius: 0;
}

.budget-page-items-table th,
.budget-page-items-table td {
  padding: 5px 6px;
  font-size: 10px;
  white-space: nowrap;
}

.budget-page-items-table td:nth-child(2),
.budget-page-items-table td:nth-child(3) {
  white-space: normal;
}

.budget-page-items-table th:nth-child(n + 5):nth-child(-n + 12),
.budget-page-items-table td:nth-child(n + 5):nth-child(-n + 12) {
  text-align: right;
}

.budget-page-items-table .budget-stage-row td {
  padding: 5px 7px !important;
}

.budget-page-items-table .budget-stage-actions-spacer {
  text-align: center;
}

.budget-page-items-table .actions {
  gap: 3px;
}

.budget-page-items-table .row-btn,
.budget-items-page-tools .row-btn {
  width: 25px;
  min-width: 25px;
  height: 25px;
  padding: 0;
  border-radius: 0;
  font-size: 10px;
}

#budgetPagePagination > .table-pagination {
  margin-top: 8px;
}

#budgetItemModal .modal-card.budget-item-editor-modal {
  width: calc(100vw - 20px);
  max-width: none;
  max-height: calc(100dvh - 20px);
}

#budgetItemModal .modal-body {
  padding: 9px 11px;
}

#budgetItemModal .autocomplete-item {
  width: 100%;
  border: 0;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
}

.budget-rubro-picker {
  min-width: 0;
  font-size: 12px;
}

.budget-picker-description {
  min-width: 0;
}

.budget-picker-toolbar,
.budget-picker-footer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.budget-picker-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.budget-picker-select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
}

.budget-rubro-picker input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #187448;
  cursor: pointer;
}

.budget-rubro-picker .budget-picker-table-wrap {
  max-height: none;
  overflow: visible;
}

.budget-rubro-picker .table-wrap td {
  padding: 8px 5px;
  font-size: 12px;
}

.budget-rubro-picker .rubro-total-btn {
  cursor: default;
}

.budget-rubro-picker .rubro-total-btn:hover {
  transform: none;
}

.budget-rubro-picker .table-wrap tr.is-selected > td {
  background: #f1faf4;
}

.budget-rubro-picker .rubro-category-columns th:nth-last-child(-n + 2),
.budget-rubro-picker td[data-label="Agregar"],
.budget-rubro-picker td[data-label="Cantidad"] {
  text-align: center;
}

.budget-picker-quantity {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  font: inherit;
  text-align: right;
}

.budget-picker-quantity:disabled {
  background: #f4f5f6;
  color: var(--muted);
}

.budget-picker-quantity:focus {
  outline: 2px solid #187448;
  outline-offset: 1px;
}

.budget-picker-footer {
  position: sticky;
  z-index: 2;
  bottom: -9px;
  padding: 10px 0 5px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.budget-picker-footer > div {
  display: grid;
  gap: 3px;
  margin-right: auto;
}

.budget-picker-footer small:empty {
  display: none;
}

.budget-picker-footer .error {
  color: var(--red);
}

.budget-picker-mobile-filters {
  display: none;
}

@media (max-width: 760px) {
  .budget-picker-mobile-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
  }

  .budget-rubro-picker .table-wrap td[data-label="Cantidad"] input {
    width: min(190px, 64%);
    margin-left: auto;
  }

  .budget-rubro-picker td[data-label="Agregar"],
  .budget-rubro-picker td[data-label="Cantidad"] {
    text-align: right;
  }

  .budget-picker-footer {
    flex-wrap: wrap;
  }

  .budget-picker-footer > div {
    flex: 1 0 100%;
  }

  .budget-picker-footer > .btn {
    flex: 1;
    justify-content: center;
    padding: 0 10px;
    font-size: 12px;
  }
}

@media (max-width: 1180px) {
  .budget-information-form {
    grid-template-columns: minmax(210px, 2fr) 82px 135px minmax(190px, 1.4fr);
  }

  .budget-information-form > .field:nth-of-type(5),
  .budget-information-form > .field:nth-of-type(6),
  .budget-information-form > .btn {
    grid-row: 2;
  }

  .budget-information-form > .field:nth-of-type(5) {
    grid-column: span 2;
  }

  .budget-information-form > .field:nth-of-type(6) {
    grid-column: 3;
  }

  .budget-information-form > .btn {
    grid-column: 4;
  }

  .budget-items-page-head {
    align-items: flex-end;
    flex-direction: column;
  }

  .budget-items-page-tools {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .budget-page-header {
    padding-inline: 8px;
  }

  .budget-page-header .company-pill,
  .budget-page-header .user-pill {
    display: none;
  }

  .budget-page-header-left img {
    max-width: 78px;
    height: 32px;
  }

  .budget-page-main {
    gap: 8px;
    padding: 7px;
  }

  .budget-page-panel {
    padding: 9px;
    border-radius: 0;
  }

  .budget-information-form {
    grid-template-columns: 1fr;
  }

  .budget-information-form > .field,
  .budget-information-form > .field:nth-of-type(5),
  .budget-information-form > .field:nth-of-type(6),
  .budget-information-form > .btn {
    grid-column: 1;
    grid-row: auto;
  }

  .budget-information-form > .btn {
    width: 100%;
  }

  .budget-items-page-head {
    align-items: stretch;
  }

  .budget-items-page-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .budget-page-total,
  .budget-items-page-tools > .btn {
    min-height: 40px;
  }

  .budget-items-page-tools > .btn {
    width: 100%;
  }

  .budget-page-table-wrap {
    max-height: none;
    overflow-x: auto;
    border: 0;
  }
}

@media (max-width: 430px) {
  .budget-page-header-left img {
    display: none;
  }

  .budget-page-header-left strong {
    max-width: 175px;
  }

  .budget-items-page-tools {
    grid-template-columns: 1fr;
  }

  .budget-page-total {
    text-align: left;
  }
}

+

/* Pedidos de materiales */
#module-pedidos .table-wrap table {
  min-width: 1050px;
}

#module-pedidos .module-toolbar > select {
  height: 42px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
}

.badge.order-status.borrador {
  background: #eef0f3;
  color: #535b66;
}

.badge.order-status.solicitado {
  background: #fff1cf;
  color: #8b5b00;
}

.badge.order-status.enviado {
  background: #e7f1ff;
  color: #165ea8;
}

.badge.order-status.entregado {
  background: #e5f6ec;
  color: #187a43;
}

.badge.order-status.cancelado {
  background: #fde7e9;
  color: #a11b27;
}

.order-header-grid {
  margin-bottom: 4px;
}

.order-items-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.order-items-heading h4 {
  margin: 0 0 3px;
  font-size: 16px;
}

.order-items-heading span {
  color: var(--muted);
  font-size: 12px;
}

.order-save-first {
  padding: 24px;
  border: 1px dashed #d7dbe0;
  border-radius: 0;
  background: #fafafa;
  color: var(--muted);
  text-align: center;
}

.order-items-wrap {
  max-height: 43vh;
}

.order-items-wrap .mini-table {
  min-width: 820px;
}

.order-image-stack {
  display: flex;
  align-items: center;
  min-width: 90px;
}

.order-image-stack a {
  display: block;
  margin-right: -8px;
}

.order-image-stack img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 2px solid #fff;
  border-radius: 0;
  box-shadow: none;
}

.order-image-stack span {
  margin-left: 13px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.order-image-preview,
.order-existing-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.order-image-preview > div,
.order-existing-image {
  position: relative;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
}

.order-image-preview img,
.order-existing-image img {
  display: block;
  width: 100%;
  height: 92px;
  object-fit: cover;
  border-radius: 0;
}

.order-image-preview span {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-existing-image .row-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  box-shadow: none;
}

@media (max-width: 768px) {
  #module-pedidos .module-head {
    align-items: stretch;
    flex-direction: column;
  }

  #module-pedidos .head-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #module-pedidos .head-actions .btn {
    min-width: 0;
    justify-content: center;
  }

  #module-pedidos .module-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  #module-pedidos .module-toolbar > select,
  #module-pedidos .module-toolbar .search-box {
    width: 100%;
    max-width: none;
  }

  #module-pedidos .table-wrap table,
  #module-pedidos .table-wrap tbody,
  #module-pedidos .table-wrap tr,
  #module-pedidos .table-wrap td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #module-pedidos .table-wrap thead {
    display: none;
  }

  #module-pedidos .table-wrap tbody {
    display: grid;
    gap: 9px;
    padding: 8px;
  }

  #module-pedidos .table-wrap tr {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
  }

  #module-pedidos .table-wrap td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 2px;
    border: 0;
    text-align: right;
  }

  #module-pedidos .table-wrap td::before {
    content: attr(data-label);
    flex: 0 0 32%;
    color: var(--muted);
    font-size: 8px;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
  }

  #module-pedidos .table-wrap td.empty {
    display: block;
    text-align: center;
  }

  #module-pedidos .table-wrap td.empty::before {
    display: none;
  }

  #module-pedidos .actions {
    margin-left: auto;
  }

  .order-items-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .order-items-heading .btn {
    width: 100%;
    justify-content: center;
  }

  .order-image-preview,
  .order-existing-images {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Filtros de Rubros: la lupa abre su campo junto al botón pulsado. */
.app-body.rubros-page-open {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

.app-body.rubros-page-open .dashboard-main {
  display: none;
}

#module-rubros {
  position: relative;
  inset: auto;
  min-height: calc(100dvh - var(--header));
  grid-template-rows: auto auto;
  align-content: start;
  overflow: visible;
}

#module-rubros .rubro-table-area {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#module-rubros .rubro-table-area > .table-wrap {
  flex: none;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

#module-rubros .rubro-global-search {
  flex: none;
  width: 100%;
  min-width: 0;
  margin-bottom: 8px;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  margin-left: 3px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #187448;
  font-size: 12px;
  cursor: pointer;
  vertical-align: middle;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-trigger:hover,
:is(#module-rubros, .budget-rubro-picker) .rubro-filter-trigger.is-active,
:is(#module-rubros, .budget-rubro-picker)
  .rubro-filter-trigger[aria-expanded="true"] {
  border-color: #b7dfc8;
  background: #e8f7ee;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-trigger:focus-visible {
  outline: 2px solid #187448;
  outline-offset: 2px;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-popover {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  width: min(260px, calc(100vw - 16px));
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-popover[hidden],
:is(#module-rubros, .budget-rubro-picker) .rubro-filter-popover [hidden] {
  display: none;
}

:is(#module-rubros, .budget-rubro-picker)
  .rubro-filter-popover
  [data-rubro-filter-field="gastos"]:not([hidden]) {
  display: grid;
  gap: 8px;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-popover input {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  outline: none;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-popover input:focus {
  border-color: #187448;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-popover select {
  display: block;
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-filter-popover select:focus {
  border-color: #187448;
  outline: none;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-total-btn.mat,
:is(#module-rubros, .budget-rubro-picker) .rubro-total-btn.mdo,
:is(#module-rubros, .budget-rubro-picker) .rubro-total-btn.gas {
  background: #eaf8ef;
  border-color: #b7dfc8;
  color: #176b3e;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-total-btn.mat:hover,
:is(#module-rubros, .budget-rubro-picker) .rubro-total-btn.mdo:hover,
:is(#module-rubros, .budget-rubro-picker) .rubro-total-btn.gas:hover {
  background: #daf1e3;
  border-color: #82c69f;
}

#module-rubros .rubro-table-filters {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 11px;
  width: 100%;
  margin-bottom: 8px;
}

#module-rubros .rubro-table-filters > span {
  display: none;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
}

:is(#module-rubros, .budget-rubro-picker)
  .table-wrap
  tr[data-rubro-category-row][hidden] {
  display: none !important;
}

:is(#module-rubros, .budget-rubro-picker)
  .table-wrap
  .rubro-category-columns
  > th {
  position: static;
  z-index: auto;
}

:is(#module-rubros, .budget-rubro-picker) .table-wrap .rubro-number-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

:is(#module-rubros, .budget-rubro-picker)
  .table-wrap
  .rubro-category-heading
  > th {
  position: static;
  z-index: auto;
  padding: 0;
  border-bottom: 1px solid #cce3d6;
  background: #edf6f0;
  text-align: left;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-category-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  width: 100%;
  padding: 11px 36px;
  border: 0;
  background: transparent;
  color: #176b3e;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

#module-rubros .rubro-category-title {
  display: flex;
  align-items: center;
  min-width: 0;
}

#module-rubros .rubro-category-title .rubro-category-toggle {
  flex: 1;
  width: auto;
  min-width: 0;
}

#module-rubros .rubro-category-stage-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 6px 10px;
  font-size: 11px;
}

#module-rubros .rubro-category-stage-controls .rubro-stage-select {
  width: 140px;
  padding: 5px;
}

#module-rubros .rubro-category-stage-controls .btn {
  padding: 6px 9px;
  font-size: 11px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  #module-rubros .rubro-category-title {
    flex-wrap: wrap;
  }
  #module-rubros .rubro-category-stage-controls {
    flex: 1 0 100%;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border-top: 1px solid #cce3d6;
  }
  #module-rubros .rubro-category-stage-controls .rubro-stage-select {
    flex: 1;
    width: 0;
  }
}

#module-rubros .rubro-category-order {
  flex: 0 0 64px;
  width: 64px;
  min-width: 0;
  height: 30px;
  margin-left: 10px;
  padding: 0 4px;
  border: 1px solid #b7dfc8;
  border-radius: 0;
  background: #fff;
  color: #176b3e;
  font: inherit;
  font-size: 12px;
  text-align: center;
}

#module-rubros .rubro-category-order:focus {
  outline: 2px solid #187448;
  outline-offset: 1px;
}

#module-rubros .rubro-category-order[readonly] {
  border-color: transparent;
  background: transparent;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-category-toggle:hover {
  background: #e0f0e6;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-category-toggle:focus-visible {
  outline: 2px solid #187448;
  outline-offset: -3px;
}

:is(#module-rubros, .budget-rubro-picker) .rubro-category-toggle i {
  position: absolute;
  left: 12px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

:is(#module-rubros, .budget-rubro-picker)
  .rubro-category-toggle[aria-expanded="false"]
  i {
  transform: rotate(-90deg);
}

:is(#module-rubros, .budget-rubro-picker) .rubro-category-toggle span {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  #module-rubros .rubro-table-filters {
    display: flex;
  }

  #module-rubros .rubro-table-filters > span {
    display: inline-flex;
  }

  :is(#module-rubros, .budget-rubro-picker) .table-wrap colgroup,
  :is(#module-rubros, .budget-rubro-picker)
    .table-wrap
    .rubro-category-columns {
    display: none !important;
  }

  :is(#module-rubros, .budget-rubro-picker) .table-wrap .rubro-number-cell {
    text-align: right;
  }

  :is(#module-rubros, .budget-rubro-picker)
    .table-wrap
    .rubro-category-heading {
    padding: 0;
    overflow: hidden;
    border-color: #cce3d6;
    background: #edf6f0;
  }

  :is(#module-rubros, .budget-rubro-picker)
    .table-wrap
    .rubro-category-heading
    > th {
    border: 0;
  }
}

th.catalog-rub-col,
td.catalog-rub-col {
  width: 54px;
  text-align: center;
  white-space: nowrap;
}

.catalog-rubro-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: #198754;
  color: #fff;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.catalog-rubro-count:hover {
  background: #126a41;
}

.catalog-rubro-count:focus-visible {
  outline: 2px solid #126a41;
  outline-offset: 2px;
}
/* Presupuestos asistidos por planos */
#module-presupuestos .module-head .head-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
@media (max-width: 760px) {
  #module-presupuestos .module-head {
    flex-wrap: wrap;
    gap: 8px;
  }
  #module-presupuestos .module-head .head-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  #module-presupuestos .module-head .head-actions .btn {
    min-width: 0;
    height: auto;
    min-height: 40px;
    padding: 8px;
    font-size: 12px;
    line-height: 1.3;
    white-space: normal;
    text-align: center;
  }
}
.budget-ai-create-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line, #dbe2e8);
  padding-top: 1rem;
}
.budget-ai-create-section h4 {
  margin: 0 0 0.35rem;
}
.budget-ai-create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
  margin-top: 0.8rem;
}
.budget-ai-upload-card {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--line, #dbe2e8);
  border-radius: 0;
  background: #f8fafc;
}
.budget-ai-upload-card input[type="file"] {
  max-width: 100%;
  font-size: 0.82rem;
}
.budget-ai-panel {
  margin-bottom: 1rem;
}
.budget-ai-panel > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.05rem;
  list-style-position: inside;
}
.budget-ai-panel > summary i {
  margin-right: 0.45rem;
}
.budget-ai-panel-body {
  margin-top: 1rem;
}
.budget-ai-editor-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.7rem;
  margin: 1rem 0;
}
.budget-ai-editor-upload[hidden],
#budgetAiAnalyze[hidden] {
  display: none;
}
.budget-ai-editor-upload .field {
  flex: 1 1 170px;
  min-width: 150px;
}
.budget-ai-editor-upload .field:has(input[type="file"]) {
  flex: 2 1 260px;
}
.budget-ai-editor-upload input[type="file"] {
  max-width: 100%;
}
.budget-ai-plan-list {
  display: grid;
  gap: 0.45rem;
}
.budget-ai-plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line, #dbe2e8);
  border-radius: 0;
}
.budget-ai-plan small {
  color: #64748b;
}
.budget-ai-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 1rem 0;
}
.budget-ai-error {
  color: #b42318;
}
.budget-ai-warnings:empty,
.budget-ai-draft:empty {
  display: none;
}
.budget-ai-warnings {
  padding: 0.65rem 1rem;
  border: 1px solid #f5d59a;
  border-radius: 0;
  background: #fffbeb;
}
.budget-ai-warnings h4 {
  margin: 0 0 0.4rem;
}
.budget-ai-warnings ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}
.budget-ai-draft {
  margin-top: 1rem;
}
.budget-ai-draft-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}
.budget-ai-draft-head h3 {
  margin: 0;
}
.budget-ai-draft-head > div:last-child {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.budget-ai-table {
  min-width: 1050px;
}
.budget-ai-table td {
  vertical-align: top;
}
.budget-ai-table input[type="number"] {
  width: 90px;
}
.budget-ai-table select {
  min-width: 110px;
}
.budget-ai-table textarea {
  display: block;
  width: 210px;
  max-width: 100%;
  margin-top: 0.4rem;
}
.budget-ai-evidence {
  max-width: 230px;
  white-space: normal;
}
.budget-ai-link-button {
  border: 0;
  background: transparent;
  color: #2457a7;
  padding: 0.2rem 0;
  cursor: pointer;
  text-decoration: underline;
}
.budget-ai-rubro-chooser {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line, #dbe2e8);
  border-radius: 0;
  background: #fff;
}
.budget-ai-rubro-chooser[hidden] {
  display: none;
}
.budget-ai-rubro-chooser > div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.budget-ai-rubro-chooser input {
  width: 100%;
}
#budgetAiRubroResults {
  display: grid;
  max-height: 260px;
  overflow: auto;
  margin-top: 0.5rem;
}
#budgetAiRubroResults button {
  text-align: left;
  border: 0;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.5rem;
  background: #fff;
  cursor: pointer;
}
#budgetAiRubroResults button:hover {
  background: #f1f5f9;
}
#budgetAiRubroResults small {
  display: block;
  color: #64748b;
}

/* Administrador de salarios por año, accesible desde Rubros. */
.salary-admin .salary-toolbar {
  margin: 0 0 10px;
}
.salary-admin .salary-table-wrap {
  max-height: 360px;
}
.salary-admin-table th,
.salary-admin-table td {
  padding: 6px 7px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.salary-admin .salary-editor {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.salary-admin .salary-editor h4 {
  margin: 0 0 10px;
}
@media (max-width: 760px) {
  .salary-admin .salary-table-wrap {
    max-height: 46vh;
  }
  .salary-admin-table,
  .salary-admin-table tbody,
  .salary-admin-table tr,
  .salary-admin-table td {
    display: block;
    width: 100%;
  }
  .salary-admin-table thead {
    display: none;
  }
  .salary-admin-table tbody {
    display: grid;
    gap: 6px;
    padding: 5px;
  }
  .salary-admin-table tr {
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
  }
  .salary-admin-table td {
    display: grid;
    grid-template-columns: minmax(0, 43%) minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    border: 0;
    text-align: right;
  }
  .salary-admin-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    text-align: left;
  }
  .salary-admin-table td[data-label="Año"] .hint {
    grid-column: 2;
  }
  .salary-admin-table td .actions {
    justify-content: flex-end;
  }
  .salary-admin-table td.empty {
    display: block;
    text-align: center;
  }
  .salary-admin-table td.empty::before {
    content: none;
  }
}

.salary-admin .salary-hour-hint {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.salary-admin .salary-editor [name="hora"] {
  background: #f7f8f9;
}
@media (min-width: 761px) {
  .salary-admin-table th,
  .salary-admin-table td {
    padding: 5px 4px;
    font-size: 10px;
  }
}

.modal-card.salary-admin-modal {
  width: 95vw;
  max-width: 1400px;
}
.salary-admin-table .badge {
  white-space: nowrap;
}

.salary-admin .salary-matrix-field {
  min-width: 0;
}
.salary-admin .salary-matrix-field h5 {
  margin: 0 0 6px;
  font-size: 12px;
}
.salary-admin .salary-role-matrix-wrap {
  border: 1px solid var(--line);
  border-radius: 0;
}
.salary-admin .salary-role-matrix {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.salary-admin .salary-role-matrix th,
.salary-admin .salary-role-matrix td {
  padding: 6px;
  border: 1px solid var(--line);
  vertical-align: middle;
}
.salary-admin .salary-role-matrix th {
  background: #f7f8f9;
  font-size: 10px;
  text-align: left;
}
.salary-admin .salary-role-matrix th:first-child {
  width: 12%;
}
.salary-admin .salary-role-matrix .field {
  min-width: 0;
}
.salary-admin .salary-role-matrix input {
  width: 100%;
  min-width: 0;
  text-align: right;
}
.salary-admin .salary-role-matrix .salary-hour-hint {
  text-align: right;
}
.salary-admin .salary-period-label {
  display: block;
  font-size: 9px;
  color: var(--muted);
}
.salary-admin .salary-special-rates {
  margin-top: 5px;
}
.salary-admin .salary-special-rates summary {
  cursor: pointer;
  color: var(--good);
  font-size: 10px;
}
.salary-admin .salary-role-summary {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}
.salary-admin .salary-role-rate {
  display: grid;
  grid-template-columns: minmax(0, 42%) minmax(0, 1fr);
  gap: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.salary-admin .salary-role-rate > span {
  font-size: 10px;
  color: var(--muted);
}
.salary-admin .salary-role-rate > div {
  text-align: right;
}
@media (max-width: 760px) {
  .salary-admin .salary-role-matrix,
  .salary-admin .salary-role-matrix tbody,
  .salary-admin .salary-role-matrix tr {
    display: block;
    width: 100%;
  }
  .salary-admin .salary-role-matrix thead {
    display: none;
  }
  .salary-admin .salary-role-matrix tbody {
    display: grid;
    gap: 8px;
    padding: 5px;
  }
  .salary-admin .salary-role-matrix tr {
    border: 1px solid var(--line);
    border-radius: 0;
  }
  .salary-admin .salary-role-matrix th[scope="row"] {
    display: block;
    width: 100%;
    padding: 8px;
    border: 0;
  }
  .salary-admin .salary-role-matrix td {
    display: grid;
    grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
    gap: 6px;
    align-items: center;
    padding: 6px;
    border-width: 1px 0 0;
  }
  .salary-admin .salary-role-matrix td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
  }
  .salary-admin-table td[data-salary-role] {
    display: block;
  }
  .salary-admin-table td[data-salary-role]::before {
    display: block;
    margin-bottom: 5px;
    font-weight: 700;
  }
}
