/* -------------------------------------------------------------------------
   GestFel CSS · 35-operational-modules.css
   Facturación y LoraCat. Componentes operativos, gráficos y formularios.
   ------------------------------------------------------------------------- */

@layer modules {

.module-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin: 0 0 18px;
  padding: 12px 0 2px;
}

/* Aviso de duplicados al registrar recargas de pienso. */
.food-duplicate-warning {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--teal, #2ab7a9) 55%, currentColor);
  border-radius: 14px;
  background: color-mix(in srgb, var(--teal, #2ab7a9) 10%, var(--surface, #f4f8f7));
}

.food-duplicate-warning h3,
.food-duplicate-warning p {
  margin: 0;
}

.food-duplicate-options {
  display: grid;
  gap: 8px;
}

.food-duplicate-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line, #c8d9d6);
  border-radius: 10px;
  background: var(--surface, #fff);
  cursor: pointer;
}

.food-duplicate-option:hover,
.food-duplicate-option:focus-within {
  border-color: var(--teal, #2ab7a9);
  background: color-mix(in srgb, var(--teal, #2ab7a9) 8%, var(--surface, #fff));
}

.food-duplicate-option span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.food-duplicate-option small,
.food-duplicate-warning__note {
  color: var(--muted, #5f7471);
}

.food-duplicate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

html[data-gestfel-theme="dark"] .food-duplicate-warning {
  border-color: var(--gf-accent, #72d5c1);
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 12%, var(--gf-panel, #132b39));
  color: var(--gf-text, #eefaf7);
}

html[data-gestfel-theme="dark"] .food-duplicate-option {
  border-color: var(--gf-line, rgba(157, 204, 197, .34));
  background: #102a34;
  color: var(--gf-text, #eefaf7);
}

html[data-gestfel-theme="dark"] .food-duplicate-option:hover,
html[data-gestfel-theme="dark"] .food-duplicate-option:focus-within {
  border-color: var(--gf-accent, #72d5c1);
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 15%, #102a34);
}

html[data-gestfel-theme="dark"] .food-duplicate-option small,
html[data-gestfel-theme="dark"] .food-duplicate-warning__note {
  color: var(--gf-muted, #b7cbc7);
}

.module-hero h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  line-height: 1.1;
}

.module-hero h1 span {
  display: block;
  margin-top: 5px;
  color: var(--teal);
  font-size: .56em;
  font-weight: 750;
}

.module-hero p {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.48;
}

.module-hero__icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--teal) 25%, var(--line));
  border-radius: 17px;
  color: var(--teal);
  background: color-mix(in srgb, var(--mint) 72%, #fff);
}

.module-hero__icon .app-icon {
  width: 34px;
  height: 34px;
}

.module-hero__icon:has(.app-generated-icon) {
  border: 0;
  background: transparent;
}

.module-hero__icon .app-generated-icon {
  width: 58px;
  height: 58px;
}

.module-hero__actions,
.card-head,
.billing-lines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.module-hero__actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.module-filterbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(15, 36, 55, .05);
}

.module-filterbar label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--dark);
  font-size: .78rem;
  font-weight: 750;
}

.module-filterbar input,
.module-filterbar select {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 42px;
  min-height: 42px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: .88rem;
  line-height: 1.2;
}

.module-filterbar select {
  padding-right: 32px;
}

.module-filterbar input[type="date"] {
  padding-right: 8px;
}

.loracat-filters input[type="date"] {
  text-align: center;
}

.loracat-filters input[type="date"]::-webkit-datetime-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.billing-filters input[type="date"] {
  padding-left: 0;
  padding-right: 8px;
  text-align: center;
}

.billing-filters input[type="date"]::-webkit-datetime-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.billing-filters input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

.module-filterbar .btn,
.module-filterbar button {
  box-sizing: border-box;
  height: 42px;
  min-height: 42px;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  font-size: .88rem;
  line-height: 1.2;
}

.module-filterbar__grow {
  grid-column: span 2;
}

.billing-filters {
  grid-template-columns: .72fr 1fr 1.25fr 1.7fr .92fr .92fr auto;
}

.billing-filters .module-filterbar__grow {
  grid-column: auto;
}

.module-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin: 0 0 16px;
}

.module-kpis article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 9px 28px rgba(15, 36, 55, .055);
}

.module-kpis article > span {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
}

.module-kpis article:nth-child(even) > span {
  background: #31a75d;
}

.module-kpis .app-icon {
  width: 26px;
  height: 26px;
}

.module-kpis div {
  min-width: 0;
}

.module-kpis small,
.module-kpis em {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-style: normal;
}

.module-kpis strong {
  display: block;
  margin: 3px 0;
  color: var(--dark);
  font-size: clamp(1.55rem, 2.5vw, 2rem);
  line-height: 1;
}

.module-empty {
  display: grid;
  min-height: 270px;
  place-items: center;
  align-content: center;
  gap: 9px;
  text-align: center;
}

.module-empty > .app-icon {
  width: 52px;
  height: 52px;
  color: var(--teal);
}

.module-empty h2,
.module-empty h3,
.module-empty p {
  margin: 0;
}

.module-empty p {
  max-width: 520px;
  color: var(--muted);
}

.card-head {
  margin-bottom: 14px;
}

.card-head h2,
.billing-lines-head h3 {
  margin: 0;
}

.card-head p,
.billing-lines-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .86rem;
}

/* Facturación */

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

.billing-editor,
.billing-detail,
.billing-list {
  margin-bottom: 16px;
}

.billing-header-fields {
  margin-bottom: 20px;
}

.billing-draft-wizard {
  display: grid;
  gap: 12px;
  margin: -4px 0 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--teal) 36%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--mint) 42%, transparent);
}

.billing-draft-wizard__intro {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.billing-draft-wizard__intro span {
  color: var(--teal);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.billing-draft-wizard__intro strong {
  color: var(--text);
  font-size: .9rem;
}

.billing-draft-wizard ol {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.billing-draft-wizard__step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 10px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.billing-draft-wizard__step > span {
  display: grid;
  flex: 0 0 24px;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--muted);
  background: color-mix(in srgb, var(--line) 54%, transparent);
  font-size: .74rem;
  font-weight: 850;
}

.billing-draft-wizard__step div {
  min-width: 0;
}

.billing-draft-wizard__step strong,
.billing-draft-wizard__step small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.billing-draft-wizard__step strong {
  color: inherit;
  font-size: .78rem;
}

.billing-draft-wizard__step small {
  margin-top: 2px;
  font-size: .68rem;
}

.billing-draft-wizard__step.is-active {
  border-color: color-mix(in srgb, var(--teal) 64%, var(--line));
  color: var(--text);
  background: color-mix(in srgb, var(--mint) 72%, var(--surface));
}

.billing-draft-wizard__step.is-active > span,
.billing-draft-wizard__step.is-complete > span {
  color: #fff;
  background: var(--teal);
}

.billing-draft-cancel-form {
  display: inline-flex;
  margin: 0;
}

/* La ayuda del descuento ocupa una tercera fila. Sin este anclaje, las otras
   etiquetas de la misma fila reparten ese alto libre y sus inputs descienden. */
.billing-header-fields > label {
  min-width: 0;
  align-content: start;
}

.billing-supplier-history {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: -8px 0 16px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--teal) 32%, var(--line));
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--mint) 48%, transparent);
  font-size: .88rem;
  font-weight: 650;
}

.billing-supplier-history svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  color: var(--teal);
}

.billing-form-recovery-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: -8px 0 16px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--warning, #b7791f) 42%, var(--line));
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, #fff3cd 72%, transparent);
  font-size: .88rem;
  font-weight: 650;
}

.billing-form-recovery-note svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  color: var(--warning, #9b7000);
}

.billing-workflow-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: -8px 0 16px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--line));
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--mint) 46%, transparent);
  font-size: .88rem;
  font-weight: 650;
}

.billing-workflow-note svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  color: var(--teal);
}

.billing-workflow-note a {
  margin-left: 4px;
  overflow-wrap: anywhere;
}

