/* ===================================================
   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);
  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; flex: 1; }
.nav-group-label {
  padding: .875rem 1rem .2rem;
  font-size: .58rem; text-transform: uppercase;
  letter-spacing: .1em; color: rgba(255,255,255,.22);
  font-weight: 600; margin-top: .25rem;
}
.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 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; }
.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(220px, 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;
}
.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: 1.75rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--text-primary); }
.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); }

/* ─── 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); }
.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(2, 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; }
