* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Wartsila Voyage dark palette */
  --brand-blue: #1a3a6b;
  --brand-blue-2: #244f99;
  --brand-purple: #7c4dff;
  --brand-purple-2: #b39ddb;

  --bg: #0d1117;
  --surface: #161b2e;
  --surface-alt: #1e2540;
  --ink: #e2e8f0;
  --ink-muted: #8892b0;
  --line: #2a3560;

  --crit: #ef5350;
  --high: #ff7043;
  --caution: #ffca28;
  --pass: #66bb6a;
  --info: #42a5f5;

  --text-accent: #7eb8ff;
  --text-accent-2: #b39ddb;

  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

html, body { min-height: 100%; }
body {
  font-family: "Avenir Next", "Avenir Next LT Pro", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at 80% 10%, #1a1040 0%, #0d1117 50%, #080d1a 100%);
  color: var(--ink);
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  background: linear-gradient(95deg, var(--brand-blue) 0%, var(--brand-blue-2) 68%, #1b6fb5 100%);
  color: #fff;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 4px solid var(--brand-purple);
  box-shadow: 0 8px 20px rgba(0, 62, 126, 0.22);
}

.top-bar-title {
  font-size: 1.78rem;
  letter-spacing: 0.02em;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.top-bar-title:hover,
.top-bar-title:focus,
.top-bar-title:active,
.top-bar-title:visited {
  text-decoration: none;
  color: inherit;
}

.workspace {
  flex: 1;
  width: min(1220px, 100% - 40px);
  margin: 22px auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.landing-layout {
  width: 100%;
  min-height: calc(100vh - 170px);
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 520px);
  gap: 40px;
  align-items: center;
}

.workspace > .page-section {
  width: 100%;
}

.title-panel {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.title-panel h1 {
  font-size: clamp(2.0rem, 4.2vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--text-accent);
  max-width: 22ch;
  text-align: center;
}

.h1-sub {
  font-size: 0.65em;
}

.page-section { animation: fadeIn 0.24s ease; }
.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.upload-card,
.loading-card,
.tabs-wrapper,
.error-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.upload-card { padding: 18px; }

.loading-card,
.error-card {
  max-width: 720px;
  margin: 0 auto;
}

#uploadSection {
  width: 100%;
}

.drop-zone {
  border: 2px dashed #3d5a8a;
  border-radius: 14px;
  background: linear-gradient(180deg, #131929 0%, #0f1520 100%);
  padding: 36px 18px;
  text-align: center;
  transition: 0.2s ease;
}

.drop-zone.dragover {
  border-color: var(--brand-purple);
  background: #1a1040;
}

.dz-icon {
  width: 70px;
  height: 70px;
  margin-bottom: 10px;
  color: var(--text-accent);
}

.drop-zone h2 {
  font-size: 1.35rem;
  color: var(--ink);
  margin-bottom: 6px;
}

.drop-zone p,
.hint {
  color: var(--ink-muted);
}

.hint {
  margin-top: 8px;
  font-size: 0.84rem;
}

.upload-note {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-style: italic;
}

#fileInput { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, background 0.18s ease, color 0.18s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary,
.btn-analyze {
  background: linear-gradient(90deg, var(--brand-purple) 0%, var(--brand-purple-2) 100%);
  color: #fff;
}

.btn-primary:hover,
.btn-analyze:hover { filter: brightness(1.05); }

.btn-analyze {
  width: 100%;
  font-size: 1rem;
  margin-top: 8px;
}

.btn-secondary {
  background: var(--brand-blue);
  color: #fff;
}

.btn-secondary:hover { background: var(--brand-blue-2); }

.btn-outline {
  background: var(--surface-alt);
  color: var(--text-accent);
  border-color: #3d5a8a;
}

.btn-outline:hover {
  background: #253060;
}

.file-preview { margin-top: 10px; }

.file-meta {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-alt);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fn { font-weight: 600; }
.fs { color: var(--ink-muted); font-size: 0.84rem; }

.btn-icon {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  width: 28px;
  height: 28px;
  border-radius: 7px;
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--crit);
  background: rgba(239, 83, 80, 0.15);
}

.loading-card {
  padding: 28px;
  text-align: center;
}

.loading-card h2 {
  color: var(--text-accent);
}

.loading-card p {
  color: var(--ink-muted);
  margin-top: 4px;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 4px solid #2a3560;
  border-top-color: var(--brand-purple);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-track {
  width: min(340px, 100%);
  margin: 10px auto 0;
  height: 8px;
  border-radius: 999px;
  background: #1e2540;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand-purple), var(--brand-blue-2));
  transition: width 0.22s ease;
}

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.results-header h2 {
  color: var(--text-accent);
}

.results-sub {
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.results-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scorecard-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.scorecard {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.18s ease;
}

.scorecard:hover {
  transform: translateY(-1px);
}

.scorecard.active {
  box-shadow: 0 0 0 2px rgba(0, 83, 155, 0.25) inset;
}

.sc-count {
  font-size: 1.95rem;
  font-weight: 800;
  line-height: 1;
}

.sc-label {
  margin-top: 3px;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
}

.sc-failed { background: rgba(239, 83, 80, 0.12); border-color: rgba(239, 83, 80, 0.35); color: var(--crit); }
.sc-pass { background: rgba(102, 187, 106, 0.12); border-color: rgba(102, 187, 106, 0.35); color: var(--pass); }
.sc-info { background: rgba(66, 165, 245, 0.12); border-color: rgba(66, 165, 245, 0.35); color: var(--info); }

.category-view {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 14px;
  overflow: hidden;
}

.category-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}

.category-head h3 {
  color: var(--text-accent);
  font-size: 0.98rem;
}

.category-list {
  max-height: 280px;
  overflow: auto;
  padding: 8px 10px;
}

.category-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--surface-alt);
}

.category-item:last-child { margin-bottom: 0; }

.category-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.category-badge {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 2px 7px;
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 700;
}

.category-meta {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.category-solution {
  margin-top: 6px;
  padding: 7px 9px;
  border-radius: 7px;
  border-left: 4px solid var(--high);
  border: 1px solid rgba(255, 112, 67, 0.35);
  background: rgba(255, 112, 67, 0.12);
  color: #ffd7c8;
}

.category-solution-label {
  color: #ffd1bf;
  font-weight: 700;
  margin-right: 4px;
}

.category-empty {
  padding: 8px;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #0f1422;
}

.tab-btn {
  border: 1px solid #2a3560;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-accent);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn.active {
  background: linear-gradient(90deg, var(--brand-blue-2), var(--brand-purple));
  border-color: transparent;
  color: #fff;
}

.tab-dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-fail { background: var(--crit); }
.dot-pass { background: var(--pass); }
.dot-info { background: var(--info); }
.dot-none { background: #4a5580; }

.tab-panels { padding: 14px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-title {
  color: var(--text-accent);
  font-weight: 700;
  margin-bottom: 10px;
}

.ws-groups {
  display: grid;
  gap: 10px;
}

.ws-general-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #11182b;
  padding: 10px;
}

.ws-general-title {
  color: var(--ink-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  font-weight: 700;
}

.ws-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #10172a;
}

.ws-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #19223a;
  border-bottom: 1px solid transparent;
}

.ws-group[open] > summary {
  border-bottom-color: var(--line);
}

.ws-summary-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ws-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 8px rgba(0, 0, 0, 0.35) inset;
}

.ws-light-red {
  background: #ef5350;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 0 10px rgba(239, 83, 80, 0.8);
}

.ws-light-green {
  background: #66bb6a;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 0 10px rgba(102, 187, 106, 0.8);
}

.ws-light-blue {
  background: #42a5f5;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 0 10px rgba(66, 165, 245, 0.85);
}

.ws-group > summary::-webkit-details-marker {
  display: none;
}

.ws-name {
  color: var(--text-accent);
  font-weight: 700;
}

.ws-stats {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.ws-items {
  padding: 10px;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface-alt);
  padding: 10px 12px;
  cursor: pointer;
}

.result-main { flex: 1; }
.result-name { font-weight: 600; }
.result-found { color: var(--ink-muted); font-size: 0.84rem; }

.result-sev {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 3px 9px;
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 700;
}

.sev-failed { background: rgba(239, 83, 80, 0.15); color: var(--crit); border-color: rgba(239, 83, 80, 0.4); }
.sev-pass { background: rgba(102, 187, 106, 0.15); color: var(--pass); border-color: rgba(102, 187, 106, 0.4); }
.sev-info { background: rgba(66, 165, 245, 0.15); color: var(--info); border-color: rgba(66, 165, 245, 0.4); }

.result-body {
  display: none;
  padding: 10px 12px 12px 34px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.result-body.open { display: block; }
.result-body table { width: 100%; border-collapse: collapse; }
.result-body td { padding: 4px 8px 4px 0; vertical-align: top; }
.result-body td:first-child { width: 110px; color: var(--ink-muted); }

code {
  background: #0d1a2e;
  border: 1px solid #2a3f6a;
  border-radius: 6px;
  padding: 2px 6px;
  color: #90caf9;
  font-family: Consolas, "Courier New", monospace;
}

.result-body .rec {
  margin-top: 8px;
  padding: 7px 10px;
  border-left: 4px solid var(--brand-purple);
  background: rgba(124, 77, 255, 0.12);
  border-radius: 6px;
  color: var(--text-accent-2);
}

.error-card {
  text-align: center;
  padding: 26px;
  border-left: 8px solid var(--crit);
}

.error-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: var(--crit);
}

.error-card p { color: var(--ink-muted); margin: 8px 0 10px; }

@media (max-width: 1024px) {
  .workspace {
    width: min(960px, 100% - 28px);
  }

  .landing-layout {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .title-panel {
    justify-content: center;
    text-align: center;
  }

  .title-panel h1 {
    max-width: none;
  }
}

@media (max-width: 760px) {
  .top-bar-title { font-size: 1.4rem; }
  .workspace { width: min(1320px, 100% - 18px); margin: 14px auto; }
  .landing-layout { gap: 18px; }
  .title-panel h1 { font-size: clamp(2rem, 11vw, 3rem); }
  .scorecard-row { grid-template-columns: repeat(2, 1fr); }
}
