/* =========================
   TOKENS / VARIABLES
========================= */
:root{
  --bg:#F6F7FB;
  --card:#FFFFFF;
  --text:#12131A;
  --muted:#6B7280;

  --orange:#F28C28;
  --blue:#2E3A8C;

  --radius:16px;
  --shadow:0 16px 40px rgba(0,0,0,.10);
}

/* =========================
   BASE
========================= */
*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background:var(--bg);
}

a{ color:inherit; }

.muted,
.text-muted{
  color:var(--muted);
}

/* =========================
   LAYOUT APP
========================= */
.app{
  display:flex;
  min-height:100vh;
}

.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
}

.content{
  padding:18px;
  max-width:1100px;
  width:100%;
  margin:0 auto;
}

.footer{
  padding:14px 16px;
  color:var(--muted);
  text-align:center;
}

/* =========================
   TOPBAR
========================= */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 16px;
  background:var(--card);
  border-bottom:1px solid rgba(0,0,0,.06);
}

.topbar-title{
  font-weight:700;
}

.topbar-right{
  display:flex;
  gap:10px;
  align-items:center;
}

.menu-toggle{
  border:0;
  background:transparent;
  font-size:28px;
  cursor:pointer;
  color:#172033;
  line-height:1;
  padding:6px 10px;
  border-radius:10px;
}

.menu-toggle:hover{
  background:#f3f6fb;
}

.logout-form{
  display:flex;
  align-items:center;
}

.logout-btn{
  border:0;
  background:#3341a1;
  color:#fff;
  width:42px;
  height:42px;
  border-radius:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:20px;
}

.logout-btn:hover{
  filter:brightness(0.95);
}

.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:38px;
  height:38px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.08);
  background:rgba(255,255,255,.7);
  text-decoration:none;
}

.icon-btn:hover{
  transform:translateY(-1px);
}

/* =========================
   SIDEBAR
========================= */
.sidebar-app{
  width:280px;
  min-width:280px;
  background:#fff;
  border-right:1px solid #e9edf5;
  min-height:100vh;
  padding:20px 16px;
  transition:width .25s ease, min-width .25s ease, padding .25s ease;
  overflow:hidden;
}

.sidebar-brand{
  padding-bottom:18px;
  margin-bottom:18px;
  border-bottom:1px solid #eef2f7;
  text-align:left;
}

.sidebar-brand-logo img{
  max-height:46px;
  width:auto;
  object-fit:contain;
  margin-bottom:10px;
}

.sidebar-brand-name{
  font-size:2rem;
  font-weight:700;
  color:#172033;
  line-height:1.2;
}

.sidebar-brand-sub{
  font-size:1.4rem;
  color:#6b7280;
  margin-top:4px;
}

.sidebar-nav{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.sidebar-link{
  display:flex;
  align-items:center;
  padding:10px 12px;
  border-radius:10px;
  text-decoration:none;
  color:#1f2937;
  transition:background .2s ease, color .2s ease;
}

.sidebar-link:hover{
  background:#f3f6fb;
}

.sidebar-link.is-active{
  background:#eef3ff;
  color:#243cbe;
  font-weight:600;
}

.sidebar-link-text{
  display:inline-block;
}

.sidebar-group{
  border-radius:12px;
}

.sidebar-group summary{
  list-style:none;
}

.sidebar-group summary::-webkit-details-marker{
  display:none;
}

.sidebar-group-title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  cursor:pointer;
  font-weight:700;
  color:#172033;
  border-radius:10px;
}

.sidebar-group-title:hover{
  background:#f8fafc;
}

.sidebar-group-label{
  display:inline-block;
}

.sidebar-caret{
  font-size:1.2rem;
  color:#6b7280;
  transition:transform .2s ease;
}

.sidebar-group[open] .sidebar-caret{
  transform:rotate(180deg);
}

.sidebar-group-links{
  margin-top:6px;
  margin-left:10px;
  padding-left:10px;
  border-left:2px solid #eef2f7;
  display:flex;
  flex-direction:column;
  gap:6px;
}

/* Sidebar colapsado */
body.sidebar-collapsed .sidebar-app{
  width:84px;
  min-width:84px;
  padding:20px 10px;
}

