/* ==========================================================================
   DARYPOS — SISTEMA DE DISEÑO "EDITORIAL CLÍNICO / BOUTIQUE"
   ========================================================================== */

:root {
  /* Paleta Base */
  --bg-canvas: #FBF9FF;         /* Lila muy claro */
  --bg-surface: #FFFFFF;        /* Blanco puro para tarjetas */
  --bg-subtle: #F0EBFF;         /* Lila suave para fondos secundarios */
  --ink-primary: #2F2445;       /* Ciruela profunda, legible sobre lila */
  --ink-secondary: #625576;     /* Malva oscuro */
  --ink-muted: #8A7FA0;         /* Malva suave */

  /* Acentos Clínicos & Estéticos */
  --accent-sage: #C9B8F4;       /* Lila pastel (acción principal) */
  --accent-sage-hover: #B9A3EA;
  --accent-sage-soft: #F0EAFF;
  --accent-terracotta: #C46D45; /* Terracota cálido (alertas suaves / crédito) */
  --accent-terracotta-soft: #F9EDE8;

  /* Estados */
  --danger: #C93B3B;
  --danger-soft: #FDECEC;
  --border-light: #E4E1D8;

  /* Tipografía */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Sombras & Radios */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 4px 20px -2px rgba(24, 32, 38, 0.05), 0 1px 3px rgba(24, 32, 38, 0.03);
  --shadow-float: 0 12px 32px -4px rgba(24, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--ink-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
}

/* ==========================================================================
   ESTRUCTURA PRINCIPAL (APP SHELL)
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* BARRA LATERAL */
.sidebar {
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--border-light);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-sage);
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  letter-spacing: -0.03em;
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-secondary);
}

/* Navegación */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 24px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.nav-item i {
  width: 19px;
  height: 19px;
}

.nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--ink-primary);
}

.nav-item.active {
  background-color: var(--accent-sage-soft);
  color: var(--accent-sage);
  font-weight: 600;
}

/* Widget de Estado de Caja */
.caja-status-card {
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
}

.status-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online {
  background-color: #10B981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-sage);
}

.status-amount {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.status-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-secondary);
  margin-bottom: 12px;
}

.caja-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ==========================================================================
   ÁREA PRINCIPAL & TOPBAR
   ========================================================================== */

.main-workspace {
  padding: 28px 36px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.page-heading h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-heading p {
  color: var(--ink-secondary);
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cloud-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-sage);
}

.cloud-badge i {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   COMPONENTES REUTILIZABLES (BOTONES, TARJETAS, INPUTS)
   ========================================================================== */

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn i {
  width: 17px;
  height: 17px;
}

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

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

.btn-outline {
  background-color: transparent;
  border-color: var(--border-light);
  color: var(--ink-primary);
}

.btn-outline:hover {
  background-color: var(--bg-subtle);
}

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

.btn-xs {
  padding: 6px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-light);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.84rem;
}

.btn-lg {
  padding: 14px 20px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view-section.active {
  display: block;
}

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

/* ==========================================================================
   MÓDULO 1: CAJA & FACTURACIÓN (POS)
   ========================================================================== */

.pos-layout {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 24px;
  align-items: start;
}

.catalog-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 11px 16px;
}

.search-box i {
  width: 18px;
  height: 18px;
  color: var(--ink-muted);
}

.search-box input {
  border: none;
  outline: none;
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  background: transparent;
}

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.pill.active {
  background: var(--ink-primary);
  color: #fff;
  border-color: var(--ink-primary);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-float);
  border-color: var(--accent-sage);
}

.item-tag {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--accent-sage-soft);
  color: var(--accent-sage);
  margin-bottom: 10px;
}

.item-tag.retail {
  background: var(--accent-terracotta-soft);
  color: var(--accent-terracotta);
}

.item-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.item-desc {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin-bottom: 16px;
}

.item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px dashed var(--border-light);
}

.price {
  font-weight: 600;
  font-size: 1.05rem;
}

.btn-add {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: var(--accent-sage);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* Ticket / Facturación */
.pos-ticket {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-float);
  position: sticky;
  top: 24px;
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.ticket-header h2 {
  font-size: 1.15rem;
}

.ticket-number {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  padding: 4px 8px;
  border-radius: 6px;
}

.client-selector label,
.payment-mode label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 16px;
}

