* { box-sizing: border-box; }
body {
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  margin: 0;
  background: #f5f6fa;
  color: #1f2330;
}
header {
  background: #1f2937;
  color: #fff;
  padding: 1rem 2rem;
}
header h1 { margin: 0; font-size: 1.25rem; display:flex; align-items:baseline; gap:1.5rem; }
header .nav { font-size: 0.9rem; font-weight: normal; display:inline-flex; gap:1rem; }
header a { color: inherit; text-decoration: none; }
header .nav a { opacity: 0.8; }
header .nav a:hover { opacity: 1; text-decoration: underline; }

footer {
  max-width: 1100px;
  margin: 3rem auto 2rem auto;
  padding: 0.9rem 1rem 0 1rem;
  text-align: center;
  font-size: 0.72rem;
  color: #9ca3af;
  border-top: 1px solid #e5e7eb;
  letter-spacing: 0.3px;
}
footer p { margin: 0; }
main { max-width: 1100px; margin: 2rem auto; padding: 0 1rem; }

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }

.row-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.row-form input { flex: 1; min-width: 160px; padding: 0.5rem; border: 1px solid #cbd0d8; border-radius: 4px; }
button, .row-form button {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}
button.link { background: none; color: #b91c1c; padding: 0; }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid #e5e7eb; font-size: 0.9rem; }
th { background: #f9fafb; }
.actions a, .actions form { margin-right: 0.5rem; }
.muted { color: #6b7280; }
.meta { list-style: none; padding: 0; }
.meta li { padding: 0.15rem 0; }

.flash { padding: 0.6rem 0.9rem; border-radius: 4px; margin-bottom: 1rem; }
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }

.group { border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.group-head { font-size: 0.95rem; margin-bottom: 0.4rem; }
.group-items { margin: 0.25rem 0 0; padding-left: 1.25rem; font-size: 0.9rem; }
.group-items li { padding: 0.1rem 0; }
button[disabled] { background: #9ca3af; cursor: not-allowed; }

/* Utility — hide on screen, opposite below for print */
.print-only { display: none; }

/* ---------- Print styles (used by browser "Save as PDF") ---------- */
@media print {
  /* App chrome that adds no value on paper. */
  header, footer, .flash, .no-print { display: none !important; }
  .print-only { display: block; }

  body { background: #fff; color: #000; }
  main {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  /* Cards: keep borders, drop shadows, avoid mid-card page breaks. */
  .card {
    box-shadow: none;
    border: 1px solid #cbd0d8;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin: 0 0 0.5rem 0;
    page-break-inside: avoid;
  }

  /* Force all <details> open so collapsed summaries print. The JS hook in
     base.html also flips the `open` attribute as a belt-and-braces guard
     for browsers that ignore the CSS path. */
  details > summary { list-style: none; cursor: default; }
  details > summary::-webkit-details-marker { display: none; }
  details:not([open]) > *:not(summary) { display: revert !important; }

  /* Long tables should split between rows, never inside a row. */
  table { page-break-inside: auto; }
  tr, thead, tfoot { page-break-inside: avoid; page-break-after: auto; }

  /* Links shouldn't paint blue / underline in a printed report. */
  a, a:visited { color: inherit; text-decoration: none; }

  /* US Letter with comfortable margins. Change to A4 if needed. */
  @page { size: letter; margin: 0.6in 0.55in; }

  /* Headings shouldn't be orphaned at the bottom of a page. */
  h1, h2, h3 { page-break-after: avoid; }
}