body.sidebar-collapsed .sidebar-brand-name,
body.sidebar-collapsed .sidebar-brand-sub,
body.sidebar-collapsed .sidebar-link-text,
body.sidebar-collapsed .sidebar-group-label,
body.sidebar-collapsed .sidebar-group-links,
body.sidebar-collapsed .sidebar-caret{
  display:none;
}

body.sidebar-collapsed .sidebar-brand{
  display:flex;
  justify-content:center;
  align-items:center;
  border-bottom:0;
  margin-bottom:10px;
  padding-bottom:8px;
}

body.sidebar-collapsed .sidebar-brand-logo img{
  margin-bottom:0;
  max-height:42px;
}

body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-group-title{
  justify-content:center;
  padding-left:0;
  padding-right:0;
}

body.sidebar-collapsed .sidebar-group{
  width:100%;
}

/* =========================
   COMPONENTES BASE
========================= */
.card{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:16px;
  padding:1rem;
  box-shadow:0 4px 14px rgba(0,0,0,.04);
  width:100%;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:none;
  border-radius:10px;
  padding:.65rem .95rem;
  font-weight:600;
  text-decoration:none;
  cursor:pointer;
  background:var(--blue);
  color:#fff;
}

.btn:hover{
  filter:brightness(1.05);
}

.btn.primary,
.btn-primary{
  background:var(--blue);
  color:#fff;
}

.btn-secondary{
  background:#e5e7eb;
  color:#111827;
}

.btn-success{
  background:#15803d;
  color:#fff;
}

.btn.icon{
  background:transparent;
  color:var(--text);
  font-size:18px;
}

.btn.small,
.btn-sm{
  padding:6px 12px;
  font-size:13px;
  border-radius:8px;
}

.btn.btn-icon{
  display:inline-flex;
  align-items:center;
  gap:8px;
}

.btn.btn-icon .ico{
  width:16px;
  height:16px;
  fill:currentColor;
}

.input,
.form-control{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.12);
  background:#fff;
  outline:none;
}

.input:focus,
.form-control:focus{
  border-color:rgba(242,140,40,.9);
}

.grid2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.grid-app{
  display:grid;
  gap:1rem;
}

