:root {
  color-scheme: light;
  /* Design: restrained palette with a single accent for trust and focus. */
  --ink: #111827;
  --muted: #4b5563;
  --paper: #f5f7fb;
  --surface: #ffffff;
  --accent: #245bdb;
  --border: #d9dee7;
  --focus: rgba(36, 91, 219, 0.25);
  --radius: 14px;
  --shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Source Sans 3", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #f8fbff 0%, #f3f6fb 50%, #eef2f8 100%);
  min-height: 100vh;
}

h1,
h2 {
  font-family: "IBM Plex Serif", "Source Serif 4", "Iowan Old Style", "Palatino", serif;
  letter-spacing: 0.1px;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 24px 88px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  font-size: 1.25rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 6px;
}

.intro {
  position: relative;
  display: block;
  padding-right: calc(42.5% + 14px);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  margin: 0 0 10px;
  color: var(--muted);
}

.intro-copy h1 {
  font-size: clamp(2.4rem, 3.6vw, 3.4rem);
  margin: 0 0 14px;
}

.lede {
  font-size: 1.12rem;
  margin: 0;
  max-width: 48ch;
  color: var(--muted);
}

.actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.caption {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.2px;
  width: fit-content;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 20px 36px rgba(15, 23, 42, 0.12);
}

.trust-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: calc(42.5% - 14px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.trust-panel h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.trust-panel p {
  margin: 0 0 14px;
  color: var(--muted);
}

.trust-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card.wide {
  grid-column: 1 / -1;
}

.primary-card {
  border-left: 4px solid var(--accent);
  background: linear-gradient(120deg, rgba(36, 91, 219, 0.06), transparent 55%);
}

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

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.file-input {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  background: #f9fbff;
  font-weight: 600;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.file-input:hover {
  border-color: var(--accent);
  background: #f3f7ff;
}

.file-input input {
  display: none;
}

.file-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  color: var(--muted);
}

.status {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.88rem;
  width: fit-content;
}

.status.error-state {
  background: #fff1ed;
  border-color: #f2b8a8;
}

.error {
  background: #fff1ed;
  border: 1px solid #f2b8a8;
  border-radius: 12px;
  padding: 12px;
  font-size: 0.95rem;
  color: #8a2b1f;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: min(420px, 90vw);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
  border: 1px solid var(--border);
  z-index: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.modal-close {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.modal-close:hover,
.modal-close:focus {
  border-color: var(--accent);
  color: var(--accent);
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--ink);
}

input,
select,
button {
  font-family: inherit;
  font-size: 1rem;
}

input,
select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
button:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.strata {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.strata-title {
  margin: 0;
  font-weight: 600;
}

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

.check-grid label {
  flex-direction: row;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  gap: 8px;
  background: #fff;
}

.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.12);
}

.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

#previewTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

#previewTable th,
#previewTable td {
  border-bottom: 1px solid #eef1f6;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

#previewTable th {
  background: #f6f8fc;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 600;
}

.hidden {
  display: none;
}

/* ---------------------------------------------------------------------------
   Navigation
   --------------------------------------------------------------------------- */

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-link--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Help icons and tooltips
   --------------------------------------------------------------------------- */

.label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: help;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.help-icon:hover,
.help-icon:focus {
  background: var(--accent);
  color: #fff;
  outline: none;
}

.help-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  padding: 10px 12px;
  background: var(--ink);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.45;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 10;
  pointer-events: none;
}

.help-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}

.help-icon:hover .help-tooltip,
.help-icon:focus .help-tooltip {
  opacity: 1;
  visibility: visible;
}

/* ---------------------------------------------------------------------------
   Results display (power analysis)
   --------------------------------------------------------------------------- */

.results-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: "IBM Plex Serif", "Source Serif 4", "Iowan Old Style", "Palatino", serif;
  color: var(--ink);
}

.result-value.highlight {
  color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .intro {
    padding-right: 0;
  }

  .trust-panel {
    position: static;
    width: 100%;
    margin-top: 20px;
  }

  .section-grid {
    grid-template-columns: 1fr;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .file-meta {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }

  .site-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .results-summary {
    grid-template-columns: 1fr;
  }

  .help-tooltip {
    left: 0;
    transform: translateX(0);
    width: 200px;
  }

  .help-tooltip::after {
    left: 12px;
    transform: none;
  }
}
