:root {
  --bg: #f5efe4;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --ink: #14213d;
  --muted: #516173;
  --line: #d9e2ec;
  --accent: #bd6a2f;
  --accent-dark: #8d4b1f;
  --accent-soft: #f8e6d8;
  --good-bg: #dcfce7;
  --good-ink: #166534;
  --bad-bg: #fee2e2;
  --bad-ink: #991b1b;
  --shadow: 0 18px 45px rgba(20, 33, 61, 0.12);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(189, 106, 47, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(20, 33, 61, 0.08), transparent 24%),
    linear-gradient(180deg, #fbf6ef 0%, var(--bg) 100%);
  color: var(--ink);
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 36px 20px 72px;
}

.hero {
  display: block;
  margin-bottom: 28px;
}

.hero-copy {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 30px;
}

.hero-topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.hero-stat-label,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: #7c8796;
}

h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.03;
  margin: 10px 0 14px;
}

h2,
h3,
p {
  margin-top: 0;
}

.intro,
.section-note,
.status {
  color: var(--muted);
}

.section-note {
  margin-bottom: 0;
}

.card {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.upload-card {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

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

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  background: var(--panel-strong);
  color: var(--ink);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(189, 106, 47, 0.35);
  outline-offset: 2px;
}

button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ink), #243860);
  color: white;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 10px 18px rgba(20, 33, 61, 0.16);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: none;
}

.upload-shell,
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.upload-shell {
  margin-top: 18px;
}

.selected-file {
  min-width: 240px;
  flex: 1 1 260px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
}

.selected-file-label,
.metric-label,
.summary-pill-label {
  display: block;
  font-size: 12px;
  color: #768395;
  margin-bottom: 4px;
}

.feedback-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(20, 33, 61, 0.06);
  color: var(--ink);
}

.login-page {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 24px;
  position: relative;
  overflow: hidden;
}

.login-page::before,
.login-page::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.login-page::before {
  width: 420px;
  height: 420px;
  top: -110px;
  left: -120px;
  background: radial-gradient(circle, rgba(189, 106, 47, 0.16) 0%, rgba(189, 106, 47, 0) 72%);
}

.login-page::after {
  width: 460px;
  height: 460px;
  right: -140px;
  bottom: -160px;
  background: radial-gradient(circle, rgba(20, 33, 61, 0.14) 0%, rgba(20, 33, 61, 0) 72%);
}

.login-shell {
  width: min(460px, 100%);
  display: grid;
  justify-items: center;
  position: relative;
  z-index: 1;
}

.login-card {
  backdrop-filter: blur(12px);
  border-radius: 32px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.login-card {
  width: 100%;
  max-width: 460px;
  padding: 34px 30px 30px;
  background: rgba(255, 255, 255, 0.9);
  display: grid;
  gap: 18px;
  justify-items: center;
  text-align: center;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand-mark {
  width: 68px;
  height: 68px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--ink), #2f4b78);
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 18px 30px rgba(20, 33, 61, 0.18);
}

.login-brand-centered {
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.login-card-head-centered {
  display: grid;
  gap: 14px;
  justify-items: center;
  width: 100%;
  max-width: 340px;
}

.login-card-head-centered h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 52px);
}

.login-subtitle {
  max-width: 320px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.login-field {
  gap: 0;
  width: min(100%, 320px);
  justify-items: center;
}

.login-field input {
  width: 100%;
  text-align: center;
  padding: 14px 16px;
  border-radius: 999px;
  border-color: #d4dde7;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.login-submit {
  width: min(100%, 220px);
  padding: 14px 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.login-form {
  display: grid;
  gap: 14px;
  width: 100%;
  justify-items: center;
}

.login-error {
  width: min(100%, 320px);
  margin-top: 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(153, 27, 27, 0.12);
  color: var(--bad-ink);
  text-align: center;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.compact-actions {
  margin-top: 0;
}

.summary-strip,
.results-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.outlier-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  overflow: hidden;
}

.outlier-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(248, 251, 255, 0.92);
  border-bottom: 1px solid rgba(217, 226, 236, 0.9);
}

.outlier-panel summary::-webkit-details-marker {
  display: none;
}

.outlier-panel summary::after {
  content: "Apri";
  float: right;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
}

.outlier-panel[open] summary::after {
  content: "Chiudi";
}

.outlier-panel-body {
  padding: 18px;
}

.summary-pill,
.metric-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.summary-pill strong,
.metric-card strong {
  font-size: 24px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.88);
}

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

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #e7edf4;
  vertical-align: middle;
}

thead th {
  position: sticky;
  top: 0;
  background: #f8fbff;
  z-index: 1;
}

tbody tr:hover {
  background: rgba(189, 106, 47, 0.06);
}

.field-group {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 4px;
  color: var(--muted);
}

.checkbox-field input {
  width: auto;
  margin: 0;
}

.panel-actions {
  margin-top: 18px;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.pass {
  background: var(--good-bg);
  color: var(--good-ink);
}

.badge.fail {
  background: var(--bad-bg);
  color: var(--bad-ink);
}

.badge.included {
  background: #e0f2fe;
  color: #075985;
}

.badge.excluded {
  background: #eceff3;
  color: #516173;
}

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

.chart-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 10px 25px rgba(20, 33, 61, 0.08);
}

.chart-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.chart-card-head h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.chart-expand-button {
  padding: 9px 14px;
  font-size: 14px;
}

.chart {
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}

.chart-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 33, 61, 0.62);
  backdrop-filter: blur(5px);
}

.chart-modal-panel {
  position: relative;
  width: min(92vw, 1320px);
  height: min(90vh, 920px);
  background: #fbfdff;
  border-radius: 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.25);
  padding: 24px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.chart-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.chart-modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#toggle-chart-info-button {
  background: linear-gradient(135deg, #eef2f6, #d8e0e8);
  color: #465464;
  border: 1px solid #c4ced9;
}

#toggle-chart-info-button:hover {
  background: linear-gradient(135deg, #e6ebf1, #ced7e1);
}

.chart-modal-info {
  position: absolute;
  top: 88px;
  right: 24px;
  z-index: 4;
  width: min(360px, calc(100% - 48px));
  max-height: calc(100% - 132px);
  overflow: auto;
  border: 1px solid #d7dee7;
  border-radius: 16px;
  background: #f7f9fb;
  padding: 16px 18px;
  box-shadow: 0 18px 32px rgba(20, 33, 61, 0.16);
}

.chart-modal-info p {
  margin-bottom: 10px;
  color: var(--muted);
}

.chart-modal-info p:last-child {
  margin-bottom: 0;
}

.chart-modal-plot {
  min-height: 100%;
  min-width: 0;
}

@media (max-width: 920px) {
  .page {
    padding: 24px 14px 56px;
  }

  .login-card {
    padding: 28px 20px 24px;
    border-radius: 26px;
  }

  .login-brand-centered {
    flex-direction: column;
  }

  .login-card-head-centered h1 {
    font-size: clamp(30px, 10vw, 42px);
  }

  .login-field,
  .login-error {
    width: 100%;
  }

  .card {
    padding: 18px;
  }

  .chart {
    min-height: 300px;
  }

  .chart-modal-panel {
    width: 95vw;
    height: 92vh;
    padding: 18px;
  }

  .chart-modal-info {
    top: 82px;
    right: 18px;
    width: calc(100% - 36px);
    max-height: 42vh;
  }
}