.grid-2{
  grid-template-columns:repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3{
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
}

.mt-2{ margin-top:.75rem; }
.mt-3{ margin-top:1rem; }

.text-right{ text-align:right; }
.text-center{ text-align:center; }

.inline-form{
  display:inline-block;
  margin:0;
}

.actions-inline{
  display:flex;
  gap:.5rem;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.form-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
}

.form-group label{
  display:block;
  margin-bottom:.4rem;
  font-weight:600;
}

/* =========================
   ALERTAS / BADGES
========================= */
.alert{
  padding:.85rem 1rem;
  border-radius:12px;
  font-weight:500;
  margin-bottom:12px;
}

.alert.ok,
.alert-success{
  background:#ecfdf5;
  color:#166534;
}

.alert.err{
  background:rgba(239,68,68,.12);
  color:#991b1b;
}

.badge{
  display:inline-block;
  padding:4px 10px;
  font-size:12px;
  border-radius:999px;
  background:rgba(46, 58, 140, 0.08);
  color:var(--blue);
  font-weight:600;
}

.badge-success{
  background:#e6f7ed;
  color:#1f9254;
}

.badge-danger{
  background:#fdeaea;
  color:#c0392b;
}

.badge-pend_compras{ background:#fff7ed; }
.badge-en_gestion{ background:#eff6ff; }
.badge-lista_oc{ background:#ecfdf5; }

/* =========================
   TABLAS
========================= */
.table-wrap,
.table-responsive{
  width:100%;
  overflow-x:auto;
  margin-top:20px;
}

.table,
.table-app{
  width:100%;
  border-collapse:collapse;
  font-size:14px;
}

.table thead,
.table-app thead{
  background:#fafbff;
}

.table thead th,
.table-app th{
  text-align:left;
  font-weight:600;
  color:#2E3A8C;
  padding:14px 16px;
  border-bottom:1px solid #e8ebf5;
  vertical-align:top;
}

.table tbody td,
.table-app td{
  padding:14px 16px;
  border-bottom:1px solid #f1f3f9;
  color:#333;
  vertical-align:top;
}

.table tbody tr:hover,
.table-app tbody tr:hover{
  background:#f9faff;
  transition:.2s ease;
}

.table tbody tr:last-child td,
.table-app tbody tr:last-child td{
  border-bottom:none;
}

/* =========================
   HEADER DE PÁGINA
========================= */
.page-header,
.page-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px 16px;
  flex-wrap:wrap;
  margin-bottom:1.25rem;
}

.page-header h1,
.page-title{
  margin:0;
  line-height:1.15;
  font-size:1.6rem;
  font-weight:700;
}

.page-header p,
.page-subtitle{
  margin:.35rem 0 0;
  color:#6b7280;
}

.page-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.page-actions .btn{
  white-space:nowrap;
}

.section-title,
.card-title{
  margin:0 0 1rem;
  font-size:1.05rem;
  font-weight:700;
}

/* =========================
   LISTAS / INFO
========================= */
.list{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.list-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
}

.list-row > div:first-child{
  flex:1;
}

.info-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(230px, 1fr));
  gap:.75rem 1rem;
}

/* =========================
   FILTROS
========================= */
.filters .btn{
  min-width:120px;
  height:38px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

/* =========================
   LOGIN
========================= */
.auth-page{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(242,140,40,.25), transparent 60%),
    radial-gradient(900px 500px at 85% 15%, rgba(46,58,140,.18), transparent 60%),
    var(--bg);
}

.auth-wrap{
  width:100%;
  max-width:420px;
}

.auth-card{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px;
}

.auth-brand{
  margin-bottom:14px;
}

.auth-logo{
  text-align:center;
  margin-bottom:10px;
}

.auth-logo img{
  display:block;
  margin:0 auto;
  max-height:60px;
  object-fit:contain;
}

.auth-sub{
  color:var(--muted);
  font-size:13px;
  margin-top:4px;
}

.auth-form .input{
  height:42px;
}

.auth-foot{
  margin-top:12px;
  font-size:12px;
}

/* =========================
   MENUS
========================= */
.menu{
  display:none;
  position:absolute;
  right:0;
  top:42px;
  background:var(--card);
  border-radius:12px;
  box-shadow:var(--shadow);
  min-width:220px;
  overflow:hidden;
  z-index:80;
}

.menu.open{
  display:block;
}

.menu button{
  width:100%;
  border:0;
  background:transparent;
  padding:10px 12px;
  text-align:left;
  cursor:pointer;
}

.menu button:hover{
  background:rgba(46,58,140,.08);
}

.menu form{
  margin:0;
}

.menu form button{
  width:100%;
}

/* =========================
   MODAL
========================= */
.modal{
  display:none;
  position:fixed;
  inset:0;
  z-index:9998;
}

.modal.open{
  display:block;
}

.modal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.45);
}

.modal-card{
  position:relative;
  max-width:920px;
  width:min(920px, 92vw);
  margin:5vh auto;
  max-height:85vh;
  overflow:auto;
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:0 20px 60px rgba(0,0,0,.25);
  padding:18px;
  z-index:9999;
}

/* =========================
   PERMISOS POR ROL
========================= */
.perm-card{ padding:18px; }
.perm-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:16px; }
.perm-head h2{ margin:0; font-size:22px; }
.perm-sub{ color:var(--muted); font-size:13px; margin-top:4px; }

.perm-toolbar{
  display:grid;
  grid-template-columns:260px 1fr auto;
  gap:12px;
  margin:14px 0 10px;
  padding:12px;
  background:rgba(0,0,0,.02);
  border:1px solid rgba(0,0,0,.06);
  border-radius:12px;
}

.perm-role label,
.perm-search label{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}

.perm-search input{ width:100%; }

