/* ============================================================
   Patrimonio — Design System
   Tema: Dark Wealth Management / Family Office
   ============================================================ */


:root {
  --bg-0:       #0C0E11;   /* fondo base app */
  --bg-1:       #131619;   /* cards, sidebar */
  --bg-2:       #1A1E24;   /* cards elevadas */
  --bg-3:       #212730;   /* hover states */

  --border:     #2A3140;
  --border-2:   #363F50;

  --text-1:     #F0F2F5;   /* títulos */
  --text-2:     #9BA3B0;   /* secundario */
  --text-3:     #5C6472;   /* terciario / disabled */

  --blue:       #3B7FE8;
  --blue-light: #5C9AEF;
  --blue-dim:   #1E3A5F;

  --green:      #22C55E;
  --green-dim:  #14532D;
  --red:        #EF4444;
  --red-dim:    #450A0A;
  --amber:      #F59E0B;
  --amber-dim:  #451A03;

  --purple:     #8B5CF6;
  --teal:       #14B8A6;

  --radius:     10px;
  --radius-lg:  16px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.5);
  --shadow:     0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.6);

  --font-sans:  'DM Sans', system-ui, sans-serif;
  --font-serif: 'DM Serif Display', Georgia, serif;

  --sidebar-w:  240px;
  --sidebar-collapsed-w: 72px;
  --header-h:   60px;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--blue-light); text-decoration: none; }
a:hover { color: var(--text-1); }
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width .22s ease, transform .3s ease, box-shadow .22s ease;
  overflow: visible;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.brand-icon {
  color: var(--blue);
  font-size: 18px;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--text-1);
  letter-spacing: 0.3px;
}
.sidebar-collapse-toggle {
  position: absolute;
  top: 17px;
  right: 10px;
  z-index: 2;
  width: 28px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 20px;
  line-height: 1;
  transition: background .15s, color .15s, right .22s, top .22s;
}
.sidebar-collapse-toggle:hover { background: var(--bg-3); color: var(--text-1); }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.nav-section {
  padding: 0 12px;
  margin-bottom: 4px;
}
.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-3);
  padding: 10px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.nav-item.active {
  background: var(--blue-dim);
  color: var(--blue-light);
}
.nav-item .nav-icon { font-size: 16px; opacity: .8; }
.nav-item .nav-icon { flex: 0 0 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--blue);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--bg-2);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--blue-dim);
  border: 2px solid var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: var(--blue-light);
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: 12.5px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-3); }
.btn-logout {
  background: none; border: none; padding: 4px; color: var(--text-3);
  font-size: 14px; cursor: pointer; transition: color .15s;
}
.btn-logout:hover { color: var(--red); }

