:root {
  --bg: #0b1220;
  --bg-soft: #111827;
  --surface: #151f32;
  --surface-2: #1e293b;
  --text: #e5eefb;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-soft: #1d4ed8;
  --growth: #14532d;
  --growth-text: #86efac;
  --decline: #450a0a;
  --decline-text: #fca5a5;
  --popular: #1e3a5f;
  --popular-text: #93c5fd;
  --border: #243044;
  --radius: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: min(1280px, calc(100% - 1.5rem));
  margin: 0 auto;
}

.header {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.95);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header--terminal {
  box-shadow: var(--shadow);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.header-search {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.search-input,
.filter-input,
.controls select,
.notification-form input,
.notification-form select,
.modal__content input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  width: 100%;
}

.search-input--header {
  min-width: 0;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 30;
  max-height: 280px;
  overflow-y: auto;
}

.search-suggestions li a,
.search-suggestions__empty {
  display: block;
  padding: 0.55rem 0.85rem;
  color: var(--text);
}

.search-suggestions li a:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-soft);
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.user-chip__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.user-chip__email {
  font-size: 0.9rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widgets-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding: 1.25rem 0;
}

.widget {
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.widget--growth {
  background: linear-gradient(180deg, var(--growth), #0f2918);
}

.widget--decline {
  background: linear-gradient(180deg, var(--decline), #2a0a0a);
}

.widget--popular {
  background: linear-gradient(180deg, var(--popular), #12243d);
}

.widget__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.widget--growth .widget__title {
  color: var(--growth-text);
}

.widget--decline .widget__title {
  color: var(--decline-text);
}

.widget--popular .widget__title {
  color: var(--popular-text);
}

.widget-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.widget-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
}

.widget-list li:last-child {
  border-bottom: none;
}

.widget-list__empty {
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.panel__header--stack {
  align-items: flex-start;
  flex-direction: column;
}

.panel h2,
.panel h3 {
  margin: 0;
}

.panel__note {
  color: var(--muted);
  margin: 0 0 1rem;
}

.listing-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.75rem;
}

.listing-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.filters-accordion {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
}

.filters-accordion__summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}

.filters-accordion__summary::-webkit-details-marker {
  display: none;
}

.filters-accordion[open] .filters-accordion__summary {
  margin-bottom: 0.75rem;
}

.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
}

.table-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 140px;
}

.filter-search {
  flex: 1 1 200px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap--scroll {
  border: 1px solid var(--border);
  border-radius: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.data-table th,
.data-table td {
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.data-table th:hover {
  color: #fff;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.loading {
  color: var(--muted);
  text-align: center;
}

.link-btn {
  color: #93c5fd;
  font-weight: 600;
}

.pct--up {
  color: var(--growth-text);
}

.pct--down {
  color: var(--decline-text);
}

.star-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.star-btn--active {
  color: #fbbf24;
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}

.hero {
  padding: 2rem 0 1rem;
}

.hero--compact {
  padding-top: 1.25rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.hero__subtitle {
  margin: 0;
  color: var(--muted);
}

.controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.chart-wrap {
  position: relative;
  height: 380px;
  width: 100%;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1.2rem 0 2rem;
  color: var(--muted);
  margin-top: 1rem;
  text-align: center;
}

.footer p {
  margin: 0 0 0.5rem;
}

.footer a {
  color: #93c5fd;
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
  max-width: calc(100% - 2rem);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal__content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
}

.modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal__hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-error {
  color: #fca5a5;
  margin: 0;
}

.notification-form {
  display: grid;
  gap: 0.85rem;
  max-width: 420px;
}

.notification-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
}

.status-text {
  color: var(--muted);
  font-size: 0.95rem;
}

.nav {
  display: flex;
  gap: 1rem;
}

.nav__link {
  color: var(--muted);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
}

.nav__link--active,
.nav__link:hover {
  color: #fff;
  background: var(--surface-2);
}

.error-page {
  text-align: center;
  padding: 2rem 1.2rem;
}

@media (max-width: 768px) {
  .header__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .header-search {
    max-width: none;
    order: 3;
    width: 100%;
  }

  .header-auth {
    width: 100%;
    justify-content: flex-end;
  }

  .widgets-grid {
    grid-template-columns: 1fr;
  }

  .listing-filters {
    grid-template-columns: 1fr;
  }

  .filters-accordion:not([open]) .listing-filters {
    display: none;
  }

  .filter-input,
  .listing-filters select,
  .table-filters select,
  .table-filters input {
    min-height: 44px;
    font-size: 16px;
  }

  .table-filters {
    flex-direction: column;
  }

  .table-filters label,
  .filter-search {
    width: 100%;
    min-width: 0;
  }

  .data-table th,
  .data-table td {
    padding: 0.65rem 0.55rem;
    font-size: 0.9rem;
  }

  .star-btn {
    width: 48px;
    height: 48px;
  }

  .chart-wrap {
    height: 280px;
  }

  .user-chip__email {
    display: none;
  }

  .container {
    width: calc(100% - 1rem);
  }
}
