:root {
  --bg: #0a0e0d;
  --panel: #161d1b;
  --panel-2: #202a26;
  --line: #3b4943;
  --text: #f7fbf8;
  --muted: #b8c5be;
  --brand: #b8f054;
  --brand-2: #75c94b;
  --danger: #ff6b6b;
  --warn: #f7c948;
  --ok: #61d394;
  --shadow: 0 20px 60px rgba(0, 0, 0, .28);
}

/* Pacientes 360 · hoja de vida gerencial 2026-08-24 */
.patients-section-head {
  align-items: flex-end;
  margin-bottom: 16px;
}

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

.patient-directory-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1.5fr) repeat(3, minmax(150px, .55fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.025);
}

.patient-directory-toolbar label {
  display: grid;
  gap: 5px;
  margin: 0;
}

.patient-directory-toolbar label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.patient-directory-toolbar input,
.patient-directory-toolbar select {
  min-height: 40px;
}

.patient-directory-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  min-height: 34px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.patient-directory-summary > strong { color: var(--text); font-size: 18px; }
.patient-directory-summary > span { padding-left: 12px; border-left: 1px solid var(--line); }

.patient-directory {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(7,15,11,.72);
}

.patient-directory-head,
.patient-directory-row {
  display: grid;
  grid-template-columns: 88px 56px minmax(190px, 1.4fr) minmax(140px, .9fr) 132px minmax(118px, .75fr) minmax(140px, .8fr) 24px;
  gap: 10px;
  align-items: center;
}

.patient-directory-head {
  min-height: 42px;
  padding: 0 14px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.patient-directory-list {
  max-height: calc(100vh - 350px);
  min-height: 260px;
  overflow: auto;
  scrollbar-width: thin;
}

.patient-directory-row {
  position: relative;
  width: 100%;
  min-height: 72px;
  padding: 10px 14px 10px 18px;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
  border-radius: 0;
  color: var(--text);
  background: transparent;
  box-shadow: none;
  text-align: left;
  transition: background .16s ease, transform .16s ease;
}

.patient-directory-row::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 0;
  width: 4px;
  border-radius: 0 6px 6px 0;
  background: #7d8a82;
}

.patient-directory-row:hover,
.patient-directory-row:focus-visible {
  background: rgba(255,255,255,.055);
  transform: none;
}

.patient-directory-row.is-active::before { background: #8ed94d; }
.patient-directory-row.has-alert::before { background: #ffbe4a; }
.patient-directory-row.is-inactive::before { background: #78909c; }
.patient-directory-row.is-offboarded::before { background: #ff5f69; }
.patient-directory-row.has-alert { background: linear-gradient(90deg, rgba(255,190,74,.055), transparent 36%); }
.patient-directory-row.has-doc-alert { background: linear-gradient(90deg, rgba(255,190,74,.035), transparent 32%); }
.patient-directory-row.has-doc-alert .patient-avatar { border-color: rgba(255,190,74,.72); box-shadow: 0 0 0 3px rgba(255,190,74,.08); }
.patient-directory-row.is-offboarded { opacity: .76; }

.patient-avatar,
.patient-dossier-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(185,255,102,.28);
  border-radius: 50%;
  color: var(--brand);
  background: rgba(185,255,102,.09);
  font-size: 13px;
  font-weight: 950;
}

.patient-avatar img,
.patient-dossier-avatar img { width: 100%; height: 100%; object-fit: cover; }
.patient-directory-code { color: var(--brand); font-size: 12px; font-weight: 900; }
.patient-directory-name { display: grid; gap: 3px; min-width: 0; }
.patient-directory-name strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.patient-directory-name small,
.patient-directory-date small { color: var(--muted); font-size: 10px; }
.patient-directory-category { color: #d6e2d9; font-size: 11px; font-weight: 800; }
.patient-directory-date { display: grid; gap: 3px; color: #d8e2db; font-size: 11px; }
.patient-directory-date small { display: none; }

.patient-directory-docs { display: grid; gap: 6px; }
.patient-directory-docs > span { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.patient-directory-docs b { color: var(--text); }
.patient-directory-docs > i,
.patient-doc-progress > i,
.patient-product-ranking span > i {
  display: block;
  overflow: hidden;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,.09);
}
.patient-directory-docs em,
.patient-doc-progress em,
.patient-product-ranking em { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #74b83b, var(--brand)); }
.patient-directory-open { color: var(--brand); font-size: 24px; text-align: right; }

.patient-directory-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px 6px 0;
  color: var(--muted);
  font-size: 10px;
}
.patient-directory-legend span { display: inline-flex; gap: 6px; align-items: center; }
.patient-directory-legend i { width: 8px; height: 8px; border-radius: 50%; background: #7d8a82; }
.patient-directory-legend i.is-active { background: #8ed94d; }
.patient-directory-legend i.has-alert { background: #ffbe4a; }
.patient-directory-legend i.is-inactive { background: #78909c; }
.patient-directory-legend i.is-offboarded { background: #ff5f69; }
.patient-directory-empty,
.patient-dossier-error { display: grid; place-items: center; gap: 8px; min-height: 260px; color: var(--muted); text-align: center; }
.patient-directory-empty strong,
.patient-dossier-error strong { color: var(--text); font-size: 18px; }

.patient-dossier-backdrop { padding: 10px; }
.patient-dossier {
  width: min(1240px, 100%);
  max-height: 96vh;
  padding: 0;
  border-radius: 24px;
  background: #101914;
}

.patient-dossier-hero {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 72px minmax(250px, 1fr) minmax(170px, auto) auto;
  gap: 14px;
  align-items: center;
  min-height: 112px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #16241b 0%, #101914 75%);
}
.patient-dossier-hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: #7d8a82; }
.patient-dossier-hero.is-active::before { background: #8ed94d; }
.patient-dossier-hero.has-alert::before { background: #ffbe4a; }
.patient-dossier-hero.is-offboarded::before { background: #ff5f69; }
.patient-dossier-avatar { width: 64px; height: 64px; font-size: 19px; }
.patient-dossier-identity { min-width: 0; }
.patient-dossier-identity p { margin: 0 0 4px; color: var(--brand); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.patient-dossier-identity h2 { margin: 0 0 5px; font-size: clamp(22px, 3vw, 32px); }
.patient-dossier-identity span,
.patient-dossier-hero-status small { color: var(--muted); font-size: 11px; }
.patient-dossier-hero-status { display: grid; gap: 6px; justify-items: start; }
.patient-dossier-hero-status > span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.patient-dossier-actions { display: flex; gap: 6px; align-items: center; }

.patient-dossier-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px 16px 0;
}
.patient-dossier-kpis article { display: grid; gap: 4px; min-height: 94px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.025); }
.patient-dossier-kpis article.warn { border-color: rgba(255,190,74,.34); background: rgba(255,190,74,.06); }
.patient-dossier-kpis span { color: var(--muted); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.patient-dossier-kpis strong { color: var(--brand); font-size: clamp(19px, 2.2vw, 27px); }
.patient-dossier-kpis small { color: var(--muted); font-size: 10px; }

.patient-dossier-main { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px 0; }
.patient-dossier-column { display: grid; gap: 12px; align-content: start; }
.patient-dossier-panel { padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.025); }
.patient-dossier-panel > header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.patient-dossier-panel > header h3 { margin: 1px 0 0; font-size: 15px; }
.patient-dossier-panel > header .eyebrow { margin: 0; font-size: 8px; }
.patient-dossier-panel > header > span,
.patient-dossier-panel > header > strong { color: var(--brand); font-size: 12px; }

.patient-opportunity-list,
.patient-product-ranking,
.patient-document-list,
.patient-timeline { display: grid; gap: 7px; }
.patient-opportunity { display: grid; grid-template-columns: 9px 1fr; gap: 9px; align-items: start; padding: 9px 10px; border-radius: 12px; background: rgba(255,255,255,.025); }
.patient-opportunity > i { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #7d8a82; }
.patient-opportunity.warn > i { background: #ffbe4a; }
.patient-opportunity.danger > i { background: #ff5f69; }
.patient-opportunity.ok > i { background: #8ed94d; }
.patient-opportunity div { display: grid; gap: 2px; }
.patient-opportunity strong { font-size: 11px; }
.patient-opportunity span { color: var(--muted); font-size: 10px; line-height: 1.4; }

.patient-profile-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.patient-profile-facts > div { min-width: 0; padding: 9px 10px; border: 1px solid rgba(255,255,255,.06); border-radius: 11px; background: rgba(255,255,255,.02); }
.patient-profile-facts dt { color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.patient-profile-facts dd { overflow: hidden; margin: 3px 0 0; color: var(--text); font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }

.patient-product-ranking > div { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; }
.patient-product-ranking > div > b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 7px; color: var(--brand); background: rgba(185,255,102,.08); font-size: 9px; }
.patient-product-ranking > div > span { display: grid; gap: 3px; }
.patient-product-ranking strong { font-size: 11px; }
.patient-product-ranking small { color: var(--muted); font-size: 9px; }
.patient-product-ranking span > i { height: 3px; }

.patient-recommendation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.patient-recommendation-grid > article { display: grid; gap: 4px; min-width: 0; padding: 10px; border: 1px solid rgba(185,255,102,.14); border-radius: 13px; background: linear-gradient(145deg, rgba(185,255,102,.055), rgba(255,255,255,.018)); }
.patient-recommendation-grid span { color: var(--brand); font-size: 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.patient-recommendation-grid strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.patient-recommendation-grid small { color: var(--muted); font-size: 8px; }
.patient-recommendation-grid b { font-size: 10px; }
.patient-recommendation-grid button { width: 100%; min-height: 30px; margin-top: 3px; }

.patient-doc-progress { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 10px; }
.patient-doc-progress span { color: var(--muted); font-size: 9px; }
.patient-review-controls,
.patient-document-upload { margin-top: 8px; border: 1px solid rgba(255,255,255,.07); border-radius: 12px; background: rgba(0,0,0,.12); }
.patient-review-controls summary,
.patient-document-upload summary { padding: 9px 10px; color: var(--brand); cursor: pointer; font-size: 10px; font-weight: 850; }
.patient-review-controls > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 10px 10px; }
.patient-review-controls label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; }
.patient-review-controls .full { grid-column: 1 / -1; }
.patient-review-controls select,
.patient-review-controls input { min-height: 34px; padding: 6px 8px; font-size: 10px; }
.patient-document-list { max-height: 205px; overflow: auto; margin-top: 10px; }
.patient-document-list a { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 9px; border: 1px solid rgba(255,255,255,.06); border-radius: 11px; color: var(--text); background: rgba(255,255,255,.018); text-decoration: none; }
.patient-document-list a > span { display: grid; gap: 2px; min-width: 0; }
.patient-document-list b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.patient-document-list small { overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.patient-document-list a > i { color: var(--brand); font-size: 9px; font-style: normal; }
.patient-document-upload form { padding: 0 10px 10px; }

.patient-reservation-list,
.patient-promotion-list { display: grid; gap: 7px; }
.patient-reservation-list > article { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 9px 10px; border: 1px solid rgba(255,255,255,.06); border-radius: 12px; background: rgba(255,255,255,.02); }
.patient-reservation-list > article > div { display: grid; gap: 3px; min-width: 0; }
.patient-reservation-list strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.patient-reservation-list small { color: var(--muted); font-size: 8px; }
.patient-reservation-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.patient-reservation-actions button { width: auto; min-height: 30px; padding: 5px 9px; font-size: 9px; }
.patient-reservation-create { margin-top: 8px; border: 1px solid rgba(185,255,102,.14); border-radius: 12px; background: rgba(185,255,102,.035); }
.patient-reservation-create summary { padding: 9px 10px; color: var(--brand); cursor: pointer; font-size: 10px; font-weight: 850; }
.patient-reservation-create form { padding: 0 10px 10px; }
.patient-promotion-list { grid-template-columns: 1fr 1fr; }
.patient-promotion-list > article { display: grid; gap: 4px; padding: 10px; border: 1px solid rgba(255,190,74,.15); border-radius: 12px; background: rgba(255,190,74,.035); }
.patient-promotion-list span { color: #ffd36a; font-size: 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.patient-promotion-list strong { font-size: 10px; }
.patient-promotion-list p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.patient-promotion-list small { color: #c7d2cb; font-size: 8px; }

.patient-timeline-panel { margin: 12px 16px 16px; }
.patient-timeline { grid-template-columns: 1fr 1fr; }
.patient-timeline-entry { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 5px; align-items: stretch; }
.patient-timeline-entry > button { display: grid; grid-template-columns: 72px 1fr auto 12px; gap: 8px; align-items: center; min-height: 54px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.06); border-radius: 12px; color: var(--text); background: rgba(255,255,255,.02); box-shadow: none; text-align: left; }
.patient-timeline-entry > a { display: grid; place-items: center; border: 1px solid rgba(185,255,102,.18); border-radius: 10px; color: var(--brand); background: rgba(185,255,102,.055); font-size: 9px; font-weight: 900; text-decoration: none; }
.patient-timeline-entry > a:hover { border-color: var(--brand); background: rgba(185,255,102,.1); }
.patient-timeline time { color: var(--brand); font-size: 9px; font-weight: 900; }
.patient-timeline-entry > button > span { display: grid; gap: 3px; min-width: 0; }
.patient-timeline-entry > button > span strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.patient-timeline-entry > button small { color: var(--muted); font-size: 8px; }
.patient-timeline-entry > button > b { font-size: 11px; }
.patient-timeline-entry > button > i { color: var(--brand); font-size: 18px; font-style: normal; }

.patient-dossier-loading { display: grid; place-items: center; gap: 12px; color: var(--text); }
.patient-dossier-loading span { width: 34px; height: 34px; border: 3px solid rgba(185,255,102,.18); border-top-color: var(--brand); border-radius: 50%; animation: patient-spin .8s linear infinite; }
@keyframes patient-spin { to { transform: rotate(360deg); } }

.patient-modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.patient-modal-head h2 { margin: 2px 0 5px; }
.patient-modal-head p { margin: 0; color: var(--muted); }
.patient-editor-card { width: min(900px, 100%); }
.patient-editor-form { grid-template-columns: 1fr 1fr; }
.patient-editor-actions { display: flex; justify-content: flex-end; gap: 8px; }
.patient-editor-actions button { width: auto; }
.danger-button { color: #ffc5c8; border-color: rgba(255,95,105,.32); background: rgba(255,95,105,.08); }

@media (max-width: 1100px) {
  .patient-directory-toolbar { grid-template-columns: 1fr 1fr 1fr; }
  .patient-directory-search { grid-column: span 2; }
  .patient-directory-head,
  .patient-directory-row { grid-template-columns: 78px 50px minmax(180px, 1.4fr) minmax(130px, .8fr) 120px minmax(110px, .7fr) 24px; }
  .patient-directory-head > span:nth-child(4),
  .patient-directory-row > .patient-directory-category { display: none; }
  .patient-dossier-hero { grid-template-columns: 64px 1fr auto; }
  .patient-dossier-hero-status { display: none; }
}

@media (max-width: 760px) {
  .patients-section-head { align-items: stretch; }
  .patients-head-actions { width: 100%; }
  .patients-head-actions button { flex: 1; }
  .patient-directory-toolbar { grid-template-columns: 1fr 1fr; }
  .patient-directory-search { grid-column: 1 / -1; }
  .patient-directory-toolbar > button { grid-column: 1 / -1; width: 100%; }
  .patient-directory-head { display: none; }
  .patient-directory-list { max-height: none; }
  .patient-directory-row { grid-template-columns: 44px 1fr auto; grid-template-areas: "photo name open" "code category status" "date date docs"; gap: 7px 10px; padding: 12px 12px 12px 16px; }
  .patient-avatar { grid-area: photo; width: 40px; height: 40px; }
  .patient-directory-name { grid-area: name; }
  .patient-directory-open { grid-area: open; }
  .patient-directory-code { grid-area: code; }
  .patient-directory-category { display: block !important; grid-area: category; }
  .patient-directory-status { grid-area: status; justify-self: end; }
  .patient-directory-date { grid-area: date; display: flex; gap: 5px; }
  .patient-directory-date small { display: inline; }
  .patient-directory-docs { grid-area: docs; min-width: 100px; }
  .patient-dossier-backdrop { padding: 0; }
  .patient-dossier { width: 100%; max-height: 100vh; min-height: 100vh; border: 0; border-radius: 0; }
  .patient-dossier-hero { grid-template-columns: 50px 1fr; min-height: 96px; padding: 12px 14px; }
  .patient-dossier-avatar { width: 48px; height: 48px; }
  .patient-dossier-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .patient-dossier-kpis { grid-template-columns: 1fr 1fr; }
  .patient-dossier-main { grid-template-columns: 1fr; }
  .patient-timeline { grid-template-columns: 1fr; }
  .patient-timeline-entry > button { grid-template-columns: 62px 1fr auto 10px; }
  .patient-review-controls > div { grid-template-columns: 1fr 1fr; }
  .patient-editor-form { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .patient-profile-facts,
  .patient-recommendation-grid,
  .patient-promotion-list { grid-template-columns: 1fr; }
}

/* Visual foundation: green identifies actions and state; neutral tones carry content. */
@media screen {
  body {
    background:
      radial-gradient(circle at top left, rgba(184, 240, 84, .1), transparent 30%),
      linear-gradient(180deg, #0a0f0d 0%, #0c1210 100%);
    letter-spacing: .005em;
  }

  p,
  small,
  .small,
  .muted,
  .muted-box {
    color: var(--muted);
  }

  .panel,
  .card,
  .chart-panel,
  .settings-group,
  .table-panel {
    border-color: rgba(184, 197, 190, .2);
    background: linear-gradient(145deg, rgba(31, 41, 37, .97), rgba(20, 27, 24, .98));
  }

  label,
  th,
  .eyebrow {
    color: #dce6e0;
  }

  input,
  select,
  textarea {
    color: #f8fbf9;
    border-color: rgba(184, 197, 190, .28);
    background: #0b110f;
  }

  input::placeholder,
  textarea::placeholder {
    color: #84958c;
    opacity: 1;
  }

  input:focus,
  select:focus,
  textarea:focus,
  button:focus-visible,
  a:focus-visible {
    outline: 3px solid rgba(184, 240, 84, .62);
    outline-offset: 2px;
  }

  table thead th {
    color: #ecf3ef;
    background: #101714;
    border-bottom-color: rgba(184, 240, 84, .3);
  }

  table tbody td {
    color: #e7efea;
    border-bottom-color: rgba(184, 197, 190, .17);
  }

  table tbody tr:hover td {
    background: rgba(184, 240, 84, .055);
  }
}

.paged-table {
  min-width: 0;
}

.paged-table tbody tr[hidden] {
  display: none;
}

.table-pagination {
  display: grid;
  grid-template-columns: minmax(190px, auto) 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 10px 12px;
  border-top: 1px solid rgba(184, 197, 190, .18);
  color: var(--muted);
  background: rgba(8, 13, 11, .58);
}

.table-pagination label,
.table-page-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.table-pagination select {
  width: auto;
  min-width: 76px;
  min-height: 36px;
  padding: 6px 30px 6px 10px;
}

.table-pagination > span {
  text-align: center;
}

.table-page-actions {
  justify-content: flex-end;
}

.table-page-actions strong {
  min-width: 58px;
  color: var(--text);
  text-align: center;
}

.table-page-actions button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.security-key-manager fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(184, 197, 190, .22);
  border-radius: 14px;
}

.security-key-manager legend {
  padding: 0 8px;
  color: var(--text);
  font-weight: 800;
}

.api-key-once {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 16px 0;
  padding: 16px;
  border: 1px solid rgba(247, 201, 72, .55);
  border-radius: 14px;
  background: rgba(247, 201, 72, .08);
}

.api-key-once strong {
  grid-column: 1 / -1;
  color: #ffe29a;
}

.api-key-once code {
  overflow-wrap: anywhere;
  color: var(--text);
}

.portal-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  border-color: rgba(184, 240, 84, .36);
  background:
    radial-gradient(circle at 90% 20%, rgba(184, 240, 84, .18), transparent 30%),
    linear-gradient(145deg, #263329, #121917);
}

.portal-hero h2 {
  margin: 4px 0 8px;
  font-size: clamp(26px, 4vw, 40px);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  color: #11170f;
  background: var(--brand);
  font-weight: 900;
  text-decoration: none;
}

.portal-kpis {
  margin-bottom: 18px;
}

.portal-promotions {
  display: grid;
  gap: 12px;
}

.portal-promotions article {
  padding: 16px;
  border: 1px solid rgba(184, 197, 190, .18);
  border-radius: 14px;
  background: rgba(255, 255, 255, .025);
}

.portal-promotions article span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.portal-promotions h4 {
  margin: 5px 0;
  color: var(--text);
}

@media (max-width: 680px) {
  .portal-hero {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Portal privado: una sola navegación y lectura cómoda en cualquier pantalla. */
.patient-portal-mode {
  --sidebar-w: 220px;
  background:
    radial-gradient(circle at 82% 8%, rgba(184, 240, 84, .10), transparent 26%),
    var(--bg);
}

.patient-portal-mode .tabs .nav-group-label,
.patient-portal-mode .tabs .nav-group + .nav-group {
  display: none;
}

.patient-portal-mode .tabs .nav-group:has([data-view="portal"]) {
  display: grid;
  margin: 10px 0 0;
  padding: 0;
  border: 0;
}

.patient-portal-mode .tabs button[data-view="portal"] {
  display: block;
  min-height: 48px;
  font-size: 15px;
  text-align: center;
}

.patient-portal-mode #systemStatus { display: none; }
.patient-portal-mode main { max-width: 1480px; }

.portal-insights-grid,
.portal-history {
  margin-bottom: 18px;
}

.portal-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.portal-card-heading h3 { margin: 0; font-size: 21px; }
.portal-card-heading > small { max-width: 190px; color: var(--muted); text-align: right; }

.portal-preference-row {
  display: grid;
  grid-template-columns: 32px minmax(150px, .75fr) minmax(130px, 1.3fr) 50px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.portal-preference-row:last-child { border-bottom: 0; }
.portal-preference-rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #182014;
  background: var(--brand);
  font-size: 12px;
  font-weight: 950;
}

.portal-preference-copy { display: grid; min-width: 0; }
.portal-preference-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-preference-copy small { color: var(--muted); }
.portal-preference-track {
  overflow: hidden;
  height: 9px;
  border: 1px solid rgba(184, 240, 84, .15);
  border-radius: 999px;
  background: #0d1410;
}
.portal-preference-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--ok));
}
.portal-preference-value { color: var(--brand); text-align: right; }

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

.portal-discovery-card {
  min-height: 112px;
  padding: 15px;
  border: 1px solid rgba(184, 240, 84, .18);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(184, 240, 84, .08), rgba(255, 255, 255, .02));
}
.portal-discovery-card span { color: var(--brand); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.portal-discovery-card h4 { margin: 7px 0 3px; color: var(--text); font-size: 17px; }
.portal-discovery-card p { margin: 0; font-size: 12px; }
.portal-discovery-note { margin: 14px 0 0; font-size: 11px; }

.portal-dispensation-list { display: grid; gap: 10px; }
.portal-dispensation-card {
  display: grid;
  grid-template-columns: minmax(155px, .35fr) minmax(260px, 1fr) minmax(250px, .6fr);
  gap: 18px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 16px;
  background: rgba(255, 255, 255, .025);
}
.portal-dispensation-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.portal-dispensation-head > div { display: grid; }
.portal-dispensation-head span { color: var(--muted); font-size: 11px; }
.portal-dispensation-card > p { margin: 0; color: var(--text); }
.portal-dispensation-foot { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.portal-dispensation-foot > div { display: grid; gap: 3px; text-align: right; }
.portal-dispensation-foot small { color: var(--muted); }
.portal-dispensation-foot strong { color: var(--brand); font-size: 17px; }

@media (max-width: 900px) {
  .portal-dispensation-card { grid-template-columns: 1fr; gap: 10px; }
  .portal-dispensation-foot { justify-content: space-between; }
  .portal-dispensation-foot > div { text-align: left; }
}

@media (max-width: 680px) {
  .patient-portal-mode .topbar-brand h1 { font-size: 20px; }
  .patient-portal-mode .topbar-brand .eyebrow { display: none; }
  .portal-card-heading { display: grid; }
  .portal-card-heading > small { max-width: none; text-align: left; }
  .portal-preference-row { grid-template-columns: 28px 1fr 42px; }
  .portal-preference-track { grid-column: 2 / -1; }
  .portal-discovery-grid { grid-template-columns: 1fr; }
  .portal-dispensation-foot { align-items: stretch; flex-direction: column; }
  .portal-dispensation-foot .button-link { width: 100%; }
}

@media (max-width: 680px) {
  .table-pagination {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .table-pagination > span {
    text-align: left;
  }

  .table-page-actions {
    justify-content: space-between;
  }
}

@media print {
  .paged-table tbody tr[hidden] {
    display: table-row !important;
  }

  .table-pagination {
    display: none !important;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(184, 240, 84, .13), transparent 34%), var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vw, 64px);
  background:
    radial-gradient(circle at 82% 12%, rgba(184, 240, 84, .16), transparent 31%),
    linear-gradient(118deg, rgba(255,255,255,.035), transparent 42%),
    var(--bg);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .72fr);
  width: min(1120px, 100%);
  min-height: min(690px, calc(100vh - 80px));
  overflow: hidden;
  border: 1px solid rgba(184, 240, 84, .22);
  border-radius: 28px;
  background: #101613;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .42);
}

.login-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(30px, 5vw, 66px);
  background:
    linear-gradient(180deg, rgba(184, 240, 84, .08), transparent 38%),
    linear-gradient(145deg, #18231d, #0d1210);
}

.login-intro-copy {
  max-width: 620px;
  margin: clamp(64px, 12vh, 122px) 0 auto;
}

.login-intro-copy h1 {
  max-width: 11ch;
  margin: 0;
  font-size: clamp(42px, 5.7vw, 76px);
  line-height: .98;
  letter-spacing: -.04em;
  text-wrap: balance;
}

.login-intro-copy p {
  max-width: 52ch;
  margin: 24px 0 0;
  color: #c7d5cc;
  font-size: clamp(15px, 1.6vw, 19px);
}

.login-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 54px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

.login-flow span {
  display: grid;
  gap: 7px;
  color: #e5eee8;
  font-size: 12px;
  font-weight: 800;
}

.login-flow b {
  color: var(--brand);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .1em;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, .08);
  border-radius: 0;
  padding: clamp(32px, 5vw, 64px);
  background: #151d19;
  box-shadow: none;
}

.login-form-heading > span {
  display: block;
  margin-bottom: 12px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.login-form-heading h2 {
  margin: 0;
  font-size: clamp(30px, 3.4vw, 44px);
  line-height: 1.05;
  letter-spacing: -.03em;
}

.login-form-heading p {
  margin: 14px 0 30px;
  color: var(--muted);
}

.login-card label {
  gap: 8px;
  color: #e6eee9;
  font-weight: 800;
}

.login-card input {
  min-height: 50px;
  border-color: #46554d;
  background: #0f1512;
}

.login-card input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(184, 240, 84, .14);
  outline: 0;
}

.login-submit {
  min-height: 52px;
  margin-top: 4px;
  color: #0c120e;
  font-weight: 950;
}

.login-status {
  min-height: 22px;
  margin-top: 14px;
  color: #ffabab;
}

.login-security-note {
  margin: 20px 0 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  color: #9eada4;
  font-size: 12px;
}

.login-brand,
.topbar-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand img,
.topbar-brand img,
.sidebar-brand img {
  display: block;
  object-fit: contain;
  background: transparent;
  border: 0;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .32));
}

.login-brand img {
  width: 74px;
  height: 74px;
  border-radius: 20px;
  padding: 0;
}

.login-brand strong,
.sidebar-brand strong {
  display: block;
  color: var(--text);
  font-size: 17px;
  letter-spacing: .08em;
}

.login-brand span,
.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

.topbar-brand img {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 16px;
  padding: 0;
}

.official-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 14px;
  text-align: left;
}

.official-brand img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  background: transparent;
  border-radius: 16px;
  padding: 0;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .32));
}

.official-brand strong,
.official-brand span { display: block; }
.official-brand strong { color: var(--text); font-size: 18px; letter-spacing: .08em; }
.official-brand span { color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: .16em; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 28px 32px 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(26px, 4vw, 42px); line-height: 1.05; }
h2 { font-size: 24px; }
h3 { font-size: 17px; margin-bottom: 14px; }
p { color: var(--muted); }

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  white-space: nowrap;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 32px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 16, .94);
  backdrop-filter: blur(14px);
  scrollbar-width: thin;
}

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

.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.button-like:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.guest-slot {
  display: grid;
  gap: 6px;
  min-width: 240px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
}

.guest-slot strong {
  color: var(--brand);
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: 12px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--brand);
  color: #17200f;
  cursor: pointer;
  font-weight: 800;
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.tabs button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tabs button.active {
  background: var(--brand);
  color: #17200f;
  border-color: var(--brand);
}

main { padding: 26px 32px 42px; }
.view { display: none; }
.view.active { display: block; }

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

.section-head p { margin: 6px 0 0; }

.dashboard-timebar {
  align-items: center;
}

.dashboard-timebar label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.dashboard-timebar input[type="range"] {
  width: min(240px, 42vw);
  accent-color: var(--brand);
}

.dashboard-timebar strong {
  min-width: 72px;
  color: var(--brand);
}

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

.card, .panel {
  background: linear-gradient(180deg, rgba(255,255,255,.035), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.card { padding: 18px; min-width: 0; overflow: hidden; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.card .value {
  max-width: 100%;
  font-size: clamp(22px, 2.7vw, 38px);
  font-weight: 900;
  line-height: 1.05;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .hint { color: var(--muted); margin-top: 6px; font-size: 12px; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid.wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(360px, .8fr); }
.panel { padding: 18px; min-width: 0; }
.table-panel { overflow-x: auto; }
.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.table-panel::after {
  content: "";
  display: block;
  height: 1px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .62);
}

.modal-card {
  width: min(980px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sensitive-authorization-card {
  width: min(520px, 94vw);
}

.sensitive-authorization-card label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.sensitive-authorization-notice {
  padding: 12px 14px;
  border: 1px solid rgba(255, 190, 74, .34);
  border-radius: 14px;
  background: rgba(255, 190, 74, .09);
  color: #ffe0a3;
  line-height: 1.45;
}

.sensitive-edit-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid rgba(255, 190, 74, .42);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 190, 74, .15), rgba(181, 255, 77, .07));
}

.sensitive-edit-banner strong { color: #ffe0a3; }
.sensitive-edit-banner span { color: var(--muted); }
.sensitive-edit-banner button { grid-column: 2; grid-row: 1 / span 2; }

@media (max-width: 680px) {
  .sensitive-edit-banner { grid-template-columns: 1fr; }
  .sensitive-edit-banner button { grid-column: 1; grid-row: auto; }
}

.sale-detail-modal {
  width: min(1180px, 100%);
}

.small-value {
  font-size: 18px !important;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.detail-grid span {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  color: var(--muted);
}

.detail-grid strong {
  color: var(--text);
}

th, td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

tr.clickable:hover { background: rgba(184,240,84,.08); cursor: pointer; }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1513;
  color: var(--text);
  padding: 10px 12px;
}

textarea { min-height: 76px; resize: vertical; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.danger { color: var(--danger); }

.danger-soft {
  border-color: rgba(255,107,107,.45);
  color: #ffb3b3;
}

.mini-progress {
  width: 150px;
  max-width: 100%;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.08);
}

.mini-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--ok));
}

.debt-payment-panel {
  position: sticky;
  top: 12px;
}

.debt-payment-panel.active {
  border-color: rgba(199,255,94,.42);
  background:
    radial-gradient(circle at 100% 0, rgba(199,255,94,.13), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,.04), transparent),
    var(--panel);
}

.pulse-focus .debt-payment-panel,
#debtPaymentPanel.pulse-focus .debt-payment-panel {
  animation: debtPulse .9s ease;
}

@keyframes debtPulse {
  0% { box-shadow: 0 0 0 0 rgba(199,255,94,.36), var(--shadow); }
  100% { box-shadow: 0 0 0 18px rgba(199,255,94,0), var(--shadow); }
}

.compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-actions button {
  width: auto;
}

.debtors-module .grid.two {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  align-items: start;
}

.debtors-module .table-scroll {
  max-height: min(58vh, 560px);
}

.debtors-module table {
  min-width: 860px;
}

.debtors-module .mini-progress {
  min-width: 120px;
}

/* Créditos: tablero operativo de cartera */
.debtors-module {
  display: grid;
  gap: 18px;
}

.debtors-module > .section-head {
  margin-bottom: 0;
}

.debt-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.debt-kpi {
  position: relative;
  min-width: 0;
  min-height: 126px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0, rgba(184,240,84,.09), transparent 42%),
    linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
}

.debt-kpi::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: rgba(184,240,84,.55);
}

.debt-kpi > span,
.debt-kpi > small {
  color: var(--muted);
}

.debt-kpi > span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.debt-kpi > strong {
  min-width: 0;
  color: #f6fbf7;
  font-size: clamp(25px, 2.35vw, 38px);
  line-height: 1;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.debt-kpi-balance > strong,
.debt-kpi-alert > strong { color: #ffd36a; }
.debt-kpi-collected > strong { color: #65e6a3; }
.debt-kpi-alert::after { background: #ff6f78; }
.debt-kpi-collected::after { background: #65e6a3; }

.debt-insights-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr);
  gap: 14px;
  align-items: stretch;
}

.debt-insights-grid > * {
  min-width: 0;
  min-height: 300px;
}

.debt-insights-grid .viz-bars {
  max-height: 238px;
  overflow: auto;
}

.debt-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  gap: 16px;
  align-items: start;
}

.debt-patient-section {
  min-width: 0;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 20px;
  background: rgba(255,255,255,.018);
}

.debt-section-title,
.debt-person-head,
.debt-payment-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.debt-section-title {
  align-items: center;
  margin-bottom: 14px;
}

.debt-section-title h3,
.debt-person-head h4,
.debt-payment-head h3 {
  margin: 0;
}

.debt-section-title > span {
  padding: 7px 10px;
  border: 1px solid rgba(184,240,84,.22);
  border-radius: 999px;
  color: #d7ff8b;
  background: rgba(184,240,84,.07);
  font-size: 12px;
  font-weight: 800;
}

.debt-person-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 10px;
  max-height: 670px;
  padding-right: 4px;
  overflow: auto;
}

.debt-person-card {
  min-width: 0;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.016));
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.debt-person-card:hover {
  border-color: rgba(184,240,84,.28);
  background: linear-gradient(145deg, rgba(184,240,84,.075), rgba(255,255,255,.02));
  transform: translateY(-1px);
}

.debt-person-card.is-alert {
  border-color: rgba(255,111,120,.24);
}

.debt-person-code {
  display: block;
  margin-bottom: 3px;
  color: #a9d9ba;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
}

.debt-person-head h4 {
  color: #fff;
  font-size: 15px;
}

.debt-person-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.debt-person-balance {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.debt-person-balance span {
  color: var(--muted);
  font-size: 11px;
}

.debt-person-balance strong {
  color: #ffd36a;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1;
}

.debt-person-progress {
  display: grid;
  gap: 6px;
}

.debt-person-progress > div:last-child,
.debt-person-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
}

.debt-person-meta {
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.065);
}

.debt-person-meta span {
  display: grid;
  gap: 3px;
}

.debt-person-meta b {
  color: #dce7df;
  font-weight: 800;
}

.debt-person-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 7px;
}

.debt-person-actions button {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 11px;
}

.debt-payment-panel {
  min-width: 0;
  overflow: hidden;
}

.debt-payment-empty {
  min-height: 258px;
  display: grid;
  align-content: center;
  gap: 16px;
  text-align: center;
  border-style: dashed;
  background: linear-gradient(145deg, rgba(184,240,84,.035), rgba(255,255,255,.018));
}

.debt-empty-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border: 1px solid rgba(184,240,84,.42);
  border-radius: 16px;
  color: #d7ff8b;
  background: rgba(184,240,84,.09);
  font-size: 25px;
  font-weight: 900;
}

.debt-payment-empty h3,
.debt-payment-empty p { margin: 0; }
.debt-payment-empty p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }

.debt-empty-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.debt-empty-steps span {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
}

.debt-empty-steps b {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 50%;
  color: #10170d;
  background: var(--brand);
}

.debt-payment-head {
  margin-bottom: 14px;
}

.debt-payment-head p { margin: 4px 0 0; }
.debt-payment-head button { width: auto; }

.debt-selected-balance {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(247,201,72,.24);
  border-radius: 14px;
  background: rgba(247,201,72,.07);
}

.debt-selected-balance span { color: var(--muted); font-size: 11px; }
.debt-selected-balance strong { color: #ffd36a; font-size: clamp(22px, 2.5vw, 32px); }
.debt-payment-form { gap: 10px; }
.debt-submit-payment { margin-top: 4px; }

.debt-audit-block {
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 18px;
  background: rgba(255,255,255,.018);
}

.debt-audit-block > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
  transition: background .18s ease;
}

.debt-audit-block > summary::-webkit-details-marker { display: none; }
.debt-audit-block > summary:hover { background: rgba(184,240,84,.055); }
.debt-audit-block > summary span { display: grid; gap: 3px; }
.debt-audit-block > summary b { color: #fff; font-size: 14px; }
.debt-audit-block > summary small { color: var(--muted); }
.debt-audit-block > summary > strong {
  min-width: 32px;
  padding: 6px 9px;
  border-radius: 999px;
  color: #d7ff8b;
  background: rgba(184,240,84,.09);
  text-align: center;
}

.debt-audit-block[open] > summary {
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(184,240,84,.035);
}

.debt-audit-block .table-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.debt-policy-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255,255,255,.018);
  font-size: 11px;
}