/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
html.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-w); }
html.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed-w); }
html.sidebar-collapsed .sidebar:hover,
html.sidebar-collapsed .sidebar:focus-within {
  width: var(--sidebar-w);
  box-shadow: 10px 0 28px rgba(0,0,0,.45);
}
html.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding-left: 12px;
  padding-right: 12px;
}
html.sidebar-collapsed .brand-name,
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .nav-text,
html.sidebar-collapsed .nav-badge,
html.sidebar-collapsed .user-info,
html.sidebar-collapsed .user-pill .btn-logout { display: none; }
html.sidebar-collapsed .sidebar-collapse-toggle {
  top: 75px;
  right: 22px;
  background: transparent;
}
html.sidebar-collapsed .sidebar-nav { overflow-x: hidden; }
html.sidebar-collapsed .nav-section { padding-left: 10px; padding-right: 10px; }
html.sidebar-collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
html.sidebar-collapsed .sidebar-footer { padding-left: 10px; padding-right: 10px; }
html.sidebar-collapsed .user-pill { justify-content: center; padding-left: 0; padding-right: 0; background: transparent; }
html.sidebar-collapsed .sidebar:hover .sidebar-brand,
html.sidebar-collapsed .sidebar:focus-within .sidebar-brand { justify-content: flex-start; padding-left: 20px; padding-right: 50px; }
html.sidebar-collapsed .sidebar:hover .brand-name,
html.sidebar-collapsed .sidebar:focus-within .brand-name,
html.sidebar-collapsed .sidebar:hover .nav-label,
html.sidebar-collapsed .sidebar:focus-within .nav-label,
html.sidebar-collapsed .sidebar:hover .nav-text,
html.sidebar-collapsed .sidebar:focus-within .nav-text,
html.sidebar-collapsed .sidebar:hover .nav-badge,
html.sidebar-collapsed .sidebar:focus-within .nav-badge,
html.sidebar-collapsed .sidebar:hover .user-info,
html.sidebar-collapsed .sidebar:focus-within .user-info,
html.sidebar-collapsed .sidebar:hover .user-pill .btn-logout,
html.sidebar-collapsed .sidebar:focus-within .user-pill .btn-logout { display: initial; }
html.sidebar-collapsed .sidebar:hover .nav-section,
html.sidebar-collapsed .sidebar:focus-within .nav-section { padding-left: 12px; padding-right: 12px; }
html.sidebar-collapsed .sidebar:hover .nav-item,
html.sidebar-collapsed .sidebar:focus-within .nav-item { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }
html.sidebar-collapsed .sidebar:hover .sidebar-footer,
html.sidebar-collapsed .sidebar:focus-within .sidebar-footer { padding-left: 12px; padding-right: 12px; }
html.sidebar-collapsed .sidebar:hover .user-pill,
html.sidebar-collapsed .sidebar:focus-within .user-pill { justify-content: flex-start; padding-left: 8px; padding-right: 10px; background: var(--bg-2); }
html.sidebar-collapsed .sidebar:hover .sidebar-collapse-toggle,
html.sidebar-collapsed .sidebar:focus-within .sidebar-collapse-toggle { top: 17px; right: 10px; background: var(--bg-2); }
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
  position: sticky; top: 0; z-index: 50;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--text-1);
  flex: 1;
}
.page-subtitle { font-size: 12px; color: var(--text-3); }

.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-sm { padding: 14px 16px; }
.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
  margin-bottom: 10px;
}

