/* Material-inspired styling, mobile-first (crew uses phones in the field).
   Hand-rolled — no framework, no CDN; served by whitenoise. */

:root {
  --primary: #2d6a33;
  --primary-dark: #1e4b23;
  --on-primary: #ffffff;
  --primary-container: #b0d3ae;
  --surface: #ffffff;
  --background: #f2f5f0;
  --on-surface: #1a1c19;
  --muted: #5c6459;
  --outline: #c3ccc0;
  --outline-light: #dde4da;
  --error: #a3271b;
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
  --elev-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  color: var(--on-surface);
  background: var(--background);
}

/* ---- App bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.65rem 1rem;
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--elev-2);
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: var(--on-primary);
  text-decoration: none;
}
.nav {
  display: flex;
  gap: 0.25rem 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.nav a, .nav .linklike {
  color: #ddebdb;
  text-decoration: none;
  font-weight: 500;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
}
.nav a:hover, .nav .linklike:hover { color: var(--on-primary); }
.inline { display: inline; }
.linklike {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
}

/* ---- Layout ---- */
.container { max-width: 64rem; margin: 1rem auto 3rem; padding: 0 1rem; }
h1 { font-size: 1.6rem; font-weight: 500; margin: 0.75rem 0; }
h2 { font-size: 1.15rem; font-weight: 500; margin: 0.25rem 0 0.75rem; }
h3 { font-size: 1rem; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.page-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem 1rem; flex-wrap: wrap;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--elev-1);
  padding: 1rem;
}

/* ---- Buttons (Material filled / text) ---- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.55rem 1.4rem;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--primary-dark); box-shadow: var(--elev-1); }
.button.small { min-height: 2.1rem; padding: 0.25rem 0.9rem; font-size: 0.85rem; }
.linklike-dark {
  background: none; border: none; padding: 0.4rem 0.5rem; font: inherit;
  cursor: pointer; color: var(--primary); font-weight: 500;
  border-radius: 999px; text-decoration: none;
}
.linklike-dark:hover { background: #e4ede2; }

/* ---- Chips / badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  vertical-align: middle;
}
.badge.draft { background: #f4e5b3; color: #574a13; }
.badge.final { background: #cfe8d1; color: #1e4b23; }

/* ---- Messages ---- */
.message { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 1rem; box-shadow: var(--elev-1); }
.message.warning { background: #faf1d3; color: #574a13; }
.message.error { background: #f8ded9; color: var(--error); }
.message.success { background: #d8eeda; color: #1e4b23; }

/* ---- Tables ---- */
.scroll-x { overflow-x: auto; border-radius: 12px; box-shadow: var(--elev-1); }
.scroll-x table.data { box-shadow: none; }
table.data {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  border-radius: 12px;
  /* no overflow:hidden here — it would break position:sticky cells */
  box-shadow: var(--elev-1);
}
table.data th, table.data td {
  border-bottom: 1px solid var(--outline-light);
  padding: 0.6rem 0.75rem;
  text-align: left;
  white-space: nowrap;
}
table.data th { background: #e7ede4; font-weight: 600; font-size: 0.85rem; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.totals th { background: #d8eeda; }
tr.superseded td { color: #8a978c; background: #fafbfa; }
td.missing { background: #faf1d3; }

/* Grid: keep the block column visible while scrolling sideways on phones */
table.grid th:first-child, table.grid td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--outline-light);
}
table.grid th:first-child { background: #e7ede4; }
table.grid input.frac { width: 5rem; }

/* ---- Forms ---- */
input, textarea, select {
  font: inherit;
  font-size: 1rem; /* 16px: stops iOS zoom-on-focus */
}
form p label { display: block; font-weight: 500; margin-bottom: 0.25rem; }
form p input, form p textarea, form p select,
.inline-form input, table.grid input.frac, .grid-save textarea {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--outline);
  border-radius: 8px;
  background: var(--surface);
}
form p input, form p textarea, form p select { width: 100%; max-width: 22rem; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}
form .helptext { display: block; color: var(--muted); font-size: 0.85rem; }
form .errorlist { color: var(--error); margin: 0.2rem 0; padding-left: 1rem; }
.inline-form { display: inline-flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }
.inline-form input { width: 5.5rem; }
.grid-save { margin-top: 1rem; }
.grid-save textarea { width: 100%; max-width: 42rem; display: block; margin: 0.5rem 0; }
.form-narrow { max-width: 26rem; }
.finalize { margin-top: 1rem; }

/* ---- Misc ---- */
.login-box { max-width: 26rem; margin: 3rem auto; text-align: center; }
.obs { border-top: 1px solid var(--outline-light); padding: 0.6rem 0; }
.obs:first-of-type { border-top: none; }
.hours-whole { font-variant-numeric: tabular-nums; }

/* ---- Phone tweaks ---- */
@media (max-width: 640px) {
  .container { padding: 0 0.75rem; margin-top: 0.75rem; }
  h1 { font-size: 1.35rem; }
  table.data th, table.data td { padding: 0.55rem 0.6rem; font-size: 0.9rem; }
  .page-head .button { width: 100%; }
  .login-box { margin-top: 2rem; }
}
