.dashboard-page {
  --insight-surface: var(--app-surface);
  --insight-fill: var(--app-fill);
  --insight-line: var(--app-line);
  --insight-muted: var(--app-muted);
  --insight-red: #ff8da5;
  --insight-blue: #9cb9f2;
  --insight-purple: #d3b0f0;
  --insight-action: var(--app-action);
  --insight-action-ink: var(--app-action-ink);
  --insight-shadow: var(--app-shadow);
}

html[data-theme="light"] .dashboard-page {
  --insight-red: #ad1b3b;
  --insight-blue: #345f9e;
  --insight-purple: #70478d;
}

.dashboard-page main { margin-top: 40px; }
.dashboard-page .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-page .stat { background: var(--insight-surface); border-color: var(--insight-line); }
.dashboard-page .stat b { font-variant-numeric: tabular-nums; }

.smartlink-board, .dashboard-insights { margin: 28px 0; }
.smartlink-board {
  border: 1px solid var(--insight-line);
  border-radius: 18px;
  background: var(--insight-surface);
  box-shadow: var(--insight-shadow);
}
.board-heading, .insight-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 15px;
}
.board-heading { padding: 20px 21px 0; }
.board-heading h2, .insight-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.035em; }
.dashboard-page :is(.board-count, .insight-status, .insight-heading p, .insight-empty) { color: var(--insight-muted); font-size: 13px; }
.board-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 17px 21px; }
.dashboard-page .board-toolbar :is(input, select), .dashboard-page .insight-heading select {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--insight-line);
  border-radius: 9px;
  background: var(--insight-fill);
  color: var(--app-ink);
  padding: 9px 11px;
}
.board-toolbar input { width: min(244px, 100%); }
.board-toolbar select { width: min(180px, 100%); }
.dashboard-page .board-toolbar #newLink {
  margin-left: auto;
  color: var(--insight-action-ink);
  background: var(--insight-action);
  white-space: nowrap;
  padding: 9px 14px;
}
.smartlink-scroll { overflow-x: auto; }
.smartlink-table { border-collapse: collapse; width: 100%; min-width: 735px; text-align: left; }
.dashboard-page .smartlink-table th, .dashboard-page .smartlink-table td { padding: 12px 16px; border-top: 1px solid var(--insight-line); }
.smartlink-table :is(th, td):first-child { padding-left: 21px; }
.smartlink-table :is(th, td):last-child { padding-right: 21px; }
.smartlink-table th:first-child { width: 36%; }
.smartlink-table th:nth-child(2) { width: 16%; }
.smartlink-table th:nth-child(3), .smartlink-table th:nth-child(4) { width: 12%; }
.dashboard-page .smartlink-table thead th { font-size: 12px; color: var(--insight-muted); white-space: nowrap; }
.smartlink-table thead button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-align: left;
}
.smartlink-table thead button::after { content: '↕'; margin-left: 6px; opacity: .65; }
.smartlink-table th[aria-sort="descending"] button::after { content: '↓'; opacity: 1; }
.smartlink-table th[aria-sort="ascending"] button::after { content: '↑'; opacity: 1; }
.smartlink-table tbody tr:is(:hover, :focus-within) { background: var(--insight-fill); }
.smartlink-table .release-cover { width: 44px; height: 44px; flex-basis: 44px; border-radius: 8px; background: var(--insight-fill); font-size: 18px; }
.smartlink-table .release-text { min-width: 0; max-width: 100%; }
.smartlink-table .release-text :is(strong, small) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smartlink-table .release-text strong { color: var(--app-ink); font-size: 13px; }
.dashboard-page .smartlink-table .release-text small { color: var(--insight-muted); font-weight: 450; margin-top: 4px; }
.smartlink-table tbody { font-variant-numeric: tabular-nums; }
.smartlink-table .table-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; white-space: nowrap; }
.smartlink-table .table-actions > :is(button, a) { color: var(--app-ink); background: var(--insight-surface); border: 1px solid var(--insight-line); padding: 7px 9px; border-radius: 7px; font-size: 12px; }
.smartlink-table .table-actions > [data-delete] { color: var(--app-danger); }
.smartlink-table .table-actions > :is(button, a):hover { background: var(--insight-fill); }
.smartlink-table .table-empty { padding: 25px; color: var(--insight-muted); }
.smartlink-board .board-footer { margin: 0; border-top: 1px solid var(--insight-line); padding: 14px 21px; }

.insight-heading { margin-bottom: 13px; }
.insight-heading p { margin: 5px 0 0; }
.insight-status:empty { display: none; }
.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.insight-card {
  min-width: 0;
  padding: 19px;
  border: 1px solid var(--insight-line);
  border-radius: 17px;
  background: var(--insight-surface);
  box-shadow: var(--insight-shadow);
}
.insight-card h3 { margin: 0 0 13px; font-size: 14px; letter-spacing: -.02em; }
.insight-trend { grid-column: 1 / -1; }
.insight-totals { display: flex; flex-wrap: wrap; gap: 12px 26px; margin-bottom: 12px; }
.insight-totals span { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; color: var(--insight-muted); font-size: 13px; }
.insight-totals span::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--insight-red); }
.insight-totals span:nth-child(2)::before { background: var(--insight-blue); }
.insight-totals strong { color: var(--app-ink); font-size: 17px; }
.insight-trend canvas { display: block; width: 100%; height: 168px; }
.insight-trend details { margin-top: 9px; color: var(--insight-muted); font-size: 12px; }
.insight-trend summary { cursor: pointer; }
.insight-day-scroll { max-height: 200px; overflow: auto; margin-top: 8px; }
.insight-day-scroll table { width: 100%; border-collapse: collapse; text-align: left; }
.insight-day-scroll :is(td, th) { padding: 7px 4px; border-bottom: 1px solid var(--insight-line); }
.insight-ranking { list-style: none; padding: 0; margin: 0; }
.insight-ranking li { display: grid; grid-template-columns: 1fr auto; gap: 4px 9px; align-items: center; margin: 0 0 11px; font-size: 13px; }
.insight-ranking strong { font-variant-numeric: tabular-nums; }
.insight-track { grid-column: 1 / -1; height: 5px; border-radius: 10px; background: var(--insight-fill); overflow: hidden; }
.insight-track span { display: block; height: 100%; border-radius: inherit; }
.dashboard-page .smartlink-board :is(button, a, input, select):focus-visible,
.dashboard-page .dashboard-insights :is(summary, select):focus-visible { outline: 2px solid var(--insight-blue); outline-offset: 2px; }

@media (max-width: 760px) {
  .dashboard-page main { margin-top: 28px; }
  .insight-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .dashboard-page .stats { grid-template-columns: 1fr 1fr; }
  .dashboard-page .stat { padding: 14px; }
  .dashboard-page .stat b { font-size: 26px; }
  .board-heading, .board-toolbar { padding-inline: 13px; }
  .board-toolbar input { width: 100%; }
  .board-toolbar select { width: auto; flex: 1 1 100px; }
  .dashboard-page .board-toolbar #newLink { padding-inline: 8px; }
  .smartlink-table th:first-child { position: sticky; left: 0; z-index: 1; min-width: 188px; max-width: 188px; background: var(--insight-surface); box-shadow: 1px 0 var(--insight-line); }
}

.smartlink-board [hidden], .dashboard-insights [hidden] { display: none; }
