/* =========================================================
   CALIDAD — Base de estilos compartida
   Paleta: "Clínico claro" — blanco + acento teal, refinado
   para que sea sutil: sin gradientes, sombras neutras, un solo
   acento de color usado con moderación.

   Cualquier plantilla que haga {% extends "calidad/base.html" %}
   hereda esto automáticamente. No se debe duplicar en las
   páginas hijas: solo agregan su CSS propio en {% block extra_css %}.
   ========================================================= */

   :root{
    --brand: #0f6e56;                   /* teal: único acento de marca */
    --brand-hover: #0b5745;
    --brand-soft: #e7f5f0;              /* lavado muy tenue para estados activos */
    --brand-soft-strong: #d3ece3;
    --text-on-brand-soft: #085041;
    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
  
    --body-bg: #f7f7f5;
    --surface: #ffffff;
    --surface-muted: #f8f9f8;
    --surface-dark: #14201c;
    --surface-dark-alt: #182420;
  
    --sidebar-bg: #ffffff;
    --sidebar-text: #1c1f1e;
    --link-color: #6b756f;
    --hover-bg: rgba(15,110,86,.06);
    --divider: #eceae5;
  
    --input-bg: #ffffff;
    --input-text: #1c1f1e;
    --mark-bg: rgba(250,204,21,.28);
  
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 70px;
  
    /* Sombras neutras (sin tinte de color): contacto nítido + ambiente difuso */
    --shadow-soft: 0 1px 2px rgba(20,24,22,.06), 0 10px 24px -10px rgba(20,24,22,.14);
    --shadow-strong: 0 2px 6px rgba(20,24,22,.07), 0 24px 56px -18px rgba(20,24,22,.24);
    --shadow-lift: 0 8px 20px -8px rgba(20,24,22,.20);
  
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-pill: 999px;
  
    --axis-bg-gradient: none;
    --ring: rgba(15,110,86,.22);
  
    --ease: cubic-bezier(.2,.7,.3,1);
  }
  
  body.dark-mode{
    --body-bg: #101613;
    --surface: #182420;
    --surface-muted: #182420;
    --surface-dark: #101613;
    --surface-dark-alt: #1b2723;
    --sidebar-bg: #14201c;
    --sidebar-text: #eef2ef;
    --link-color: #9aa8a2;
    --hover-bg: rgba(52,211,153,.12);
    --divider: #263531;
    --input-bg: #101613;
    --input-text: #eef2ef;
    --mark-bg: rgba(253,224,71,.30);
    --brand-soft: rgba(15,110,86,.22);
    --brand-soft-strong: rgba(15,110,86,.32);
    --text-on-brand-soft: #6ee7b7;
  }
  
  *{ box-sizing:border-box; }
  html{ -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; }
  body{
    margin:0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size:14.5px;
    line-height:1.5;
    letter-spacing:-.005em;
    color: var(--sidebar-text);
    background-color: var(--body-bg);
    transition: background-color .3s ease, color .3s ease;
  }
  
  @keyframes axis-fade-in{
    from{ opacity:0; transform:translateY(4px); }
    to  { opacity:1; transform:translateY(0); }
  }
  
  @media (prefers-reduced-motion: reduce){
    *{ animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; }
  }
  
  a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible{
    outline: 2px solid var(--brand);
    outline-offset: 2px;
  }
  
  /* ======= SIDEBAR ======= */
  .sidebar{
    height:100vh;
    width: var(--sidebar-w);
    position:fixed;
    left:0; top:0;
    z-index:999;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding:12px 10px 14px 10px;
    transition: width .25s ease, box-shadow .25s ease, transform .25s ease, background-color .3s ease;
    display:flex;
    flex-direction:column;
    border-right:1px solid var(--divider);
    animation: axis-fade-in .45s ease-out;
    overflow:auto;
  }
  
  .sidebar-brand{
    display:flex; align-items:center; gap:10px;
    padding:4px 6px 10px 6px; margin-bottom:4px;
  }
  .sidebar-brand-logo{
    width:32px;height:32px;border-radius:10px;
    overflow:hidden;display:grid;place-items:center;
    background: var(--brand);
    transition: transform .2s var(--ease);
  }
  .sidebar-brand-logo img{ max-width:20px; max-height:20px; display:block; filter:brightness(0) invert(1); }
  .sidebar-brand:hover .sidebar-brand-logo{ transform: translateY(-1px); }
  .sidebar-brand-text{ display:flex; flex-direction:column; line-height:1.1; }
  .brand-title{ font-weight:700; letter-spacing:.02em; font-size:14px; color: var(--sidebar-text); }
  .brand-subtitle{ font-size:11px; color:#9aa39d; }
  
  @keyframes axis-pulse{
    0% { box-shadow:0 0 0 0 rgba(34,197,94,.35); }
    70% { box-shadow:0 0 0 6px rgba(34,197,94,0); }
    100%{ box-shadow:0 0 0 0 rgba(34,197,94,0); }
  }
  .conn-dot{
    margin-left:auto; width:8px;height:8px;border-radius:999px;
    background:#22c55e; box-shadow:0 0 0 2px rgba(34,197,94,.20);
    flex-shrink:0; animation: axis-pulse 1.8s infinite;
  }
  
  .top-controls{
    display:flex; align-items:center; gap:6px;
    padding:0 2px 8px 2px; margin-bottom:6px;
    border-bottom:1px solid var(--divider);
  }
  #toggle-btn, #themeToggle{
    background:none; border:none; color: var(--link-color);
    font-size:16px; cursor:pointer; padding:6px 8px;
    border-radius:var(--radius-pill); display:grid; place-items:center;
    transition: background .18s ease, color .18s ease;
  }
  #toggle-btn:hover, #themeToggle:hover{ background: var(--hover-bg); color: var(--sidebar-text); }
  #toggle-btn:active, #themeToggle:active{ transform: translateY(0); }
  
  .sidebar.collapsed{ width: var(--sidebar-collapsed-w); padding-inline: 6px; }
  .sidebar.collapsed .sidebar-brand-text{ display:none; }
  .sidebar.collapsed .conn-dot{ margin-left:0; }
  .sidebar.collapsed .top-controls{ justify-content:center; border-bottom:none; padding-bottom:4px; margin-bottom:4px; }
  
  .sidebar-search{ padding: 6px 2px 10px 2px; }
  .sidebar-search input{
    width:100%; padding:7px 9px; border-radius:var(--radius-pill);
    border:1px solid var(--divider); outline:none; font-size:13px;
    background: var(--surface-muted); color: var(--input-text);
    transition: border-color .18s ease, box-shadow .18s ease;
  }
  .sidebar-search input::placeholder{ color:#9aa39d; }
  .sidebar-search input:focus{ border-color: var(--brand); box-shadow:0 0 0 1px rgba(15,110,86,.35); }
  .sidebar.collapsed .sidebar-search{ display:none; }
  
  .sidebar a{
    display:flex; align-items:center; padding:9px 10px;
    color: var(--link-color); text-decoration:none; font-size:13px; font-weight:500;
    transition: background .16s var(--ease), color .16s var(--ease);
    border-radius:var(--radius-pill); margin:1px 2px; gap:10px; position:relative;
  }
  .sidebar a:hover{ background: var(--hover-bg); color: var(--sidebar-text); }
  .sidebar a.active{
    background: var(--brand-soft);
    color: var(--text-on-brand-soft); font-weight:600;
    box-shadow: inset 2px 0 0 var(--brand);
  }
  .sidebar a.disabled{ opacity:.4; cursor:not-allowed; pointer-events:none; }
  .icon-left{ width:22px; display:grid; place-items:center; font-size:15px; flex-shrink:0; }
  .text-label{ white-space:nowrap; }
  .sidebar.collapsed .text-label{ display:none; }
  .text-soon{ margin-left:auto; font-size:9px; font-weight:700; color:#9aa39d; }
  .sidebar.collapsed .text-soon{ display:none; }
  
  mark.sidebar-hit{ background: var(--mark-bg); padding:0 2px; border-radius:3px; }
  
  .sidebar-footer{
    margin-top:auto; text-align:center; padding:10px 4px 4px 4px;
    font-size:10px; color: #9aa39d; border-top:1px solid var(--divider);
  }
  .sidebar-footer strong{ color: var(--sidebar-text); font-weight:600; }
  .sidebar.collapsed .sidebar-footer{ display:none; }
  
  /* ===== MAIN / LAYOUT ===== */
  .main{
    margin-left: var(--sidebar-w);
    padding: 20px 22px 26px 22px;
    transition: margin .25s ease;
    min-height: 100vh;
  }
  .sidebar.collapsed ~ .main{ margin-left: var(--sidebar-collapsed-w); }
  
  .page-container{
    max-width: 1200px; margin: 0 auto;
    background-color: var(--surface); border-radius: var(--radius-lg);
    padding: 20px 24px 24px 24px; box-shadow: var(--shadow-soft);
    color: var(--sidebar-text); border:1px solid var(--divider);
    animation: axis-fade-in .35s ease-out;
  }
  
  header.page-header{
    display:flex; align-items:center; justify-content:space-between; gap:12px;
    margin-bottom:18px; padding-bottom:14px;
    border-bottom:1px solid var(--divider);
  }
  header.page-header h1{ margin:0; font-size:1.25rem; font-weight:600; letter-spacing:-.01em; display:flex; align-items:center; gap:10px; color: var(--sidebar-text); }
  header.page-header h1 i{
    width:30px;height:30px;border-radius:9px; display:grid; place-items:center;
    font-size:14px; color: var(--brand); background: var(--brand-soft);
  }
  
  /* ===== COMPONENTES COMUNES: cards, botones, inputs, tabla, badges ===== */
  .card{
    background: var(--surface); border:1px solid var(--divider);
    border-radius: var(--radius-lg); overflow:hidden;
  }
  
  .card-h{
    padding:13px 16px; display:flex; align-items:center; justify-content:space-between;
    gap:10px; border-bottom:1px solid var(--divider); background: var(--surface-muted);
  }
  
  .ttl{ font-weight:600; display:flex; align-items:center; gap:10px; letter-spacing:-.005em; color: var(--sidebar-text); }
  .ttl i{
    width:28px; height:28px; border-radius:9px; display:grid; place-items:center; font-size:13px;
    background: var(--brand-soft); color: var(--brand);
  }
  
  .card-b{ padding: 12px 14px; }
  
  input[type="text"], input[type="number"], input[type="search"], input[type="password"], input[type="email"], .tree-search, .search input{
    width:100%; padding:9px 11px; border-radius: var(--radius-pill);
    border:1px solid var(--divider); outline:none; font-weight:600;
    background: var(--surface); color: var(--sidebar-text);
  }
  .tree-search:focus, .search input:focus{ border-color: var(--brand); box-shadow:0 0 0 3px var(--ring); }
  
  .toolbar{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; justify-content:space-between; margin-bottom:10px; }
  .search{ flex: 1 1 420px; display:flex; gap:10px; align-items:center; }
  
  .btn{
    border:0; padding:10px 16px; border-radius: var(--radius-pill); cursor:pointer;
    font-weight:600; font-size:13.5px; transition: background .15s ease, filter .15s ease, transform .1s ease;
  }
  .btn-primary{ color:#fff; background: var(--brand); }
  .btn-primary:hover:not(:disabled){ background: var(--brand-hover); }
  .btn-ghost{ background: var(--surface-muted); border:1px solid var(--divider); color: var(--sidebar-text); }
  .btn-ghost:hover:not(:disabled){ filter:brightness(0.98); background: var(--hover-bg); }
  .btn:disabled{ opacity:.5; cursor:not-allowed; }
  .btn:active:not(:disabled){ transform: translateY(0.5px); }
  .btn.mini{ padding:6px 12px; font-size:12px; }
  
  table{
    width:100%; border-collapse:separate; border-spacing:0;
    border:1px solid var(--divider); border-radius: var(--radius-md); overflow:hidden; background: var(--surface);
  }
  thead th{
    text-align:left; font-size:11.5px; letter-spacing:.06em; text-transform:uppercase;
    padding:12px; background: var(--surface-muted); color:#6b756f; font-weight:600; border-bottom:1px solid var(--divider);
  }
  tbody td{ padding:12px; border-bottom:1px solid var(--divider); font-weight:500; vertical-align:top; color: var(--sidebar-text); }
  tbody tr:last-child td{ border-bottom:none; }
  tbody tr{ transition: background .12s ease; }
  tbody tr:hover{ background: var(--hover-bg); }
  
  .muted{ color:#6b756f; font-weight:400; }
  
  .badge-pill{
    display:inline-flex; align-items:center; gap:7px; padding:5px 11px;
    border-radius: var(--radius-pill); font-weight:600; font-size:12px;
    border:1px solid var(--divider); background: var(--surface);
  }
  .badge-pill::before{ content:""; width:6px; height:6px; border-radius:999px; background:#9aa39d; flex-shrink:0; }
  .on{ border-color: rgba(34,197,94,.28); background: rgba(34,197,94,.06); color:#15803d; }
  .on::before{ background:#22c55e; }
  .off{ border-color: rgba(239,68,68,.26); background: rgba(239,68,68,.06); color:#b91c1c; }
  .off::before{ background:#ef4444; }
  button.badge-pill{ font: inherit; cursor: pointer; -webkit-appearance:none; appearance:none; transition: filter .12s ease; }
  button.badge-pill:hover{ filter: brightness(0.96); }
  
  .empty{
    padding:16px; border:1px dashed var(--divider); border-radius: var(--radius-md);
    background: var(--surface-muted); font-weight:500; color:#6b756f; text-align:center;
  }
  
  .crumb{ margin-top:6px; font-weight:600; color:#6b756f; }
  
  .hint{ font-size:12px; color:#6b756f; margin-top:8px; }
  
  @media (max-width: 980px){
    .ind-grid{ grid-template-columns: 1fr; }
  }