/* ============================================================
   TORNUS DESIGN SYSTEM — INSTAGRAM AUDIENCE ANALYTICS
   Marca Tornus: Petróleo profundo (#00232c), Crema (#f7f2df),
   Amarillo solar (#fbfb75), Acento (#0b4a57) y Terracota (#b07a12).
   Tipografías: Archivo, Instrument Serif, IBM Plex Mono.
   ============================================================ */

:root {
  --bg: #f7f2df;
  --surface: #fffdf6;
  --ink: #00232c;
  --muted: #56686b;
  --line: #e3dbc2;
  --accent: #0b4a57;
  --accent-soft: #e7eee9;
  --sun: #b07a12;
  --band: #00232c;
  --band-ink: #f7f2df;
  --band-muted: #9db3b4;
  --band-accent: #fbfb75;
  --band-line: #15424d;
  --btn: #00232c;
  --btn-ink: #fbfb75;
  --crit: #a8321f;
  --crit-soft: #f6e0d8;
  --ok: #2c6b45;
  --ok-soft: #e0ecdf;
  --display: "Instrument Serif", Georgia, serif;
  --body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 6px;
  --r-lg: 12px;
  --shadow-card: 0 2px 10px rgba(0, 35, 44, 0.04), 0 1px 3px rgba(0, 35, 44, 0.03);
  --shadow-hover: 0 12px 30px rgba(0, 35, 44, 0.12);
}

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

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14.5px;
  line-height: 1.45;
  letter-spacing: .005em;
  padding: 28px 20px 48px;
  min-height: 100vh;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
}

/* Header & Tornus Brand Bar */
.brand-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.tornus-wm {
  font-family: var(--body);
  font-stretch: 125%;
  font-weight: 800;
  letter-spacing: .32em;
  color: var(--ink);
  font-size: 14px;
  text-transform: uppercase;
}

.tornus-wm span {
  color: var(--sun);
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-link {
  font-family: var(--mono);
  font-size: 11.5px;
  text-decoration: none;
  color: var(--muted);
  padding: 5px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  transition: all .15s ease;
}

.nav-link:hover {
  color: var(--ink);
  border-color: var(--ink);
  background: #ede6d1;
}

.nav-link.active {
  color: var(--band-accent);
  background: var(--ink);
  border-color: var(--ink);
  font-weight: 600;
}

.tornus-system-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: rgba(0, 35, 44, 0.04);
  padding: 4px 10px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tornus-system-tag .dot {
  width: 6px;
  height: 6px;
  background: var(--ok);
  border-radius: 50%;
}

/* Main Hero Title */
.header-hero {
  margin-bottom: 24px;
}

.header-hero h1 {
  font-family: var(--display);
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  font-weight: 400;
  line-height: 0.98;
  color: var(--ink);
  letter-spacing: .01em;
  margin-bottom: 8px;
}

.header-hero p {
  color: var(--muted);
  font-size: 14px;
  max-width: 65ch;
}

/* Search Box Tornus Style */
.search-container {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.search-container:focus-within {
  border-color: var(--ink);
  box-shadow: 0 4px 18px rgba(0, 35, 44, 0.08);
}

.search-prefix {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
  padding-left: 6px;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--body);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.search-input::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.btn-tornus {
  background: var(--btn);
  color: var(--btn-ink);
  border: 1px solid var(--btn);
  font-family: var(--body);
  font-stretch: 112%;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--r);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all .15s ease;
}

.btn-tornus:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
  transform: translateY(-1px);
}

/* Suggestion Pills */
.quick-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  font-size: 12px;
  color: var(--muted);
}

.quick-tags .lab {
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  font-size: 10.5px;
}

.tag-chip {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 3px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: all .15s ease;
}

.tag-chip:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--band-accent);
}

/* Dashboard Layout Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  align-items: start;
}

.column-left,
.column-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Tornus Card Base */
.card-tornus {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  position: relative;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--body);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

.card-stamp {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .05em;
  color: var(--muted);
  text-transform: uppercase;
}

.card-stamp strong {
  color: var(--ink);
}

/* Profile Main Card */
.profile-top-wrap {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.avatar-frame {
  position: relative;
  flex-shrink: 0;
}

.profile-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  background: var(--bg);
}

