/* Insights page styles */
.insights-area {
  padding: 20px;
  display: grid;
  grid-template-rows: auto auto; /* content grows; page scrolls */
  gap: 16px;
}

.insights-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-bg, #11161e);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.04);
}

.insights-tab {
  appearance: none;
  border: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  color: #dbe7ff;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: all .2s ease;
  border: 1px solid rgba(255,255,255,0.08);
}

.insights-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.18);
}

.insights-tab.active {
  background: linear-gradient(180deg, var(--brand, #3b82f6), #2563eb);
  color: white;
  box-shadow: 0 6px 16px rgba(59,130,246,0.35);
  border-color: transparent;
}

.insights-panel {
  background: var(--panel-bg, #0f141b);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 20px;
  height: auto; /* let content decide height */
  overflow: visible; /* rely on page scroll */
  box-shadow: 0 12px 24px rgba(0,0,0,0.3);
}

/* Dashboard grid (10x10) */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-auto-rows: 90px; /* each row height */
  gap: 10px;
  min-height: 0; /* grow with items */
  padding: 6px;
}

.tile {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  transition: box-shadow .2s ease, transform .2s ease;
}
.tile:hover { box-shadow: 0 12px 28px rgba(0,0,0,0.35); transform: translateY(-1px); }
.tile-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; cursor: move; user-select: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tile-title { font-size: 13px; font-weight: 600; color: #dbe7ff; }
.tile-actions { display: flex; gap: 6px; }
.tile-body { padding: 8px; height: calc(100% - 42px); display: grid; grid-template-columns: 230px 1fr; gap: 10px; align-items: start; align-content: start; }
.tile-body .chart-wrap { max-width: unset; margin: 0 auto; display: flex; align-items: center; justify-content: center; height: 100%; }
.tile-body .chart-wrap canvas { max-width: 100%; max-height: 100%; width: auto !important; height: auto !important; display: block; }
.tile-info { 
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(148,163,184,0.25);
  border-radius: 12px;
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 1px 6px rgba(0,0,0,0.25);
}
.tile-info h4 {
  margin: 0;
  padding: 8px 10px 10px;
  font-size: 13px; color: #cfe0ff; font-weight: 700; letter-spacing: .2px;
  border-bottom: 1px solid rgba(148,163,184,0.2);
}
/* Rows look like a table */
.tile-info .stat {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148,163,184,0.2);
  background: rgba(255,255,255,0.02);
}
.tile-info .stat:nth-child(odd) { background: rgba(255,255,255,0.03); }
.tile-info .stat:first-of-type { border-top-left-radius: 10px; border-top-right-radius: 10px; }
.tile-info .stat:last-child { border-bottom: 0; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; }
.tile-info .label { display: flex; align-items: center; gap: 8px; color: #dbe7ff; font-size: 12px; line-height: 1.2; }
.tile-info .dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; box-shadow: 0 0 0 2px rgba(0,0,0,0.15) inset; }
.tile-info .value { color: #9fb2dd; font-size: 12px; white-space: nowrap; }

/* Line insights: summary cards */
.tile-info .info-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 6px 0 8px;
}
.tile-info .info-summary .card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr max-content; /* reserve fixed space for numbers */
  grid-template-rows: auto auto;
  row-gap: 4px;
  column-gap: 8px; /* avoid label-number touching */
}
.tile-info .info-summary .card .k {
  color: #9fb2dd;
  font-size: 11px;
  white-space: nowrap;            /* keep label on one line */
  overflow: hidden;               /* prevent overflow */
  text-overflow: ellipsis;        /* truncate with ellipsis */
}
.tile-info .info-summary .card .v {
  color: #e6eeff;
  font-weight: 700;
  font-size: 16px;
  justify-self: end;
  white-space: nowrap;            /* keep number on one line */
}
.tile-info .info-summary .card .s { grid-column: 1 / span 2; color: #8da6d9; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Line insights: compact table */
.tile-info .info-table { max-height: 220px; overflow: auto; border-radius: 8px; border: 1px solid rgba(255,255,255,0.06); }
.data-table.compact thead th { position: sticky; top: 0; background: rgba(15,20,27,0.95); z-index: 1; font-size: 11px; padding: 6px 8px; }
.data-table.compact tbody td { font-size: 12px; padding: 6px 8px; }
.data-table.compact tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }
.data-table.compact tbody tr:hover { background: rgba(255,255,255,0.04); }
.tile-resize { position: absolute; right: 4px; bottom: 4px; width: 14px; height: 14px; cursor: se-resize; opacity: .8; }
.tile-resize:after { content: ''; position: absolute; right: 2px; bottom: 2px; width: 10px; height: 10px; border-right: 2px solid #7aa2ff; border-bottom: 2px solid #7aa2ff; }

/* Placeholder blocks */
.insights-placeholder {
  background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(59,130,246,0.04));
  border: 1px dashed rgba(59,130,246,0.4);
  color: #c8d7ff;
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  font-weight: 500;
}

/* Graphs controls */
.graphs-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.graphs-controls .input-sm {
  min-width: 200px;
}

/* Tiny selects used in tile header */
.input-xs {
  appearance: none;
  background: rgba(255,255,255,0.06);
  color: #e4edff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}

/* Charts list */
.graphs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.chart-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 12px;
}
.chart-row.selected { outline: 2px solid var(--brand, #3b82f6); }
.chart-title { font-weight: 600; color: #e4edff; }
.chart-meta { color: #97a6c3; font-size: 12px; }
.chart-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Data card */
.graphs-data { display: grid; gap: 12px; }
.data-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 12px;
  transition: box-shadow .2s ease, transform .2s ease;
}
.data-card:hover { box-shadow: 0 14px 28px rgba(0,0,0,0.35); transform: translateY(-2px); }
.data-title { font-weight: 600; margin-bottom: 8px; }
.chart-wrap { max-width: 380px; margin: 6px auto 12px; position: relative; }
.chart-wrap canvas { width: 100% !important; height: auto !important; display: block; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { text-align: left; font-size: 12px; color: #9cb3e0; padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.data-table tbody td { padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.04); }

/* Sortable headers */
.data-table thead th.sortable { user-select: none; }
.data-table thead th.sortable:hover { background: rgba(255,255,255,0.04); }
.data-table thead th .sort-indicator { font-size: 10px; opacity: 0.85; margin-left: 6px; }

/* Table actions (e.g., clear sort) */
.info-table .table-actions { display: flex; justify-content: flex-end; gap: 6px; padding: 6px 0; }

/* Utility */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
  .insights-area { padding: 12px; gap: 12px; }
  .insights-tabs { flex-wrap: wrap; gap: 8px; }
  .insights-tab { flex: 1 0 auto; padding: 10px 12px; }
  .chart-wrap { max-width: 300px; }
  .dashboard-grid { grid-auto-rows: 110px; min-height: 420px; }
  .tile-body { grid-template-columns: 1fr; }
}

/* Modern scroll styling for insights table */
.tile-info .info-table {
  /* Subtle top/bottom fade to hint scroll */
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.0) 0, rgba(0,0,0,1) 12px, rgba(0,0,0,1) calc(100% - 12px), rgba(0,0,0,0.0) 100%);
          mask-image: linear-gradient(180deg, rgba(0,0,0,0.0) 0, rgba(0,0,0,1) 12px, rgba(0,0,0,1) calc(100% - 12px), rgba(0,0,0,0.0) 100%);
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(148,163,184,0.55) transparent; /* thumb track */
}
.tile-info .info-table:hover { scrollbar-color: rgba(148,163,184,0.9) transparent; }

/* Chrome/Edge/Safari */
.tile-info .info-table::-webkit-scrollbar { width: 10px; height: 10px; }
.tile-info .info-table::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}
.tile-info .info-table::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(148,163,184,0.35), rgba(148,163,184,0.55));
  border-radius: 10px;
  border: 2px solid transparent; /* creates padding */
  background-clip: content-box;
}
.tile-info .info-table:hover::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(148,163,184,0.6), rgba(148,163,184,0.85));
}
.tile-info .info-table::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, rgba(148,163,184,0.85), rgba(148,163,184,1));
}

/* Slight inner shadow to table container for depth */
.tile-info .info-table { box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -1px 0 rgba(0,0,0,0.3); }
