/* ============================================================================
   Panel de la clínica — shell de escritorio
   Las primitivas (botones, tarjetas, formularios, tablas, chips, KPIs, toast)
   viven en design-system.css. Aquí solo el armazón y los compuestos del panel.
   ========================================================================= */

/* ------------------------------------------------------------- Estructura - */

.layout { display: flex; height: 100vh; overflow: hidden; }

/* El fondo del sidebar usa el color de marca de la clínica (--brand-600); todo
   su texto/íconos usan --on-brand (blanco o tinta oscura, el que más contraste
   dé contra ESE color exacto — se recalcula en runtime, ver applyBrandColor()
   en admin.js) para que nunca quede letra ilegible sin importar el color elegido. */
.sidebar {
  width: 256px; flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: var(--s5) var(--s3);
  background: var(--brand-600); border-right: 1px solid var(--border);
}

/* El logo identifica la plataforma: discreto y pequeño, nunca protagonista. */
.brand {
  display: flex; align-items: center; min-height: 36px;
  padding: 0 var(--s3); margin-bottom: var(--s6);
  font-size: 14px; font-weight: 600; letter-spacing: -.01em; color: var(--on-brand);
}
.brand .easy { color: var(--on-brand); opacity: .8; }
.brand img { display: block; }

.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar nav button {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: 9px var(--s3);
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; color: var(--on-brand); opacity: .8; text-align: left;
  transition: background var(--t-fast), color var(--t-fast), opacity var(--t-fast);
}
.sidebar nav button .ico { width: 18px; font-size: 15px; text-align: center; opacity: .9; flex: none; }
.sidebar nav button:hover { background: rgba(127,127,127,.22); opacity: 1; }
.sidebar nav button.active { background: var(--brand-50); color: var(--brand-700); opacity: 1; font-weight: 600; }
.sidebar nav button.active .ico { opacity: 1; }

.side-footer { padding: var(--s4) var(--s3) 0; border-top: 1px solid rgba(127,127,127,.3); }
.side-footer .who { font-size: 13px; font-weight: 600; color: var(--on-brand); }
.side-footer .role {
  font-size: 11.5px; color: var(--on-brand); opacity: .7; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-footer button {
  width: 100%; margin-top: var(--s3); padding: 7px var(--s3);
  border: 1px solid rgba(127,127,127,.4); border-radius: var(--r-sm);
  background: transparent; color: var(--on-brand);
  font-size: 12.5px; font-weight: 500; text-align: center;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.side-footer button:hover { background: var(--err-bg); color: var(--err); border-color: var(--err-br); }

.main { flex: 1; overflow-y: auto; padding: var(--s7); }

/* ----------------------------------------------------------------- Login -- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s6); background: var(--bg); }
.login-card {
  width: 100%; max-width: 400px; padding: var(--s7);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg);
}
.login-card .brand2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.login-card .brand2 .easy { color: var(--brand-600); }
.login-card .sub { margin: 2px 0 var(--s6); }
.login-card .btn { height: 42px; margin-top: var(--s2); }

/* Ilustraciones decorativas a los lados del login (solo pantallas anchas;
   ocultas por defecto, se muestran cuando la pantalla visible es el login). */
.side-deco {
  display: none; position: fixed; top: 50%; transform: translateY(-50%); z-index: 0;
  width: min(30vw, 340px); height: auto; pointer-events: none; user-select: none;
}
.side-deco.left { left: clamp(0px, 3vw, 60px); }
.side-deco.right { right: clamp(0px, 3vw, 60px); }
@media (min-width: 1280px) {
  body:has(.login-wrap) .side-deco { display: block; }
}

/* ------------------------------------------------------------- Dashboard -- */

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); align-items: start; }

.dash-label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); margin: var(--s6) 0 var(--s3);
}
.cards + .dash-label, .grid2 + .dash-label { margin-top: var(--s7); }

/* Barras horizontales de las gráficas del dashboard */
.hbars { display: flex; flex-direction: column; gap: var(--s3); }
.hbar-row { display: grid; grid-template-columns: 38% 1fr auto; align-items: center; gap: var(--s3); }
.hbar-lbl { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-full); overflow: hidden; }
.hbar-fill {
  display: block; height: 100%; min-width: 2px; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand-500), var(--brand-600));
  transition: width 420ms cubic-bezier(.2,.7,.2,1);
}
.hbar-val { font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Desglose de egresos por categoría (Finanzas) */
.cat-row {
  display: grid; grid-template-columns: 30px 130px 1fr auto 20px;
  align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s2); border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--t-fast);
}
.cat-row:hover { background: var(--surface-2); }
.cat-row .ico { font-size: 15px; text-align: center; opacity: .8; }
.cat-row .nm { font-size: 12.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-row .track { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-full); overflow: hidden; }
.cat-row .fill { display: block; height: 100%; min-width: 2px; border-radius: var(--r-full); background: var(--err); opacity: .8; }
.cat-row .amt { font-size: 12.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cat-row .arrow { color: var(--text-faint); font-size: 12px; }

.row-link { cursor: pointer; border-radius: var(--r-sm); transition: background var(--t-fast); }
.row-link:hover { background: var(--surface-2); }

/* Ítems dinámicos de factura (el JS puede sobrescribir las columnas) */
.item-row { grid-template-columns: 1fr 70px 90px 90px 120px 34px; }

/* ---------------------------------------------------------------- Modales - */

.modal-mask {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: var(--s5);
  background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px);
  animation: mask-in 150ms ease;
}
@keyframes mask-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 560px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
  padding: var(--s6);
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: 0 24px 48px -12px rgba(16,24,40,.25);
  animation: modal-in 190ms cubic-bezier(.2,.7,.2,1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 17px; margin-bottom: var(--s5); }

/* -------------------------------------------------------------- Responsive */

@media (max-width: 1100px) {
  .grid2 { grid-template-columns: 1fr; }
  .cards.c5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  /* La navegación pasa a una barra superior desplazable: nada se oculta. */
  .layout { flex-direction: column; height: auto; overflow: visible; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center; gap: var(--s4);
    padding: var(--s3) var(--s4);
    border-right: none; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
  }
  .brand { margin-bottom: 0; padding: 0; flex: none; }
  .sidebar nav { flex-direction: row; gap: var(--s1); overflow-x: auto; }
  .sidebar nav button { padding: 7px var(--s3); white-space: nowrap; }
  .side-footer {
    margin-left: auto; padding: 0; border-top: none; flex: none;
    display: flex; align-items: center; gap: var(--s3);
  }
  .side-footer .who, .side-footer .role { display: none; }
  .side-footer button { margin-top: 0; width: auto; padding: 6px var(--s3); }
  .main { padding: var(--s5) var(--s4); overflow: visible; }
}

@media (max-width: 600px) {
  .cards, .cards.c4, .cards.c5 { grid-template-columns: repeat(2, 1fr); }
  .main { padding: var(--s4) var(--s3); }
  .modal { padding: var(--s5); }
  .item-row { grid-template-columns: 1fr 1fr; }
}
