:root {
  --ink: #15231c;
  --muted: #5a6a60;
  --line: #d5ddd7;
  --bg0: #eef4ef;
  --bg1: #f8fbf8;
  --card: #ffffff;
  --accent: #1f6b4a;
  --accent-2: #2f8f65;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "Candara", "Calibri", sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, #cfe6d6 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #d9e8df 0%, transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.2rem 1.2rem 3rem;
}

.hero {
  margin-bottom: 1.4rem;
}

.hero.compact h1 { font-size: 1.7rem; }

.brand {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: 2.2rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0;
  color: var(--muted);
  max-width: 38rem;
}

.upload, .notes, .card, .flash, .stats > div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.upload {
  padding: 1.2rem;
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 10px 30px rgba(21, 35, 28, 0.05);
}

.drop {
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1.5px dashed #9eb5a6;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbf8, #eef6f1);
  cursor: pointer;
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}

.drop input {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

.drop span {
  font-weight: 600;
  color: var(--ink);
}

.drop.needs-file {
  border-color: #c9852a;
  background: linear-gradient(180deg, #fff8ee, #ffefd6);
  box-shadow: 0 0 0 3px rgba(201, 133, 42, 0.18);
  animation: nudge 0.45s ease;
}

.drop.needs-file span {
  color: #7a4e10;
}

@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-3px); }
  60% { transform: translateY(2px); }
}

.progress-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7fbf8;
  padding: 0.9rem 1rem 1rem;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.55rem;
}

.progress-head strong {
  font-size: 0.98rem;
}

.progress-head span {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #dde8e1;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  max-height: 280px;
  overflow: auto;
}

.file-list li {
  display: grid;
  grid-template-columns: 1.4rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: white;
  border: 1px solid #e4ebe6;
  font-size: 0.9rem;
}

.file-list .mark {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  background: #eef3f0;
}

.file-list li.processing .mark {
  color: var(--accent);
  background: #dff0e6;
  animation: pulse 1s ease-in-out infinite;
}

.file-list li.done .mark {
  color: white;
  background: var(--accent);
}

.file-list li.error .mark {
  color: white;
  background: #b33b2a;
}

.file-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list .meta {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list li.done .meta { color: var(--accent); }
.file-list li.error .meta { color: #b33b2a; }

.progress-note {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.form-error {
  margin: 0;
  color: #7a2e24;
  background: #fff1ee;
  border: 1px solid #f0c2ba;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font-size: 0.9rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

button, .btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font: inherit;
  font-weight: 650;
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn.secondary {
  background: white;
  color: var(--accent);
  border: 1px solid #b9cec1;
}

.notes {
  padding: 1.1rem 1.2rem 1.2rem;
}

.notes h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.notes ol { margin: 0 0 0.8rem 1.1rem; padding: 0; }
.notes p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.flash {
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  color: #7a2e24;
  background: #fff1ee;
  border-color: #f0c2ba;
}

.flash.warn {
  color: #7a4e10;
  background: #fff6e8;
  border-color: #f0d2a0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  margin-bottom: 1.1rem;
}

.stats > div {
  padding: 0.8rem 0.9rem;
}

.stats strong {
  display: block;
  font-size: 1.25rem;
}

.stats span {
  color: var(--muted);
  font-size: 0.82rem;
}

.cards {
  display: grid;
  gap: 0.9rem;
}

.card {
  padding: 1.1rem 1.2rem 1.2rem;
}

.card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  color: var(--accent);
}

.card p {
  margin: 0 0 0.9rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.back {
  margin-top: 1.4rem;
}

.back a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.page.wide { max-width: 960px; }

.page.shell {
  max-width: 1180px;
}

.shell-body {
  display: block;
}

.side-panel {
  display: none;
}

.jump-chips {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.15rem 0 0.85rem;
  margin-bottom: 0.2rem;
  -webkit-overflow-scrolling: touch;
}

.jump-chips a {
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 600;
}

.jump-chips a em {
  font-style: normal;
  color: var(--muted);
  margin-left: 0.25rem;
}

.mobile-only { display: block; }

.side-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.75rem;
}

.side-block h2 {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc, .side-labs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.toc a, .side-labs a {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.toc a:hover, .side-labs a:hover,
.toc a.active, .side-labs a.active {
  background: #eef6f1;
}

.toc a em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.78rem;
}

.side-labs a strong {
  font-size: 0.88rem;
}

.side-labs .badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.1rem;
  margin-bottom: 1.1rem;
  box-shadow: 0 8px 24px rgba(21, 35, 28, 0.04);
  scroll-margin-top: 1rem;
}

.lab-list > li {
  scroll-margin-top: 1rem;
}

.panel-head {
  margin-bottom: 0.75rem;
}

.panel-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  color: var(--accent);
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.lab-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.lab-list.compact .lab-sub { display: none; }

.lab-card {
  display: flex;
  justify-content: space-between;
  gap: 0.9rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fbf8;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.lab-card:hover,
.lab-card.active {
  border-color: #9eb5a6;
  background: #eef6f1;
}

.lab-main {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.lab-main strong {
  font-size: 1rem;
}

.lab-sub, .lab-meta, .muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.lab-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lab-side {
  display: grid;
  justify-items: end;
  gap: 0.2rem;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.tone-ok {
  background: #dff3e6;
  color: #176b3d;
}

.tone-warn {
  background: #fff1d6;
  color: #8a5a10;
}

.tone-bad {
  background: #ffe3de;
  color: #9a2f22;
}

.lab-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1rem;
}

.btn.tiny {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  margin-left: auto;
}

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.data th {
  color: var(--muted);
  font-weight: 600;
}

.flag-H { color: #b33b2a; font-weight: 650; }
.flag-L { color: #0b5ea8; font-weight: 650; }

.summary-list {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.chart-embed {
  margin-top: 0.8rem;
}

.chart-embed img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

/* Tablet / PC: sticky vertical nav beside content */
@media (min-width: 768px) {
  .shell-body {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 1.1rem;
    align-items: start;
  }

  .side-panel {
    display: block;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: auto;
  }

  .jump-chips,
  .mobile-only {
    display: none;
  }

  .cards.mobile-stack {
    display: none;
  }

  .page.shell {
    padding-top: 1.6rem;
  }
}

@media (min-width: 1100px) {
  .shell-body {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 1.4rem;
  }
}

@media (max-width: 767px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 1.8rem; }
  .lab-card { flex-direction: column; align-items: flex-start; }
  .lab-side { justify-items: start; }
  .btn.tiny { margin-left: 0; }
}