.debt-policy-note b { color: #fff; }

/* Créditos 2.0: información primero, asignación contable bajo demanda */
#reportsView[data-report-mode="credits"] .databi-period-toolbar #reportCashier,
#reportsView[data-report-mode="credits"] .databi-period-toolbar #reportPaymentMethod,
#reportsView[data-report-mode="credits"] .databi-period-toolbar #reportPersonCategory,
#reportsView[data-report-mode="credits"] .databi-period-toolbar #reportGenetics,
#reportsView[data-report-mode="credits"] .databi-period-toolbar #reportPresentation,
#reportsView[data-report-mode="credits"] .databi-period-toolbar #reportProductSearch {
  display: none;
}

#reportsView[data-report-mode="credits"] > .section-head,
#reportsView[data-report-mode="credits"] .databi-period-toolbar .range-field {
  display: none;
}

#reportsView[data-report-mode="credits"] .databi-period-toolbar {
  display: grid;
  grid-template-columns: 170px 170px minmax(240px, 1fr);
  gap: 8px;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.018);
}

#reportsView[data-report-mode="credits"] #reportsOutput > .debtors-module {
  padding: 14px;
}

.credit-module-head { align-items: center; }
.credit-module-head h3 { margin: 2px 0 4px; font-size: 22px; }

.credit-command-summary {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
}

.credit-command-summary article {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.credit-command-summary span { color: var(--muted); font-size: 12px; font-weight: 750; }
.credit-command-summary strong { color: #fff; font-size: clamp(20px, 2vw, 29px); letter-spacing: -.035em; }
.credit-command-summary article:first-child strong { color: #ffd36a; }
.credit-command-summary .attention strong { color: #ff8e94; }

.credit-patient-section { padding: 12px; }
.credit-list-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.credit-list-tools input { min-width: 0; }
.credit-filter-buttons { display: flex; gap: 6px; }
.credit-filter-buttons button { width: auto; min-height: 36px; padding: 7px 11px; }
.credit-filter-buttons button.active { color: #15200d; border-color: var(--brand); background: var(--brand); }
.credit-list-tools > span { color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }

.credit-list-head,
.credit-person-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.35fr) 145px minmax(165px, .9fr) minmax(150px, .8fr) 190px;
  align-items: center;
  gap: 12px;
}

.credit-list-head {
  padding: 6px 12px;
  color: #8fa199;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.credit-person-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  max-height: min(64vh, 680px);
}

.credit-person-row {
  min-height: 76px;
  padding: 10px 12px;
  border-radius: 12px;
  transform: none;
}
.credit-person-row:hover { transform: none; }
.credit-person-row[hidden] { display: none; }

.credit-person-identity {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.credit-person-identity:hover { border: 0; background: transparent; }
.credit-person-identity h4 { margin: 1px 0; color: #fff; font-size: 14px; }
.credit-person-identity p { margin: 0; color: var(--muted); font-size: 10px; }

.credit-person-status { display: grid; justify-items: start; gap: 5px; }
.credit-person-status small,
.credit-person-money span,
.credit-person-money small { color: var(--muted); font-size: 10px; }
.credit-person-money { min-width: 0; display: grid; gap: 3px; }
.credit-person-money strong { min-width: 0; color: #eaf0ec; font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
.credit-person-balance strong { color: #ffd36a; font-size: 20px; }
.credit-person-row .debt-person-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.credit-person-row .debt-person-actions button { min-height: 34px; padding: 6px 8px; font-size: 10px; }

.credit-payment-events-list,
.credit-money-history { display: grid; gap: 7px; padding: 10px; }
.credit-money-history { padding: 0; }
.credit-popup-section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.credit-popup-section-head h3 { margin: 2px 0 0; }
.credit-popup-section-head > span { color: var(--muted); font-size: 11px; }

.credit-money-event {
  overflow: hidden;
  border: 1px solid rgba(101,230,163,.18);
  border-radius: 13px;
  background: rgba(101,230,163,.035);
}
.credit-money-event-main {
  display: grid;
  grid-template-columns: minmax(150px, .75fr) minmax(220px, 1.25fr);
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
}
.credit-money-event-main > div { min-width: 0; display: grid; gap: 3px; }
.credit-money-event-main span,
.credit-money-event-main small { color: var(--muted); font-size: 10px; }
.credit-money-event-main strong { color: #65e6a3; font-size: 23px; letter-spacing: -.03em; }
.credit-money-event-context b { color: #fff; font-size: 12px; }
.credit-allocation-detail { border-top: 1px solid rgba(255,255,255,.055); }
.credit-allocation-detail summary { padding: 7px 14px; cursor: pointer; color: #8fa199; font-size: 9px; }
.credit-allocation-detail > div { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.credit-allocation-detail > div span { display: flex; gap: 8px; padding: 5px 7px; border-radius: 7px; background: rgba(255,255,255,.04); font-size: 10px; }
.credit-allocation-detail em { color: #c8d4cc; font-style: normal; }
.credit-receipt-link { padding: 0; border: 0; background: transparent; color: var(--accent); font: inherit; text-decoration: underline; box-shadow: none; }
.credit-receipt-link:hover { color: #fff; transform: none; box-shadow: none; }

.credit-account-modal { width: min(1040px, calc(100vw - 28px)); max-height: calc(100vh - 28px); }
.credit-account-summary { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.credit-account-summary > div { display: grid; gap: 4px; padding: 13px 15px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.025); }
.credit-account-summary span { color: var(--muted); font-size: 10px; }
.credit-account-summary strong { color: #fff; font-size: 20px; }
.credit-account-summary > div:first-child strong { color: #ffd36a; font-size: 28px; }

.credit-payment-entry { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(460px, 1.5fr) auto; align-items: end; gap: 14px; }
.credit-payment-entry h3 { margin: 2px 0 4px; }
.credit-payment-entry p { margin: 0; color: var(--muted); font-size: 11px; }
.credit-payment-entry > button { width: auto; white-space: nowrap; }
.credit-payment-fields { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 7px; }
.credit-payment-fields label { font-size: 10px; }
.credit-payment-fields .credit-fx-settlement,
.debt-payment-form .credit-fx-settlement {
  display: flex;
  grid-column: 1 / -1;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 211, 106, .25);
  border-radius: 12px;
  background: rgba(255, 211, 106, .05);
  color: #ffd36a;
}
.credit-fx-settlement input[type="checkbox"] { width: 16px; min-width: 16px; height: 16px; margin-top: 1px; }
.credit-fx-settlement span { display: grid; gap: 2px; font-weight: 850; }
.credit-fx-settlement small { color: var(--muted); font-weight: 500; line-height: 1.35; }
.credit-internal-audit { margin-top: 2px; }
.debt-audit-block > #debtPaymentPanel { padding: 10px; }
.report-render-error {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 22px;
  border-color: rgba(255,111,120,.35);
  background: rgba(255,111,120,.055);
}
.report-render-error h3,
.report-render-error p { margin: 0; }
.report-render-error button { width: auto; }

@media (max-width: 1050px) {
  .credit-list-head { display: none; }
  .credit-person-row { grid-template-columns: minmax(200px, 1.2fr) 135px minmax(160px, .9fr) minmax(140px, .8fr); }
  .credit-person-row .debt-person-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
  .credit-person-row .debt-person-actions button { width: auto; }
  .credit-payment-entry { grid-template-columns: 1fr; align-items: stretch; }
  .credit-payment-entry > button { width: 100%; }
}

@media (max-width: 760px) {
  #reportsView[data-report-mode="credits"] .databi-period-toolbar { grid-template-columns: 1fr; }
  .credit-command-summary { grid-template-columns: 1fr; }
  .credit-list-tools { grid-template-columns: 1fr; }
  .credit-filter-buttons { overflow-x: auto; }
  .credit-person-row { grid-template-columns: 1fr 1fr; }
  .credit-person-identity { grid-column: 1 / -1; }
  .credit-person-status { justify-self: start; }
  .credit-person-last-payment { text-align: right; }
  .credit-person-row .debt-person-actions { grid-column: 1 / -1; display: grid; }
  .credit-money-event-main { grid-template-columns: 1fr; }
  .credit-account-summary { grid-template-columns: 1fr; }
  .credit-payment-fields { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .credit-person-row { grid-template-columns: 1fr; }
  .credit-person-last-payment { text-align: left; }
  .credit-payment-fields { grid-template-columns: 1fr; }
}

@media (max-width: 1180px) {
  .debt-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .debt-workspace { grid-template-columns: 1fr; }
  .debt-payment-panel { position: relative; top: auto; }
  .debt-payment-empty { min-height: 210px; }
}

@media (max-width: 860px) {
  .debt-insights-grid { grid-template-columns: 1fr; }
  .debt-insights-grid > * { min-height: auto; }
  .debt-person-list { max-height: none; overflow: visible; padding-right: 0; }
}

@media (max-width: 680px) {
  .debt-kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .debt-kpi { min-height: 112px; padding: 14px; }
  .debt-kpi > strong { font-size: clamp(22px, 7vw, 30px); }
  .debt-patient-section { padding: 12px; }
  .debt-person-list { grid-template-columns: 1fr; }
  .debt-person-actions { grid-template-columns: 1fr; }
  .debt-empty-steps { grid-template-columns: 1fr; }
  .debt-empty-steps span { grid-template-columns: 28px 1fr; align-items: center; text-align: left; }
  .debt-empty-steps b { margin: 0; }
  .debt-audit-block > summary { padding: 14px; }
  .debt-policy-note { display: grid; gap: 7px; }
}

.line-adder {
  display: grid;
  grid-template-columns: 1fr 110px 140px 150px;
  gap: 10px;
  margin: 14px 0;
}

.primary-wide { width: 100%; margin-top: 12px; }

.pos-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.pos-actions button {
  width: 100%;
}

.actions-cell {
  min-width: 210px;
}

.actions-cell button {
  margin: 2px;
}

.danger-btn {
  border-color: rgba(255, 83, 83, .45);
  color: #ffd0d0;
}

.muted-box {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 18px;
  color: var(--muted);
}

.quote-total {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
}

.quote-total span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
}

.quote-total strong {
  font-size: 30px;
  line-height: 1;
}

.split-account {
  margin: 10px 0 12px;
}

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

.split-grid span {
  color: var(--muted);
  font-size: 12px;
}

.split-grid strong {
  color: var(--text);
  font-size: 18px;
}

.split-warning {
  color: var(--warn);
  margin-top: 10px;
  font-weight: 700;
}

.ticket {
  background: #f7f8ef;
  color: #1b211b;
  font-family: "Consolas", monospace;
  white-space: pre-wrap;
  overflow-x: auto;
}

.ticket strong { color: #0f160e; }
.ticket-panel h3 { margin-bottom: 12px; }
.danger-text { color: var(--danger); }
.small { font-size: 12px; color: var(--muted); }

.soft-sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.documents-upload {
  margin-top: 18px;
}

.bar-list {
  display: grid;
  gap: 10px;
  margin: 10px 0 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 110px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #0f1513;
  overflow: hidden;
  border: 1px solid var(--line);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

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

.value.up {
  color: var(--warn);
}

.value.down {
  color: var(--ok);
}

.dollar-chart {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 220px;
  overflow-x: auto;
  padding: 18px 8px 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.dollar-bar {
  min-width: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: end;
  gap: 8px;
}

.dollar-bar-fill {
  width: 24px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  box-shadow: 0 0 18px rgba(185, 255, 102, .18);
}

.dollar-bar span {
  color: var(--muted);
  font-size: 11px;
  writing-mode: vertical-rl;
}

.help-panel ol {
  color: var(--muted);
  padding-left: 20px;
}

.help-panel li { margin-bottom: 8px; }

.settings-group {
  padding: 0 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-group:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--brand);
  color: #16200e;
  padding: 13px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-weight: 900;
  max-width: 380px;
}

.hidden { display: none !important; }

/* Fase 1 UI/UX - modernizacion visual CSS-first */
:root {
  --sidebar-w: 268px;
  --bg: #090d0c;
  --panel: #121816;
  --panel-2: #18221e;
  --line: rgba(196, 255, 119, .12);
  --line-strong: rgba(196, 255, 119, .24);
  --text: #f3fbf5;
  --muted: #9aaca2;
  --brand: #c7ff5e;
  --brand-2: #56d364;
  --brand-soft: rgba(199, 255, 94, .12);
  --danger: #ff6b7a;
  --warn: #ffd166;
  --ok: #63e6a8;
  --shadow: 0 22px 80px rgba(0, 0, 0, .35);
  --shadow-soft: 0 12px 36px rgba(0, 0, 0, .24);
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 6% 6%, rgba(199, 255, 94, .14), transparent 28%),
    radial-gradient(circle at 82% 10%, rgba(86, 211, 100, .10), transparent 24%),
    linear-gradient(135deg, #070a09 0%, #0d1411 48%, #0a0f0d 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  margin-left: var(--sidebar-w);
  padding: 22px 30px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: rgba(9, 13, 12, .82);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  max-width: 980px;
  font-size: clamp(25px, 3vw, 38px);
  letter-spacing: -.04em;
}

.status-pill {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, .055);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.tabs {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 16px;
  border-right: 1px solid rgba(255, 255, 255, .08);
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(199, 255, 94, .10), transparent 26%),
    rgba(10, 14, 13, .96);
  box-shadow: 18px 0 60px rgba(0, 0, 0, .28);
}

.tabs::before {
  content: none;
}

.tabs::after {
  content: "Operado con JAUS OS";
  display: block;
  margin: auto 8px 4px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-brand {
  margin: 0 6px 16px;
  padding: 9px;
  border: 1px solid rgba(184, 240, 84, .2);
  border-radius: 16px;
  background: rgba(255, 255, 255, .035);
}

.sidebar-brand img {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 14px;
  padding: 0;
}

.tabs button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 12px;
  background: transparent;
  color: #b6c7bd;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.tabs button:hover {
  color: var(--text);
  border-color: rgba(255,255,255,.08);
  background: rgba(255,255,255,.045);
  transform: translateX(2px);
}

.tabs button.active {
  color: #0f170d;
  border-color: rgba(199, 255, 94, .72);
  background: linear-gradient(135deg, var(--brand), #92e85a);
  box-shadow: 0 12px 30px rgba(199, 255, 94, .18);
}

main {
  margin-left: var(--sidebar-w);
  padding: 28px 30px 46px;
}

.view.active {
  animation: fadeUp .22s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-head {
  padding: 20px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
  box-shadow: var(--shadow-soft);
}

.section-head h2 {
  font-size: clamp(22px, 2.4vw, 30px);
  letter-spacing: -.03em;
}

.section-head p {
  max-width: 760px;
}

.cards {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.card, .panel {
  position: relative;
  overflow: hidden;
  border-color: rgba(255,255,255,.075);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.018)),
    var(--panel);
  box-shadow: var(--shadow-soft);
}

.card::before, .panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(199,255,94,.36), transparent);
  pointer-events: none;
}

.card {
  min-height: 136px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.card .label {
  color: #b7c8bd;
  font-size: 11px;
}

.card .value {
  color: var(--text);
  font-size: clamp(28px, 3.2vw, 40px);
  letter-spacing: -.05em;
}

.card .hint {
  color: #8fa097;
}

#dashboardCards .card:first-child {
  background:
    radial-gradient(circle at 100% 0, rgba(199,255,94,.23), transparent 42%),
    linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02)),
    var(--panel);
}

#dashboardCards .card:nth-child(2) .value { color: var(--ok); }
#dashboardCards .card:nth-child(4) .value { color: var(--warn); }

.grid {
  gap: 18px;
  margin-bottom: 18px;
}

.grid.wide-left {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, .85fr);
}

.panel {
  border-radius: 24px;
  padding: 20px;
}

.panel h3 {
  color: #f6fff8;
  letter-spacing: -.015em;
}

.table-panel {
  scrollbar-width: thin;
  scrollbar-color: rgba(199,255,94,.35) transparent;
}

.table-panel,
.panel.table-panel {
  overflow: auto !important;
  overscroll-behavior: contain;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  max-height: min(62vh, 620px);
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(199,255,94,.45) rgba(255,255,255,.04);
}

.table-scroll:focus {
  outline: 2px solid rgba(199,255,94,.55);
  outline-offset: 2px;
}

.table-scroll::-webkit-scrollbar,
.table-panel::-webkit-scrollbar,
.modal-card::-webkit-scrollbar,
.product-grid::-webkit-scrollbar,
.tabs::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-scroll::-webkit-scrollbar-track,
.table-panel::-webkit-scrollbar-track,
.modal-card::-webkit-scrollbar-track,
.product-grid::-webkit-scrollbar-track,
.tabs::-webkit-scrollbar-track {
  background: rgba(255,255,255,.04);
  border-radius: 999px;
}

.table-scroll::-webkit-scrollbar-thumb,
.table-panel::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb,
.product-grid::-webkit-scrollbar-thumb,
.tabs::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, rgba(199,255,94,.72), rgba(117,201,75,.45));
  border: 2px solid rgba(15,21,19,.85);
  border-radius: 999px;
}

.table-scroll::after {
  content: "Desplazá horizontalmente para ver todas las columnas";
  position: sticky;
  left: 0;
  bottom: 0;
  display: none;
  width: max-content;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(199,255,94,.18);
  border-radius: 999px;
  background: rgba(10,14,13,.92);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(18, 24, 22, .96);
  color: #aebfb5;
}

th:first-child { border-radius: 12px 0 0 12px; }
th:last-child { border-radius: 0 12px 12px 0; }

td {
  color: #dce9e1;
}

tbody tr {
  transition: background .14s ease, transform .14s ease;
}

tbody tr:hover {
  background: rgba(199,255,94,.055);
}

.toolbar {
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 18px;
  background: rgba(255,255,255,.035);
  box-shadow: var(--shadow-soft);
}

input, select, textarea {
  border-color: rgba(255,255,255,.10);
  background: rgba(4, 8, 7, .58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(199,255,94,.58);
  box-shadow: 0 0 0 3px rgba(199,255,94,.10);
  background: rgba(6, 11, 9, .86);
}

button {
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(199,255,94,.13);
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button.secondary {
  background: rgba(255,255,255,.045);
  border-color: rgba(255,255,255,.10);
  box-shadow: none;
}

.badge {
  align-items: center;
  min-height: 26px;
  border-color: rgba(255,255,255,.10);
  background: rgba(255,255,255,.055);
  letter-spacing: .02em;
}

.badge.ok {
  color: var(--ok);
  background: rgba(99, 230, 168, .10);
  border-color: rgba(99, 230, 168, .24);
}

.badge.warn {
  color: var(--warn);
  background: rgba(255, 209, 102, .10);
  border-color: rgba(255, 209, 102, .24);
}

.badge.danger {
  color: var(--danger);
  background: rgba(255, 107, 122, .10);
  border-color: rgba(255, 107, 122, .24);
}

.muted-box {
  border-color: rgba(255,255,255,.11);
  background: rgba(255,255,255,.035);
}

.quote-total {
  border: 1px solid rgba(199,255,94,.28);
  background:
    radial-gradient(circle at 100% 0, rgba(199,255,94,.20), transparent 36%),
    rgba(199,255,94,.075);
}

.quote-total strong {
  color: var(--brand);
  font-size: clamp(30px, 4vw, 46px);
}

.split-grid span {
  padding: 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
}

.ticket {
  min-height: 340px;
  border-radius: 18px;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}

.bar-row {
  grid-template-columns: minmax(120px, 150px) minmax(140px, 1fr) minmax(100px, auto);
  padding: 8px;
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.bar-track {
  height: 14px;
  background: rgba(0,0,0,.26);
}

.bar-fill {
  box-shadow: 0 0 22px rgba(199,255,94,.18);
}

.line-adder {
  grid-template-columns: minmax(220px, 1fr) 92px 132px 150px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 18px;
  background: rgba(255,255,255,.03);
}

.settings-group {
  border-color: rgba(255,255,255,.08);
}

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid, .grid.wide-left { grid-template-columns: 1fr; }
}

@media (max-width: 1000px) {
  .topbar {
    position: relative;
    margin-left: 0;
  }
  .tabs {
    position: sticky;
    top: 0;
    inset: auto;
    width: auto;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 12px 34px rgba(0,0,0,.24);
  }
  .tabs::before, .tabs::after { display: none; }
  .tabs button {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    text-align: center;
  }
  .tabs button:hover {
    transform: translateY(-1px);
  }
  main {
    margin-left: 0;
  }
  .cards, .grid, .grid.wide-left { grid-template-columns: 1fr; }
  .topbar, .section-head, .toolbar { flex-direction: column; align-items: stretch; }
  main, .topbar, .tabs { padding-left: 16px; padding-right: 16px; }
  .form-grid, .line-adder { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .split-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .debt-payment-panel {
    position: relative;
    top: auto;
  }
  .debtors-module .grid.two {
    grid-template-columns: 1fr;
  }
  .debtors-module .table-scroll {
    max-height: 52vh;
  }
}

@media (max-width: 680px) {
  body { font-size: 13px; }
  body { overflow-x: hidden; }
  .topbar {
    padding-top: 18px;
    gap: 12px;
    flex-direction: column;
    align-items: stretch;
  }
  h1 { font-size: 26px; }
  h2 { font-size: 21px; }
  main { padding-top: 18px; }
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
  .tabs {
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .tabs button {
    padding: 9px 11px;
    border-radius: 999px;
  }
  .cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .card, .panel {
    border-radius: 16px;
    padding: 14px;
  }
  .card .value { font-size: 25px; }
  button {
    width: 100%;
    min-height: 42px;
  }
  .toolbar {
    gap: 8px;
    flex-direction: column;
    align-items: stretch;
  }
  th, td {
    padding: 9px 8px;
  }
  table {
    min-width: 720px;
    font-size: 12px;
  }
  .table-scroll {
    max-height: min(62vh, 520px);
    border: 1px solid rgba(255,255,255,.06);
  }
  .table-scroll::after {
    display: block;
  }
  .section-head {
    padding: 16px;
    border-radius: 18px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .quote-total {
    align-items: flex-start;
    flex-direction: column;
  }
  .split-grid {
    grid-template-columns: 1fr;
  }
  .bar-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .status-pill {
    white-space: normal;
    word-break: break-word;
  }
  .form-grid,
  .line-adder,
  .catalog-price-box,
  .catalog-image-editor {
    grid-template-columns: 1fr;
  }
  .modal-backdrop {
    align-items: stretch;
    padding: 8px;
  }
  .modal-card {
    width: 100%;
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
    padding: 12px;
  }
  .debtors-module {
    padding: 12px;
  }
  .debtors-module .cards {
    grid-template-columns: 1fr;
  }
  .debtors-module .table-scroll {
    max-height: 58vh;
  }
  .debtors-module table {
    min-width: 760px;
  }
  .debtors-module .actions-cell,
  .compact-actions {
    min-width: 145px;
  }
  .compact-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .compact-actions button,
  .actions-cell button {
    width: 100%;
  }
  .debt-payment-panel .grid.two {
    grid-template-columns: 1fr;
  }
  .debt-payment-panel {
    scroll-margin-top: 72px;
  }
  .sale-detail-modal .cards {
    grid-template-columns: 1fr;
  }
  .sale-detail-modal .grid.two {
    grid-template-columns: 1fr;
  }
  .actions-cell {
    min-width: 160px;
  }
  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }
}

/* Dashboard compacto y auditable */
#dashboardView .panel {
  min-height: 0;
}

#dashboardView .chart-panel {
  max-height: 360px;
  overflow: hidden;
}

#dashboardView .chart-panel > .viz-bars,
#dashboardView .chart-panel > .insight-list,
#dashboardView .chart-panel > .donut-wrap,
#dashboardView #lowStock .chart-panel {
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

#dashboardView #patientsByStatus .chart-panel {
  max-height: 300px;
}

#dashboardView #recentSales .insight-list,
#dashboardView #documentAlerts .insight-list,
#dashboardView #noDispenseAlerts .insight-list {
  max-height: 230px;
  overflow-y: auto;
}

#dashboardView #lowStock {
  display: grid;
  gap: 14px;
}

#dashboardView #lowStock .chart-panel {
  max-height: 320px;
}

#dashboardCards {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

#dashboardCards .card .value {
  font-size: clamp(1.35rem, 2vw, 2.05rem);
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  #dashboardView .grid.two {
    grid-template-columns: 1fr;
  }
  #dashboardView .chart-panel {
    max-height: 340px;
  }
}

@media print {
  body { background: white; color: black; }
  .topbar, .tabs, .section-head, .panel:not(.ticket-panel), button { display: none !important; }
  main { margin-left: 0; }
  .view { display: block; }
  .ticket-panel { display: block; box-shadow: none; border: 0; }
  .ticket { color: black; background: white; border: 0; }
}

@media (max-width: 420px) {
  main, .topbar, .tabs {
    padding-left: 12px;
    padding-right: 12px;
  }
  h1 { font-size: 23px; }
  .eyebrow { font-size: 11px; }
  input, select, textarea {
    padding: 10px;
  }
  table {
    min-width: 600px;
  }
}

/* Navegacion jerarquica JAUS OS */
.tabs .nav-group {
  display: grid;
  gap: 4px;
  width: 100%;
  border-radius: 14px;
  transition: background .22s ease, box-shadow .22s ease;
}

.tabs .nav-group > button[data-view] {
  display: none;
}

.tabs .nav-group.is-open > button[data-view]:not(.hidden) {
  display: block;
  animation: navItemIn .22s cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes navItemIn {
  from { opacity: 0; transform: translateY(-7px) scale(.985); }
  to { opacity: 1; transform: translateY(0); }
}

.tabs .nav-group + .nav-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.tabs .nav-group-label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .025), transparent 82%);
  color: rgba(243, 251, 245, .72);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  box-shadow: inset 3px 0 0 transparent;
  transform: none;
  transition:
    color .2s ease,
    background .2s ease,
    border-color .2s ease,
    box-shadow .2s ease;
}

.tabs .nav-group-label::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: .8;
  transition: transform .22s ease, color .2s ease, opacity .2s ease;
}

.tabs .nav-group-label:hover,
.tabs .nav-group-label:focus-visible {
  color: #fff;
  background: linear-gradient(90deg, rgba(184, 240, 84, .09), rgba(255,255,255,.035));
  border-color: rgba(184, 240, 84, .22);
  box-shadow: inset 3px 0 0 rgba(184, 240, 84, .55);
  transform: none;
}

.tabs .nav-group.is-open .nav-group-label {
  color: #d7ff8b;
  border-color: rgba(184, 240, 84, .3);
  background: linear-gradient(90deg, rgba(184, 240, 84, .14), rgba(184, 240, 84, .025) 78%);
  box-shadow:
    inset 3px 0 0 var(--brand),
    0 8px 22px rgba(0, 0, 0, .12);
}

.tabs .nav-group.is-open .nav-group-label::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.tabs .nav-group button[data-view] {
  margin-top: 0;
  color: rgba(243, 251, 245, .82);
  background: rgba(255, 255, 255, .025);
  border-color: rgba(255, 255, 255, .035);
}

.tabs .nav-group button[data-view]:hover:not(.active) {
  color: #fff;
  border-color: rgba(184, 240, 84, .18);
  background: rgba(184, 240, 84, .065);
}

.tabs .nav-group button[data-view].active {
  color: #10170d;
  font-weight: 900;
  border-color: rgba(215, 255, 139, .82);
  background: linear-gradient(135deg, #caff62, #8fe55b);
  box-shadow:
    0 10px 24px rgba(184, 240, 84, .18),
    inset 0 1px 0 rgba(255, 255, 255, .42);
}

.tabs .nav-group button[data-view]::before {
  display: none;
  content: none;
}

.dashboard-subsection {
  display: grid;
  gap: 16px;
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid rgba(184, 240, 84, .2);
}

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border: 1px solid rgba(184, 240, 84, .18);
  border-radius: 24px;
  background:
    radial-gradient(circle at 90% 10%, rgba(184, 240, 84, .12), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018));
  box-shadow: var(--shadow-soft);
}