.perm-bulk{
  display:flex;
  gap:8px;
  align-items:end;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.perm-group{
  border:1px solid rgba(0,0,0,.08);
  border-radius:14px;
  background:#fff;
  margin:10px 0;
  overflow:hidden;
}

.perm-group > summary{
  list-style:none;
  cursor:pointer;
  display:flex;
  justify-content:space-between;
  gap:14px;
  padding:12px 14px;
  background:rgba(46,58,140,.06);
  border-bottom:1px solid rgba(0,0,0,.06);
}

.perm-group > summary::-webkit-details-marker{ display:none; }

.perm-group-title{ font-weight:800; }

.perm-group-meta{
  display:flex;
  align-items:center;
  gap:10px;
}

.tag{
  font-size:12px;
  padding:4px 8px;
  border-radius:999px;
  background:rgba(0,0,0,.06);
  color:var(--muted);
}

.link{
  background:transparent;
  border:0;
  padding:0;
  cursor:pointer;
  color:var(--blue);
  font-weight:700;
}

.dot{ color:var(--muted); }

.perm-table{ padding:10px 12px 12px; }

.perm-row{
  display:grid;
  grid-template-columns:1.2fr 1.6fr 140px 140px;
  gap:12px;
  align-items:center;
  padding:10px 8px;
  border-radius:10px;
}

.perm-row + .perm-row{
  border-top:1px dashed rgba(0,0,0,.08);
}

.perm-row-head{
  font-size:12px;
  color:var(--muted);
  padding-top:6px;
  padding-bottom:6px;
}

.perm-key .mono{
  font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size:12.5px;
  font-weight:700;
}

.perm-desc{
  color:var(--text);
  font-size:13px;
}

.center{ text-align:center; }

.perm-footer{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
  margin-top:14px;
}

/* =========================
   MODAL 2FA
========================= */
.modal-wrap{
  min-height:calc(100vh - 120px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}

.modal-2fa{
  width:min(900px, 100%);
  background:var(--card);
  border-radius:18px;
  box-shadow:var(--shadow);
  overflow:hidden;
  border:1px solid rgba(0,0,0,.06);
}

.modal-2fa .head{
  padding:18px 22px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-bottom:1px solid rgba(0,0,0,.06);
}

.modal-2fa .head h2{
  margin:0;
  font-size:18px;
}

.modal-2fa .head .x{
  border:0;
  background:transparent;
  font-size:22px;
  cursor:pointer;
  opacity:.6;
}

.modal-2fa .body{
  display:grid;
  grid-template-columns:1.35fr .85fr;
  gap:0;
}

.modal-2fa .left{ padding:22px; }

.modal-2fa .right{
  padding:22px;
  background:linear-gradient(180deg, rgba(46,58,140,.06), rgba(242,140,40,.04));
  border-left:1px solid rgba(0,0,0,.06);
  display:flex;
  align-items:center;
  justify-content:center;
}

.step{
  display:flex;
  gap:12px;
  margin:14px 0;
}

.step .num{
  width:26px;
  height:26px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  font-size:13px;
  background:rgba(46,58,140,.12);
  color:var(--blue);
}

.step .txt{
  line-height:1.25;
}

.step .txt b{
  display:block;
}

.qr-card{
  background:#fff;
  border-radius:14px;
  padding:14px;
  border:1px solid rgba(0,0,0,.08);
  text-align:center;
}

.qr-card img{
  width:220px;
  height:220px;
  display:block;
  margin:0 auto;
}

.secret-row{
  margin-top:10px;
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
}

.secret{
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight:800;
  font-size:13px;
  padding:8px 10px;
  border-radius:10px;
  border:1px dashed rgba(0,0,0,.2);
  background:rgba(0,0,0,.02);
}

.form-row{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:14px;
}

.form-row input{
  width:180px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.18);
  outline:none;
}

.form-row input:focus{
  border-color:rgba(46,58,140,.55);
}

/* =========================
   FICHA ARTÍCULO
========================= */
.ficha{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}

.ficha-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
  padding:18px 20px;
  border-bottom:1px solid rgba(0,0,0,.08);
  background:linear-gradient(180deg, rgba(46,58,140,.06), rgba(0,0,0,0));
}

.ficha-title{
  margin:0;
  font-size:20px;
  font-weight:900;
  letter-spacing:.2px;
}

.ficha-sub{
  margin:6px 0 0;
  color:var(--muted);
  font-size:13px;
}