/* ─── KPI Cards ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color .2s;
}
.kpi-card:hover { border-color: var(--border-2); }
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
  margin-bottom: 6px;
}
.kpi-value {
  font-size: clamp(16px, 2vw, 24px);
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
.kpi-delta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}
.kpi-delta.up   { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* ─── Grid Layout ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.col-span-2 { grid-column: span 2; }

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid-4 { grid-template-columns: 1fr; } }

/* ─── Dashboard de consultas Telegram ─────────────────────── */
.telegram-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  padding: 24px 26px; margin-bottom: 18px; border: 1px solid #27486f;
  border-radius: var(--radius-lg); overflow: hidden; position: relative;
  background: radial-gradient(circle at 88% 10%, rgba(59,127,232,.23), transparent 36%),
              linear-gradient(130deg, #111b29 0%, var(--bg-1) 55%, #132018 100%);
}
.telegram-hero::after { content: '✈'; position: absolute; right: 37%; top: -18px; font-size: 105px; opacity: .035; transform: rotate(-18deg); }
.telegram-eyebrow { color: var(--blue-light); font-size: 10px; letter-spacing: 1.35px; font-weight: 700; margin-bottom: 5px; }
.telegram-hero h2 { font-family: var(--font-serif); font-size: 28px; line-height: 1.1; margin: 0; }
.telegram-hero p { color: var(--text-2); margin: 7px 0 0; font-size: 13px; }
.telegram-hero-total { position: relative; z-index: 1; min-width: 150px; padding-left: 22px; border-left: 1px solid rgba(148,163,184,.25); }
.telegram-hero-total span, .telegram-hero-total small { display: block; color: var(--text-3); font-size: 11px; }
.telegram-hero-total strong { display: block; color: var(--text-1); font-size: 29px; line-height: 1.15; font-variant-numeric: tabular-nums; margin: 2px 0; }
.telegram-kpis { margin-bottom: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.telegram-kpi { position: relative; overflow: hidden; }
.telegram-kpi::before { content: ''; position: absolute; width: 50px; height: 50px; border-radius: 50%; right: -17px; top: -18px; opacity: .3; }
.telegram-kpi-blue::before { background: var(--blue); }.telegram-kpi-teal::before { background: var(--teal); }.telegram-kpi-purple::before { background: var(--purple); }.telegram-kpi-green::before { background: var(--green); }
.telegram-insights-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(260px, .9fr); gap: 16px; margin-bottom: 16px; }
.telegram-chart-card, .telegram-topic-card, .telegram-users-card, .telegram-log-card { padding: 18px; }
.telegram-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.telegram-card-head .card-title { margin-bottom: 3px; color: var(--text-2); }
.telegram-chart-wrap { height: 230px; position: relative; }
.telegram-live-dot { color: #70e29c; background: rgba(34,197,94,.11); border: 1px solid rgba(34,197,94,.25); border-radius: 999px; padding: 3px 8px; font-size: 10px; white-space: nowrap; }
.telegram-live-dot::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--green); margin: 0 5px 1px 0; }
.telegram-topic-list { display: grid; gap: 13px; }
.telegram-topic-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.telegram-topic-meta b { color: var(--text-3); font-weight: 600; }.telegram-topic-meta strong { color: var(--text-1); font-variant-numeric: tabular-nums; }
.telegram-topic-track { height: 6px; background: var(--bg-3); border-radius: 99px; overflow: hidden; }.telegram-topic-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--teal)); }
.telegram-users-card { margin-bottom: 16px; }
.telegram-user-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.telegram-user { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 13px 10px; border-right: 1px solid var(--border); }.telegram-user:last-child { border-right: 0; }
.telegram-user-rank { color: var(--text-3); font-size: 11px; width: 11px; }.telegram-user-avatar { width: 27px; height: 27px; flex: 0 0 27px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-dim); color: var(--blue-light); font-size: 11px; font-weight: 700; }
.telegram-user div { min-width: 0; flex: 1; }.telegram-user strong, .telegram-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.telegram-user strong { font-size: 12px; }.telegram-user small { color: var(--text-3); font-size: 10px; margin-top: 1px; }.telegram-user > b { color: var(--blue-light); font-size: 14px; font-variant-numeric: tabular-nums; }
.telegram-empty { color: var(--text-3); font-size: 13px; padding: 22px 0; text-align: center; }.telegram-log-card { margin-top: 0; }.telegram-log-head { margin-bottom: 18px; }.telegram-log-count { color: var(--text-3); border: 1px solid var(--border); border-radius: 99px; padding: 3px 9px; font-size: 11px; white-space: nowrap; }
@media (max-width: 1050px) { .telegram-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }.telegram-user-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }.telegram-user:nth-child(2n) { border-right: 0; } }
@media (max-width: 760px) { .telegram-hero { align-items: flex-start; flex-direction: column; }.telegram-hero-total { padding-left: 0; border-left: 0; }.telegram-insights-grid { grid-template-columns: 1fr; }.telegram-user-list { grid-template-columns: 1fr; }.telegram-user { border-right: 0; border-bottom: 1px solid var(--border); }.telegram-user:last-child { border-bottom: 0; } }
@media (max-width: 480px) { .telegram-kpis { grid-template-columns: 1fr; }.telegram-hero { padding: 20px; }.telegram-hero h2 { font-size: 24px; } }

