:root {
  color-scheme: dark;
  --ink: #f1f1f2;
  --muted: #a0a6ad;
  --accent: #10b981;
  --accent-hover: #059669;
  --panel: rgba(14, 19, 27, 0.86);
  --card: rgba(14, 19, 27, 0.86);
  --border: rgba(241, 241, 242, 0.12);
  --shadow: 0 25px 50px rgba(0, 0, 0, 0.45);
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  line-height: 1.5;
  background:
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.15), transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(78, 114, 170, 0.2), transparent 40%),
    radial-gradient(circle at 60% 80%, rgba(59, 130, 246, 0.15), transparent 45%),
    linear-gradient(135deg, #0b0f16, #141a24 50%, #0a0e14);
}

/* Top Navigation */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 24px;
}

.top-nav a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background 0.2s;
}

.top-nav a:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Page Container */
.page {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* Hero Header */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 36px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(17, 23, 34, 0.92), rgba(21, 28, 39, 0.78));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  margin-bottom: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 600;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin: 0 0 8px;
  font-weight: 700;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 10px;
  font-weight: 600;
}

h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 520px;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  backdrop-filter: blur(14px);
  overflow: visible;
}

/* Section Headers with Collapse */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
}

.section-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 12px;
}

/* Collapsible Sections */
.collapse-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.collapse-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.collapse-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.collapse-icon {
  display: block;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.collapse-btn[aria-expanded="false"] .collapse-icon {
  transform: rotate(-45deg);
}

.collapsible {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 0;
  opacity: 0;
}

.collapsible.open {
  max-height: 1000px;
  opacity: 1;
  overflow: visible;
}

/* Grid Layout */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* Labels and Inputs */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 500;
  font-size: 0.9rem;
}

.label-text {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 1;
}

input, select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder {
  color: var(--muted);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

select option {
  background: #1a1f2e;
  color: var(--ink);
}

/* Tooltips */
.tooltip-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: bold;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}

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

.tooltip-btn:hover + .tooltip,
.tooltip-btn:focus + .tooltip {
  visibility: visible;
  opacity: 1;
}

.tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  left: 0;
  z-index: 100;
  background: #1e2536;
  color: var(--ink);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.5;
  max-width: 280px;
  min-width: 200px;
  margin-bottom: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
}

.tooltip::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 16px;
  border: 6px solid transparent;
  border-top-color: #1e2536;
}

/* Tooltip in results (needs different positioning) */
h3 .tooltip-btn {
  vertical-align: middle;
  margin-left: 4px;
}

h3 .tooltip {
  left: auto;
  right: 0;
}

h3 .tooltip::before {
  left: auto;
  right: 16px;
  border-top-color: #1e2536;
}

/* Location Input with Status */
.input-with-status {
  position: relative;
}

.input-with-status input {
  width: 100%;
  padding-right: 32px;
}

.location-status {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
}

.location-status.valid::after {
  content: "✓";
  color: var(--success);
}

.location-status.invalid::after {
  content: "✗";
  color: var(--error);
}

.location-status.checking::after {
  content: "...";
  color: var(--muted);
}