.chips{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.chip{
  display:inline-flex;
  gap:6px;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  border:1px solid rgba(0,0,0,.10);
  background:#fff;
}

.chip.ok{ border-color:rgba(16,185,129,.35); background:rgba(16,185,129,.10); }
.chip.warn{ border-color:rgba(245,158,11,.35); background:rgba(245,158,11,.10); }
.chip.bad{ border-color:rgba(239,68,68,.35); background:rgba(239,68,68,.10); }
.chip.neutral{ border-color:rgba(46,58,140,.25); background:rgba(46,58,140,.08); }

.ficha-body{ padding:18px 20px; }

.section{
  padding:14px 14px 10px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:14px;
  background:#fff;
  margin-bottom:14px;
}

.form-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px 18px;
}

.span-2{ grid-column:1/-1; }

.field label{
  display:block;
  font-weight:800;
  font-size:12px;
  margin:0 0 6px;
  color:rgba(0,0,0,.75);
}

.field .hint{
  margin-top:6px;
  font-size:12px;
  color:var(--muted);
}

.field input,
.field select,
.field textarea{
  width:100%;
  padding:10px 12px;
  border:1px solid rgba(0,0,0,.12);
  border-radius:12px;
  background:#fff;
  outline:none;
  transition:.15s ease;
}

.field textarea{
  min-height:92px;
  resize:vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus{
  border-color:rgba(46,58,140,.55);
  box-shadow:0 0 0 4px rgba(46,58,140,.12);
}

.field input[disabled],
.field select[disabled],
.field textarea[disabled]{
  background:rgba(0,0,0,.04);
  color:rgba(0,0,0,.55);
  cursor:not-allowed;
}

.ficha-actions{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:14px 20px;
  border-top:1px solid rgba(0,0,0,.08);
  background:rgba(0,0,0,.02);
}

/* =========================
   COTIZACIONES / BLOQUES
========================= */
.cotizacion-box{
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:1rem;
  margin-bottom:1rem;
}

.cotizacion-header{
  display:flex;
  justify-content:space-between;
  gap:1rem;
  flex-wrap:wrap;
}

/* =========================
   FIX SELECT MULTIPLE
========================= */
select.input[multiple]{
  -webkit-appearance:menulist !important;
  appearance:auto !important;
  background-color:#fff !important;
  color:var(--text) !important;
  padding:8px !important;
  line-height:1.2 !important;
  overflow:auto !important;
  min-height:160px !important;
}

select.input[multiple] option{
  color:#111 !important;
  background-color:#fff !important;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 900px){
  .content{
    padding:14px;
  }

  .grid2,
  .form-grid,
  .grid-2,
  .grid-3{
    grid-template-columns:1fr;
  }

  .perm-toolbar{
    grid-template-columns:1fr;
  }

  .perm-row{
    grid-template-columns:1fr;
  }

  .center{
    text-align:left;
  }

  .ficha-head{
    flex-direction:column;
    align-items:flex-start;
  }

  .chips{
    justify-content:flex-start;
  }

  .modal-2fa .body{
    grid-template-columns:1fr;
  }

  .modal-2fa .right{
    border-left:0;
    border-top:1px solid rgba(0,0,0,.06);
  }

  .sidebar-app{
    position:fixed;
    left:-320px;
    top:0;
    height:100vh;
    z-index:50;
    transition:left .2s ease, width .25s ease, min-width .25s ease, padding .25s ease;
  }

  .sidebar-app.open{
    left:0;
  }

  body.sidebar-collapsed .sidebar-app{
    left:0;
  }
}


/* =========================
   ARTICULOS
========================= */

.articulo-autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #d9deea;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.10);
  max-height: 260px;
  overflow-y: auto;
  z-index: 30;
}

.articulo-autocomplete-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eef2f7;
}

.articulo-autocomplete-item:last-child {
  border-bottom: 0;
}

.articulo-autocomplete-item:hover {
  background: #f7f9fc;
}

.articulo-ac-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.articulo-ac-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #667085;
}

.articulo-autocomplete-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: #667085;
}

/* =========================
BASE
========================= */
*,
*::before,
*::after {
box-sizing: border-box;
}

:root {
--bg: #f3f6fb;
--surface: #ffffff;
--surface-soft: #f8fbff;
--border: #e5ecf4;
--text: #18324b;
--muted: #6f8196;
--primary: #1f4f82;
--primary-2: #2f6fb2;
--success: #1f9d68;
--warning: #d99100;
--danger: #d84d4d;
--shadow-1: 0 6px 18px rgba(15, 23, 42, 0.05);
--shadow-2: 0 14px 34px rgba(15, 23, 42, 0.09);
--radius-sm: 14px;
--radius-md: 18px;
--radius-lg: 24px;
}

