/* =========================================================
   LABORATORIO CLÍNICO ESTHER — Sistema de diseño
   Paleta clínica cálida: teal profesional + acento ámbar
   ========================================================= */
:root{
  --color-primary: #0AA3CF;
  --color-primary-dark: #06627C;
  --color-primary-light: #EAF7FB;
  --color-accent: #F2A65A;
  --color-accent-dark: #D9863A;
  --color-bg: #F5F8F8;
  --color-surface: #FFFFFF;
  --color-border: #E3E9E8;
  --color-text: #1F2A28;
  --color-text-muted: #667370;
  --color-success: #1E8449;
  --color-success-bg: #E7F6EC;
  --color-warning: #B7791F;
  --color-warning-bg: #FDF3E2;
  --color-danger: #AF2326;
  --color-danger-bg: #FBEAE8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16,40,36,.05), 0 1px 3px rgba(16,40,36,.06);
  --shadow-md: 0 6px 16px rgba(16,40,36,.08), 0 2px 6px rgba(16,40,36,.05);
  --font-display: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --sidebar-width: 264px;
  --topbar-height: 58px;
}

*{box-sizing:border-box;}
html{-webkit-text-size-adjust:100%;}
body{
  margin:0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  font-size:15px;
  line-height:1.5;
}
h1,h2,h3,h4{
  font-family: var(--font-display);
  color: var(--color-primary-dark);
  margin:0 0 8px;
  letter-spacing:-.01em;
}
h1{font-size:24px; font-weight:800;}
h3{font-size:16px; font-weight:700;}
a{color:var(--color-primary);}

.layout{display:flex; min-height:100vh;}

/* ---------- Overlay (móvil) ---------- */
.sidebar-overlay{
  display:none; position:fixed; inset:0; background:rgba(8,20,18,.45);
  z-index:40; backdrop-filter: blur(1px);
}
.sidebar-overlay.active{display:block;}

/* ---------- Sidebar ---------- */
.sidebar{
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--color-primary-dark), #06332e 85%);
  color:#fff;
  display:flex;
  flex-direction:column;
  flex-shrink:0;
  position:sticky;
  top:0;
  height:100vh;
  z-index:50;
  transition: transform .25s ease;
}
.sidebar-brand{
  padding:22px 20px 18px;
  display:flex; align-items:center; gap:10px;
  border-bottom:1px solid rgba(255,255,255,.12);
}
.brand-logo-wide{
  width:auto; max-width:170px; height:auto; display:block;
  background:#fff; border-radius:10px; padding:6px 10px;
}
.brand-mark{
  width:36px; height:36px; border-radius:10px; flex-shrink:0;
  background: var(--color-accent);
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-display); font-weight:800; color:#3a2308; font-size:16px;
}
.brand-text .brand-name{font-size:15px; font-weight:800; font-family:var(--font-display); line-height:1.25; display:block;}
.brand-text .brand-sub{font-size:11px; color:rgba(255,255,255,.6); display:block;}
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden;
  clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

.sidebar-close{
  display:none; margin-left:auto; background:none; border:none; color:#fff;
  font-size:20px; cursor:pointer; padding:4px 8px;
}

