:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-muted: #f0f4ff;
  --text: #151a2d;
  --muted: #667085;
  --line: #e4e8f1;
  --primary: #3b63f2;
  --primary-strong: #2446bb;
  --accent: #7c3aed;
  --warning: #f97316;
  --danger: #c93636;
  --shadow: 0 18px 42px rgba(26, 32, 57, 0.08);
  --radius: 8px;
  --topbar-height: 68px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  padding: 12px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(221, 227, 234, 0.74);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.75rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 0.94rem;
}

.nav-links a {
  padding: 8px 4px;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--primary);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(236px, 280px) minmax(0, 1fr);
  gap: 24px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 48px) 56px;
}

.filter-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--topbar-height) - 48px);
  overflow: auto;
  padding: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(228, 232, 241, 0.96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-heading,
.drawer-header,
.results-header,
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading p {
  margin: 0;
  font-weight: 800;
}

.filter-group {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.filter-group:first-child {
  border-top: 0;
}

.filter-group legend,
.filter-group label:first-child {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
}

.filter-options {
  display: grid;
  gap: 8px;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--muted);
  font-size: 0.9rem;
}

.check-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.filter-select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.content-area {
  min-width: 0;
}

.command-center {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 20px;
}

.intro-copy {
  padding: clamp(20px, 4vw, 34px);
  background: #fff;
  border: 1px solid rgba(228, 232, 241, 0.96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.intro-copy p:last-child,
.data-status p {
  max-width: 780px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.signal-board {
  position: relative;
  overflow: hidden;
  min-height: 0;
  padding: 20px;
  background: linear-gradient(135deg, #1e2b71, #4f46e5 58%, #7c3aed);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.signal-visual {
  position: relative;
  height: 160px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
}

.node,
.beam {
  position: absolute;
  display: block;
}

.node {
  width: 26px;
  height: 26px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: #3ed3ad;
}

.node-a {
  top: 24px;
  left: 26px;
}

.node-b {
  top: 86px;
  left: 92px;
  background: #82a2ff;
}

.node-c {
  top: 34px;
  right: 80px;
  background: #ffc26d;
}

.node-d {
  right: 26px;
  bottom: 24px;
  background: #ff8c7a;
}

.beam {
  height: 3px;
  background: rgba(255, 255, 255, 0.42);
  transform-origin: left center;
}

.beam-a {
  top: 52px;
  left: 48px;
  width: 96px;
  transform: rotate(34deg);
}

.beam-b {
  top: 92px;
  left: 118px;
  width: 128px;
  transform: rotate(-24deg);
}

.beam-c {
  right: 48px;
  bottom: 48px;
  width: 82px;
  transform: rotate(28deg);
}

.sync-metrics {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.sync-metrics div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.sync-metrics dt {
  color: rgba(255, 255, 255, 0.66);
}

.sync-metrics dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.search-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 0 20px;
  background: var(--surface);
  border: 1px solid #d9e0ef;
  border-radius: var(--radius);
  box-shadow: 0 14px 30px rgba(26, 32, 57, 0.08);
}

.search-box span {
  color: var(--muted);
  font-size: 1.3rem;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.select-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.select-label select {
  min-height: 38px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

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

.metric-card {
  min-height: 94px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
}

.metric-card.urgent strong {
  color: var(--warning);
}

.active-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  margin: 6px 0 14px;
}

.filter-chip,
.tag,
.status-badge,
.deadline-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 800;
}

.filter-chip {
  gap: 6px;
  color: var(--primary-strong);
  background: #e8edff;
}

.filter-chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.results-header {
  margin: 16px 0;
}

.results-header.compact {
  margin-top: 26px;
}

.results-header h2,
.data-status h2 {
  margin: 0;
  font-size: 1.35rem;
}

.results-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.contest-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  min-height: 260px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px 0 8px;
}

.pagination-bar span {
  min-width: 72px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

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

.contest-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 330px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(26, 32, 57, 0.06);
  animation: fadeIn 180ms ease both;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.contest-card:hover,
.contest-card:focus-within {
  border-color: rgba(49, 87, 213, 0.42);
  box-shadow: 0 18px 42px rgba(26, 32, 57, 0.12);
  transform: translateY(-3px);
}

.card-topline,
.card-footer,
.detail-actions,
.meta-grid,
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-topline {
  justify-content: space-between;
  margin-bottom: 12px;
}

.category-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.card-title {
  margin: 0 0 8px;
  font-size: 1.06rem;
  line-height: 1.35;
}

.card-title button {
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.card-summary {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  min-height: 74px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.meta-grid {
  flex-wrap: wrap;
  align-items: stretch;
  margin: 0 0 12px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 9px;
  background: #f7f9ff;
  border: 1px solid #e8edf2;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.82rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.tag {
  color: #3154c9;
  background: var(--surface-muted);
}

.status-badge {
  color: #fff;
  background: var(--accent);
}

.status-badge.upcoming {
  background: var(--primary);
}

.status-badge.urgent {
  background: var(--warning);
  animation: pulse 1.8s ease-in-out infinite;
}

.status-badge.closed {
  background: #778392;
}

.deadline-badge {
  color: var(--warning);
  background: #fff2e8;
}

.deadline-badge.closed {
  color: #5e6977;
  background: #eef1f4;
}

.card-footer {
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.link-button,
.primary-button,
.outline-button,
.ghost-button,
.save-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.primary-button,
.link-button {
  color: #fff;
  background: var(--primary);
}

.primary-button:hover,
.link-button:hover {
  background: var(--primary-strong);
}

.outline-button {
  color: var(--primary);
  background: #fff;
  border-color: rgba(49, 87, 213, 0.36);
}

.ghost-button {
  color: var(--muted);
  background: transparent;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  color: var(--primary);
  background: #eef2ff;
}

.text-button {
  padding: 0;
  color: var(--primary);
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.save-button {
  min-width: 42px;
  padding: 0 10px;
  color: var(--muted);
  background: #fff;
  border-color: var(--line);
}

.save-button.is-saved {
  color: var(--primary);
  background: #e8edff;
  border-color: #bac8ff;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--text);
  background: #fff;
  border-color: var(--line);
}

.mobile-filter-trigger,
.mobile-only {
  display: none;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  text-align: center;
  background: #fff;
  border: 1px dashed #b8c3cf;
  border-radius: var(--radius);
}

.empty-state.compact {
  min-height: 150px;
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.data-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 22px;
  margin-top: 30px;
  padding: 24px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.recommendation-section,
.saved-section,
.admin-section {
  margin-top: 26px;
}

.mini-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mini-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 176px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(21, 32, 43, 0.05);
}

.mini-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.mini-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.mini-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.saved-hide-toggle {
  min-width: max-content;
}

.notification-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.notification-panel strong {
  margin-right: 8px;
}

.admin-section {
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.admin-card {
  padding: 16px;
  background: #f7f9fb;
  border: 1px solid #e8edf2;
  border-radius: var(--radius);
}

.admin-card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-list li {
  display: grid;
  gap: 4px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.admin-list strong,
.admin-list span,
.admin-list small {
  overflow-wrap: anywhere;
}

.admin-list span,
.admin-list small,
.form-note {
  color: var(--muted);
}

.quick-form {
  display: grid;
  gap: 10px;
}

.quick-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.quick-form input {
  min-height: 42px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.form-note {
  margin: 12px 0 0;
  line-height: 1.5;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: #f7f9fb;
  border: 1px solid #e8edf2;
  border-radius: var(--radius);
}

.status-list strong {
  color: var(--primary);
  white-space: nowrap;
}

.status-list span {
  color: var(--muted);
  text-align: right;
}

.filter-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.filter-drawer.is-open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.drawer-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: 88vh;
  overflow: auto;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  transform: translateY(0);
  animation: drawerIn 180ms ease;
}

.full-width {
  width: 100%;
}

.detail-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: 88vh;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.52);
}

.detail-card {
  padding: clamp(18px, 4vw, 30px);
  background: #fff;
}

.detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin: 10px 0 8px;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  line-height: 1.12;
}

.detail-header p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.detail-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 16px;
}

.detail-sections {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 20px;
  margin-top: 20px;
}

.detail-section {
  padding: 16px;
  background: #f7f9fb;
  border: 1px solid #e8edf2;
  border-radius: var(--radius);
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.detail-section p,
.detail-section li {
  color: var(--muted);
  line-height: 1.65;
}

.detail-section ul {
  margin: 0;
  padding-left: 18px;
}

.close-dialog {
  align-self: start;
}

.skeleton-card {
  gap: 12px;
}

.skeleton {
  display: block;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eef2f6, #f8fafc, #eef2f6);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}

.skeleton.line {
  height: 16px;
}

.skeleton.line.short {
  width: 36%;
}

.skeleton.line.medium {
  width: 68%;
}

.skeleton.block {
  height: 150px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 5px rgba(214, 95, 33, 0.12);
  }
}

@keyframes drawerIn {
  from {
    transform: translateY(18px);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 1180px) {
  .contest-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 920px) {
  .nav-links,
  .desktop-filter {
    display: none;
  }

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

  .mobile-filter-trigger,
  .mobile-only {
    display: inline-flex;
  }

  .command-center,
  .data-status,
  .detail-sections,
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding-inline: 14px;
  }

  .workspace {
    padding: 16px 12px 40px;
  }

  .command-center {
    gap: 12px;
  }

  .signal-board {
    min-height: 238px;
  }

  .search-toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    align-items: stretch;
  }

  .select-label {
    flex: 1;
    min-width: 0;
  }

  .contest-grid,
  .overview-grid,
  .mini-card-grid {
    grid-template-columns: 1fr;
  }

  .contest-card {
    min-height: 0;
  }

  .results-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .notification-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-header {
    grid-template-columns: 1fr;
  }

  .close-dialog {
    justify-self: end;
    order: -1;
  }

  .status-list li {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-list span {
    text-align: left;
  }
}
