* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top right, #eef4ff, transparent 30%), var(--bg);
  color: var(--ink);
}

button,
select,
textarea {
  font: inherit;
}

.app-shell {
  max-width: 1720px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.app-shell.is-report-mode .filters-card,
.app-shell.is-report-mode .explore-host,
.app-shell.is-report-mode .saved-views-card {
  display: none;
}

.hero-card,
.filters-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hero-card,
.filters-card {
  padding: 18px;
}

.hero-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.hero-copy {
  min-width: 0;
}

.hero-title,
.section-title {
  margin: 0;
  letter-spacing: -0.02em;
}

.hero-title {
  font-size: 28px;
}

.hero-subtitle,
.section-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.hero-action-button {
  min-width: 178px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #44546a;
  cursor: pointer;
}

.hero-action-button-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: rgba(33, 85, 214, 0.22);
}

.hero-action-button-primary:hover {
  color: #ffffff;
  border-color: rgba(33, 85, 214, 0.22);
  filter: brightness(1.03);
}

.hero-action-button:hover {
  border-color: rgba(33, 85, 214, 0.18);
  color: var(--accent);
}

.hero-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.hero-note {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-muted);
  border: 1px solid var(--line);
  color: #41526c;
  font-size: 12px;
}

.saved-views-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px;
}

.analysis-document-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px;
}

.explore-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px;
}

.explore-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.explore-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

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

.explore-field {
  display: grid;
  gap: 6px;
}

.explore-label {
  font-size: 12px;
  font-weight: 600;
  color: #506078;
}

.explore-select {
  height: 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 0 12px;
  color: var(--ink);
}

.explore-button {
  min-width: 164px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #44546a;
  cursor: pointer;
}

.explore-summary {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--panel-muted);
  color: #4d5d74;
  font-size: 13px;
}

.explore-series-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.explore-series-header {
  display: grid;
  gap: 4px;
}

.explore-series-title {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.explore-series-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.explore-series-empty {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--panel-muted);
  color: #5d6d85;
  font-size: 12px;
}

.explore-series-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.explore-series-chip {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #4d5d74;
  cursor: pointer;
}

.explore-series-chip.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(33, 85, 214, 0.18);
}

.explore-series-chip:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.saved-views-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.saved-views-empty {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line);
  background: var(--panel-muted);
  color: #5d6d85;
}

.saved-views-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.saved-view-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #ffffff;
  padding: 14px;
}

.saved-view-card.is-active {
  border-color: rgba(33, 85, 214, 0.24);
  box-shadow: inset 0 0 0 1px rgba(33, 85, 214, 0.08);
}

.saved-view-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.saved-view-copy {
  min-width: 0;
}

.saved-view-title {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.saved-view-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.saved-view-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.saved-view-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(33, 85, 214, 0.14);
  background: rgba(33, 85, 214, 0.06);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.saved-view-filters {
  margin: 10px 0 0;
  color: #5d6d85;
  font-size: 13px;
  line-height: 1.45;
}

.saved-view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
  justify-content: flex-end;
}

.saved-view-button {
  min-width: 88px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #536277;
  cursor: pointer;
}

.saved-view-button.is-danger {
  color: #b42318;
}

.document-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.document-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.document-blocks {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.document-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #ffffff;
  padding: 14px;
}

.document-block.is-hidden {
  opacity: 0.62;
}

.document-block.is-active {
  border-color: rgba(33, 85, 214, 0.24);
  box-shadow: inset 0 0 0 1px rgba(33, 85, 214, 0.08);
}

.document-block-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.document-block-copy {
  min-width: 0;
}

.document-block-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.document-block-status {
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.document-block-title {
  margin: 6px 0 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.document-block-copytext,
.document-text-content {
  margin: 10px 0 0;
  color: #5d6d85;
  font-size: 13px;
  line-height: 1.5;
}

.document-kpi-value {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.document-multi-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.document-multi-kpi-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-muted);
}

.document-multi-kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.document-multi-kpi-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.document-block-section {
  background: linear-gradient(180deg, rgba(33, 85, 214, 0.04), rgba(33, 85, 214, 0.01));
}

.document-section-title {
  margin: 6px 0 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.document-section-copy {
  margin: 10px 0 0;
  color: #536277;
  font-size: 14px;
  line-height: 1.55;
}

.document-block-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--panel-muted);
  color: #44546a;
  font-size: 13px;
  line-height: 1.5;
}

.document-block-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.document-block-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(33, 85, 214, 0.14);
  background: rgba(33, 85, 214, 0.06);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.document-block-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.document-block-button {
  min-width: 84px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #536277;
  cursor: pointer;
}

.document-block-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.document-block-button.is-danger {
  color: #b42318;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.filters-grid,
.panels-grid {
  display: grid;
  gap: 14px;
}

.filters-grid {
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  margin-top: 16px;
}

.panels-grid {
  grid-template-columns: 1fr;
  min-width: 0;
}

.panels-grid > * {
  min-width: 0;
}

.filter-field {
  display: grid;
  gap: 6px;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: #506078;
}

.panel-card-summary,
.panel-card-agent {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}

.panel-card-summary .panel-header,
.panel-card-agent .panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-title-wrap {
  display: grid;
  gap: 4px;
}

.panel-card-summary .panel-title,
.panel-card-agent .panel-title {
  margin: 0;
  letter-spacing: -0.02em;
}

.panel-card-summary .panel-copy,
.panel-card-agent .panel-copy,
.panel-card-agent .agent-status {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.panel-card-summary .panel-body,
.panel-card-agent .panel-body {
  margin-top: 16px;
  min-width: 0;
}

.panel-card-agent .panel-controls {
  display: flex;
  gap: 8px;
}

.panel-toggle {
  min-width: 88px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #536277;
  cursor: pointer;
}

.panel-toggle.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(33, 85, 214, 0.18);
}

.panel-summary-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

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

.legacy-table th,
.legacy-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.panel-placeholder {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line);
  background: var(--panel-muted);
  color: #4a5c75;
}

.agent-form {
  display: grid;
  gap: 12px;
}

.agent-input {
  min-height: 120px;
  width: 100%;
}

@media (max-width: 900px) {
  .hero-header,
  .section-header,
  .panel-card-summary .panel-header,
  .panel-card-agent .panel-header {
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    align-items: stretch;
  }

  .saved-view-top {
    flex-direction: column;
  }

  .saved-view-actions {
    width: 100%;
  }

  .document-header,
  .document-block-header {
    flex-direction: column;
  }

  .document-header-actions,
  .document-block-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .panel-card-agent .panel-controls {
    width: 100%;
  }

  .panel-toggle {
    flex: 1 1 auto;
  }

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