:root {
  --brand: #E91E63;
  --brand-dark: #AD1457;
  --brand-soft: #fce4ec;
  --topbar-1: #0a0a0a;
  --topbar-2: #1f1f1f;
  --accent: #39a96b;
  --bg: #f3f6f8;
  --card: #ffffff;
  --text: #1a2733;
  --muted: #6a7884;
  --border: #d8e0e6;
  --danger: #c0392b;
  --warn: #d98e00;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
header.topbar {
  background: linear-gradient(90deg, var(--topbar-1), var(--topbar-2));
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  border-bottom: 2px solid var(--brand);
}
header.topbar .brand { display: flex; align-items: center; gap: 12px; }
header.topbar .brand .logo {
  height: 140px; width: auto; max-width: 600px;
  display: block;
  object-fit: contain;
}
header.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .3px; }
header.topbar nav a {
  color: #fff; text-decoration: none; margin-left: 16px;
  font-size: 14px; opacity: .9;
}
header.topbar nav a:hover { opacity: 1; text-decoration: underline; }

main { max-width: 1100px; margin: 24px auto; padding: 0 20px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card h2 { margin-top: 0; color: var(--brand-dark); font-size: 18px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.flash.ok { background: #e6f4ea; color: #1d6b3e; border: 1px solid #b5dcc4; }
.flash.err { background: #fdecea; color: #a4271b; border: 1px solid #f5c4be; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
input[type=text], input[type=email], input[type=number], input[type=date],
input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit; background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

.checkgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px;
}
.checkgrid label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkgrid input[type=checkbox] { width: 16px; height: 16px; }

button, .btn {
  background: var(--brand); color: #fff; border: none; padding: 9px 16px;
  border-radius: 6px; font-size: 14px; cursor: pointer; font-weight: 600;
  text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #ffffff; color: var(--brand); border: 1px solid var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: #fafafa; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.tag.ok { background: #e6f4ea; color: #1d6b3e; }
.tag.low { background: #fff1cf; color: #8a5b00; }
.tag.high { background: #fdecea; color: #a4271b; }
.tag.na { background: #eef2f5; color: var(--muted); }

.chem-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; margin-bottom: 6px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo-grid img { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

.footer {
  text-align: center; padding: 18px; color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--border); margin-top: 40px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.footer .powered { display: flex; align-items: center; gap: 8px; }
.footer .powered img, .footer .powered .placeholder {
  height: 22px; opacity: .75;
}
.footer .placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 10px; border: 1px dashed var(--border); border-radius: 4px;
  font-size: 11px; color: var(--muted);
}

.rec-list li { margin-bottom: 6px; }

@media print {
  header.topbar, .no-print { display: none !important; }
  body { background: #fff; }
  main { max-width: 100%; margin: 0; padding: 0; }
  .card { box-shadow: none; border: none; }
}

/* ---- responsive: tablets (<= 900px) and phones (<= 640px) ---- */
@media (max-width: 900px) {
  header.topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  header.topbar .brand h1 { font-size: 16px; }
  header.topbar nav { width: 100%; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
  header.topbar nav a {
    margin-left: 0;
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(255,255,255,.08);
    font-size: 14px;
  }
  main { padding: 0 12px; margin: 14px auto; }
  .card { padding: 14px; }
  .row, .row-2, .row-3 { grid-template-columns: 1fr !important; }
  /* tables: allow horizontal scroll instead of squishing */
  .card { overflow-x: auto; }
  table { min-width: 100%; }
}

@media (max-width: 640px) {
  /* prevent iOS from auto-zooming when focusing inputs */
  input[type=text], input[type=email], input[type=number], input[type=date],
  input[type=password], input[type=color], input[type=file], select, textarea {
    font-size: 16px;
    padding: 12px 12px;
  }
  /* touch-friendly buttons */
  button, .btn { padding: 12px 16px; font-size: 15px; min-height: 44px; }
  .btn.small { padding: 8px 12px; font-size: 13px; min-height: 36px; }
  header.topbar .brand .logo { height: 90px; }
  header.topbar h1 { font-size: 14px; }
  /* let chemistry-row stack */
  .chem-row { grid-template-columns: 1fr; gap: 6px; }
  /* photo grid: 2 columns on phones (was 3) */
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .photo-grid img { height: 110px; }
  /* checkgrid: 1 column on phones */
  .checkgrid { grid-template-columns: 1fr; }
  /* details/summary spacing for reports list */
  details > summary { padding: 14px !important; font-size: 14px; }
  /* hero banners: stack action-button below the message on narrow screens */
  .hero-banner-row { flex-direction: column; align-items: stretch !important; }
  .hero-banner-row .btn,
  .hero-banner-row a.btn { width: 100%; text-align: center; }
}

/* Spinner used for loading indicators across the app */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  opacity: 0.85;
}
.btn[disabled], button[disabled] { opacity: 0.65; cursor: progress; }
@keyframes spin { to { transform: rotate(360deg); } }
