:root {
  --app-bg: #eef2f9;
  --app-bg-2: #f7f8fc;
  --app-primary: #1d4ed8;
  --app-primary-soft: #dbeafe;
  --app-secondary: #64748b;
  --app-success: #16a34a;
  --app-success-soft: #d1fae5;
  --app-danger: #dc2626;
  --app-card-border: #e5e9f2;
  --app-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
  --app-shadow-strong: 0 14px 40px rgba(29, 78, 216, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--app-bg);
  background-image:
    radial-gradient(1200px 600px at -10% -20%, #dbeafe 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 0%, #ede9fe 0%, transparent 55%),
    linear-gradient(180deg, var(--app-bg) 0%, var(--app-bg-2) 100%);
  background-attachment: fixed;
  color: #0f172a;
  overflow-x: hidden;
}

.app-main-container .row > [class*="col-"] {
  min-width: 0;
}

.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ----- Cards ----- */
.card {
  border: 0;
  border-radius: 1rem;
}

.app-card,
.card.shadow-sm {
  border: 1px solid var(--app-card-border);
  box-shadow: var(--app-shadow) !important;
  background-color: #ffffffcc;
  backdrop-filter: blur(6px);
}

.app-card .card-header,
.card.shadow-sm .card-header {
  border-radius: 1rem 1rem 0 0;
}

/* ----- Hero ----- */
.app-hero {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
  background-color: #1d4ed8;
  background-image:
    radial-gradient(600px 220px at 100% -40%, rgba(255, 255, 255, 0.18), transparent 70%),
    linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 55%, #6366f1 100%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  color: #ffffff;
  border-radius: 1rem 1rem 0 0;
  padding: 1.1rem 1.1rem 1.25rem;
  overflow: hidden;
  position: relative;
}

.app-hero::after {
  content: "";
  position: absolute;
  inset: auto -40px -50px auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 65%);
  pointer-events: none;
}

.app-hero > * + * {
  margin-top: 0.5rem;
}

.app-badge {
  width: fit-content;
  color: var(--app-primary);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.app-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
  line-height: 1.5;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.app-subtitle strong {
  color: #fef9c3;
  font-weight: 700;
}

.app-identity {
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.app-title {
  font-size: clamp(1.5rem, 4.6vw, 2.3rem);
  line-height: 1.18;
  overflow-wrap: anywhere;
  letter-spacing: -0.01em;
}

@media (min-width: 576px) {
  .app-hero {
    padding: 1.4rem 1.4rem 1.55rem;
  }
}

@media (min-width: 992px) {
  .app-hero {
    padding: 1.75rem 1.75rem 1.9rem;
  }

  .table-cell-nowrap {
    white-space: nowrap;
  }
}

/* ----- Method switch (SAW / WP) ----- */
.method-switch {
  display: inline-flex;
  background-color: #eef2ff;
  border: 1px solid #e0e7ff;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  width: 100%;
  max-width: 100%;
}

.method-pill {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  color: var(--app-secondary);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.method-pill:hover {
  color: #0f172a;
}

.method-pill.active {
  background-color: #ffffff;
  color: var(--app-primary);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.15);
}

.method-pill:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.method-desc code {
  background-color: #f1f5f9;
  padding: 0 0.3rem;
  border-radius: 0.25rem;
  color: #0f172a;
}

/* ----- Weight sum indicator ----- */
.weight-sum-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  background-color: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 0.6rem;
  padding: 0.45rem 0.75rem;
  font-variant-numeric: tabular-nums;
  transition: all 0.18s ease;
}

.weight-sum-indicator .label {
  color: var(--app-secondary);
  font-weight: 500;
}

.weight-sum-indicator .value {
  font-weight: 700;
  font-size: 1rem;
}

.weight-sum-indicator.is-valid {
  border-color: var(--app-success);
  background-color: var(--app-success-soft);
  color: #065f46;
}

.weight-sum-indicator.is-invalid {
  border-color: var(--app-danger);
  background-color: #fee2e2;
  color: #991b1b;
}

/* ----- Top recommendation ----- */
.top-rec-card #top-recommendation:not(.text-secondary) {
  color: #065f46;
  background-color: var(--app-success-soft);
  border-radius: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-left: 4px solid var(--app-success);
}

#top-recommendation {
  font-size: 0.98rem;
  line-height: 1.45;
}

#top-method-badge {
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ----- Ranking table highlights ----- */
#ranking-table tbody tr.ranking-top {
  background-color: var(--app-success-soft);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  background-color: #f1f5f9;
  color: #475569;
}

.rank-badge.gold {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  color: #78350f;
}

.rank-badge.silver {
  background: linear-gradient(135deg, #e2e8f0, #94a3b8);
  color: #1e293b;
}

.rank-badge.bronze {
  background: linear-gradient(135deg, #fed7aa, #c2410c);
  color: #7c2d12;
}

.score-bar {
  position: relative;
  height: 6px;
  width: 100%;
  max-width: 180px;
  background-color: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.score-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1d4ed8, #6366f1);
  border-radius: 999px;
}

.score-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

footer {
  font-size: 0.85rem;
}

/* ----- Mobile (< 576px) ----- */
@media (max-width: 575.98px) {
  .app-main-container {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .app-title {
    font-size: 1.35rem;
    line-height: 1.28;
  }

  .app-subtitle {
    font-size: 0.9rem;
  }

  .app-identity {
    font-size: 0.84rem;
  }

  #monitors-table,
  #ranking-table,
  #normalization-table,
  #preference-table {
    font-size: 0.92rem;
    min-width: 0;
  }

  .mobile-stacked-table {
    border-collapse: separate;
    border-spacing: 0;
  }

  .mobile-stacked-table thead {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    white-space: nowrap;
  }

  .mobile-stacked-table,
  .mobile-stacked-table tbody,
  .mobile-stacked-table tr,
  .mobile-stacked-table td {
    display: block;
    width: 100%;
  }

  .mobile-stacked-table tbody tr {
    margin-bottom: 0.7rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background-color: #ffffff;
    padding: 0.4rem 0.8rem;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
    overflow: hidden;
  }

  .mobile-stacked-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .mobile-stacked-table tbody td {
    border: 0;
    border-bottom: 1px dashed #dbe4f0;
    padding: 0.45rem 0;
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    text-align: left;
  }

  .mobile-stacked-table tbody td:last-child {
    border-bottom: 0;
  }

  .mobile-stacked-table tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.74rem;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.12rem;
  }

  .card {
    border-radius: 0.85rem;
  }

  .app-hero {
    border-radius: 0.85rem 0.85rem 0 0;
    padding: 1rem;
  }

  .form-label {
    font-size: 0.88rem;
    margin-bottom: 0.25rem;
  }

  .btn {
    font-size: 0.92rem;
  }

  .method-pill {
    font-size: 0.88rem;
    padding: 0.4rem 0.6rem;
  }

  .score-bar {
    max-width: 100%;
  }
}
