.aggregation-btn {
  background: #1e293b;
  color: #d4dde8;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
}
.aggregation-btn:hover {
  background: #334155;
}
.aggregation-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
* { box-sizing: border-box; }
html,body { height: 100%; }
body {
  margin: 0;
  padding: 24px;
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  background: #0a0e1a;
  color: #f0f4f8;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: 0 18px;
}

h1,h2,h3 { margin: 8px 0; text-align: center; line-height:1.15; color:#ffffff; }
h1 { font-size: 2.2rem; }
h3 { font-size: 1.3rem; }
p { color: #d4dde8; margin: 6px 0; text-align:center; }
a { color: #60a5fa; text-decoration: none; }
a:hover { color: #93c5fd; text-decoration: underline; }

.top-box {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.15);
  padding: 14px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 18px auto 4px;
  max-width: fit-content;
}
.controls label { display:block; font-size:13px; color:#d4dde8; margin-bottom:6px; font-weight: 600; }
.controls input[type="text"]{
  min-width: 240px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #1e293b;
  color: #f0f4f8;
  outline: none;
  font-size: 14px;
}
.controls input[type="text"]:focus {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
  border-color: #60a5fa;
}

button {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #1e293b;
  color: #f0f4f8;
  cursor: pointer;
  font-weight: 600;
  transition: all .15s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  font-size: 14px;
}
button:hover {
  transform: translateY(-1px);
  background: #334155;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
button.primary {
  background: #2563eb;
  color: #fff;
  border: 1px solid #3b82f6;
}
button.primary:hover {
  background: #3b82f6;
}

#statusBar { margin-left: 6px; color: #93c5fd; font-weight:700; transition:opacity .6s; }
#searchMessage { color:#86efac; font-weight:700; margin-left:8px; }

.filters { display:none; gap:8px; margin-top:12px; justify-content:center; flex-wrap: wrap; }
.filters button {
  background:#1e293b;
  color:#d4dde8;
  border:1px solid rgba(148, 163, 184, 0.2);
  padding:8px 12px;
  border-radius:8px;
}
.filters button.active {
  background: #2563eb;
  color:#ffffff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.card-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  margin-top: 16px;
}
@media (max-width:1100px) { .card-grid { grid-template-columns: repeat(3, minmax(220px,1fr)); } }
@media (max-width:820px)  { .card-grid { grid-template-columns: repeat(2, minmax(200px,1fr)); } }
@media (max-width:520px)  { .card-grid { grid-template-columns: repeat(1, 1fr); } }

.card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.15);
  padding: 16px;
  border-radius: 12px;
  min-height: 96px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.card h4 { color:#cbd5e1; font-size:13px; margin:0; text-transform: uppercase; letter-spacing: 0.5px; }
.card p  { color:#ffffff; font-size:20px; font-weight:800; margin:0; }

.charts {
  display: grid;
  gap: 18px;
  margin-top: 20px;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width:960px) { .charts { grid-template-columns: 1fr; } }

.chart-card {
  background: rgba(30, 41, 59, 0.6);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height: 460px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.chart-card.chart-full {
  grid-column: 1 / 3;
}
@media (max-width:960px) {
  .chart-card.chart-full {
    grid-column: 1;
  }
}

.canvas-wrap {
  width:100%;
  height:360px;
  position:relative;
  border-radius:8px;
  overflow:hidden;
  background: rgba(15, 23, 42, 0.4);
  display:flex;
  align-items:center;
  justify-content:center;
}

.canvas-wrap canvas, canvas {
  display:block;
  width:100% !important;
  height:100% !important;
  max-width:100%;
}

.center { display:flex; justify-content:center; gap: 8px}
.center button { margin-top:4px; }

.pie-block { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding-top:8px; }
.pie-block canvas { max-width:360px; max-height:260px; border-radius:8px; background:transparent; }

.table-wrap { display:flex; justify-content:center; width:100%; }
.table-wrap table {
  border-collapse: collapse;
  width: 360px;
  max-width: 100%;
  background: rgba(15, 23, 42, 0.6);
  color: #f0f4f8;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.period-analysis-table {
  width: 100%;
  max-width: 100%;
  min-width: 800px;
}

.period-analysis-wrapper {
  overflow-x: auto;
  margin: 12px 0;
}

.distribution-bar-container {
  display: flex;
  width: 200px;
  height: 20px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.distribution-segment {
  height: 100%;
  transition: opacity 0.2s;
}

.distribution-segment:hover {
  opacity: 0.8;
}
.table-wrap th {
  background: rgba(30, 41, 59, 0.8);
  padding:12px;
  font-weight:700;
  color:#ffffff;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.table-wrap td {
  padding:10px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 14px;
}

.heatmap {
  display:flex;
  gap:10px;
  justify-content:center;
  align-items:flex-start;
  padding:8px 0;
  flex-wrap: wrap;
}
.heat-col { display:flex; flex-direction:column; align-items:center; gap:8px; }
.heat-label {
  color:#cbd5e1;
  font-size:12px;
  margin-bottom:6px;
  font-weight: 600;
  text-transform: uppercase;
  text-align: center;
  min-width: 50px;
}
.heat-cell {
  width:50px;
  height:50px;
  border-radius:8px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  font-weight:700;
  transition: all .12s ease;
  border: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 16px;
}
.heat-cell:hover {
  transform: translateY(-3px) scale(1.05);
  cursor:pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.heat-cell.small {
  width: 38px;
  height: 38px;
  font-size: 13px;
}
.heat-label.small {
  font-size: 10px;
  min-width: 38px;
}

#posts { margin-top:20px; }
.post {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.15);
  padding:14px;
  border-radius:10px;
  margin-bottom:10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.post .small { color:#cbd5e1; font-size:13px; }

.export-row {
  display:flex;
  justify-content:space-between;
  align-items: center;
  gap:12px;
  margin-top:10px;
  flex-wrap: wrap;
}
.export-row button {
  background:#2563eb;
  color:#fff;
  border-radius:8px;
  padding:8px 12px;
  border: 1px solid #3b82f6;
}

.post-filters {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-level {
  background: #1e293b !important;
  color: #d4dde8 !important;
  border: 1px solid rgba(148, 163, 184, 0.2) !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
}
.filter-level.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.hidden { display:none !important; }
.small { font-size:13px; color:#cbd5e1; }
.center-text { text-align:center; }

html { scroll-behavior: smooth; }

.filter-topic {
  background: #1e293b !important;
  color: #d4dde8 !important;
  border: 1px solid rgba(148, 163, 184, 0.2) !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
}
.filter-topic.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
