.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  animation: float-in 0.7s ease both;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.06), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1;
}

.card > * {
  position: relative;
  z-index: 2;
}

.card:hover::before {
  opacity: 1;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.14);
}

.card > .card-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  gap: 8px;
  align-items: center;
}

.card-action {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.95);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-action:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
}

.fullscreen-close {
  display: none;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 900;
}

.modal-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.card-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.card-action.is-active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 20px rgba(109, 94, 252, 0.25);
}

.card.chart-primary,
.card.table-wide {
  grid-column: span 2;
}

.card.chart-primary.compact {
  grid-column: span 1;
}

.card.full-width {
  grid-column: 1 / -1;
}

.card.chart-primary .chart-frame {
  min-height: 460px;
}

.card.chart-primary.compact .chart-frame {
  min-height: 380px;
}

.card.chart-full .chart-frame {
  min-height: 640px;
}

.card.full-width.chart-full .chart-frame {
  min-height: 700px;
}

.card.is-modal {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.3);
  opacity: 1;
  transform: none;
  position: fixed;
  inset: var(--modal-inset);
  margin: 0;
  z-index: 950;
  overflow: hidden;
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-radius 0.35s ease, opacity 0.25s ease;
  transform-origin: top left;
  will-change: transform;
}

.card.is-modal::before {
  opacity: 0;
}

.card.is-modal:hover {
  transform: none;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.3);
}

.card.is-modal .chart-frame {
  flex: 1;
  min-height: 0;
}

.card.is-modal .fullscreen-toggle {
  display: none;
}

.card.is-modal .reset-zoom-btn {
  display: inline-flex !important;
}

.card.is-modal .fullscreen-close {
  display: inline-flex;
}

.card.is-modal .table-host {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card.is-modal .table-scroll {
  max-height: none;
  height: 100%;
  flex: 1;
}

.card[data-delay="1"] {
  animation-delay: 0.08s;
}

.card[data-delay="2"] {
  animation-delay: 0.16s;
}

.card[data-delay="3"] {
  animation-delay: 0.24s;
}

.card h3 {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-weight: 600;
  margin: 0 0 12px;
  font-size: 18px;
  letter-spacing: 0.01em;
}

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

.card-kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--muted);
}

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

.metric {
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.12), rgba(255, 255, 255, 0.85));
  border: 1px solid rgba(109, 94, 252, 0.12);
}

.metric span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.metric strong {
  font-size: 22px;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.notes {
  display: grid;
  gap: 10px;
  font-size: 14px;
}

.note {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(42, 212, 181, 0.15);
  color: #0b6a54;
}

.note.orange {
  background: rgba(247, 176, 75, 0.2);
  color: #825318;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 28px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.92);
  color: #f9fafb;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1200;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.insight-list {
  display: grid;
  gap: 10px;
}

.insight-card {
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 8px;
}

.insight-card.insight-blue {
  background: rgba(219, 234, 254, 0.35);
  border-color: rgba(59, 130, 246, 0.18);
}

.insight-card.insight-orange {
  background: rgba(255, 247, 227, 0.7);
  border-color: rgba(247, 176, 75, 0.25);
}

.insight-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.insight-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.insight-card.insight-orange .insight-dot {
  background: rgba(247, 176, 75, 0.7);
  box-shadow: 0 0 0 4px rgba(247, 176, 75, 0.2);
}

.insight-message {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

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

.compare-card {
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 14px;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.08), rgba(255, 255, 255, 0.9));
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 10px;
}

.compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compare-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}

.compare-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.compare-stat span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.compare-stat strong {
  font-size: 16px;
}

.compare-delta {
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}

.compare-delta.is-up {
  color: #0f8a5f;
}

.compare-delta.is-down {
  color: #b42318;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.08);
  color: var(--muted);
}

.badge-good {
  background: rgba(16, 185, 129, 0.18);
  color: #0f8a5f;
}

.badge-warn,
.badge-warning {
  background: rgba(247, 176, 75, 0.2);
  color: #8a5a12;
}

.badge-bad,
.badge-high {
  background: rgba(180, 35, 24, 0.18);
  color: #8a1c12;
}

.badge-info {
  background: rgba(59, 130, 246, 0.18);
  color: #1f4ed8;
}

.alert-list {
  display: grid;
  gap: 12px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.card.is-modal .alert-list {
  max-height: none;
  height: 100%;
  flex: 1;
  min-height: 0;
}

.alert-list::-webkit-scrollbar {
  width: 8px;
}

.alert-list::-webkit-scrollbar-thumb {
  background: rgba(109, 94, 252, 0.25);
  border-radius: 999px;
}

.alert-card {
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 8px;
}

.alert-card.severity-high {
  border-color: rgba(180, 35, 24, 0.25);
  background: rgba(255, 235, 238, 0.7);
}

.alert-card.severity-warning {
  border-color: rgba(217, 151, 12, 0.25);
  background: rgba(255, 247, 227, 0.7);
}

.alert-card.severity-info {
  border-color: rgba(59, 130, 246, 0.2);
  background: rgba(239, 246, 255, 0.8);
}

.alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert-meta {
  font-size: 11px;
  color: var(--muted);
}

.alert-message {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.alert-context {
  font-size: 12px;
  color: var(--muted);
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent), #3c2d92);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 24px rgba(109, 94, 252, 0.25);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(109, 94, 252, 0.3);
}

.btn-secondary {
  background: linear-gradient(135deg, #64748b, #475569);
  margin-left: 8px;
}

.btn-secondary:hover {
  box-shadow: 0 14px 28px rgba(71, 85, 105, 0.3);
}

.error {
  margin-top: 8px;
  color: #b42318;
  font-size: 13px;
}

.success {
  margin-top: 8px;
  color: #027a48;
  font-size: 13px;
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
