:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #0b6d4f;
  --accent-soft: #e7f5ef;
  --border: #dde3eb;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, #eef4ff 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, #e8fff0 0%, transparent 35%),
    var(--bg);
}

.container {
  width: min(980px, 92vw);
  margin: 32px auto;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(23, 44, 70, 0.08);
  padding: 20px;
}

.auth-card {
  display: grid;
  gap: 12px;
}

.auth-card h2 {
  margin: 0;
}

.auth-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.auth-form input {
  flex: 1;
}

.error-message {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

.hero h1 {
  margin: 0;
  font-size: 28px;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.mode-switcher {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.mode-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border-radius: 14px;
  background: #eef2f7;
}

.mode-toggle-btn {
  background: transparent;
  color: #2f3f53;
}

.mode-toggle-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 16px rgba(11, 109, 79, 0.18);
}

.mode-panel {
  display: grid;
  gap: 16px;
}

.controls {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

label {
  font-weight: 600;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="text"],
input[type="date"],
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

.search-wrap {
  position: relative;
}

.companies-tooltip {
  position: relative;
}

.report-mode-tooltip {
  position: relative;
}

.tooltip-trigger {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8edf5;
  color: #2f3f53;
  font-size: 13px;
  font-weight: 700;
}

.tooltip-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(360px, 78vw);
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(23, 44, 70, 0.14);
  z-index: 20;
}

.tooltip-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
}

.tooltip-content {
  font-size: 13px;
  color: var(--text);
}

.tooltip-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.search-results {
  position: absolute;
  top: 74px;
  width: 100%;
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: none;
  z-index: 10;
}

.search-item {
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid #f2f4f7;
}

.search-item:hover {
  background: var(--accent-soft);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.date-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

button,
.actions a,
.report-actions a {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

button,
.actions a:not(.disabled),
.report-actions a:not(.disabled) {
  background: var(--accent);
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  background: #eef2f7;
  color: #2f3f53;
}

.period-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.preset {
  background: #eef2f7;
  color: #2f3f53;
}

.industry-preset {
  background: #eef2f7;
  color: #2f3f53;
}

.industry-preset-locked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f3f5f8;
  color: #7a8797;
  cursor: default;
}

.locked-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #e3e8ef;
  color: #536274;
  font-size: 11px;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}

.locked-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  display: none;
  width: max-content;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #243447;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  white-space: normal;
  box-shadow: 0 10px 20px rgba(23, 44, 70, 0.18);
  z-index: 20;
}

.locked-badge:hover .locked-tooltip,
.locked-badge:focus-visible .locked-tooltip {
  display: block;
}

.preset.active,
.industry-preset.active,
.other-period-btn.active {
  background: var(--accent);
  color: #fff;
}

.period-custom {
  margin-top: 2px;
}

.other-period-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #e8edf5;
  color: #2f3f53;
}

.date-range-panel {
  margin-top: 8px;
}

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

.section-intro {
  display: grid;
  gap: 6px;
  padding-top: 16px;
  padding-bottom: 16px;
  background: linear-gradient(135deg, #f9fcff 0%, #f5fbf7 100%);
}

.section-intro.hidden {
  display: none;
}

.section-label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0b6d4f;
}

.section-description {
  margin: 0;
  color: var(--muted);
}

.disabled {
  pointer-events: none;
  background: #c7ced8;
  color: #f8fafc;
}

.hidden {
  display: none !important;
}

.summary {
  margin-top: 0;
  color: #0d4b37;
  font-weight: 600;
}

.industry-loading {
  display: grid;
  gap: 16px;
}

.industry-loading-head,
.industry-loading-copy,
.industry-loading-list {
  display: grid;
  gap: 10px;
}

.industry-loading-stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(90deg, #edf2f7 0%, #f8fbfd 50%, #edf2f7 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.35s ease-in-out infinite;
}