/* Buttons */
.form-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 10px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  flex: 1;
  min-width: 200px;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.4);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-small:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-tiny {
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tiny:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

/* Loading States */
.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* Results Section */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.results-header h2 {
  margin: 0;
}

.results-actions {
  display: flex;
  gap: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.result-grid article {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.metric {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  color: var(--accent);
}

.meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 6px 0 0;
}

/* Two Column Layout */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.two-col article {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

ul {
  margin: 0;
  padding-left: 20px;
}

li {
  margin-bottom: 6px;
  color: var(--muted);
}

/* Interactive Checklist */
.checklist-section {
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

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

.checklist-header h3 {
  margin: 0;
}

.checklist-actions {
  display: flex;
  gap: 6px;
}

.interactive-checklist {
  list-style: none;
  padding: 0;
}

.interactive-checklist li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

.interactive-checklist li:last-child {
  border-bottom: none;
}

.interactive-checklist input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.interactive-checklist label {
  font-weight: 400;
  cursor: pointer;
  flex: 1;
}

.interactive-checklist li.checked label {
  color: var(--muted);
  text-decoration: line-through;
}

.checklist-progress {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 12px;
}

/* Collapsible Articles */
.collapsible-article {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}

.article-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition: background 0.2s;
}

.article-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

.article-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.article-toggle h3 {
  margin: 0;
  font-size: 1rem;
}

.article-toggle .collapse-icon {
  transform: rotate(-45deg);
  transition: transform 0.2s;
}

.article-toggle[aria-expanded="true"] .collapse-icon {
  transform: rotate(45deg);
}

.article-content {
  display: none;
  padding: 18px;
  background: rgba(0, 0, 0, 0.2);
}

.article-toggle[aria-expanded="true"] + .article-content {
  display: block;
}

/* Weight Table */
.weight-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.weight-table th, .weight-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.weight-table th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: var(--muted);
}

.weight-table td:nth-child(even) {
  font-weight: 600;
  color: var(--accent);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1a1f2e;
}

.timeline-marker {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.timeline-content strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.timeline-content p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Resources Section */
.resources-section {
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.resource-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.resource-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s;
}

.resource-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.resource-icon {
  font-size: 1.2rem;
}

/* Notification */
.notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, #1e2536, #252d3d);
  color: var(--ink);
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  z-index: 1000;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Footer */
footer {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

footer p {
  margin: 8px 0;
}

a {
  color: var(--accent);
}

a:hover {
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Mobile Responsive */
@media (max-width: 760px) {
  .top-nav {
    padding: 0.75rem 16px;
  }

  .page {
    padding: 0 16px 40px;
  }

  .hero {
    padding: 24px;
    border-radius: 16px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

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

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

  .form-actions {
    flex-direction: column;
  }

  .btn-primary, .btn-secondary {
    width: 100%;
    padding: 16px;
  }

  input, select {
    padding: 14px;
    font-size: 16px;
  }

  .tooltip {
    max-width: calc(100vw - 48px);
    left: -50px;
  }

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

  .checklist-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .weight-table {
    font-size: 0.75rem;
  }

  .weight-table th, .weight-table td {
    padding: 8px 6px;
  }

  .resource-links {
    grid-template-columns: 1fr;
  }
}

/* Print Styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }

  .top-nav,
  .form-actions,
  .results-actions,
  .checklist-actions,
  .tooltip-btn,
  .resource-links,
  .notification {
    display: none !important;
  }

  .page {
    max-width: 100%;
    padding: 0;
  }

  .hero, .card {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }

  .hidden {
    display: block !important;
  }

  #results {
    display: block !important;
  }

  .collapsible {
    max-height: none !important;
    opacity: 1 !important;
  }

  .article-content {
    display: block !important;
    background: white !important;
  }

  .metric {
    color: #059669 !important;
  }

  .result-grid article,
  .two-col article,
  .checklist-section,
  .collapsible-article {
    background: white !important;
    border: 1px solid #ccc !important;
  }

  .interactive-checklist li {
    page-break-inside: avoid;
  }

  .interactive-checklist input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #333;
    border-radius: 3px;
    background: white;
  }

  footer {
    color: #666 !important;
    border-top-color: #ccc !important;
  }

  a {
    color: #059669 !important;
  }
}

@media print {
  body.print-checklist-only .hero,
  body.print-checklist-only .card:not(#results),
  body.print-checklist-only .result-grid,
  body.print-checklist-only .two-col,
  body.print-checklist-only .collapsible-article,
  body.print-checklist-only .resources-section,
  body.print-checklist-only article:not(.checklist-section),
  body.print-checklist-only footer {
    display: none !important;
  }

  body.print-checklist-only .checklist-section {
    display: block !important;
  }
}