html {
scroll-behavior: smooth;
}

body {
margin: 0;
background:
radial-gradient(circle at top left, #f9fbff 0%, #f3f6fb 45%, #eef3f8 100%);
color: var(--text);
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.45;
}

.main-content,
.page-content,
.content-wrapper {
padding: 26px;
}

/* =========================
WRAPPER DASHBOARD
========================= */
.dashboard-page {
max-width: 1600px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 22px;
}

/* =========================
HEADER
========================= */
.page-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
flex-wrap: wrap;
padding: 22px 26px;
background: linear-gradient(135deg, #ffffff 0%, #f7fbff 100%);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-1);
}

.page-header h1,
.page-title {
margin: 0;
font-size: 2rem;
font-weight: 800;
color: #163556;
letter-spacing: -0.03em;
}

.page-subtitle,
.page-header p,
.muted,
.text-muted {
margin: 6px 0 0;
color: var(--muted);
font-size: 0.98rem;
}

/* =========================
KPI GRID
========================= */
.kpi-grid,
.dashboard-grid {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 16px;
}

.kpi-card,
.card-kpi,
.stat-card {
position: relative;
overflow: hidden;
min-height: 138px;
padding: 18px 18px 16px;
background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
border: 1px solid var(--border);
border-radius: var(--radius-md);
box-shadow: var(--shadow-1);
transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.kpi-card:hover,
.card-kpi:hover,
.stat-card:hover {
transform: translateY(-4px);
box-shadow: var(--shadow-2);
border-color: #d7e3ef;
}

.kpi-card::before,
.card-kpi::before,
.stat-card::before {
content: "";
position: absolute;
inset: 0 0 auto 0;
height: 4px;
background: linear-gradient(90deg, var(--primary) 0%, var(--primary-2) 100%);
}

.kpi-card.success::before { background: linear-gradient(90deg, #1f9d68 0%, #33b27e 100%); }
.kpi-card.warning::before { background: linear-gradient(90deg, #d99100 0%, #f0ae24 100%); }
.kpi-card.danger::before  { background: linear-gradient(90deg, #d84d4d 0%, #ef6868 100%); }

.kpi-label,
.card-title,
.stat-label {
margin: 0 0 12px;
color: var(--muted);
font-size: 0.72rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
line-height: 1.4;
}

.kpi-value,
.card-value,
.stat-value {
margin: 0;
color: #0f2f50;
font-size: 2rem;
font-weight: 800;
line-height: 1;
letter-spacing: -0.04em;
}

.kpi-helper,
.card-helper,
.stat-helper {
margin-top: 10px;
color: #4d6178;
font-size: 0.9rem;
line-height: 1.4;
}

/* =========================
LAYOUT DE BLOQUES
========================= */
.dashboard-sections {
display: grid;
grid-template-columns: repeat(12, minmax(0, 1fr));
gap: 18px;
}

.panel,
.section,
.dashboard-block,
.chart-card,
.table-card,
.info-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-md);
box-shadow: var(--shadow-1);
padding: 20px;
}

/* tamaños sugeridos */
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.section-title,
.panel-title,
.dashboard-block h2,
.dashboard-block h3 {
margin: 0 0 16px;
color: #173756;
font-size: 1.35rem;
font-weight: 800;
letter-spacing: -0.03em;
}

/* =========================
LISTAS TIPO RANKING
========================= */
.ranking-list,
.metric-list,
.summary-list,
.activity-list {
display: flex;
flex-direction: column;
gap: 10px;
}

.ranking-item,
.metric-item,
.summary-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
padding: 12px 14px;
background: #f9fbfe;
border: 1px solid #e8eef5;
border-radius: var(--radius-sm);
}

.ranking-item .name,
.metric-item .name,
.summary-item .name {
color: #27425d;
font-weight: 600;
}

.ranking-item .value,
.metric-item .value,
.summary-item .value {
color: #0f3050;
font-weight: 800;
white-space: nowrap;
}

/* =========================
TABLAS
========================= */
.table-container {
overflow-x: auto;
border: 1px solid var(--border);
border-radius: var(--radius-md);
background: #fff;
}

table {
width: 100%;
min-width: 640px;
border-collapse: separate;
border-spacing: 0;
}

thead th {
background: #f7fafe;
color: #5d7188;
text-transform: uppercase;
letter-spacing: 0.06em;
font-size: 0.76rem;
font-weight: 800;
padding: 14px;
text-align: left;
border-bottom: 1px solid var(--border);
}

tbody td {
padding: 14px;
font-size: 0.94rem;
color: #263d55;
border-bottom: 1px solid #edf2f7;
}

tbody tr:last-child td {
border-bottom: none;
}

tbody tr:hover {
background: #fbfdff;
}

/* =========================
BADGES
========================= */
.badge {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 6px 12px;
border-radius: 999px;
font-size: 0.76rem;
font-weight: 700;
border: 1px solid transparent;
}

.badge.success {
background: #ebfaf2;
color: var(--success);
border-color: #d1efdf;
}

.badge.warning {
background: #fff8e8;
color: var(--warning);
border-color: #f6dfaa;
}

.badge.danger {
background: #fdeeee;
color: var(--danger);
border-color: #f5caca;
}

.badge.primary {
background: #edf5fd;
color: var(--primary);
border-color: #d4e4f5;
}

/* =========================
ACTIVIDAD COMPACTA
========================= */
.activity-list {
max-height: 420px;
overflow: auto;
padding-right: 4px;
}

.activity-list::-webkit-scrollbar {
width: 8px;
}

.activity-list::-webkit-scrollbar-thumb {
background: #cfd9e4;
border-radius: 999px;
}

.activity-item {
position: relative;
padding: 14px 14px 14px 18px;
background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
}

.activity-item::before {
content: "";
position: absolute;
left: 0;
top: 14px;
bottom: 14px;
width: 4px;
border-radius: 999px;
background: linear-gradient(180deg, var(--primary) 0%, var(--primary-2) 100%);
}

.activity-title {
margin: 0;
color: #173756;
font-size: 0.96rem;
font-weight: 800;
}

.activity-meta {
margin: 4px 0 8px;
color: var(--muted);
font-size: 0.82rem;
}

.activity-text {
margin: 0;
color: #42586f;
font-size: 0.9rem;
line-height: 1.45;
}

/* =========================
BLOQUE DESTACADO
========================= */
.hero-panel {
background: linear-gradient(135deg, #173b61 0%, #2c669e 100%);
color: #fff;
border: none;
box-shadow: var(--shadow-2);
}

.hero-panel .section-title,
.hero-panel h2,
.hero-panel p,
.hero-panel .muted {
color: #fff;
}

.hero-panel .muted {
opacity: 0.88;
}

/* =========================
RESPONSIVE
========================= */
@media (max-width: 1400px) {
.kpi-grid,
.dashboard-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-3,
.span-4 {
grid-column: span 6;
}

.span-5,
.span-6,
.span-7,
.span-8 {
grid-column: span 12;
}
}

@media (max-width: 992px) {
.main-content,
.page-content,
.content-wrapper {
padding: 18px;
}

.kpi-grid,
.dashboard-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-sections {
grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-3,
.span-4,
.span-5,
.span-6,
.span-7,
.span-8,
.span-12 {
grid-column: span 2;
}

.page-header h1,
.page-title {
font-size: 1.65rem;
}
}

@media (max-width: 768px) {
.main-content,
.page-content,
.content-wrapper {
padding: 14px;
}

.kpi-grid,
.dashboard-grid,
.dashboard-sections {
grid-template-columns: 1fr;
}

.span-3,
.span-4,
.span-5,
.span-6,
.span-7,
.span-8,
.span-12 {
grid-column: span 1;
}

.page-header {
padding: 18px;
}

.page-header h1,
.page-title {
font-size: 1.4rem;
}

.kpi-value,
.card-value,
.stat-value {
font-size: 1.6rem;
}

table {
min-width: 580px;
}
}

.metric-bar {
  width: 100%;
  height: 10px;
  background: #edf3f9;
  border-radius: 999px;
  overflow: hidden;
}

.metric-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-2) 100%);
}
