:root {
  --rojo: #C0392B;
  --rojo-osc: #96281B;
  --azul: #14264f;
  --dorado: #B8860B;
  --fondo: #F7F8FA;
  --borde: #E4E7EC;
  --texto: #1F2937;
  --texto-suave: #6B7280;
  --verde: #15803D;
  --verde-bg: #DCFCE7;
  --ambar: #92400E;
  --ambar-bg: #FEF3C7;
  --rojo-badge: #B91C1C;
  --rojo-badge-bg: #FEE2E2;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--fondo); color: var(--texto); font-size: 15px; }
a { color: var(--rojo); }

/* ---- Login ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0d1b3e 0%, #14264f 60%, #1a2a4a 100%); padding: 20px; }
.login-caja { background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { height: 74px; margin-bottom: 12px; }
.login-caja h1 { font-size: 20px; font-weight: 800; color: var(--azul); }
.login-sub { color: var(--texto-suave); font-size: 14px; margin: 4px 0 22px; }
.login-caja form { text-align: left; }
.login-caja label { display: block; font-size: 13px; font-weight: 600; color: var(--texto-suave); margin-bottom: 14px; }
.login-caja input { width: 100%; margin-top: 5px; }

/* ---- Estructura panel ---- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #fff; border-right: 1px solid var(--borde); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid var(--borde); }
.brand img { height: 42px; }
.brand strong { display: block; font-size: 15px; color: var(--azul); }
.brand span { font-size: 12px; color: var(--texto-suave); }
.sidebar nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--texto); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.sidebar nav a:hover { background: var(--fondo); }
.sidebar nav a.activo { background: rgba(192,57,43,.09); color: var(--rojo); }
.sidebar nav a .ico { width: 20px; text-align: center; }
.sidebar-pie { border-top: 1px solid var(--borde); padding: 14px 16px; }
.quien { font-weight: 700; font-size: 13px; }
.quien span { display: block; font-weight: 400; font-size: 12px; color: var(--texto-suave); }
.salir { font-size: 13px; }
.contenido { flex: 1; padding: 24px 28px; min-width: 0; }
.topbar h1 { font-size: 22px; font-weight: 800; color: var(--azul); margin-bottom: 18px; }

/* ---- Componentes ---- */
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.tarjeta h2 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.metrica { background: #fff; border: 1px solid var(--borde); border-radius: 14px; padding: 16px 18px; }
.met-num { display: block; font-size: 24px; font-weight: 800; color: var(--azul); }
.met-lbl { font-size: 12px; color: var(--texto-suave); font-weight: 600; }
.metrica.alerta-bajo .met-num { color: var(--ambar); }
.metrica.alerta-agotado .met-num { color: var(--rojo-badge); }
.dos-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--texto-suave); padding: 8px 10px; border-bottom: 1px solid var(--borde); }
td { padding: 9px 10px; border-bottom: 1px solid var(--fondo); vertical-align: middle; }
tbody tr:hover { background: #FAFBFC; }
.num { text-align: right; }
tfoot td { font-weight: 800; border-top: 2px solid var(--borde); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 50px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.ok, .badge.entrada { background: var(--verde-bg); color: var(--verde); }
.badge.bajo { background: var(--ambar-bg); color: var(--ambar); }
.badge.agotado, .badge.salida { background: var(--rojo-badge-bg); color: var(--rojo-badge); }

.btn { display: inline-block; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--borde); background: #fff; color: var(--texto); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--fondo); }
.btn.primario { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn.primario:hover { background: var(--rojo-osc); }
.btn.btn-block { width: 100%; text-align: center; }
.btn.chico { padding: 5px 10px; font-size: 13px; border-radius: 8px; }

input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(192,57,43,.25); border-color: var(--rojo); }
label { font-size: 13px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-grid label { display: block; }
.form-grid input, .form-grid select { margin-top: 5px; }
.acciones-form { margin-top: 18px; display: flex; gap: 10px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; font-size: 14px; }
.flash.ok { background: var(--verde-bg); color: var(--verde); }
.flash.error { background: var(--rojo-badge-bg); color: var(--rojo-badge); }
.vacio { color: var(--texto-suave); font-size: 14px; padding: 10px 0; }

.buscador { margin-bottom: 14px; max-width: 360px; }

/* ---- Salida multi-artículo / Quirófano ---- */
.motivos { display: flex; flex-wrap: wrap; gap: 10px; }
.motivo-radio { display: flex; align-items: center; gap: 8px; border: 1px solid var(--borde); border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.motivo-radio:has(input:checked) { border-color: var(--rojo); background: rgba(192,57,43,.07); color: var(--rojo); }
.motivo-radio input { width: auto; accent-color: var(--rojo); }
.grid-articulos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; max-height: 480px; overflow-y: auto; padding: 2px; }
.art-card { border: 1px solid var(--borde); border-radius: 12px; padding: 12px 14px; background: #fff; }
.art-card.sin-stock { opacity: .5; }
.art-card.con-cantidad { border-color: var(--rojo); background: rgba(192,57,43,.05); }
.art-nombre { font-weight: 700; font-size: 13px; line-height: 1.3; min-height: 34px; }
.art-stock { font-size: 12px; color: var(--texto-suave); margin: 4px 0 8px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--borde); background: #fff; font-size: 16px; font-weight: 700; cursor: pointer; }
.stepper button:hover:not(:disabled) { background: var(--fondo); }
.stepper button:disabled { opacity: .4; cursor: default; }
.stepper input { text-align: center; padding: 6px 4px; }
.barra-fija { position: sticky; bottom: 0; background: #fff; border: 1px solid var(--borde); border-radius: 14px; padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; box-shadow: 0 -6px 24px rgba(0,0,0,.06); }
#resumen-salida { font-weight: 700; font-size: 14px; color: var(--texto-suave); }
.fila-encabezado { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.fila-encabezado h2 { margin: 0; }
.fila-acciones { display: flex; gap: 8px; align-items: center; }
.inline { display: inline; }
.detalle-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 18px; font-size: 14px; color: var(--texto); }

/* ---- Móvil ---- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 8px; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-pie { display: flex; justify-content: space-between; align-items: center; }
  .contenido { padding: 16px; }
  .dos-columnas { grid-template-columns: 1fr; }
  .tarjeta { overflow-x: auto; }
}
