:root {
  --navy: #112641;
  --cyan: #00aeeb;
  --ink: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --card: #ffffff;
  --bg: #f3f6f9;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #eef6fb 0%, var(--bg) 45%, #e8eef5 100%);
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }

.hero {
  background: linear-gradient(135deg, rgba(17, 38, 65, 0.98), rgba(0, 174, 235, 0.85));
  color: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(17, 38, 65, 0.16);
  margin-bottom: 16px;
}

.hero-top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-mark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
}

.brand-mark img { display: block; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.84);
}

h1 { margin: 0 0 8px; font-size: clamp(1.5rem, 2.4vw, 2rem); }
.lede { margin: 0; color: rgba(255, 255, 255, 0.84); }

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

.user-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: rgba(255, 255, 255, 0.96);
  color: var(--navy);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
}

.stat strong {
  display: block;
  font-size: 1.35rem;
  margin-bottom: 4px;
}

.stat span {
  color: var(--muted);
  font-size: 0.8rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 24px rgba(17, 38, 65, 0.06);
}

.sign-in-panel { text-align: center; padding: 32px 24px; }
.sign-in-panel h2 { color: var(--navy); margin-top: 0; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
}

input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--cyan);
  color: #fff;
}

.btn.secondary { background: var(--navy); }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  background: var(--navy);
  color: #fff;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fef3c7;
  color: #92400e;
}

.notice.error {
  background: #fee2e2;
  color: #991b1b;
}

.hidden { display: none !important; }

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

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
}

.insights-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 16px;
  margin-bottom: 16px;
}

.insight-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.insight-head h2 {
  margin: 0 0 4px;
  color: var(--navy);
  font-size: 1rem;
}

.insight-head p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.sentiment-bar {
  display: flex;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef2f7;
}

.sentiment-bar .seg {
  display: block;
  height: 100%;
  min-width: 0;
}

.sentiment-bar .positive { background: #059669; }
.sentiment-bar .neutral { background: #94a3b8; }
.sentiment-bar .negative { background: #dc2626; }

.sentiment-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.sentiment-legend strong { color: var(--navy); }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.positive { background: #059669; }
.dot.neutral { background: #94a3b8; }
.dot.negative { background: #dc2626; }

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  min-height: 72px;
}

.word-tag {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: #eef6fb;
  color: var(--navy);
  font-size: calc(0.78rem * var(--size, 1));
  font-weight: 600;
}

.word-tag em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.word-bars { display: grid; gap: 8px; }

.word-bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 28px;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
}

.word-bar-track {
  height: 8px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}

.word-bar-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #00aeeb, #112641);
  border-radius: 999px;
}

.phrase-title {
  margin: 12px 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.phrase-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.phrase-tag {
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink);
}

.phrase-tag em {
  font-style: normal;
  color: var(--muted);
}

.sentiment-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.sentiment-badge.positive { background: #dcfce7; color: #166534; }
.sentiment-badge.neutral { background: #e2e8f0; color: #334155; }
.sentiment-badge.negative { background: #fee2e2; color: #991b1b; }

@media (max-width: 960px) {
  .insights-grid { grid-template-columns: 1fr; }
}