.nav-menu{flex:1; padding:14px 12px; overflow-y:auto;}
.nav-section{
  text-transform:uppercase; font-size:10.5px; letter-spacing:.08em; font-weight:700;
  color:rgba(255,255,255,.45); padding:16px 10px 6px;
}
.nav-menu a{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; margin:2px 0; border-radius:10px;
  color:rgba(255,255,255,.85); text-decoration:none; font-size:14px; font-weight:500;
  transition: background .15s ease, color .15s ease;
}
.nav-menu a .dot{
  width:7px; height:7px; border-radius:50%; background:rgba(255,255,255,.35); flex-shrink:0;
}
.nav-menu a:hover{background:rgba(255,255,255,.08); color:#fff;}
.nav-menu a.active{background: var(--color-accent); color:#3a2308; font-weight:700;}
.nav-menu a.active .dot{background:#3a2308;}

.sidebar-footer{padding:14px 18px 18px; border-top:1px solid rgba(255,255,255,.12);}
.user-box{display:flex; flex-direction:column; margin-bottom:10px; font-size:13px;}
.user-box strong{color:#fff;}
.user-box span{opacity:.6; text-transform:capitalize;}
.btn-logout{
  color:#fff; font-size:13px; text-decoration:none; font-weight:600;
  display:inline-flex; align-items:center; gap:6px; opacity:.85;
}
.btn-logout:hover{opacity:1;}

.app-footer{
  margin-top:30px; padding-top:16px; border-top:1px solid var(--color-border);
  text-align:center; font-size:12px; color:var(--color-text-muted);
}
.app-footer a{color:var(--color-text-muted); text-decoration:none; font-weight:600;}
.app-footer a:hover{color:var(--color-primary); text-decoration:underline;}

.login-credit{
  text-align:center; margin-top:18px; font-size:11.5px; color:rgba(255,255,255,.75);
}
.login-credit a{color:#fff; text-decoration:none; font-weight:700;}
.login-credit a:hover{text-decoration:underline;}

/* ---------- Topbar móvil ---------- */
.topbar{
  display:none; position:sticky; top:0; z-index:30;
  height: var(--topbar-height); background: var(--color-surface);
  border-bottom:1px solid var(--color-border);
  align-items:center; gap:12px; padding:0 14px;
}
.hamburger{
  background:none; border:none; cursor:pointer; padding:8px;
  display:flex; flex-direction:column; gap:4px; justify-content:center;
}
.hamburger span{width:20px; height:2px; background:var(--color-primary-dark); border-radius:2px;}
.topbar .topbar-title{font-family:var(--font-display); font-weight:800; color:var(--color-primary-dark); font-size:15px;}
.topbar-logo{height:32px; width:auto; display:block;}

/* ---------- Contenido ---------- */
.content{flex:1; padding:28px 32px; max-width:1200px; min-width:0;}
.page-title{display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:22px; flex-wrap:wrap;}
.page-title h1{margin:0;}

.card{
  background: var(--color-surface);
  border:1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding:22px;
  margin-bottom:20px;
  box-shadow: var(--shadow-sm);
}

/* ---------- Stat cards (dashboard) ---------- */
.stats-grid{
  display:grid; grid-template-columns:repeat(auto-fit, minmax(190px,1fr)); gap:16px; margin-bottom:22px;
}
.stat-card{
  background:var(--color-surface); border:1px solid var(--color-border); border-radius:var(--radius-lg);
  padding:18px; box-shadow:var(--shadow-sm); display:flex; flex-direction:column; gap:10px;
}
.stat-icon{
  width:38px; height:38px; border-radius:10px; display:flex; align-items:center; justify-content:center;
}
.stat-icon svg{width:20px; height:20px;}
.stat-value{font-family:var(--font-display); font-size:28px; font-weight:800; color:var(--color-primary-dark);}
.stat-label{font-size:12.5px; color:var(--color-text-muted); font-weight:600;}
.stat-teal{background:var(--color-primary-light); color:var(--color-primary-dark);}
.stat-amber{background:var(--color-warning-bg); color:var(--color-warning);}
.stat-green{background:var(--color-success-bg); color:var(--color-success);}
.stat-rose{background:var(--color-danger-bg); color:var(--color-danger);}

/* ---------- Tablas ---------- */
.table-responsive{width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; border-radius:var(--radius-md);}
table{width:100%; border-collapse:collapse; background:#fff; min-width:560px;}
th, td{padding:11px 14px; border-bottom:1px solid var(--color-border); text-align:left; font-size:13.5px;}
th{background:var(--color-primary-light); color:var(--color-primary-dark); font-weight:700; font-size:12.5px; text-transform:uppercase; letter-spacing:.02em; white-space:nowrap;}
tbody tr:hover td{background:#FAFCFB;}
tbody tr:last-child td{border-bottom:none;}

.badge{padding:4px 11px; border-radius:20px; font-size:11.5px; font-weight:700; display:inline-block; white-space:nowrap;}
.badge-ok{background:var(--color-success-bg); color:var(--color-success);}
.badge-warn{background:var(--color-danger-bg); color:var(--color-danger);}
.badge-pending{background:var(--color-warning-bg); color:var(--color-warning);}

/* ---------- Botones ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding:10px 18px; border-radius:10px; text-decoration:none;
  font-size:14px; font-weight:700; cursor:pointer; border:none;
  background: var(--color-primary); color:#fff;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover{background: var(--color-primary-dark);}
.btn:active{transform:scale(.98);}
.btn-secondary{background:#EEF2F1; color:var(--color-text);}
.btn-secondary:hover{background:#E3E9E8;}
.btn-danger{background:var(--color-danger-bg); color:var(--color-danger);}
.btn-danger:hover{background:#f6d7d3;}
.btn-sm{padding:6px 12px; font-size:12.5px; border-radius:8px;}
.btn-outline-danger{background:transparent; color:var(--color-danger); border:1.5px solid var(--color-danger-bg); box-shadow:none;}
.btn-outline-danger:hover{background:var(--color-danger-bg);}

/* Grupo de botones de acción dentro de una fila de tabla (Editar, Eliminar, etc.) */
.acciones{display:flex; flex-wrap:wrap; align-items:center; gap:6px 8px;}

/* ---------- Formularios ---------- */
form label{display:block; margin:12px 0 6px; font-size:13px; font-weight:700; color:var(--color-text);}
form input, form select, form textarea{
  width:100%; padding:10px 12px; border:1.5px solid var(--color-border); border-radius:10px;
  font-size:14.5px; font-family:var(--font-body); background:#fff; color:var(--color-text);
  transition:border-color .15s ease;
}
form input:focus, form select:focus, form textarea:focus{
  outline:none; border-color:var(--color-primary);
}
.form-row{display:flex; gap:16px; flex-wrap:wrap;}
.form-row > div{flex:1; min-width:180px;}

.alert{padding:13px 16px; border-radius:var(--radius-md); margin-bottom:16px; font-size:14px; font-weight:600;}
.alert-success{background:var(--color-success-bg); color:var(--color-success); border:1px solid #bfe6ca;}
.alert-error{background:var(--color-danger-bg); color:var(--color-danger); border:1px solid #f0c3bd;}
.alert-warning{background:var(--color-warning-bg); color:var(--color-warning); border:1px solid #f0dfb0;}

.fuera-rango{color:var(--color-danger); font-weight:700;}

/* ---------- Login ---------- */
.login-wrapper{
  min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:20px;
  background: radial-gradient(circle at 20% 15%, #12B4CE, var(--color-primary-dark) 72%);
}
.login-logo{display:block; width:100%; max-width:280px; margin:0 auto 18px;}
.login-box{
  background:#fff; padding:38px 34px; border-radius:var(--radius-lg); width:100%; max-width:360px;
  box-shadow:0 20px 50px rgba(0,0,0,.25);
}
.login-mark{
  width:52px; height:52px; border-radius:14px; background:var(--color-accent);
  display:flex; align-items:center; justify-content:center; margin:0 auto 16px;
  font-family:var(--font-display); font-weight:800; color:#3a2308; font-size:22px;
}
.login-box h1{font-size:19px; text-align:center; margin-bottom:4px;}
.login-box p.sub{text-align:center; color:var(--color-text-muted); margin-bottom:22px; font-size:13px;}

/* =========================================================
   RESPONSIVE — móvil y tablet
   ========================================================= */
@media (max-width: 900px){
  .topbar{display:flex;}
  .sidebar{
    position:fixed; left:0; top:0; height:100dvh;
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }
  .sidebar.open{transform:translateX(0);}
  .sidebar-close{display:block;}
  .content{padding:18px 16px 90px;}
  .page-title{flex-direction:column; align-items:flex-start;}
  .page-title .btn{width:100%;}
  .form-row{flex-direction:column; gap:0;}
  .stats-grid{grid-template-columns:repeat(2,1fr); gap:10px;}
  .stat-value{font-size:22px;}
  table{min-width:520px;}
  .card{padding:16px; border-radius:var(--radius-md);}
}

@media (max-width: 480px){
  .stats-grid{grid-template-columns:1fr 1fr;}
  h1{font-size:20px;}
}