.billing-document-missing {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--warning, #b7791f) 42%, var(--line));
  border-radius: 7px;
  color: #8a5a00;
  background: color-mix(in srgb, #fff3cd 72%, transparent);
  font-size: .75rem;
  font-weight: 800;
  line-height: 1.2;
}

.billing-document-missing-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: -4px 0 16px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--warning, #b7791f) 42%, var(--line));
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, #fff3cd 72%, transparent);
  font-size: .86rem;
  font-weight: 650;
}

.billing-document-missing-note svg,
.billing-document-missing-note .app-illustrated-icon,
.billing-document-missing-note .app-generated-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
  color: var(--warning, #9b7000);
}

.billing-pdf-field {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px dashed color-mix(in srgb, var(--teal) 42%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--mint) 45%, #fff);
}

.billing-pdf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.billing-pdf-ocr-choice {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 750;
}

.billing-pdf-ocr-choice input {
  width: auto;
  min-height: 0;
  accent-color: var(--teal);
}

.billing-pdf-first {
  justify-self: start;
}

.billing-pdf-manual-link {
  justify-self: start;
  color: var(--teal);
  font-size: .78rem;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.billing-editor--pdf-first .billing-header-fields > label:not(.billing-pdf-field),
.billing-editor--pdf-first .billing-totals-assistant,
.billing-editor--pdf-first .billing-reference-editor,
.billing-editor--pdf-first .billing-advanced-lines {
  display: none;
}

.billing-editor--pdf-first > form > .actions .btn-primary {
  display: none;
}

.billing-pdf-first.is-ready {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.billing-form [data-billing-paid-date][hidden] {
  display: none;
}

.billing-reference-editor {
  margin: 16px 0;
  padding: 0 14px 2px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--soft) 64%, #fff);
}

.billing-reference-editor > summary {
  padding: 14px 0 12px;
  border-bottom: 1px solid transparent;
  color: var(--teal);
  cursor: pointer;
  font-weight: 800;
}

.billing-reference-editor[open] > summary {
  margin-bottom: 12px;
  border-bottom-color: var(--line);
}

.billing-reference-editor__intro {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .84rem;
}

.billing-assignment-guide {
  display: grid;
  gap: 5px;
  margin: 14px 0 16px;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--teal) 26%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--mint) 36%, var(--soft));
}

.billing-assignment-guide strong {
  color: var(--teal);
}

.billing-assignment-guide p {
  max-width: 76ch;
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
}

.billing-section-hint {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 650;
}

.billing-reference-editor__concept-note {
  margin: 8px 0 12px;
  padding: 9px 11px;
  border-left: 3px solid var(--teal);
  color: var(--muted);
  background: color-mix(in srgb, var(--teal) 8%, transparent);
  font-size: .78rem;
  line-height: 1.4;
}

.billing-reference-grid select[multiple],
.billing-reference-secondary select[multiple] {
  min-height: 176px;
  padding: 6px;
}

.billing-reference-grid {
  align-items: stretch;
}

.billing-reference-grid > label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 244px;
}

.billing-reference-grid > label > select[multiple] {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

.billing-reference-grid > label > .field-help {
  min-height: 2.7em;
  margin-top: 8px;
}

.billing-reference-grid option,
.billing-reference-secondary option {
  padding: 7px 8px;
  border-radius: 7px;
}

.billing-reference-secondary {
  margin: 12px 0 18px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.billing-reference-secondary summary,
.billing-advanced-lines > summary,
.billing-detail-lines > summary,
.billing-reference-editor > summary {
  color: var(--teal);
  cursor: pointer;
  font-weight: 800;
}

.billing-reference-secondary .grid {
  margin-top: 12px;
}

.billing-advanced-lines {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--soft) 64%, #fff);
}

.billing-advanced-lines > p {
  margin: 7px 0 0;
  color: var(--muted);
}

.billing-advanced-lines .billing-lines-head {
  padding-top: 8px;
  border-top: 0;
}

.billing-lines-head {
  margin: 8px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.billing-lines {
  display: grid;
  gap: 12px;
}

.billing-line {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--soft) 70%, #fff);
}

.billing-line__main {
  display: grid;
  grid-template-columns: minmax(210px, 2fr) minmax(150px, 1.15fr) minmax(82px, .55fr) minmax(105px, .75fr) minmax(105px, .7fr) minmax(78px, .5fr) minmax(145px, .9fr) 36px;
  gap: 10px;
  align-items: start;
}

.billing-line label {
  display: grid;
  grid-template-rows: minmax(2.4em, auto) auto auto;
  align-content: start;
  gap: 5px;
  min-width: 0;
  font-size: .78rem;
  font-weight: 750;
}

.billing-field-label {
  display: block;
  line-height: 1.2;
}

.billing-line__discount .field-help {
  line-height: 1.2;
}

.billing-line select[data-billing-line-tax-rate]:disabled {
  cursor: not-allowed;
  opacity: .72;
  background: color-mix(in srgb, var(--soft) 76%, var(--line));
}

.billing-line__calculation,
.billing-totals-assistant {
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--teal) 22%, var(--line));
  border-radius: 9px;
  color: var(--muted);
  background: color-mix(in srgb, var(--teal) 7%, var(--soft));
  font-size: .78rem;
  font-weight: 700;
}

