﻿:root {
  --bg: #050914;
  --card: #0f172a;
  --surface: #0d1324;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #22d3ee;
  --accent-2: #a855f7;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
  --font: "Poppins", "Trebuchet MS", "Segoe UI", sans-serif;
  --base-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--base-size);
  background: radial-gradient(circle at 10% 20%, rgba(34, 211, 238, 0.15), transparent 25%),
              radial-gradient(circle at 90% 10%, rgba(168, 85, 247, 0.12), transparent 25%),
              radial-gradient(circle at 30% 80%, rgba(16, 185, 129, 0.12), transparent 30%),
              var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body.theme-light {
  --bg: #e9edf5;
  --card: #f5f7fb;
  --surface: #eef2f7;
  --border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #475569;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
  background: radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.18), transparent 28%),
              radial-gradient(circle at 80% 10%, rgba(168, 85, 247, 0.14), transparent 28%),
              var(--bg);
}
body.font-compact { --base-size: 15px; }
body.font-mini { --base-size: 14px; }

#app { min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.micro { font-size: 0.9rem; margin: 0; }
.tiny { font-size: 0.8rem; margin: 0; }
.success { color: var(--success); }
.warning { color: var(--warning); }
.brand { font-weight: 700; margin: 0; letter-spacing: 0.4px; }
.brand-mark { font-size: 2rem; font-weight: 800; letter-spacing: 0.6px; }
.eyebrow { color: var(--muted); margin: 6px 0 14px; }

