/* Control de Inversiones Financieras — Mobile-First Responsive Styles */
:root {
  --primary: #1a1a2e;
  --primary-light: #16213e;
  --accent: #0f3460;
  --positive: #28a745;
  --negative: #dc3545;
  --neutral: #6c757d;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

/* ── Navigation ── */
.navbar {
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.navbar-brand {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navbar-brand .brand-icon { font-size: 1.25rem; }
.navbar-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}
.navbar-links a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.navbar-links a:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ── Cards / Panels ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ── Section headings ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}
.section-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

/* ── Summary stats bar ── */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.stat-pill strong { color: var(--text); }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8f9ff; }
tbody td { padding: 0.65rem 0.75rem; vertical-align: middle; }
.col-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.col-action { text-align: right; }

/* ── Price change colors ── */
.positive { color: var(--positive); font-weight: 600; }
.negative { color: var(--negative); font-weight: 600; }
.neutral { color: var(--neutral); }

/* ── Instrument detail ── */
.breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 0.35rem; }

.instrument-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.instrument-identity { flex: 1; }
.instrument-symbol {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}
.instrument-name {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.instrument-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}
.instrument-price-block { text-align: right; }
.price-current {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.price-change-row {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.2rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ── Time filter buttons ── */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.filter-btn {
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Chart ── */
.chart-container {
  position: relative;
  height: 320px;
  margin-bottom: 1.25rem;
}
.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  color: var(--text-muted);
  display: none;
}
.chart-loading.visible { display: flex; }

/* ── Stats panel ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-box {
  background: var(--bg);
  border-radius: 6px;
  padding: 0.65rem 0.9rem;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  margin-top: 0.1rem;
}

/* ── Action link ── */
.btn-link {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  transition: all 0.15s;
}
.btn-link:hover {
  background: var(--accent);
  color: #fff;
}
.btn-action {
  background: var(--accent);
  color: #fff;
  padding: 0.35rem 0.9rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-action:hover { background: var(--primary); }

/* ── Footer ── */
footer {
  background: var(--primary);
  color: rgba(255,255,255,0.6);
  text-align: center;
  font-size: 0.8rem;
  padding: 1rem;
  margin-top: 2rem;
}
footer a { color: rgba(255,255,255,0.8); text-decoration: none; }

/* ── 404 page ── */
.error-page {
  text-align: center;
  padding: 4rem 1rem;
}
.error-page h2 { font-size: 2rem; color: var(--primary); margin-bottom: 0.75rem; }
.error-page p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Responsive ── */
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .chart-container { height: 380px; }
}

@media (max-width: 767px) {
  .navbar-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--primary-light);
    padding: 0.75rem;
    gap: 0.2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  }
  .navbar-links.open { display: flex; }
  .navbar-links a { padding: 0.6rem 0.75rem; }
  .nav-toggle { display: block; }
  .instrument-header { flex-direction: column; }
  .instrument-price-block { text-align: left; }
  .price-change-row { justify-content: flex-start; }
  thead th { font-size: 0.72rem; padding: 0.5rem; }
  tbody td { padding: 0.55rem 0.5rem; }
}

@media (max-width: 480px) {
  .section-title { font-size: 1.05rem; }
  .price-current { font-size: 1.6rem; }
  .instrument-symbol { font-size: 1.4rem; }
  .container { padding: 1rem 0.75rem; }
}