.subsection-head p {
  margin: 4px 0 0;
}

#realityDollarSection .panel {
  min-height: auto;
}

@media (max-width: 860px) {
  .tabs .nav-group {
    display: grid;
    flex: 0 0 auto;
    width: min(78vw, 280px);
    gap: 6px;
  }

  .tabs .nav-group + .nav-group {
    margin-top: 0;
    padding-top: 0;
    padding-left: 8px;
    border-top: 0;
    border-left: 1px solid rgba(255, 255, 255, .1);
  }

  .tabs .nav-group-label {
    display: flex;
    width: 100%;
    min-width: max-content;
    min-height: 44px;
    border-color: rgba(255,255,255,.1);
    background: rgba(255,255,255,.045);
  }

  .tabs .nav-group.is-open > button[data-view]:not(.hidden) {
    display: block;
    width: 100%;
  }

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

@media (prefers-reduced-motion: reduce) {
  .tabs .nav-group,
  .tabs .nav-group-label,
  .tabs .nav-group-label::after,
  .tabs .nav-group.is-open > button[data-view]:not(.hidden) {
    animation: none;
    transition: none;
  }
}

/* Fase 1 UX completa - capa POS/Restobar operativa */
.tabs button[data-view="dashboard"],
.tabs button[data-view="patients"],
.tabs button[data-view="catalog"],
.tabs button[data-view="dollar"],
.tabs button[data-view="terpscoins"],
.tabs button[data-view="settings"] {
  margin-top: 16px;
}

.tabs button[data-view="dashboard"]::before,
.tabs button[data-view="patients"]::before,
.tabs button[data-view="catalog"]::before,
.tabs button[data-view="dollar"]::before,
.tabs button[data-view="terpscoins"]::before,
.tabs button[data-view="settings"]::before {
  display: block;
  margin-bottom: 8px;
  color: rgba(243, 251, 245, .46);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.tabs button[data-view="dashboard"]::before { content: "Operativa"; }
.tabs button[data-view="patients"]::before { content: "Pacientes"; }
.tabs button[data-view="catalog"]::before { content: "Productos"; }
.tabs button[data-view="dollar"]::before { content: "Analisis"; }
.tabs button[data-view="terpscoins"]::before { content: "Fidelizacion"; }
.tabs button[data-view="settings"]::before { content: "Sistema"; }

#dashboardView .grid:first-of-type .panel,
#dashboardView .grid:nth-of-type(2) .panel,
#dashboardView .grid:nth-of-type(3) .panel {
  min-height: 280px;
}

#dashboardView #lowStock h3 {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

#posView .grid.wide-left {
  grid-template-columns: minmax(0, 1.5fr) minmax(330px, .75fr);
  align-items: start;
}

#posView .panel:first-of-type {
  display: grid;
  gap: 14px;
}

#saleForm {
  padding: 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  background: rgba(255,255,255,.035);
}

.patient-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.patient-search-row button {
  width: auto;
  min-width: 92px;
}

.manual-discount-compact {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(90px, .7fr);
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.manual-discount-compact label { font-size: 11px; }
.manual-discount-compact input { min-height: 38px; padding: 8px 10px; }
.manual-discount-compact .small { grid-column: 1 / -1; color: var(--brand); }

#saleItemSelect {
  opacity: .88;
}

.product-grid {
  max-height: 430px;
  overflow: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
}

.pos-product-tools {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 18px;
  background: rgba(10,14,13,.96);
  backdrop-filter: blur(12px);
}

.pos-category-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pos-product-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.pos-product-result-count {
  min-width: 92px;
  padding: 9px 11px;
  border: 1px solid rgba(181, 255, 77, .22);
  border-radius: 12px;
  background: rgba(181, 255, 77, .08);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.chip {
  width: auto;
  min-height: 34px;
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 999px;
  background: rgba(255,255,255,.045);
  color: var(--muted);
  box-shadow: none;
  font-size: 12px;
}

.chip.active {
  color: #0f170d;
  border-color: rgba(199,255,94,.66);
  background: linear-gradient(135deg, var(--brand), #92e85a);
}

.product-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.pos-product-section { margin: 14px 0 20px; }
.pos-product-section > h4 {
  margin: 0 0 9px;
  color: var(--brand);
  font-size: 12px;
  letter-spacing: .12em;
}

.cart-quantity {
  display: grid;
  grid-template-columns: 38px 64px 38px 38px;
  gap: 6px;
  align-items: center;
}

.cart-quantity button,
.cart-quantity input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 6px;
  text-align: center;
}

.cart-remove { font-size: 19px; }

.product-card {
  width: 100%;
  min-height: 118px;
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-areas:
    "avatar meta"
    "avatar price";
  gap: 8px 12px;
  align-items: center;
  text-align: left;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 20px;
  padding: 14px;
  color: var(--text);
  background:
    radial-gradient(circle at 100% 0, rgba(199,255,94,.13), transparent 34%),
    rgba(255,255,255,.04);
  box-shadow: none;
}

.product-card:hover {
  border-color: rgba(199,255,94,.36);
  background:
    radial-gradient(circle at 100% 0, rgba(199,255,94,.20), transparent 38%),
    rgba(255,255,255,.055);
}

.product-avatar {
  grid-area: avatar;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #0b1209;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-weight: 950;
  letter-spacing: -.04em;
}

.product-image {
  grid-area: avatar;
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}

.product-card.has-image {
  grid-template-columns: 72px 1fr;
  min-height: 136px;
}

.catalog-thumb {
  width: 54px;
  height: 54px;
  object-fit: contain;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: var(--brand);
  font-weight: 950;
}

.catalog-thumb.placeholder {
  align-items: center;
  justify-content: center;
}

.catalog-image-editor {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.03);
}

.catalog-image-editor .catalog-thumb {
  width: 82px;
  height: 82px;
}

.catalog-image-editor input[type="file"] {
  margin: 8px 8px 8px 0;
  max-width: 100%;
}

.catalog-price-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(197, 255, 71, .04);
}

.product-meta {
  grid-area: meta;
  display: grid;
  gap: 4px;
}

.product-meta strong {
  font-size: 15px;
  line-height: 1.15;
}

.product-meta small {
  color: var(--muted);
  font-size: 12px;
}

.product-price {
  grid-area: price;
  color: var(--brand);
  font-size: 16px;
  font-weight: 950;
}

.cart-empty {
  margin: 4px 0;
  text-align: center;
}

.cart-list {
  display: grid;
  gap: 10px;
}

.cart-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  background: rgba(255,255,255,.04);
}

.cart-item strong {
  display: block;
}

.cart-item span,
.cart-item small {
  color: var(--muted);
  font-size: 12px;
}

.cart-item-numbers {
  min-width: 155px;
  text-align: right;
}

.cart-item-numbers strong {
  color: var(--brand);
  font-size: 18px;
}

.ticket-panel {
  position: sticky;
  top: 104px;
}

#ticketPreview:empty::before {
  content: "El comprobante aparecera al registrar la operacion.";
  color: #536053;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

#patientsView .grid.wide-left,
#catalogView .grid.wide-left {
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, .95fr);
}

#patientsTable table,
#documentsConsultTable table,
#catalogTable table,
#stockTable table,
#salesTable table {
  min-width: 680px;
}

#salesTable.panel {
  padding: 14px;
}

#cashClosingOutput .cards,
#patientReportOutput .cards {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

#reportsOutput .panel,
#cashClosingOutput .panel,
#patientReportOutput .panel {
  margin-bottom: 18px;
}

#reportsOutput .table-scroll,
#cashClosingOutput .table-scroll,
#patientReportOutput .table-scroll,
#salesTable .table-scroll,
#settingsPanel .table-scroll {
  max-height: min(58vh, 560px);
}

#documentsView .cards {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.documents-toolbar {
  align-items: stretch;
}

.documents-toolbar input {
  flex: 1 1 360px;
}

.documents-toolbar select {
  flex: 0 1 260px;
}

.alert-grid {
  align-items: start;
}

.alert-list-panel {
  min-height: 260px;
}

.alert-card-list {
  display: grid;
  gap: 10px;
  max-height: min(48vh, 520px);
  overflow: auto;
  padding-right: 4px;
}

.alert-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
}

.alert-card strong,
.doc-editor-card strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.alert-card span,
.doc-editor-card span {
  color: var(--muted);
  font-size: 12px;
}

.alert-card p {
  margin: 0;
  color: var(--text);
}

.alert-card.warn {
  border-color: rgba(247, 201, 72, .35);
  background: linear-gradient(135deg, rgba(247, 201, 72, .09), rgba(255,255,255,.025));
}

.alert-card.danger {
  border-color: rgba(255, 107, 107, .38);
  background: linear-gradient(135deg, rgba(255, 107, 107, .10), rgba(255,255,255,.025));
}

.alert-card.ok {
  border-color: rgba(97, 211, 148, .32);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid rgba(184, 240, 84, .18);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0,0,0,.18);
  font-size: 11px;
  font-weight: 800;
}

.mini-chip.ok {
  color: var(--ok);
}

.documents-editor-panel {
  margin-top: 16px;
}

.doc-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  max-height: min(68vh, 760px);
  overflow: auto;
  padding-right: 4px;
}

.doc-editor-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.035);
}

.doc-editor-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.doc-field-grid label,
.doc-alert-note {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.doc-field-grid select,
.doc-alert-note input {
  width: 100%;
}

#reportsOutput .detail-panel .table-scroll {
  max-height: min(66vh, 680px);
}

#reportsOutput .report-scroll-panel .table-scroll {
  max-height: min(62vh, 620px);
  overflow: auto;
}

#reportsOutput .chart-panel .viz-bars {
  max-height: min(58vh, 560px);
  overflow: auto;
  padding-right: 4px;
}

.modal-card .table-scroll {
  max-height: min(42vh, 380px);
}

.sale-detail-modal .grid.two {
  align-items: start;
}

.sale-detail-modal .panel.table-panel {
  max-height: min(56vh, 520px);
}

.report-console {
  display: grid;
  gap: 18px;
}

.report-head {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(185, 255, 102, .08), rgba(255,255,255,.025));
}

.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi-card.ok .value {
  color: var(--ok);
}

.kpi-card.warn .value {
  color: var(--warn);
}

.kpi-title-row,
.chart-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title-with-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-slot {
  min-width: 0;
}

.dashboard-slot > div,
.dashboard-slot .chart-panel {
  height: 100%;
}

.chart-title-row h3 {
  min-width: 0;
}

.metric-info {
  position: relative;
  z-index: 4;
  display: inline-grid;
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  place-items: center;
  border: 1px solid rgba(199, 255, 94, .42);
  border-radius: 50%;
  background: rgba(199, 255, 94, .08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: help;
  outline: none;
}

.metric-info:focus,
.metric-info:hover {
  border-color: var(--accent);
  background: rgba(199, 255, 94, .18);
  box-shadow: 0 0 0 3px rgba(199, 255, 94, .10);
}

.metric-tooltip {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  z-index: 30;
  display: none;
  width: min(330px, 78vw);
  padding: 12px 14px;
  border: 1px solid rgba(199, 255, 94, .28);
  border-radius: 13px;
  background: #111916;
  color: #dce9e1;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  transform: translateX(-18px);
  pointer-events: none;
}

.metric-tooltip strong {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 12px;
}

.metric-info:hover .metric-tooltip,
.metric-info:focus .metric-tooltip,
.metric-info:focus-within .metric-tooltip {
  display: block;
}

.chart-panel {
  min-height: 280px;
  overflow: visible;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.chart-head h3 {
  margin: 0 0 4px;
}

.chart-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

button.compact {
  padding: 8px 11px;
  min-height: 0;
  white-space: nowrap;
}

.viz-bars {
  display: grid;
  gap: 10px;
}

.viz-bar-row {
  display: grid;
  grid-template-columns: 28px minmax(140px, .9fr) minmax(140px, 1.6fr) 118px;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.045);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.viz-rank {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(185, 255, 102, .12);
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.viz-label {
  color: var(--text);
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viz-track {
  height: 13px;
  border-radius: 999px;
  background: rgba(0,0,0,.35);
  border: 1px solid var(--line);
  overflow: hidden;
}

.viz-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  box-shadow: 0 0 22px rgba(185, 255, 102, .18);
}

.viz-bar-row strong {
  text-align: right;
  color: var(--brand);
}

.stacked-metric {
  display: grid;
  gap: 16px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 18px;
  align-items: center;
}

.donut-chart {
  width: min(220px, 100%);
  aspect-ratio: 1;
  border-radius: 999px;
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 16px 40px rgba(0,0,0,.24);
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: inherit;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.08);
}

.donut-chart span {
  position: relative;
  z-index: 1;
  max-width: 62%;
  text-align: center;
  color: var(--text);
  font-size: clamp(14px, 1.4vw, 20px);
  font-weight: 950;
  line-height: 1.05;
}

.donut-legend {
  display: grid;
  gap: 8px;
}

.donut-legend div {
  display: grid;
  grid-template-columns: 12px minmax(100px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.045);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}

.donut-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.cash-alert.ok {
  border-color: rgba(97, 211, 148, .38);
  background: rgba(97, 211, 148, .08);
}

.cash-alert.warn {
  border-color: rgba(247, 201, 72, .42);
  background: rgba(247, 201, 72, .08);
}

.stacked-track {
  display: flex;
  height: 24px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.28);
}

.stacked-track span {
  min-width: 2px;
}

.seg-0 { background: #b9ff66; }
.seg-1 { background: #58d68d; }
.seg-2 { background: #f8c471; }
.seg-3 { background: #85c1e9; }
.seg-4 { background: #d7b4ff; }
.seg-5 { background: #ff8f7a; }

.stacked-legend {
  display: grid;
  gap: 8px;
}

.stacked-legend div {
  display: grid;
  grid-template-columns: 12px minmax(120px, 1fr) auto 54px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.stacked-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.stacked-legend strong {
  color: var(--text);
}

.stacked-legend small {
  text-align: right;
  color: var(--brand);
}

.line-chart-wrap {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  background: radial-gradient(circle at 20% 0%, rgba(185,255,102,.08), transparent 32%);
}

.line-chart {
  width: 100%;
  min-height: 220px;
}

.line-area {
  fill: rgba(185,255,102,.09);
  stroke: none;
}

.line-stroke {
  fill: none;
  stroke: var(--brand);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgba(185,255,102,.24));
}

.line-chart circle {
  fill: var(--brand);
  stroke: #142014;
  stroke-width: 2;
}

.line-axis {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 6px 4px;
}

.line-axis strong {
  color: var(--brand);
}

.insight-list {
  display: grid;
  gap: 10px;
}

.insight-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.045);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.insight-item strong {
  color: var(--text);
}

.insight-item span {
  color: var(--muted);
  text-align: right;
  font-size: 13px;
}

.detail-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 14px;
}

.detail-panel summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--brand);
}

#settingsPanel.panel {
  max-width: 1180px;
}

@media (max-width: 1000px) {
  .tabs button[data-view] {
    margin-top: 0;
  }
  .tabs button[data-view]::before {
    display: none;
  }
  #posView .grid.wide-left,
  #patientsView .grid.wide-left,
  #catalogView .grid.wide-left {
    grid-template-columns: 1fr;
  }
  .ticket-panel {
    position: relative;
    top: auto;
  }
}

@media (max-width: 680px) {
  .product-grid {
    max-height: none;
  }
  .product-card-grid {
    grid-template-columns: 1fr;
  }
  .cart-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .cart-item-numbers {
    min-width: 0;
    text-align: left;
  }
  .viz-bar-row,
  .stacked-legend div,
  .insight-item {
    grid-template-columns: 1fr;
    display: grid;
    text-align: left;
  }
  .viz-bar-row strong,
  .insight-item span {
    text-align: left;
  }
  .chart-head {
    flex-direction: column;
  }
  .donut-wrap {
    grid-template-columns: 1fr;
  }
  .donut-chart {
    max-width: 220px;
    justify-self: center;
  }
  #reportsOutput .grid.two,
  #cashClosingOutput .grid.two,
  #patientReportOutput .grid.two,
  #documentsView .grid.two,
  .sale-detail-modal .grid.two {
    grid-template-columns: 1fr;
  }
  #reportsOutput .table-scroll,
  #cashClosingOutput .table-scroll,
  #patientReportOutput .table-scroll,
  #salesTable .table-scroll {
    max-height: 64vh;
  }
  .detail-panel {
    overflow: visible;
  }
  .detail-panel summary {
    position: sticky;
    top: 58px;
    z-index: 3;
    background: var(--panel);
    padding: 10px 0;
  }
  .documents-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }
  .doc-editor-grid {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .doc-field-grid {
    grid-template-columns: 1fr;
  }
  .alert-card-list {
    max-height: none;
  }
}

/* Fase responsive/data-viz 2026-07-25: capa global de estabilidad visual */
.view {
  max-width: 100%;
}

.panel,
.card,
.chart-panel,
.table-scroll,
.modal-card,
.ticket,
.muted-box {
  min-width: 0;
}

.section-head .toolbar,
.report-head .toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chart-panel {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.chart-panel > .viz-bars,
.chart-panel > .insight-list,
.chart-panel > .donut-wrap,
.chart-panel > .stacked-metric {
  min-height: 0;
}

.chart-panel .viz-bars {
  max-height: min(56vh, 560px);
  overflow: auto;
  padding-right: 4px;
}

.chart-panel .insight-list {
  max-height: min(50vh, 460px);
  overflow: auto;
  padding-right: 4px;
}

.viz-bar-row {
  grid-template-columns: 30px minmax(160px, 1fr) minmax(160px, 2fr) minmax(92px, auto);
}

.viz-label {
  white-space: normal;
  line-height: 1.25;
}

.donut-wrap {
  min-width: 0;
}

.donut-legend {
  max-height: min(42vh, 360px);
  overflow: auto;
  padding-right: 4px;
}

.table-panel > h3,
.panel.table-panel > h3,
.report-scroll-panel > h3 {
  position: sticky;
  left: 0;
}

#cashClosingOutput .grid.two,
#reportsOutput .grid.two,
#terpscoinsOutput .grid.two,
#patientReportOutput .grid.two,
#documentsView .grid.two,
#stockView .grid.two,
#expensesView .grid.two {
  align-items: start;
}

#cashSessionsOutput .table-scroll,
#cashClosingOutput .table-scroll,
#reportsOutput .table-scroll,
#terpscoinsOutput .table-scroll,
#patientReportOutput .table-scroll,
#salesTable .table-scroll,
#stockMovementsTable .table-scroll,
#expensesTable .table-scroll,
#documentsTable .table-scroll,
#documentsConsultTable .table-scroll,
#dispenseAlertsTable .table-scroll,
#patientsTable .table-scroll,
#catalogTable .table-scroll,
#stockTable .table-scroll {
  max-height: min(64vh, 680px);
}

/* Cash workspace: one compact, navigable stream instead of parallel wide tables. */
.compact-btn,
.cash-action-btn {
  min-width: 0 !important;
  width: auto;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.1;
}

.cash-workspace {
  padding: 14px;
  overflow: visible;
}

.cash-collapsible {
  overflow: visible;
}

.cash-collapsible > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  min-height: 40px;
  padding: 2px 0;
}

.cash-collapsible > summary::-webkit-details-marker {
  display: none;
}

.cash-collapsible > summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(189, 255, 79, .1);
  color: var(--accent);
  font-weight: 800;
  flex: 0 0 auto;
}

.cash-collapsible[open] > summary::before {
  content: "−";
}

.cash-collapsible > summary span {
  font-weight: 750;
}

.cash-collapsible > summary small {
  color: var(--muted);
}

.cash-open-control {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.cash-open-toolbar,
.cash-report-toolbar,
.cash-collapsible-body {
  margin-top: 12px;
}

.cash-closing-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.cash-closing-kpis .cash-card-total {
  border-color: rgba(185, 255, 102, .28);
}

.cash-closing-kpis .cash-card-total .value {
  color: var(--accent);
}

.cash-closing-kpis .cash-card-accent {
  border-color: rgba(255, 211, 106, .32);
  background: rgba(255, 211, 106, .05);
}

.cash-closing-kpis .cash-card-accent .value {
  color: #ffd36a;
}

.cash-abono-focus {
  display: grid;
  gap: 14px;
}

.cash-abono-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.cash-abono-head span {
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
}

.cash-abono-head h2 {
  margin: 4px 0;
  font-size: 20px;
}

.cash-abono-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.cash-abono-head > strong {
  color: #ffd36a;
  font-size: clamp(25px, 3vw, 36px);
}

.cash-abono-list {
  display: grid;
  gap: 9px;
}

.cash-abono-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .025);
}

.cash-abono-patient {
  display: grid;
  gap: 3px;
}

.cash-abono-patient > span {
  color: var(--accent);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
}

.cash-abono-patient h3 {
  margin: 0;
  font-size: 14px;
}

.cash-abono-patient small {
  color: var(--muted);
  font-size: 10px;
}

.cash-abono-amount {
  color: #ffd36a;
  font-size: 22px;
  white-space: nowrap;
}

.cash-abono-status {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 900;
  white-space: nowrap;
}