/* ─── Tablas ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table-scroll {
  max-height: min(62vh, 620px);
  overflow: auto;
}
.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-1);
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-2); cursor: pointer; }
tbody td {
  padding: 11px 12px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}
.td-main { color: var(--text-1); font-weight: 500; }
.td-pos  { color: var(--green); }
.td-neg  { color: var(--red); }
.td-mono { font-variant-numeric: tabular-nums; }

/* ─── Pill / Badge ───────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.pill-blue   { background: var(--blue-dim);  color: var(--blue-light); }
.pill-green  { background: var(--green-dim); color: var(--green); }
.pill-red    { background: var(--red-dim);   color: var(--red); }
.pill-amber  { background: var(--amber-dim); color: var(--amber); }
.pill-purple { background: #2E1F5E;          color: var(--purple); }

/* ─── Botones ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all .15s;
  cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--blue);  color: #fff; border-color: var(--blue); }
.btn-primary:hover  { background: var(--blue-light); border-color: var(--blue-light); }
.btn-secondary { background: var(--bg-2); color: var(--text-1); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--bg-3); }
.btn-ghost  { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-1); }
.btn-danger { background: var(--red-dim); color: var(--red); border-color: transparent; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ─── Formularios ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  padding: 9px 12px;
  font-size: 13.5px;
  transition: border-color .15s;
  outline: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,127,232,.15);
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239BA3B0' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* ─── Alertas ────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-error  { background: var(--red-dim);   color: var(--red);   border: 1px solid #7F1D1D; }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid #14532D; }
.alert-info   { background: var(--blue-dim);  color: var(--blue-light); border: 1px solid #1E3A5F; }

/* ─── Upload Area ────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--blue);
  background: var(--blue-dim);
}
.upload-icon { font-size: 40px; margin-bottom: 12px; }
.upload-title { font-size: 16px; font-weight: 600; color: var(--text-1); margin-bottom: 6px; }
.upload-hint { font-size: 13px; color: var(--text-3); }

/* ─── Progress bar ───────────────────────────────────────────── */
.progress { background: var(--bg-3); border-radius: 20px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--blue); transition: width .4s; }
.progress-bar.green { background: var(--green); }

/* ─── Donut chart placeholder ────────────────────────────────── */
.chart-container { position: relative; }
.chart-legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-pct { margin-left: auto; font-weight: 600; color: var(--text-1); font-variant-numeric: tabular-nums; }

/* ─── Holder badge ───────────────────────────────────────────── */
.holder-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}

/* ─── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-2);
  border-radius: 10px;
  padding: 3px;
  width: fit-content;
  margin-bottom: 20px;
}
.tab {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: all .15s;
  border: none; background: none;
}
.tab.active { background: var(--bg-0); color: var(--text-1); box-shadow: var(--shadow-sm); }
.tab:hover:not(.active) { color: var(--text-2); }

/* ─── Toggle ─────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filter-select { max-width: 160px; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in .2s ease;
}
@keyframes modal-in {
  from { opacity:0; transform: translateY(10px) scale(.98); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex; align-items: center;
  margin-bottom: 20px;
}
.modal-title { font-size: 18px; font-weight: 600; flex: 1; }
.modal-close { background: none; border: none; color: var(--text-3); font-size: 20px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text-1); }

/* ─── Spinner ────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Carga global de vistas ─────────────────────────────────── */
.page-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12,14,17,.70);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}
.page-loading-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}
.page-loading-card {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 13px 17px;
  color: var(--text-1);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .15px;
  background: rgba(26,30,36,.94);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  box-shadow: 0 10px 34px rgba(0,0,0,.42), 0 0 0 1px rgba(59,127,232,.08);
}
.page-loading-orbit {
  width: 19px;
  height: 19px;
  border: 2px solid rgba(92,154,239,.20);
  border-top-color: var(--blue-light);
  border-right-color: var(--teal);
  border-radius: 50%;
  animation: page-loading-spin .72s linear infinite;
}
@keyframes page-loading-spin { to { transform: rotate(360deg); } }

/* ─── Análisis de cartera con IA ─────────────────────────────── */
.ai-analysis-body {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.65;
}
.ai-analysis-intro {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: linear-gradient(120deg, rgba(59,127,232,.12), rgba(20,184,166,.06));
  border: 1px solid rgba(92,154,239,.24);
  border-radius: 10px;
}
.ai-analysis-intro p,
.ai-analysis-section-content p { margin: 0 0 8px; }
.ai-analysis-intro p:last-child,
.ai-analysis-section-content p:last-child { margin-bottom: 0; }
.ai-analysis-sections { display: grid; gap: 9px; }
.ai-analysis-section {
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 3px solid var(--blue);
}
.ai-analysis-section-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}
.ai-analysis-section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  color: var(--blue-light);
  font-size: 11px;
  font-weight: 700;
  background: var(--blue-dim);
  border-radius: 50%;
}
.ai-analysis-section h3 {
  margin: 0;
  color: var(--text-1);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}
