:root {
  --navy: #0f1f38;
  --navy-light: #16294a;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --bg: #f4f6fa;
  --panel-bg: #ffffff;
  --border: #e2e6ee;
  --text: #1a2233;
  --text-muted: #64748b;
  --green: #0d9c5e;
  --red: #d64545;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--navy);
  color: #fff;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.app-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
}
.menu-toggle span {
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}

.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100%;
  background: var(--navy-light);
  color: #fff;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
}
.side-menu.open { transform: translateX(0); }

.side-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  font-weight: 600;
}
.menu-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.menu-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}
.menu-item {
  display: block;
  padding: 12px 20px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
}
.menu-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.menu-item.active {
  color: #fff;
  border-left-color: var(--accent);
  background: rgba(37,99,235,0.15);
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}
.menu-overlay.open { opacity: 1; pointer-events: auto; }

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.filter-row label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.filter-row select {
  flex: 1;
  max-width: 320px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: #fff;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px 20px;
}

.filter-field label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}
.range-inputs input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}
.range-sep {
  color: var(--text-muted);
  font-weight: 600;
  flex: none;
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.result-count {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.btn {
  border: none;
  border-radius: 7px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #eef1f6; color: var(--text); }
.btn-secondary:hover { background: #e2e6ee; }

.table-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 560px;
}

thead th {
  text-align: right;
  background: #eef1f6;
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 7px;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
thead th:nth-child(2) { text-align: left; }

tbody td {
  padding: 5px 7px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
tbody td:nth-child(2) {
  text-align: left;
  font-weight: 700;
  color: var(--navy);
}
tbody tr:hover { background: #f8fafc; }

.col-num {
  width: 1%;
  color: var(--text-muted);
  font-weight: 400 !important;
}

.col-ticker {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 28px;
}

.subpanel-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 12px;
}

.rec-frame-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  height: 75vh;
  min-height: 420px;
}

.rec-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.img-frame-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-align: center;
  background: #0b1526;
}

.grafico-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  margin: 0 auto;
}

.hint-bar {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  max-width: calc(100% - 24px);
  background: var(--navy);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 25;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.hint-bar.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
  .content { padding: 14px 10px 50px; }
  .panel { padding: 14px; }
}
