:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #d9dce2;
  --border-strong: #bcc2cc;
  --text: #1f2329;
  --muted: #636b78;
  --accent: #2b5fff;
  --accent-2: #30a46c;
  --danger: #d43d4f;
  --shadow: 0 3px 10px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
textarea,
input {
  font: inherit;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.dashboard-sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 20px 14px;
  border-right: 1px solid var(--border);
  background: #eceef2;
  display: grid;
  gap: 20px;
  grid-template-rows: auto 1fr auto;
}

.sidebar-brand h1 {
  margin-top: 4px;
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}

.sidebar-brand p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
  align-content: start;
}

.sidebar-link {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #454b57;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}

.sidebar-link:hover {
  color: var(--text);
  background: #dde1e8;
}

.sidebar-link.is-active {
  color: #1d2533;
  border-color: #bec4d1;
  background: #f6f7fa;
}

.sidebar-actions {
  display: grid;
  gap: 12px;
}

.sidebar-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.sync-chip {
  border: 1px solid var(--border);
  background: #f8f9fb;
  border-radius: 12px;
  padding: 10px;
}

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

.sync-chip strong {
  display: block;
  margin-top: 4px;
  font-size: 0.9rem;
}

.dashboard-main {
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.page-header {
  border: 1px solid var(--border);
  background: linear-gradient(
    180deg,
    rgba(24, 31, 40, 0.95),
    rgba(18, 24, 32, 0.95)
  );
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.page-header h2 {
  margin-top: 4px;
  font-size: 1.65rem;
  letter-spacing: -0.03em;
}

.hero-copy {
  max-width: 72ch;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.view-section {
  display: grid;
  gap: 14px;
}

.hidden {
  display: none;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7a8290;
  font-size: 0.72rem;
}

h2,
h3,
p {
  margin: 0;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.kpi-grid {
  margin-bottom: 2px;
}

.stat-card {
  min-width: 140px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.stat-card span,
.muted {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.05rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.82fr);
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.chat-panel {
  padding: 18px;
}

.insight-panel {
  padding: 18px;
}

.panel-header,
.subpanel-header,
.assistant-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header {
  margin-bottom: 18px;
}

.panel-header h2 {
  font-size: 1.4rem;
}

.panel-header h3 {
  font-size: 1.25rem;
}

.chat-form {
  display: grid;
  gap: 14px;
}

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

.field span,
.subpanel h3 {
  font-size: 0.92rem;
  color: #5f6673;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  padding: 16px 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: #ffffff;
  outline: none;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

input[type="datetime-local"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: #ffffff;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

input[type="datetime-local"]:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(43, 95, 255, 0.16);
}

.time-range-block {
  margin: 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f7f8fb;
}

.time-range-block legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.compact-field {
  gap: 6px;
}

.time-range-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.time-range-apply-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.time-range-apply-row .primary-button {
  min-width: 180px;
}

textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(43, 95, 255, 0.16);
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip,
.primary-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.chip {
  padding: 10px 14px;
  color: #2f3642;
  background: #eef1f6;
  border-color: var(--border);
}

.chip:hover,
.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 12px 18px;
  font-weight: 700;
  color: #ffffff;
  background: #2a5cf2;
}

.secondary-button {
  padding: 10px 14px;
  color: #2f3642;
  border-color: var(--border);
  background: #f1f3f8;
}

.assistant-card,
.subpanel,
.evidence-item,
.top-question-item {
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.global-time-range {
  box-shadow: var(--shadow);
}

.assistant-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 0 5px rgba(48, 164, 108, 0.16);
  margin-top: 6px;
}

.answer-text {
  margin-top: 16px;
  line-height: 1.72;
  color: #222834;
  min-height: 220px;
}

.answer-markdown {
  display: grid;
  gap: 14px;
}

.answer-markdown > :first-child {
  margin-top: 0;
}

.answer-markdown > :last-child {
  margin-bottom: 0;
}

.md-heading {
  margin: 6px 0 0;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.md-heading:first-child {
  margin-top: 0;
}

.md-heading:nth-of-type(1) {
  font-size: 1.42rem;
}

.md-heading:nth-of-type(2) {
  font-size: 1.12rem;
  color: #344054;
}

.md-paragraph {
  margin: 0;
  color: #1f2632;
}

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

.md-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 8px;
}

.md-quote {
  margin: 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: #eef4ff;
  border-radius: 14px;
  color: #24324a;
}

.md-code {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 16px;
  background: #111827;
  border: 1px solid #202c43;
}

.md-code code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
}

.answer-markdown code {
  padding: 0.12em 0.35em;
  border-radius: 8px;
  background: #edf2ff;
  color: #253873;
}

.answer-markdown a {
  color: #2753d7;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.subpanel {
  margin-top: 10px;
  padding: 14px;
  border-radius: 14px;
}

.signal-list,
.top-questions,
.all-questions,
.evidence-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.pager-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.signal-list {
  padding-left: 18px;
  color: var(--text);
}

.signal-list li {
  line-height: 1.55;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric-pill {
  min-width: 0;
  padding: 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.metric-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.metric-pill strong {
  display: block;
  margin-top: 6px;
  font-size: 0.98rem;
}

.evidence-item,
.top-question-item {
  padding: 14px;
  border-radius: 12px;
}

.item-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.item-meta {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.item-response {
  margin-top: 10px;
  color: #253043;
  line-height: 1.55;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2f8;
  color: #3b4454;
  font-size: 0.78rem;
}

.empty-state {
  color: var(--muted);
  padding: 12px 0;
}

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

  .dashboard-sidebar {
    min-height: auto;
    position: static;
    grid-template-rows: auto auto auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

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

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

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

@media (max-width: 760px) {
  .dashboard-main {
    padding: 12px;
  }

  .page-header,
  .chat-panel,
  .insight-panel {
    padding: 14px;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .chat-actions {
    align-items: stretch;
  }

  .time-range-grid {
    grid-template-columns: 1fr;
  }

  .time-range-apply-row {
    justify-content: stretch;
  }

  .time-range-apply-row .primary-button {
    min-width: 0;
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .global-time-range {
    top: 8px;
  }
}