.select-wrapper select {
  border: none;
  background: transparent;
  width: 100%;
  font-family: var(--font-sans);
  font-weight: 500;
  outline: none;
}

.ticket-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding: 12px 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}

.row-info strong {
  display: block;
  font-weight: 600;
}

.row-info span {
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

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

.btn-icon-danger {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
}

.btn-icon-danger:hover {
  color: var(--danger);
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--ink-secondary);
  cursor: pointer;
}

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ticket-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}

.summary-line.total {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink-primary);
  padding-top: 8px;
  border-top: 1px dashed var(--border-light);
}

/* ==========================================================================
   MÓDULO 2: PACIENTES, FICHA CLÍNICA E HISTORIAL
   ========================================================================== */

.clinical-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 24px;
  align-items: start;
}

.patient-list-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.patient-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.patient-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.patient-card.active {
  border-color: var(--accent-sage);
  background: var(--accent-sage-soft);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-sage);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.avatar.alt {
  background: var(--accent-terracotta);
}

.p-meta h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.p-meta span {
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.clinical-record-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.record-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--ink-primary);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.badge-alert {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
}

.badge-alert i {
  width: 14px;
  height: 14px;
}

.record-sub {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  margin-top: 4px;
}

.clinical-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.clinical-box h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.clinical-box h3 i {
  width: 18px;
  height: 18px;
  color: var(--accent-sage);
}

.data-pairs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pair .lbl {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
}

.pair .val {
  font-size: 0.9rem;
  color: var(--ink-primary);
}

.danger-text {
  color: var(--danger) !important;
  font-weight: 600;
}

.highlight-text {
  color: var(--accent-sage) !important;
  font-weight: 600;
}

.skin-badges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.skin-pill {
  background: var(--bg-canvas);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.skin-pill .lbl {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-secondary);
}

.skin-pill strong {
  font-size: 0.92rem;
  color: var(--accent-sage);
}

.mt-1 {
  margin-top: 16px;
}

/* Historial de Procedimientos */
.section-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.muted-sm {
  font-size: 0.84rem;
  color: var(--ink-secondary);
}

.new-procedure-drawer {
  background: var(--bg-canvas);
  border: 1px dashed var(--accent-sage);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 22px;
}

.new-procedure-drawer h4 {
  font-size: 0.88rem;
  color: var(--accent-sage);
  margin-bottom: 12px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.form-group input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-family: var(--font-sans);
}

.form-actions-right {
  display: flex;
  justify-content: flex-end;
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-left: 2px solid var(--border-light);
  margin-left: 10px;
  padding-left: 20px;
}

.timeline-item {
  position: relative;
}

.timeline-marker {
  position: absolute;
  left: -27px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-sage);
  border: 2px solid var(--bg-surface);
}

.timeline-marker.past {
  background: var(--ink-muted);
}

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

.tl-date {
  font-size: 0.8rem;
  color: var(--ink-secondary);
}

.timeline-content p {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  margin-bottom: 8px;
}

.used-products {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-prod {
  font-size: 0.76rem;
  background: var(--bg-subtle);
  color: var(--ink-primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
}

/* ==========================================================================
   MÓDULO 3: TABLA DE INVENTARIO
   ========================================================================== */

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-light);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-light);
}

.status-pill {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 600;
}

.status-pill.ok {
  background: var(--accent-sage-soft);
  color: var(--accent-sage);
}

.status-pill.low {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==========================================================================
   MÓDULO 4: CUADRE FINANCIERO POR CALENDARIO
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

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

.kpi-card.highlight {
  background: var(--accent-sage);
  color: #fff;
  border-color: var(--accent-sage);
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0.85;
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
}

.kpi-trend {
  font-size: 0.78rem;
  opacity: 0.85;
}

.cal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.cal-day-name {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-secondary);
  padding-bottom: 6px;
}

.cal-cell {
  min-height: 98px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cal-cell.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}

.cal-cell.has-data {
  background: var(--bg-surface);
}

.cal-cell.selected {
  border: 2px solid var(--accent-sage);
  box-shadow: var(--shadow-card);
}

.day-num {
  font-weight: 700;
  font-size: 0.85rem;
}

.day-metrics {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
}

.m-venta { color: var(--ink-primary); font-weight: 600; }
.m-inv { color: var(--accent-terracotta); }
.m-gan { color: var(--accent-sage); font-weight: 700; }