.cash-abono-status.ok {
  color: #b9ff66;
  background: rgba(185, 255, 102, .08);
  border: 1px solid rgba(185, 255, 102, .22);
}

.cash-abono-status.review {
  color: #ffd36a;
  background: rgba(255, 211, 106, .08);
  border: 1px solid rgba(255, 211, 106, .22);
}

.cash-abono-detail {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(255, 255, 255, .06);
  padding-top: 8px;
}

.cash-abono-detail summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.cash-abono-detail > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0 5px;
}

.cash-abono-detail > div span {
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(185, 255, 102, .07);
  color: var(--accent);
  font-size: 8px;
}

.cash-abono-detail > small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.cash-empty-compact {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.cash-detail-section {
  margin-top: 10px;
}

.cash-detail-section .cash-collapsible-body {
  display: grid;
  gap: 12px;
}

.cash-detail-section .table-panel {
  padding: 0;
}

.cash-browser-head,
.cash-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cash-browser-head h3,
.cash-browser-head p {
  margin: 0;
}

.cash-browser-head p,
.cash-pagination {
  color: var(--muted);
  font-size: 12px;
}

.cash-filterbar {
  display: grid;
  grid-template-columns: minmax(130px, .75fr) minmax(150px, 1fr) minmax(120px, .7fr) minmax(210px, 1.35fr);
  gap: 8px;
  margin: 14px 0 10px;
}

.cash-filterbar label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cash-filterbar input,
.cash-filterbar select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 9px;
  font-size: 13px;
}

.cash-session-list {
  display: grid;
  gap: 7px;
}

.cash-session-row {
  display: grid;
  grid-template-columns: minmax(140px, .9fr) minmax(150px, 1fr) minmax(145px, .9fr) minmax(175px, 1.1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .018);
}

.cash-session-row.is-open {
  border-color: rgba(189, 255, 79, .34);
  background: rgba(189, 255, 79, .045);
}

.cash-session-identity,
.cash-session-owner,
.cash-session-status,
.cash-session-money {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.cash-session-row strong,
.cash-session-row span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cash-session-row span {
  color: var(--muted);
  font-size: 11px;
}

.cash-session-money strong {
  font-size: 14px;
}

.cash-file-state {
  position: relative;
  padding-left: 11px;
}

.cash-file-state::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
}

.cash-file-state.ok { color: #9ee37d; }
.cash-file-state.error { color: #ff8c8c; }
.cash-file-state.pending { color: #f2cc60; }

.cash-session-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.cash-action-btn.primary {
  background: var(--accent);
  color: #0a120d;
}

.cash-row-menu {
  position: relative;
}

.cash-row-menu > summary {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  letter-spacing: 2px;
}

.cash-row-menu > summary::-webkit-details-marker { display: none; }

.cash-row-menu-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  right: 0;
  display: grid;
  width: 210px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  box-shadow: 0 16px 35px rgba(0, 0, 0, .35);
}

.cash-row-menu-popover button {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
}

.cash-row-menu-popover button:hover {
  background: rgba(189, 255, 79, .08);
}

.cash-pagination {
  margin-top: 12px;
}

.cash-pagination > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* POS · Venta asistida: flujo único, legible y con cierre siempre visible. */
#posView {
  --pos-accent: var(--brand);
  --pos-soft: rgba(199, 255, 94, .09);
  --pos-border: rgba(255, 255, 255, .105);
}

#posView .pos-page-head {
  margin-bottom: 12px;
}

#posView .pos-page-head h2,
#posView .pos-page-head p {
  margin-bottom: 0;
}

.pos-operation-bar {
  display: grid;
  grid-template-columns: minmax(320px, 1.6fr) repeat(3, minmax(135px, .62fr));
  gap: 9px;
  align-items: stretch;
  margin-bottom: 10px;
}

.pos-operation-bar > div {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--pos-border);
  border-radius: 15px;
  background: rgba(255, 255, 255, .035);
}

.pos-operation-bar > div > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pos-operation-bar > div > strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pos-operation-bar .cash-alert {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
}

.pos-stepper {
  position: sticky;
  top: 8px;
  z-index: 18;
  display: grid;
  grid-template-columns: repeat(6, minmax(112px, 1fr));
  gap: 6px;
  margin: 0 0 14px;
  padding: 7px;
  border: 1px solid var(--pos-border);
  border-radius: 17px;
  background: rgba(9, 15, 12, .93);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .24);
  backdrop-filter: blur(14px);
}

.pos-stepper a {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 36px;
  padding: 5px 8px;
  border-radius: 11px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}

.pos-stepper a:hover,
.pos-stepper a.is-complete {
  color: var(--text);
  background: var(--pos-soft);
}

.pos-stepper a b {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid var(--pos-border);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, .045);
}

.pos-stepper a.is-complete b {
  color: #0d150a;
  border-color: var(--pos-accent);
  background: var(--pos-accent);
}

.pos-assisted-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 350px);
  gap: 14px;
  align-items: start;
}

.pos-assisted-flow,
.pos-assisted-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}

#saleForm.pos-assisted-form {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#posView .pos-stage {
  scroll-margin-top: 72px;
  padding: 16px;
  border-color: var(--pos-border);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .042), rgba(255, 255, 255, .022));
}

.pos-stage-head {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  margin-bottom: 13px;
}

.pos-stage-head > span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 11px;
  color: #0c1509;
  background: linear-gradient(135deg, var(--pos-accent), var(--brand-2));
  font-size: 14px;
  font-weight: 950;
}

.pos-stage-head > div {
  min-width: 0;
  flex: 1;
}

.pos-stage-head h3,
.pos-stage-head p {
  margin: 0;
}

.pos-stage-head h3 {
  font-size: 18px;
}

.pos-stage-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.pos-stage-head > strong {
  color: var(--pos-accent);
  font-size: 12px;
  white-space: nowrap;
}

.pos-patient-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.pos-patient-search label,
.pos-patient-selector,
.pos-primary-parameters label,
.pos-adjustment-grid label,
.pos-payment-adder label,
.pos-quick-add label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

#posView input,
#posView select,
#posView textarea {
  font-size: 14px;
}

.pos-patient-selector {
  margin: 9px 0;
}

.pos-patient-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 84px;
  padding: 12px;
  border: 1px solid rgba(199, 255, 94, .25);
  border-radius: 17px;
  background: var(--pos-soft);
}

.pos-patient-avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  color: #0b1408;
  background: var(--pos-accent);
  font-weight: 950;
}

.pos-patient-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pos-patient-copy > span,
.pos-patient-copy > small {
  color: var(--muted);
  font-size: 11px;
}

.pos-patient-copy > strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pos-patient-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.pos-patient-badges em,
.product-meta em {
  width: max-content;
  padding: 3px 7px;
  border: 1px solid var(--pos-border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .035);
  font-size: 9px;
  font-style: normal;
  font-weight: 850;
  text-transform: uppercase;
}

.pos-patient-badges em.warn,
.product-meta em.warn {
  color: #ffd98a;
  border-color: rgba(255, 209, 102, .3);
  background: rgba(255, 209, 102, .08);
}

.product-meta em.ok {
  color: #9ce69b;
  border-color: rgba(123, 235, 136, .25);
  background: rgba(123, 235, 136, .07);
}

.pos-patient-empty,
.pos-empty-state {
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, .16);
  border-radius: 15px;
  color: var(--muted);
  text-align: center;
}

.pos-primary-parameters {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(135px, .8fr));
  gap: 9px;
}

.pos-primary-parameters > div {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--pos-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, .025);
}

.pos-primary-parameters > div span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.pos-primary-parameters > div strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pos-operation-adjustments {
  margin-top: 10px;
  border: 1px solid var(--pos-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, .02);
}

.pos-operation-adjustments summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 9px 11px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.pos-operation-adjustments summary small {
  color: var(--muted);
  font-weight: 600;
}

.pos-adjustment-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(180px, .9fr);
  gap: 9px;
  padding: 0 10px 10px;
}

.pos-adjustment-grid .full {
  grid-column: 1 / -1;
}

#posView .manual-discount-compact {
  padding: 6px;
}

.pos-quick-add {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 90px auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}

.pos-quick-add > button,
.pos-patient-search > button,
.pos-payment-adder > button {
  width: auto;
  min-height: 42px;
}

#posView .product-grid {
  max-height: 510px;
  padding-right: 4px;
}

#posView .pos-product-tools {
  grid-template-columns: minmax(190px, 1fr);
  padding: 8px;
  border-radius: 14px;
}

#posView .pos-product-tools .pos-category-chips {
  grid-column: 1 / -1;
}

@media (max-width: 560px) {
  .pos-product-search-row {
    grid-template-columns: 1fr;
  }

  .pos-product-result-count {
    justify-self: start;
  }
}

#posView .product-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 9px;
}

#posView .product-card,
#posView .product-card.has-image {
  grid-template-columns: 52px minmax(0, 1fr) auto;
  grid-template-areas: "avatar meta add" "avatar price add";
  min-height: 100px;
  padding: 11px;
  border-radius: 16px;
}

#posView .product-card.is-filtered-out {
  display: none !important;
}

#posView .product-image,
#posView .product-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

#posView .product-meta strong {
  font-size: 14px;
}

#posView .product-meta small {
  font-size: 10px;
}

.pos-product-add {
  grid-area: add;
  align-self: center;
  width: auto;
  min-width: 68px;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid rgba(199, 255, 94, .3);
  border-radius: 10px;
  color: var(--pos-accent);
  background: rgba(199, 255, 94, .08);
  font-size: 11px;
}

#posView .cart-item {
  min-height: 68px;
  padding: 10px 11px;
  border-radius: 14px;
}

#posView .cart-item-numbers strong {
  font-size: 16px;
}

#posView .split-account {
  margin-bottom: 9px;
  padding: 10px;
}

#posView .split-grid {
  grid-template-columns: repeat(5, minmax(105px, 1fr));
  gap: 6px;
}

#posView .split-grid span {
  min-height: 58px;
  padding: 8px;
  font-size: 10px;
}

#posView .split-grid strong {
  font-size: 15px;
}

.pos-payment-list {
  display: grid;
  gap: 7px;
  margin-bottom: 9px;
}

.pos-payment-row {
  display: grid;
  grid-template-columns: 28px minmax(150px, 1fr) minmax(135px, auto) auto;
  gap: 9px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--pos-border);
  border-radius: 13px;
  background: rgba(255, 255, 255, .03);
}

.pos-payment-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  color: #0b1408;
  background: var(--pos-accent);
  font-size: 11px;
  font-weight: 950;
}

.pos-payment-row > div,
.pos-payment-amount {
  display: grid;
  gap: 2px;
}

.pos-payment-row small {
  color: var(--muted);
  font-size: 10px;
}

.pos-payment-amount {
  text-align: right;
}

.pos-payment-row button {
  width: auto;
  min-height: 32px;
  padding: 5px 8px;
  font-size: 10px;
}

.pos-payment-adder {
  display: grid;
  grid-template-columns: minmax(115px, .8fr) 90px minmax(120px, .8fr) minmax(170px, 1fr) auto;
  gap: 7px;
  align-items: end;
}

#posStageConfirmation .ticket {
  max-height: 430px;
  min-height: 115px;
  overflow: auto;
  font-size: 12px;
}

.pos-sticky-summary {
  position: sticky;
  top: 64px;
  display: grid;
  gap: 9px;
}

.pos-sticky-summary > .panel {
  padding: 13px;
}

.pos-summary-label {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.pos-sticky-patient {
  display: grid;
  gap: 3px;
  min-height: 38px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--pos-border);
  color: var(--muted);
  font-size: 12px;
}

.pos-sticky-patient strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pos-sticky-patient span {
  color: var(--muted);
  font-size: 10px;
}

.pos-summary-metrics,
.pos-sticky-payment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.pos-summary-metrics span,
.pos-sticky-payment span {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
}

.pos-summary-metrics strong,
.pos-sticky-payment strong {
  color: var(--text);
  font-size: 13px;
}

#posView .quote-total {
  display: grid;
  gap: 5px;
  min-height: 112px;
  padding: 16px;
  border-color: rgba(199, 255, 94, .32);
  border-radius: 19px;
  background: linear-gradient(145deg, rgba(199, 255, 94, .15), rgba(199, 255, 94, .035));
}

#posView .quote-total span {
  font-size: 11px;
}

#posView .quote-total strong {
  align-self: end;
  font-size: clamp(30px, 3vw, 42px);
}

#posView .pos-sticky-payment {
  margin: 0;
}

#posView .pos-actions {
  grid-template-columns: .8fr 1.2fr;
  gap: 7px;
}

#posView .pos-actions button {
  min-height: 46px;
  padding: 8px 10px;
  font-size: 12px;
}

.pos-new-sale {
  min-height: 36px;
  padding: 6px 9px;
  font-size: 11px;
}

.pos-summary-hint {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

@media (max-width: 1180px) {
  .pos-operation-bar { grid-template-columns: 1fr 1fr 1fr; }
  .pos-operation-bar .cash-alert { grid-column: 1 / -1; }
  .pos-assisted-layout { grid-template-columns: 1fr; }
  .pos-sticky-summary {
    position: static;
    grid-template-columns: 1fr 1fr;
  }
  .pos-sticky-summary .pos-actions,
  .pos-sticky-summary .pos-new-sale,
  .pos-sticky-summary .pos-summary-hint { grid-column: 1 / -1; }
  .pos-stepper { overflow-x: auto; grid-template-columns: repeat(6, minmax(125px, 1fr)); }
}

@media (max-width: 760px) {
  .pos-operation-bar { grid-template-columns: 1fr 1fr; }
  .pos-operation-bar .cash-alert { grid-column: 1 / -1; }
  .pos-stepper { position: static; }
  .pos-stepper a span { display: none; }
  .pos-stepper { grid-template-columns: repeat(6, 42px); justify-content: space-between; }
  .pos-stepper a { justify-content: center; padding: 4px; }
  #posView .pos-stage { padding: 13px; }
  .pos-stage-head { align-items: flex-start; }
  .pos-stage-head p { font-size: 11px; }
  .pos-patient-search,
  .pos-primary-parameters,
  .pos-adjustment-grid,
  .pos-quick-add,
  .pos-payment-adder,
  .pos-sticky-summary { grid-template-columns: 1fr; }
  .pos-adjustment-grid .full,
  .pos-sticky-summary .pos-actions,
  .pos-sticky-summary .pos-new-sale,
  .pos-sticky-summary .pos-summary-hint { grid-column: auto; }
  .pos-patient-search > button,
  .pos-quick-add > button,
  .pos-payment-adder > button { width: 100%; }
  #posView .product-grid { max-height: 470px; }
  #posView .product-card-grid { grid-template-columns: 1fr; }
  #posView .split-grid { grid-template-columns: 1fr 1fr; }
  .pos-payment-row { grid-template-columns: 28px 1fr auto; }
  .pos-payment-amount { grid-column: 2; text-align: left; }
  .pos-payment-row button { grid-column: 3; grid-row: 1 / 3; }
  #posView .cart-item { grid-template-columns: 1fr; }
  #posView .cart-item-numbers { text-align: left; }
  #posView .cart-quantity { grid-template-columns: 38px 72px 38px 38px; }
}

@media (max-width: 1100px) {
  .cash-closing-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cash-abono-card {
    grid-template-columns: 1fr auto;
  }
  .cash-abono-status {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .cash-session-row {
    grid-template-columns: minmax(140px, 1fr) minmax(150px, 1fr) minmax(145px, 1fr) auto;
  }
  .cash-session-money {
    grid-column: 2 / 4;
    grid-row: 2;
  }
  .cash-session-actions {
    grid-column: 4;
    grid-row: 1 / 3;
  }
}

@media (max-width: 760px) {
  .cash-closing-kpis { grid-template-columns: 1fr; }
  .cash-abono-head { display: grid; }
  .cash-abono-card { grid-template-columns: 1fr; }
  .cash-abono-amount { font-size: 20px; }
  .cash-abono-status { grid-column: auto; }
  .cash-filterbar { grid-template-columns: 1fr 1fr; }
  .cash-search-field { grid-column: 1 / -1; }
  .cash-session-row { grid-template-columns: 1fr 1fr; }
  .cash-session-money,
  .cash-session-actions { grid-column: 1 / -1; grid-row: auto; }
  .cash-session-actions { justify-content: flex-start; flex-wrap: wrap; }
  .cash-row-menu-popover { right: auto; left: 0; }
  .cash-browser-head,
  .cash-pagination { align-items: flex-start; flex-direction: column; }
  .cash-collapsible > summary { align-items: flex-start; flex-wrap: wrap; }
  .cash-collapsible > summary small { flex-basis: calc(100% - 34px); margin-left: 34px; }
}

#reportsOutput .report-scroll-panel .table-scroll,
#terpscoinsOutput .report-scroll-panel .table-scroll,
#cashClosingOutput .report-scroll-panel .table-scroll {
  max-height: min(70vh, 760px);
}

.kpi-grid,
#dashboardCards,
#documentsSummary,
#expensesSummary,
#stockMovementSummary {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.card .value,
.kpi-card .value {
  overflow-wrap: anywhere;
}

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

.toolbar input,
.toolbar select,
.toolbar button {
  min-width: 140px;
}

.toolbar input[type="date"] {
  min-width: 150px;
}

.line-chart-wrap {
  overflow: hidden;
}

.line-chart {
  display: block;
  height: auto;
}

.terps-hero-card {
  border-color: rgba(189, 255, 79, .42);
  background:
    radial-gradient(circle at top right, rgba(189,255,79,.18), transparent 42%),
    linear-gradient(135deg, rgba(34,46,27,.96), rgba(10,18,13,.96));
}

.terps-podium-panel {
  overflow: hidden;
}

.terps-podium {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.15fr) minmax(0, .95fr);
  align-items: end;
  gap: 16px;
  margin-top: 12px;
}

.terps-podium-card {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 220px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(189,255,79,.16), transparent 48%),
    linear-gradient(180deg, rgba(31,42,35,.96), rgba(13,20,15,.98));
  box-shadow: 0 18px 40px rgba(0,0,0,.28);
}

.terps-podium-card.rank-1 {
  min-height: 270px;
  border-color: rgba(255, 205, 83, .62);
  background:
    radial-gradient(circle at 50% 0%, rgba(255,205,83,.28), transparent 48%),
    linear-gradient(180deg, rgba(54,47,25,.98), rgba(16,22,13,.98));
}

.terps-podium-card.rank-2 {
  min-height: 238px;
}

.terps-podium-card.rank-3 {
  min-height: 210px;
}

.podium-medal {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #0b120c;
  font-weight: 950;
  font-size: 22px;
  box-shadow: 0 0 0 8px rgba(189,255,79,.12);
}

.terps-podium-card.rank-1 .podium-medal {
  background: #ffd35a;
  box-shadow: 0 0 0 10px rgba(255,211,90,.16);
}

.terps-podium-card h3 {
  margin: 0;
  font-size: clamp(18px, 2vw, 25px);
}

.terps-podium-card strong {
  color: var(--brand);
  font-size: clamp(30px, 4vw, 54px);
  line-height: .95;
}

.terps-podium-card.rank-1 strong {
  color: #ffd35a;
}

.terps-podium-card span {
  color: var(--muted);
}

@media (min-width: 1600px) {
  main {
    max-width: 1720px;
  }
  .grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cards {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}

@media (max-width: 1280px) {
  :root {
    --sidebar-w: 232px;
  }
  .tabs {
    padding-left: 12px;
    padding-right: 12px;
  }
  .sidebar-brand {
    flex: 0 0 auto;
    margin: 0 4px 0 0;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
  }
  .sidebar-brand img {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 50%;
  }
  .sidebar-brand strong { font-size: 12px; }
  .sidebar-brand span { font-size: 9px; }
  .tabs button {
    font-size: 13px;
  }
  main,
  .topbar {
    padding-left: 22px;
    padding-right: 22px;
  }
  .grid.two,
  .grid.wide-left,
  #posView .grid.wide-left,
  #patientsView .grid.wide-left,
  #catalogView .grid.wide-left,
  .debtors-module .grid.two {
    grid-template-columns: 1fr;
  }
  .ticket-panel,
  .debt-payment-panel {
    position: relative;
    top: auto;
  }
}

@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .login-intro {
    padding: 30px;
  }
  .login-intro-copy {
    margin: 42px 0 0;
  }
  .login-intro-copy h1 {
    max-width: 14ch;
    font-size: clamp(38px, 8vw, 58px);
  }
  .login-card {
    order: -1;
    border-top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .topbar-brand { align-items: flex-start; }
  .topbar-brand img { width: 46px; height: 46px; flex-basis: 46px; border-radius: 13px; }
  .login-screen { place-items: start center; padding: 12px; }
  .login-shell { border-radius: 20px; }
  .login-intro { padding: 24px; }
  .login-intro-copy { margin: 32px 0 0; }
  .login-intro-copy h1 { font-size: 40px; }
  .login-flow { grid-template-columns: 1fr; gap: 10px; margin-top: 34px; }
  .login-flow span { grid-template-columns: 30px 1fr; align-items: baseline; }
  .login-card { order: -1; padding: 30px 24px; border-top: 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
  .login-brand img { width: 62px; height: 62px; }
  .patient-search-row { grid-template-columns: 1fr; }
  .patient-search-row button { width: 100%; }
  .manual-discount-compact { grid-template-columns: 1fr 1fr; }
  .cart-item { align-items: stretch; }
  .cart-quantity { grid-template-columns: 42px minmax(64px, 1fr) 42px 42px; }
}

@media (max-width: 860px) {
  body {
    overflow-x: hidden;
  }
  .topbar {
    position: relative;
    margin-left: 0;
    padding: 16px;
  }
  .header-actions {
    justify-content: stretch;
  }
  .header-actions > * {
    flex: 1 1 160px;
  }
  .tabs {
    position: sticky;
    top: 0;
    inset: auto;
    width: auto;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 12px 30px rgba(0,0,0,.26);
  }
  .tabs::before,
  .tabs::after {
    display: none;
  }
  .tabs button {
    width: auto;
    min-width: max-content;
    border-radius: 999px;
  }
  main {
    margin-left: 0;
    padding: 16px;
  }
  .section-head {
    display: grid;
    gap: 14px;
  }
  .section-head .toolbar,
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .toolbar input,
  .toolbar select,
  .toolbar button {
    min-width: 0;
    width: 100%;
  }
  .cards,
  .kpi-grid,
  #dashboardCards,
  #documentsSummary,
  #expensesSummary,
  #stockMovementSummary {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  .chart-head {
    display: grid;
  }
  .chart-head button {
    width: 100%;
  }
  .viz-bar-row {
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-areas:
      "rank label"
      "rank track"
      "rank value";
  }
  .viz-rank { grid-area: rank; }
  .viz-label { grid-area: label; }
  .viz-track { grid-area: track; }
  .viz-bar-row strong {
    grid-area: value;
    text-align: left;
  }
  .donut-wrap {
    grid-template-columns: 1fr;
  }
  .donut-chart {
    justify-self: center;
  }
  .terps-podium {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .terps-podium-card,
  .terps-podium-card.rank-1,
  .terps-podium-card.rank-2,
  .terps-podium-card.rank-3 {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 22px;
  }
  h2 {
    font-size: 21px;
  }
  .section-head,
  .panel,
  .card {
    border-radius: 16px;
  }
  .cards,
  .kpi-grid,
  #dashboardCards,
  #documentsSummary,
  #expensesSummary,
  #stockMovementSummary {
    grid-template-columns: 1fr;
  }
  .card {
    min-height: 104px;
  }
  .card .value {
    font-size: clamp(24px, 11vw, 34px);
    white-space: normal;
  }
  .table-scroll {
    max-height: 66vh;
  }
  table {
    min-width: 680px;
  }
  .donut-legend div {
    grid-template-columns: 12px 1fr;
  }
  .donut-legend strong,
  .donut-legend small {
    grid-column: 2;
    text-align: left;
  }
  .split-grid,
  .detail-grid,
  .settings-grid,
  .doc-field-grid,
  .catalog-price-box,
  .catalog-image-editor,
  .form-grid,
  .line-adder,
  .pos-actions {
    grid-template-columns: 1fr;
  }
  .pos-actions button,
  button {
    width: 100%;
  }
}

.role-permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.permission-checklist {
  display: grid;
  gap: 6px;
  max-height: 300px;
  overflow: auto;
  margin: 12px 0;
  padding-right: 6px;
}

.permission-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

/* Principal BI: estado de resultados y control ejecutivo por periodo. */
.dashboard-filter {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px) auto auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.025);
}

.dashboard-date-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(135px, 1fr));
  gap: 8px;
}

.dashboard-filter label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.dashboard-range-field input { accent-color: var(--brand); }
.dashboard-filter > strong { align-self: center; color: var(--brand); white-space: nowrap; }

#dashboardCards.dashboard-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 14px;
}

/* KPI ejecutivos: importes completos, tarjetas legibles y ayuda sin recortes. */
#dashboardCards .kpi-card {
  min-width: 0;
  min-height: 154px;
  padding: 17px 18px;
  overflow: hidden;
  align-content: initial;
  grid-template-rows: minmax(34px, auto) 1fr auto;
  gap: 9px;
  isolation: isolate;
}

#dashboardCards .kpi-title-row {
  align-items: flex-start;
  gap: 8px;
}

#dashboardCards .kpi-title-row .label {
  min-width: 0;
  color: #d7e4d9;
  font-size: 11px;
  line-height: 1.28;
  letter-spacing: .075em;
  overflow-wrap: normal;
  word-break: normal;
}

#dashboardCards .kpi-card .value {
  align-self: center;
  display: block;
  max-width: 100%;
  color: #f6fff8;
  font-size: clamp(27px, 2.05vw, 36px);
  line-height: 1.05;
  letter-spacing: -.045em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  overflow-wrap: normal;
  word-break: normal;
  font-variant-numeric: tabular-nums;
}

#dashboardCards .kpi-card.kpi-value-long .value {
  font-size: clamp(23px, 1.7vw, 31px);
  letter-spacing: -.055em;
}

#dashboardCards .kpi-card.kpi-value-xl .value {
  font-size: clamp(20px, 1.45vw, 27px);
  letter-spacing: -.06em;
}

#dashboardCards .kpi-card .hint {
  min-height: 30px;
  color: #b6c7ba;
  font-size: 11px;
  line-height: 1.35;
}

#dashboardCards .metric-info {
  flex: 0 0 auto;
  z-index: 1001;
}

#dashboardCards .metric-tooltip {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  z-index: 1000;
  width: min(390px, calc(100vw - 32px));
  max-height: min(70vh, 420px);
  padding: 18px;
  overflow: auto;
  transform: translate(-50%, -50%);
  border-color: rgba(184,240,84,.55);
  background: #16201b;
  box-shadow: 0 30px 90px rgba(0,0,0,.78);
  color: #dce9df;
  line-height: 1.55;
}

#dashboardCards .metric-tooltip strong {
  display: block;
  margin-bottom: 8px;
  color: #c8ff68;
  font-size: 15px;
}

.dashboard-bi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0;
  align-items: stretch;
}

.dashboard-bi-grid > div,
.dashboard-bi-grid .chart-panel { height: 100%; }
.dashboard-bi-grid--hero { grid-template-columns: minmax(300px, .82fr) minmax(460px, 1.48fr); }

.result-statement {
  display: grid;
  gap: 8px;
}

.result-statement > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.result-statement span { color: var(--muted); font-weight: 750; }
.result-statement strong { font-size: clamp(18px, 2vw, 26px); }
.result-statement .positive { color: var(--ok); }
.result-statement .negative { color: var(--warn); }
.result-statement .result-total {
  border-color: rgba(184,240,84,.38);
  background: linear-gradient(135deg, rgba(184,240,84,.14), rgba(97,211,148,.06));
}
.result-statement small { color: var(--muted); line-height: 1.45; }

.flow-chart {
  display: grid;
  gap: 10px;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}
.flow-chart-canvas {
  width: 100%;
  min-height: 230px;
  aspect-ratio: 760 / 250;
}
.flow-chart svg { display: block; width: 100%; height: 100%; min-width: 0; }
.flow-chart text { fill: var(--muted); font-size: 11px; }
.flow-axis { stroke: rgba(255,255,255,.12); }
.flow-grid { stroke: rgba(255,255,255,.075); stroke-width: 1; }
.flow-y-label { font-size: 9px !important; }
.flow-series { vector-effect: non-scaling-stroke; }
.flow-point { cursor: help; transition: r .15s ease, filter .15s ease; }
.flow-point:hover { r: 6px; filter: drop-shadow(0 0 5px rgba(184,240,84,.55)); }
.flow-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.flow-legend span { display: inline-flex; align-items: center; gap: 6px; }
.flow-legend i { width: 9px; height: 9px; border-radius: 50%; }

#dashboardFlowTimeline .chart-panel {
  max-height: none;
  height: 100%;
  overflow: visible;
}

