/* Norte · Tu cartera con IA — tema */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #15202b;
  --ink-soft: #5b6b7b;
  --ink-faint: #93a1b0;
  --line: #e7ebf0;
  --line-soft: #eef1f5;
  --accent: #ff6a2b;
  --accent-ink: #d8480e;
  --accent-soft: #fff1ea;
  --green: #14a06a;
  --green-soft: #e7f7ef;
  --red: #e0413a;
  --red-soft: #fdeceb;
  --blue: #2f6df6;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 20px rgba(16,24,40,.06);
  --shadow-pop: 0 10px 40px rgba(16,24,40,.16);
  --r: 16px;
  --r-sm: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* Layout */
#app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, #ff8c52, var(--accent));
  position: relative; box-shadow: 0 4px 10px rgba(255,106,43,.35);
}
.brand-mark::after {
  content: "✳"; position: absolute; inset: 0; color: #fff;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: var(--r-sm);
  color: var(--ink-soft); font-weight: 600; font-size: 14.5px;
  transition: background .12s, color .12s;
}
.nav-item .ni-ico { font-size: 16px; width: 18px; text-align: center; }
.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.demo-box { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; }
.demo-title { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.btn-demo {
  display: block; width: 100%; text-align: left; margin: 4px 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.btn-demo:hover { border-color: var(--accent); color: var(--accent-ink); }
.disclaimer-mini { font-size: 11px; color: var(--ink-faint); margin: 14px 4px 0; line-height: 1.4; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.8); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.hamburger { display: none; background: none; border: none; font-size: 20px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: none; background: none; padding: 6px 11px; border-radius: 7px; font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.btn-ghost { background: none; border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; font-weight: 600; color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); width: 220px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-pop); padding: 6px; z-index: 40;
}
.menu-pop button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 9px 10px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink); }
.menu-pop button:hover { background: var(--line-soft); }
.menu-pop button.danger { color: var(--red); }

.view { padding: 26px; max-width: 1180px; width: 100%; margin: 0 auto; }
.appfoot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 26px; color: var(--ink-faint); font-size: 12px; border-top: 1px solid var(--line); }

/* Tipografía de páginas */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
.page-head p { color: var(--ink-soft); margin: 0; }
.section-title { font-size: 16px; font-weight: 800; margin: 26px 0 12px; letter-spacing: -.01em; }

/* Tarjetas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1.4fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid.kpis { grid-template-columns: repeat(2,1fr); } .grid.two, .grid.three { grid-template-columns: 1fr; } }

.kpi .kpi-label { color: var(--ink-soft); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi .kpi-value { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.kpi .kpi-sub { font-size: 12.5px; font-weight: 700; margin-top: 4px; }
.kpi-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; }
.up { color: var(--green); } .down { color: var(--red); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.up { background: var(--green-soft); } .pill.down { background: var(--red-soft); }
.pill.flat { background: var(--line-soft); color: var(--ink-soft); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; font-weight: 700; font-size: 14px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(255,106,43,.28); }
.btn-primary:hover { background: #f25c1d; }
.btn-outline { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Tablas / listas */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); font-size: 14px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.asset-cell { display: flex; align-items: center; gap: 11px; }
.asset-logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: none; }
.asset-name { font-weight: 700; }
.asset-sub { color: var(--ink-faint); font-size: 12.5px; }
.cat-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }

/* Filtros */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.search { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.search input { border: none; outline: none; flex: 1; font-size: 14px; background: none; }

/* Gráficos */
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.sm { height: 220px; }
.range-tabs { display: inline-flex; gap: 4px; }
.range-tabs button { border: none; background: var(--bg); padding: 5px 11px; border-radius: 7px; font-weight: 700; font-size: 12.5px; color: var(--ink-soft); }
.range-tabs button.active { background: var(--ink); color: #fff; }

/* Distribución / barras */
.bar-row { display: grid; grid-template-columns: 130px 1fr 64px; gap: 10px; align-items: center; margin: 9px 0; }
.bar-track { height: 9px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.bar-val { font-size: 13px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }

/* Formularios */
.field { margin: 12px 0; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: var(--card); color: var(--ink); }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label { flex: 1; min-width: 120px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 13.5px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.radio-row label.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.radio-row input { display: none; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(16,24,40,.42); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--card); border-radius: 18px; box-shadow: var(--shadow-pop); width: 100%; max-width: 460px; padding: 22px; max-height: 90vh; overflow: auto; }
.modal.lg { max-width: 720px; }
.modal h3 { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
.modal .modal-sub { color: var(--ink-soft); margin: 0 0 16px; font-size: 13.5px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-close { float: right; background: none; border: none; font-size: 20px; color: var(--ink-faint); }

/* Toast */
#toastRoot { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-pop); animation: toastin .2s; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* Estados */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-soft); }
.empty .em-ico { font-size: 40px; margin-bottom: 10px; }
.skel { background: linear-gradient(90deg, var(--line-soft) 25%, #f6f8fb 37%, var(--line-soft) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: 0 0; } }
.muted { color: var(--ink-soft); }
.tiny { font-size: 12px; }
.note { background: var(--accent-soft); border: 1px solid #ffd9c6; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--accent-ink); }
.warn { background: #fff8e6; border: 1px solid #ffe7a3; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #8a6300; }

/* Responsive sidebar */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 60; transition: left .2s; width: 252px; }
  .sidebar.open { left: 0; box-shadow: var(--shadow-pop); }
  .hamburger { display: block; }
  .view { padding: 18px; }
}
