/* WashData: one mobile-first stylesheet for a 3-user field research tool,
   not a marketing site. System font stack, no CDN/webfont, high contrast,
   big touch targets (>=48px), light/dark via prefers-color-scheme. */

:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --fg: #14201a;
  --muted: #5b6a61;
  --border: #d6ddd8;
  --accent: #1f7a4d;
  --accent-fg: #ffffff;
  --accent-hover: #185f3c;
  --danger: #a3231f;
  --danger-bg: #fbe9e8;
  --due: #8a5a00;
  --due-bg: #fdf1dc;
  --overdue: #a3231f;
  --overdue-bg: #fbe9e8;
  --ok: #1f7a4d;
  --ok-bg: #e6f2ea;
  --upcoming-bg: #eef0ec;
  --radius: 10px;
  --touch: 48px;
  --focus: #2f6fed;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161a;
    --surface: #1a2027;
    --fg: #e9edf0;
    --muted: #9aa7ac;
    --border: #303a42;
    --accent: #3fbf7f;
    --accent-fg: #08150f;
    --accent-hover: #57cf92;
    --danger: #ff8a80;
    --danger-bg: #3a1c1c;
    --due: #f0b64e;
    --due-bg: #3a2f13;
    --overdue: #ff8a80;
    --overdue-bg: #3a1c1c;
    --ok: #3fbf7f;
    --ok-bg: #10281c;
    --upcoming-bg: #202830;
    --focus: #7aa2ff;
  }
}

:root[data-theme="dark"] {
  --bg: #12161a;
  --surface: #1a2027;
  --fg: #e9edf0;
  --muted: #9aa7ac;
  --border: #303a42;
  --accent: #3fbf7f;
  --accent-fg: #08150f;
  --accent-hover: #57cf92;
  --danger: #ff8a80;
  --danger-bg: #3a1c1c;
  --due: #f0b64e;
  --due-bg: #3a2f13;
  --overdue: #ff8a80;
  --overdue-bg: #3a1c1c;
  --ok: #3fbf7f;
  --ok-bg: #10281c;
  --upcoming-bg: #202830;
  --focus: #7aa2ff;
}

:root[data-theme="light"] {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --fg: #14201a;
  --muted: #5b6a61;
  --border: #d6ddd8;
  --accent: #1f7a4d;
  --accent-fg: #ffffff;
  --accent-hover: #185f3c;
  --danger: #a3231f;
  --danger-bg: #fbe9e8;
  --due: #8a5a00;
  --due-bg: #fdf1dc;
  --overdue: #a3231f;
  --overdue-bg: #fbe9e8;
  --ok: #1f7a4d;
  --ok-bg: #e6f2ea;
  --upcoming-bg: #eef0ec;
  --focus: #2f6fed;
}

* {
  box-sizing: border-box;
}

/* The [hidden] attribute must win over any author class on the same
   element (Task 6 introduced elements that are both class="btn ..." and
   toggled via the hidden property/attribute from capture.js; .btn's
   `display: inline-flex` below has equal specificity to the UA
   stylesheet's `[hidden] { display: none }` and, being author CSS, would
   otherwise beat it, leaving "hidden" buttons visibly on-screen). */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 0.6em;
}

h1 {
  font-size: 1.4rem;
}

h2 {
  font-size: 1.1rem;
  margin-top: 1.4em;
}

.muted {
  color: var(--muted);
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin: 0 0 1rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* --- layout ---------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0.75rem;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
  margin-right: auto;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  order: 3;
  width: 100%;
}

.main-nav a {
  text-decoration: none;
  color: var(--fg);
  padding: 0.2rem 0.15rem;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
}

.main-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lang-toggle a {
  text-decoration: none;
  color: var(--fg);
  padding: 0 0.55rem;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
}

.lang-toggle a[aria-current="true"] {
  background: var(--accent);
  color: var(--accent-fg);
}

.user-name {
  color: var(--muted);
  font-size: 0.9rem;
}

.page {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem 0.9rem 3rem;
}

.site-footer {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem 0.9rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer a {
  text-decoration: none;
}

/* --- buttons / forms --------------------------------------------------- */

.btn, button, input[type="submit"] {
  font: inherit;
  min-height: var(--touch);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
}

.btn-primary, button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

.btn-primary:hover, button[type="submit"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  min-height: var(--touch);
  padding: 0.3rem 0.6rem;
}

.btn-block {
  width: 100%;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

form.stacked-form,
form.filter-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 100%;
}

form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.95rem;
}

input, select, textarea {
  font: inherit;
  min-height: var(--touch);
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  width: 100%;
}

textarea {
  min-height: 5rem;
  font-family: inherit;
}

form.filter-form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-bottom: 1.2rem;
}

form.filter-form label {
  flex: 1 1 140px;
}

.auth-card {
  max-width: 360px;
  margin: 3rem auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
}

.auth-card h1 {
  text-align: center;
}