.profile-details {
  flex: 1;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-display-name {
  font-family: var(--display);
  font-size: 2.2rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1;
}

.verified-badge {
  color: var(--accent);
  display: inline-flex;
}

.profile-handle {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.profile-sub-tag {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* Key Metrics 3-Col KPI */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.kpi-block {
  display: flex;
  flex-direction: column;
}

.kpi-lab {
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 2px;
}

.kpi-val-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.kpi-val {
  font-family: var(--display);
  font-weight: 400;
  font-size: 2.3rem;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.kpi-growth {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ok);
  background: var(--ok-soft);
  padding: 1px 6px;
  border-radius: var(--r);
}

/* Bio Text */
.profile-bio-box {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-line;
}

.profile-bio-box a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

/* Gender Split Table */
.demog-table {
  width: 100%;
  border-collapse: collapse;
}

.demog-table th {
  text-align: left;
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.demog-table td {
  padding: 12px 0;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(227, 219, 194, 0.4);
}

.demog-table tr:last-child td {
  border-bottom: none;
}

.demog-label {
  font-weight: 600;
  color: var(--ink);
}

.demog-val {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
}

/* Sub-row: Cities and Interests */
.sub-row {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 20px;
}

.bar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  margin-bottom: 10px;
}

.bar-item:last-child {
  margin-bottom: 0;
}

.bar-name {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.bar-track-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}

.bar-track {
  width: 90px;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.6s ease;
}

.bar-num {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  min-width: 44px;
  text-align: right;
}

/* Media Grids (Popular Posts & Collabs) */
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.media-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--line);
  cursor: pointer;
  border: 1px solid var(--line);
  transition: transform .15s ease, box-shadow .15s ease;
}

.media-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.media-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 35, 44, 0.88) 0%, rgba(0, 35, 44, 0.1) 45%, transparent 100%);
  display: flex;
  align-items: flex-end;
  padding: 8px;
  gap: 8px;
  color: var(--band-ink);
  font-family: var(--mono);
  font-size: 11.5px;
}

.collab-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--band);
  color: var(--band-accent);
  border: 1px solid var(--band-line);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 85%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* States */
.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-banner {
  background: var(--crit-soft);
  border: 1px solid var(--crit);
  color: var(--crit);
  padding: 14px 18px;
  border-radius: var(--r);
  margin-bottom: 20px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   LÍNEA TEMPORAL & FILTRO DE TIEMPO (ESTILO METRICOOL)
   ============================================================ */
.timeline-hero-card {
  padding: 24px 28px;
  margin-bottom: 8px;
}

.timeline-header-wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.timeline-title {
  font-family: var(--display);
  font-size: 2.1rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.05;
  margin-bottom: 4px;
}

.timeline-subtitle {
  color: var(--muted);
  font-size: 13px;
  max-width: 680px;
}

.timeline-status-badge {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(0, 35, 44, 0.05);
  border: 1px solid var(--line);
  color: var(--accent);
  padding: 5px 12px;
  border-radius: var(--r);
  font-weight: 600;
}

/* Time Filter Pills */
.time-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-pill {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 6px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--r);
  cursor: pointer;
  transition: all .15s ease;
}

.filter-pill:hover {
  border-color: var(--ink);
  background: #ede6d1;
}

.filter-pill.active {
  background: var(--ink);
  color: var(--band-accent);
  border-color: var(--ink);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 35, 44, 0.15);
}

.custom-date-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  padding: 10px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  flex-wrap: wrap;
}

.date-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-input {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 4px 8px;
  color: var(--ink);
}

.date-input:focus {
  outline: none;
  border-color: var(--ink);
}

.btn-tornus-sm {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--band-accent);
  border: none;
  padding: 6px 14px;
  border-radius: var(--r);
  cursor: pointer;
  transition: all .15s ease;
}

.btn-tornus-sm:hover {
  background: var(--accent);
  color: var(--surface);
}

/* Period KPI Cards */
.period-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.period-kpi-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.period-kpi-card.highlight {
  background: rgba(11, 74, 87, 0.06);
  border-color: rgba(11, 74, 87, 0.3);
}

.p-kpi-lab {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-kpi-val {
  font-family: var(--body);
  font-stretch: 110%;
  font-weight: 700;
  font-size: clamp(1.2rem, 2.2vw, 1.42rem);
  color: var(--ink);
  line-height: 1.15;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.015em;
}

.p-kpi-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chart Controls Bar */
.chart-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chart-metric-switch {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chart-switch-btn {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: all .15s ease;
}

.chart-switch-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.chart-switch-btn.active {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
  font-weight: 600;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.dot-video { background: var(--sun); }
.legend-dot.dot-carousel { background: var(--accent); }
.legend-dot.dot-image { background: var(--ink); }

/* Timeline Chart Canvas/SVG Container */
.timeline-chart-container {
  position: relative;
  width: 100%;
  height: 310px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: visible;
  padding: 10px 0 5px;
}

.timeline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

/* Tooltip */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
  background: var(--band);
  color: var(--band-ink);
  border: 1px solid var(--band-line);
  border-radius: var(--r);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  box-shadow: 0 10px 25px rgba(0, 35, 44, 0.35);
  max-width: 250px;
  transition: opacity .1s ease, transform .1s ease;
}

.chart-tooltip-header {
  font-size: 10.5px;
  color: var(--band-accent);
  margin-bottom: 4px;
  border-bottom: 1px solid var(--band-line);
  padding-bottom: 4px;
}

.chart-tooltip-metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 3px 0;
  font-size: 11px;
}

.chart-tooltip-metric strong {
  color: var(--surface);
}

/* Footer Tornus style */
.tornus-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.tornus-footer .wm {
  font-stretch: 125%;
  font-weight: 700;
  letter-spacing: .32em;
  color: var(--ink);
}

@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .period-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .sub-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { padding: 16px 12px; }
  .period-kpi-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; gap: 12px; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-controls-bar { flex-direction: column; align-items: flex-start; }
}
