:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1f4e78;
  --primary-2: #2563eb;
  --pos: #16a34a;
  --neg: #dc2626;
  --tag-bg: #eef2ff;
  --tag-fg: #3730a3;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15,23,42,.05), 0 1px 2px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-weight: bold; font-size: 16px;
}
.title { font-size: 16px; font-weight: 600; }
.subtitle { font-size: 11px; color: var(--muted); }
nav { display: flex; gap: 16px; }
.navlink {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text);
}
.navlink:hover { background: var(--bg); text-decoration: none; }
.navlink-muted { color: var(--muted); font-size: 12px; }
.user-chip {
  padding: 4px 10px; background: #eef2ff; color: #3730a3;
  border-radius: 12px; font-size: 11px; font-weight: 600;
}

/* Layout */
.layout { padding: 20px 24px 60px; max-width: 1500px; margin: 0 auto; }
.grid-dashboard {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
}
@media (max-width: 1100px) { .grid-dashboard { grid-template-columns: 1fr; } }

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 22px; font-weight: 600; margin-top: 4px; }
@media (max-width: 800px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 12px; font-size: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;}
.card-header h2 { margin: 0; }
.chart-note { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Tabla */
.table-wrap { overflow-x: auto; }
.positions-table {
  width: 100%;
  border-collapse: collapse;
}
.positions-table th, .positions-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.positions-table th { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.positions-table tr:hover td { background: #fafbff; }
.positions-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-asset strong { display: block; }
.cell-asset small { color: var(--muted); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.tag.small { font-size: 10px; padding: 1px 6px; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.small { font-size: 11px; }

/* Botones */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 500;
  cursor: pointer;
  font-size: 13px;
}
.btn-primary:hover { background: #163a5e; }
.btn-danger { background: var(--neg); color: white; border: none; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
.btn-danger.small { font-size: 11px; }

/* Sidebar */
.side-col .card { padding: 14px; }
.side-col h3 { margin: 0 0 10px; font-size: 14px; }
.list { display: flex; flex-direction: column; gap: 10px; max-height: 540px; overflow-y: auto; }
.alert-item, .news-item {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.alert-item:last-child, .news-item:last-child { border-bottom: none; }
.alert-date { font-size: 11px; color: var(--muted); }
.alert-body strong { color: var(--text); }
.news-item { display: block; color: var(--text); }
.news-item:hover { text-decoration: none; opacity: .85; }
.news-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.news-title { font-size: 13px; line-height: 1.35; }

/* Detalle */
.detail-wrap { max-width: 1300px; margin: 0 auto; }
.detail-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 16px;
}
.detail-header h1 { margin: 0; font-size: 22px; }
.detail-kpis { display: flex; gap: 28px; }
.detail-kpis > div { font-size: 13px; }
.detail-kpis strong { font-size: 16px; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.grid-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 900px) { .grid-detail { grid-template-columns: 1fr; } }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th, .mini-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.mini-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.inline-form { display: flex; gap: 8px; margin-top: 4px; }
.inline-form input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }
.manual-form label { display: block; margin: 8px 0; }
.manual-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-family: ui-monospace, monospace; font-size: 12px; }

/* Upload */
.upload-wrap { max-width: 900px; margin: 0 auto; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  background: #fafbff;
  transition: all .15s ease;
  margin-bottom: 12px;
}
.dropzone:hover, .dropzone.dragging {
  border-color: var(--primary-2);
  background: #eff6ff;
}
.dz-icon { font-size: 32px; }
.dz-text { font-weight: 500; margin: 8px 0; }
.error-box {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: 8px; padding: 12px; margin-bottom: 16px;
}
.success-box {
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534;
  border-radius: 8px; padding: 12px; margin-bottom: 16px;
}
.manual-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.manual-grid label {
  display: flex; flex-direction: column; font-size: 12px; color: var(--muted);
  gap: 4px;
}
.manual-grid input, .manual-grid select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 13px;
}
.manual-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .manual-grid { grid-template-columns: 1fr; } }

.empty-state { text-align: center; padding: 32px; color: var(--muted); }
.empty-state p { margin-bottom: 16px; }

.foot {
  text-align: center; color: var(--muted); font-size: 11px;
  padding: 24px 0;
}