.product-bi-panel { margin: 16px 0; }
.product-bi-panel > .viz-bars { margin-bottom: 16px; }
.category-unit-summaries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}
.category-unit-chart {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.02);
}
.category-unit-chart > h4 { margin: 0 0 12px; color: var(--text); }
.category-unit-chart .donut-legend { max-height: none; overflow: visible; }
.category-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 9px;
  margin: 14px 0;
}
.category-selector-btn {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 3px 10px;
  min-height: 76px;
  padding: 11px 13px;
  text-align: left;
  border-color: var(--line);
  background: rgba(255,255,255,.025);
}
.category-selector-btn span { font-size: 12px; font-weight: 850; }
.category-selector-btn span,
.category-focus-panel td,
.category-focus-panel th { color: #eef7ef; }
.category-selector-btn small { color: #b9c9bd; }
.category-selector-btn strong { color: var(--brand); font-size: 20px; }
.category-selector-btn small { grid-column: 1 / -1; color: var(--muted); }
.category-selector-btn.active {
  border-color: rgba(184,240,84,.65);
  background: linear-gradient(135deg, rgba(184,240,84,.18), rgba(97,211,148,.06));
  box-shadow: inset 0 0 0 1px rgba(184,240,84,.12);
}
.category-focus-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.025);
}
.category-focus-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.category-focus-head span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
.category-focus-head h4 { margin: 3px 0; font-size: 20px; }
.category-focus-head p { margin: 0; color: var(--muted); font-size: 12px; }
.category-focus-head > strong { color: var(--brand); font-size: clamp(24px, 3vw, 36px); }
.category-focus-panel .viz-bars { max-height: 390px; overflow: auto; }
.category-focus-panel .donut-wrap { align-items: start; }
.trace-note { display: block; margin-top: 4px; color: #a9d9ba; font-weight: 700; }
.debt-bi-total {
  display: grid;
  gap: 5px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(247,201,72,.35);
  border-radius: 16px;
  background: rgba(247,201,72,.08);
}
.debt-bi-total span, .debt-bi-total small { color: #d8e4da; }
.debt-bi-total strong { color: #ffd768; font-size: clamp(26px, 4vw, 42px); }
.category-drill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.category-drill {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.025);
  overflow: hidden;
}
.category-drill summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  list-style: none;
}
.category-drill summary::-webkit-details-marker { display: none; }
.category-drill summary span { display: grid; gap: 3px; }
.category-drill summary small { color: var(--muted); }
.category-drill summary b { color: var(--brand); font-size: 22px; }
.category-drill-body { display: grid; gap: 14px; padding: 0 14px 14px; }
.category-drill-body .viz-bars { max-height: 330px; overflow: auto; }
.category-drill-body .viz-bar-row { grid-template-columns: 28px minmax(130px, 1fr) minmax(90px, 1.2fr) auto; }

.inactivity-grid { display: grid; gap: 10px; }
.inactivity-grid details { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.inactivity-grid summary { display: flex; justify-content: space-between; padding: 13px; cursor: pointer; font-weight: 800; }
.inactivity-grid summary b { color: var(--brand); }
.inactivity-grid .insight-list { max-height: 310px; padding: 0 10px 10px; }

.csc-analysis {
  display: grid;
  gap: 16px;
  margin: 22px 0 26px;
  padding: clamp(16px, 2.4vw, 26px);
  border: 1px solid rgba(105,205,255,.3);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(47,139,190,.13), rgba(255,255,255,.018) 48%, rgba(184,240,84,.035));
  box-shadow: 0 22px 60px rgba(0,0,0,.2);
}
.csc-page-head { align-items: end; }
.csc-page-filter { width: min(610px, 100%); }
.managerial-scope-note {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 0 14px;
  padding: 12px 15px;
  border: 1px solid rgba(105,205,255,.24);
  border-radius: 15px;
  background: rgba(47,139,190,.08);
}
.managerial-scope-note strong { color: #8edcff; white-space: nowrap; }
.managerial-scope-note span { color: var(--muted); }
.csc-loading {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}
.csc-loading span {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(105,205,255,.2);
  border-top-color: #8edcff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.csc-analysis-head,
.csc-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 22px; }
.csc-analysis-head h2,
.csc-analysis-head p,
.csc-detail-head h3,
.csc-detail-head p { margin-top: 0; }
.csc-analysis-head > div:first-child > p:last-child,
.csc-detail-head p { margin-bottom: 0; color: var(--muted); }
.csc-scope {
  flex: 0 0 min(290px, 36%);
  display: grid;
  gap: 4px;
  padding: 15px;
  border: 1px solid rgba(105,205,255,.3);
  border-radius: 17px;
  background: rgba(23,123,174,.11);
}
.csc-scope span { color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.csc-scope strong { color: #8edcff; font-size: 34px; line-height: 1; }
.csc-scope small { color: #c3d2d8; line-height: 1.4; }
.csc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 11px; }
.csc-kpis .kpi-card { min-height: 126px; padding: 14px; }
.csc-kpis .kpi-card .value { font-size: clamp(23px, 2vw, 31px); }
.csc-analysis-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(270px, .75fr); gap: 14px; }
.csc-readiness,
.csc-batches { margin: 0; }
.csc-progress-row { display: grid; gap: 7px; margin-top: 15px; }
.csc-progress-row > span { display: flex; justify-content: space-between; gap: 15px; color: #dce9df; }
.csc-progress-row > span b { color: #8edcff; }
.csc-progress-row > div,
.csc-mini-progress { display: block; height: 8px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.csc-progress-row > div i,
.csc-mini-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #48a9d6, #b8f054); }
.csc-progress-row small { color: var(--muted); }
.csc-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 17px; }
.csc-facts span { padding: 11px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); }
.csc-facts b { display: block; color: var(--text); font-size: 21px; }
.csc-facts .is-ok { border-color: rgba(97,211,148,.3); }
.csc-facts .is-warn { border-color: rgba(255,190,74,.35); }
.csc-batches > p { color: var(--muted); }
.csc-batches > div { display: grid; gap: 8px; }
.csc-batches > div span { display: flex; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.csc-batches > div b { color: #8edcff; }
.csc-detail { margin: 0; }
.csc-detail-head > strong { color: #8edcff; white-space: nowrap; }
.csc-detail td strong,
.csc-detail td small { display: block; }
.csc-detail td small { margin-top: 5px; color: var(--muted); line-height: 1.35; }
.csc-patient-link {
  display: grid;
  gap: 1px;
  min-width: 190px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  box-shadow: none;
}
.csc-patient-link:hover,
.csc-patient-link:focus-visible { color: #8edcff; transform: none; }
.csc-debt { color: #ffbd70; font-weight: 850; }
.csc-settled { color: var(--success); font-weight: 850; }
.csc-progress-label { display: block; margin-bottom: 6px; color: #dce9df; font-weight: 800; }
.csc-mini-progress { width: 90px; }
.csc-method { padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; }
.csc-method summary { cursor: pointer; color: #dce9df; font-weight: 800; }
.csc-method p { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

.csc-site-workspace { gap: 20px; }
.csc-workspace-section {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}
.csc-workspace-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}
.csc-workspace-title h3,
.csc-workspace-title p { margin: 0; }
.csc-workspace-title h3 { margin-top: 3px; font-size: clamp(18px, 2vw, 24px); }
.csc-workspace-title > span {
  padding: 7px 10px;
  border: 1px solid rgba(105,205,255,.24);
  border-radius: 999px;
  color: #bfeaff;
  background: rgba(47,139,190,.08);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.csc-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.csc-chart-grid > .chart-panel,
.csc-chart-wide > .chart-panel { height: 100%; margin: 0; }
.csc-chart-wide { grid-column: 1 / -1; }
.csc-chart-grid .donut-wrap { grid-template-columns: minmax(118px, .72fr) minmax(180px, 1.28fr); }
.csc-chart-grid .donut-chart { width: min(170px, 100%); }
.csc-chart-grid .viz-bars { max-height: 310px; overflow: auto; }
.csc-patient-directory { display: grid; gap: 13px; }
.csc-patient-search {
  display: grid;
  grid-template-columns: auto minmax(230px, 430px);
  align-items: center;
  justify-content: end;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.csc-patient-directory .table-scroll { max-height: 610px; }
.csc-patient-directory table { min-width: 1100px; }
.csc-product-cell { min-width: 180px; line-height: 1.55 !important; }
.csc-ticket-directory {
  display: grid;
  gap: 13px;
  margin: 0;
  border-color: rgba(105,205,255,.24);
}
.csc-ticket-directory .table-scroll { max-height: 560px; }
.csc-ticket-directory table { min-width: 1180px; }
.csc-ticket-link {
  display: grid;
  gap: 3px;
  min-width: 118px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8edcff;
  text-align: left;
  box-shadow: none;
}
.csc-ticket-link:hover,
.csc-ticket-link:focus-visible { color: var(--brand); transform: none; }
.csc-ticket-link small,
.csc-ticket-products { color: var(--muted); line-height: 1.45; }
.csc-ticket-products { display: block; min-width: 260px; max-width: 440px; }
.csc-finance-section {
  padding: clamp(14px, 2vw, 20px);
  border: 1px solid rgba(184,240,84,.24);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(184,240,84,.07), rgba(255,255,255,.018));
}
.csc-finance-section .csc-workspace-title > div > p:last-child { margin: 5px 0 0; color: var(--muted); }
.csc-finance-kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.csc-finance-grid .chart-panel { border-color: rgba(184,240,84,.16); }
.csc-debt-control { display: grid; gap: 11px; margin: 0; }
.csc-debt-control > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.csc-debt-control h3,
.csc-debt-control p { margin: 0; }
.csc-debt-control > header > span { color: #ffbd70; font-weight: 850; }
.csc-debt-control > div { display: grid; gap: 7px; }
.csc-debt-control > div > button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 11px 13px;
  border-color: rgba(255,189,112,.18);
  background: rgba(255,189,112,.035);
  text-align: left;
}
.csc-debt-control > div > button span { display: grid; gap: 3px; }
.csc-debt-control > div > button small { color: var(--muted); }
.csc-debt-control > div > button b { color: #ffbd70; white-space: nowrap; }
.csc-finance-note {
  margin: 0;
  padding: 11px 13px;
  border-left: 3px solid rgba(105,205,255,.7);
  color: var(--muted);
  background: rgba(105,205,255,.045);
}
.csc-patient-dossier { border-color: rgba(105,205,255,.35) !important; }
.csc-dossier-hero {
  border-bottom-color: rgba(105,205,255,.2);
  background: linear-gradient(110deg, rgba(47,139,190,.16), rgba(184,240,84,.045));
}
.csc-dossier-hero::before { background: #69cdff !important; }
.csc-dossier-avatar {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px solid rgba(105,205,255,.45);
  border-radius: 50%;
  color: #dff6ff;
  background: linear-gradient(145deg, rgba(47,139,190,.35), rgba(184,240,84,.12));
  font-size: 15px;
  font-weight: 950;
  letter-spacing: .08em;
}
.csc-dossier-kpis article { border-color: rgba(105,205,255,.18); }
.csc-dossier-kpis strong { color: #8edcff; }
.csc-dossier-main .chart-panel { margin: 0; }
.csc-dossier-main .donut-wrap { grid-template-columns: minmax(120px, .75fr) minmax(170px, 1.25fr); }
.csc-dossier-main .donut-chart { width: min(165px, 100%); }
.csc-dossier-history { margin: 12px 16px 16px; }

.dollar-menu { position: relative; }
.dollar-menu > summary {
  display: grid;
  gap: 2px;
  min-width: 132px;
  padding: 8px 12px;
  border: 1px solid rgba(184,240,84,.28);
  border-radius: 14px;
  background: rgba(184,240,84,.07);
  cursor: pointer;
  list-style: none;
}
.dollar-menu > summary::-webkit-details-marker { display: none; }
.dollar-menu > summary span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.dollar-menu > summary strong { color: var(--brand); font-size: 17px; }
.header-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  display: grid;
  gap: 9px;
  width: min(310px, calc(100vw - 30px));
  padding: 16px;
  border: 1px solid rgba(184,240,84,.3);
  border-radius: 18px;
  background: #111916;
  box-shadow: 0 22px 55px rgba(0,0,0,.52);
}
.header-popover p { margin: 0; font-size: 12px; }

@media (max-width: 1120px) {
  .dashboard-filter { grid-template-columns: 1fr auto; }
  .dashboard-date-fields, .dashboard-range-field { grid-column: 1 / -1; }
  .dashboard-bi-grid--hero { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .dashboard-bi-grid { grid-template-columns: 1fr; }
  .dashboard-filter { width: 100%; }
  .category-drill-grid { grid-template-columns: 1fr; }
  .category-unit-summaries { grid-template-columns: 1fr; }
  .metric-tooltip { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); width: min(360px, calc(100vw - 32px)); }
}

@media (min-width: 1700px) {
  #dashboardCards.dashboard-kpis { grid-template-columns: repeat(4, minmax(260px, 1fr)) !important; }
}

@media (min-width: 900px) and (max-width: 1199px) {
  #dashboardCards.dashboard-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@media (min-width: 561px) and (max-width: 899px) {
  #dashboardCards.dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 560px) {
  .dashboard-date-fields { grid-template-columns: 1fr; }
  .dashboard-filter { grid-template-columns: 1fr; }
  .dashboard-filter > * { grid-column: 1; width: 100%; }
  #dashboardCards.dashboard-kpis { grid-template-columns: 1fr !important; }
  #dashboardCards .kpi-card { min-height: 142px; padding: 14px; }
  #dashboardCards .kpi-card .value,
  #dashboardCards .kpi-card.kpi-value-long .value,
  #dashboardCards .kpi-card.kpi-value-xl .value { font-size: clamp(25px, 8vw, 34px); }
  .dollar-menu { order: -1; width: 100%; }
  .dollar-menu > summary { width: 100%; }
  .header-popover { right: auto; left: 0; }
  .category-selector { display: flex; overflow-x: auto; padding-bottom: 5px; scroll-snap-type: x proximity; }
  .category-selector-btn { min-width: 150px; scroll-snap-align: start; }
  .category-focus-head { align-items: start; }
  .category-focus-head > strong { font-size: 24px; }
  .flow-chart-canvas { min-height: 210px; aspect-ratio: 1.55; }
  .flow-chart text { font-size: 9px; }
  .flow-y-label { display: none; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-legend { width: 100%; }
  .csc-analysis-head,
  .csc-detail-head { display: grid; }
  .csc-scope { width: 100%; max-width: none; }
  .csc-analysis-grid { grid-template-columns: 1fr; }
  .managerial-scope-note { align-items: flex-start; flex-direction: column; }
  .csc-chart-grid { grid-template-columns: 1fr; }
  .csc-chart-wide { grid-column: auto; }
  .csc-workspace-title { align-items: flex-start; flex-direction: column; }
  .csc-patient-search { grid-template-columns: 1fr; justify-content: stretch; }
  .csc-finance-kpis { grid-template-columns: 1fr 1fr; }
  .csc-debt-control > header { align-items: flex-start; }
  .csc-dossier-main { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  #dashboardCards.dashboard-kpis { grid-template-columns: 1fr !important; }
  #dashboardCards .kpi-card { min-height: 128px; }
  #dashboardCards .kpi-card .value { font-size: 29px; }
  .csc-chart-grid .donut-wrap,
  .csc-dossier-main .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .csc-finance-kpis { grid-template-columns: 1fr; }
  .csc-debt-control > div > button { align-items: flex-start; flex-direction: column; }
  .csc-dossier-avatar { width: 48px; height: 48px; font-size: 12px; }
}

.dashboard-widget-config {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 7px 0;
}

.dashboard-widget-config > small {
  color: var(--muted);
}

/* DataBI: periodo, acceso sensible y dispersion producto-tiempo. */
.databi-period-toolbar {
  align-items: end;
}

.databi-period-toolbar .range-field {
  flex: 1 1 280px;
  min-width: 240px;
}

.databi-period-toolbar .range-field input {
  width: min(340px, 100%);
}

.protected-report-card {
  max-width: 720px;
  margin: 18px auto;
  border-color: rgba(190, 255, 78, .35);
}

.scatter-wrap {
  width: 100%;
  max-height: 620px;
  overflow: auto;
  border-radius: 14px;
  background: rgba(7, 15, 11, .55);
}

.scatter-chart {
  display: block;
  width: max(100%, 760px);
  min-height: 240px;
}

.scatter-grid,
.scatter-axis {
  stroke: rgba(190, 255, 78, .12);
  stroke-width: 1;
}

.scatter-axis {
  stroke-dasharray: 4 6;
}

.scatter-point {
  fill: rgba(190, 255, 78, .78);
  stroke: #efffd4;
  stroke-width: 1.5;
}

.scatter-label,
.scatter-date {
  fill: var(--muted);
  font-size: 11px;
}

.stock-search-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.6fr) minmax(170px, .8fr) minmax(150px, .7fr) minmax(150px, .7fr) auto;
  align-items: end;
}

#stockView .table-panel {
  max-height: 70vh;
  overflow: auto;
}

#stockMovementsTable {
  max-height: 62vh;
  overflow: auto;
}

/* Historial de pedidos: registros legibles sin tabla ancha ni doble scroll. */
#salesView {
  --sales-border: rgba(255, 255, 255, .095);
  --sales-soft: rgba(255, 255, 255, .035);
}

#salesView .sales-history-head {
  align-items: end;
  margin-bottom: 12px;
}

#salesView .sales-filter-toolbar {
  display: grid;
  grid-template-columns: 150px 150px minmax(220px, 1fr) minmax(150px, .55fr) auto;
  align-items: end;
  gap: 9px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--sales-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, .025);
}

#salesView .sales-filter-toolbar > * {
  min-width: 0;
  width: 100%;
  margin: 0;
}

.sales-history-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, .7fr)) minmax(190px, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.sales-history-summary > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--sales-border);
  border-radius: 14px;
  background: var(--sales-soft);
}

.sales-history-summary span,
.sales-order-card span:not(.badge),
.sales-order-card small {
  color: var(--muted);
  font-size: 11px;
}

.sales-history-summary strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.sales-history-summary .sales-summary-total {
  border-color: rgba(184, 240, 84, .3);
  background: linear-gradient(135deg, rgba(184, 240, 84, .12), rgba(97, 211, 148, .035));
}

#salesTable.sales-history-results {
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.sales-history-list {
  display: grid;
  gap: 9px;
}

.sales-order-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--sales-border);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(27, 37, 32, .98), rgba(17, 25, 21, .98));
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.sales-order-primary {
  display: grid;
  grid-template-columns: minmax(125px, .55fr) minmax(220px, 1.35fr) minmax(115px, .55fr) minmax(260px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px 15px 11px;
}

.sales-order-identity,
.sales-order-patient,
.sales-order-total,
.sales-payment-detail,
.sales-stock-detail {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sales-order-identity > span,
.sales-order-patient > span,
.sales-order-total > span,
.sales-payment-detail > span,
.sales-stock-detail > span,
.sales-product-detail summary > span {
  color: #9eaea2;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.sales-order-identity strong,
.sales-order-patient strong,
.sales-payment-detail strong,
.sales-stock-detail strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.sales-order-identity time {
  color: var(--muted);
  font-size: 11px;
}

.sales-order-total strong {
  color: var(--brand);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sales-order-statuses {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 7px;
  min-width: 0;
}

.sales-state {
  position: relative;
  display: grid;
  gap: 3px;
  min-width: 0;
  min-height: 53px;
  padding: 9px 10px 9px 14px;
  overflow: hidden;
  border: 1px solid var(--sales-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
}

.sales-state::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: currentColor;
}

.sales-state > span {
  color: #aebbb1 !important;
  font-size: 9px !important;
  font-weight: 850;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.sales-state > strong {
  overflow-wrap: anywhere;
  color: currentColor;
  font-size: 13px;
  line-height: 1.15;
}

.sales-state-ordered {
  color: #ffd369;
  border-color: rgba(255, 211, 105, .35);
  background: rgba(255, 211, 105, .09);
}

.sales-state-dispatched {
  color: #73d8ff;
  border-color: rgba(115, 216, 255, .35);
  background: rgba(115, 216, 255, .085);
}

.sales-state-paid {
  color: #a9ef73;
  border-color: rgba(169, 239, 115, .38);
  background: rgba(169, 239, 115, .095);
}

.sales-state-owed,
.sales-state-cancelled {
  color: #ff8f98;
  border-color: rgba(255, 104, 116, .4);
  background: rgba(255, 104, 116, .1);
}

.sales-state-partial {
  color: #ffb55f;
  border-color: rgba(255, 181, 95, .4);
  background: rgba(255, 181, 95, .1);
}

.sales-order-secondary {
  display: grid;
  grid-template-columns: minmax(290px, 1.6fr) minmax(170px, .8fr) minmax(140px, .6fr);
  align-items: start;
  gap: 8px;
  padding: 0 15px 11px;
}

.sales-product-detail,
.sales-payment-detail,
.sales-stock-detail {
  min-width: 0;
  min-height: 59px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 12px;
  background: rgba(255, 255, 255, .025);
}

.sales-product-detail summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  min-width: 0;
  cursor: pointer;
  list-style: none;
}

.sales-product-detail summary::-webkit-details-marker {
  display: none;
}

.sales-product-detail summary::after {
  content: "Ver todos";
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  color: var(--brand);
  font-size: 10px;
  font-weight: 850;
}

.sales-product-detail[open] summary::after {
  content: "Ocultar";
}

.sales-product-detail summary strong {
  font-size: 12px;
}

.sales-product-detail summary small {
  grid-column: 1;
  overflow: hidden;
  color: #d5e2d8;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-product-detail ul {
  display: grid;
  gap: 5px;
  margin: 9px 0 0;
  padding: 9px 0 0 18px;
  border-top: 1px solid var(--sales-border);
  color: #d8e4da;
  font-size: 12px;
}

.sales-payment-detail small,
.sales-stock-detail small {
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.sales-order-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 9px 15px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  background: rgba(0, 0, 0, .09);
}

.sales-order-actions .sales-action {
  width: auto;
  min-width: 0;
  min-height: 31px;
  margin: 0;
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1;
}

.sales-order-actions .sales-detail-action {
  margin-right: auto;
  border-color: rgba(184, 240, 84, .36);
}

.sales-history-empty {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 42px 20px;
  text-align: center;
}

.sales-history-empty span {
  color: var(--muted);
}

@media (max-width: 1050px) {
  #salesView .sales-filter-toolbar {
    grid-template-columns: repeat(2, minmax(145px, .55fr)) minmax(210px, 1fr) minmax(145px, .6fr);
  }
  #salesView .sales-filter-toolbar button { grid-column: 1 / -1; }
  .sales-order-primary {
    grid-template-columns: minmax(125px, .6fr) minmax(210px, 1.3fr) minmax(110px, .6fr);
  }
  .sales-order-statuses { grid-column: 1 / -1; max-width: 430px; }
  .sales-order-secondary { grid-template-columns: minmax(260px, 1.4fr) minmax(160px, .8fr); }
  .sales-stock-detail { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  #salesView .sales-filter-toolbar { grid-template-columns: 1fr 1fr; }
  #salesView .sales-filter-toolbar #salesPatientSearch,
  #salesView .sales-filter-toolbar #salesStatus,
  #salesView .sales-filter-toolbar button { grid-column: 1 / -1; }
  .sales-history-summary { grid-template-columns: 1fr 1fr; }
  .sales-order-primary { grid-template-columns: 1fr 1fr; align-items: start; }
  .sales-order-patient { grid-column: 1 / -1; grid-row: 1; }
  .sales-order-statuses { grid-column: 1 / -1; }
  .sales-order-total { text-align: right; }
  .sales-order-secondary { grid-template-columns: 1fr; }
  .sales-stock-detail { grid-column: auto; }
  .sales-order-actions { justify-content: stretch; }
  .sales-order-actions .sales-action { flex: 1 1 calc(50% - 6px); }
  .sales-order-actions .sales-detail-action { margin-right: 0; flex-basis: 100%; }
}

@media (max-width: 430px) {
  #salesView .sales-filter-toolbar,
  .sales-history-summary,
  .sales-order-primary { grid-template-columns: 1fr; }
  #salesView .sales-filter-toolbar > *,
  .sales-order-patient,
  .sales-order-statuses { grid-column: auto; }
  .sales-order-patient { grid-row: auto; }
  .sales-order-total { text-align: left; }
  .sales-order-actions .sales-action { flex-basis: 100%; }
}

/* Inventario productivo: operacion guiada por tarjetas. */
.inventory-flow-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

/* Centro de seguridad: acciones breves, estado visible y detalle bajo demanda. */
.security-command-center {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  background: linear-gradient(145deg, rgba(174, 255, 70, .055), rgba(255, 255, 255, .018));
}

.security-center-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.mission-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.mission-card {
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015));
  color: var(--text);
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: none;
}

button.mission-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.mission-card span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.mission-card strong {
  color: var(--text);
  font-size: clamp(1.75rem, 2.6vw, 2.5rem);
  line-height: 1;
}

.mission-card small { color: var(--muted); }

.access-missing {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 194, 92, .32);
  border-radius: 14px;
  background: rgba(255, 194, 92, .06);
}

.access-missing summary {
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.access-missing div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.access-missing span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-soft);
}

.access-covered { margin-top: 12px; }

.user-access-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(150px, .35fr) minmax(180px, .4fr) auto;
  align-items: end;
  margin-bottom: 12px;
}

.user-access-filters .filter-result {
  align-self: center;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.user-permission-inline {
  display: grid;
  grid-template-columns: minmax(108px, 1fr) auto;
  gap: 6px;
  min-width: 190px;
  align-items: center;
}

.user-permission-inline small {
  color: var(--muted);
  font-weight: 750;
}

.user-permission-inline button {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: stretch;
}

@media (max-width: 860px) {
  .user-access-filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .user-access-filters { grid-template-columns: 1fr; }
}
.mission-critical { border-color: rgba(255, 97, 112, .65); background: rgba(255, 97, 112, .08); }
.mission-critical strong { color: #ff8793; }
.mission-complete { border-color: rgba(98, 218, 153, .55); }
.mission-complete strong { color: #70e2a8; }

.security-filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr minmax(220px, 2fr) 1fr auto auto;
  align-items: end;
}

.security-events-table code {
  display: block;
  color: #e4f1df;
  white-space: nowrap;
}

.security-events-table td small {
  display: block;
  max-width: 420px;
  margin-top: 5px;
  color: var(--muted);
  white-space: normal;
}

.status-ok { color: #70e2a8; font-weight: 800; }

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

@media (max-width: 700px) {
  .security-center-head { align-items: stretch; flex-direction: column; }
  .mission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mission-card { min-height: 104px; padding: 13px; }
  .security-filters { grid-template-columns: 1fr; }
  .security-events-table .table-scroll { max-height: 62vh; }
}
.inventory-flow-card {
  min-height: 112px;
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px 10px;
  padding: 16px;
  text-align: left;
  color: var(--text);
  background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
  border: 1px solid rgba(214,232,207,.16);
  border-radius: 18px;
  box-shadow: none;
}
.inventory-flow-card > span {
  grid-row: 1 / 3;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #071009;
  background: linear-gradient(145deg, var(--accent), #69dc83);
  font-size: 1rem;
  font-weight: 900;
}
.inventory-flow-card strong { font-size: 1rem; }
.inventory-flow-card small { color: var(--muted); line-height: 1.35; }
.inventory-flow-card:hover,
.inventory-flow-card.is-active {
  border-color: rgba(187,255,75,.72);
  background: linear-gradient(145deg, rgba(187,255,75,.13), rgba(105,220,131,.035));
  transform: translateY(-1px);
}
.inventory-workspace { min-height: 360px; }
.inventory-work-panel { display: none; }
.inventory-work-panel.is-active { display: block; animation: inventoryPanelIn .18s ease-out; }
@keyframes inventoryPanelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.inventory-card-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.inventory-card-heading > span {
  min-width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #071009;
  background: linear-gradient(145deg, var(--accent), #6bdb94);
  font-weight: 900;
}
.inventory-card-heading h3,
.inventory-card-heading p { margin: 0; }
.inventory-card-heading p { margin-top: 4px; color: var(--muted); }
.harvest-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(187,255,75,.25);
  border-radius: 16px;
  background: rgba(5,16,10,.45);
}
.harvest-preview > div { padding: 12px; border-radius: 12px; background: rgba(255,255,255,.045); }
.harvest-preview span,
.harvest-preview small { display: block; color: var(--muted); }
.harvest-preview strong { display: block; margin: 5px 0; color: var(--accent); font-size: clamp(1.25rem, 2vw, 1.75rem); }
.production-convention-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.production-convention-grid article {
  display: grid;
  gap: 4px;
  min-height: 108px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  border-radius: 16px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--panel) 94%, var(--brand) 6%), var(--panel));
}
.production-convention-grid span,
.production-field-label {
  color: var(--brand);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.production-convention-grid strong { color: var(--text); font-size: 17px; }
.production-convention-grid small { color: var(--muted); line-height: 1.4; }
.production-assist-field { position: relative; display: grid; gap: 6px; min-width: 0; }
.production-assist-field > label { margin: 0; }
.production-assist-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.production-assist-control input { min-width: 0; }
.production-assist-control .compact { width: auto; min-height: 42px; }
.production-assist-results {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  display: grid;
  gap: 4px;
  max-height: 294px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid color-mix(in srgb, var(--brand) 38%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 96%, #000 4%);
  box-shadow: 0 16px 38px rgba(0,0,0,.35);
}
.production-assist-results.hidden { display: none; }
.production-assist-results button {
  display: grid;
  gap: 3px;
  min-height: 54px;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  border: 1px solid transparent;
  border-radius: 11px;
  background: rgba(255,255,255,.025);
  box-shadow: none;
}
.production-assist-results button:hover,
.production-assist-results button:focus-visible { border-color: var(--brand); background: color-mix(in srgb, var(--panel) 86%, var(--brand) 14%); }
.production-assist-results button small { color: var(--muted); font-weight: 500; }
.production-assist-empty { padding: 13px; color: var(--muted); text-align: center; }
.production-decision { display: grid; gap: 8px; }
.production-choice-grid,
.production-grade-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.production-grade-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.production-choice-grid button,
.production-grade-grid button {
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 92px;
  padding: 12px;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.025);
  box-shadow: none;
}
.production-choice-grid button small,
.production-grade-grid button small { color: var(--muted); font-weight: 500; line-height: 1.35; }
.production-choice-grid button:hover,
.production-grade-grid button:hover { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }
.production-choice-grid button.is-active,
.production-grade-grid button.is-active { color: #0b130c; border-color: var(--brand); background: var(--brand); }
.production-choice-grid button.is-active small,
.production-grade-grid button.is-active small { color: rgba(5,16,9,.72); }
.production-grade-grid button:disabled { opacity: .36; cursor: not-allowed; }
.production-rule {
  padding: 12px 14px;
  color: var(--text);
  line-height: 1.45;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 92%, var(--brand) 8%);
}
.approval-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 15px;
  margin-bottom: 10px;
  border: 1px solid rgba(214,232,207,.14);
  border-radius: 15px;
  background: rgba(255,255,255,.025);
}
.approval-card.is-pending { border-color: rgba(255,190,72,.35); }
.approval-card strong,
.approval-card small { display: block; }
.approval-card small { margin-top: 4px; color: var(--muted); }
.approval-signatures,
.approval-action { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }
.approval-signatures span { flex: 1 1 220px; padding: 9px 11px; border-radius: 10px; background: rgba(255,255,255,.04); }
.approval-action input { flex: 1 1 260px; }
.consumable-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.consumable-card {
  padding: 14px;
  border: 1px solid rgba(214,232,207,.14);
  border-radius: 15px;
  background: rgba(255,255,255,.025);
}
.consumable-card > span,
.consumable-card small { display: block; color: var(--muted); }
.consumable-card > strong { display: block; margin: 4px 0 12px; }
.consumable-card > div { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; }
.production-audit-grid { margin-top: 14px; }
@media (max-width: 900px) {
  .inventory-flow-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .production-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .inventory-flow-cards { grid-template-columns: 1fr; }
  .inventory-flow-card { min-height: 82px; }
  .harvest-preview { grid-template-columns: 1fr; }
  .production-convention-grid,
  .production-choice-grid,
  .production-grade-grid { grid-template-columns: 1fr; }
  .production-convention-grid article,
  .production-choice-grid button,
  .production-grade-grid button { min-height: 0; }
  .production-assist-control { grid-template-columns: 1fr; }
  .production-assist-control .compact { width: 100%; }
  .approval-card { grid-template-columns: 1fr; }
  .inventory-card-heading { align-items: flex-start; }
}

@media (max-width: 1180px) {
  .stock-search-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .stock-search-toolbar {
    grid-template-columns: 1fr;
  }
}

/* Refuerzo visual operativo: contraste alto y superficies mas fluidas. */
:root {
  --muted: #b5c5bc;
  --line: rgba(205, 255, 151, .17);
  --line-strong: rgba(205, 255, 151, .34);
}

p, .small, .hint, label, .card .label, .section-head p {
  color: #b8c8bf;
}

th {
  color: #c9d8cf;
  letter-spacing: .045em;
}

td {
  color: #e4eee8;
}

.card, .panel, .toolbar, #saleForm {
  border-radius: 20px;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.card:hover, .panel:hover {
  border-color: rgba(199, 255, 94, .22);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .27);
}

.button-row, .toolbar, .pos-product-tools, .split-grid {
  gap: 10px;
}

input, select, textarea {
  color: #edf7f1;
}

input::placeholder, textarea::placeholder {
  color: #91a69a;
  opacity: 1;
}

.debt-payment-empty, .debt-selected-balance, .debt-audit-block,
.debt-kpi, .credit-summary-card {
  border-radius: 20px;
}

/* Fase operativa: contexto de rol, trazabilidad visible y lectura responsive. */
.role-operation-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 12px;
  align-items: baseline;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid rgba(182, 255, 76, .24);
  border-radius: 16px;
  color: var(--text);
  background: linear-gradient(110deg, rgba(178, 255, 70, .09), rgba(255, 255, 255, .025));
}

