/* ===================================================
   MantisCore — main.css  v2
   Design: Warm professional · Web-first responsive
   =================================================== */

/* ─── Variables ─────────────────────────────────── */
:root {
  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-bg: #171412;
  --sidebar-border: rgba(255,255,255,0.07);
  --sidebar-text: #a8a29e;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255,255,255,0.05);
  --sidebar-active-bg: rgba(234,88,12,0.16);
  --sidebar-active-border: #ea580c;

  /* Topbar */
  --topbar-height: 56px;
  --topbar-bg: #ffffff;
  --topbar-border: #e7e5e4;

  /* Background */
  --bg: #fafaf9;
  --bg-subtle: #f5f5f4;
  --card-bg: #ffffff;
  --border-color: #e7e5e4;
  --border-light: #f0efee;

  /* Text */
  --text-primary: #1c1917;
  --text-secondary: #44403c;
  --text-muted: #78716c;

  /* Brand / Accent — warm orange */
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-light: #fff7ed;
  --accent-mid: #fdba74;

  /* Status */
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --info: #0ea5e9;
  --info-light: #f0f9ff;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.14);

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Spacing */
  --content-padding: 1.75rem;
}

/* ─── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text-primary); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { text-decoration: underline; color: var(--accent-hover); }
img { max-width: 100%; }

/* ─── App Layout ──────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  /* El color se declara acá y no sólo en cada ítem: si un elemento del menú
     queda sin regla propia —porque se agregó uno nuevo, o porque el navegador
     tiene cacheada una hoja vieja— hereda un gris legible y no el casi negro
     del body, que sobre este fondo no se ve. Ya pasó con los grupos
     plegables. */
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: .75rem; }
.logo-icon-wrap {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #f97316);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .9rem; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(234,88,12,.4);
}
.logo-name { display: block; font-size: .95rem; font-weight: 700; color: #fff; letter-spacing: -.02em; line-height: 1.2; }
.logo-sub { display: block; font-size: .6rem; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: .08em; margin-top: 1px; }
.sidebar-close {
  display: none;
  background: none; border: none;
  color: var(--sidebar-text); cursor: pointer;
  padding: .3rem; border-radius: var(--radius-sm);
  font-size: .9rem; line-height: 1;
  transition: color .15s;
}
.sidebar-close:hover { color: #fff; }

/* Tenant section */
.sidebar-tenant {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  gap: .5rem;
}
.tenant-info { min-width: 0; }
.tenant-label { display: block; font-size: .6rem; text-transform: uppercase; letter-spacing: .1em; color: var(--sidebar-text); margin-bottom: 1px; }
.tenant-name { display: block; font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-switch {
  flex-shrink: 0; width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  color: var(--sidebar-text); font-size: .75rem;
  transition: all .15s; text-decoration: none !important;
}
.tenant-switch:hover { background: rgba(234,88,12,.2); border-color: var(--accent); color: #fff; text-decoration: none; }

/* Nav */
.sidebar-nav { padding: .625rem 0 1rem; flex: 1; }

/* Grupos plegables (<details>): el menú arranca compacto y sólo se abre la
   sección donde está parado el usuario. Sin JS de por medio — el servidor
   marca `open` y el navegador hace el resto. */
.nav-group { border: none; }
.nav-group + .nav-group { border-top: 1px solid rgba(255,255,255,.05); }
.nav-group-head {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1rem;
  font-size: .82rem; font-weight: 600;
  /* Blanco casi pleno: estos encabezados son el nivel principal del menú, no
     una etiqueta de sección. Con el gris tenue que tenían antes se perdían
     contra el fondo oscuro. */
  color: #e7e5e4;
  cursor: pointer; user-select: none;
  list-style: none;
  transition: color .15s, background .15s;
}
.nav-group-head::-webkit-details-marker { display: none; }
.nav-group-head:hover { background: var(--sidebar-hover); color: #fff; }
.nav-group-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-group-chevron {
  font-size: .62rem; opacity: .7; flex-shrink: 0;
  transition: transform .2s ease;
}
.nav-group[open] > .nav-group-head { color: #fff; }
.nav-group[open] > .nav-group-head .nav-group-chevron { transform: rotate(180deg); }
/* La sección donde está parado el usuario se distingue del resto. La marca la
   pone el servidor, no `:has()`: así no depende del soporte del navegador. */
.nav-group-activa > .nav-group-head { color: #fb923c; }
.nav-group-activa > .nav-group-head .nav-icon { opacity: 1; }

.nav-group-items { padding-bottom: .2rem; }

.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem 1rem;
  font-size: .845rem; color: var(--sidebar-text);
  transition: all .15s; text-decoration: none !important;
  position: relative; white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); }
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 3px; bottom: 3px;
  width: 3px; background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-icon { width: 16px; text-align: center; font-size: .82rem; opacity: .7; flex-shrink: 0; }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }
.nav-item-accent { color: #fb923c !important; font-weight: 500; }
.nav-item-accent:hover { background: rgba(234,88,12,.1) !important; color: #f97316 !important; }
.sidebar-quick { margin: .8rem 1rem 0; padding-top: .8rem; border-top: 1px solid var(--sidebar-border); }
.sidebar-quick-title { display: block; margin-bottom: .45rem; color: var(--sidebar-text); font-size: .68rem; font-weight: 600; }
.sidebar-quick-link { display: flex; align-items: center; gap: .5rem; padding: .38rem .45rem; color: var(--sidebar-text); font-size: .76rem; border-radius: var(--radius-sm); text-decoration: none !important; }
.sidebar-quick-link i { width: 14px; color: #fb923c; text-align: center; }
.sidebar-quick-link:hover { color: #fff; background: var(--sidebar-hover); }

/* Ítems dentro de un grupo: sangrados y un punto más chicos, para que se lea
   de un vistazo qué cuelga de qué. */
.nav-subitem {
  padding-left: 2.3rem;
  font-size: .81rem;
}
.nav-subitem .nav-icon { width: 14px; font-size: .75rem; }

/* Interruptor de módulo opcional (alta/edición de organización) */
.modulo-toggle {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: .85rem 1rem;
  margin-bottom: 1.25rem;
}
.modulo-toggle-head {
  display: flex; align-items: flex-start; gap: .7rem;
  cursor: pointer; margin: 0;
}
.modulo-toggle-head input[type="checkbox"] {
  width: 17px; height: 17px; margin-top: .12rem;
  accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.modulo-toggle-title {
  display: block; font-size: .875rem; font-weight: 600;
  color: var(--text-primary);
}
.modulo-toggle-title i { color: var(--accent); margin-right: .3rem; }
.modulo-toggle-desc {
  display: block; font-size: .78rem; color: var(--text-secondary);
  margin-top: .2rem; line-height: 1.45;
}

/* Sidebar footer */
.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: .5rem;
  flex-shrink: 0;
}
.sidebar-user { flex: 1; display: flex; align-items: center; gap: .6rem; text-decoration: none !important; min-width: 0; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: #fff; font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name { display: block; font-size: .78rem; color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: .66rem; color: var(--sidebar-text); }
.sidebar-logout {
  flex-shrink: 0; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sidebar-text); font-size: .875rem;
  border-radius: var(--radius-sm); transition: all .15s;
  text-decoration: none !important;
}
.sidebar-logout:hover { color: var(--danger); background: rgba(220,38,38,.1); }

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ─── Main Wrapper ────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.main-wrapper.main-full { margin-left: 0; }

/* Legacy compat — if .main-content used without wrapper */
.main-content.main-full { margin-left: 0; }

/* ─── Top Bar ─────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex; align-items: center;
  padding: 0 1.5rem; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}
.topbar-toggle {
  display: none; background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  font-size: 1.05rem; padding: .4rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s; flex-shrink: 0;
}
.topbar-toggle:hover { background: var(--bg-subtle); color: var(--text-primary); }
.topbar-title { flex: 1; font-size: .875rem; color: var(--text-muted); min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: .55rem; white-space: nowrap; overflow: hidden; }
.breadcrumb a { font-weight: 600; color: var(--text-secondary); }
.breadcrumb i { font-size: .55rem; color: #a8a29e; }
.breadcrumb span { overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.topbar-user {
  display: flex; align-items: center; gap: .5rem;
  text-decoration: none !important; color: var(--text-secondary);
  border-radius: var(--radius-md); padding: .3rem .5rem;
  transition: background .15s;
}
.topbar-user:hover { background: var(--bg-subtle); text-decoration: none; }
.topbar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: #fff; font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.topbar-username { font-size: .82rem; font-weight: 500; color: var(--text-secondary); }
.topbar-logout {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-md);
  color: var(--text-muted); text-decoration: none !important;
  transition: color .15s, background .15s;
}
.topbar-logout:hover { color: var(--danger); background: rgba(220,38,38,.08); }

/* ─── Main Content ────────────────────────────── */
.main-content { flex: 1; padding: var(--content-padding); max-width: 100%; }

/* Messages */
.messages-container { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
/* legacy alias */
.messages-wrapper { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: .5rem; }

/* Page container */
.page-container { max-width: 1300px; }
.page-container.page-narrow { max-width: 760px; }
.page-container.page-wide { max-width: 100%; }

/* ─── Page Header ─────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap; gap: .75rem;
}
.page-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; color: var(--text-primary); }
.page-subtitle { font-size: .875rem; color: var(--text-muted); margin-top: .3rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.page-actions { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }
.back-link {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .8rem; color: var(--text-muted);
  margin-bottom: .35rem; text-decoration: none !important; transition: color .15s;
}
.back-link:hover { color: var(--accent); }

/* ─── Cards ──────────────────────────────────── */
.card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-body { padding: 1.5rem; }
.card-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card-title { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.card-section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 600; padding: 1rem 1.5rem .5rem; border-bottom: 1px solid var(--border-light); }
.border-success { border-color: var(--success) !important; }
.border-danger { border-color: var(--danger) !important; }

/* ─── Tables ─────────────────────────────────── */
.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  padding: .625rem 1rem;
  background: var(--bg-subtle);
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--accent-light); }
.table.table-compact td, .table.table-compact th { padding: .45rem .875rem; }
.table-total td { background: var(--bg-subtle); font-weight: 700; border-top: 2px solid var(--border-color); }
.table-subtotal td { background: var(--bg-subtle); border-top: 1px solid var(--border-color); }
.text-right { text-align: right; }
.row-anulado td { opacity: .45; text-decoration: line-through; }

/* ─── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  font-size: .875rem; font-weight: 500;
  border-radius: var(--radius-md); border: 1px solid transparent;
  cursor: pointer; transition: all .15s;
  white-space: nowrap; text-decoration: none !important;
  font-family: inherit; line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 2px 8px rgba(234,88,12,.3); }
.btn-secondary { background: #fff; color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--bg-subtle); border-color: #d6d3d1; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-ghost.btn-danger { color: var(--danger); }
.btn-ghost.btn-danger:hover { background: var(--danger-light); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Badges ─────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .6rem; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-radius: 20px; white-space: nowrap; }
.badge-borrador { background: #fef3c7; color: #92400e; }
.badge-confirmado { background: var(--success-light); color: #15803d; }
.badge-anulado { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border-color); }
.badge-success { background: var(--success-light); color: #15803d; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-tipo-activo { background: #dbeafe; color: #1e40af; }
.badge-tipo-pasivo { background: #fce7f3; color: #9d174d; }
.badge-tipo-patrimonio { background: #ede9fe; color: #5b21b6; }
.badge-tipo-ingreso { background: var(--success-light); color: #15803d; }
.badge-tipo-egreso { background: var(--danger-light); color: #991b1b; }

/* ─── Forms ─────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: .825rem; font-weight: 500; color: var(--text-secondary); margin-bottom: .35rem; }
.form-control {
  display: block; width: 100%; padding: .5rem .75rem;
  font-size: .875rem; font-family: inherit;
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  background: #fff; color: var(--text-primary);
  outline: none; transition: border-color .15s, box-shadow .15s; line-height: 1.5;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(234,88,12,.12); }
.form-control.form-control-sm { padding: .35rem .6rem; font-size: .8rem; }
.form-control:disabled, .form-control[readonly] { background: var(--bg-subtle); color: var(--text-muted); cursor: not-allowed; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-error { display: block; font-size: .775rem; color: var(--danger); margin-top: .25rem; }
.form-hint { display: block; font-size: .775rem; color: var(--text-muted); margin-top: .25rem; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-light); }
.is-invalid { border-color: var(--danger) !important; }
.filter-bar { margin-bottom: 1.25rem; }
.filter-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ─── Alerts ─────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start;
  gap: .75rem; padding: .875rem 1rem;
  border-radius: var(--radius-md); font-size: .875rem;
  border: 1px solid transparent; position: relative;
}
.alert-icon { flex-shrink: 0; font-size: 1rem; margin-top: .05rem; }
.alert > span { flex: 1; }
.alert-link { font-weight: 600; text-decoration: underline; }
.alert-close { flex-shrink: 0; background: none; border: none; cursor: pointer; opacity: .6; font-size: .9rem; padding: 0; line-height: 1; transition: opacity .15s; margin-left: auto; color: inherit; }
.alert-close:hover { opacity: 1; }
.alert-success { background: var(--success-light); color: #15803d; border-color: #bbf7d0; }
.alert-error, .alert-danger { background: var(--danger-light); color: #991b1b; border-color: #fca5a5; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fcd34d; }
.alert-info { background: var(--info-light); color: #0369a1; border-color: #bae6fd; }

/* ─── Stat Cards ─────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  container-type: inline-size;
}
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; width: 4px; height: 100%;
  background: var(--border-color);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.stat-card.stat-success::before, .stat-card.stat-card-success::before { background: var(--success); }
.stat-card.stat-warning::before { background: var(--warning); }
.stat-card.stat-danger::before, .stat-card.stat-card-danger::before { background: var(--danger); }
.stat-card.stat-accent::before { background: var(--accent); }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 600; margin-bottom: .5rem; }
.stat-value { font-size: clamp(1.1rem, 8cqi, 1.75rem); font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-sub { font-size: .775rem; color: var(--text-muted); margin-top: .35rem; }
.stat-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.stat-card.stat-success .stat-value, .stat-card.stat-card-success .stat-value { color: var(--success); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-danger .stat-value, .stat-card.stat-card-danger .stat-value { color: var(--danger); }
.stat-card.stat-accent .stat-value { color: var(--accent); }
.hub-stat-link { color: inherit; text-decoration: none !important; transition: border-color .15s, box-shadow .15s; }
.hub-stat-link:hover { color: inherit; border-color: var(--accent-mid); box-shadow: var(--shadow-md); }
.hub-header .page-title i { margin-right: .5rem; color: var(--accent); font-size: 1.15rem; }
.hub-group { margin-top: 1.75rem; }
.hub-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.hub-card { display: flex; flex-direction: column; min-height: 210px; }
.hub-card-main { display: flex; flex: 1; flex-direction: column; align-items: flex-start; padding: 1.4rem 1.4rem 1rem; color: var(--text-primary); text-decoration: none !important; }
.hub-card-main:focus-visible { outline: 3px solid rgba(234,88,12,.3); outline-offset: -3px; }
.hub-card-icon { color: var(--accent); font-size: 1.75rem; margin-bottom: 1rem; }
.hub-card-title { font-size: 1rem; font-weight: 650; }
.hub-card-description { color: var(--text-muted); font-size: .82rem; line-height: 1.5; margin-top: .35rem; }
.hub-card-actions { display: flex; gap: .5rem; padding: .9rem 1.4rem 1.15rem; border-top: 1px solid var(--border-light); }
.hub-pendientes { margin: 1.5rem 0; }
.pending-grid { display: flex; flex-wrap: wrap; gap: .75rem; }
.pending-item { min-width: 230px; display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; border: 1px solid; border-radius: var(--radius-md); text-decoration: none !important; font-size: .84rem; }
.pending-danger { color: #991b1b; background: var(--danger-light); border-color: #fecaca; }
.pending-warning { color: #92400e; background: var(--warning-light); border-color: #fde68a; }
.screen-search { position: fixed; inset: 0; z-index: 500; background: rgba(28,25,23,.5); padding: 12vh 1rem 1rem; }
.screen-search-panel { width: min(520px,100%); max-height: 70vh; margin: auto; padding: 1rem; background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.screen-search-panel label { display: block; margin-bottom: .55rem; font-size: .82rem; font-weight: 600; }
.screen-search-results { max-height: 45vh; overflow: auto; margin: .6rem 0; }
.screen-search-results a { display: flex; align-items: center; gap: .65rem; padding: .6rem .7rem; color: var(--text-secondary); border-radius: var(--radius-sm); text-decoration: none !important; }
.screen-search-results a i { width: 16px; color: var(--accent); text-align: center; }
.screen-search-results a:hover, .screen-search-results a.selected { background: var(--accent-light); color: var(--accent-hover); }
.screen-search-panel small { color: var(--text-muted); }

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

/* ─── Navegación por áreas ───────────────────── */
body[data-area]:not([data-area="hub"]) .page-header {
  border-top: 4px solid var(--area);
  padding-top: 1rem;
}
.sidebar-area-header {
  min-height: 116px;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: .8rem;
  background: var(--area);
  color: #fff;
}
.sidebar-all-areas {
  color: rgba(255,255,255,.9);
  font-size: .74rem;
  font-weight: 600;
  text-decoration: none !important;
}
.sidebar-all-areas:hover { color: #fff; }
.sidebar-all-areas i { margin-right: .35rem; }
.sidebar-area-title { display: flex; align-items: center; gap: .7rem; font-size: 1.05rem; font-weight: 700; }
.sidebar-area-title i { width: 28px; font-size: 1.35rem; text-align: center; }
.nav-panel { margin-bottom: .35rem; }
.nav-group-head { justify-content: space-between; }
.nav-group-head > i { font-size: .6rem; transition: transform .15s; }
.nav-group[open] > .nav-group-head > i { transform: rotate(180deg); }
.nav-group-activa > .nav-group-head { color: #fff; }
.nav-group-items .nav-item { padding-left: 1.45rem; font-size: .8rem; }
body[data-area]:not([data-area="hub"]) .nav-item.active {
  background: color-mix(in srgb, var(--area) 24%, transparent);
  color: #fff;
}
body[data-area]:not([data-area="hub"]) .nav-item.active::before { background: var(--area); }
.hub-sidebar-label { padding: .8rem 1rem .3rem; color: #78716c; font-size: .7rem; font-weight: 700; }
.hub-area-link .nav-icon { color: var(--area-link); opacity: 1; }
.breadcrumb-area {
  padding: .26rem .55rem;
  border-radius: 999px;
  color: var(--area) !important;
  background: var(--area-suave);
}
.topbar-hub-title { font-weight: 650; color: var(--text-secondary); }

/* Hub principal: el color funciona como señal de dominio. */
.areas-page { max-width: 1180px !important; margin: 0 auto; }
.areas-intro { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin: .75rem 0 2rem; }
.areas-intro h1 { font-size: clamp(1.75rem, 4vw, 2.7rem); letter-spacing: -.045em; line-height: 1.05; }
.areas-intro p { margin-top: .6rem; color: var(--text-muted); font-size: .95rem; }
.areas-company { font-size: 2.5rem; font-weight: 800; letter-spacing: -.08em; color: #d6d3d1; }
.areas-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
.area-card {
  position: relative;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  min-height: 190px;
  padding: 1.35rem;
  overflow: hidden;
  color: #1c1917;
  background: var(--card-area-soft);
  border: 1px solid color-mix(in srgb, var(--card-area) 44%, white);
  border-top: 7px solid var(--card-area);
  border-radius: 14px;
  text-decoration: none !important;
  transition: transform .15s, box-shadow .15s;
}
.area-card:hover { color: #1c1917; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.area-card:focus-visible { outline: 3px solid var(--card-area); outline-offset: 3px; }
.area-card-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 12px; background: var(--card-area); color: #fff; font-size: 1.55rem; }
.area-card-copy { display: flex; flex-direction: column; gap: .38rem; }
.area-card-copy strong { color: #1c1917; font-size: 1.3rem; letter-spacing: -.02em; }
.area-card-copy > span { max-width: 42ch; color: #44403c; font-size: .84rem; line-height: 1.45; }
.area-card-metrics { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 1.5rem; align-self: end; }
.area-card-metrics > span { display: flex; flex-direction: column; gap: .15rem; }
.area-card-metrics b { color: #1c1917; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.area-card-metrics small { color: #57534e; font-size: .68rem; }
.area-card-open { color: var(--card-area); padding-top: .25rem; }

/* Panel de área. */
.hub-header .page-title i { color: var(--area); }
.hub-stats .stat-card { border-top: 3px solid var(--area); }
.hub-stat-link:hover { border-color: var(--area); }
.hub-section { margin-top: 1.75rem; }
.area-quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.area-quick-link { display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; color: var(--text-primary); background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-md); text-decoration: none !important; }
.area-quick-link i { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: var(--area); background: var(--area-suave); }
.area-quick-link:hover { color: var(--area); border-color: var(--area); }
.hub-empty { color: var(--text-muted); font-size: .85rem; }
.screen-search-results .search-area { margin-left: auto; padding: .18rem .45rem; border-radius: 999px; color: var(--search-area); background: var(--search-area-soft); font-size: .65rem; font-weight: 650; }

@media (max-width: 767px) {
  .areas-grid, .area-quick-grid { grid-template-columns: 1fr; }
  .areas-intro { align-items: start; }
  .areas-company { display: none; }
  .area-card { min-height: 170px; grid-template-columns: 50px minmax(0, 1fr) auto; padding: 1.05rem; }
  .area-card-icon { width: 48px; height: 48px; font-size: 1.25rem; }
}

/* ─── Section titles ──────────────────────────── */
.section-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: .75rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.link-muted { font-size: .8rem; color: var(--text-muted); }
.link-muted:hover { color: var(--accent); text-decoration: none; }

/* ─── Quick access grid ───────────────────────── */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.quick-card {
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 1.25rem 1rem;
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: .5rem;
  color: var(--text-secondary); transition: all .2s;
  text-decoration: none !important; box-shadow: var(--shadow-xs);
}
.quick-card:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.quick-card-icon, .quick-icon { font-size: 1.5rem; line-height: 1; }
.quick-card > span:last-child { font-size: .8rem; font-weight: 500; }
.recent-section { margin-top: 1.5rem; }

/* ─── Detail view ──────────────────────────────── */
.detail-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; padding: 1.25rem 1.5rem; }
.detail-item { display: flex; flex-direction: column; gap: 3px; }
.detail-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 600; }
.detail-value { font-size: .9rem; color: var(--text-primary); }
.link-primary { color: var(--accent); }
.link-primary:hover { text-decoration: underline; }

/* ─── Balance ─────────────────────────────────── */
.balance-section-header { padding: .75rem 1rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--text-muted); background: var(--bg-subtle); border-bottom: 1px solid var(--border-color); }

/* ─── Empty state ─────────────────────────────── */
.empty-state-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 3.5rem 2rem; text-align: center; color: var(--text-muted); box-shadow: var(--shadow-sm); }
.empty-icon { font-size: 3rem; display: block; margin-bottom: 1rem; }
.empty-state-card h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: .5rem; }
.empty-state-card p { font-size: .875rem; margin-bottom: 1.25rem; }

/* ─── Utility ─────────────────────────────────── */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-accent { color: var(--accent) !important; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }

/* ─── Auth pages ─────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1c1917 0%, #171412 60%, #2d1b10 100%);
  padding: 2rem;
}
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: var(--radius-xl); padding: 2.5rem; box-shadow: var(--shadow-lg); }
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-logo { font-size: 2rem; display: block; margin-bottom: .75rem; }
.auth-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), #f97316);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto .875rem;
  font-size: 1.4rem; color: #fff;
  box-shadow: 0 4px 16px rgba(234,88,12,.35);
}
.auth-title { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin-bottom: .25rem; letter-spacing: -.02em; }
.auth-subtitle { font-size: .875rem; color: var(--text-muted); }
.auth-form .btn-primary { margin-top: .5rem; }

/* ─── Tenant selector ─────────────────────────── */
.tenant-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1c1917 0%, #171412 60%, #2d1b10 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 2rem;
}
.tenant-page-header { text-align: center; margin-bottom: 2.5rem; color: #fff; }
.tenant-page-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--accent), #f97316);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem; font-size: 1.75rem; color: #fff;
  box-shadow: 0 4px 16px rgba(234,88,12,.35);
}
.tenant-page-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; color: #fff; }
.tenant-page-subtitle { font-size: .875rem; color: rgba(255,255,255,.55); margin-top: .25rem; }
.tenant-list { display: flex; flex-direction: column; gap: .75rem; width: 100%; max-width: 520px; }
.tenant-option {
  display: flex; align-items: center; gap: 1rem;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem;
  cursor: pointer; transition: all .15s; text-decoration: none !important;
}
.tenant-option:hover { background: rgba(234,88,12,.12); border-color: rgba(234,88,12,.4); }
.tenant-option-icon {
  width: 42px; height: 42px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #f97316);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(234,88,12,.3);
}
.tenant-option-name { font-weight: 600; color: #fff; font-size: .95rem; }
.tenant-option-sub { font-size: .8rem; color: rgba(255,255,255,.5); margin-top: 2px; }
.tenant-option-arrow { margin-left: auto; color: rgba(255,255,255,.35); font-size: .875rem; }

/* ─── Profile ─────────────────────────────────── */
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: #fff; font-size: 1.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem; box-shadow: 0 4px 16px rgba(234,88,12,.3);
}

/* ─── Cuentas tree ─────────────────────────────── */
.cuenta-level-0 .cuenta-name { font-weight: 700; }
.cuenta-level-1 .cuenta-name { padding-left: 1.5rem; font-weight: 600; }
.cuenta-level-2 .cuenta-name { padding-left: 3rem; }
.cuenta-level-3 .cuenta-name { padding-left: 4.5rem; color: var(--text-secondary); }
.cuenta-level-4 .cuenta-name { padding-left: 6rem; color: var(--text-muted); }
.imputable-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); margin-left: .5rem; vertical-align: middle; }

/* ─── Print ──────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-header .page-actions, .reporte-filters { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}

/* ─── Responsive — Tablet (≤ 1024px) ──────────── */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; align-items: center; justify-content: center; }
  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .main-content { padding: 1.25rem; }
}

/* ─── Responsive — Mobile (≤ 640px) ───────────── */
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-meta { grid-template-columns: 1fr; }
  .editor-meta { grid-template-columns: 1fr; }
  .page-title { font-size: 1.35rem; }
  .d-none-sm { display: none !important; }
  .form-actions { flex-direction: column; }
  .page-header { flex-direction: column; }
  .topbar { padding: 0 1rem; }
  .main-content { padding: 1rem; }
  .card-body { padding: 1rem; }
  .filter-form { flex-direction: column; }
  .filter-form > * { width: 100%; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .form-row { flex-direction: column; gap: 0; }
}

/* ─── Forms: row layout & checks ─────────────── */
.form-body { padding: 1.5rem; }
.form-row { display: flex; gap: 1rem; align-items: flex-start; }
.form-row .form-group { flex: 1; }
.form-check-group { display: flex; align-items: center; gap: .5rem; padding: .5rem 0; }
.form-check-group input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); flex-shrink: 0; }
.form-check-label { font-size: .875rem; color: var(--text-secondary); cursor: pointer; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ─── Plan de cuentas — tree table ────────────── */
.table-tree { border-collapse: collapse; }

/* Fila de cuenta */
.cuenta-row { transition: background .1s; }
.cuenta-row:hover td { background: var(--accent-light) !important; }
.row-inactive td { opacity: .5; }

/* Celda código con barra de tipo */
.cuenta-row td.td-codigo {
  font-family: var(--font-mono);
  font-size: .82rem;
  white-space: nowrap;
  padding-left: 0 !important;
}
.cuenta-codigo-inner {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.cuenta-type-bar {
  display: inline-block;
  width: 3px;
  border-radius: 2px;
  align-self: stretch;
  min-height: 20px;
  flex-shrink: 0;
}
.tipo-activo .cuenta-type-bar    { background: #3b82f6; }
.tipo-pasivo .cuenta-type-bar    { background: #ec4899; }
.tipo-patrimonio .cuenta-type-bar{ background: #8b5cf6; }
.tipo-ingreso .cuenta-type-bar   { background: var(--success); }
.tipo-egreso .cuenta-type-bar    { background: var(--danger); }

/* Nombre con indentación */
.td-nombre { position: relative; }
.cuenta-indent {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.cuenta-indent-spacer { display: inline-block; flex-shrink: 0; }
.cuenta-nombre-text {
  font-size: .875rem;
  color: var(--text-primary);
}
/* Grupos (no imputables) en cursiva más oscura */
.cuenta-grupo .cuenta-nombre-text {
  font-weight: 600;
  color: var(--text-primary);
}
/* Sub-cuentas imputables */
.cuenta-hoja .cuenta-nombre-text {
  color: var(--text-secondary);
  font-size: .85rem;
}
/* Indicador conector árbol */
.tree-connector {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--border-color);
  font-size: .65rem;
  flex-shrink: 0;
}

/* Filas de grupo: fondo levemente diferente */
.cuenta-row.es-grupo > td { background: #fafaf8; }
.cuenta-row.nivel-0 > td { background: var(--bg-subtle); }
.cuenta-row.nivel-0 .cuenta-nombre-text { font-weight: 700; font-size: .9rem; }
.cuenta-row.nivel-1 .cuenta-nombre-text { font-weight: 600; }

/* Search en header */
.search-form { display: flex; align-items: center; }
.search-input { width: 260px; }

/* ─── Código sugerido (badge en campo código) ─── */
.codigo-suggestion {
  display: inline-block;
  margin-top: .3rem;
  font-size: .72rem;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid #fed7aa;
  border-radius: var(--radius-sm);
  padding: .15rem .5rem;
  cursor: pointer;
  transition: background .15s;
}
.codigo-suggestion:hover { background: #fed7aa; }


/* ─── Landing pública ─────────────────────────────────────────── */
.landing { color: var(--text-primary); }
.landing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 2rem; max-width: 1100px; margin: 0 auto;
}
.landing-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.landing-brand-icon {
  width: 38px; height: 38px; border-radius: var(--radius-md, 10px);
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.landing-brand-name { font-size: 1.15rem; letter-spacing: -.02em; }
.landing-nav-links { display: flex; align-items: center; gap: 1rem; }
.landing-link { color: var(--text-muted); text-decoration: none; font-size: .9rem; }
.landing-link:hover { color: var(--text-primary); }

.landing-hero {
  text-align: center; max-width: 760px; margin: 0 auto; padding: 4rem 1.5rem 3rem;
}
.landing-hero-title { font-size: 2.75rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-bottom: 1.25rem; }
.landing-hero-sub { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 2rem; }
.landing-hero-cta { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.landing-hero-note { margin-top: 1rem; font-size: .85rem; color: var(--text-muted); }

.landing-section { max-width: 1000px; margin: 0 auto; padding: 3.5rem 1.5rem; }
.landing-section-title { text-align: center; font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .5rem; }
.landing-section-sub { text-align: center; color: var(--text-muted); margin-bottom: 2rem; }
.landing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-top: 2rem; }
.landing-card {
  background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.06));
}
.landing-card-icon { font-size: 1.5rem; color: var(--accent); margin-bottom: .75rem; }
.landing-card h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.landing-card p { font-size: .9rem; color: var(--text-muted); line-height: 1.5; }

.landing-pricing { background: var(--bg-subtle); border-radius: var(--radius-xl); }
.landing-price-card {
  max-width: 380px; margin: 1.5rem auto 0; background: #fff;
  border: 1px solid var(--border-color); border-radius: var(--radius-xl);
  padding: 2rem; text-align: center; box-shadow: var(--shadow-lg);
}
.landing-price-badge {
  display: inline-block; background: rgba(234,88,12,.12); color: var(--accent);
  font-size: .75rem; font-weight: 600; padding: .25rem .75rem; border-radius: 999px; margin-bottom: 1rem;
}
.landing-price-amount { font-size: 2.5rem; font-weight: 800; letter-spacing: -.03em; }
.landing-price-currency { font-size: 1.25rem; vertical-align: super; margin-right: 2px; }
.landing-price-period { font-size: 1rem; font-weight: 500; color: var(--text-muted); }
.landing-price-list { list-style: none; padding: 0; margin: 1.5rem 0; text-align: left; }
.landing-price-list li { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; font-size: .9rem; }
.landing-price-list i { color: var(--accent); font-size: .8rem; }

.landing-footer {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem; font-size: .85rem;
  color: var(--text-muted); border-top: 1px solid var(--border-color);
}

@media (max-width: 760px) {
  .landing-grid { grid-template-columns: 1fr; }
  .landing-hero-title { font-size: 2rem; }
  .landing-nav-links .landing-link { display: none; }
}

/* ─── Barra de impersonación ───────────────────────────────────── */
.impersonation-bar {
  background: #b91c1c; color: #fff; text-align: center;
  padding: .5rem 1rem; font-size: .85rem; position: sticky; top: 0; z-index: 1000;
}
.impersonation-bar a { color: #fff; text-decoration: underline; margin-left: .5rem; font-weight: 600; }

/* ─── Landing: secciones extra ─────────────────────────────────── */
.landing-eyebrow {
  display: inline-block; background: rgba(234,88,12,.1); color: var(--accent);
  font-size: .78rem; font-weight: 600; padding: .3rem .85rem; border-radius: 999px; margin-bottom: 1.25rem;
  letter-spacing: .02em;
}
.landing-strip {
  max-width: 1000px; margin: 0 auto; padding: 1.5rem; display: grid;
  grid-template-columns: repeat(4, 1fr); gap: 1rem; border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}
.landing-strip > div { text-align: center; display: flex; flex-direction: column; gap: .2rem; }
.landing-strip strong { font-size: 1.05rem; }
.landing-strip span { font-size: .82rem; color: var(--text-muted); }

.landing-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-top: 1.5rem; }
.landing-step { text-align: center; padding: 1rem; }
.landing-step-num {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--accent), #f97316); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700;
  box-shadow: 0 4px 14px rgba(234,88,12,.3);
}
.landing-step h3 { font-size: 1.1rem; margin-bottom: .4rem; }
.landing-step p { color: var(--text-muted); font-size: .9rem; }

.landing-price-trial {
  background: rgba(22,163,74,.1); color: var(--success); font-size: .85rem; font-weight: 600;
  padding: .5rem; border-radius: 8px; margin: 0 0 1rem;
}

.landing-faq { max-width: 720px; margin: 1.5rem auto 0; display: flex; flex-direction: column; gap: .6rem; }
.landing-faq-item {
  background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1rem 1.25rem;
}
.landing-faq-item summary {
  cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center;
}
.landing-faq-item summary::after { content: '+'; color: var(--accent); font-size: 1.3rem; font-weight: 400; }
.landing-faq-item[open] summary::after { content: '−'; }
.landing-faq-item p { margin: .75rem 0 0; color: var(--text-muted); font-size: .9rem; line-height: 1.6; }

.landing-cta {
  max-width: 760px; margin: 1rem auto 0; text-align: center; padding: 3.5rem 1.5rem;
  background: linear-gradient(135deg, #1c1917, #2d1b10); border-radius: var(--radius-xl); color: #fff;
}
.landing-cta h2 { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .5rem; }
.landing-cta p { color: rgba(255,255,255,.7); margin-bottom: 1.5rem; }

@media (max-width: 760px) {
  .landing-strip { grid-template-columns: repeat(2, 1fr); }
  .landing-steps { grid-template-columns: 1fr; }
}

/* ─── Landing: mockup del producto ─────────────────────────────── */
.landing-mockup { max-width: 880px; margin: 3rem auto 0; padding: 0 1rem; }
.mock-window {
  background: #fff; border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.18); text-align: left;
}
.mock-titlebar {
  display: flex; align-items: center; gap: .4rem; padding: .6rem .9rem; background: #f5f5f4;
  border-bottom: 1px solid var(--border-color);
}
.mock-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.mock-url {
  margin-left: .75rem; background: #fff; border: 1px solid var(--border-color); border-radius: 6px;
  padding: .15rem .7rem; font-size: .72rem; color: var(--text-muted); flex: 1; max-width: 320px;
}
.mock-body { display: grid; grid-template-columns: 200px 1fr; min-height: 280px; }
.mock-sidebar { background: #1c1917; color: #e7e5e4; padding: 1rem .85rem; }
.mock-logo { font-weight: 700; font-size: .9rem; color: #fff; display: flex; align-items: center; gap: .4rem; }
.mock-logo i { color: var(--accent); }
.mock-tenant {
  font-size: .68rem; color: rgba(255,255,255,.5); margin: .6rem 0 1rem; padding-bottom: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.mock-nav { display: flex; flex-direction: column; gap: .15rem; }
.mock-nav span {
  display: flex; align-items: center; gap: .55rem; font-size: .76rem; color: rgba(255,255,255,.65);
  padding: .42rem .55rem; border-radius: 7px;
}
.mock-nav span i { width: 14px; font-size: .72rem; }
.mock-nav span.active { background: var(--accent); color: #fff; }
.mock-content { padding: 1.25rem 1.4rem; }
.mock-h { font-weight: 700; font-size: 1.05rem; margin-bottom: 1rem; color: var(--text-primary); }
.mock-badge {
  background: rgba(234,88,12,.12); color: var(--accent); font-size: .62rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 999px; vertical-align: middle; margin-left: .4rem;
}
.mock-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.mock-table th {
  text-align: right; color: var(--text-muted); font-weight: 600; font-size: .68rem; text-transform: uppercase;
  padding: .35rem .5rem; border-bottom: 1px solid var(--border-color);
}
.mock-table th:first-child { text-align: left; }
.mock-table td { padding: .42rem .5rem; text-align: right; border-bottom: 1px solid #f5f5f4; font-variant-numeric: tabular-nums; }
.mock-table td:first-child { text-align: left; color: var(--text-primary); }
.mock-table tr.g td { font-weight: 700; background: #fafaf9; }
.mock-table tr.tot td { font-weight: 700; border-top: 2px solid var(--accent); }
.mock-table td.pos { color: var(--success); font-weight: 600; }

@media (max-width: 620px) {
  .mock-body { grid-template-columns: 1fr; }
  .mock-sidebar { display: none; }
}

/* ─── Landing: grilla de planes ────────────────────────────────── */
.landing-plans {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem;
  max-width: 900px; margin: 1.5rem auto 0; align-items: stretch;
}
.landing-plans .landing-price-card { margin: 0; display: flex; flex-direction: column; }
.landing-plans .landing-price-card .btn { margin-top: auto; }
.landing-price-card.featured { border: 2px solid var(--accent); box-shadow: 0 16px 44px rgba(234,88,12,.18); }
.landing-plan-name { font-weight: 700; font-size: 1.05rem; margin-bottom: .25rem; }
.landing-plan-desc { color: var(--text-muted); font-size: .85rem; margin: 0 0 .75rem; }

/* ===================================================================
   MÓDULO ADMINISTRATIVO
   Facturación, cuentas corrientes y tesorería.
   =================================================================== */

/* ─── Grillas de formulario ─────────────────────────────────────── */
.form-grid { display: grid; gap: 0 1rem; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .form-group { min-width: 0; }
.req { color: var(--danger); font-weight: 600; }
.form-group.has-error .form-control { border-color: var(--danger); }

.form-check-group { display: flex; flex-direction: column; justify-content: center; }
.form-check-label {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .825rem; color: var(--text-secondary); cursor: pointer;
}
.form-check-label input { margin: 0; }
.filtro-label { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.inline-form { display: inline; }

/* ─── Grillas de contenido ──────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-2-3 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; }
.stats-grid-compact { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.stats-grid-compact .stat-value { font-size: clamp(1.05rem, 7.5cqi, 1.35rem); }
.card-body-tight { padding: .75rem 1.5rem; }

/* ─── Chips de filtro ───────────────────────────────────────────── */
.chips-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .75rem; border-radius: 20px;
  border: 1px solid var(--border-color); background: var(--card-bg);
  font-size: .78rem; color: var(--text-secondary);
  text-decoration: none !important; transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-active:hover { color: #fff; }
.chip-count {
  background: rgba(0, 0, 0, .08); border-radius: 10px;
  padding: 0 .35rem; font-size: .7rem; font-weight: 600;
}
.chip-active .chip-count { background: rgba(255, 255, 255, .25); }

/* ─── Paginación ────────────────────────────────────────────────── */
.paginacion {
  display: flex; align-items: center; justify-content: center;
  gap: .5rem; margin-top: 1rem; flex-wrap: wrap;
}
.paginacion-info { font-size: .8rem; color: var(--text-muted); }

/* ─── Tablas de formset (editores) ──────────────────────────────── */
.tabla-formset td { padding: .35rem .4rem; vertical-align: top; }
.tabla-formset .form-control { min-width: 0; width: 100%; }
.tabla-formset select.form-control { max-width: 100%; }
.fila-formset.fila-borrada { opacity: .4; }
.fila-formset.fila-borrada .form-control { text-decoration: line-through; }
.estado-autoguardado { font-size: .8rem; font-weight: 400; color: var(--text-muted); white-space: nowrap; }
.link-button { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
.buscador-cuenta { position: relative; min-width: 14rem; }
.buscador-cuenta__detalle,
.buscador-cuenta__aviso { min-height: 1.15rem; margin-top: .25rem; font-size: .78rem; line-height: 1.25; color: var(--text-muted); }
.buscador-cuenta__aviso:not(:empty) { color: var(--warning-dark, #8a5a00); }
.buscador-cuenta__opciones { position: absolute; z-index: 30; top: calc(100% - 2.3rem); left: 0; right: 0; max-height: 320px; margin: .2rem 0 0; padding: .25rem; overflow-y: auto; list-style: none; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: var(--radius-sm, 4px); box-shadow: 0 8px 20px rgba(0, 0, 0, .14); }
.buscador-cuenta__opciones [role="option"] { display: flex; flex-direction: column; gap: .1rem; padding: .45rem .55rem; border-radius: 3px; cursor: pointer; }
.buscador-cuenta__opciones [role="option"] span { color: var(--text-muted); font-size: .78rem; }
.buscador-cuenta__opciones [role="option"].activa { background: var(--primary-light, #e8f0fe); }
.buscador-cuenta__opciones [role="option"].es-exacta strong { color: var(--primary); }
.buscador-cuenta__mas { padding: .45rem .55rem; color: var(--text-muted); font-size: .78rem; border-top: 1px solid var(--border); }
.table-container:has(.buscador-cuenta) { overflow: visible; }
.celda-borrar { text-align: center; white-space: nowrap; }
.borrar-check { cursor: pointer; color: var(--text-muted); display: inline-flex; align-items: center; gap: .25rem; }
.borrar-check:hover { color: var(--danger); }
.borrar-check input { margin: 0; }
.btn-icono {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: .3rem; border-radius: 4px;
  transition: all .15s;
}
.btn-icono:hover { color: var(--danger); background: var(--danger-light); }

/* ─── Panel de totales ──────────────────────────────────────────── */
.panel-totales .card-body { padding-top: 1rem; }
.totales-linea {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .35rem 0; font-size: .875rem; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}
.totales-linea:last-of-type { border-bottom: none; }
.totales-final {
  margin-top: .4rem; padding-top: .6rem;
  border-top: 2px solid var(--border-color) !important;
  border-bottom: none;
  font-size: 1.05rem; font-weight: 700; color: var(--text-primary);
}
.importe-destacado { font-size: 1.15rem; font-weight: 700; }

/* ─── Letra del comprobante ─────────────────────────────────────── */
.letra-comprobante {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border: 1px solid var(--text-secondary);
  border-radius: 3px; font-size: .72rem; font-weight: 700;
  color: var(--text-primary); vertical-align: middle;
}
.letra-comprobante.letra-grande { width: 30px; height: 30px; font-size: 1rem; }

/* ─── Estados adicionales ───────────────────────────────────────── */
.badge-emitido { background: var(--success-light); color: #15803d; }
.badge-tipo-cliente { background: #dbeafe; color: #1e40af; }
.badge-tipo-proveedor { background: #fce7f3; color: #9d174d; }
.badge-tipo-transportista { background: #ffedd5; color: #9a3412; }
.badge-tipo-banco { background: #e0e7ff; color: #3730a3; }
.badge-tipo-empleado { background: #ecfccb; color: #3f6212; }
.badge-tipo-socio { background: #ede9fe; color: #5b21b6; }
.badge-tipo-otro { background: var(--bg-subtle); color: var(--text-secondary); }
.row-inactivo td { opacity: .55; }
.fila-conciliada td { background: var(--success-light); }
.text-xs { font-size: .74rem; }

/* ─── Libro IVA ─────────────────────────────────────────────────── */
.tabla-libro { font-size: .78rem; white-space: nowrap; }
.tabla-libro th, .tabla-libro td { padding: .35rem .5rem; }
.col-grupo { border-left: 1px solid var(--border-color); border-right: 1px solid var(--border-color); }

/* ─── Posición de IVA ───────────────────────────────────────────── */
.posicion-grid {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: .75rem 1rem;
}
.posicion-item { display: flex; flex-direction: column; gap: .2rem; min-width: 150px; }
.posicion-valor { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 700; }
.posicion-op { font-size: 1.35rem; color: var(--text-muted); font-weight: 300; }
.posicion-resultado {
  background: var(--bg-subtle); border-radius: 6px;
  padding: .5rem .875rem; border: 1px solid var(--border-color);
}

/* ─── Configuración ─────────────────────────────────────────────── */
.estado-arca {
  display: flex; flex-direction: column; gap: .35rem;
  padding-top: .5rem; border-top: 1px solid var(--border-light); margin-top: .5rem;
}
.qr-link { display: inline-block; margin-top: .35rem; }

/* ─── Impresión de listados ─────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print, .page-actions, .filter-bar { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: minmax(0, 1fr); }
  .posicion-op { display: none; }
  .posicion-grid { flex-direction: column; align-items: stretch; }
}

/* ─── Estados contables ─────────────────────────────── */
/* Activo a la izquierda, Pasivo + PN a la derecha: es la disposición con la
   que se lee un estado de situación patrimonial. En pantalla angosta se
   apilan, que sigue siendo legible. */
.estados-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 2rem;
  align-items: start;
}
@media (max-width: 900px) {
  .estados-grid { grid-template-columns: 1fr; gap: 1.5rem; }
}

/* La verificación de la ecuación contable. Que cierre no es un detalle
   decorativo: es la prueba de que los estados se pueden presentar. */
.ecuacion {
  margin: 1rem 1.5rem 1.25rem;
  padding: .7rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  display: flex;
  align-items: baseline;
  gap: .55rem;
}
.ecuacion i { flex-shrink: 0; }
.ecuacion-ok {
  background: rgba(22,163,74,.08);
  border: 1px solid rgba(22,163,74,.25);
  color: var(--success);
}
.ecuacion-mal {
  background: rgba(220,38,38,.08);
  border: 1px solid rgba(220,38,38,.3);
  color: var(--danger);
}

/* El panel de cada área repite la paleta de su tarjeta del hub: fondo suave,
   franja superior y el ícono en el color pleno. El texto queda oscuro sobre el
   fondo suave para no perder contraste (el trigo sobre crema no lo aguanta). */
.area-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.35rem;
  background: var(--area-suave);
  border: 1px solid color-mix(in srgb, var(--area) 44%, white);
  border-top: 7px solid var(--area);
  border-radius: 14px;
}
.area-banner .area-card-icon { background: var(--area); flex-shrink: 0; }
.area-banner-title { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; color: #1c1917; }
.area-banner-sub { margin-top: .25rem; color: #44403c; font-size: .86rem; }
.hub-page .hub-stats .stat-card {
  background: color-mix(in srgb, var(--area-suave) 55%, white);
  border-color: color-mix(in srgb, var(--area) 30%, white);
  border-top: 4px solid var(--area);
}
.hub-page .hub-stat-link:hover { border-color: var(--area); box-shadow: var(--shadow-md); }
.hub-page .section-title { display: flex; align-items: center; gap: .5rem; }
.hub-page .section-title::before {
  content: '';
  width: 4px;
  height: 1em;
  border-radius: 2px;
  background: var(--area);
}
.hub-page .area-quick-link {
  background: color-mix(in srgb, var(--area-suave) 45%, white);
  border-color: color-mix(in srgb, var(--area) 30%, white);
}
.hub-page .area-quick-link i { color: #fff; background: var(--area); }
.hub-page .area-quick-link:hover { color: var(--text-primary); background: var(--area-suave); border-color: var(--area); }
@media (max-width: 767px) {
  .area-banner { padding: 1rem; }
  .area-banner .area-card-icon { width: 48px; height: 48px; font-size: 1.25rem; }
}

/* Guía de certificados de ARCA. */
.guia { max-width: 980px; }
.guia-texto p, .guia-texto li { line-height: 1.6; font-size: .9rem; }
.guia-texto ol, .guia-texto ul { padding-left: 1.3rem; display: grid; gap: .45rem; margin: .5rem 0; }
.guia-codigo { margin: .75rem 0; padding: .9rem 1rem; overflow-x: auto; background: #1c1917; color: #f5f5f4; border-radius: var(--radius-md); font-size: .8rem; line-height: 1.55; }
.guia-estado { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: .9rem; }
.guia-estado > div { display: flex; flex-direction: column; gap: .25rem; }
.guia-servicio-estado { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 0; border-top: 1px solid var(--border-light); font-size: .88rem; }
.guia-servicio-estado i { width: 18px; margin-right: .4rem; color: var(--text-muted); }
.guia-botones-prueba { display: flex; flex-wrap: wrap; gap: .5rem; }
@media print {
  .sidebar, .topbar, .page-actions, .back-link { display: none !important; }
  .main-wrapper { margin: 0 !important; }
  .guia .card { break-inside: avoid; }
}

/* Encabezado con acción a la derecha (p. ej. «Liquidar» en Pendientes de liquidar). */
.d-flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.radio-tarjeta { display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem; margin-bottom: .5rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); cursor: pointer; }
.radio-tarjeta:has(input:checked) { border-color: var(--area, var(--accent)); background: var(--area-suave, var(--accent-light)); }