.auth-panel { display: grid; place-items: center; padding: 40px 16px; }
.auth-card {
  width: min(420px, 100%);
  padding: 32px;
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.92), rgba(17, 24, 39, 0.75));
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
body.theme-light .auth-card { background: linear-gradient(145deg, #fdfefe, #eef3f9); }
.login-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.login-logo {
  width: 88px;
  height: auto;
}
.login-title {
  font-size: 1.55rem;
  text-align: center;
}

.layout { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; transition: grid-template-columns 0.25s ease; }
.layout.sidebar-collapsed { grid-template-columns: 88px 1fr; }

.sidebar {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(10, 14, 26, 0.95));
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease, left 0.25s ease, padding 0.25s ease;
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.25);
  width: 280px;
}
body.theme-light .sidebar { background: linear-gradient(180deg, #f8fafc, #e6ebf4); box-shadow: 8px 0 30px rgba(15, 23, 42, 0.08); }
.sidebar.collapsed { width: 88px; padding: 20px 10px; }

.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.icon-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
body.theme-light .icon-btn { background: rgba(0, 0, 0, 0.04); }

.menu-list {
  margin: 24px 0;
  display: grid;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
}
.menu-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-size: calc(var(--base-size) - 2px);
}
.menu-item:hover { background: rgba(255, 255, 255, 0.04); border-color: var(--border); }
.menu-item.active { background: linear-gradient(90deg, rgba(34, 211, 238, 0.18), rgba(168, 85, 247, 0.18)); border-color: rgba(255, 255, 255, 0.2); }
.menu-icon { font-size: 1.1rem; display: inline-flex; align-items: center; justify-content: center; }
.menu-icon i { font-size: 1rem; }
.menu-label { font-weight: 600; font-size: 1em; }
.menu-sub { color: var(--muted); font-size: calc(var(--base-size) - 4px); }
.menu-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.menu-caret { font-size: 0.8rem; color: var(--muted); transition: transform 0.2s ease; }
.menu-group { display: grid; gap: 6px; }
.menu-group .submenu { display: none; margin-left: 20px; border-left: 1px dashed var(--border); padding-left: 10px; }
.menu-group.open .submenu { display: grid; gap: 6px; }
.menu-group.open .menu-caret { transform: rotate(180deg); }
.submenu .menu-item { padding: 10px 12px; font-size: 0.9rem; }

.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-sub,
.sidebar.collapsed .sidebar-header div,
.sidebar.collapsed .user-mini div { display: none; }
.sidebar.collapsed .menu-item { grid-template-columns: 1fr; justify-items: center; }
.sidebar.collapsed .menu-icon { font-size: 1.2rem; }
.sidebar.collapsed .user-mini { justify-content: center; }
.sidebar.collapsed .submenu { display: none !important; }
.sidebar.collapsed .menu-caret { display: none; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 14px; margin-top: auto; }
.user-mini { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.avatar { border-radius: 50%; object-fit: cover; }
.avatar.xs { width: 36px; height: 36px; }
.avatar.sm { width: 54px; height: 54px; }
.avatar.lg { width: 96px; height: 96px; }
.avatar-click { cursor: pointer; border: 1px dashed transparent; }
.avatar-click:hover { border-color: var(--border); }

.content { padding: 26px; transition: padding 0.2s ease; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.top-actions { display: flex; gap: 6px; align-items: center; padding-top: 2px; }

.btn {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn.primary { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #0b1020; box-shadow: 0 12px 30px rgba(34, 211, 238, 0.25); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: var(--border); background: transparent; }
.btn.secondary { background: rgba(251, 146, 60, 0.2); border-color: rgba(251, 146, 60, 0.45); color: #fb923c; }
.btn.warn-lite { background: rgba(250, 204, 21, 0.2); border-color: rgba(250, 204, 21, 0.35); color: #fbbf24; }
.btn.danger-lite { background: rgba(248, 113, 113, 0.2); border-color: rgba(248, 113, 113, 0.35); color: #f87171; }
.btn.info-lite { background: rgba(96, 165, 250, 0.2); border-color: rgba(96, 165, 250, 0.35); color: #60a5fa; }
.btn.wide { grid-column: 1/-1; }

.panel-section { animation: fade 0.22s ease; }
.panel {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(12, 18, 31, 0.92));
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
body.theme-light .panel { background: linear-gradient(145deg, #fdfefe, #eef2f7); }
.panel.soft { background: rgba(255, 255, 255, 0.02); box-shadow: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 1.15rem; }
.topbar h1 { margin: 0; font-size: 1.25rem; }
.panel-head.compact { margin-bottom: 8px; }

.grid.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { padding: 16px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: 14px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); }
body.theme-light .tile { background: rgba(0, 0, 0, 0.02); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4); }

.activity { display: grid; gap: 10px; }
.activity-row { display: grid; grid-template-columns: 14px 1fr; gap: 10px; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.success { background: var(--success); }
.dot.accent { background: var(--accent); }
.dot.warning { background: var(--warning); }

.form-grid { display: grid; gap: 14px; }
.form-grid.two-col { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
label { display: grid; gap: 6px; color: var(--text); font-weight: 600; }
input, textarea, select {
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
}
select[multiple] { min-height: 120px; }
.checkbox-inline { align-items: center; display: flex; gap: 8px; }
.checkbox-inline input { accent-color: var(--accent); }

.report-title {
  margin-top: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.report-legend {
  display: grid;
  gap: 6px;
  max-width: 280px;
  margin: 10px 0 8px;
}
.legend-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.legend-color {
  width: 22px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.legend-color.orient { background: rgba(251, 146, 60, 0.35); }
.legend-color.norte { background: rgba(96, 165, 250, 0.35); }
.legend-color.garant { background: rgba(34, 197, 94, 0.3); }

.report-total-ingreso {
  margin-top: 10px;
  font-weight: 700;
  padding: 8px 10px;
  background: rgba(34, 211, 238, 0.18);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 10px;
  width: fit-content;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.report-summary-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 8px;
}
.report-summary-box .summary-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.report-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.report-row-oriente td { background: rgba(251, 146, 60, 0.12); }
.report-row-norte td { background: rgba(96, 165, 250, 0.12); }
.report-row-garant td { background: rgba(34, 197, 94, 0.12); }
.report-row-total td {
  font-weight: 700;
  background: rgba(34, 211, 238, 0.18);
}
textarea { resize: vertical; }
.form-error { color: var(--danger); font-size: 0.9rem; min-height: 1.2rem; }
.avatar-preview { display: flex; align-items: center; gap: 12px; }
.option-row { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); padding: 8px 10px; border-radius: 12px; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.permissions-grid { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 16px; }
.permissions-list { display: grid; gap: 10px; max-height: 420px; overflow: auto; padding-right: 6px; }
.permission-item { display: flex; align-items: center; gap: 10px; border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.permission-sub { margin-left: 24px; }
.menu-config-input { width: 100%; }
.sublinea-input { width: 100%; }
.toggle { accent-color: var(--accent); }
.filters-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filters-row label { min-width: 200px; }
.novedad-form { margin-bottom: 14px; }
.edad-form { margin-bottom: 14px; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.cartera-table {
  overflow-x: auto;
}
.cartera-table table {
  min-width: 900px;
  font-size: 0.85rem;
}
.cartera-table th,
.cartera-table td {
  padding: 6px 8px;
}
.cartera-table th {
  font-size: 0.7rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.cartera-input {
  width: 76px;
  padding: 6px 6px;
}
.cartera-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.btn.icon {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.btn.icon i {
  font-size: 0.85rem;
}
.btn.danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}
.liq-header {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.liq-header-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.liq-period {
  text-align: right;
}
.liq-header-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.liq-header-grid span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.liq-header-grid strong {
  font-size: 0.95rem;
}
.liq-panel { margin-top: 16px; }
.liq-summary {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  display: grid;
  gap: 6px;
}
.liq-summary-table {
  width: 70%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.liq-summary-table td {
  padding: 6px 0;
  border: none;
}
.liq-summary-table td.val {
  text-align: right;
}
.liq-summary-table tr.total td {
  font-weight: 700;
  color: var(--accent);
}
.liq-summary-row.total {
  font-size: 1rem;
  color: var(--accent);
}
.liq-category-row td {
  background: rgba(34, 211, 238, 0.12);
  font-weight: 700;
  color: var(--text);
}
.liq-subtotal-row td {
  background: rgba(148, 163, 184, 0.12);
  font-weight: 700;
}
.liq-cobertura-row td {
  background: rgba(148, 163, 184, 0.08);
  font-weight: 700;
}
.liq-resumen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.liq-resumen-grid.two {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.liq-resumen-card {
  border: 1px solid rgba(30, 58, 95, 0.6);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 6px;
  font-weight: 700;
  overflow: hidden;
}
.liq-resumen-card span {
  color: #fff;
  background: linear-gradient(180deg, #1e3a5f, #163154);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 10px;
}
.liq-resumen-card strong {
  font-size: 1.15rem;
  padding: 6px 12px 12px;
}
.liq-resumen-card.total {
  background: linear-gradient(120deg, rgba(72, 124, 182, 0.18), rgba(30, 58, 95, 0.15));
  border-color: rgba(30, 58, 95, 0.8);
}
.liq-sublinea-row td:first-child {
  color: var(--muted);
}
.liq-table-ventas th,
.liq-table-ventas td {
  padding: 8px 6px;
  font-size: 0.85rem;
}
.liq-table-ventas th {
  font-size: 0.75rem;
  letter-spacing: 0.4px;
}

.table-container { margin-top: 14px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 8px; text-align: left; }
th { background: rgba(255, 255, 255, 0.04); color: var(--muted); font-weight: 700; font-size: 0.8rem; }
td { border-top: 1px solid var(--border); }
.sync-fieldset {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin: 0;
}
.sync-fieldset legend {
  padding: 0 8px;
  font-weight: 700;
  color: var(--text);
}
.sync-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}
.sync-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.user-inline { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.drawer-user { margin-bottom: 12px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 20;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1080px, 96vw);
  max-height: 80vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  z-index: 40;
  font-size: 0.9rem;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 9, 20, 0.45);
  backdrop-filter: blur(2px);
  z-index: 100;
}
body.theme-light .loading-overlay {
  background: rgba(233, 237, 245, 0.7);
}
.loading-card {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 20px 24px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
body.theme-light .loading-card {
  background: #f5f7fb;
}
.loading-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  animation: pulse 1.2s ease-in-out infinite;
}
.loading-text {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100%);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
  padding: 22px;
  z-index: 30;
  overflow-y: auto;
  transform: translateX(0);
  animation: slideIn 0.25s ease;
}
body.theme-light .drawer { box-shadow: -12px 0 40px rgba(15, 23, 42, 0.1); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.drawer-tabs { display: grid; grid-auto-flow: column; gap: 8px; margin-bottom: 12px; }
.tab { border: 1px solid var(--border); background: rgba(255, 255, 255, 0.04); color: var(--text); padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.tab.active { border-color: var(--accent); color: var(--accent); }
.drawer-pane { animation: fade 0.2s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(34, 211, 238, 0.2)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.35)); }
}

/* Responsive */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 240px 1fr; }
  .layout.sidebar-collapsed { grid-template-columns: 78px 1fr; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -320px; top: 0; width: 260px; z-index: 10; height: 100vh; }
  .sidebar.open { left: 0; }
  .content { padding: 80px 18px 32px; }
  .topbar { position: sticky; top: 0; backdrop-filter: blur(6px); background: rgba(11, 18, 32, 0.9); padding: 12px 0; z-index: 5; border-bottom: 1px solid var(--border); }
  .permissions-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .top-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .btn { width: 100%; text-align: center; }
  .btn.ghost { width: auto; }
  .menu-item { grid-template-columns: 1fr; }
}
