/* ===============================
   VARIABLES
================================= */
:root{
  --bg: #f6f8fc;
  --panel: #ffffff;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #dbe4f0;
  --accent: #4f46e5;
  --accent-soft: rgba(79,70,229,.08);
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

/* ===============================
   BASE
================================= */
*{ box-sizing: border-box; }

body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a{ text-decoration:none; color:inherit; }

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

/* ===============================
   SIDEBAR
================================= */
.sidebar{
  width: 290px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px;
  overflow:auto;
  transition: width .25s ease;
}

.sidebar-collapsed .sidebar{ width: 78px; }

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius: 14px;
  font-weight: 800;
  letter-spacing: .2px;
  margin-bottom: 8px;
}

.brand i{ font-size: 20px; }

.sidebar-section{
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin: 14px 8px 6px;
}

/* NAV ITEMS */
.nav-item,
.nav-sub,
.nav-summary{
  display:flex;
  align-items:center;
  gap:10px;
  padding:9px 12px;
  border-radius: 14px;
  border:1px solid transparent;
  font-size:14px;
  transition: all .15s ease;
}

.nav-item:hover,
.nav-sub:hover,
.nav-summary:hover{
  background: rgba(255,255,255,.06);
}

.nav-item.active,
.nav-sub.active{
  background: var(--accent-soft);
  border-color: rgba(79,140,255,.25);
}

.nav-sub{
  margin-left: 8px;
  color: var(--muted);
  padding-left: 18px;
}

details.nav-group{ margin-bottom: 6px; }

details.nav-group summary{
  cursor:pointer;
  list-style:none;
}

details.nav-group summary::-webkit-details-marker{ display:none; }

.chev{
  margin-left:auto;
  transition: transform .2s ease;
}

details[open] .chev{ transform: rotate(180deg); }

/* ===============================
   MAIN + TOPBAR
================================= */
.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
}

.topbar{
  height:64px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom:1px solid var(--border);
  background: rgba(15,26,45,.65);
  backdrop-filter: blur(10px);
}

.topbar__left,
.topbar__right{
  display:flex;
  align-items:center;
  gap:12px;
}

.iconbtn{
  width:42px;
  height:42px;
  display:grid;
  place-items:center;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  cursor:pointer;
}

.iconbtn:hover{ background: rgba(255,255,255,.12); }

.search{
  width:min(520px,50vw);
  background: rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.08);
  color: var(--text);
  padding:12px 16px;
  border-radius:14px;
  outline:none;
}

.search:focus{
  border-color:#3b82f6;
  box-shadow:0 0 0 2px rgba(59,130,246,.25);
}

.search::placeholder{ color: var(--muted); }

.btn{
  background: var(--accent);
  border:none;
  color:#fff;
  padding:10px 14px;
  border-radius:14px;
  font-weight:600;
  cursor:pointer;
  transition:.15s ease;
}

.btn:hover{ filter: brightness(1.08); }

.userpill{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  font-size:14px;
}

/* ===============================
   CONTENT + GRID
================================= */
.content{ padding:18px; }

.grid{ display:grid; gap:14px; }

.kpis{ grid-template-columns: repeat(4, minmax(0,1fr)); }
.two{ grid-template-columns: 2fr 1fr; }

@media (max-width: 1100px){
  .kpis{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two{ grid-template-columns: 1fr; }
}

@media (max-width: 768px){
  .sidebar{ width:250px; }
  .search{ display:none; }
}

/* ===============================
   CARDS
================================= */
.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding:16px;
  box-shadow: var(--shadow);
  transition:.2s ease;
}

.card:hover{ transform: translateY(-2px); }