.billing-line__calculation.is-warning,
.billing-totals-assistant.is-warning {
  color: #8b4a17;
  border-color: color-mix(in srgb, #c77a2b 42%, var(--line));
  background: color-mix(in srgb, #f3c47b 22%, var(--soft));
}

.billing-totals-assistant {
  margin-top: -8px;
}

.billing-line input,
.billing-line select {
  width: 100%;
  min-height: 40px;
}

.billing-line__remove {
  width: 36px;
  height: 40px;
  padding: 0;
  color: #a63b32;
  border: 1px solid color-mix(in srgb, #a63b32 32%, var(--line));
  background: #fff;
  font-size: 1.4rem;
}

.billing-line__links {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.billing-line__links summary {
  color: var(--teal);
  cursor: pointer;
  font-size: .84rem;
  font-weight: 800;
}

.billing-line__links > p {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: .8rem;
}

.billing-line__allocation {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--teal) 18%, var(--line));
}

.billing-line__allocation-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.billing-line__allocation-head > div {
  display: grid;
  gap: 3px;
}

.billing-line__allocation-head strong {
  color: var(--dark);
  font-size: .86rem;
}

.billing-line__allocation-head small {
  color: var(--muted);
  font-size: .76rem;
}

.billing-line__allocation-head > label {
  min-width: min(100%, 300px);
}

.billing-line__existing-event,
.billing-line__target,
.billing-line__new-event {
  margin-top: 10px;
  padding: 11px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--mint) 34%, #fff);
}

.billing-line__existing-event label,
.billing-line__target label {
  display: grid;
  gap: 5px;
  font-size: .78rem;
  font-weight: 750;
}

.billing-line__existing-event select,
.billing-line__target select {
  min-height: 40px;
}

.billing-line__target-picker {
  display: grid;
  gap: 7px;
}

.billing-line__multi-toggle {
  display: block !important;
  min-height: 0;
  color: var(--muted);
  font-size: .74rem !important;
  font-weight: 700 !important;
}

.billing-line__multi-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.billing-line__multi-toggle input {
  width: auto;
  min-height: 0;
  accent-color: var(--teal);
}

.billing-line__multi-picker {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.billing-line__multi-picker > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  cursor: pointer;
  color: var(--dark);
  font-size: .84rem;
  font-weight: 750;
  list-style: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.billing-line__multi-picker > summary::-webkit-details-marker {
  display: none;
}

.billing-line__multi-picker > summary::after {
  content: '⌄';
  color: var(--teal);
  font-size: 1.1rem;
}

.billing-line__multi-picker[open] > summary {
  border-bottom: 1px solid var(--line);
}

.billing-line__multi-picker[open] > summary::after {
  transform: rotate(180deg);
}

.billing-line__multi-picker-panel {
  display: grid;
  gap: 8px;
  padding: 9px;
}

.billing-line__multi-picker-panel input[type="search"] {
  min-height: 36px;
}

.billing-line__multi-picker-options {
  display: grid;
  gap: 6px;
  max-height: min(280px, 42vh);
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 8px;
}

.billing-line__multi-picker-option {
  display: flex !important;
  grid-template-rows: none !important;
  align-items: flex-start;
  gap: 9px;
  min-height: 42px !important;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 7px;
  color: var(--dark);
  background: color-mix(in srgb, var(--soft) 62%, #fff);
  font-size: .8rem !important;
  font-weight: 650 !important;
  line-height: 1.3;
  cursor: pointer;
}

@media (max-width: 540px) {
  .billing-line__multi-picker-options {
    gap: 5px;
    max-height: min(232px, 38vh);
    padding: 5px;
  }
}

.billing-line__multi-picker-option:hover,
.billing-line__multi-picker-option:focus-within {
  border-color: color-mix(in srgb, var(--teal) 48%, var(--line));
  background: color-mix(in srgb, var(--mint) 82%, #fff);
}

.billing-line__multi-picker-option input {
  flex: 0 0 auto;
  width: auto;
  min-height: 0;
  margin-top: .12em;
  accent-color: var(--teal);
}

.billing-line__multi-picker-option[hidden] {
  display: none !important;
}

.billing-wizard__progress {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.billing-wizard__progress span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: color-mix(in srgb, var(--soft) 60%, #fff);
  font-size: .7rem;
  font-weight: 800;
}

.billing-wizard__progress span.is-active,
.billing-wizard__progress span.is-complete {
  color: var(--teal);
  border-color: color-mix(in srgb, var(--teal) 38%, var(--line));
  background: color-mix(in srgb, var(--mint) 75%, #fff);
}

.billing-wizard__screen {
  min-height: 82px;
}

.billing-wizard__screen .field-help {
  margin: 0 0 9px;
}

.billing-wizard__actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 10px;
}

.billing-wizard__message {
  min-height: 1.1em;
  margin: 5px 0 0;
  color: #9a4337;
  font-size: .76rem;
  font-weight: 700;
}

.billing-live-total {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin: 14px 0;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.billing-live-total span {
  color: var(--muted);
  font-size: .82rem;
}

.billing-live-total strong {
  display: block;
  margin-top: 3px;
  color: var(--dark);
  font-size: 1.08rem;
}

.billing-detail-table td:first-child small,
.billing-list td:first-child small,
.billing-list td:nth-child(4) small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.billing-reference-summary {
  margin: 16px 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--soft) 62%, #fff);
}

.billing-ocr-panel {
  margin: 16px 0;
  padding: 17px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line));
  border-radius: 16px;
  background:
    radial-gradient(circle at 100% 0, color-mix(in srgb, var(--mint) 64%, transparent) 0, transparent 38%),
    #fff;
}

.billing-ocr-panel__head,
.billing-ocr-panel__action,
.billing-ocr-review__intro,
.billing-ocr-applied,
.billing-ocr-dismissed,
.billing-ocr-progress,
.billing-ocr-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.billing-ocr-panel__head h3,
.billing-ocr-review__intro h4 {
  margin: 4px 0;
}

.billing-ocr-panel__head p,
.billing-ocr-panel__action p,
.billing-ocr-review__intro p {
  margin: 0;
  color: var(--muted);
}

.billing-ocr-panel__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--teal);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.billing-ocr-panel__eyebrow svg {
  width: 16px;
  height: 16px;
}

.billing-ocr-panel__action {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.billing-ocr-status {
  white-space: nowrap;
}

.billing-ocr-status--pending,
.billing-ocr-status--processing {
  color: #086c94;
  background: #e7f7ff;
}

.billing-ocr-status--completed {
  color: #8a5c00;
  background: #fff5d9;
}

.billing-ocr-status--applied {
  color: #13734d;
  background: #e5f7ee;
}

.billing-ocr-status--dismissed {
  color: #536477;
  background: #edf2f5;
}

.billing-ocr-status--failed {
  color: #a33c32;
  background: #fff0ed;
}

.billing-ocr-progress,
.billing-ocr-error {
  justify-content: flex-start;
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: color-mix(in srgb, #e7f7ff 82%, #fff);
}

.billing-ocr-progress small,
.billing-ocr-applied small,
.billing-ocr-dismissed small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.billing-ocr-progress__spinner {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 3px solid color-mix(in srgb, var(--teal) 18%, #fff);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: billing-ocr-spin .9s linear infinite;
}

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

.billing-ocr-error {
  flex-wrap: wrap;
  background: #fff3f1;
}

.billing-ocr-error p {
  flex: 1 1 320px;
  margin: 0;
  color: #86372f;
}

.billing-ocr-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 15px 0;
}

.billing-ocr-meta span {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--soft) 54%, #fff);
}

.billing-ocr-meta strong,
.billing-ocr-meta small {
  display: block;
}

.billing-ocr-meta strong {
  overflow: hidden;
  font-size: .88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.billing-ocr-meta small {
  margin-top: 3px;
  color: var(--muted);
  font-size: .7rem;
}

.billing-ocr-warnings {
  margin: 12px 0;
  padding: 10px 12px 10px 30px;
  border-radius: 10px;
  color: #775300;
  background: #fff8e5;
  font-size: .8rem;
}

.billing-payment-evidence {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--teal) 28%, var(--line));
  border-radius: 11px;
  color: var(--dark);
  background: color-mix(in srgb, var(--mint) 45%, #fff);
}

.billing-payment-evidence > svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  color: var(--teal);
}

.billing-payment-evidence p,
.billing-payment-evidence small {
  margin: 2px 0 0;
}

.billing-payment-evidence p {
  font-weight: 750;
}

.billing-payment-evidence small {
  display: block;
  color: var(--muted);
}

.billing-ocr-review {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.billing-ocr-review__intro > span {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--teal);
  background: color-mix(in srgb, var(--mint) 70%, #fff);
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}

.billing-ocr-fields {
  margin-top: 13px;
}

.billing-ocr-fields label {
  position: relative;
}

.billing-ocr-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
  min-height: 1.3em;
}

.billing-ocr-ai-helper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 13px 0;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--teal) 25%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--mint) 38%, transparent);
}

.billing-ocr-ai-helper strong,
.billing-ocr-ai-helper small {
  display: block;
}

.billing-ocr-ai-helper small {
  margin-top: 3px;
  color: var(--muted);
}

.billing-ocr-ai-log {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--soft) 28%, transparent);
}

.billing-ocr-ai-log__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 10px 0;
  color: var(--muted);
  font-size: .78rem;
}

.billing-ocr-ai-log__error {
  color: var(--danger, #a33b32);
  font-weight: 750;
}

.billing-ocr-ai-log label {
  display: block;
  margin-top: 10px;
}

.billing-ocr-ai-log pre {
  max-height: 260px;
  margin: 5px 0 0;
  padding: 9px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 7%, var(--surface));
  font-size: .72rem;
}

.billing-ocr-lines-preview {
  margin-top: 16px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--teal) 22%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--soft) 45%, transparent);
}

.billing-ocr-lines-preview .table-wrap {
  margin: 9px -4px;
}

.billing-ocr-lines-preview table {
  width: 100%;
}

.billing-ocr-lines-preview small {
  display: block;
  color: var(--muted);
}

.billing-ocr-lines-editor__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.billing-ocr-lines-editor__head strong,
.billing-ocr-lines-editor__head small {
  display: block;
}

.billing-ocr-lines-editor__head small {
  max-width: 680px;
  margin-top: 3px;
}

.billing-ocr-lines-editor table {
  min-width: 1030px;
}

.billing-ocr-lines-editor td {
  vertical-align: middle;
}

.billing-ocr-lines-editor td:first-child {
  min-width: 230px;
}

.billing-ocr-lines-editor td:nth-child(2) {
  min-width: 135px;
}

.billing-ocr-lines-editor td:nth-child(n+3):nth-child(-n+7) {
  min-width: 96px;
}

.billing-ocr-lines-editor input,
.billing-ocr-lines-editor select {
  min-width: 0;
}

.billing-ocr-lines-editor output {
  display: inline-block;
  min-width: 74px;
  color: var(--dark);
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
}

.billing-ocr-lines-editor__summary {
  margin: 10px 0 4px;
  color: var(--teal);
  font-size: .78rem;
  font-weight: 750;
}