.auth-card h2 {
  margin-top: 0.2em;
  text-align: center;
  color: var(--muted);
  font-weight: 500;
}

.auth-card .lang-toggle {
  margin: 0 auto 1.2rem;
  display: flex;
  justify-content: center;
  width: fit-content;
}

.auth-intro {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin-top: -0.4rem;
}

/* --- tables -------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface);
}

/* --- day page / entry cards ------------------------------------------ */

.day-section {
  margin-bottom: 1.4rem;
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.entry-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.entry-card a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
  color: var(--fg);
  min-height: var(--touch);
  justify-content: center;
}

.entry-id {
  font-weight: 700;
}

.entry-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.status-due {
  background: var(--due-bg);
  border-color: var(--due);
}

.status-overdue {
  background: var(--overdue-bg);
  border-color: var(--overdue);
}

.status-upcoming {
  background: var(--upcoming-bg);
  padding: 0.6rem 0.9rem;
}

.status-resumable {
  border-color: var(--accent);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

.empty-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- plant detail ------------------------------------------------------ */

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
  margin: 0 0 1rem;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.detail-list dd {
  margin: 0 0 0.3rem;
}

.session-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.session-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  background: var(--surface);
}

.session-card.session-complete {
  border-left: 4px solid var(--ok);
}

.session-card.session-open {
  border-left: 4px solid var(--due);
}

.session-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.session-status {
  font-size: 0.85rem;
  font-weight: 600;
}

.session-date {
  color: var(--muted);
  font-size: 0.85rem;
}

.session-notes {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 0.4rem;
}

img.thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
  background: var(--upcoming-bg);
}

.thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.4rem;
}

/* --- wash results ------------------------------------------------------ */

.wash-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.wash-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  background: var(--surface);
}

.wash-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.wash-pct {
  color: var(--accent);
}

.fractions-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
}

.fractions-fieldset legend {
  font-weight: 600;
  padding: 0 0.4rem;
}

.fraction-row {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.fraction-row label {
  flex: 1;
}

/* --- portfolios --------------------------------------------------------- */

.portfolio-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.portfolio-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.7rem 0.9rem;
}

.portfolio-card > a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.completeness {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.completeness-bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: var(--upcoming-bg);
  overflow: hidden;
}

.completeness-fill {
  height: 100%;
  background: var(--accent);
}

.completeness-label {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

/* --- strain page --------------------------------------------------------- */

.strain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.8rem;
}

.strain-plant-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.6rem;
  text-decoration: none;
  color: var(--fg);
}

.strain-plant-card img.thumb,
.strain-plant-card .thumb-placeholder {
  aspect-ratio: 4 / 3;
  margin-bottom: 0.3rem;
}

/* --- help page ------------------------------------------------------- */

.help-section {
  margin-bottom: 1.6rem;
}

.help-section h2 {
  color: var(--accent);
}

/* --- Task 6: generic notice banner (day-page/capture-complete banners,
   password-change prompt, admin temp-password display) ------------------ */

.notice {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid var(--ok);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin: 0 0 1rem;
}

/* --- Task 6: capture entry page (/capture) ----------------------------- */

.capture-entry-actions {
  margin-bottom: 1rem;
}

.scan-area {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.scan-area video {
  width: 100%;
  max-height: 60vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
  object-fit: cover;
}

.capture-manual-form {
  margin: 1rem 0 1.4rem;
}

/* --- Task 6: capture session screen (/capture/{id}) --------------------- */

.capture-progress {
  font-weight: 600;
  margin-bottom: 0.8rem;
}

.active-shot-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: stretch;
}

.active-shot-card h2 {
  margin: 0;
}

.shot-ref-icon {
  display: flex;
  justify-content: center;
  color: var(--muted);
}

#camera-video {
  width: 100%;
  max-height: 55vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
  object-fit: cover;
}

#preview-img {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}

.shot-status {
  min-height: 1.4rem;
  font-weight: 600;
}

.shot-status.status-ok {
  color: var(--ok);
}

.shot-status.status-failed {
  color: var(--danger);
}

.shot-checklist {
  list-style: none;
  margin: 0 0 1.2rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.shot-checklist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.5rem 0.8rem;
  min-height: var(--touch);
  cursor: pointer;
}

.shot-checklist-item.shot-done {
  border-color: var(--ok);
}

.shot-checklist-item.shot-active {
  border-color: var(--accent);
  border-width: 2px;
}

.shot-checklist-count {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.shot-done .shot-checklist-count {
  color: var(--ok);
  font-weight: 600;
}

/* --- Task 6: admin ------------------------------------------------------ */

.temp-password-notice {
  text-align: center;
}

.temp-password {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: all;
}

.labels-picker-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.6rem;
  font-weight: 400 !important;
  cursor: pointer;
}

.labels-picker-checkbox {
  width: auto;
  min-height: auto;
  flex: none;
}