.card-header{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title{
  font-weight: 800;
  font-size: 16px;
  margin: 0;
}

.card-subtitle{
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.tall{ min-height:260px; }

.kpi-success{ border-left: 4px solid var(--success); }
.kpi-warning{ border-left: 4px solid var(--warning); }
.kpi-danger{ border-left: 4px solid var(--danger); }

.muted{ color: var(--muted); font-size: 13px; display:block; margin-top: 6px; }
.page{ max-width: 1200px; margin: 0 auto; }
.list{ margin:0; padding-left: 18px; color: var(--muted); }
.list li{ margin: 10px 0; }

.quick{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}

.quick-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
}

.quick-item:hover{ background: rgba(255,255,255,.07); }

@media (max-width: 900px){ .quick{ grid-template-columns: 1fr; } }

/* ===============================
   PAGE LAYOUT (forms + tables)
================================= */
.container{
  max-width: 1200px;
  margin: 0 auto;
}

.grid-2{
  display:grid;
  grid-template-columns: 420px 1fr;
  gap: 14px;
  align-items:start;
}

@media (max-width: 1100px){
  .grid-2{ grid-template-columns: 1fr; }
}

/* ===============================
   FORM ELEMENTS
================================= */
.form{ display:grid; gap: 12px; }

.form-row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px){
  .form-row{ grid-template-columns: 1fr; }
}

.field{
  display:flex;
  flex-direction: column;
  gap: 8px;
}

label{
  color: var(--muted);
  font-size: 13px;
}

input[type="text"],
input[type="number"],
select,
textarea{
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 14px;
  outline:none;
  transition:.15s ease;
}

input:focus, select:focus, textarea:focus{
  border-color: rgba(79,140,255,.55);
  box-shadow: 0 0 0 4px rgba(79,140,255,.18);
}

.checkline{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
}

.form-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding-top: 6px;
}

