@font-face {
  font-family: "Safiro";
  src: url("/static/fonts/safiro-medium-webfont.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f3ff;
  --bg-elevated: #ffffff;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-2: #f8f7ff;
  --primary: #8e7cff;
  --primary-strong: #6f5cff;
  --primary-soft: rgba(142, 124, 255, 0.12);
  --text: #18142b;
  --muted: #6d6790;
  --border: #dfdaf8;
  --border-strong: rgba(142, 124, 255, 0.28);
  --sidebar-bg: #fbfaff;
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --shadow: 0 18px 50px rgba(37, 25, 86, 0.08);
  --success-bg: rgba(39, 174, 96, 0.12);
  --success-text: #1f8f56;
  --warning-bg: rgba(255, 204, 122, 0.14);
  --warning-text: #9a6700;
  --danger-bg: rgba(255, 111, 145, 0.14);
  --danger-text: #b42354;
}

html[data-theme="dark"] {
  --bg: #090d18;
  --bg-elevated: #0f1525;
  --panel: rgba(15, 21, 37, 0.92);
  --panel-2: rgba(18, 27, 47, 0.98);
  --primary: #8e7cff;
  --primary-strong: #a798ff;
  --primary-soft: rgba(142, 124, 255, 0.14);
  --text: #eef0ff;
  --muted: #a7afcf;
  --border: rgba(142, 124, 255, 0.16);
  --border-strong: rgba(142, 124, 255, 0.34);
  --sidebar-bg: #07101e;
  --topbar-bg: rgba(7, 16, 30, 0.84);
  --shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
  --success-bg: rgba(39, 174, 96, 0.16);
  --success-text: #7df0b0;
  --warning-bg: rgba(255, 204, 122, 0.14);
  --warning-text: #ffe4a3;
  --danger-bg: rgba(255, 111, 145, 0.14);
  --danger-text: #ffc0cf;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family:
    "Work Sans",
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(
      circle at top center,
      rgba(142, 124, 255, 0.14),
      transparent 28%
    ),
    linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg) 100%);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.18s ease;
}

a:hover {
  color: var(--primary-strong);
}

button,
input,
select,
textarea {
  font: inherit;
}

img {
  max-width: 100%;
  display: block;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.num,
.digit,
.metric-value,
.metric-subvalue,
.pagination a,
.pagination span,
.badge-number,
input[type="date"],
input[type="number"] {
  font-family: "Safiro", sans-serif;
}

.fa-light,
.fal {
  font-weight: 300;
}

.justify-start {
  justify-content: start !important;
}

.justify-center {
  justify-content: center !important;
}

.border-none {
  border: none !important;
}

.menu-icon {
  flex-grow: 0;
  flex-shrink: 0;
  margin-right: 0.5rem;
  font-size: 1.25rem;
}

/* App shell */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 20px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
}

.brand .fa-chess-rook {
  color: var(--primary);
  font-size: 1.45rem;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 2rem;
  color: var(--text);
  border: 1px solid transparent;
  transition: 0.2s ease;
}

.side-nav a:hover,
.side-nav a.is-active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.danger:hover {
  background: rgba(255, 79, 122, 0.08) !important;
}

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

/* Topbar */

.topbar {
  position: sticky;
  z-index: 20;
}

.topbar-inner,
.content-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
}