.role-operation-banner strong { color: var(--pos-accent, #c4ff58); font-size: 12px; letter-spacing: .03em; }
.role-operation-banner span { min-width: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.pos-validation-note {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--pos-accent, #c4ff58);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
  background: rgba(196, 255, 88, .055);
  font-size: 11px;
  line-height: 1.45;
}
.pos-validation-note strong { color: var(--text); }

.pos-traceability-checklist {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--pos-border, rgba(255, 255, 255, .1));
}
.pos-traceability-title { color: var(--text); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.pos-traceability-list { display: grid; gap: 5px; }
.pos-traceability-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 10px;
  background: rgba(255, 255, 255, .025);
}
.pos-traceability-icon { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #0d150a; background: #77877c; font-size: 12px; font-weight: 950; }
.pos-traceability-item span:last-child { display: grid; gap: 1px; min-width: 0; }
.pos-traceability-item strong, .pos-traceability-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-traceability-item strong { color: var(--text); font-size: 11px; }
.pos-traceability-item small { color: var(--muted); font-size: 10px; }
.pos-traceability-item.is-ok { border-color: rgba(106, 224, 154, .25); }
.pos-traceability-item.is-ok .pos-traceability-icon { background: #6ae09a; }
.pos-traceability-item.is-pending { border-color: rgba(255, 193, 92, .25); }
.pos-traceability-item.is-pending .pos-traceability-icon { color: #201700; background: #ffc15c; }
.pos-traceability-item.is-neutral .pos-traceability-icon { color: var(--text); background: rgba(255, 255, 255, .16); }

@media (max-width: 760px) {
  .role-operation-banner { grid-template-columns: 1fr; gap: 3px; }
  .role-operation-banner span { font-size: 11px; }
  .pos-traceability-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 430px) { .pos-traceability-list { grid-template-columns: 1fr; } }

/* Keep patient workspaces above the global modal defaults declared earlier. */
.modal-backdrop.patient-dossier-backdrop { padding: 10px; }
.modal-card.patient-dossier { width: min(1240px, 100%); max-height: 96vh; padding: 0; border-radius: 24px; background: #101914; }
.modal-card.patient-editor-card { width: min(900px, 100%); }
@media (max-width: 760px) {
  .modal-backdrop.patient-dossier-backdrop { padding: 0; }
  .modal-card.patient-dossier { width: 100%; max-height: 100vh; min-height: 100vh; border: 0; border-radius: 0; }
}

/* POS guiado 2026-08-26: menos carga cognitiva, busqueda asistida y comprobante en vivo. */
#posView {
  --pos-surface: rgba(19, 29, 24, .94);
  --pos-surface-soft: rgba(255, 255, 255, .035);
  --pos-accent-soft: rgba(194, 255, 86, .1);
}

#posView .pos-stage {
  border-color: rgba(207, 238, 218, .14);
  background:
    radial-gradient(circle at 100% 0, rgba(193, 255, 82, .045), transparent 34%),
    linear-gradient(145deg, rgba(255, 255, 255, .048), rgba(255, 255, 255, .022));
  box-shadow: 0 16px 38px rgba(0, 0, 0, .17);
}

.pos-assisted-layout {
  grid-template-columns: minmax(0, 1fr) minmax(370px, 410px);
  gap: 18px;
}

.pos-stage-head > span {
  box-shadow: 0 8px 22px rgba(172, 255, 68, .2);
}

.pos-patient-selector > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pos-patient-selector > span small {
  color: var(--pos-accent);
  font-size: 10px;
  font-weight: 850;
}

.pos-quick-add-details {
  margin-bottom: 10px;
  border: 1px solid var(--pos-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, .018);
}

.pos-quick-add-details > summary {
  padding: 10px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.pos-quick-add-details[open] > summary {
  color: var(--text);
  border-bottom: 1px solid var(--pos-border);
}

.pos-quick-add-details .pos-quick-add {
  margin: 0;
  padding: 10px;
}

#posView .pos-product-tools {
  position: sticky;
  top: 61px;
  z-index: 4;
  padding: 10px;
  border: 1px solid rgba(194, 255, 86, .22);
  background: rgba(13, 23, 18, .97);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .24);
}

#posView #posProductSearch {
  min-height: 48px;
  padding-inline: 15px;
  border-color: rgba(194, 255, 86, .3);
  font-size: 15px;
}

#posView .pos-product-result-count {
  color: var(--pos-accent);
  font-weight: 850;
}

#posView .product-card {
  overflow: hidden;
  border-color: rgba(212, 235, 220, .13);
  background: linear-gradient(145deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .02));
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

#posView .product-card:hover,
#posView .product-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(194, 255, 86, .48);
  background: linear-gradient(145deg, rgba(194, 255, 86, .12), rgba(255, 255, 255, .028));
}

#posView .product-card:active {
  transform: scale(.985);
}

.pos-payment-method-help {
  margin: 8px 0;
  padding: 9px 11px;
  border-radius: 11px;
  color: #d7e5dc;
  background: rgba(105, 222, 150, .075);
  font-size: 11px;
}

.pos-payment-adder {
  grid-template-columns: minmax(125px, .8fr) 90px minmax(125px, .8fr) minmax(175px, 1fr) auto auto;
}

.pos-payment-balance {
  display: grid;
  grid-template-columns: repeat(4, minmax(105px, 1fr));
  gap: 7px;
}

.pos-payment-balance > span {
  display: grid;
  gap: 4px;
  min-height: 60px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, .075);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, .025);
  font-size: 10px;
}

.pos-payment-balance strong {
  color: var(--text);
  font-size: 16px;
}

.pos-payment-balance .is-pending strong { color: #ffd36f; }
.pos-payment-balance .is-ready strong { color: #6ee5a3; }

.pos-payment-progress {
  height: 8px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, .08);
}

.pos-payment-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pos-accent), #65dda0);
  transition: width .2s ease;
}

.pos-payment-progress-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
}

.split-rounding {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.pos-next-action {
  padding: 11px 13px;
  border: 1px solid rgba(255, 202, 91, .25);
  border-radius: 14px;
  color: #ffe2a1;
  background: rgba(255, 190, 69, .07);
  font-size: 11px;
  font-weight: 850;
}

.pos-next-action.is-ready {
  color: #b9ffd3;
  border-color: rgba(102, 225, 157, .32);
  background: rgba(102, 225, 157, .09);
}

.pos-integrity-details {
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 15px;
  background: rgba(255, 255, 255, .025);
}

.pos-integrity-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 11px;
  font-weight: 850;
}

.pos-integrity-details > summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.pos-integrity-details .pos-traceability-checklist {
  margin: 0;
  padding: 0 10px 10px;
  border: 0;
}

#posStageConfirmation .ticket {
  max-height: none;
  min-height: 260px;
  padding: 0;
  overflow: hidden;
  white-space: pre-wrap;
  border-color: rgba(202, 231, 212, .15);
  background: #f7f7ef;
  color: #172019;
}

#posStageConfirmation .ticket > .live-ticket-preview {
  white-space: normal;
}

.live-ticket-preview {
  display: grid;
  gap: 0;
  color: #1a241d;
  background: #f7f7ef;
}

.live-ticket-preview > header,
.live-ticket-customer,
.live-ticket-totals,
.live-ticket-payments {
  padding: 14px 16px;
}

.live-ticket-preview > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #f8ffe8;
  background: linear-gradient(110deg, #20351d, #111c14);
  font-size: 13px;
  font-weight: 900;
}

.live-ticket-preview > header em {
  padding: 4px 8px;
  border: 1px solid rgba(197, 255, 88, .5);
  border-radius: 99px;
  color: #c9ff68;
  font-size: 9px;
  font-style: normal;
  text-transform: uppercase;
}

.live-ticket-customer {
  display: grid;
  gap: 3px;
  border-bottom: 1px dashed #bec8bd;
}

.live-ticket-customer span { font-weight: 850; }
.live-ticket-customer small { color: #657169; }

.live-ticket-lines,
.live-ticket-payments ul {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.live-ticket-lines li,
.live-ticket-payments li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #d9dfd8;
}

.live-ticket-lines li > span {
  display: grid;
  gap: 2px;
}

.live-ticket-lines small,
.live-ticket-payments li span,
.live-ticket-payments > span { color: #69756d; font-size: 10px; }

.live-ticket-empty {
  margin: 14px 16px;
  padding: 22px;
  border: 1px dashed #b9c4ba;
  border-radius: 12px;
  color: #657169;
  text-align: center;
  line-height: 1.5;
}

.live-ticket-totals {
  display: grid;
  gap: 6px;
  margin: 0;
  border-bottom: 1px dashed #bec8bd;
}

.live-ticket-totals > div,
.live-ticket-payments > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.live-ticket-totals dt,
.live-ticket-totals dd { margin: 0; }
.live-ticket-totals .is-total { padding-top: 8px; border-top: 1px solid #ced6cd; font-size: 18px; font-weight: 950; }

.live-ticket-payments {
  display: grid;
  gap: 8px;
}

.live-ticket-payments li { padding-inline: 0; }
.live-ticket-payments > div { padding-top: 8px; border-top: 1px solid #d3dad2; }

@media (max-width: 1360px) {
  .pos-assisted-layout { grid-template-columns: minmax(0, 1fr) minmax(340px, 370px); }
  .pos-payment-adder { grid-template-columns: 1fr 90px 1fr 1.25fr; }
  .pos-payment-adder > button { width: 100%; }
}

@media (max-width: 1180px) {
  .pos-assisted-layout { grid-template-columns: 1fr; }
  .pos-sticky-summary { grid-template-columns: minmax(220px, .8fr) minmax(280px, 1fr); }
  .pos-next-action,
  .pos-integrity-details { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  #posView .pos-product-tools { top: 0; }
  .pos-payment-adder,
  .pos-payment-balance { grid-template-columns: 1fr 1fr; }
  .pos-payment-adder label:nth-of-type(3),
  .pos-payment-adder label:nth-of-type(4),
  .pos-payment-adder > button { grid-column: 1 / -1; }
  .pos-sticky-summary { grid-template-columns: 1fr; }
  .pos-next-action,
  .pos-integrity-details { grid-column: auto; }
  #posView .quote-total { min-height: 92px; }
  #posView .quote-total strong { font-size: 34px; }
  .live-ticket-lines li,
  .live-ticket-payments li { align-items: start; }
}

@media (max-width: 430px) {
  #posView .pos-stage { padding: 11px; border-radius: 16px; }
  .pos-stage-head h3 { font-size: 16px; }
  .pos-stage-head > span { width: 29px; height: 29px; }
  .pos-payment-balance { grid-template-columns: 1fr; }
  .pos-payment-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
  .live-ticket-lines li,
  .live-ticket-payments li { grid-template-columns: 1fr; gap: 4px; }
}

/* Venta asistida 2026-08-26: selección compacta, correo y equivalencias. */
.pos-patient-empty {
  grid-column: 1 / -1;
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 18px 20px;
}

.pos-patient-empty strong { color: var(--text); font-size: 14px; }
.pos-patient-empty span { line-height: 1.45; }

.pos-patient-email {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 2px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 13px;
  background: rgba(255, 255, 255, .025);
}

.pos-patient-email label { display: grid; gap: 5px; }
.pos-patient-email label span { color: var(--muted); font-size: 10px; font-weight: 850; }
.pos-patient-email button { width: auto; min-height: 42px; }
.pos-patient-email small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }
.pos-patient-email.is-required { border-color: rgba(255, 202, 91, .35); background: rgba(255, 190, 69, .07); }
.pos-patient-email.is-ready { border-color: rgba(102, 225, 157, .25); }

#posView .pos-product-search-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

#posView .pos-product-search-row > button {
  width: auto;
  min-height: 48px;
}

#posView .pos-product-result-count {
  display: flex;
  align-items: center;
  gap: 5px;
}

#posView .pos-product-result-count button {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--pos-accent);
  background: transparent;
  box-shadow: none;
  font: inherit;
  text-decoration: underline;
}

#posView .product-card,
#posView .product-card.has-image {
  grid-template-columns: 48px minmax(0, 1fr) auto;
  grid-template-areas: "avatar meta price";
  min-height: 86px;
  padding: 10px 12px;
}

#posView .product-card.has-image { grid-template-columns: 56px minmax(0, 1fr) auto; }
#posView .product-card .product-price { grid-area: price; align-self: center; white-space: nowrap; }
#posView .product-card .product-meta { align-self: center; }
#posView .product-card .product-image { width: 48px; height: 48px; }

.live-ticket-totals .is-total dd { display: grid; justify-items: end; gap: 2px; }
.live-ticket-totals .is-total dd small { color: #647168; font-size: 10px; font-weight: 700; }
#posView .quote-total small { color: #c8d8cc; font-size: 10px; }
.pos-total-usd { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.pos-payment-balance > span > small { color: var(--muted); font-size: 9px; }

@media (max-width: 760px) {
  #posView .pos-page-head { align-items: flex-start; }
  #posView .pos-page-head h2 { font-size: clamp(22px, 7vw, 30px); }
  #posView .pos-operation-bar { gap: 6px; }
  #posView .pos-operation-bar > div { min-width: 0; padding: 8px; }
  #posView .pos-patient-card { grid-template-columns: 44px minmax(0, 1fr); padding: 10px; }
  #posView .pos-patient-avatar { width: 44px; height: 44px; border-radius: 13px; }
  #posView .pos-patient-copy > strong { font-size: 14px; }
  #posView .pos-patient-email { grid-template-columns: 1fr; }
  #posView .pos-patient-email button,
  #posView .pos-product-search-row > button { width: 100%; }
  #posView .pos-patient-email small { grid-column: auto; }
  #posView .pos-product-search-row { grid-template-columns: 1fr auto; }
  #posView .pos-product-search-row .pos-product-result-count { grid-column: 1 / -1; justify-self: stretch; justify-content: center; }
  #posView .product-grid { max-height: none; overflow: visible; padding-right: 0; }
  #posView .pos-product-tools { position: static; }
  #posView .product-card-grid { grid-template-columns: 1fr; }
  #posView .product-card,
  #posView .product-card.has-image { grid-template-columns: 44px minmax(0, 1fr) auto; min-height: 76px; }
  #posView .product-card .product-image,
  #posView .product-card .product-avatar { width: 42px; height: 42px; }
}

@media (max-width: 430px) {
  #posView .pos-patient-search { grid-template-columns: 1fr; }
  #posView .pos-product-search-row { grid-template-columns: 1fr; }
  #posView .pos-product-search-row .pos-product-result-count { grid-column: auto; }
  #posView .product-card,
  #posView .product-card.has-image {
    grid-template-columns: 40px minmax(0, 1fr);
    grid-template-areas: "avatar meta" "price price";
  }
  #posView .product-card .product-price { justify-self: end; }
}

/* Facturador 2026-08-27: buscador estable y escala tipografica legible. */
#posView { font-size: 15px; }
#posView #posStageProducts { display: block; }
#posView #saleProductGrid {
  display: grid;
  align-content: start;
  gap: 12px;
  max-height: none;
  min-height: 0;
  overflow: visible;
  padding: 0;
}
#posView #saleProductGrid .pos-product-tools {
  position: static;
  top: auto;
  z-index: auto;
  gap: 9px;
  margin: 0;
  padding: 10px;
  box-shadow: none;
}
#posView #saleProductGrid .product-card-grid {
  align-content: start;
  max-height: min(48vh, 470px);
  overflow-y: auto;
  padding: 0 4px 4px 0;
  scrollbar-gutter: stable;
}
#posView .pos-stage-head h3 { font-size: 19px; }
#posView .pos-stage-head p { font-size: 13px; line-height: 1.45; }
#posView .pos-quick-add-details > summary { font-size: 12px; }
#posView label,
#posView .pos-patient-selector > span { font-size: 12px; }
#posView input,
#posView select,
#posView textarea,
#posView button { font-size: 14px; }
#posView .chip { font-size: 12px; }
#posView .product-card .product-meta strong { font-size: 14px; line-height: 1.25; }
#posView .product-card .product-meta small { font-size: 11px; line-height: 1.35; }
#posView .product-card .product-price { font-size: 16px; }
#posView .pos-product-result-count { font-size: 12px; }

@media (max-width: 760px) {
  #posView { font-size: 15px; }
  #posView #saleProductGrid .product-card-grid {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  #posView #saleProductGrid .pos-product-tools { padding: 9px; }
  #posView .pos-category-chips { scrollbar-width: thin; }
}

@media (max-width: 430px) {
  #posView .pos-stage-head h3 { font-size: 18px; }
  #posView .pos-stage-head p { font-size: 12px; }
  #posView input,
  #posView select,
  #posView textarea,
  #posView button { font-size: 14px; }
}

/* Gastos asistidos: el mismo lenguaje operativo del Facturador, aplicado a egresos. */
#expensesView {
  --expense-accent: #b8ff4d;
  --expense-soft: rgba(184, 255, 77, .075);
  --expense-border: rgba(184, 255, 77, .19);
  font-size: 15px;
}

.expense-page-head .eyebrow { margin-bottom: 3px; }

.expense-filter-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, .8fr)) repeat(3, minmax(150px, 1fr)) minmax(210px, 1.4fr) auto;
  gap: 8px;
}

.expense-stepper {
  position: sticky;
  top: 8px;
  z-index: 17;
  display: grid;
  grid-template-columns: repeat(5, minmax(112px, 1fr));
  gap: 6px;
  margin: 14px 0;
  padding: 7px;
  border: 1px solid var(--expense-border);
  border-radius: 17px;
  background: rgba(9, 15, 12, .94);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .23);
  backdrop-filter: blur(14px);
}

.expense-stepper a {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 38px;
  padding: 5px 8px;
  border-radius: 11px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 850;
}

.expense-stepper a:hover,
.expense-stepper a.is-complete {
  color: var(--text);
  background: var(--expense-soft);
}

.expense-stepper a b {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border: 1px solid var(--expense-border);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, .045);
}

.expense-stepper a.is-complete b {
  color: #0b1408;
  border-color: var(--expense-accent);
  background: var(--expense-accent);
}

.expense-assisted-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
  gap: 14px;
  align-items: start;
}

.expense-assisted-flow,
.expense-assisted-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}

#expenseForm.expense-assisted-form {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#expensesView .expense-stage {
  scroll-margin-top: 74px;
  padding: 17px;
  border-color: var(--expense-border);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .022));
}

.expense-stage-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 14px;
}

.expense-stage-head > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 11px;
  color: #0b1408;
  background: linear-gradient(135deg, var(--expense-accent), var(--brand-2));
  font-weight: 950;
}

.expense-stage-head > div { min-width: 0; }
.expense-stage-head h3,
.expense-stage-head p { margin: 0; }
.expense-stage-head h3 { font-size: 19px; }
.expense-stage-head p { margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.4; }

.expense-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.expense-field-grid label,
.expense-notes-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#expensesView input,
#expensesView select,
#expensesView textarea,
#expensesView button { font-size: 14px; }

.expense-wide-field { grid-column: span 2; }

.expense-field-grid > .hidden { display: none; }
.expense-stock-picker { display: grid; gap: 10px; min-width: 0; }
.expense-stock-picker > p { margin: 0; color: var(--muted); font-size: 13px; }
.expense-stock-results { display: grid; gap: 8px; min-width: 0; }
.expense-stock-option { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; text-align: left; }
.expense-stock-option span { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.expense-stock-option b { white-space: nowrap; }
.expense-stock-option small { color: var(--muted); }
.expense-stock-option[aria-pressed="true"] { border-color: var(--accent); background: rgba(166, 236, 70, .12); }

.expense-readonly-field {
  display: grid;
  gap: 6px;
  min-height: 45px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .025);
}

.expense-readonly-field span { color: var(--muted); font-size: 11px; font-weight: 800; }
.expense-readonly-field strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.expense-rule-note {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 199, 78, .35);
  border-radius: 13px;
  color: #ffe3a1;
  background: rgba(255, 184, 52, .08);
}

.expense-rule-note span { color: var(--muted); font-size: 12px; }

.expense-live-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.expense-live-preview > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .025);
}

.expense-live-preview span { color: var(--muted); font-size: 11px; font-weight: 800; }
.expense-live-preview strong { overflow-wrap: anywhere; }
.expense-preview-wide { grid-column: 1 / -1; }

.expense-submit-btn {
  width: 100%;
  margin-top: 12px;
  min-height: 48px;
}

.expense-submit-btn:disabled { cursor: not-allowed; filter: grayscale(.6); opacity: .48; }

.expense-sticky-summary {
  position: sticky;
  top: 74px;
  display: grid;
  gap: 10px;
}

.expense-sticky-summary .panel { padding: 15px; border-color: var(--expense-border); }
.expense-summary-label { color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.expense-sticky-total { display: block; margin: 10px 0 14px; color: var(--expense-accent); font-size: clamp(28px, 3vw, 40px); line-height: 1; overflow-wrap: anywhere; }

.expense-summary-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .7fr);
  gap: 8px;
}

.expense-summary-metrics span { display: grid; gap: 3px; color: var(--muted); font-size: 10px; }
.expense-summary-metrics strong { overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.expense-next-action {
  padding: 11px 12px;
  border: 1px solid var(--expense-border);
  border-radius: 13px;
  color: var(--text);
  background: var(--expense-soft);
  font-size: 12px;
  line-height: 1.45;
}

.expense-integrity-checklist { display: grid; gap: 7px; }

.expense-check {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .025);
}

.expense-check > b { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.expense-check span { display: grid; gap: 1px; }
.expense-check strong { font-size: 12px; }
.expense-check small { color: var(--muted); font-size: 10px; }
.expense-check.is-ready { border-color: rgba(89, 224, 160, .32); }
.expense-check.is-ready > b { color: #0a1b12; background: #59e0a0; }

.expense-history-panel { margin-top: 14px; }
.compact-section-head { margin-bottom: 10px; }
.compact-section-head h3,
.compact-section-head p { margin: 0; }
.compact-section-head p { margin-top: 3px; color: var(--muted); font-size: 12px; }

@media (max-width: 1180px) {
  .expense-filter-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .expense-assisted-layout { grid-template-columns: minmax(0, 1fr) minmax(260px, 300px); }
}

@media (max-width: 900px) {
  .expense-assisted-layout { grid-template-columns: 1fr; }
  .expense-sticky-summary { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .expense-sticky-summary .panel { grid-column: 1 / -1; }
  .expense-field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .expense-page-head { align-items: flex-start; }
  .expense-filter-toolbar { grid-template-columns: 1fr 1fr; }
  .expense-filter-toolbar #expensesSearch { grid-column: 1 / -1; }
  .expense-stepper { position: static; grid-template-columns: repeat(5, minmax(42px, 1fr)); overflow-x: auto; }
  .expense-stepper a { justify-content: center; padding: 5px; }
  .expense-stepper a span { display: none; }
  .expense-field-grid,
  .expense-live-preview,
  .expense-sticky-summary { grid-template-columns: 1fr; }
  .expense-wide-field,
  .expense-preview-wide,
  .expense-sticky-summary .panel { grid-column: auto; }
  #expensesView .expense-stage { padding: 14px; border-radius: 17px; }
  .expense-stage-head { align-items: flex-start; }
  .expense-stage-head h3 { font-size: 18px; }
  .expense-history-panel { padding: 12px; }
}

@media (max-width: 430px) {
  .expense-filter-toolbar { grid-template-columns: 1fr; }
  .expense-filter-toolbar #expensesSearch { grid-column: auto; }
  .expense-summary-metrics { grid-template-columns: 1fr; }
}

/* Catálogo asistido: vitrina operativa inspirada en flujos simples de comercio. */
#catalogView {
  --catalog-accent: #b8f054;
  --catalog-soft: rgba(184, 240, 84, .075);
  --catalog-border: rgba(184, 240, 84, .2);
}

.catalog-section-head { align-items: flex-end; }

.catalog-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.catalog-summary-card {
  display: grid;
  gap: 4px;
  min-height: 108px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.018));
}