/* ===============================
   TABLE
================================= */
.table-wrap{
  overflow:auto;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.table{
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: rgba(255,255,255,.02);
}

.table th, .table td{
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  text-align:left;
  font-size: 14px;
  vertical-align: middle;
}

.table th{
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .8px;
  background: rgba(255,255,255,.03);
  position: sticky;
  top: 0;
}

.table tr:hover td{ background: rgba(255,255,255,.05); }

.num{
  text-align:right;
  font-variant-numeric: tabular-nums;
}

/* Table actions */
.actions{
  display:flex;
  gap: 8px;
  justify-content:flex-end;
  align-items:center;
}

.actions-wrap{
  display:flex !important;
  align-items:center !important;
  gap:12px !important;
}

.actions-wrap form{ margin:0 !important; }

.btn-sm{
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}

.btn-secondary{
  background: rgba(255,255,255,.08);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger{
  background: rgba(255,93,93,.14);
  border: 1px solid rgba(255,93,93,.25);
  color: #ffd1d1;
}

/* Small toolbar above table */
.toolbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar .search{ width: min(520px, 55vw); }

/* ===============================
   ALERTS + BADGES
================================= */
.alert{
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.alert-success{
  background: rgba(34,197,94,.14);
  border-color: rgba(34,197,94,.25);
  color: #d6ffe6;
}

.alert-danger,
.alert-error{
  background: rgba(255,93,93,.12);
  border-color: rgba(255,93,93,.25);
  color: #ffd1d1;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
}

.badge-success{
  background: rgba(34,197,94,.14);
  border-color: rgba(34,197,94,.25);
  color: #d6ffe6;
}

.badge-muted{
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.10);
  color: var(--muted);
}

/* Minor contrast helpers */
.btn-outline-info{ border-color: rgba(13, 202, 240, .55); }
.btn-outline-danger{ border-color: rgba(220, 53, 69, .65); }

.badge.bg-success{ box-shadow: 0 0 0 1px rgba(25, 135, 84, .35) inset; }
.badge.bg-secondary{ box-shadow: 0 0 0 1px rgba(108, 117, 125, .35) inset; }

.btn-group .btn{ white-space: nowrap; }

/* ===============================
   PAGER
================================= */
.pager{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.pager__actions{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===============================
   TOAST (floating, modern)
================================= */
.toast-stack{
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast{
  width: min(420px, calc(100vw - 36px));
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(18, 28, 48, .88);
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
  overflow: hidden;

  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 12px 10px;

  transform: translateY(-8px);
  opacity: 0;
  animation: toastIn .25s ease forwards;

  pointer-events: auto;
}

@keyframes toastIn{
  to{ transform: translateY(0); opacity: 1; }
}

.toast__body{ padding-left: 4px; }

.toast__title{
  font-size: 12px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 800;
}

.toast__text{
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.toast__close{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: .15s ease;
}

.toast__close:hover{
  background: rgba(255,255,255,.12);
  transform: scale(1.03);
}

.toast__bar{
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  overflow: hidden;
  position: relative;
  margin-top: 2px;
}

.toast__bar::after{
  content:"";
  position:absolute;
  left:0; top:0; bottom:0;
  width: 100%;
  transform: translateX(-100%);
  animation: toastBar 4s linear forwards;
  background: var(--accent);
}

@keyframes toastBar{
  to{ transform: translateX(0); }
}

/* Color accents per type */
.toast-success{ border-color: rgba(34,197,94,.25); }
.toast-success .toast__bar::after{ background: rgba(34,197,94,.95); }

.toast-error, .toast-danger{ border-color: rgba(255,93,93,.25); }
.toast-error .toast__bar::after, .toast-danger .toast__bar::after{ background: rgba(255,93,93,.95); }

.toast-warning{ border-color: rgba(250,204,21,.25); }
.toast-warning .toast__bar::after{ background: rgba(250,204,21,.95); }

.toast-info{ border-color: rgba(79,140,255,.25); }
.toast-info .toast__bar::after{ background: rgba(79,140,255,.95); }

@media (max-width: 520px){
  .toast-stack{ left: 12px; right: 12px; top: 12px; }
  .toast{ width: 100%; }
}

/* ===============================
   INVOICE ODOO-LIKE FORMSET HELPERS
================================= */
.manual-row select,
.manual-row input{
  width: 100% !important;
  min-width: 90px !important;
}

.manual-subtotal{ text-align: right; }

/* =========================================
   RESPONSIVE SEGURO SOLO FORMULARIOS/TABLAS
========================================= */

.container,
.grid-2,
.form,
.form-row,
.field,
.toolbar,
.table-wrap,
.actions,
.actions-wrap,
.pager,
.pager__actions {
  min-width: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
}

input,
select,
textarea {
  max-width: 100%;
}

@media (max-width: 900px){
  .grid-2{
    grid-template-columns: 1fr;
  }

  .toolbar{
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .search{
    width: 100%;
  }

  .pager{
    flex-direction: column;
    align-items: stretch;
  }

  .pager__actions{
    justify-content: flex-start;
  }
}

@media (max-width: 768px){
  .content{
    padding: 14px;
  }

  .form-row{
    grid-template-columns: 1fr;
  }

  .form-actions{
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn,
  .form-actions button{
    width: 100%;
  }

  .actions,
  .actions-wrap{
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .actions .btn,
  .actions-wrap .btn,
  .actions-wrap a,
  .actions-wrap button{
    width: 100%;
  }

  .actions-wrap form{
    width: 100%;
  }

  .actions-wrap form button{
    width: 100%;
  }

  .table{
    min-width: 640px;
  }
}

@media (max-width: 520px){
  .content{
    padding: 12px;
  }

  .card{
    padding: 14px;
  }

  .table{
    min-width: 560px;
  }

  .toolbar{
    gap: 8px;
  }
}



/* ///////// */

/* =========================================
   DARK THEME FIXES
   pegar al final de dashboard.css
========================================= */

/* Texto general */
body,
.content,
.card,
.card-body,
.card-header,
.card-footer,
.table,
.table th,
.table td,
label,
.small,
small,
span,
p,
h1, h2, h3, h4, h5, h6,
li,
div {
  color: var(--text);
}

/* Textos secundarios */
.text-muted,
small,
.card-subtitle,
.sidebar-section,
label {
  color: var(--muted) !important;
}

/* Cards */
.card,
.panel,
.modal-content,
.dropdown-menu,
.list-group-item,
.bg-white,
.bg-light {
  background: var(--card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Tablas */
.table-wrap {
  background: var(--card);
}

.table {
  background: rgba(255,255,255,.02) !important;
  color: var(--text) !important;
}

.table thead,
.table thead th {
  background: rgba(255,255,255,.04) !important;
  color: var(--muted) !important;
  border-color: var(--border) !important;
}

.table tbody,
.table tbody tr,
.table tbody td {
  background: transparent !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background: rgba(255,255,255,.025) !important;
  color: var(--text) !important;
}

.table-hover > tbody > tr:hover > * {
  background: rgba(255,255,255,.05) !important;
  color: var(--text) !important;
}

.table-bordered,
.table-bordered th,
.table-bordered td {
  border-color: var(--border) !important;
}

/* Bootstrap table variants */
.table-light,
.table-light > th,
.table-light > td,
.table-white,
.table-white > th,
.table-white > td {
  background: rgba(255,255,255,.04) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Formularios */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea,
.form-control,
.form-select {
  background: rgba(255,255,255,.06) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted) !important;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-select:focus {
  background: rgba(255,255,255,.08) !important;
  color: var(--text) !important;
  border-color: rgba(79,140,255,.55) !important;
  box-shadow: 0 0 0 4px rgba(79,140,255,.18) !important;
}

/* Select options */
select option {
  background: #162338;
  color: var(--text);
}

/* Input group / addons */
.input-group-text {
  background: rgba(255,255,255,.06) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Dropdowns */
.dropdown-menu {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

.dropdown-item {
  color: var(--text) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: rgba(255,255,255,.06) !important;
  color: #fff !important;
}

/* Modals */
.modal-content,
.modal-header,
.modal-body,
.modal-footer {
  background: var(--card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Alerts */
.alert {
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.alert-light {
  background: rgba(255,255,255,.04) !important;
  color: var(--text) !important;
}

/* List groups */
.list-group-item {
  background: rgba(255,255,255,.03) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Badges suaves en oscuro */
.badge.bg-light,
.badge.text-dark {
  background: rgba(255,255,255,.08) !important;
  color: var(--text) !important;
}

/* Links */
a {
  color: inherit;
}

a:hover {
  color: #fff;
}

/* Si Bootstrap mete fondo blanco en responsive tables */
.table-responsive {
  background: transparent !important;
}

/* Si algún contenedor externo mete blanco */
[class*="bg-white"],
[class*="bg-light"] {
  background: var(--card) !important;
  color: var(--text) !important;
}



/* =========================================
   DARK FIX PARA TFOOT
========================================= */

.table tfoot,
.table tfoot tr,
.table tfoot th,
.table tfoot td {
  background: rgba(255,255,255,.04) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.table tfoot th,
.table tfoot td {
  font-weight: 700;
  vertical-align: middle;
}

.table tfoot tr:hover th,
.table tfoot tr:hover td {
  background: rgba(255,255,255,.06) !important;
  color: var(--text) !important;
}

/* Si el total va alineado a la derecha */
.table tfoot .num,
.table tfoot td.num,
.table tfoot th.num {
  color: #fff !important;
  font-variant-numeric: tabular-nums;
}

/* Si Bootstrap mete variantes claras */
.table-light tfoot,
.table-light tfoot tr,
.table-light tfoot th,
.table-light tfoot td {
  background: rgba(255,255,255,.04) !important;
  color: var(--text) !important;
}




/* =========================================
   FIX MENU RAPIDO + NUEVO
========================================= */

.quicknew{
  position: relative !important;
  display: inline-block !important;
}

.quicknew-menu{
  display: none !important;
  position: absolute !important;
  top: calc(100% + 8px) !important;
  right: 0 !important;
  min-width: 260px !important;
  padding: 10px !important;
  border-radius: 16px !important;
  background: rgba(15, 23, 42, .98) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 20px 50px rgba(0,0,0,.45) !important;
  z-index: 9999 !important;
}

.quicknew-menu.open{
  display: block !important;
}

.quicknew-menu a{
  display: block !important;
  padding: 10px 12px !important;
  border-radius: 12px !important;
  color: var(--text) !important;
  white-space: nowrap !important;
}

.quicknew-menu a:hover{
  background: rgba(255,255,255,.06) !important;
}

.quicknew-sep{
  height: 1px !important;
  margin: 8px 0 !important;
  background: var(--border) !important;
}

/* =========================================================
   TEMA CLARO SOBRIO - gris piedra + indigo suave
========================================================= */
:root{
  --bg: #edf1f6;
  --panel: #f6f8fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --border: rgba(148,163,184,.22);
  --accent: #4f46e5;
  --accent-soft: rgba(79,70,229,.08);
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 18px;
  --shadow: 0 12px 32px rgba(15,23,42,.08);
}

body{
  background: linear-gradient(180deg, #eef2f7 0%, #e8edf5 100%);
  color: var(--text);
}

/* Sidebar real del proyecto */
.sidebar,
.main-sidebar,
.app-sidebar{
  width: 290px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px;
  overflow: auto;
  transition: width .25s ease;
  box-shadow: inset -1px 0 0 rgba(148,163,184,.12);
}

.app.sidebar-collapsed .app-sidebar,
.sidebar-collapsed .sidebar{
  width: 78px;
}

.sidebar-section{
  color: #7b8798;
}

.nav-item,
.nav-sub,
.nav-summary{
  color: var(--text);
}

.nav-sub{
  color: var(--muted);
}

.nav-item:hover,
.nav-sub:hover,
.nav-summary:hover{
  background: rgba(79,70,229,.06);
}

.nav-item.active,
.nav-sub.active{
  background: var(--accent-soft);
  border-color: rgba(79,70,229,.16);
  color: #312e81;
}

/* Topbar */
.topbar{
  background: rgba(246,248,251,.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.iconbtn{
  background: rgba(255,255,255,.80);
  border: 1px solid var(--border);
  color: var(--text);
}

.iconbtn:hover{
  background: #ffffff;
}

.search{
  background: rgba(255,255,255,.88);
  border: 1px solid var(--border);
  color: var(--text);
}

.search::placeholder{
  color: #94a3b8;
}

.userpill{
  background: rgba(255,255,255,.78);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Cards */
.card{
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-title{
  color: var(--text);
}

.card-subtitle,
.muted,
.list{
  color: var(--muted);
}

/* Widgets rápidos */
.quick-item,
.checkline{
  background: #f8fafc;
  border: 1px solid var(--border);
}

.quick-item:hover{
  background: #f1f5f9;
}

/* Formularios */
label{
  color: #475569;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
select,
textarea{
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus{
  border-color: rgba(79,70,229,.34);
  box-shadow: 0 0 0 4px rgba(79,70,229,.10);
}

/* Tablas */
.table-wrap{
  background: #ffffff;
  border: 1px solid var(--border);
}

.table{
  background: #ffffff;
}

.table th{
  background: #f8fafc;
  color: #64748b;
  border-bottom: 1px solid var(--border);
}

.table td{
  background: transparent;
}

.table tr:hover td{
  background: #f8fafc;
}

/* Botones secundarios */
.btn-secondary{
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger{
  background: rgba(220,38,38,.08);
  border: 1px solid rgba(220,38,38,.18);
  color: #b91c1c;
}

/* Alertas */
.alert{
  background: #ffffff;
  border: 1px solid var(--border);
}

.alert-success{
  background: rgba(22,163,74,.08);
  border-color: rgba(22,163,74,.18);
  color: #166534;
}

.alert-danger,
.alert-error{
  background: rgba(220,38,38,.08);
  border-color: rgba(220,38,38,.18);
  color: #991b1b;
}

/* Badges */
.badge{
  background: #f8fafc;
  border: 1px solid var(--border);
  color: #475569;
}

.badge-success{
  background: rgba(22,163,74,.10);
  border-color: rgba(22,163,74,.18);
  color: #166534;
}

.badge-muted{
  background: #f1f5f9;
  border-color: #dbe3ee;
  color: #64748b;
}

/* Toasts */
.toast{
  background: rgba(255,255,255,.96);
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(15,23,42,.14);
}

.toast__title{
  color: #64748b;
}

.toast__text{
  color: #1f2937;
}

.toast__close{
  color: #1f2937;
  background: #f8fafc;
}

.toast__close:hover{
  background: #eef2ff;
}

.toast__bar{
  background: #e5e7eb;
}


/* =========================================================
   PULIDO DE FONDOS - CAPAS MAS SUAVES Y MENOS BLANCO PURO
========================================================= */
:root{
  --bg: #e9eef5;
  --panel: #f4f7fb;
  --card: #f7f9fc;
  --card-2: #fbfcfe;
  --surface: #eef3f8;
  --text: #1f2937;
  --muted: #64748b;
  --border: rgba(148,163,184,.20);
  --accent: #4f46e5;
  --shadow: 0 12px 30px rgba(15,23,42,.07);
}

body{
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(79,70,229,.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(59,130,246,.05), transparent 50%),
    linear-gradient(180deg, #edf2f8 0%, #e6ecf4 100%) !important;
  color: var(--text);
}

/* zona central */
.main,
.app-main{
  background: transparent !important;
}

.content{
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.06));
  min-height: calc(100vh - 64px);
}

/* sidebar un poco mas marcada */
.sidebar,
.main-sidebar,
.app-sidebar{
  background: linear-gradient(180deg, #f6f8fb 0%, #eef3f8 100%) !important;
  border-right: 1px solid var(--border) !important;
}

/* cards y superficies */
.card,
.panel,
.modal-content,
.dropdown-menu,
.offcanvas,
.accordion-item,
.table-wrap,
.table-responsive,
.bg-white,
.bg-light,
[class*="bg-white"],
[class*="bg-light"]{
  background: var(--card) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow) !important;
}

/* cabeceras y bloques internos */
.card-header,
.card-footer,
.modal-header,
.modal-footer,
.rounded.p-3,
.rounded.p-4,
.border.rounded,
.table thead th,
.table-light > :not(caption) > * > *{
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* cuerpos */
.card-body,
.modal-body,
.list-group-item{
  background: var(--card-2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* tablas normales */
.table,
.table tbody,
.table tbody tr,
.table tbody td,
.table tfoot,
.table tfoot tr,
.table tfoot td,
.table tfoot th{
  background: var(--card-2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.table thead,
.table thead th,
.table th{
  background: #eef3f8 !important;
  color: #64748b !important;
  border-color: var(--border) !important;
}

.table-hover > tbody > tr:hover > *,
.table tr:hover td{
  background: #edf3ff !important;
  color: var(--text) !important;
}

/* importantisimo: neutraliza las table-dark */
.table-dark,
.table-dark > :not(caption) > * > *{
  background: var(--card-2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.table-dark thead th{
  background: #eef3f8 !important;
  color: #64748b !important;
}

/* formularios */
.form-control,
.form-select,
.input-group-text,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea{
  background: #fbfdff !important;
  color: var(--text) !important;
  border: 1px solid rgba(148,163,184,.24) !important;
}

.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus{
  background: #ffffff !important;
  border-color: rgba(79,70,229,.34) !important;
  box-shadow: 0 0 0 4px rgba(79,70,229,.10) !important;
}

/* dropdowns y listas */
.dropdown-item,
.list-group-item{
  color: var(--text) !important;
}

.dropdown-item:hover,
.list-group-item:hover{
  background: #eef3ff !important;
  color: #312e81 !important;
}

/* paginacion */
.page-link{
  background: #f8fafc !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.page-link:hover{
  background: #eef3ff !important;
  color: #312e81 !important;
}

/* ===== AJUSTE FINO DE FONDOS REALES ===== */
:root{
  --bg: #e8edf4;
  --panel: #f4f7fb;
  --card: #f6f8fc;
  --card-soft: #fbfcfe;
  --surface: #eef3f8;
  --text: #1f2937;
  --muted: #64748b;
  --border: rgba(148,163,184,.18);
  --shadow: 0 12px 28px rgba(15,23,42,.06);
}

body{
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(79,70,229,.06), transparent 50%),
    radial-gradient(900px 520px at 100% 0%, rgba(59,130,246,.05), transparent 48%),
    linear-gradient(180deg, #edf2f8 0%, #e6edf5 100%) !important;
}

.content{
  padding: 18px;
  min-height: calc(100vh - 64px);
  background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.04));
}

.card{
  background: linear-gradient(180deg, var(--card-soft) 0%, var(--card) 100%) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow) !important;
}

.table-wrap,
.table-responsive{
  background: transparent !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
}

.table{
  background: transparent !important;
}

.table thead th{
  background: var(--surface) !important;
  color: #64748b !important;
  border-color: var(--border) !important;
}

.table tbody td,
.table tfoot td,
.table tfoot th{
  background: rgba(255,255,255,.34) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.table tbody tr:hover td{
  background: #eef3ff !important;
}

.card hr{
  border-color: var(--border) !important;
}

.card form p{
  margin-bottom: 14px;
}

.card form p label{
  display: block;
  margin-bottom: 6px;
}

/* ===== Ajuste final de utilidades claras ===== */
:root{
  --surface-strong: #ffffff;
  --surface-soft-2: #f8fafc;
}

body{
  background:
    radial-gradient(1000px 420px at 0% 0%, rgba(37,99,235,.08), transparent 52%),
    radial-gradient(850px 430px at 100% 0%, rgba(59,130,246,.06), transparent 48%),
    linear-gradient(180deg, #f7f9fc 0%, #f1f5f9 100%) !important;
}

.table-dark,
.table-dark > :not(caption) > * > *{
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}

.table-dark thead th{
  background: #f8fafc !important;
  color: #64748b !important;
}

.btn-outline-light,
.btn-light,
.btn-secondary,
.btn-outline-primary,
.btn-outline-info,
.btn-outline-danger{
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}

.btn-outline-light:hover,
.btn-light:hover,
.btn-secondary:hover,
.btn-outline-primary:hover,
.btn-outline-info:hover,
.btn-outline-danger:hover{
  background: #eef4ff !important;
  color: #1d4ed8 !important;
}

.text-white{ color: #0f172a !important; }
.text-muted, .muted{ color: #64748b !important; }


/* ===== Ajustes quirurgicos finales: tablas, colapso y botones ===== */
.table,
.table-dark{
  --bs-table-color: var(--text);
  --bs-table-bg: #ffffff;
  --bs-table-border-color: var(--border);
  --bs-table-striped-bg: #f8fafc;
  --bs-table-striped-color: var(--text);
  --bs-table-active-bg: #eaf2ff;
  --bs-table-active-color: var(--text);
  --bs-table-hover-bg: #eef4ff;
  --bs-table-hover-color: var(--text);
}

.table > :not(caption) > * > *,
.table-dark > :not(caption) > * > *,
.table-active,
.table-active > th,
.table-active > td,
.table-hover > tbody > tr:hover > *,
.table tbody > tr:hover > *{
  color: var(--text) !important;
  box-shadow: none !important;
}

.table-hover > tbody > tr:hover > *,
.table tbody > tr:hover > *{
  background: #eef4ff !important;
}

.table-active,
.table-active > th,
.table-active > td{
  background: #eaf2ff !important;
}

.table tbody td .text-white,
.table tbody td .text-dark,
.table-dark tbody td .text-white,
.table-dark tbody td .text-dark,
.table tbody td a,
.table-dark tbody td a{
  color: inherit !important;
}

.app.sidebar-collapsed .app-sidebar,
.app.sidebar-collapsed .sidebar{
  overflow-x: hidden;
}

.app.sidebar-collapsed .sidebar-section,
.app.sidebar-collapsed .brand-name,
.app.sidebar-collapsed .nav-text,
.app.sidebar-collapsed .chev{
  display: none !important;
}

.app.sidebar-collapsed .brand,
.app.sidebar-collapsed .brand-pro,
.app.sidebar-collapsed .nav-item,
.app.sidebar-collapsed .nav-sub,
.app.sidebar-collapsed .nav-summary,
.app.sidebar-collapsed details.nav-group > summary{
  justify-content: center !important;
  gap: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  text-align: center;
}

.app.sidebar-collapsed .nav-item i,
.app.sidebar-collapsed .nav-sub i,
.app.sidebar-collapsed .nav-summary i,
.app.sidebar-collapsed details.nav-group > summary i{
  margin: 0 !important;
  font-size: 18px;
}

.app.sidebar-collapsed details.nav-group details.nav-group > summary{
  margin-left: 0 !important;
}

.btn,
.btn-erp,
button.btn-erp,
a.btn,
button.btn,
input.btn,
input[type="submit"].btn,
input[type="button"].btn{
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.15;
  white-space: nowrap;
  padding: 10px 16px;
}

.btn-sm,
.btn-group-sm > .btn,
.actions .btn-sm,
.actions-wrap .btn-sm{
  min-height: 34px;
  padding: 6px 10px !important;
}

.actions-wrap .btn,
.actions-wrap a,
.actions-wrap button,
.form-actions .btn,
.form-actions button{
  min-height: 42px;
}


/* ===============================
   MOBILE POLISH
================================= */
@media (max-width: 768px){
  .content,
  .page,
  .container,
  .grid,
  .card{
    min-width: 0;
  }

  .content{
    padding: 12px;
  }

  .card{
    padding: 14px;
    border-radius: 16px;
  }

  .toolbar,
  .form-actions,
  .actions,
  .actions-wrap,
  .btn-group{
    flex-wrap: wrap;
  }

  .toolbar{
    align-items: stretch;
  }

  .toolbar .search{
    width: 100%;
  }

  .btn,
  .btn-erp,
  button.btn-erp,
  .btn-sm{
    min-height: 40px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .table th,
  .table td{
    padding: 10px 10px;
    font-size: 13px;
  }
}

@media (max-width: 480px){
  .content{
    padding: 10px;
  }

  .kpis,
  .quick,
  .form-row,
  .grid-2{
    grid-template-columns: 1fr;
  }

  .card{
    padding: 12px;
  }

  .form-actions,
  .actions,
  .actions-wrap{
    display: grid !important;
    grid-template-columns: 1fr;
  }

  .form-actions > *,
  .actions > *,
  .actions-wrap > *,
  .actions-wrap form,
  .actions-wrap form button{
    width: 100%;
  }
}


/* Responsive reforzado */
.matrix-card,
.matrix-panel,
.matrix-table-wrap,
.matrix-grid,
.matrix-stats,
.matrix-hero,
.matrix-chart,
.matrix-side,
.matrix-kpi,
.matrix-card * {
  min-width: 0;
}

.matrix-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.matrix-table-wrap table td,
.matrix-table-wrap table th,
.matrix-kpi,
.matrix-side,
.matrix-card {
  word-break: break-word;
  overflow-wrap: anywhere;
}

@media (max-width: 992px){
  .matrix-actions,
  .matrix-toolbar,
  .matrix-header {
    gap: 10px;
    flex-wrap: wrap;
  }
}

@media (max-width: 768px){
  .matrix-actions > *,
  .matrix-toolbar > * {
    width: 100%;
  }
}
