:root {
  --bg: #0b1220;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e5eefb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(160deg, #0b1220 0%, #111827 45%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
}

header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 18, 32, 0.85);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
}

.site-nav a.active {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.15rem;
}

.badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

.steps {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.step {
  flex: 1;
  min-width: 160px;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.9rem;
}

.step.active {
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--text);
  background: rgba(56, 189, 248, 0.08);
}

.step.done {
  border-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel h2 {
  font-size: 1.2rem;
  margin-bottom: 0.35rem;
}

.panel p.sub {
  color: var(--muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.hidden { display: none !important; }

.upload-zone {
  border: 2px dashed rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.05);
}

.upload-zone input { display: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

textarea { min-height: 90px; resize: vertical; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.checkbox-row input { width: auto; }

.confidence {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.confidence.high { color: var(--success); }
.confidence.medium { color: var(--warning); }
.confidence.low { color: var(--danger); }

.field-hint {
  font-size: 0.72rem;
  margin-top: 0.25rem;
  line-height: 1.35;
  opacity: 0.9;
}

.field-help {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.35;
}

.section-note {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(90deg, #0284c7, #7c3aed);
  color: white;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--panel-border);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.preview-box {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #cbd5e1;
  max-height: 180px;
  overflow: auto;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.standard-card h3 {
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.standard-card.ind-as h3 { color: var(--accent-2); }

.metric {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.92rem;
}

.metric span:last-child { font-weight: 600; }

ul.notes {
  margin-top: 0.75rem;
  padding-left: 1.1rem;
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.5;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 1rem;
}

th, td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: right;
}

th:first-child, td:first-child { text-align: left; }

th { color: var(--muted); font-weight: 600; }

.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
}

.loading {
  color: var(--accent);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.hero h1 {
  font-size: 2rem;
  margin: 1rem 0 0.5rem;
}

.btn-link {
  display: inline-block;
  text-decoration: none;
}

.breadcrumb {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.tool-header h1 {
  font-size: 1.5rem;
}

.page-intro {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.tool-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: border-color 0.2s, transform 0.2s;
}

.tool-card:hover {
  border-color: rgba(56, 189, 248, 0.45);
  transform: translateY(-2px);
}

.tool-tag {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  margin-bottom: 0.5rem;
}

.tool-card h3 {
  margin-bottom: 0.5rem;
}

.tool-card p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.tool-cta {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.form-section h3 {
  font-size: 1rem;
  color: var(--accent);
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.report-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.25rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 1px solid var(--panel-border);
}

.report-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
}

.report-nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.standard-tabs {
  display: flex;
  gap: 0.35rem;
}

.standard-tabs .tab {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--panel-border);
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.standard-tabs .tab.active {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.12);
}

.report-section {
  margin-bottom: 1.5rem;
}

.report-section h3 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--panel-border);
}

.report-cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem 1.5rem;
}

.report-cover-grid dt {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.report-cover-grid dd {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.table-wrap table {
  margin-top: 0;
  min-width: 640px;
}

.report-subsection {
  margin-top: 1.25rem;
}

.report-subsection h4 {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.measurement-lines {
  list-style: none;
  padding: 0;
  margin: 0;
}

.measurement-lines li {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

.measurement-lines li.equals {
  font-weight: 700;
  margin-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

#report-inputs td:last-child,
.journal-table td:first-child,
.journal-table td:nth-child(2),
.journal-table td:nth-child(3) {
  text-align: left;
}

.exemption-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

@media print {
  header, .steps, .report-nav, .standard-tabs, .actions, .breadcrumb { display: none !important; }
  body { background: white; color: black; }
  .panel { border: 1px solid #ccc; break-inside: avoid; }
}

.report-nav.section-tabs {
  gap: 0.35rem;
}

.section-tab {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--panel-border);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
}

.section-tab.active {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.12);
}

.report-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.report-subtabs .sub-tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
}

.report-subtabs .sub-tab.active {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.4);
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.saved-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  flex-wrap: wrap;
}

.saved-item-meta {
  flex: 1;
  min-width: 200px;
}

.saved-item-meta strong {
  display: block;
  font-size: 0.92rem;
}

.saved-item-meta span {
  font-size: 0.78rem;
  color: var(--muted);
}

.saved-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.table-wrap.tall {
  max-height: 520px;
  overflow-y: auto;
}

.report-panel.hidden-section {
  display: none;
}

@media (max-width: 640px) {
  main { padding: 1rem; }
  .header-inner { flex-direction: column; align-items: flex-start; }
}