.catalog-summary-card > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.catalog-summary-card > strong { color: var(--text); font-size: 30px; line-height: 1; }
.catalog-summary-card > small { color: var(--muted); font-size: 11px; }
.catalog-summary-card.is-warning { border-color: rgba(247,201,72,.36); background: linear-gradient(145deg, rgba(247,201,72,.09), rgba(255,255,255,.018)); }
.catalog-summary-card.is-warning > strong { color: var(--warn); }
.catalog-summary-card.is-danger { border-color: rgba(255,107,107,.35); background: linear-gradient(145deg, rgba(255,107,107,.085), rgba(255,255,255,.018)); }
.catalog-summary-card.is-danger > strong { color: var(--danger); }

.catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.65fr) repeat(3, minmax(145px, .65fr)) auto;
  gap: 9px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.025);
}

.catalog-toolbar label {
  display: grid;
  gap: 5px;
  min-width: 0;
  margin: 0;
}

.catalog-toolbar label > span,
.catalog-editor-head span,
.catalog-identity-box > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.catalog-toolbar input,
.catalog-toolbar select { min-width: 0; min-height: 42px; }

.catalog-view-switch {
  display: flex;
  gap: 5px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(4,9,7,.55);
}

.catalog-view-switch button { min-height: 34px; padding: 7px 10px; border-radius: 9px; }
.catalog-view-switch button.is-active { color: #0b1209; border-color: var(--catalog-accent); background: var(--catalog-accent); }

.catalog-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(350px, .72fr);
  gap: 12px;
  align-items: start;
}

.catalog-browser-panel { min-width: 0; padding: 12px; }
.catalog-editor-panel { position: sticky; top: 90px; min-width: 0; max-height: calc(100vh - 112px); overflow: auto; scrollbar-width: thin; }

.catalog-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.catalog-editor-head h3 { margin: 3px 0 0; font-size: 20px; }
.catalog-editor-head .compact { display: none; }
.catalog-result-summary { display: flex; gap: 7px; align-items: baseline; min-height: 36px; padding: 3px 4px 10px; color: var(--muted); }
.catalog-result-summary strong { color: var(--text); font-size: 21px; }
.catalog-result-summary small { margin-left: auto; color: var(--catalog-accent); }

.catalog-product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.catalog-product-card {
  display: grid;
  grid-template-rows: 118px minmax(72px, auto) auto;
  gap: 11px;
  min-width: 0;
  min-height: 242px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: linear-gradient(150deg, rgba(255,255,255,.045), rgba(255,255,255,.018));
  box-shadow: none;
  text-align: left;
}

.catalog-product-card:hover,
.catalog-product-card:focus-visible { border-color: rgba(184,240,84,.45); background: linear-gradient(150deg, rgba(184,240,84,.095), rgba(255,255,255,.025)); transform: translateY(-1px); }
.catalog-product-card.is-selected { border-color: var(--catalog-accent); box-shadow: 0 0 0 2px rgba(184,240,84,.11); }
.catalog-product-card.is-inactive { opacity: .58; }

.catalog-product-visual {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 30%, rgba(184,240,84,.11), rgba(4,9,7,.38));
}

.catalog-product-visual .catalog-thumb { width: 88px; height: 88px; border: 0; background: transparent; }
.catalog-product-visual img.catalog-thumb { object-fit: contain; }

.catalog-stock-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.catalog-product-visual .catalog-stock-pill { position: absolute; right: 7px; bottom: 7px; }
.catalog-stock-pill.is-ok { color: #8ee6b2; border-color: rgba(97,211,148,.28); background: rgba(97,211,148,.11); }
.catalog-stock-pill.is-low { color: #ffd76d; border-color: rgba(247,201,72,.32); background: rgba(247,201,72,.11); }
.catalog-stock-pill.is-out { color: #ff9b9b; border-color: rgba(255,107,107,.32); background: rgba(255,107,107,.11); }

.catalog-product-copy { display: grid; align-content: start; gap: 4px; min-width: 0; }
.catalog-product-category { color: var(--catalog-accent); font-size: 10px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.catalog-product-copy strong { overflow: hidden; font-size: 14px; line-height: 1.25; text-overflow: ellipsis; }
.catalog-product-copy small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.catalog-product-price { display: grid; gap: 2px; align-self: end; }
.catalog-product-price strong { color: var(--catalog-accent); font-size: 19px; }
.catalog-product-price small { color: var(--muted); font-size: 10px; }

#catalogTable .table-scroll { max-height: min(62vh, 620px); }
#catalogTable td > strong,
#catalogTable td > small { display: block; }
#catalogTable td > small { margin-top: 3px; color: var(--muted); }
#catalogTable tr.is-selected td { background: rgba(184,240,84,.08); }

.catalog-pagination { margin: 12px -12px -12px; border-radius: 0 0 18px 18px; }
.catalog-empty { min-height: 260px; }
.catalog-empty strong,
.catalog-empty span { display: block; }

.catalog-identity-box {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--catalog-border);
  border-radius: 15px;
  background: var(--catalog-soft);
}

.catalog-identity-box > strong { color: var(--catalog-accent); font-size: 18px; }
.catalog-identity-box > small { color: var(--muted); }

@media (max-width: 1240px) {
  .catalog-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .catalog-search-field { grid-column: span 2; }
  .catalog-product-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}

@media (max-width: 980px) {
  .catalog-workspace { grid-template-columns: 1fr; }
  .catalog-editor-panel { display: none; position: static; max-height: none; }
  .catalog-editor-panel.is-open { display: block; }
  .catalog-editor-head .compact { display: inline-flex; width: auto; }
}

@media (max-width: 680px) {
  .catalog-section-head { align-items: stretch; }
  .catalog-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-summary-card { min-height: 94px; padding: 12px; }
  .catalog-summary-card > strong { font-size: 26px; }
  .catalog-toolbar { grid-template-columns: 1fr 1fr; padding: 10px; }
  .catalog-search-field { grid-column: 1 / -1; }
  .catalog-view-switch { grid-column: 1 / -1; }
  .catalog-view-switch button { width: 50%; }
  .catalog-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .catalog-product-card { grid-template-rows: 92px minmax(76px, auto) auto; min-height: 218px; padding: 9px; border-radius: 15px; }
  .catalog-product-visual .catalog-thumb { width: 70px; height: 70px; }
  .catalog-product-copy strong { font-size: 13px; }
  .catalog-product-price strong { font-size: 17px; }
  .catalog-pagination { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .catalog-toolbar { grid-template-columns: 1fr; }
  .catalog-search-field,
  .catalog-view-switch { grid-column: auto; }
  .catalog-product-grid { grid-template-columns: 1fr; }
  .catalog-product-card { grid-template-columns: 94px minmax(0, 1fr); grid-template-rows: auto auto; min-height: 128px; }
  .catalog-product-visual { grid-row: 1 / 3; min-height: 104px; }
  .catalog-product-copy { align-self: center; }
  .catalog-product-price { align-self: start; }
  .catalog-summary-card > span { font-size: 9px; }
}
.inventory-forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.inventory-forecast-card {
  display: grid;
  gap: 6px;
  min-height: 116px;
  padding: 13px;
  text-align: left;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 92%, var(--brand) 8%);
  border: 1px solid color-mix(in srgb, var(--line) 72%, var(--brand) 28%);
  border-radius: 16px;
  box-shadow: none;
}

.inventory-forecast-card strong,
.inventory-forecast-card b {
  color: var(--text);
}

.inventory-forecast-card small {
  color: var(--muted);
}

.inventory-forecast-card.risk-sin_stock,
.inventory-forecast-card.risk-critico {
  border-color: color-mix(in srgb, #ff667a 70%, var(--line));
  background: color-mix(in srgb, var(--panel) 88%, #ff667a 12%);
}

.inventory-forecast-card.risk-alto,
.inventory-forecast-card.risk-prever {
  border-color: color-mix(in srgb, #ffc857 62%, var(--line));
  background: color-mix(in srgb, var(--panel) 90%, #ffc857 10%);
}

@media (max-width: 680px) {
  .inventory-forecast-grid {
    grid-template-columns: 1fr;
  }

  .inventory-forecast-card {
    min-height: 0;
  }
}

/* Centro de control de inventario · flujo operativo y BI */
.inventory-command-head { align-items: flex-end; }
.inventory-command-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.inventory-command-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 2px 10px;
  align-items: center;
  min-height: 92px;
  padding: 14px;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,.035), rgba(255,255,255,.012));
  box-shadow: none;
}
.inventory-command-card > span {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  border: 1px solid color-mix(in srgb, var(--brand) 38%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--brand) 9%, transparent);
}
.inventory-command-card strong { font-size: 14px; }
.inventory-command-card small { grid-column: 2; color: var(--muted); line-height: 1.35; }
.inventory-command-card:hover,
.inventory-command-card.is-active {
  border-color: color-mix(in srgb, var(--brand) 66%, var(--line));
  background: linear-gradient(145deg, color-mix(in srgb, var(--panel) 86%, var(--brand) 14%), var(--panel));
  transform: translateY(-1px);
}
.inventory-operations-shell { min-height: 360px; margin-bottom: 16px; }
.inventory-operation-panel { display: none; }
.inventory-operation-panel.is-active { display: block; animation: inventoryPanelIn .18s ease-out; }
.inventory-operation-heading { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.inventory-operation-heading > span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  color: #0c130f;
  font-weight: 950;
  border-radius: 15px;
  background: var(--brand);
}
.inventory-operation-heading h3,
.inventory-operation-heading p { margin: 0; }
.inventory-operation-heading p { margin-top: 3px; color: var(--muted); }
.inventory-bi-panel { margin-bottom: 16px; overflow: hidden; }
.compact-field { display: grid; gap: 4px; min-width: 130px; }
.compact-field > span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.inventory-bi-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
  margin: 14px 0;
}
.inventory-kpi {
  display: grid;
  gap: 7px;
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.025);
}
.inventory-kpi > span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.inventory-kpi > strong { color: var(--text); font-size: clamp(22px, 2vw, 30px); line-height: 1; }
.inventory-kpi > small { color: var(--muted); line-height: 1.3; }
.inventory-kpi.danger { border-color: color-mix(in srgb, var(--danger) 58%, var(--line)); background: color-mix(in srgb, var(--panel) 90%, var(--danger) 10%); }
.inventory-kpi.warn { border-color: color-mix(in srgb, var(--warn) 56%, var(--line)); background: color-mix(in srgb, var(--panel) 91%, var(--warn) 9%); }
.inventory-kpi.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.inventory-bi-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .8fr); gap: 10px; margin-bottom: 10px; }
.inventory-bi-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(5,12,9,.4); }
.inventory-bi-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.inventory-bi-card-head div { display: grid; gap: 3px; }
.inventory-bi-card-head span { color: var(--brand); font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.inventory-bi-card-head small { color: var(--muted); text-align: right; }
.inventory-flow-chart { display: flex; align-items: flex-end; gap: 5px; height: 190px; padding-top: 20px; overflow-x: auto; }
.inventory-flow-column { display: grid; grid-template-rows: minmax(0, 1fr) auto; align-items: end; gap: 6px; min-width: 28px; height: 100%; flex: 1; }
.inventory-flow-column small { color: var(--muted); font-size: 8px; text-align: center; writing-mode: vertical-rl; }
.inventory-flow-stack { display: flex; flex-direction: column; justify-content: flex-end; width: 100%; min-height: 8px; overflow: hidden; border-radius: 7px 7px 2px 2px; background: rgba(255,255,255,.035); }
.inventory-flow-stack span { display: block; min-height: 3px; }
.inventory-flow-stack .flow-entrada { background: var(--ok); }
.inventory-flow-stack .flow-salida { background: var(--danger); }
.inventory-flow-stack .flow-traslado { background: #65a8ff; }
.inventory-flow-stack .flow-conteo { background: var(--warn); }
.inventory-location-cards { display: grid; gap: 9px; margin-top: 14px; }
.inventory-location-cards article { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 13px; border: 1px solid rgba(255,255,255,.07); border-radius: 14px; background: rgba(255,255,255,.025); }
.inventory-location-cards article > span { color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.inventory-location-cards article > strong { font-size: 20px; }
.inventory-location-cards article > small { color: var(--muted); }
.inventory-location-cards article > b { grid-column: 2; grid-row: 2; color: var(--brand); text-align: right; }
.inventory-location-cards article > em { grid-column: 1 / -1; color: var(--danger); font-size: 10px; font-style: normal; }
.inventory-location-cards article > em.ok { color: var(--ok); }
.inventory-data-quality { display: flex; gap: 10px; align-items: center; margin: 10px 0; padding: 10px 13px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); font-size: 11px; }
.inventory-data-quality strong { color: var(--text); white-space: nowrap; }
.inventory-data-quality.is-warning { border-color: color-mix(in srgb, var(--warn) 48%, var(--line)); background: rgba(247,201,72,.055); }
.inventory-data-quality.is-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.inventory-balance-panel { margin-bottom: 16px; }
#inventoryAttentionTable td small,
#stockTable td small { display: block; margin-top: 4px; color: var(--muted); }
#inventoryAttentionTable td button { margin-top: 7px; }

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

@media (max-width: 680px) {
  .inventory-command-strip,
  .inventory-bi-kpis { grid-template-columns: 1fr; }
  .inventory-command-card { min-height: 78px; }
  .inventory-operations-shell { min-height: 0; }
  .inventory-operation-heading { align-items: flex-start; }
  .inventory-data-quality { align-items: flex-start; flex-direction: column; }
  .inventory-flow-chart { height: 160px; }
}

/* Inventario visual 2026-08-29: operacion progresiva, tactil y responsive. */
#stockView {
  --inventory-surface: #121a17;
  --inventory-surface-soft: #18221e;
  --inventory-accent: #b8f054;
  --inventory-blue: #79b8ff;
}

.inventory-command-head { margin-bottom: 12px; }
.inventory-command-head h2 { margin-bottom: 5px; font-size: clamp(25px, 3vw, 38px); }
.inventory-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inventory-export-menu { position: relative; }
.inventory-export-menu > summary {
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 52%, var(--line));
  border-radius: 13px;
  color: #0a120d;
  background: var(--brand);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  list-style: none;
}
.inventory-export-menu > summary::-webkit-details-marker { display: none; }
.inventory-export-popover {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 9px;
  width: min(340px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #16201c;
  box-shadow: var(--shadow);
}
.inventory-export-popover p { margin: -3px 0 3px; color: var(--muted); font-size: 11px; }
.inventory-export-popover label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }

#stockView .role-operation-banner {
  min-height: 0;
  margin-bottom: 10px;
  padding: 10px 13px;
  border-radius: 14px;
}

.inventory-status-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 18px;
}
.inventory-status-summary > button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  min-height: 86px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  color: var(--text);
  background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.018));
  box-shadow: none;
  text-align: left;
}
.inventory-status-summary > button:hover { border-color: rgba(184,240,84,.48); transform: translateY(-1px); }
.inventory-status-summary span { grid-column: 1; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.inventory-status-summary strong { grid-column: 1; font-size: 24px; line-height: 1; }
.inventory-status-summary small { grid-column: 1; color: var(--muted); }
.inventory-status-summary b { grid-column: 2; grid-row: 1 / 4; align-self: center; color: var(--muted); font-size: 25px; }
.inventory-status-summary > button.danger { border-color: rgba(255,107,107,.35); background: linear-gradient(145deg, rgba(255,107,107,.10), rgba(255,255,255,.015)); }
.inventory-status-summary > button.warn { border-color: rgba(247,201,72,.34); background: linear-gradient(145deg, rgba(247,201,72,.09), rgba(255,255,255,.015)); }
.inventory-status-summary > button.ok strong { color: #aee98b; }

.inventory-task-heading { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin: 0 2px 9px; }
.inventory-task-heading > div { display: grid; gap: 2px; }
.inventory-task-heading span { color: var(--brand); font-size: 10px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.inventory-task-heading strong { font-size: 17px; }
.inventory-task-heading small { color: var(--muted); }

#stockView .inventory-command-strip { gap: 8px; margin: 0 0 18px; }
#stockView .inventory-command-card {
  grid-template-columns: 46px minmax(0, 1fr) auto;
  min-height: 88px;
  padding: 12px;
  border-radius: 17px;
}
#stockView .inventory-command-card > span { grid-row: 1 / 3; width: 46px; height: 46px; font-size: 21px; }
#stockView .inventory-command-card strong { grid-column: 2; font-size: 14px; }
#stockView .inventory-command-card small { grid-column: 2 / 4; font-size: 10px; }
#stockView .inventory-command-card em { grid-column: 3; grid-row: 1; color: var(--brand); font-size: 10px; font-style: normal; font-weight: 900; text-transform: uppercase; }

.inventory-section-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 5px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(4,9,7,.54);
}
.inventory-section-tabs button {
  display: grid;
  gap: 2px;
  min-height: 54px;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.inventory-section-tabs button:hover { color: var(--text); background: rgba(255,255,255,.035); transform: none; }
.inventory-section-tabs button.is-active { color: #0b120d; background: var(--brand); }
.inventory-section-tabs button strong { font-size: 13px; }
.inventory-section-tabs button small { color: inherit; font-size: 9px; opacity: .78; }
.inventory-view-panel { display: none; }
.inventory-view-panel.is-active { display: block; animation: inventoryPanelIn .16s ease-out; }

.inventory-stock-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.45fr) minmax(170px, .55fr) minmax(150px, .48fr) auto;
  gap: 9px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--inventory-surface);
}
.inventory-stock-toolbar label { display: grid; gap: 5px; min-width: 0; margin: 0; }
.inventory-stock-toolbar label > span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.inventory-stock-toolbar input,
.inventory-stock-toolbar select { min-width: 0; min-height: 43px; }
.inventory-search-field input { border-color: rgba(184,240,84,.34); font-size: 14px; }
.inventory-view-toggle { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 13px; }
.inventory-view-toggle button { min-height: 35px; padding: 7px 9px; border-radius: 9px; }
.inventory-view-toggle button.is-active { color: #0b120d; border-color: var(--brand); background: var(--brand); }
.inventory-results-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 54px; padding: 7px 4px; }
.inventory-results-head > div { display: grid; gap: 2px; }
.inventory-results-head strong { font-size: 18px; }
.inventory-results-head small,
.inventory-results-head > span { color: var(--muted); font-size: 10px; }
.inventory-list-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(150px, .55fr) minmax(150px, .55fr) auto;
  gap: 8px;
  align-items: end;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid rgba(121,184,255,.24);
  border-radius: 15px;
  background: rgba(121,184,255,.045);
}
.inventory-list-filters label { display: grid; gap: 4px; margin: 0; }
.inventory-list-filters label > span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.inventory-list-filters input,
.inventory-list-filters select,
.inventory-list-filters button { min-height: 40px; }
.inventory-stock-list { min-width: 820px; }

#stockView .inventory-forecast-grid {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
#stockView .inventory-forecast-card { min-width: min(280px, 78vw); min-height: 104px; scroll-snap-align: start; }