.ai-analysis-list {
  margin: 6px 0 0;
  padding-left: 18px;
}
.ai-analysis-list li { margin: 4px 0; }
.ai-analysis-body strong { color: var(--text-1); font-weight: 650; }

/* ─── Auth page ──────────────────────────────────────────────── */
.auth-page {
  background: radial-gradient(ellipse at 30% 20%, #0F1E38 0%, var(--bg-0) 60%);
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  padding: 24px;
}
.auth-container { width: 100%; max-width: 400px; }
.auth-brand {
  display: flex; align-items: center; gap: 10px;
  justify-content: center; margin-bottom: 32px;
}
.auth-brand .brand-name { font-size: 22px; }
.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth-legal-acceptance { display:flex; flex-direction:column; gap:10px; margin:4px 0 18px; color:var(--text-2); font-size:12px; line-height:1.5; }
.auth-legal-acceptance label { display:flex; align-items:flex-start; gap:8px; cursor:pointer; }
.auth-legal-acceptance input { margin-top:3px; accent-color:var(--blue); flex:0 0 auto; }
.auth-legal-acceptance a { text-decoration:underline; }
.legal-draft-warning { border:1px solid #8A5A13; background:rgba(245,158,11,.1); color:#FBBF24; padding:12px 14px; border-radius:10px; margin-bottom:20px; font-size:13px; }
.legal-page { max-width:820px; margin:32px auto; padding:0 18px 48px; }
.legal-page .auth-card { max-width:none; }
.legal-page h2 { font-size:17px; margin:24px 0 8px; }
.legal-page p, .legal-page li { color:var(--text-2); margin:8px 0; }
.legal-page ul { padding-left:22px; }
.legal-page .legal-placeholder { color:#FBBF24; font-weight:600; }
.auth-title { font-family: var(--font-serif); font-size: 26px; margin-bottom: 6px; }
.auth-subtitle { color: var(--text-3); font-size: 13.5px; margin-bottom: 24px; }
.auth-form .btn { margin-top: 8px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--text-3); font-size: 13px; }
.auth-footer { text-align: center; margin-top: 16px; color: var(--text-3); font-size: 11.5px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.empty-text  { font-size: 14px; margin-bottom: 20px; }

/* ─── Hamburger ──────────────────────────────────────────────── */
.btn-menu {
  display: none;
  background: none; border: none; color: var(--text-2); font-size: 22px; cursor: pointer; padding: 6px;
}
.sidebar-overlay { display: none; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .col-span-2 { grid-column: span 1; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 260px; }

  .btn-menu { display: flex; }

  .sidebar {
    width: var(--sidebar-w);
    transform: translateX(-100%);
    z-index: 300;
  }
  .sidebar.open { transform: translateX(0); }

  html.sidebar-collapsed .sidebar,
  html.sidebar-collapsed .sidebar:hover,
  html.sidebar-collapsed .sidebar:focus-within { width: var(--sidebar-w); box-shadow: none; }
  html.sidebar-collapsed .main-content { margin-left: 0; }
  html.sidebar-collapsed .sidebar-brand,
  html.sidebar-collapsed .sidebar:hover .sidebar-brand,
  html.sidebar-collapsed .sidebar:focus-within .sidebar-brand { justify-content: flex-start; padding-left: 20px; padding-right: 50px; }
  html.sidebar-collapsed .brand-name,
  html.sidebar-collapsed .nav-label,
  html.sidebar-collapsed .nav-text,
  html.sidebar-collapsed .user-info,
  html.sidebar-collapsed .user-pill .btn-logout { display: initial; }
  html.sidebar-collapsed .sidebar-collapse-toggle { display: none; }
  html.sidebar-collapsed .nav-section,
  html.sidebar-collapsed .sidebar:hover .nav-section,
  html.sidebar-collapsed .sidebar:focus-within .nav-section { padding-left: 12px; padding-right: 12px; }
  html.sidebar-collapsed .nav-item,
  html.sidebar-collapsed .sidebar:hover .nav-item,
  html.sidebar-collapsed .sidebar:focus-within .nav-item { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }
  html.sidebar-collapsed .sidebar-footer,
  html.sidebar-collapsed .sidebar:hover .sidebar-footer,
  html.sidebar-collapsed .sidebar:focus-within .sidebar-footer { padding-left: 12px; padding-right: 12px; }
  html.sidebar-collapsed .user-pill,
  html.sidebar-collapsed .sidebar:hover .user-pill,
  html.sidebar-collapsed .sidebar:focus-within .user-pill { justify-content: flex-start; padding-left: 8px; padding-right: 10px; background: var(--bg-2); }

  .sidebar-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 299;
    opacity: 0; pointer-events: none;
    transition: opacity .3s;
  }
  .sidebar-overlay.open { opacity: 1; pointer-events: all; }

  .main-content { margin-left: 0; }
  .page-body { padding: 16px; }
  .page-header { padding: 14px 16px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 18px; }

  .grid-3 { grid-template-columns: 1fr; }

  table { font-size: 12px; }
  thead th, tbody td { padding: 8px; }
}

/* ─── Evolution chart range buttons ─────────────────────────── */
.evo-header {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.evo-btns {
  display: flex !important;
  flex-direction: row !important;
  gap: 4px;
  flex-wrap: wrap;
}
.evo-btn {
  display: inline-block !important;
  background: #1A1E24;
  border: 1px solid #2A3140;
  color: #5C6472;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .3px;
  transition: background .15s, color .15s;
}
.evo-btn:hover { background: #212730; color: #9BA3B0; }
.evo-btn-active { background: #1E3A5F !important; border-color: #3B7FE8 !important; color: #5C9AEF !important; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── Utilidades ─────────────────────────────────────────────── */
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.mb-1   { margin-bottom: 6px; }
.mb-2   { margin-bottom: 12px; }
.mb-3   { margin-bottom: 20px; }
.mb-4   { margin-bottom: 28px; }
.mt-auto { margin-top: auto; }
.text-sm  { font-size: 12px; }
.text-xs  { font-size: 11px; }
.text-muted { color: var(--text-3); }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 16px;
}
.modal-hidden { display: none !important; }
.modal-box {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  margin: auto;
  padding: 28px;
  animation: modal-in .15s ease;
}
@keyframes modal-in {
  from { opacity:0; transform: translateY(-10px); }
  to   { opacity:1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-3); font-size: 20px;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg-2); color: var(--text-1); }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 520px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-2 [style*="grid-column:1/-1"] { grid-column: 1 !important; }
}
.label-hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-3);
}

