/* ==========================================================================
   ContaCloud - Design System oficial basado en modelo.html
   Paleta: Navy (#173B78), Blue (#168FE0), Sky (#38B9F2), Pale (#EAF7FF),
   Ink (#16304F), Gray (#64748B), Border (#D9E8F3), Bg (#F5F9FC)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Variables Oficiales modelo.html */
  --navy: #173B78;
  --blue: #168FE0;
  --sky: #38B9F2;
  --pale: #EAF7FF;
  --ink: #16304F;
  --gray: #64748B;
  --border: #D9E8F3;
  --bg: #F5F9FC;
  --white: #ffffff;
  --ok: #16A36A;
  --warn: #E9A23B;
  --danger: #D94C5C;
  --side: 260px;

  /* Aliases para compatibilidad con módulos existentes */
  --primary: var(--blue);
  --primary-hover: #1178bd;
  --primary-subtle: var(--pale);
  --primary-text: var(--navy);

  --secondary: #64748B;
  --secondary-hover: #475569;
  --secondary-subtle: #f1f5f9;

  --success: var(--ok);
  --success-subtle: #e8f8f1;
  --warning: var(--warn);
  --warning-subtle: #fff5e1;
  --danger-subtle: #fdecef;
  --info: var(--sky);
  --info-subtle: var(--pale);

  --bg-body: var(--bg);
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-muted: #f8fbfd;
  --border-color: var(--border);
  --border-subtle: #edf3f7;
  --text-heading: var(--ink);
  --text-body: var(--ink);
  --text-muted: var(--gray);
  --text-dim: #94a3b8;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-full: 99px;

  --shadow-sm: 0 2px 7px rgba(23, 59, 120, 0.08);
  --shadow-md: 0 8px 30px rgba(23, 59, 120, 0.05);
  --shadow-lg: 0 16px 40px rgba(23, 59, 120, 0.12);
}

/* Base & Reset */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

/* Contenedor Principal de la App */
.app, .app-container {
  min-height: 100vh;
  display: flex;
}

/* Sidebar Fijo */
.side, .sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--side);
  background: #ffffff;
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  height: 74px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), var(--sky));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(22, 143, 224, 0.3);
  flex-shrink: 0;
}

.brand span {
  color: var(--blue);
}

.roles {
  display: flex;
  margin: 14px;
  background: var(--pale);
  padding: 4px;
  border-radius: 9px;
  flex-shrink: 0;
}

.roles button, .roles a {
  flex: 1;
  border: 0;
  background: none;
  padding: 8px;
  font-size: 10px;
  font-weight: 800;
  border-radius: 7px;
  color: var(--gray);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.15s ease;
}

.roles .on, .roles button.on, .roles a.on {
  background: #ffffff;
  color: var(--navy);
  box-shadow: 0 2px 7px rgba(23, 59, 120, 0.08);
}

.nav, .sidebar-nav {
  padding: 0 12px 20px 12px;
  overflow-y: auto;
  flex: 1;
}

.label, .menu-title {
  font-size: 9px;
  color: #94a3b8;
  font-weight: 800;
  letter-spacing: 0.7px;
  margin: 15px 10px 6px;
  text-transform: uppercase;
}

.nav button, .nav a, .nav .nav-link {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  padding: 10px 12px;
  border-radius: 9px;
  color: #53677e;
  font-size: 12px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  margin-bottom: 2px;
}

.nav button:hover, .nav a:hover, .nav .nav-link:hover,
.nav button.active, .nav a.active, .nav .nav-link.active {
  background: var(--pale);
  color: var(--blue);
}

.nav button.active, .nav a.active, .nav .nav-link.active {
  box-shadow: inset 3px 0 var(--blue);
  font-weight: 750;
}