.inventory-product-stage.is-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(430px, 1fr));
  gap: 9px;
}
.inventory-product-card {
  display: grid;
  grid-template-columns: 70px minmax(150px, 1fr) minmax(128px, auto);
  grid-template-rows: auto 1fr auto;
  gap: 9px 13px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: linear-gradient(145deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.inventory-product-card:hover { border-color: rgba(184,240,84,.38); transform: translateY(-1px); }
.inventory-product-card.is-selected { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(184,240,84,.09); }
.inventory-product-card.risk-sin_stock,
.inventory-product-card.risk-critico,
.inventory-product-card.risk-auditar { border-left: 4px solid var(--danger); }
.inventory-product-card.risk-alto,
.inventory-product-card.risk-prever { border-left: 4px solid var(--warn); }
.inventory-product-visual { grid-row: 1 / 3; display: grid; align-content: center; justify-items: center; gap: 7px; min-width: 0; }
.inventory-product-visual .catalog-thumb { width: 62px; height: 62px; }
.inventory-product-visual > span { overflow: hidden; width: 70px; color: var(--muted); font-size: 8px; font-weight: 900; text-align: center; text-overflow: ellipsis; text-transform: uppercase; }
.inventory-product-main { display: grid; align-content: start; gap: 2px; min-width: 0; }
.inventory-product-main > small { color: var(--brand); font-size: 9px; font-weight: 900; }
.inventory-product-main h3 { overflow: hidden; margin: 0; font-size: 15px; line-height: 1.2; text-overflow: ellipsis; }
.inventory-product-main p { margin: 1px 0 0; color: var(--muted); font-size: 10px; }
.inventory-product-quantity { display: grid; justify-items: end; align-content: start; gap: 2px; text-align: right; }
.inventory-product-quantity > span { color: var(--muted); font-size: 9px; }
.inventory-product-quantity > strong { color: var(--ok); font-size: 24px; line-height: 1; }
.inventory-product-quantity > strong small { color: inherit; font-size: 10px; }
.inventory-product-quantity > em { color: var(--muted); font-size: 9px; font-style: normal; }
.inventory-product-quantity.is-out > strong,
.inventory-product-quantity.is-negative > strong { color: var(--danger); }
.inventory-product-health { grid-column: 2; display: grid; align-content: end; gap: 3px; min-width: 0; }
.inventory-product-health > span { margin-bottom: 2px; }
.inventory-product-health > strong { font-size: 11px; }
.inventory-product-health > small { color: var(--muted); font-size: 9px; line-height: 1.35; }
.inventory-product-actions { grid-column: 3; display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; align-self: end; }
.inventory-product-actions button { min-height: 32px; padding: 6px 9px; border-radius: 10px; font-size: 9px; }
.inventory-product-actions button:first-child { color: #0b120d; border-color: var(--brand); background: var(--brand); }
.inventory-empty-state { display: grid; place-items: center; gap: 4px; min-height: 220px; padding: 32px; border: 1px dashed var(--line); border-radius: 20px; color: var(--muted); text-align: center; }
.inventory-empty-state strong { color: var(--text); font-size: 18px; }

.inventory-stock-list .inventory-list-product { display: flex; gap: 9px; align-items: center; min-width: 230px; }
.inventory-stock-list .inventory-list-product .catalog-thumb { width: 38px; height: 38px; border-radius: 10px; }
.inventory-stock-list .inventory-list-product span { display: grid; gap: 2px; }
.inventory-stock-list td > small { display: block; margin-top: 3px; color: var(--muted); }
.inventory-pagination { margin-top: 10px; }

.inventory-priority-details { margin-top: 10px; border: 1px solid var(--line); border-radius: 15px; }
.inventory-priority-details > summary { padding: 12px 14px; color: var(--text); cursor: pointer; font-weight: 900; }
.inventory-priority-details > div { padding: 0 10px 10px; }

.inventory-daily-work {
  margin: 12px 0;
  padding: 15px;
  border: 1px solid rgba(184,240,84,.32);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(184,240,84,.075), rgba(255,255,255,.018) 45%, rgba(97,211,148,.035));
  scroll-margin-top: 72px;
}
.inventory-daily-work-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.inventory-daily-work-head h3 { margin: 2px 0 3px; font-size: 19px; }
.inventory-daily-work-head p { margin: 0; color: var(--muted); }
.inventory-daily-work-date { display: grid; gap: 2px; min-width: 170px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 13px; background: rgba(0,0,0,.15); text-align: right; }
.inventory-daily-work-date span,
.inventory-daily-work-date small { color: var(--muted); font-size: 9px; }
.inventory-daily-work-date strong { color: var(--brand); font-size: 15px; }
.inventory-daily-plan-summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 11px 0; }
.inventory-daily-plan-summary > span { display: inline-flex; gap: 6px; align-items: center; min-height: 28px; padding: 5px 9px; border: 1px solid rgba(255,193,79,.25); border-radius: 999px; color: var(--muted); background: rgba(255,193,79,.06); font-size: 9px; font-weight: 850; text-transform: uppercase; }
.inventory-daily-plan-summary > span.owner { border-color: rgba(97,211,148,.24); background: rgba(97,211,148,.05); }
.inventory-daily-plan-summary > span.is-clear { border-color: rgba(97,211,148,.35); color: var(--ok); }
.inventory-daily-plan-summary b { color: var(--text); font-size: 12px; }
.inventory-daily-jobs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.inventory-daily-job { display: grid; gap: 9px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 15px; background: rgba(7,15,11,.58); }
.inventory-daily-job.priority-p0 { border-left-color: var(--danger); background: linear-gradient(135deg, rgba(255,107,107,.075), rgba(7,15,11,.58)); }
.inventory-daily-job.priority-p1 { border-left-color: #ff8b55; }
.inventory-daily-job.priority-p3 { border-left-color: var(--brand); }
.inventory-daily-job > header { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.inventory-daily-job > header span { color: var(--muted); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.inventory-daily-job > header b { padding: 4px 7px; border-radius: 999px; color: #10170f; background: var(--brand); font-size: 8px; letter-spacing: .04em; }
.inventory-daily-job-product { display: grid; gap: 2px; min-width: 0; }
.inventory-daily-job-product strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.inventory-daily-job-product small { color: var(--muted); font-size: 9px; }
.inventory-daily-job-objective { display: grid; gap: 2px; padding: 8px 9px; border-radius: 11px; background: rgba(184,240,84,.06); }
.inventory-daily-job-objective span { color: var(--muted); font-size: 8px; font-weight: 900; text-transform: uppercase; }
.inventory-daily-job-objective strong { color: var(--brand); font-size: 14px; }
.inventory-daily-job-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.inventory-daily-job-metrics > span { display: grid; gap: 2px; padding: 6px 7px; border: 1px solid rgba(255,255,255,.055); border-radius: 9px; }
.inventory-daily-job-metrics small { color: var(--muted); font-size: 8px; }
.inventory-daily-job-metrics b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.inventory-daily-job > p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.inventory-daily-job > footer { display: flex; gap: 9px; align-items: end; justify-content: space-between; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.06); }
.inventory-daily-job > footer > span { display: grid; gap: 2px; }
.inventory-daily-job > footer small { color: var(--muted); font-size: 8px; }
.inventory-daily-job > footer strong { font-size: 10px; }
.inventory-daily-job > footer > div { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.inventory-daily-job > footer button { min-height: 31px; padding: 5px 8px; font-size: 8px; }
.inventory-daily-empty { grid-column: 1 / -1; display: grid; place-items: center; gap: 3px; min-height: 120px; padding: 20px; border: 1px dashed rgba(97,211,148,.32); border-radius: 14px; color: var(--muted); text-align: center; }
.inventory-daily-empty strong { color: var(--ok); font-size: 15px; }
.inventory-daily-plan-note { margin: 9px 0 0; color: var(--muted); font-size: 9px; }

.inventory-recent-activity { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.inventory-recent-activity > button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 4px 9px;
  align-items: center;
  min-height: 62px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255,255,255,.022);
  box-shadow: none;
  text-align: left;
}
.inventory-recent-activity > button:hover { border-color: rgba(184,240,84,.42); transform: none; }
.inventory-activity-sign { grid-row: 1 / 3; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; font-size: 19px; font-weight: 950; }
.inventory-activity-sign.is-in { color: var(--ok); background: rgba(97,211,148,.10); }
.inventory-activity-sign.is-out { color: var(--danger); background: rgba(255,107,107,.10); }
.inventory-recent-activity > button > div { display: grid; gap: 2px; min-width: 0; }
.inventory-recent-activity strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.inventory-recent-activity small { color: var(--muted); font-size: 9px; }
.inventory-recent-activity b { font-size: 12px; text-align: right; }
.inventory-recent-activity b.is-in { color: var(--ok); }
.inventory-recent-activity b.is-out { color: var(--danger); }
.inventory-recent-activity em { grid-column: 2 / 4; color: var(--muted); font-size: 8px; font-style: normal; }
.inventory-history-panel { margin-top: 10px; }

.inventory-operation-modal { position: fixed; z-index: 1600; inset: 0; display: none; }
.inventory-operation-modal.is-open { display: grid; place-items: center; }
.inventory-operation-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.inventory-operation-dialog {
  position: relative;
  width: min(900px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #111a16;
  box-shadow: 0 32px 90px rgba(0,0,0,.54);
  scrollbar-width: thin;
}
.inventory-operation-modal-head { position: sticky; z-index: 3; top: -18px; display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin: -18px -18px 16px; padding: 17px 18px 14px; border-bottom: 1px solid var(--line); background: rgba(17,26,22,.96); backdrop-filter: blur(10px); }
.inventory-operation-modal-head h2 { margin: 2px 0 3px; font-size: 23px; }
.inventory-operation-modal-head p { margin: 0; color: var(--muted); }
.inventory-operation-modal-head .eyebrow { color: var(--brand); }
.inventory-operation-dialog .inventory-operations-shell { min-height: 0; margin: 0; }
.inventory-operation-dialog .inventory-operation-panel { padding: 0; border: 0; background: transparent; }
body.inventory-modal-open { overflow: hidden; }
#stockReceiptNewFields.form-grid { margin: 0; }
.inventory-transfer-target {
  display: grid;
  gap: 3px;
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid rgba(97,211,148,.34);
  border-radius: 13px;
  background: rgba(97,211,148,.055);
}
.inventory-transfer-target span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.inventory-transfer-target strong { color: var(--ok); font-size: 16px; }
.inventory-transfer-target small { color: var(--muted); font-size: 9px; }

.inventory-assisted-picker { position: relative; display: grid; gap: 7px; }
.inventory-assisted-picker > label { margin: 0; }
.inventory-assisted-picker input[type="search"] { min-height: 45px; border-color: rgba(184,240,84,.34); font-size: 14px; }
.inventory-picker-selected { min-height: 54px; }
.inventory-picker-selected.is-ready { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 9px; align-items: center; min-height: 58px; padding: 8px 10px; border: 1px solid rgba(97,211,148,.32); border-radius: 13px; background: rgba(97,211,148,.06); }
.inventory-picker-selected .catalog-thumb { width: 38px; height: 38px; border-radius: 10px; }
.inventory-picker-selected > div { display: grid; gap: 2px; min-width: 0; }
.inventory-picker-selected strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-picker-selected small { color: var(--muted); font-size: 9px; }
.inventory-picker-selected b { color: var(--brand); font-size: 12px; }
.inventory-picker-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 260px; overflow: auto; scrollbar-width: thin; }
.inventory-picker-results > button { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px; align-items: center; min-height: 56px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: rgba(255,255,255,.025); box-shadow: none; text-align: left; }
.inventory-picker-results > button:hover { border-color: rgba(184,240,84,.48); transform: none; }
.inventory-picker-results .catalog-thumb { width: 36px; height: 36px; border-radius: 9px; }
.inventory-picker-results > button > span { display: grid; gap: 2px; min-width: 0; }
.inventory-picker-results strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.inventory-picker-results small { color: var(--muted); font-size: 8px; }

@media (max-width: 1100px) {
  .inventory-status-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-stock-toolbar { grid-template-columns: minmax(240px, 1fr) repeat(2, minmax(150px, .55fr)); }
  .inventory-view-toggle { grid-column: 1 / -1; justify-self: end; }
  .inventory-product-stage.is-cards { grid-template-columns: 1fr; }
  .inventory-daily-jobs { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .inventory-command-head { align-items: stretch; }
  .inventory-head-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .inventory-head-actions > button,
  .inventory-export-menu,
  .inventory-export-menu > summary { width: 100%; }
  .inventory-export-menu > summary { text-align: center; }
  .inventory-export-popover { position: fixed; top: auto; right: 10px; bottom: 10px; left: 10px; width: auto; }
  .inventory-status-summary { grid-template-columns: 1fr 1fr; }
  .inventory-status-summary > button { min-height: 78px; padding: 10px; }
  .inventory-status-summary strong { font-size: 20px; }
  .inventory-task-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  #stockView .inventory-command-strip { grid-template-columns: 1fr; }
  #stockView .inventory-command-card { display: grid; grid-template-columns: 38px minmax(0, 1fr); min-height: 104px; align-content: start; }
  #stockView .inventory-command-card > span { width: 38px; height: 38px; font-size: 18px; }
  #stockView .inventory-command-card strong { align-self: center; font-size: 12px; }
  #stockView .inventory-command-card small { grid-column: 1 / -1; font-size: 9px; }
  #stockView .inventory-command-card em { display: none; }
  .inventory-section-tabs { position: sticky; z-index: 20; top: 0; }
  .inventory-section-tabs button { min-height: 48px; padding: 7px 8px; text-align: center; }
  .inventory-section-tabs button small { display: none; }
  .inventory-stock-toolbar { grid-template-columns: 1fr; }
  .inventory-list-filters { grid-template-columns: 1fr; }
  .inventory-view-toggle { grid-column: auto; justify-self: stretch; }
  .inventory-view-toggle button { flex: 1; }
  .inventory-results-head { align-items: flex-start; flex-direction: column; gap: 3px; }
  .inventory-product-card { grid-template-columns: 58px minmax(0, 1fr); grid-template-rows: auto auto auto auto; }
  .inventory-product-visual { grid-row: 1 / 2; }
  .inventory-product-visual .catalog-thumb { width: 52px; height: 52px; }
  .inventory-product-visual > span { display: none; }
  .inventory-product-main { grid-column: 2; }
  .inventory-product-quantity { grid-column: 1 / -1; justify-items: start; text-align: left; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.06); }
  .inventory-product-health { grid-column: 1 / -1; }
  .inventory-product-actions { grid-column: 1 / -1; justify-content: stretch; }
  .inventory-product-actions button { flex: 1; min-height: 38px; }
  .inventory-recent-activity { grid-template-columns: 1fr; }
  .inventory-bi-kpis { grid-template-columns: 1fr 1fr; }
  .inventory-daily-work { padding: 11px; border-radius: 16px; }
  .inventory-daily-work-head { align-items: stretch; flex-direction: column; }
  .inventory-daily-work-date { min-width: 0; text-align: left; }
  .inventory-daily-job-metrics { grid-template-columns: 1fr; }
  .inventory-daily-job > footer { align-items: stretch; flex-direction: column; }
  .inventory-daily-job > footer > div,
  .inventory-daily-job > footer button { width: 100%; }
  .inventory-kpi { min-height: 100px; }
  .inventory-operation-modal.is-open { display: block; }
  .inventory-operation-dialog { width: 100%; min-height: 100vh; max-height: 100vh; padding: 14px; border: 0; border-radius: 0; }
  .inventory-operation-modal-head { top: -14px; margin: -14px -14px 14px; padding: 14px; }
  .inventory-operation-modal-head h2 { font-size: 20px; }
  .inventory-operation-modal-head > div > p:last-child { display: none; }
  .inventory-operation-heading > span { width: 40px; height: 40px; flex-basis: 40px; }
  .inventory-operation-heading p { font-size: 10px; }
  .inventory-picker-results { grid-template-columns: 1fr; }
  .inventory-picker-selected.is-ready { grid-template-columns: 36px minmax(0, 1fr); }
  .inventory-picker-selected b { grid-column: 2; }
  .inventory-pagination { align-items: stretch; }
}
/* Employee governance: the API enforces the same boundaries independently. */
.tabs .nav-group.hidden { display: none !important; }
[data-permission].hidden { display: none !important; }
body[data-employee-role="VENDEDOR"] #stockView [onclick*="openStockHistory"],
body[data-employee-role="VENDEDOR"] #stockView .inventory-export-menu,
body[data-employee-role="VENDEDOR"] #inventoryStatusSummary button:last-child,
body[data-employee-role="VENDEDOR"] #stockView [onclick*="setInventoryView('activity')"] { display: none !important; }
body[data-employee-role="VENDEDOR"] .cash-report-panel,
body[data-employee-role="VENDEDOR"] #cashClosingView > details,
body[data-employee-role="VENDEDOR"] #cashSessionDate,
body[data-employee-role="VENDEDOR"] [data-inventory-view="activity"],
body[data-employee-role="VENDEDOR"] [data-inventory-panel="activity"],
body[data-employee-role="VENDEDOR"] #exportInventoryXlsx,
body[data-employee-role="VENDEDOR"] #stockHistoryDrawer,
body[data-employee-role="JEFE_CULTIVO"] #productionWholesaleCustomers,
body[data-employee-role="JARDINERO"] #productionWholesaleCustomers {
  display: none !important;
}
body[data-employee-role="JEFE_CULTIVO"] #expensesSummary .card:nth-child(2),
body[data-employee-role="JEFE_CULTIVO"] #expensesSummary .card:nth-child(3),
body[data-employee-role="JEFE_CULTIVO"] #expensesSummary .card:nth-child(4) { display: none !important; }

/* Referral network: verified attribution, two-way reading and campaign readiness. */
#referralsView { --referral-accent: #b9ff54; --referral-ok: #62dda0; --referral-warn: #ffc45f; }
.referral-section-head { align-items: flex-end; }
.referral-integrity-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 14px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255,196,95,.25);
  border-radius: 16px;
  background: linear-gradient(120deg, rgba(255,196,95,.09), rgba(255,255,255,.02));
}
.referral-integrity-note strong { color: var(--referral-warn); font-size: 12px; text-transform: uppercase; letter-spacing: .055em; }
.referral-integrity-note span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.referral-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px; margin-bottom: 12px; }
.referral-kpi {
  display: grid;
  gap: 5px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.018));
}
.referral-kpi span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.referral-kpi strong { align-self: end; color: var(--referral-accent); font-size: clamp(21px, 2vw, 30px); font-variant-numeric: tabular-nums; }
.referral-kpi small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.referral-kpi.is-alert { border-color: rgba(255,196,95,.35); background: linear-gradient(145deg, rgba(255,196,95,.09), rgba(255,255,255,.018)); }
.referral-kpi.is-alert strong { color: var(--referral-warn); }
.referral-contacts-panel { margin-bottom: 12px; padding: 13px; }
.referral-contacts-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.referral-contacts-head > div { display: grid; gap: 3px; }
.referral-contacts-head h3, .referral-contacts-head p { margin: 0; }
.referral-contacts-head p, .referral-contacts-head > span { color: var(--muted); font-size: 10px; }
.referral-contacts-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 11px; }
.referral-contact-card { display: grid; gap: 10px; min-width: 0; padding: 12px; border: 1px solid rgba(185,255,84,.2); border-radius: 16px; background: linear-gradient(145deg, rgba(185,255,84,.055), rgba(255,255,255,.018)); }
.referral-contact-card.needs-review { border-color: rgba(255,196,95,.3); }
.referral-contact-card header, .referral-contact-card footer { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.referral-contact-card header > div { display: grid; gap: 3px; min-width: 0; }
.referral-contact-card header strong { overflow: hidden; color: var(--text); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.referral-contact-card header small { color: var(--muted); font-size: 9px; }
.referral-contact-status { flex: none; padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; font-size: 8px; font-weight: 900; text-transform: uppercase; }
.referral-contact-status.is-activo { color: var(--referral-ok); border-color: rgba(98,221,160,.3); }
.referral-contact-status.is-pendiente { color: var(--referral-warn); border-color: rgba(255,196,95,.35); }
.referral-contact-status.is-inactivo { color: var(--muted); }
.referral-contact-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 0; }
.referral-contact-card dl > div:first-child { grid-column: 1 / -1; }
.referral-contact-card dt { color: var(--muted); font-size: 8px; font-weight: 850; text-transform: uppercase; }
.referral-contact-card dd { overflow: hidden; margin: 2px 0 0; color: var(--text); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.referral-contact-impact { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.referral-contact-impact span { display: grid; gap: 2px; padding: 7px; border-radius: 10px; color: var(--muted); background: rgba(0,0,0,.17); font-size: 8px; }
.referral-contact-impact b { color: var(--text); font-size: 10px; }
.referral-contact-card footer { justify-content: flex-end; }
.referral-contact-editor-card textarea { min-height: 82px; }
.patient-referrer-picker { display: grid; gap: 7px; padding: 11px; border: 1px solid rgba(185,255,84,.22); border-radius: 15px; background: rgba(185,255,84,.035); }
.patient-referrer-picker > small { color: var(--muted); font-size: 9px; }
.referral-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(290px, .65fr); gap: 12px; align-items: start; }
.referral-control-panel, .referral-leaders-panel { padding: 13px; }
.referral-leaders-panel { position: sticky; top: 10px; }
.referral-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) repeat(2, minmax(145px, .38fr)); gap: 8px; }
.referral-toolbar label { display: grid; gap: 5px; }
.referral-toolbar label > span { color: var(--muted); font-size: 10px; font-weight: 850; }
.referral-result-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 45px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.referral-result-head > div { display: flex; gap: 8px; align-items: center; }
.referral-result-head strong { color: var(--text); font-size: 15px; }
.referral-result-head span { padding-left: 8px; border-left: 1px solid var(--line); }
.referral-result-head label { display: flex; gap: 7px; align-items: center; }
.referral-result-head select { min-height: 34px; padding: 5px 28px 5px 8px; }
.referral-directory-head, .referral-row { display: grid; grid-template-columns: minmax(190px, 1.1fr) minmax(150px, .85fr) minmax(175px, 1fr) 115px 76px; gap: 10px; align-items: center; }
.referral-directory-head { padding: 7px 10px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.referral-directory-list { display: grid; gap: 6px; }
.referral-row { min-height: 78px; padding: 10px; border: 1px solid rgba(255,255,255,.07); border-radius: 15px; background: rgba(255,255,255,.022); transition: border-color .16s ease, background .16s ease; }
.referral-row:hover { border-color: rgba(185,255,84,.29); background: rgba(185,255,84,.035); }
.referral-row.needs-review { border-left: 3px solid var(--referral-warn); }
.referral-person { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 9px; align-items: center; min-width: 0; }
.referral-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #10170d; background: linear-gradient(135deg, var(--referral-accent), #68db84); font-size: 12px; font-weight: 950; }
.referral-person > span, .referral-inbound, .referral-outbound, .referral-state { display: grid; gap: 3px; min-width: 0; }
.referral-person strong, .referral-inbound strong, .referral-outbound strong { overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.referral-person small, .referral-inbound small, .referral-outbound small, .referral-state small { color: var(--muted); font-size: 9px; }
.referral-inbound span, .referral-outbound span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.referral-status { display: inline-flex; justify-self: start; padding: 5px 8px; border: 1px solid; border-radius: 999px; font-size: 9px; font-weight: 900; letter-spacing: .035em; text-transform: uppercase; }
.referral-status.is-confirmed { color: var(--referral-ok); border-color: rgba(98,221,160,.3); background: rgba(98,221,160,.08); }
.referral-status.is-pending { color: var(--referral-warn); border-color: rgba(255,196,95,.32); background: rgba(255,196,95,.08); }
.referral-action { display: flex; justify-content: flex-end; }
.referral-pagination { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.referral-pagination > div { display: flex; gap: 8px; align-items: center; }
.referral-leader-list { display: grid; gap: 7px; margin-top: 12px; }
.referral-leader-list > button { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 7px 9px; align-items: center; width: 100%; padding: 9px; border: 1px solid rgba(255,255,255,.07); border-radius: 13px; color: var(--text); background: rgba(255,255,255,.02); box-shadow: none; text-align: left; }
.referral-leader-list > button:hover { border-color: rgba(185,255,84,.35); transform: none; }
.referral-leader-list b { grid-row: 1 / 3; display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; color: #14200b; background: var(--referral-accent); }
.referral-leader-list span { display: grid; gap: 2px; min-width: 0; }
.referral-leader-list strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.referral-leader-list small, .referral-leader-list i { color: var(--muted); font-size: 9px; font-style: normal; }
.referral-leader-list i { grid-column: 2; }

.referral-editor-backdrop { padding: 12px; }
.referral-editor-card { width: min(880px, 100%); max-height: calc(100vh - 24px); overflow: auto; padding: 0; border-radius: 24px; background: #101914; }
.referral-editor-head { position: sticky; z-index: 3; top: 0; display: flex; justify-content: space-between; gap: 16px; padding: 17px; border-bottom: 1px solid var(--line); background: rgba(16,25,20,.96); backdrop-filter: blur(10px); }
.referral-editor-head h2, .referral-editor-head p { margin: 0; }
.referral-editor-head h2 { margin: 3px 0; font-size: 22px; }
.referral-editor-head p:last-child { color: var(--muted); font-size: 11px; }
.referral-two-fronts { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 14px 17px 0; }
.referral-two-fronts article { display: grid; gap: 5px; min-height: 91px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); }
.referral-two-fronts small { color: var(--referral-accent); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.referral-two-fronts strong { font-size: 13px; }
.referral-two-fronts span { display: flex; flex-wrap: wrap; gap: 5px; color: var(--muted); font-size: 10px; }
.referral-two-fronts i { padding: 4px 6px; border-radius: 8px; color: var(--text); background: rgba(185,255,84,.08); font-style: normal; }
.referral-editor-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 17px 17px; }
.referral-editor-form fieldset { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; }
.referral-editor-form legend { margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 850; }
.referral-source-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.referral-source-choices button { min-height: 48px; padding: 8px; border: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.025); box-shadow: none; }
.referral-source-choices button.is-active { color: #15200c; border-color: var(--referral-accent); background: var(--referral-accent); }
.referral-editor-form > label, .referral-patient-picker { display: grid; gap: 6px; }
.referral-patient-picker { grid-column: 1 / -1; padding: 11px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.02); }
.referral-selected-candidate { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; color: var(--muted); background: rgba(185,255,84,.055); }
.referral-selected-candidate strong { color: var(--text); }
.referral-candidate-results { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 220px; overflow: auto; }
.referral-candidate-results > button { display: grid; gap: 2px; padding: 9px; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.025); box-shadow: none; text-align: left; }
.referral-candidate-results > button:hover { border-color: rgba(185,255,84,.4); transform: none; }
.referral-candidate-results small, .referral-candidate-results > span { color: var(--muted); font-size: 10px; }
.referral-candidate-results > span { grid-column: 1 / -1; padding: 7px; }
.referral-editor-form .full { grid-column: 1 / -1; }
.referral-editor-warning { padding: 10px; border-left: 3px solid var(--referral-warn); border-radius: 0 10px 10px 0; color: var(--muted); background: rgba(255,196,95,.06); font-size: 10px; }
.referral-editor-actions { display: flex; justify-content: flex-end; gap: 8px; }
.referral-editor-actions button { width: auto; }

@media (max-width: 1180px) {
  .referral-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .referral-contacts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .referral-layout { grid-template-columns: 1fr; }
  .referral-leaders-panel { position: static; }
}
@media (max-width: 860px) {
  .referral-toolbar { grid-template-columns: 1fr 1fr; }
  .referral-search { grid-column: 1 / -1; }
  .referral-directory-head { display: none; }
  .referral-row { grid-template-columns: 1fr 1fr auto; }
  .referral-person { grid-column: 1 / 3; }
  .referral-state { grid-column: 3; grid-row: 1; }
  .referral-inbound, .referral-outbound { padding-top: 8px; border-top: 1px solid rgba(255,255,255,.06); }
  .referral-action { grid-column: 3; }
}
@media (max-width: 600px) {
  .referral-section-head { align-items: stretch; }
  .referral-section-head .toolbar { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .referral-integrity-note { grid-template-columns: 1fr; }
  .referral-kpis { grid-template-columns: 1fr 1fr; }
  .referral-contacts-head { align-items: flex-start; flex-direction: column; }
  .referral-contacts-grid { grid-template-columns: 1fr; }
  .referral-contact-card footer { display: grid; grid-template-columns: 1fr 1fr; }
  .referral-contact-card footer button { width: 100%; }
  .referral-kpi { min-height: 100px; padding: 11px; }
  .referral-toolbar { grid-template-columns: 1fr; }
  .referral-search { grid-column: auto; }
  .referral-result-head { align-items: flex-start; flex-direction: column; }
  .referral-row { grid-template-columns: 1fr auto; }
  .referral-person { grid-column: 1; }
  .referral-state { grid-column: 2; }
  .referral-inbound, .referral-outbound { grid-column: 1 / -1; }
  .referral-action { grid-column: 1 / -1; }
  .referral-action button { width: 100%; }
  .referral-pagination { align-items: stretch; flex-direction: column; }
  .referral-pagination > div { justify-content: space-between; }
  .referral-editor-backdrop { padding: 0; }
  .referral-editor-card { width: 100%; min-height: 100vh; max-height: 100vh; border: 0; border-radius: 0; }
  .referral-two-fronts, .referral-editor-form { grid-template-columns: 1fr; }
  .referral-source-choices { grid-template-columns: 1fr 1fr; }
  .referral-candidate-results { grid-template-columns: 1fr; }
  .referral-editor-form > label, .referral-editor-form .full { grid-column: 1; }
  .referral-editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .referral-editor-actions button { width: 100%; }
}
.dynamic-authorization-panel {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.dynamic-authorization-countdown {
  margin: 10px 0 14px;
  color: var(--muted);
}

.dynamic-authorization-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.dynamic-authorization-card {
  display: grid;
  gap: 8px;
}

.dynamic-authorization-card code {
  color: var(--accent);
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 900;
  letter-spacing: .18em;
}

.expense-document-gateway {
  display: grid;
  gap: 14px;
  margin: 16px 0;
  padding: 16px;
  border-color: rgba(184,255,77,.28);
  background: linear-gradient(145deg, rgba(22,37,27,.96), rgba(10,18,14,.98));
}

.expense-document-gateway > header,
.remittance-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.expense-document-gateway h3,
.expense-document-gateway p,
.remittance-head h3,
.remittance-head p { margin: 0; }
.expense-document-gateway header > div > p:last-child,
.remittance-head p { margin-top: 4px; color: var(--muted); font-size: 12px; }

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

.expense-document-card {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  gap: 11px;
  align-items: center;
  min-height: 108px;
  padding: 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.025);
  text-align: left;
}

.expense-document-card:hover,
.expense-document-card.is-active { border-color: var(--expense-accent); background: var(--expense-soft); transform: translateY(-1px); }
.expense-document-card > b { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; color: #0b1408; background: var(--expense-accent); font-size: 17px; }
.expense-document-card > span { display: grid; gap: 2px; min-width: 0; }
.expense-document-card strong { font-size: 15px; }
.expense-document-card small { color: var(--expense-accent); font-size: 11px; font-weight: 800; }
.expense-document-card em { margin-top: 4px; color: var(--muted); font-size: 11px; font-style: normal; line-height: 1.35; }
.expense-document-card > i { color: var(--expense-accent); font-size: 22px; font-style: normal; }
.expense-document-gateway.is-selected .expense-document-card { min-height: 76px; }
.expense-document-empty,
.purchase-mode-help { padding: 11px 12px; border: 1px dashed var(--expense-border); border-radius: 13px; color: var(--muted); background: rgba(255,255,255,.018); font-size: 12px; }
.purchase-mode-help { grid-column: 1 / -1; color: var(--text); }
.remittance-panel { padding: 17px; }
.remittance-head > span { padding: 6px 9px; border: 1px solid rgba(255,199,87,.3); border-radius: 999px; color: #ffd76d; background: rgba(255,199,87,.08); font-size: 11px; font-weight: 850; white-space: nowrap; }
.remittance-line { grid-template-columns: 36px minmax(260px,2fr) minmax(130px,.65fr) auto; }

.purchase-receipt-panel {
  margin: 18px 0;
  border-color: rgba(185, 255, 76, .34);
  background: linear-gradient(145deg, rgba(25, 40, 29, .96), rgba(13, 22, 17, .98));
}

.purchase-receipt-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  cursor: pointer;
  list-style: none;
}

.purchase-receipt-panel > summary span,
.purchase-lines-head > div,
.purchase-footer > div {
  display: grid;
  gap: 4px;
}

.purchase-receipt-panel > summary small,
.purchase-lines-head span,
.purchase-product-assist > small,
.purchase-footer small {
  color: var(--muted);
}

.purchase-receipt-panel > summary > strong,
.purchase-receipt-panel > summary > span > b,
.purchase-footer > div > strong {
  color: var(--lime);
}

.purchase-pending-note {
  display: grid;
  gap: 5px;
  margin: 16px 0;
  padding: 13px 15px;
  border: 1px solid rgba(255, 199, 87, .42);
  border-radius: 14px;
  background: rgba(255, 199, 87, .08);
}

.purchase-pending-note span {
  color: var(--muted);
}

.purchase-receipt-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.purchase-header-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.purchase-file-field {
  grid-column: span 2;
}

.purchase-lines-head,
.purchase-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.purchase-lines {
  display: grid;
  gap: 10px;
}

.purchase-line {
  display: grid;
  grid-template-columns: 36px minmax(260px, 2fr) minmax(110px, .55fr) minmax(140px, .7fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(7, 13, 10, .56);
}

.purchase-line-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  align-self: center;
  border-radius: 11px;
  color: #0b130d;
  background: var(--lime);
  font-weight: 900;
}

.purchase-product-assist {
  position: relative;
}

.purchase-product-results {
  position: absolute;
  z-index: 25;
  top: calc(100% - 16px);
  right: 0;
  left: 0;
  display: grid;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #101a14;
  box-shadow: 0 18px 34px rgba(0, 0, 0, .42);
}

.purchase-product-results button {
  display: grid;
  gap: 2px;
  padding: 10px;
  text-align: left;
  color: var(--text);
  border: 0;
  background: transparent;
}

.purchase-product-results button:hover {
  background: rgba(185, 255, 76, .1);
}

.purchase-product-results small {
  color: var(--muted);
}

.purchase-footer > label {
  flex: 1;
}

@media (max-width: 900px) {
  .expense-document-options { grid-template-columns: 1fr; }
  .purchase-header-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .purchase-line {
    grid-template-columns: 34px minmax(0, 1fr) minmax(105px, .45fr);
  }

  .remittance-line { grid-template-columns: 34px minmax(0,1fr) minmax(115px,.45fr); }

  .purchase-line > label:last-of-type {
    grid-column: 2;
  }
}

@media (max-width: 620px) {
  .expense-document-gateway > header,
  .remittance-head { align-items: stretch; flex-direction: column; }
  .purchase-header-grid,
  .purchase-line {
    grid-template-columns: 1fr;
  }

  .remittance-line { grid-template-columns: 1fr; }

  .purchase-file-field,
  .purchase-line > label:last-of-type {
    grid-column: auto;
  }

  .purchase-line-number {
    display: none;
  }

  .purchase-lines-head,
  .purchase-footer,
  .purchase-receipt-panel > summary {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Administración de proveedores y cuenta corriente por ventas. */
.supplier-account-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.supplier-workspace {
  display: grid;
  grid-template-columns: minmax(245px, 300px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.supplier-directory-panel {
  position: sticky;
  top: 82px;
  padding: 12px;
}

.supplier-directory-panel > label { display: grid; gap: 6px; margin-bottom: 10px; }

.supplier-directory {
  display: grid;
  gap: 7px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.supplier-directory-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  box-shadow: none;
}

.supplier-directory-card:hover,
.supplier-directory-card.is-active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--panel));
}

.supplier-directory-card span { display: grid; gap: 3px; }
.supplier-directory-card span:last-child { justify-items: end; }
.supplier-directory-card small { color: var(--muted); }
.supplier-directory-card em { font-style: normal; }

.supplier-detail { display: grid; gap: 14px; min-width: 0; }

.supplier-profile-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.supplier-profile-head > div:nth-child(2) { display: flex; gap: 8px; align-items: center; }

.supplier-contact-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.supplier-contact-strip div {
  padding: 10px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.supplier-contact-strip dt {
  color: var(--muted);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.supplier-contact-strip dd { margin: 4px 0 0; font-weight: 700; }

.supplier-alert {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: .035em;
}

.supplier-alert.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 46%, var(--line)); }
.supplier-alert.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 46%, var(--line)); }
.supplier-alert.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 46%, var(--line)); }

.supplier-balance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.supplier-balance-grid article { display: grid; gap: 5px; min-height: 94px; }
.supplier-balance-grid span { color: var(--muted); }
.supplier-balance-grid strong { font-size: clamp(1.15rem, 2vw, 1.7rem); }
.supplier-balance-due { border-color: color-mix(in srgb, var(--brand) 54%, var(--line)); }

.supplier-cost-warning {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--warn) 42%, var(--line));
  border-radius: 14px;
}

.supplier-cost-warning span { color: var(--muted); }

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

.supplier-action-card { display: grid; gap: 10px; align-content: start; }
.supplier-action-card > div:first-child p { margin: 3px 0 0; }
.supplier-action-card label { display: grid; gap: 5px; }

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

.supplier-product-results {
  display: grid;
  max-height: 235px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.supplier-product-results button {
  display: grid;
  gap: 2px;
  padding: 10px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  box-shadow: none;
}

.supplier-product-results button:hover { background: var(--panel-2); }
.supplier-product-results small { color: var(--muted); }
.supplier-products-panel small { display: block; color: var(--muted); }
.row-muted { opacity: .62; }
.supplier-editor-card { width: min(720px, calc(100vw - 24px)); }

@media (max-width: 1100px) {
  .supplier-account-summary,
  .supplier-balance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .supplier-workspace { grid-template-columns: 230px minmax(0, 1fr); }
  .supplier-action-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .supplier-workspace { grid-template-columns: 1fr; }
  .supplier-directory-panel { position: static; }
  .supplier-directory { grid-template-columns: repeat(2, minmax(210px, 1fr)); max-height: none; overflow-x: auto; }
  .supplier-profile-head { grid-template-columns: 1fr; }
  .supplier-profile-head > div:nth-child(2) { justify-content: space-between; }
  .supplier-contact-strip { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .supplier-account-summary,
  .supplier-balance-grid,
  .supplier-payment-grid { grid-template-columns: 1fr; }
  .supplier-directory { display: flex; }
  .supplier-directory-card { min-width: min(270px, 82vw); }
  .supplier-page-head .section-actions { width: 100%; }
  .supplier-page-head .section-actions button { flex: 1; }
}