.topbar-inner,
.main {
  width: min(1200px, 100%);
  margin: 0 auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-inner {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0px 28px 0px;
}

.topbar-filters {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar-filters-grid {
  display: grid;
  grid-template-columns: 160px 160px minmax(160px, 1fr) minmax(140px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.topbar-search-field {
  min-width: 0;
}

.topbar-filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .field label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.topbar .field input,
.topbar .field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}

@media (max-width: 1200px) {
  .topbar-inner {
    align-items: stretch;
    flex-direction: column;
  }

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

  .topbar-filter-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .topbar-filters-grid {
    grid-template-columns: 1fr;
  }

  .topbar-filter-actions .btn,
  .topbar-actions .btn,
  .topbar-actions .theme-toggle {
    width: 100%;
  }
}

.content-shell {
  padding: 28px 24px 48px;
}

.main {
  padding: 28px 24px 48px;
}
/* Page */

.subheader:not(:empty) {
  margin-bottom: 2.125rem;
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

.subheader-title {
  font-size: 1.375rem;
  font-weight: 500;
  margin: 0;
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
}

.subheader-title .small {
  font-weight: 400;
  color: #838383;
  margin-bottom: 0;
  font-size: 0.875rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.page-title h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.page-title p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

/* Drop down
.daily-chart-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.daily-topic-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 260px;
  max-width: 340px;
}

.daily-topic-select-icon {
  position: absolute;
  left: 0.9rem;
  z-index: 2;
  pointer-events: none;
  font-size: 0.95rem;
  color: rgba(140, 120, 200, 0.9);
}

.daily-topic-select-caret {
  position: absolute;
  right: 0.9rem;
  z-index: 2;
  pointer-events: none;
  font-size: 0.85rem;
  color: var(--muted-color, #7a7396);
  transition:
    transform 0.18s ease,
    color 0.18s ease;
}

.daily-topic-select-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  height: 44px;
  padding: 0 2.5rem 0 2.55rem;
  border-radius: 14px;
  border: 1px solid rgba(140, 120, 200, 0.18);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.88),
    rgba(248, 243, 255, 0.96)
  );
  color: var(--text-color, #1c1730);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
  cursor: pointer;
}

.daily-topic-select-input:hover {
  border-color: rgba(140, 120, 200, 0.28);
  box-shadow:
    0 14px 28px rgba(123, 97, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.daily-topic-select-input:focus {
  outline: none;
  border-color: rgba(168, 85, 247, 0.45);
  box-shadow:
    0 0 0 4px rgba(207, 124, 255, 0.12),
    0 14px 28px rgba(123, 97, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.daily-topic-select-wrap:focus-within .daily-topic-select-caret {
  transform: translateY(1px);
  color: rgba(168, 85, 247, 0.95);
}

.daily-topic-select-input option {
  color: #1c1730;
  background: #ffffff;
}

html[data-theme="dark"] .daily-topic-select-icon {
  color: rgba(207, 124, 255, 0.92);
}

html[data-theme="dark"] .daily-topic-select-caret {
  color: #a7afcf;
}

html[data-theme="dark"] .daily-topic-select-input {
  border-color: rgba(207, 124, 255, 0.2);
  color: #eef0ff;
}

html[data-theme="dark"] .daily-topic-select-input option {
  color: #eef0ff;
  background: #11182d;
}

@media (max-width: 768px) {
  .daily-topic-select-wrap {
    min-width: 100%;
    max-width: 100%;
  }
}
 */
/* Buttons */

.btn,
.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 14px;
  padding: 11px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition:
    transform 0.16s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
}

.btn-ghost,
.btn-soft {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  color: var(--text);
}

/* Cards / panels */

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
}

.panel {
  padding: 22px;
}

.card-transparent {
  background-color: rgba(255, 255, 255, 0);
  border: none;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.metric-card {
  padding: 20px;
}

.metric-label {
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 12px;
}

.metric-value {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.metric-subvalue {
  margin-top: 10px;
  color: var(--success-text);
  font-weight: 700;
}

.section-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  margin-top: 18px;
}

.section-grid-full {
  margin-top: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-size: 1.1rem;
}

.panel-title .muted {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

/* Charts */
.topics-highcharts-wrap,
.daily-stock-chart-wrap {
  width: 100%;
}

#topicsBarChart {
  width: 100%;
  height: 260px;
}

#dailyPostsStockChart {
  width: 100%;
  height: 420px;
}

.daily-chart-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.daily-topic-select {
  min-width: 280px;
}

.daily-topic-select label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.daily-topic-select select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}

.is-threat-row td {
  background: rgba(205, 92, 92, 0.06);
}

/* Filters */

.filters-panel {
  padding: 20px;
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.filters-panel form {
  display: grid;
  gap: 18px;
}

.filters-form,
.filters-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.05fr 0.9fr 1.35fr auto;
  gap: 14px;
  align-items: end;
}

.filters-grid--posts {
  grid-template-columns: 1fr 1fr 0.9fr 1.2fr 1fr auto;
}

.filter-summary-wrap {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 14px 0;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}

.filter-summary-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.filter-summary-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.filter-summary-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
}

.btn-sm {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.86rem;
}

.field {
  min-width: 0;
}

.field label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 48px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 78%, transparent);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  align-self: end;
}