.billing-ocr-lines-editor__summary.is-warning {
  color: var(--danger, #a33b32);
}

.billing-ocr-error-dialog {
  width: min(540px, calc(100vw - 32px));
  margin: auto;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--danger, #a33b32) 38%, var(--line));
  border-radius: 18px;
  color: var(--dark);
  background: var(--surface, #fff);
  box-shadow: 0 24px 80px rgba(15, 36, 55, .28);
}

.billing-ocr-error-dialog::backdrop {
  background: rgba(10, 25, 31, .58);
  backdrop-filter: blur(3px);
}

.billing-ocr-error-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.billing-ocr-error-dialog h3 {
  margin: 3px 0 0;
  font-size: 1.1rem;
}

.billing-ocr-error-dialog__eyebrow {
  color: var(--danger, #a33b32);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.billing-ocr-error-dialog__close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--danger, #a33b32);
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.billing-ocr-error-dialog > p {
  margin: 16px 0 7px;
  color: var(--danger, #a33b32);
  font-weight: 750;
}

.billing-ocr-error-dialog > small {
  display: block;
  color: var(--muted);
}

.billing-ocr-error-dialog .actions {
  margin-top: 18px;
}

.ocr-confidence {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: auto;
  justify-self: start;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 800;
}

.ocr-confidence--high {
  color: #14734e;
  background: #e4f7ed;
}

.ocr-confidence--medium {
  color: #876000;
  background: #fff3ce;
}

.ocr-confidence--low {
  color: #9d4137;
  background: #ffebe8;
}

.billing-ocr-applied {
  justify-content: flex-start;
  margin-top: 14px;
  padding: 12px;
  border-radius: 11px;
  color: #126747;
  background: #e8f7ef;
}

.billing-ocr-applied > svg {
  width: 22px;
  height: 22px;
}

.billing-ocr-dismissed {
  justify-content: flex-start;
  margin-top: 14px;
  padding: 12px;
  border-radius: 11px;
  color: #536477;
  background: #edf2f5;
}

.billing-ocr-dismissed > svg {
  width: 22px;
  height: 22px;
}

.billing-ocr-dismiss-form {
  margin-top: 10px;
}

.billing-ocr-text {
  margin-top: 13px;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}

.billing-ocr-text summary {
  color: var(--teal);
  cursor: pointer;
  font-size: .78rem;
  font-weight: 800;
}

.billing-ocr-text pre {
  max-height: 280px;
  margin: 10px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--dark);
  background: color-mix(in srgb, var(--soft) 58%, #fff);
  font: 500 .74rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.billing-ocr-repeat {
  margin-top: 11px;
}

.billing-ocr-panel--compact {
  padding: 12px 14px;
}

.billing-ocr-panel--compact .billing-ocr-applied {
  margin-top: 0;
  padding: 0;
  background: transparent;
}

.billing-ocr-panel--compact .billing-ocr-dismissed {
  margin-top: 0;
  padding: 0;
  background: transparent;
}

.billing-ocr-panel--compact .billing-ocr-repeat {
  margin-top: 0;
  margin-left: auto;
}

.billing-reference-summary h3 {
  margin: 0 0 11px;
}

.billing-reference-summary__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.billing-reference-summary__head h3 {
  margin-bottom: 4px;
}

.billing-reference-summary__head p {
  max-width: 68ch;
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.billing-reference-summary__count {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--teal) 26%, var(--line));
  border-radius: 8px;
  color: var(--teal);
  font-size: .74rem;
  font-weight: 800;
  white-space: nowrap;
}

.billing-reference-summary__items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.billing-reference-summary__entry {
  display: flex;
  min-width: min(290px, 100%);
  max-width: 100%;
  flex: 1 1 330px;
  align-items: stretch;
  gap: 8px;
}

.billing-reference-summary__item {
  display: inline-flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--teal) 28%, var(--line));
  border-radius: 10px;
  background: #fff;
  font-size: .78rem;
}

.billing-reference-summary__item small {
  color: var(--muted);
}

.billing-reference-summary__inferred {
  color: var(--teal) !important;
  font-weight: 700;
}

.billing-reference-summary__item--link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.billing-reference-summary__item--link:hover,
.billing-reference-summary__item--link:focus-visible {
  border-color: var(--teal);
  background: color-mix(in srgb, var(--soft) 70%, #fff);
  transform: translateY(-1px);
}

.billing-reference-summary__unlink {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.billing-reference-summary__unlink .btn,
.billing-line-destination .btn {
  min-height: 34px;
  padding: 6px 9px;
  font-size: .72rem;
  white-space: nowrap;
}

.billing-line-destinations {
  display: grid;
  gap: 7px;
}

.billing-line-destination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.billing-line-destination > span {
  min-width: 0;
}

.billing-line-destination__link {
  min-width: 0;
  padding: 0;
  border: 0;
  color: var(--teal);
  background: transparent;
  font: inherit;
  font-weight: 750;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--teal) 42%, transparent);
  text-underline-offset: 3px;
  cursor: pointer;
}

.billing-line-destination__link:hover,
.billing-line-destination__link:focus-visible {
  color: var(--text);
  text-decoration-color: currentColor;
}

.billing-reference-dialog {
  width: min(640px, calc(100vw - 24px));
  max-width: 640px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(8, 29, 35, .34);
}

.billing-reference-dialog::backdrop {
  background: rgba(5, 22, 28, .68);
  backdrop-filter: blur(3px);
}

.billing-reference-dialog__panel {
  position: relative;
  padding: 28px;
}

.billing-reference-dialog__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.billing-reference-dialog__close:hover,
.billing-reference-dialog__close:focus-visible {
  color: var(--text);
  border-color: var(--teal);
}

.billing-reference-dialog__eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.billing-reference-dialog h2 {
  max-width: calc(100% - 42px);
  margin: 0;
  font-size: clamp(1.25rem, 2.6vw, 1.65rem);
}

.billing-reference-dialog__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
  gap: 12px;
  margin-top: 22px;
}

.billing-reference-dialog__body > div {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--soft) 72%, transparent);
}

.billing-reference-dialog__body span {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 750;
  text-transform: uppercase;
}

.billing-reference-dialog__body strong {
  overflow-wrap: anywhere;
}

.billing-reference-dialog__help {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.billing-reference-dialog__actions {
  margin-top: 22px;
}

html[data-gestfel-theme="dark"] .billing-reference-dialog {
  color: var(--gf-text, #eefaf7);
  background: var(--gf-panel, #132b39);
}

html[data-gestfel-theme="dark"] .billing-reference-dialog__body > div {
  background: color-mix(in srgb, var(--gf-surface, #0d2732) 76%, transparent);
}

@media (max-width: 540px) {
  .billing-reference-dialog__panel {
    padding: 24px 18px 18px;
  }

  .billing-reference-dialog__body {
    grid-template-columns: 1fr;
  }

  .billing-reference-dialog__actions,
  .billing-reference-dialog__actions .btn {
    width: 100%;
  }
}

.is-reference-target {
  scroll-margin-top: 105px;
  outline: 4px solid color-mix(in srgb, var(--teal) 78%, #fff);
  outline-offset: 5px;
  background: color-mix(in srgb, var(--teal) 13%, var(--soft)) !important;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--teal) 15%, transparent), 0 10px 28px color-mix(in srgb, var(--teal) 24%, transparent);
  animation: reference-target-pulse 2.4s ease-out;
}

@keyframes reference-target-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--teal) 0%, transparent); }
  35% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--teal) 28%, transparent), 0 10px 30px color-mix(in srgb, var(--teal) 28%, transparent); }
}

.billing-detail-lines {
  margin-top: 12px;
}

.billing-detail-lines .table-wrap {
  margin-top: 10px;
}

.billing-detail-lines__help {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}

.billing-detail-total {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding-top: 14px;
  color: var(--muted);
}

.billing-detail-total strong {
  color: var(--dark);
  font-size: 1.1rem;
}

.badge-borrador {
  color: #684f00;
  background: #fff3c4;
}

.badge-contabilizada {
  color: #185b8d;
  background: #e8f4ff;
}

.badge-pagada {
  color: #17643b;
  background: #dcf7e7;
}

.badge-anulada {
  color: #8a3131;
  background: #fde8e6;
}

/* LoraCat */

.loracat-demo-notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 14px;
  padding: 13px 16px;
  border: 1px solid #d9ad49;
  border-radius: 14px;
  color: #5e470d;
  background: #fff6d9;
}