/* ─── Detail rows (property detail) ─────────────────────────── */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span { color: var(--text-3); flex-shrink: 0; }
.detail-row strong { text-align: right; word-break: break-word; }

/* ─── Delete icon button ─────────────────────────────────────── */
.btn-icon-del {
  background: none; border: none;
  color: var(--text-3); cursor: pointer;
  font-size: 12px; padding: 3px 7px;
  border-radius: 5px;
  transition: background .15s, color .15s;
}
.btn-icon-del:hover { background: rgba(239,68,68,.15); color: var(--red); }

/* ─── KPI row layout ─────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
/* ─── Tabla Posiciones — sin scroll horizontal ───────────────── */

/* En desktop: quitar nowrap de la primera columna (nombre) para
   que pueda partir en varias líneas y la tabla quepa en pantalla */
.portfolio-table thead th,
.portfolio-table tbody td {
  white-space: normal;
}
/* El resto de columnas numéricas sí mantienen nowrap */
.portfolio-table thead th:not(:first-child),
.portfolio-table tbody td:not(:first-child) {
  white-space: nowrap;
}
/* La columna nombre tiene ancho mínimo para no colapsar demasiado */
.portfolio-table td.col-name {
  min-width: 120px;
  word-break: break-word;
}

/* Móvil: ocultar columnas secundarias, mostrar solo lo esencial   */
@media (max-width: 640px) {
  /* Columnas ocultas en móvil: Cantidad, P.Medio, P.Actual,
     P&L Realizado, Dividendos */
  .portfolio-table .col-hide-mobile {
    display: none;
  }
  /* Ajustar padding para aprovechar espacio */
  .portfolio-table thead th,
  .portfolio-table tbody td {
    padding: 8px 7px;
    font-size: 12px;
  }
  /* La divisa como pill ocupa poco, reducir padding */
  .portfolio-table td.col-cur {
    padding-left: 4px;
    padding-right: 4px;
  }
}
/* ─── Range buttons (dashboard / asset / portfolio) ─────────── */
/* Usado por _BTN_BASE / _BTN_ACTIVE en JS                        */
.range-btn {
  display: inline-block;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .3px;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.range-btn:hover { background: var(--bg-3); color: var(--text-2); }
.range-btn.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue-light);
}