/* Tables */

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  white-space: nowrap;
}

th a {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

tr:hover td {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.post-text {
  max-width: 720px;
  color: var(--muted);
  line-height: 1.5;
}

.empty-state {
  padding: 30px 20px;
  color: var(--muted);
  text-align: center;
}

/* Badges / chips */

.badge,
.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary-strong);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
  font-size: 0.9rem;
}

.topic-chip {
  margin: 0 8px 8px 0;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: transparent;
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: transparent;
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: transparent;
}

/* Lists */

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

.list-clean li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-clean li:last-child {
  border-bottom: 0;
}

/* Pagination */

.pagination {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 18px 20px;
}

.pagination a,
.pagination span {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
}

.pagination .is-active {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  color: #fff;
}

.pagination .ellipsis {
  border-color: transparent;
  background: transparent;
  min-width: auto;
  padding-inline: 4px;
}

/* Utilities */

.muted {
  color: var(--muted);
}

.user-total-post {
  padding-left: 2rem;
  font-size: 1rem;
  font-weight: 400;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.post-text-cell {
  min-width: 320px;
  max-width: 640px;
}

.post-text {
  color: var(--muted);
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}

.post-more-btn {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.post-more-btn:hover {
  color: var(--primary-strong);
}

.overview-kpi-list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 28px;
}

.overview-kpi-item {
  display: flex;
  align-items: center;
  gap: 18px;
  color: inherit;
  text-decoration: none;
  padding: 10px 4px;
  border-radius: 22px;
  transition:
    transform 0.18s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.overview-kpi-item:hover {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.overview-kpi-icon {
  flex: 0 0 auto;
}

.overview-kpi-icon-inner {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  font-size: 1.6rem;
}

.overview-kpi-item-threat .overview-kpi-icon-inner {
  background: rgba(205, 92, 92, 0.12);
  color: rgb(205, 92, 92);
}

.overview-kpi-content {
  min-width: 0;
}

.overview-kpi-value {
  margin: 0;
  font-size: clamp(2.1rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text);
}

.overview-kpi-label {
  margin: 6px 0 0;
  font-size: 1rem;
  color: var(--primary);
  font-weight: 500;
}

.overview-kpi-item-threat .overview-kpi-label {
  color: rgb(205, 92, 92);
}

.overview-kpi-meta {
  margin: 6px 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

@media (max-width: 760px) {
  .overview-kpi-list {
    grid-template-columns: 1fr;
  }
}

.topic-bar-chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

@media (max-width: 900px) {
  .topic-bar-chart-wrap {
    height: 320px;
  }
}

@media (max-width: 640px) {
  .topic-bar-chart-wrap {
    height: 420px;
  }
}

/* Responsive */

@media (max-width: 1100px) {
  .section-grid,
  .filters-form,
  .filters-grid,
  .filters-grid--posts {
    grid-template-columns: 1fr 1fr;
  }

  .filter-actions {
    grid-column: 1 / -1;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding-bottom: 10px;
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .topbar-inner,
  .content-shell {
    width: min(1200px, 100%);
  }
}

@media (max-width: 640px) {
  .topbar-inner,
  .content-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page-header,
  .table-header,
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .section-grid,
  .filters-form,
  .filters-grid,
  .filters-grid--posts,
  .cards {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    width: 100%;
  }

  .filter-actions .btn,
  .topbar-actions .btn,
  .topbar-actions .theme-toggle {
    width: 100%;
  }

  table {
    min-width: 760px;
  }
}