.loracat-demo-notice .app-icon { flex: 0 0 auto; color: #9b7000; }

.loracat-filter-panel {
  margin-bottom: 16px;
  border: 2px solid color-mix(in srgb, var(--teal) 28%, var(--line));
  border-radius: 15px;
  background: var(--surface, #fff);
  box-shadow: 0 10px 30px rgba(15, 36, 55, .08);
}

.loracat-filter-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 68px;
  box-sizing: border-box;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  color: var(--dark);
  background: color-mix(in srgb, var(--mint) 28%, var(--surface, #fff));
  font-weight: 800;
}

.loracat-filter-panel > summary::-webkit-details-marker { display: none; }

.loracat-filter-panel > summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 48%, transparent);
  outline-offset: -4px;
}

.loracat-filter-panel > summary::after {
  content: '⌄';
  color: var(--teal);
  font-size: 1.45rem;
  line-height: 1;
  transition: transform .18s ease;
}

.loracat-filter-panel[open] > summary {
  border-radius: 13px 13px 0 0;
  background: color-mix(in srgb, var(--mint) 44%, var(--surface, #fff));
}

.loracat-filter-panel[open] > summary::after { transform: rotate(180deg); }

.loracat-filter-panel > summary > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: .98rem;
}

.loracat-filter-panel > summary .app-icon {
  width: 18px;
  height: 18px;
  color: var(--teal);
}

.loracat-filter-panel > summary small {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
}

.loracat-filter-panel .module-filterbar {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 15px 15px;
  box-shadow: none;
}
.loracat-demo-notice strong { display: block; margin-bottom: 3px; }
.loracat-demo-notice p { margin: 0; line-height: 1.45; }

html[data-gestfel-theme="dark"] .loracat-demo-notice {
  color: #fff3c0;
  background: color-mix(in srgb, #9b7000 20%, var(--gf-panel, #132b39));
  border-color: #d9ad49;
}

html[data-gestfel-theme="dark"] .loracat-demo-notice .app-icon { color: #ffd875; }

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

.loracat-dashboard > .card {
  min-width: 0;
  padding: 16px;
}

.loracat-heatmap {
  grid-column: span 5;
}

.loracat-flow-chart {
  grid-column: span 4;
}

.loracat-alerts {
  grid-column: span 3;
  grid-row: span 2;
}

.loracat-presence {
  grid-column: span 6;
}

.loracat-devices {
  grid-column: span 3;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: 30px repeat(24, minmax(0, 1fr));
  gap: 3px;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.loracat-heatmap {
  overflow: hidden;
}

.heatmap-grid strong,
.heatmap-hour {
  color: var(--muted);
  font-size: .65rem;
  font-weight: 650;
  text-align: center;
}

.heatmap-cell {
  display: block;
  aspect-ratio: 1;
  min-height: 10px;
  border-radius: 2px;
  background: #edf2f1;
}

.heatmap-cell--1 {
  background: #dcefdc;
}

.heatmap-cell--2 {
  background: #aadfca;
}

.heatmap-cell--3 {
  background: #67c5b5;
}

.heatmap-cell--4 {
  background: #279e99;
}

.heatmap-cell--5 {
  background: #176d83;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 12px;
  color: var(--muted);
  font-size: .68rem;
}

.heatmap-legend i {
  width: 17px;
  height: 10px;
  border-radius: 2px;
}

.loracat-chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 3px;
  font-size: .76rem;
}

.loracat-chart-legend span::before {
  display: inline-block;
  width: 12px;
  height: 3px;
  margin-right: 5px;
  border-radius: 4px;
  content: "";
  vertical-align: middle;
}

.loracat-chart-legend .is-entry::before {
  background: #2ca968;
}

.loracat-chart-legend .is-exit::before {
  background: #078c98;
}

.loracat-flow-chart svg {
  display: block;
  width: 100%;
  min-height: 180px;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-line--entry {
  stroke: #2ca968;
}

.chart-line--exit {
  stroke: #078c98;
}

.loracat-flow-chart text {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
}

.loracat-flow-chart .chart-axis-label {
  text-anchor: end;
  font-size: 10px;
}

.loracat-alert-list,
.loracat-device-list {
  display: grid;
  gap: 8px;
}

.loracat-alert {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.loracat-alert > span {
  color: #d97706;
}

.loracat-alert--critica > span {
  color: #cc4538;
}

.loracat-alert--info > span {
  color: #247bc1;
}

.loracat-alert .app-icon {
  width: 21px;
  height: 21px;
}

.loracat-alert strong,
.loracat-alert p,
.loracat-alert time {
  display: block;
  margin: 0;
}

.loracat-alert p {
  margin: 3px 0 5px;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.35;
}

.loracat-alert time {
  color: var(--muted);
  font-size: .67rem;
}

.loracat-alert form button {
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--teal);
  border: 1px solid var(--line);
  background: #fff;
}

.presence-axis {
  display: flex;
  justify-content: space-between;
  margin: 0 0 7px 145px;
  color: var(--muted);
  font-size: .68rem;
}

.loracat-presence-head {
  align-items: flex-start;
}

.loracat-presence-day {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
}

.loracat-presence-day label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 750;
}

.loracat-presence-day select {
  min-width: 118px;
}

.presence-row {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  margin: 9px 0;
}

.presence-cat,
.loracat-cat-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.presence-cat img,
.loracat-cat-cell img {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.presence-cat strong {
  overflow: hidden;
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-track {
  position: relative;
  display: block;
  height: 12px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 24.7%, var(--line) 25%, transparent 25.3%, transparent 49.7%, var(--line) 50%, transparent 50.3%, transparent 74.7%, var(--line) 75%, transparent 75.3%),
    #edf2f1;
}

.presence-track i {
  position: absolute;
  top: 2px;
  height: 8px;
  border-radius: 7px;
  background: #31a75d;
  cursor: help;
  outline: 0;
}

.presence-track i::after {
  position: absolute;
  z-index: 3;
  bottom: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: 190px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--teal) 28%, var(--line));
  border-radius: 8px;
  color: var(--dark);
  background: var(--surface, #fff);
  box-shadow: 0 8px 22px rgba(15, 36, 55, .16);
  content: attr(data-presence-tooltip);
  font-size: .72rem;
  font-style: normal;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity .15s ease, transform .15s ease;
  white-space: nowrap;
}

.presence-track i:hover::after,
.presence-track i:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.loracat-device-list article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.loracat-device-list article:last-child {
  border-bottom: 0;
}

.device-signal {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  color: var(--teal);
  border-radius: 10px;
  background: var(--mint);
}

.device-signal--inactivo {
  color: var(--muted);
  background: #edf0f0;
}

.device-signal--mantenimiento {
  color: #a66300;
  background: #fff1d3;
}

.device-signal .app-icon {
  width: 21px;
  height: 21px;
}

.loracat-device-list strong,
.loracat-device-list small,
.device-readings span {
  display: block;
}

.loracat-device-list small,
.device-readings {
  color: var(--muted);
  font-size: .68rem;
}

.device-readings {
  text-align: right;
}

.loracat-algorithm p {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.loracat-alerts .loracat-algorithm {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.loracat-alerts .loracat-algorithm h2 {
  font-size: 1rem;
}

.loracat-algorithm dl {
  margin: 12px 0 0;
}

.loracat-algorithm dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: .75rem;
}

.loracat-algorithm dt {
  color: var(--muted);
}

.loracat-algorithm dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.loracat-events {
  margin-bottom: 16px;
}

.loracat-events__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.loracat-events__summary::-webkit-details-marker {
  display: none;
}

.loracat-events__summary::after {
  flex: 0 0 auto;
  color: var(--teal);
  content: '⌄';
  font-size: 1.35rem;
  line-height: 1;
  transition: transform .18s ease;
}

.loracat-events[open] .loracat-events__summary::after {
  transform: rotate(180deg);
}

.loracat-events__summary > span:first-child {
  display: grid;
  gap: 3px;
}

.loracat-events__summary strong {
  color: var(--dark);
  font-size: 1.15rem;
}

html[data-gestfel-theme="dark"] .loracat-events__summary strong {
  color: var(--gf-text, #eefaf7);
}

.loracat-events__summary small,
.loracat-events__count {
  color: var(--muted);
  font-size: .76rem;
}

.loracat-events__count {
  margin-left: auto;
  white-space: nowrap;
}

.loracat-events__body {
  margin-top: 14px;
}

.loracat-events .table {
  font-size: .82rem;
}

.loracat-device-dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 17px;
  color: var(--dark);
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 36, 55, .22);
}

.loracat-device-dialog::backdrop {
  background: rgba(15, 36, 55, .48);
}

.loracat-device-dialog form {
  padding: 20px;
}

html[data-gestfel-theme="dark"] .module-filterbar,
html[data-gestfel-theme="dark"] .module-kpis article,
html[data-gestfel-theme="dark"] .billing-line,
html[data-gestfel-theme="dark"] .billing-advanced-lines,
html[data-gestfel-theme="dark"] .billing-ocr-panel,
html[data-gestfel-theme="dark"] .billing-payment-evidence,
html[data-gestfel-theme="dark"] .billing-reference-summary,
html[data-gestfel-theme="dark"] .billing-reference-summary__item,
html[data-gestfel-theme="dark"] .billing-ocr-error-dialog,
html[data-gestfel-theme="dark"] .loracat-device-dialog {
  color: var(--gf-text, #eefaf7);
  background: var(--gf-panel, var(--surface, #132b39));
}

html[data-gestfel-theme="dark"] .billing-workflow-note {
  color: var(--gf-text, #eefaf7);
  border-color: var(--gf-line, rgba(157, 204, 197, .34));
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 10%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .billing-workflow-note a {
  color: var(--gf-accent, #72d5c1);
}

html[data-gestfel-theme="dark"] .billing-document-missing,
html[data-gestfel-theme="dark"] .billing-document-missing-note {
  color: #f0c28d;
  border-color: rgba(240, 194, 141, .52);
  background: rgba(157, 91, 28, .22);
}

html[data-gestfel-theme="dark"] .billing-document-missing-note svg,
html[data-gestfel-theme="dark"] .billing-document-missing-note .app-illustrated-icon,
html[data-gestfel-theme="dark"] .billing-document-missing-note .app-generated-icon {
  color: #f0c28d;
}

html[data-gestfel-theme="dark"] .billing-pdf-ocr-choice {
  color: var(--gf-muted, #b7cbc7);
}

@media (max-width: 720px) {
  .billing-pdf-actions,
  .billing-pdf-actions .btn {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .billing-document-missing-note svg,
  .billing-document-missing-note .app-illustrated-icon,
  .billing-document-missing-note .app-generated-icon {
    width: 44px;
    height: 44px;
  }
}

html[data-gestfel-theme="dark"] .billing-reference-summary__count {
  color: var(--gf-text, #eefaf7);
  border-color: var(--gf-line, rgba(157, 204, 197, .34));
}

html[data-gestfel-theme="dark"] .billing-reference-summary__item--link:hover,
html[data-gestfel-theme="dark"] .billing-reference-summary__item--link:focus-visible {
  color: var(--gf-text, #eefaf7) !important;
  background: color-mix(in srgb, var(--gf-accent, #69d8ca) 13%, var(--gf-panel, #132b39)) !important;
  border-color: var(--gf-accent, #69d8ca);
}

html[data-gestfel-theme="dark"] .billing-reference-summary__item--link:hover small,
html[data-gestfel-theme="dark"] .billing-reference-summary__item--link:focus-visible small {
  color: var(--gf-muted, #b7cbc7);
}

html[data-gestfel-theme="dark"] .module-filterbar label,
html[data-gestfel-theme="dark"] .module-kpis strong,
html[data-gestfel-theme="dark"] .billing-line label,
html[data-gestfel-theme="dark"] .billing-live-total strong,
html[data-gestfel-theme="dark"] .billing-detail-total strong,
html[data-gestfel-theme="dark"] .loracat-device-dialog label,
html[data-gestfel-theme="dark"] .loracat-device-dialog h2 {
  color: var(--gf-text, #eefaf7);
}

html[data-gestfel-theme="dark"] .module-kpis small,
html[data-gestfel-theme="dark"] .module-kpis em,
html[data-gestfel-theme="dark"] .billing-live-total span,
html[data-gestfel-theme="dark"] .billing-detail-total {
  color: var(--gf-muted, #a7bdb8);
}

html[data-gestfel-theme="dark"] .module-hero__icon {
  background: color-mix(in srgb, var(--teal) 18%, var(--surface, #132b39));
}

html[data-gestfel-theme="dark"] .billing-pdf-field {
  background: color-mix(in srgb, var(--teal) 12%, var(--surface, #132b39));
}

html[data-gestfel-theme="dark"] .billing-draft-wizard {
  border-color: color-mix(in srgb, var(--gf-accent, #72d5c1) 42%, var(--gf-line, rgba(157, 204, 197, .34)));
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 10%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .billing-draft-wizard__intro strong,
html[data-gestfel-theme="dark"] .billing-draft-wizard__step.is-active {
  color: var(--gf-text, #eefaf7);
}

html[data-gestfel-theme="dark"] .billing-draft-wizard__step {
  border-color: var(--gf-line, rgba(157, 204, 197, .34));
  background: color-mix(in srgb, var(--gf-panel, #132b39) 78%, #08161c);
}

html[data-gestfel-theme="dark"] .billing-draft-wizard__step.is-active {
  border-color: var(--gf-accent, #72d5c1);
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 13%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .billing-ocr-ai-helper {
  color: var(--gf-text, #eefaf7);
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 10%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .billing-ocr-ai-helper small {
  color: var(--gf-muted, #b7cbc7);
}

html[data-gestfel-theme="dark"] .billing-ocr-panel--compact .billing-ocr-applied {
  color: var(--gf-accent, #72d5c1);
}

html[data-gestfel-theme="dark"] .billing-ocr-panel--compact .billing-ocr-applied small {
  color: var(--gf-muted, #b7cbc7);
}

html[data-gestfel-theme="dark"] .billing-ocr-panel--compact .billing-ocr-dismissed {
  color: var(--gf-accent, #72d5c1);
}

html[data-gestfel-theme="dark"] .billing-ocr-panel--compact .billing-ocr-dismissed small {
  color: var(--gf-muted, #b7cbc7);
}

html[data-gestfel-theme="dark"] .billing-assignment-guide {
  border-color: var(--gf-line-strong, rgba(157, 204, 197, .38));
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 10%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .billing-assignment-guide strong,
html[data-gestfel-theme="dark"] .billing-reference-editor__concept-note {
  color: var(--gf-text, #eefaf7);
}

html[data-gestfel-theme="dark"] .billing-line__existing-event,
html[data-gestfel-theme="dark"] .billing-line__target,
html[data-gestfel-theme="dark"] .billing-line__new-event {
  background: color-mix(in srgb, var(--teal) 10%, var(--surface, #132b39));
}

/* El selector múltiple tiene superficie propia. No debe heredar el texto
   claro de .billing-line label sobre el fondo claro de los controles nativos. */
html[data-gestfel-theme="dark"] .billing-line__multi-picker {
  border-color: var(--gf-line-strong, rgba(157, 204, 197, .5));
  background: var(--gf-panel, #132b39);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .16);
}

html[data-gestfel-theme="dark"] .billing-line__multi-picker > summary {
  color: var(--gf-text, #eefaf7);
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 8%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .billing-line__multi-picker > summary::after {
  color: var(--gf-accent, #72d5c1);
}

html[data-gestfel-theme="dark"] .billing-line__multi-picker[open] > summary {
  border-bottom-color: var(--gf-line, rgba(157, 204, 197, .34));
}

html[data-gestfel-theme="dark"] .billing-line__multi-picker-panel {
  background: var(--gf-panel, #132b39);
}

html[data-gestfel-theme="dark"] .billing-line .billing-line__multi-picker-panel input[type="search"] {
  color: var(--gf-text, #eefaf7) !important;
  border-color: var(--gf-line-strong, rgba(157, 204, 197, .5)) !important;
  background: #0d232c !important;
}

html[data-gestfel-theme="dark"] .billing-line .billing-line__multi-picker-panel input[type="search"]::placeholder {
  color: var(--gf-muted, #b7cbc7) !important;
  opacity: 1;
}

html[data-gestfel-theme="dark"] .billing-line__multi-picker-options {
  border-color: var(--gf-line, rgba(157, 204, 197, .34));
  background: #0d232c;
}

html[data-gestfel-theme="dark"] .billing-line .billing-line__multi-picker-option {
  color: var(--gf-text, #eefaf7) !important;
  border-color: var(--gf-line, rgba(157, 204, 197, .28));
  background: #102a34;
}

html[data-gestfel-theme="dark"] .billing-line .billing-line__multi-picker-option:hover,
html[data-gestfel-theme="dark"] .billing-line .billing-line__multi-picker-option:focus-within {
  border-color: var(--gf-accent, #72d5c1);
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 17%, #102a34);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gf-accent, #72d5c1) 20%, transparent);
}

html[data-gestfel-theme="dark"] .billing-line .billing-line__multi-picker-option input {
  accent-color: var(--gf-accent, #72d5c1);
}

html[data-gestfel-theme="dark"] .billing-reference-editor {
  background: color-mix(in srgb, var(--gf-panel, #132b39) 88%, #08161c);
}

html[data-gestfel-theme="dark"] .billing-line__calculation,
html[data-gestfel-theme="dark"] .billing-totals-assistant {
  color: var(--gf-muted, #b7cbc7);
  border-color: var(--gf-line, rgba(157, 204, 197, .34));
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 8%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .billing-line__calculation.is-warning,
html[data-gestfel-theme="dark"] .billing-totals-assistant.is-warning {
  color: #f0c28d;
  border-color: rgba(240, 194, 141, .48);
  background: rgba(157, 91, 28, .22);
}

html[data-gestfel-theme="dark"] .billing-ocr-meta span,
html[data-gestfel-theme="dark"] .billing-ocr-text pre,
html[data-gestfel-theme="dark"] .billing-ocr-lines-preview small {
  color: var(--gf-text, #eefaf7);
  background: color-mix(in srgb, var(--teal) 8%, var(--surface, #132b39));
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-preview small {
  color: var(--gf-muted, #b7cbc7);
  background: transparent;
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor {
  color: var(--gf-text, #eefaf7);
  border-color: var(--gf-line-strong, rgba(157, 204, 197, .58));
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 8%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor__head strong {
  color: var(--gf-text, #eefaf7);
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor__head small,
html[data-gestfel-theme="dark"] .billing-ocr-lines-editor > small {
  color: var(--gf-muted, #b7cbc7);
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor .table-wrap {
  border-color: var(--gf-line, rgba(157, 204, 197, .34));
  background: #0d232c;
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor th {
  color: var(--gf-text, #eefaf7);
  background: #102a34;
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor td {
  border-color: var(--gf-line, rgba(157, 204, 197, .28));
  background: #10252d;
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor input,
html[data-gestfel-theme="dark"] .billing-ocr-lines-editor select {
  color: var(--gf-text, #eefaf7) !important;
  border-color: var(--gf-line-strong, rgba(157, 204, 197, .58)) !important;
  background: #0d232c !important;
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor .btn-outline {
  color: var(--gf-accent, #72d5c1) !important;
  border-color: var(--gf-accent, #72d5c1) !important;
  background: #0d232c !important;
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor .btn-outline:hover,
html[data-gestfel-theme="dark"] .billing-ocr-lines-editor .btn-outline:focus-visible {
  color: #08201f !important;
  border-color: var(--gf-accent, #72d5c1) !important;
  background: var(--gf-accent, #72d5c1) !important;
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor output {
  color: var(--gf-text, #eefaf7) !important;
  background: #10252d !important;
  border-color: var(--gf-line-strong, rgba(157, 204, 197, .58)) !important;
}

html[data-gestfel-theme="dark"] .vet-invoice-association {
  color: var(--gf-text, #eefaf7);
  background: var(--gf-panel, #132b39) !important;
  border-color: var(--gf-line-strong, rgba(157, 204, 197, .58)) !important;
}

html[data-gestfel-theme="dark"] .vet-invoice-association > summary {
  color: var(--gf-accent, #72d5c1);
}

html[data-gestfel-theme="dark"] .vet-invoice-association__body > label {
  color: var(--gf-text, #eefaf7);
}

html[data-gestfel-theme="dark"] .vet-invoice-association__body .field-help {
  color: var(--gf-muted, #b7cbc7);
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor td:nth-child(9) .btn.danger {
  color: #ffe9ed !important;
  background: #49242e !important;
  border-color: #e18a99 !important;
}

html[data-gestfel-theme="dark"] .billing-ocr-lines-editor td:nth-child(9) .btn.danger:hover,
html[data-gestfel-theme="dark"] .billing-ocr-lines-editor td:nth-child(9) .btn.danger:focus-visible {
  color: #fff8f9 !important;
  background: #6a2d3d !important;
  border-color: #ffafbb !important;
}

html[data-gestfel-theme="dark"] .billing-ocr-error-dialog {
  border-color: rgba(240, 194, 141, .48);
}

html[data-gestfel-theme="dark"] .billing-ocr-error-dialog > p,
html[data-gestfel-theme="dark"] .billing-ocr-error-dialog__eyebrow {
  color: #f0c28d;
}

html[data-gestfel-theme="dark"] .billing-ocr-error-dialog > small {
  color: var(--gf-muted, #b7cbc7);
}

@media (max-width: 820px) {
  .billing-reference-summary__head {
    flex-direction: column;
  }

  .billing-reference-summary__count {
    align-self: flex-start;
  }

  .billing-reference-summary__entry {
    flex-basis: 100%;
  }

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

  .billing-ocr-panel__head,
  .billing-ocr-panel__action,
  .billing-ocr-review__intro,
  .billing-ocr-dismissed,
  .billing-ocr-lines-editor__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .billing-ocr-lines-editor__head .btn {
    width: 100%;
  }

  .billing-ocr-lines-editor .table-wrap {
    margin: 10px 0;
    overflow: visible;
  }

  .billing-ocr-lines-editor table,
  .billing-ocr-lines-editor tbody {
    display: block;
    min-width: 0;
  }

  .billing-ocr-lines-editor thead {
    display: none;
  }

  .billing-ocr-lines-editor tr[data-billing-ocr-line] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: color-mix(in srgb, var(--soft) 48%, transparent);
  }

  .billing-ocr-lines-editor tr[data-billing-ocr-line]:first-child {
    margin-top: 0;
  }

  .billing-ocr-lines-editor td,
  .billing-ocr-lines-editor td:first-child,
  .billing-ocr-lines-editor td:nth-child(2),
  .billing-ocr-lines-editor td:nth-child(n+3):nth-child(-n+7) {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .billing-ocr-lines-editor td::before {
    display: block;
    margin: 0 0 4px;
    color: var(--muted);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
  }

  .billing-ocr-lines-editor td:nth-child(1),
  .billing-ocr-lines-editor td:nth-child(2),
  .billing-ocr-lines-editor td:nth-child(7) {
    grid-column: 1 / -1;
  }

  .billing-ocr-lines-editor td:nth-child(1)::before { content: 'Concepto'; }
  .billing-ocr-lines-editor td:nth-child(2)::before { content: 'Categoría'; }
  .billing-ocr-lines-editor td:nth-child(3)::before { content: 'Cantidad'; }
  .billing-ocr-lines-editor td:nth-child(4)::before { content: 'Precio'; }
  .billing-ocr-lines-editor td:nth-child(5)::before { content: 'Descuento'; }
  .billing-ocr-lines-editor td:nth-child(6)::before { content: 'IVA'; }
  .billing-ocr-lines-editor td:nth-child(7)::before { content: 'Precio e IVA'; }
  .billing-ocr-lines-editor td:nth-child(8)::before { content: 'Total calculado'; }
  .billing-ocr-lines-editor td:nth-child(9)::before { content: 'Acción'; }

  .billing-ocr-lines-editor td input,
  .billing-ocr-lines-editor td select,
  .billing-ocr-lines-editor td:nth-child(9) .btn {
    width: 100%;
  }

  .billing-ocr-lines-editor output {
    min-height: 2.65rem;
    padding: 8px 10px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface, #fff);
  }

  .billing-line__allocation-head {
    align-items: stretch;
    flex-direction: column;
  }

  .billing-line__allocation-head > label {
    min-width: 0;
  }
}

html[data-gestfel-theme="dark"] .billing-line__remove,
html[data-gestfel-theme="dark"] .loracat-alert form button {
  background: var(--surface, #132b39);
}

html[data-gestfel-theme="dark"] .loracat-alert,
html[data-gestfel-theme="dark"] .presence-track {
  background-color: color-mix(in srgb, var(--surface, #132b39) 76%, var(--line));
}

html[data-gestfel-theme="dark"] .loracat-filter-panel {
  border-color: color-mix(in srgb, var(--gf-accent, #72d5c1) 40%, var(--gf-line, rgba(157, 204, 197, .34)));
  background: var(--gf-panel, #132b39);
}

html[data-gestfel-theme="dark"] .loracat-filter-panel > summary {
  color: var(--gf-text, #eefaf7);
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 13%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .loracat-filter-panel[open] > summary {
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 21%, var(--gf-panel, #132b39));
}

html[data-gestfel-theme="dark"] .loracat-filter-panel > summary small {
  color: var(--gf-muted, #b7cbc7);
}

html[data-gestfel-theme="dark"] .presence-track i::after {
  color: var(--gf-text, #eefaf7);
  background: var(--gf-panel, #132b39);
  border-color: var(--gf-line, rgba(157, 204, 197, .24));
}

.invoice-reference-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  vertical-align: middle;
}

.invoice-reference-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 27px;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--teal) 38%, var(--line));
  border-radius: 999px;
  color: var(--teal);
  background: color-mix(in srgb, var(--mint) 68%, #fff);
  font-size: .72rem;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.invoice-reference-link span {
  opacity: .72;
  font-weight: 700;
}

.invoice-reference-link:hover,
.invoice-reference-link:focus-visible {
  border-color: var(--teal);
  color: var(--teal-strong, var(--teal));
  background: color-mix(in srgb, var(--mint) 48%, #fff);
}

.invoice-reference-links--missing {
  align-items: center;
  gap: 0;
}

.invoice-reference-missing {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, #b45309 42%, var(--line));
  border-radius: 8px;
  color: #92400e;
  background: #fff7ed;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.billing-delete-invoice__body {
  position: absolute;
  top: 1.8rem;
  right: 0;
  z-index: 2;
  width: min(360px, calc(100vw - 32px));
  padding: 15px;
  border: 1px solid color-mix(in srgb, #b42318 24%, var(--line));
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 61, 58, .18);
}

.billing-delete-invoice__body strong {
  color: #9f1239;
}

.billing-delete-invoice__body p {
  margin: 7px 0 12px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.billing-delete-invoice__body form {
  position: static;
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: block;
}

/* El disparador de borrado es un <summary>; se le da la misma geometría que a
   los demás botones de la cabecera para evitar el salto de línea y el marcador
   nativo del navegador. */
.billing-delete-invoice {
  flex: 0 0 auto;
  margin-left: 0;
}

.billing-delete-invoice > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  box-sizing: border-box;
  padding: .55rem .8rem;
  border: 1px solid color-mix(in srgb, #b42318 36%, var(--line));
  border-radius: 10px;
  color: #9f1239;
  background: color-mix(in srgb, #fff1f2 78%, #fff);
  font-size: .88rem;
  font-weight: 800;
  line-height: 1.2;
  list-style: none;
}

.billing-delete-invoice > summary::-webkit-details-marker {
  display: none;
}

.billing-delete-invoice > summary::marker {
  content: '';
}

.billing-delete-invoice > summary:hover,
.billing-delete-invoice > summary:focus-visible {
  border-color: #b42318;
  color: #fff;
  background: #b42318;
}

.billing-delete-invoice__body button {
  width: 100%;
  justify-content: center;
}

.clinical-case .invoice-reference-links,
.clinical-timeline-item .invoice-reference-links {
  display: flex;
}

html[data-gestfel-theme="dark"] .invoice-reference-link {
  color: var(--gf-accent, #72d5c1);
  border-color: color-mix(in srgb, var(--gf-accent, #72d5c1) 42%, var(--line));
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 12%, var(--surface, #132b39));
}

html[data-gestfel-theme="dark"] .invoice-reference-link:hover,
html[data-gestfel-theme="dark"] .invoice-reference-link:focus-visible {
  color: var(--gf-text, #eefaf7);
  border-color: var(--gf-accent, #72d5c1);
  background: color-mix(in srgb, var(--gf-accent, #72d5c1) 19%, var(--surface, #132b39));
}

html[data-gestfel-theme="dark"] .invoice-reference-missing,
html[data-gestfel-theme="dark"] .billing-delete-invoice__body {
  color: var(--gf-text, #eefaf7);
  background: color-mix(in srgb, #b45309 12%, var(--surface, #132b39));
}

html[data-gestfel-theme="dark"] .invoice-reference-missing {
  border-color: color-mix(in srgb, #f59e0b 46%, var(--line));
  color: #fbbf24;
}

html[data-gestfel-theme="dark"] .billing-delete-invoice__body strong {
  color: #fda4af;
}

html[data-gestfel-theme="dark"] .billing-delete-invoice > summary {
  border-color: rgba(253, 164, 175, .42);
  color: #fda4af;
  background: rgba(159, 18, 57, .2);
}

html[data-gestfel-theme="dark"] .billing-delete-invoice > summary:hover,
html[data-gestfel-theme="dark"] .billing-delete-invoice > summary:focus-visible {
  border-color: #fb7185;
  color: #fff;
  background: #be123c;
}

@media (max-width: 1180px) {
  .module-filterbar {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .billing-filters {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .billing-filters .module-filterbar__grow {
    grid-column: span 2;
  }

  .loracat-heatmap,
  .loracat-flow-chart,
  .loracat-presence {
    grid-column: span 8;
  }

  .loracat-alerts,
  .loracat-devices {
    grid-column: span 4;
    grid-row: auto;
  }

  .billing-line__main {
    grid-template-columns: repeat(4, minmax(110px, 1fr)) 36px;
  }

  .billing-line__description {
    grid-column: span 2;
  }
}

@media (max-width: 820px) {
  .module-hero {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .module-hero__actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

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

  .module-filterbar__grow {
    grid-column: auto;
  }

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

  .loracat-dashboard > .card {
    grid-column: 1 / -1;
  }

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

  .billing-line__description {
    grid-column: 1 / -2;
  }

  .billing-live-total,
  .billing-detail-total {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 780px) {
  .billing-detail .card-head > .actions {
    width: 100%;
  }

  .billing-delete-invoice {
    width: 100%;
  }

  .billing-delete-invoice > summary {
    display: flex;
    width: 100%;
  }

  .billing-delete-invoice__body {
    position: static;
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
  }
}

@media (max-width: 540px) {
  .billing-draft-wizard ol {
    grid-template-columns: 1fr;
  }

  .billing-draft-wizard__step strong,
  .billing-draft-wizard__step small {
    white-space: normal;
  }

  .billing-reference-summary__entry,
  .billing-line-destination {
    align-items: stretch;
    flex-direction: column;
  }

  .billing-reference-summary__unlink,
  .billing-reference-summary__unlink .btn,
  .billing-line-destination form,
  .billing-line-destination .btn {
    width: 100%;
  }

  .module-hero {
    grid-template-columns: 1fr;
  }

  .module-hero__icon {
    width: 48px;
    height: 48px;
  }

  .module-filterbar,
  .module-kpis,
  .billing-kpis,
  .billing-line__main {
    grid-template-columns: 1fr;
  }

  .module-filterbar .btn,
  .module-hero__actions .btn {
    width: 100%;
  }

  .module-kpis article {
    min-height: 94px;
  }

  .billing-line__description {
    grid-column: auto;
  }

  .billing-line__remove {
    width: 100%;
  }

  .billing-pdf-first {
    width: 100%;
  }

  .card-head,
  .billing-lines-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .presence-axis {
    margin-left: 0;
  }

  .loracat-presence-head {
    gap: 12px;
  }

  .loracat-presence-day,
  .loracat-presence-day label,
  .loracat-presence-day select {
    width: 100%;
  }

  .presence-row {
    grid-template-columns: 1fr;
  }

  .loracat-events__summary {
    align-items: flex-start;
  }

  .loracat-events__count {
    display: none;
  }
}

}