.skeleton-title {
  height: 28px;
  width: min(360px, 75%);
}

.skeleton-heading {
  height: 20px;
  width: 180px;
}

.skeleton-text {
  height: 14px;
  width: 100%;
}

.skeleton-text-medium {
  width: 72%;
}

.skeleton-text-wide {
  width: 88%;
}

.skeleton-stat {
  height: 76px;
}

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

.stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: 14px 0 16px;
}

.report-actions {
  margin: 4px 0 16px;
}

.report-actions a:not(.disabled) {
  display: inline-flex;
  align-items: center;
}

.result-head h2,
.digest-block h3,
.digest-list-block h3,
.news-head h3 {
  margin-top: 0;
}

.posts-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.posts-tab {
  background: #eef2f7;
  color: #2f3f53;
}

.posts-tab.active {
  background: var(--accent);
  color: #fff;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fafcff;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.stat:hover {
  border-color: #c4d0dd;
  box-shadow: 0 6px 12px rgba(23, 44, 70, 0.08);
}

#industry-stats .stat {
  cursor: default;
}

#industry-stats .stat:hover {
  border-color: var(--border);
  box-shadow: none;
}

.stat.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(11, 109, 79, 0.12);
  transform: translateY(-1px);
}

.stat.disabled-stat {
  opacity: 0.72;
}

.stat .label {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.stat .value {
  font-size: 22px;
  margin-top: 4px;
  font-weight: 700;
}

.indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 9px;
}

.indicator-total {
  background: #6b7280;
}

.indicator-good {
  background: #12b76a;
}

.indicator-neutral {
  background: #f79009;
}

.indicator-bad {
  background: #f04438;
}

.posts {
  display: grid;
  gap: 10px;
}

.post {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.filter-reason {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.filter-reason summary {
  cursor: pointer;
  color: #2f3f53;
  font-size: 13px;
  font-weight: 600;
}

.filter-reason-content {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.reprocess-button {
  margin-top: 10px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 18px;
  color: var(--muted);
  background: #fafcff;
}

.post .meta {
  color: var(--muted);
  font-size: 12px;
}

.post .sentiment-negative {
  color: var(--danger);
}

.post .sentiment-positive {
  color: #067647;
}

.post .sentiment-neutral {
  color: var(--muted);
}

.industry-companies {
  margin: 6px 0;
}

.digest-block {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, #fcfffd 0%, #f6fbf8 100%);
}

.digest-overview {
  display: grid;
  gap: 12px;
}

.digest-overview-paragraph {
  margin: 0;
}

.digest-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.digest-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

.digest-list-block {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #fbfcfe;
}

.digest-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.digest-list-empty {
  color: var(--muted);
}

.news-block {
  margin-top: 16px;
}

.industry-news-block {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.news-head {
  margin-bottom: 12px;
}

.news-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eef2f7;
  color: #2f3f53;
}

.news-toggle:hover {
  background: #e8edf5;
}

.news-toggle-icon {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  margin-left: 12px;
  flex: 0 0 auto;
}

.news-toggle[aria-expanded="true"] .news-toggle-icon {
  transform: rotate(-135deg);
}

.duplicates-toggle {
  margin-top: 8px;
  background: #e8edf5;
  color: #2f3f53;
  padding: 8px 10px;
}

.duplicates {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.duplicate-post {
  display: grid;
  gap: 6px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.pagination-info {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 720px) {
  .mode-toggle,
  .period-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-form,
  .actions,
  .posts-tabs,
  .date-row {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination {
    justify-content: space-between;
  }

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

.duplicates.hidden {
  display: none;
}

.duplicate-post {
  padding: 8px 0;
}

.duplicate-score {
  margin-top: 3px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.pagination.hidden {
  display: none;
}

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

.pagination-info {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 700px) {
  .mode-toggle,
  .period-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .date-row {
    flex-direction: column;
    align-items: stretch;
  }
}