/* ==========================================================================
   MODAL DE FICHA CLÍNICA & FORMULARIOS AVANZADOS
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 32, 38, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px -12px rgba(24, 32, 38, 0.25);
  overflow: hidden;
}

/* El formulario de inventario es largo: debe desplazarse dentro de un modal
   con altura definida para que los campos inferiores sigan siendo clicables. */
#modalNuevoProducto .modal-dialog {
  height: min(88vh, 820px);
}

#modalNuevoProducto .modal-body {
  height: 100%;
}

.modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-canvas);
}

.modal-eyebrow {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-sage);
  margin-bottom: 2px;
}

.modal-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.btn-close-modal {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.btn-close-modal:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-soft);
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 22px;
  min-height: 0;
  overscroll-behavior: contain;
}

.form-section {
  background: var(--bg-canvas);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.form-section-title i {
  width: 17px;
  height: 17px;
  color: var(--accent-sage);
}

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

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.mt-sm {
  margin-top: 14px;
}

.modal-body input[type="text"],
.modal-body input[type="tel"],
.modal-body input[type="date"],
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink-primary);
  transition: border-color 0.15s ease;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--accent-sage);
}

.input-readonly {
  background: var(--bg-subtle) !important;
  font-weight: 600;
  color: var(--accent-sage) !important;
  cursor: not-allowed;
}

.label-danger {
  color: var(--danger);
}

/* Selector Visual de Fototipos (I al VI) */
.phototype-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.photo-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.photo-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.photo-option .swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1);
}

.photo-option strong {
  font-size: 0.8rem;
}

.photo-option small {
  font-size: 0.68rem;
  color: var(--ink-secondary);
}

.photo-option:has(input:checked) {
  border: 2px solid var(--accent-sage);
  background: var(--accent-sage-soft);
}

/* Checkboxes tipo píldora para Tipo de Piel */
.skin-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-pill {
  cursor: pointer;
}

.check-pill input {
  display: none;
}

.check-pill span {
  display: inline-block;
  padding: 7px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 99px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-secondary);
  transition: all 0.15s ease;
}

.check-pill input:checked + span {
  background: var(--accent-sage);
  color: #fff;
  border-color: var(--accent-sage);
  font-weight: 600;
}

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   ESTILOS PARA MODALES DE CAJA E INVENTARIO
   ========================================================================== */

.modal-sm {
  max-width: 480px;
}

.modal-md {
  max-width: 660px;
}

.modal-body input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--ink-primary);
}

.modal-body input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-sage);
}

.input-lg {
  font-size: 1.15rem !important;
  font-weight: 600;
  padding: 12px 14px !important;
}

.arqueo-summary {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.arq-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

.arq-row.total {
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px dashed var(--border-light);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.text-terracotta {
  color: var(--accent-terracotta);
}

.diff-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-sage-soft);
  color: var(--accent-sage);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.diff-box.warning {
  background: var(--danger-soft);
  color: var(--danger);
}

.diff-box.surplus {
  background: var(--accent-terracotta-soft);
  color: var(--accent-terracotta);
}

.insumo-picker-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.insumo-picker-row select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-family: var(--font-sans);
}

.status-pill.empty {
  background: #182026;
  color: #FFFFFF;
}

.form-row-3-proc {
  display: grid;
  grid-template-columns: 1.6fr 0.8fr 1.2fr;
  gap: 12px;
  margin-bottom: 12px;
}

.proc-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.send-pos-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--ink-primary);
  cursor: pointer;
}

.send-pos-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-sage);
}

.badge-pendiente-cobro {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-terracotta-soft);
  color: var(--accent-terracotta);
  margin-left: 8px;
}


.proc-btn-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge-cobrado {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--accent-sage-soft);
  color: var(--accent-sage);
  margin-left: 8px;
}

.btn-cobrar-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent-terracotta);
  background: var(--accent-terracotta-soft);
  color: var(--accent-terracotta);
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.15s ease;
}

.btn-cobrar-item:hover {
  background: var(--accent-terracotta);
  color: #fff;
}

/* Paleta lila pastel: el texto sobre los controles lila conserva contraste. */
.brand-mark,
.btn-primary,
.btn-add,
.avatar,
.kpi-card.highlight,
.check-pill input:checked + span {
  color: var(--ink-primary);
}

