:root {
  --ink: #111114;
  --text: #252333;
  --muted: #666174;
  --subtle: #817b8c;
  --line: #ded9f0;
  --line-strong: #cac3df;
  --surface: #ffffff;
  --surface-muted: #fbfaff;
  --canvas: #f7f6ff;
  --purple: #4b2cf5;
  --purple-strong: #3517d4;
  --purple-soft: #ece8ff;
  --purple-soft-pressed: #e1dbff;
  --lavender: #b9aef5;
  --amber: #ffb800;
  --poster-placeholder: #eeeaf5;
  --green: #247544;
  --green-soft: #e8f6ec;
  --green-line: #83b991;
  --red: #a12c2c;
  --red-soft: #fbe9e9;
  --shadow: rgba(17, 17, 20, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@font-face {
  font-family: "MaterialCommunityIcons";
  font-style: normal;
  font-weight: normal;
  src: url("assets/MaterialCommunityIcons.ttf") format("truetype");
}

:root[data-theme="dark"] {
  --ink: #f7f4ff;
  --text: #f3f0ff;
  --muted: #c7beda;
  --subtle: #a89dbd;
  --line: #3a344b;
  --line-strong: #514967;
  --surface: #1b1924;
  --surface-muted: #242130;
  --canvas: #111018;
  --purple: #9d86ff;
  --purple-strong: #d9d0ff;
  --purple-soft: #2d2357;
  --purple-soft-pressed: #3a2b72;
  --lavender: #6e5ab8;
  --amber: #ffc84d;
  --poster-placeholder: #302b3d;
  --green: #78d69a;
  --green-soft: #143521;
  --green-line: #3c8454;
  --red: #ff8a8a;
  --red-soft: #401d22;
  --shadow: rgba(3, 3, 6, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 76px;
  padding: 10px clamp(18px, 4vw, 40px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand img {
  border-radius: 10px;
  height: 52px;
  width: 52px;
}

.eyebrow {
  color: var(--purple-strong);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 2px;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
  margin-bottom: 0;
}

h2 {
  color: var(--ink);
  font-size: 30px;
  line-height: 1.15;
  margin-bottom: 8px;
}

h3 {
  color: var(--ink);
  font-size: 18px;
  margin-bottom: 0;
}

main {
  margin: 0 auto;
  max-width: 1360px;
  padding: 26px clamp(18px, 4vw, 40px) 40px;
}

.header-actions,
.toolbar,
.panel-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.header-actions {
  flex-wrap: wrap;
}

.session-label {
  color: var(--muted);
  font-size: 14px;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 900;
  min-height: 40px;
  padding: 0 16px;
}

.primary-button {
  background: var(--purple);
  color: var(--surface);
}

.secondary-button,
.icon-button {
  background: var(--purple-soft);
  color: var(--purple-strong);
}

.secondary-button:hover,
.icon-button:hover {
  background: var(--purple-soft-pressed);
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
}

.signed-out {
  align-items: center;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--surface) 92%, var(--purple-soft)) 0%, var(--purple-soft) 62%, color-mix(in srgb, var(--amber) 22%, var(--surface)) 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  min-height: 360px;
  padding: clamp(24px, 6vw, 64px);
}

.intro-copy {
  max-width: 640px;
}

.intro-copy p:last-child {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.admin-shell {
  display: grid;
  gap: 20px;
}

.toolbar {
  min-height: 92px;
  position: relative;
}

.dashboard-lockup {
  align-items: center;
  color: var(--ink);
  display: flex;
  gap: 14px;
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.dashboard-lockup img {
  border-radius: 14px;
  height: 76px;
  width: 76px;
}

.dashboard-lockup span,
.dashboard-lockup strong {
  display: block;
  line-height: 1;
}

.dashboard-lockup span {
  color: var(--purple-strong);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.dashboard-lockup strong {
  color: var(--ink);
  font-size: 27px;
  margin-top: 4px;
}

.status-message {
  color: var(--muted);
  min-height: 22px;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px var(--shadow);
}

.metric {
  min-height: 112px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.metric strong {
  color: var(--ink);
  display: block;
  font-size: 32px;
  line-height: 1;
}

.metric small {
  color: var(--muted);
  display: block;
  margin-top: 10px;
}

.tab-bar {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  width: fit-content;
}

.tab-button {
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--purple-strong);
  cursor: pointer;
  font-weight: 900;
  min-height: 38px;
  min-width: 118px;
  padding: 0 18px;
}

.tab-button:hover {
  background: var(--purple-soft);
}

.tab-button.active {
  background: var(--purple);
  color: var(--surface);
}

.tab-panel.hidden {
  display: none;
}

.filter-bar {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
}

.filter-button {
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--purple-strong);
  cursor: pointer;
  font-weight: 900;
  min-height: 32px;
  min-width: 58px;
  padding: 0 10px;
}

.filter-button:hover {
  background: var(--purple-soft);
}

.filter-button.active {
  background: var(--purple);
  color: var(--surface);
}

.subtle-message {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: -4px 0 14px;
}

.content-grid {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.7fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.detail-panel {
  position: sticky;
  top: 96px;
}

.rankings-layout {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 0.7fr);
}

.rankings-header {
  align-items: flex-start;
}

.ranking-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ranking-detail-panel {
  position: sticky;
  top: 96px;
}

.panel-header {
  gap: 16px;
  margin-bottom: 16px;
}

input[type="search"] {
  background: var(--surface-muted);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  min-height: 38px;
  min-width: min(260px, 45vw);
  padding: 0 12px;
}

input[type="search"]::placeholder {
  color: var(--subtle);
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  table-layout: fixed;
  width: 100%;
}

th:nth-child(1),
td:nth-child(1) {
  width: 32%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 17%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 24%;
}

th:nth-child(4),
td:nth-child(4),
th:nth-child(5),
td:nth-child(5) {
  width: 13.5%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.seen-cell {
  white-space: nowrap;
}

.role-cell .pill-row {
  align-items: flex-start;
  flex-direction: column;
}

.role-cell .sign-in-methods {
  align-items: flex-start;
  flex-direction: row;
}

.sign-in-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.method-pill {
  background: var(--purple-soft);
  color: var(--purple-strong);
}

.method-pill {
  align-items: center;
  border: 1px solid var(--lavender);
  border-radius: 999px;
  display: inline-grid;
  font-size: 12px;
  font-weight: 900;
  gap: 5px;
  grid-template-columns: 16px auto;
  min-height: 24px;
  padding: 3px 7px;
  width: fit-content;
}

.method-icon {
  color: var(--purple-strong);
  display: block;
  font-family: "MaterialCommunityIcons";
  font-size: 16px;
  font-style: normal;
  font-weight: normal;
  height: 16px;
  line-height: 16px;
  text-rendering: auto;
  width: 16px;
}

.count-cell {
  white-space: nowrap;
}

.media-count {
  display: grid;
  gap: 4px;
  justify-items: stretch;
  line-height: 1.1;
  width: 62px;
}

.media-count-pill {
  align-items: center;
  background: var(--purple-soft);
  border: 1px solid var(--lavender);
  border-radius: 999px;
  color: var(--purple-strong);
  display: grid;
  grid-template-columns: 18px minmax(18px, 1fr);
  font-size: 13px;
  font-weight: 900;
  gap: 5px;
  justify-items: end;
  min-height: 24px;
  padding: 3px 7px;
  width: 100%;
}

.media-total {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--ink);
  margin-top: 4px;
  position: relative;
}

.media-total::before {
  background: var(--amber);
  content: "";
  height: 1px;
  left: 2px;
  position: absolute;
  right: 2px;
  top: -4px;
}

.media-icon {
  color: var(--purple-strong);
  display: block;
  flex: 0 0 auto;
  font-family: "MaterialCommunityIcons";
  font-size: 17px;
  font-style: normal;
  font-weight: normal;
  height: 18px;
  justify-self: start;
  line-height: 18px;
  text-rendering: auto;
  width: 18px;
}

.media-total-icon {
  border-radius: 4px;
  height: 16px;
  justify-self: start;
  width: 16px;
}

tr[data-user-id] {
  cursor: pointer;
}

tr[data-user-id]:hover,
tr.selected {
  background: var(--purple-soft);
}

.muted {
  color: var(--muted);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  align-items: center;
  background: var(--purple-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--purple-strong);
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  min-height: 24px;
  padding: 4px 8px;
}

.pill.outline-pill {
  border-color: var(--lavender);
}

.rank-pill {
  background: var(--amber);
  color: var(--ink);
}

.pill.good {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green);
}

.empty-state {
  color: var(--muted);
  line-height: 1.5;
}

.user-detail {
  display: grid;
  gap: 14px;
}

.detail-meta {
  display: grid;
  gap: 8px;
}

.detail-meta > div {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(68px, auto) minmax(0, 1fr);
}

.detail-meta strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.detail-meta > .detail-copy-row {
  grid-template-columns: minmax(68px, auto) minmax(0, 1fr) 32px;
}

.detail-panel .panel-header h3 {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy-button {
  align-items: center;
  background: var(--purple-soft);
  border: 1px solid var(--lavender);
  border-radius: 999px;
  color: var(--purple-strong);
  cursor: pointer;
  display: inline-grid;
  font-family: "MaterialCommunityIcons";
  font-size: 16px;
  font-style: normal;
  font-weight: normal;
  height: 28px;
  justify-content: center;
  line-height: 1;
  width: 28px;
}

.copy-button:hover {
  background: var(--purple-soft-pressed);
}

.copy-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.title-copy-button {
  flex: 0 0 auto;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card,
.ranking-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 69px minmax(0, 1fr);
  min-height: 130px;
  padding: 10px;
}

.ranking-card {
  cursor: pointer;
  min-height: 116px;
}

.ranking-card:hover,
.ranking-card.selected {
  background: var(--purple-soft);
  border-color: var(--lavender);
}

.item-card-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.poster,
.poster-placeholder {
  background: var(--poster-placeholder);
  border-radius: 8px;
  height: 104px;
  width: 69px;
}

.poster {
  display: block;
  object-fit: cover;
}

.poster-placeholder {
  align-items: center;
  color: var(--subtle);
  display: flex;
  font-size: 16px;
  font-weight: 900;
  justify-content: center;
}

.item-card h4,
.ranking-card strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
  margin: 0;
}

.item-card p,
.ranking-card .muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 0;
}

.item-notes {
  background: var(--surface-muted);
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  padding: 7px 9px;
}

.ranking-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  max-width: 620px;
}

.ranking-detail {
  display: grid;
  gap: 14px;
}

.ranking-detail-hero {
  display: grid;
  gap: 12px;
  grid-template-columns: 69px minmax(0, 1fr);
}

.ranking-detail-hero h4 {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
  margin: 8px 0 6px;
}

.ranking-user-groups {
  display: grid;
  gap: 14px;
}

.ranking-user-group {
  display: grid;
  gap: 8px;
}

.ranking-user-group h4 {
  align-items: center;
  color: var(--ink);
  display: flex;
  font-size: 14px;
  gap: 8px;
  margin: 0;
}

.ranking-user-group h4 span {
  background: var(--amber);
  border-radius: 999px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  min-width: 24px;
  padding: 3px 7px;
  text-align: center;
}

.ranking-user-row {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  padding: 10px;
}

.ranking-user-row strong {
  color: var(--ink);
  font-size: 14px;
}

.ranking-user-row span,
.ranking-user-row p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
}

.hidden {
  display: none;
}

@media (max-width: 1180px) {
  .dashboard-lockup {
    display: none;
  }
}

@media (max-width: 980px) {
  .metric-grid,
  .content-grid,
  .rankings-layout,
  .ranking-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel,
  .ranking-detail-panel {
    position: static;
  }

  .app-header,
  .header-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .tab-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .ranking-actions {
    justify-content: stretch;
    width: 100%;
  }

  .filter-bar {
    display: grid;
    flex: 1;
    grid-template-columns: repeat(3, 1fr);
  }

  .tab-button {
    min-width: 0;
    padding: 0 12px;
  }

  input[type="search"] {
    min-width: 100%;
    width: 100%;
  }
}
