:root {
  color-scheme: dark;
  --bg: #070a12;
  --bg-raised: #0b101b;
  --surface: #101826;
  --surface-2: #141f2f;
  --surface-3: #1a2638;
  --text: #eef4ff;
  --muted: #9aa8bc;
  --subtle: #728096;
  --line: #253246;
  --line-soft: rgba(148, 163, 184, 0.16);
  --cyan: #2dd4bf;
  --blue: #60a5fa;
  --rose: #fb7185;
  --amber: #fbbf24;
  --green: #4ade80;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #0a0f19;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e11d48;
  color: #fff;
  font-weight: 900;
}

.brand h1,
.brand p,
.dashboard-head h2,
.dashboard-head p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
  line-height: 1.1;
}

.brand p {
  margin-top: 4px;
  color: var(--subtle);
  font-size: 13px;
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line-soft);
}

.note-panel {
  margin-top: auto;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
}

.note-label {
  display: block;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.note-panel strong {
  display: block;
  margin: 6px 0;
  color: var(--cyan);
  font-size: 28px;
}

.note-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.dashboard-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  min-height: 132px;
  padding: 24px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
}

.title-block {
  max-width: 740px;
}

.eyebrow {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.dashboard-head h2 {
  margin-top: 6px;
  font-size: 34px;
  line-height: 1.1;
}

.lead {
  margin-top: 10px !important;
  color: var(--muted);
  font-size: 15px;
}

.head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.external-link,
.period-pill,
.counter {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.external-link {
  color: var(--text);
}

.external-link:hover {
  border-color: var(--cyan);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.insight-card,
.panel {
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 132px;
  padding: 18px;
}

.metric-card .label,
.insight-card .label {
  color: var(--muted);
  font-size: 13px;
}

.metric-card .value {
  display: block;
  margin-top: 12px;
  color: var(--text);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.metric-card .hint,
.insight-card .hint {
  margin-top: 10px;
  color: var(--subtle);
  font-size: 13px;
}

.metric-card.accent-teal {
  border-top: 4px solid var(--cyan);
}

.metric-card.accent-blue {
  border-top: 4px solid var(--blue);
}

.metric-card.accent-rose {
  border-top: 4px solid var(--rose);
}

.metric-card.accent-amber {
  border-top: 4px solid var(--amber);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.insight-card {
  min-height: 104px;
  padding: 16px;
}

.insight-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.15;
}

.insight-card[data-tone="green"] strong {
  color: var(--green);
}

.insight-card[data-tone="blue"] strong {
  color: var(--blue);
}

.insight-card[data-tone="rose"] strong {
  color: var(--rose);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.panel h3 {
  margin-top: 4px;
  font-size: 20px;
}

.video-panel {
  min-width: 0;
}

.filters {
  display: grid;
  grid-template-columns: auto minmax(230px, 1fr) 150px 180px 42px;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  align-self: end;
  min-height: 42px;
  padding: 3px;
  border-radius: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

.segment {
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.segment.active {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 800;
}

.field {
  display: grid;
  gap: 5px;
}

.field span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text);
  padding: 0 11px;
}

.field input::placeholder {
  color: #64748b;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(45, 212, 191, 0.22);
  border-color: var(--cyan);
}

.icon-button {
  width: 42px;
  height: 42px;
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--cyan);
}

.table-wrap {
  position: relative;
  max-height: calc(100vh - 330px);
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0d1422;
  color: var(--subtle);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.data-table th[data-sort] {
  cursor: pointer;
}

.data-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  padding: 13px 14px;
  vertical-align: middle;
  font-size: 14px;
}

.data-table tr:hover td {
  background: rgba(96, 165, 250, 0.06);
}

.date-cell {
  min-width: 130px;
}

.date-cell strong {
  display: block;
}

.date-cell span,
.video-link span {
  display: block;
  color: var(--subtle);
  font-size: 12px;
  margin-top: 2px;
}

.metric-number {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.views-high {
  color: var(--rose);
}

.video-link {
  max-width: 310px;
  display: block;
  color: var(--blue);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.video-link:hover {
  text-decoration: underline;
}

.loader-row {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
}

.sentinel {
  height: 1px;
}

.side-column {
  display: grid;
  gap: 18px;
}

.month-list {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.month-item {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.month-item:focus-visible {
  outline: 2px solid rgba(45, 212, 191, 0.28);
  outline-offset: 4px;
}

.month-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 14px;
}

.month-name {
  font-weight: 780;
}

.month-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  border-radius: 8px;
  background: #0a0f19;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: 8px;
  background: var(--cyan);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--cyan);
}

.daily-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 18px 8px;
}

.mini-stat {
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
}

.mini-stat span {
  display: block;
  color: var(--subtle);
  font-size: 12px;
}

.mini-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.day-heatmap {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 5px;
  padding: 10px 18px 18px;
}

.day-cell {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 4px;
  background: #111827;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.day-cell.level-0 {
  background: #111827;
}

.day-cell.level-1 {
  background: #164e63;
}

.day-cell.level-2 {
  background: #0f766e;
}

.day-cell.level-3 {
  background: #0891b2;
}

.day-cell.level-4 {
  background: #f59e0b;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@media (max-width: 1240px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .side-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav-stack {
    grid-template-columns: repeat(4, 1fr);
  }

  .note-panel {
    margin-top: 0;
  }

  .workspace {
    padding: 16px;
  }

  .dashboard-head {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
  }

  .head-actions {
    justify-content: flex-start;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr)) 42px;
  }

  .search-field {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .dashboard-head h2 {
    font-size: 28px;
  }

  .lead {
    font-size: 14px;
  }

  .external-link,
  .period-pill {
    width: 100%;
    justify-content: flex-start;
    white-space: normal;
  }

  .metric-grid,
  .side-column,
  .daily-summary {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .search-field {
    grid-column: auto;
  }

  .icon-button {
    width: 100%;
  }

  .nav-stack {
    grid-template-columns: repeat(2, 1fr);
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  .data-table {
    min-width: 0;
  }

  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    padding: 12px;
    border-bottom: 1px solid var(--line-soft);
  }

  .data-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    min-height: 34px;
    padding: 8px 0;
    border-bottom: 0;
    text-align: right;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--subtle);
    font-size: 12px;
    font-weight: 750;
    text-align: left;
    text-transform: uppercase;
  }

  .date-cell strong,
  .date-cell span {
    text-align: right;
  }

  .video-link {
    max-width: 210px;
    text-align: right;
  }
}