.btn-primary:hover {
  color: var(--ink-primary);
}

/* Pantalla de inicio de sesión */
.login-screen {
  align-items: center;
  background: linear-gradient(135deg, #F6F1FF 0%, #E6DAFF 100%);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 2000;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #E1D7FA;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(77, 53, 120, 0.18);
  max-width: 430px;
  padding: 38px;
  width: 100%;
}

.login-mark {
  align-items: center;
  background: var(--accent-sage);
  border-radius: 15px;
  color: var(--ink-primary);
  display: flex;
  font-size: 1.4rem;
  font-weight: 700;
  height: 52px;
  justify-content: center;
  margin-bottom: 22px;
  width: 52px;
}

.login-eyebrow {
  color: #705B9D;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card h1 {
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  margin: 6px 0 8px;
}

.login-copy { color: var(--ink-secondary); font-size: 0.93rem; }

.login-form { display: grid; gap: 9px; margin-top: 26px; }

.login-form label { color: var(--ink-primary); font-size: 0.84rem; font-weight: 700; margin-top: 7px; }

.login-form input {
  background: #fff;
  border: 1px solid #D9CFF1;
  border-radius: var(--radius-sm);
  color: var(--ink-primary);
  font: inherit;
  padding: 12px;
}

.login-form input:focus { border-color: #9474D8; outline: 3px solid #EDE5FF; }
.login-form .btn { margin-top: 12px; }
.login-form .btn:disabled { cursor: wait; opacity: 0.65; }
.login-message { color: var(--danger); font-size: 0.82rem; font-weight: 600; min-height: 18px; }

.stock-replenishment-preview {
  background: var(--accent-sage-soft);
  border: 1px solid #DACCF7;
  border-radius: var(--radius-sm);
  color: var(--ink-primary);
  font-size: 0.82rem;
  margin-top: 14px;
  padding: 10px 12px;
}

.form-save-message {
  color: var(--danger);
  flex: 1 1 100%;
  font-size: 0.78rem;
  font-weight: 600;
  min-height: 0;
}

.form-save-message:empty { display: none; }
.form-save-message[data-type="success"] { color: #26754D; }

.product-image-previews {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.product-image-previews > .muted-sm { grid-column: 1 / -1; }

.product-image-preview {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin: 0;
  overflow: hidden;
}

.product-image-preview img {
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: cover;
  width: 100%;
}

.product-image-preview figcaption {
  color: var(--ink-secondary);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 8px;
}

.product-image-preview.image-error img {
  background: var(--danger-soft);
  min-height: 92px;
  opacity: 0.25;
}

/* Mejoras de inventario, cobros e impresión de facturas */
.tax-line {
  color: var(--accent-terracotta);
}

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

.btn-table-action {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--ink-primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 8px;
}

.btn-table-action:hover {
  border-color: var(--accent-sage);
  color: var(--accent-sage);
}

.daily-movements {
  margin-top: 20px;
  border-top: 1px solid var(--border-light);
  padding-top: 18px;
}

.daily-invoices {
  border-top: 1px solid var(--border-light);
  margin-top: 20px;
  padding-top: 18px;
}

.daily-invoices h3 {
  align-items: center;
  display: flex;
  font-size: 1rem;
  gap: 8px;
  margin: 0 0 4px;
}

.invoice-list { display: grid; gap: 8px; margin-top: 12px; }

.invoice-history-row {
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 10px 12px;
}

.invoice-history-row span {
  color: var(--ink-secondary);
  display: block;
  font-size: 0.82rem;
  margin-top: 2px;
}

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

.invoice-confirmation-summary {
  background: var(--accent-sage-soft);
  border: 1px solid #DACCF7;
  border-radius: var(--radius-sm);
  display: grid;
  gap: 7px;
  padding: 14px;
}

.invoice-confirmation-summary p { margin: 0; }

.invoice-detail-head {
  border-bottom: 1px solid var(--border-light);
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: 16px;
}

.invoice-detail-head h3 { font-size: 1.1rem; margin: 2px 0 0; }
.invoice-detail-head strong { display: block; font-size: 0.9rem; margin-top: 2px; }
.invoice-detail-totals { display: grid; gap: 8px; margin-left: auto; max-width: 320px; width: 100%; }
.invoice-detail-totals span { display: flex; justify-content: space-between; }
.invoice-detail-totals .total { border-top: 2px solid var(--ink-primary); font-size: 1rem; margin-top: 4px; padding-top: 9px; }

.daily-movements h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font-size: 1rem;
}

.movement-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.movement-row {
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.movement-row strong,
.movement-row span {
  display: block;
}

.movement-row span {
  color: var(--ink-secondary);
  font-size: 0.82rem;
  margin-top: 2px;
}

.invoice-delivery-body {
  padding: 24px 28px 28px;
}

.invoice-delivery-summary {
  color: var(--ink-primary);
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.invoice-delivery-actions {
  display: grid;
  gap: 10px;
  margin: 20px 0 14px;
}

.invoice-delivery-actions .btn {
  justify-content: center;
}

.invoice-delivery-note {
  border-top: 1px solid var(--border-light);
  margin: 0;
  padding-top: 14px;
}

@media (max-width: 700px) {
  .app-shell {
    display: block;
    min-height: auto;
  }

  .sidebar {
    bottom: 0;
    box-shadow: 0 -8px 24px rgba(77, 53, 120, 0.12);
    display: block;
    height: auto;
    left: 0;
    min-height: 76px;
    overflow: visible;
    padding: 6px 8px max(8px, env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    top: auto;
    z-index: 900;
  }

  .brand,
  .caja-status-card {
    display: none;
  }

  .nav-menu {
    align-items: stretch;
    display: grid;
    gap: 3px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 0;
  }

  .nav-item {
    align-items: center;
    flex-direction: column;
    font-size: 0.59rem;
    gap: 4px;
    justify-content: center;
    line-height: 1.1;
    min-height: 62px;
    overflow: visible;
    padding: 5px 1px;
    text-align: center;
  }

  /* Lucide reemplaza los elementos <i> por <svg>; se estiliza el SVG final. */
  .nav-item svg {
    display: block;
    flex: 0 0 20px;
    height: 20px;
    overflow: visible;
    stroke-width: 2.2;
    width: 20px;
  }

  .nav-item span {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .main-workspace {
    overflow: visible;
    padding: 18px 14px 120px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
  }

  .page-heading h1 { font-size: 1.35rem; }
  .topbar-actions { gap: 8px; width: 100%; }
  .topbar-actions .btn { flex: 1; padding: 9px 10px; }
  .topbar-actions .btn span { font-size: 0.78rem; }

  .pos-layout,
  .clinical-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .pos-ticket {
    position: static;
  }

  .catalog-toolbar,
  .section-header-flex,
  .record-header,
  .proc-footer-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-pills { overflow-x: auto; padding-bottom: 3px; flex-wrap: nowrap; }
  .pill { flex: 0 0 auto; }
  .catalog-grid { grid-template-columns: 1fr; }
  .clinical-grid,
  .kpi-grid,
  .form-grid-2,
  .form-grid-3,
  .form-row-3-proc,
  .insumo-picker-row { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }

  .patient-list-panel { max-height: none; }
  .patient-cards { flex-direction: row; overflow-x: auto; }
  .patient-card { flex: 0 0 230px; }

  .table-responsive { margin: 0 -14px; overflow-x: auto; padding: 0 14px; }
  .data-table { min-width: 760px; }
  .calendar-grid { min-width: 610px; }
  #view-calendario .card { overflow-x: auto; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-dialog,
  .modal-sm,
  .modal-md,
  .modal-lg {
    border-radius: 20px 20px 0 0;
    max-height: min(90vh, 90dvh);
    max-width: none;
    width: 100%;
  }

  #modalNuevoProducto .modal-dialog {
    height: min(90vh, 90dvh);
  }
  .modal-header,
  .modal-footer { padding-left: 18px; padding-right: 18px; }
  .modal-body {
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-left: 18px;
    padding-right: 18px;
    touch-action: pan-y;
  }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; }

  .login-screen { align-items: flex-start; overflow-y: auto; padding: 24px 16px; }
  .login-card { margin: auto 0; padding: 28px 22px; }
  .product-image-previews { grid-template-columns: repeat(2, minmax(0, 1fr)); }

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

  .invoice-history-row { align-items: flex-start; flex-direction: column; }
  .invoice-history-actions { justify-content: flex-start; }
  .invoice-detail-head { grid-template-columns: 1fr 1fr; }

  .inventory-actions {
    min-width: 130px;
  }
}