/* ─── Maintenance / chart control buttons ───────────────────── */
/* Usado por _MAINT_BTN_ON/OFF en JS                               */
.maint-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.maint-btn:hover { background: var(--bg-3); color: var(--text-2); }
.maint-btn.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue-light);
}

/* Toggle variant (candle chart mode) — _MAINT_BTN_TOGGLE_ON/OFF  */
.maint-btn-toggle {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.maint-btn-toggle.on {
  background: #1A2A1A;
  border-color: var(--green);
  color: var(--green);
}

/* ─── AI analysis grid (inyectado antes en DOMContentLoaded) ── */
.ai-grid-main   { display: grid; grid-template-columns: 55fr 45fr; gap: 14px; margin-bottom: 14px; }
.ai-grid-ind    { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.ai-grid-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ai-gauges-row  { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .ai-grid-main   { grid-template-columns: 1fr; }
  .ai-grid-ind    { grid-template-columns: repeat(2, 1fr); }
  .ai-grid-bottom { grid-template-columns: 1fr; }
  .ai-gauges-row  { gap: 4px; }
}

/* ─── Watchlist table (inyectado antes en _wlLoadTable) ─────── */
.wl-job-notice {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  align-items: center;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 1px solid #3B82F6;
  border-radius: 10px;
  background: #172554;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  color: #DBEAFE;
  font-size: 13px;
  font-weight: 600;
}
.wl-job-notice.done { border-color: #22C55E; background: #052E16; color: #DCFCE7; }
.wl-job-notice.error { border-color: #EF4444; background: #450A0A; color: #FEE2E2; }
.wl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.wl-table th,
.wl-table td { padding: 10px 12px; white-space: nowrap; }
.wl-table th {
  background: #111318;
  color: var(--text-3);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid #21262D;
}
.wl-table td { border-bottom: 1px solid #21262D; }
.wl-table tr:nth-child(even) td { background: #0D1117; }
.wl-col-name,
.wl-col-dist,
.wl-col-rsi { display: table-cell; }

/* Timeline de eventos del Dashboard y Stocks Watchlist */
.agenda-timeline-track { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; scroll-snap-type: x proximity; }
.agenda-timeline-track::-webkit-scrollbar { height: 7px; }
.agenda-timeline-track::-webkit-scrollbar-track { background: transparent; }
.agenda-timeline-track::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }
.agenda-timeline-track > div { scroll-snap-align: start; }

/* ── Ordenación: cabeceras clicables ── */
.wl-table th.wl-sortable { cursor: pointer; user-select: none; }
.wl-table th.wl-sortable:hover { color: var(--text-1); background: #161B22; }
.wl-table th .wl-ar { color: #3B7FE8; font-size: 9px; }

/* ── Responsive: ocultar columnas menos críticas por anchura ── */
@media (max-width: 1200px) {
  .wl-col-accy,
  .wl-col-renty { display: none; }
}
@media (max-width: 1000px) {
  .wl-col-date,
  .wl-col-rent { display: none; }
}
@media (max-width: 900px) {
  .wl-col-dist,
  .wl-col-rsi,
  .wl-col-acc { display: none; }
}
@media (max-width: 640px) {
  .wl-col-name,
  .wl-col-vol { display: none; }
  .wl-table th,
  .wl-table td { padding: 8px 6px; font-size: 12px; }
}
