:root {
  --ink: #15202b;
  --muted: #5b6b7c;
  --line: rgba(21, 32, 43, 0.1);
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --accent: #0f7a6c;
  --accent-deep: #0a5a50;
  --accent-soft: rgba(15, 122, 108, 0.12);
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(21, 32, 43, 0.08);
  --radius: 18px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Outfit", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d7f3ee 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e7eef8 0%, transparent 50%),
    linear-gradient(180deg, #f4f7fb 0%, #eef3f7 100%);
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(21, 32, 43, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 32, 43, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 50% 20%, black, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  width: 420px;
  height: 420px;
  right: -80px;
  top: 120px;
  background: radial-gradient(circle, rgba(15, 122, 108, 0.18), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
  animation: drift 12s ease-in-out infinite alternate;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-40px, 30px, 0);
  }
}

.app {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.top-nav {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 24px rgba(21, 32, 43, 0.05);
  animation: rise 0.45s ease both;
}

.top-nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.top-nav a:hover {
  color: var(--ink);
  background: rgba(15, 122, 108, 0.08);
}

.top-nav a.is-active {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.trend-actions {
  margin-top: 14px;
  margin-bottom: 0;
}

.trend-actions .hint {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.trend-status {
  margin: 4px 0 14px;
}

.progress-panel {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 24px rgba(21, 32, 43, 0.04);
}

.progress-panel[hidden] {
  display: none !important;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e7eef3;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #149484, #0f7a6c 55%, #0a5a50);
  transition: width 0.25s ease;
}

.progress-fill.is-indeterminate {
  width: 35% !important;
  animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.chart-card {
  animation: rise 0.7s ease both;
}

.chart-card header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.chart-card header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.chart-wrap {
  height: 300px;
  margin-top: 14px;
}

.chart-wrap-sm {
  height: 260px;
}

.span-2 {
  grid-column: span 2;
}

.crash-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.crash-list-panel {
  padding: 0;
  overflow: hidden;
  position: sticky;
  top: 12px;
}

.crash-list {
  max-height: 70vh;
  overflow: auto;
}

.crash-item {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.crash-item:hover,
.crash-item.is-active {
  background: rgba(15, 122, 108, 0.08);
}

.crash-item strong {
  font-size: 0.95rem;
}

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

.dump-path {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-hint {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.diagnosis-card {
  margin-bottom: 14px;
}

.diagnosis-card h2 {
  margin: 6px 0 8px;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.confidence {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  margin: 8px 0 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.86rem;
}

.cause-list,
.suggest-list {
  margin: 0;
  padding-left: 1.1rem;
  color: #334155;
}

.cause-list {
  margin-bottom: 10px;
}

.cause-list li,
.suggest-list li {
  margin: 6px 0;
}

.crash-grid {
  margin-bottom: 14px;
}

.mono-block,
.finding-list,
.timeline {
  margin-top: 12px;
  font-size: 0.9rem;
  line-height: 1.55;
}

.mono-block {
  font-family: var(--mono);
  font-size: 0.82rem;
  display: grid;
  gap: 6px;
}

.mono-block .path-line {
  color: var(--muted);
  word-break: break-all;
}

.finding-item {
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  background: #f5f8fa;
}

.finding-item.level-critical {
  background: #fdecea;
}

.finding-item.level-high {
  background: #fff4e5;
}

.finding-item.level-medium {
  background: #eef6ff;
}

.finding-item strong {
  display: block;
  margin-bottom: 4px;
}

.finding-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 11rem 4.5rem minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}

.timeline-item .tag {
  color: var(--accent-deep);
  font-weight: 600;
}

.ai-result {
  margin: 12px 0 0;
  padding: 14px;
  border-radius: 14px;
  background: #0f1a22;
  color: #d7e6df;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow: auto;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 36rem;
  font-size: 1rem;
}

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

.env-switch {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.env-switch select,
.filter-grid input,
.filter-grid select,
.search-box input {
  font: inherit;
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.env-switch select:focus,
.filter-grid input:focus,
.filter-grid select:focus,
.search-box input:focus {
  border-color: rgba(15, 122, 108, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  animation: rise 0.65s ease both;
}

.filters {
  animation-delay: 0.05s;
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box:focus-within {
  border-color: rgba(15, 122, 108, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-box svg {
  color: var(--muted);
  flex-shrink: 0;
}

.search-box input {
  border: 0;
  box-shadow: none;
  padding-left: 0;
  width: 100%;
  background: transparent;
}

.search-box input:focus {
  box-shadow: none;
}

.range-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  border-color: rgba(15, 122, 108, 0.4);
}

.chip.is-active {
  background: var(--accent-soft);
  border-color: rgba(15, 122, 108, 0.35);
  color: var(--accent-deep);
}

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

.filter-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #149484, var(--accent));
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 122, 108, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #128878, var(--accent-deep));
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn-sm {
  padding: 7px 10px;
  font-size: 0.88rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
  animation: rise 0.7s ease both;
  animation-delay: 0.08s;
}

.stat {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(21, 32, 43, 0.04);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.stat strong {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.table-panel {
  animation-delay: 0.12s;
  padding: 0;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-text.is-error {
  color: var(--danger);
}

.status-text.is-loading {
  color: var(--accent);
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  max-height: min(62vh, 720px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfc;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: rgba(15, 122, 108, 0.04);
}

.mono {
  font-family: var(--mono);
  font-size: 0.86rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #eef2f6;
  color: #334155;
}

.badge.level-all,
.badge.level-info {
  background: #e8f5f2;
  color: var(--accent-deep);
}

.badge.level-warn,
.badge.level-warning {
  background: #fff4e5;
  color: var(--warn);
}

.badge.level-error,
.badge.level-fatal,
.badge.level-critical {
  background: #fdecea;
  color: var(--danger);
}

.info-preview {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
}

.empty-row td,
.loading-row td {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer code {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.detail-dialog {
  border: 0;
  padding: 0;
  border-radius: 20px;
  width: min(720px, calc(100vw - 24px));
  box-shadow: 0 30px 80px rgba(21, 32, 43, 0.28);
  background: transparent;
}

.detail-dialog::backdrop {
  background: rgba(15, 23, 32, 0.45);
  backdrop-filter: blur(4px);
}

.detail-sheet {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
}

.detail-sheet header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.detail-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-sheet h2 {
  margin: 6px 0 0;
  font-size: 1.4rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.detail-meta span {
  background: #f3f6f8;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.detail-json {
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: #0f1a22;
  color: #d7e6df;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow: auto;
  max-height: 50vh;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: #15202b;
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

  .crash-list-panel {
    position: static;
  }

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

  .search-row {
    flex-wrap: wrap;
  }

  .search-box {
    flex: 1 1 100%;
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 20px, 1200px);
    padding-top: 22px;
  }

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

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