/* Área Principal */
.main, .main-wrapper {
  margin-left: var(--side);
  width: calc(100% - var(--side));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Topbar Sticky */
.top, .topbar {
  height: 74px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top h1, .page-title h2 {
  font-size: 19px;
  margin: 0;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.2px;
}

.crumb, .page-title p {
  font-size: 11px;
  color: var(--gray);
  margin-top: 2px;
}

.actions, .topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Inputs, Selects & Buscador */
.search, .input, .select, .form-control, .form-select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #ffffff;
  padding: 0 12px;
  outline: none;
  font-size: 12px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search {
  width: 230px;
}

.search:focus, .input:focus, .select:focus, .form-control:focus, .form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(22, 143, 224, 0.15);
}

/* Botones */
.btn {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--navy);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn:hover {
  background: var(--pale);
  border-color: var(--blue);
  color: var(--blue);
}

.btn.primary, .btn-primary {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.btn.primary:hover, .btn-primary:hover {
  background: #1178bd;
  border-color: #1178bd;
  color: #ffffff;
}

.btn.secondary, .btn-secondary {
  background: #ffffff;
  color: var(--navy);
  border-color: var(--border);
}

.btn.secondary:hover, .btn-secondary:hover {
  background: var(--pale);
  border-color: var(--blue);
  color: var(--blue);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 10px;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: #bd3948;
  border-color: #bd3948;
  color: #ffffff;
}

/* Contenido Principal */
.content, .page-content {
  padding: 25px;
  max-width: 1550px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

/* Hero Banner Oficial */
.hero {
  background: linear-gradient(135deg, var(--navy), #205c9f);
  border-radius: 16px;
  padding: 24px;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(23, 59, 120, 0.12);
}

.hero:after {
  content: "";
  position: absolute;
  right: -80px;
  top: -100px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(56, 185, 242, 0.2);
  pointer-events: none;
}

.hero h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
}

.hero p {
  margin: 0;
  color: #dceeff;
  font-size: 12px;
}

.hero .buttons {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 1;
}

/* Grillas */
.grid {
  display: grid;
  gap: 15px;
}
.g4, .stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}
.g3 {
  grid-template-columns: repeat(3, 1fr);
}
.g2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Tarjetas */
.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(23, 59, 120, 0.04);
  margin-bottom: 20px;
  overflow: hidden;
}

.pad, .card-body {
  padding: 17px;
}

.card-header {
  padding: 14px 17px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
}

.card-title, .head h2 {
  font-size: 15px;
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

.head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 13px;
}

.head p {
  font-size: 10px;
  color: var(--gray);
  margin: 3px 0 0;
}

/* KPIs Oficiales */
.kpi, .stat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(23, 59, 120, 0.04);
  padding: 16px;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi label, .stat-label {
  font-size: 11px;
  color: var(--gray);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.kpi b, .stat-value {
  display: block;
  font-size: 25px;
  margin: 4px 0 4px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.trend, .stat-sub {
  font-size: 10px;
  color: var(--ok);
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.trend.down, .stat-sub.negative {
  color: var(--danger);
}

.stat-icon-wrapper {
  display: none;
}

/* Tablas Oficiales */
.tablewrap {
  overflow-x: auto;
  border-radius: 14px;
  width: 100%;
}

.table, .table-modern {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.table th, .table-modern th {
  text-align: left;
  background: #f8fbfd;
  color: #718096;
  font-size: 9px;
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.table td, .table-modern td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf3f7;
  color: var(--ink);
  font-size: 11px;
  vertical-align: middle;
}

.table tbody tr:hover, .table-modern tbody tr:hover {
  background: #fbfdff;
}

.numeric {
  text-align: right !important;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Status & Badges Oficiales */
.status, .badge {
  padding: 4px 8px;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.3px;
  line-height: 1;
}

.ok, .badge-success, .badge-soft-success {
  background: #e8f8f1;
  color: #128457;
}

.warning, .badge-warning, .badge-soft-warning {
  background: #fff5e1;
  color: #9a6816;
}

.bad, .badge-danger, .badge-soft-danger {
  background: #fdecef;
  color: #b73548;
}

.info, .badge-primary, .badge-info, .badge-soft-primary {
  background: var(--pale);
  color: var(--blue);
}

.badge-locked {
  background: #fff5e1;
  color: #9a6816;
  border: 1px solid #f6d89e;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 99px;
  margin-left: auto;
}

/* Alertas */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}

.alert-success {
  background: #e8f8f1;
  color: #128457;
  border-color: #c2eed9;
}

.alert-danger {
  background: #fdecef;
  color: #b73548;
  border-color: #f7cbd1;
}

.alert-warning {
  background: #fff5e1;
  color: #9a6816;
  border-color: #fee4b4;
}

.alert-info {
  background: var(--pale);
  color: var(--blue);
  border-color: #c9e9fc;
}

/* Gráficos y Barras de Actividad */
.chart {
  height: 220px;
  padding: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.bar {
  flex: 1;
  background: linear-gradient(var(--sky), var(--blue));
  border-radius: 7px 7px 2px 2px;
  min-width: 18px;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.report {
  padding: 0;
}

.report .table td:nth-child(n+2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.section {
  margin-top: 16px;
}

/* Modales */
.modal, .modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 33, 57, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal.show, .modal.open, .modal-overlay.show, .modal-overlay.open {
  display: flex;
}

.modalbox, .modal-dialog, .modal-container {
  background: #ffffff;
  border-radius: 16px;
  width: min(700px, 100%);
  padding: 22px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(23, 59, 120, 0.15);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2, .modal-header h3 {
  font-size: 16px;
  margin: 0;
  font-weight: 700;
  color: var(--navy);
}

.modal-close {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--pale);
  color: var(--blue);
}

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

.form-group, .field {
  margin-bottom: 12px;
}

.field label, .form-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: #52677f;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.field .input, .field .select, .form-group .form-control, .form-group .form-select {
  width: 100%;
}

.full {
  grid-column: 1 / -1;
}

.modalfoot, .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 0 17px;
  background: #ffffff;
}

.tab-btn {
  background: none;
  border: 0;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--blue);
}

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.mobile {
  display: none;
}

/* Responsive Breakpoints */
@media (max-width: 1050px) {
  .g4, .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .search {
    width: 160px;
  }
}

@media (max-width: 760px) {
  .side, .sidebar {
    transform: translateX(-100%);
  }
  .side.open, .sidebar.open, .side.show, .sidebar.show {
    transform: none;
    width: var(--side);
  }
  .main, .main-wrapper {
    margin-left: 0;
    width: 100%;
  }
  .mobile {
    display: inline-flex;
  }
  .top, .topbar {
    padding: 0 14px;
  }
  .search {
    display: none;
  }
  .content, .page-content {
    padding: 15px;
  }
  .g4, .g3, .g2, .stats-grid {
    grid-template-columns: 1fr;
  }
  .form {
    grid-template-columns: 1fr;
  }
  .full {
    grid-column: auto;
  }
}

/* Estilos de Impresión Limpia Contable */
@media print {
  @page {
    size: auto;
    margin: 8mm 8mm 8mm 8mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 8pt !important;
  }

  .side, .sidebar, .top, .topbar, .actions, .btn, .no-print, .filters {
    display: none !important;
  }

  .main, .main-wrapper {
    margin: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
  }

  .content, .page-content {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .card {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .tablewrap {
    overflow: visible !important;
  }

  .table, .table-modern {
    width: 100% !important;
    font-size: 8pt !important;
  }

  .table th, .table-modern th {
    background: #f1f5f9 !important;
    color: #000000 !important;
    border: 1px solid #94a3b8 !important;
    padding: 4px 6px !important;
  }

  .table td, .table-modern td {
    border: 1px solid #cbd5e1 !important;
    padding: 4px 6px !important;
    color: #000000 !important;
  }

  .numeric {
    text-align: right !important;
    font-family: var(--font-mono) !important;
  }
}
