/* Home. Mobile first: one column, big tap targets. The desktop block is LAST (see the
   banner at the bottom): media queries add no specificity, so anything written below it
   would win on source order. */
:root {
  --green: #2f5233;
  --green-light: #4d7c4d;
  --red: #b3452c;
  --amber: #c98a2b;
  --bg: #f6f4ef;
  --card-bg: #ffffff;
  --text: #23291f;
  --muted: #6b7160;
  --border: #ddd6c6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Beats every component's own display value, wherever it's declared. */
.hidden { display: none !important; }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--green);
  color: white;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}

.header-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end; }
.current-user { font-size: 0.85rem; font-weight: 600; }
.status-bar { font-size: 0.8rem; opacity: 0.9; flex-basis: 100%; text-align: right; }
.status-bar:empty { display: none; }

select, input, textarea, button {
  font: inherit;
  padding: 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

button { cursor: pointer; background: var(--green); color: white; border-color: var(--green); min-height: 44px; }
button[disabled] { opacity: 0.55; cursor: default; }
.secondary-btn { background: transparent; color: white; border-color: rgba(255, 255, 255, 0.6); white-space: nowrap; min-height: 0; }
.quiet-btn { background: white; color: var(--green); border-color: var(--border); }
.quiet-btn.current { border-color: var(--green); font-weight: 700; }
.danger-btn { background: white; color: var(--red); border: 1px solid var(--red); font-weight: 600; }
.link-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.8rem;
  border: 1px solid var(--border); border-radius: 6px; color: var(--green); text-decoration: none; background: white;
}

main { max-width: 760px; margin: 0 auto; padding: 0.75rem; padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px)); }

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.8rem;
}
.home-section h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.home-section h3 { margin: 0.8rem 0 0.35rem; font-size: 0.95rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.section-head h2 { margin: 0; }

.form-hint { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0; }
.muted-line { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0; }
.feedback { font-size: 0.85rem; margin: 0.3rem 0 0; }
.feedback.error, .auth-error { color: var(--red); }
.feedback:empty { display: none; }

.offline-note {
  background: #fff7e6; border: 1px solid #f0d9a8; color: #6b4a12;
  border-radius: 8px; padding: 0.55rem 0.75rem; font-size: 0.88rem; margin: 0 0 0.8rem;
}

.auth-screen {
  max-width: 380px; margin: 3rem auto; padding: 1.5rem;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
}
.auth-form { display: flex; flex-direction: column; gap: 0.5rem; }
.auth-form h2 { margin: 0; }
.auth-sub, .auth-note { color: var(--muted); font-size: 0.85rem; margin: 0; }
.auth-links { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; }
.auth-links a { color: var(--green); }
.button-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.stacked-form { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.4rem 0 0.8rem; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
.plain-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* Lists of jobs: each a link to the board, opened on that job. */
.home-job-list, .plain-list { list-style: none; margin: 0; padding: 0; }
.home-job {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.6rem 0.7rem; margin: 0 0 0.4rem;
  border: 1px solid var(--border); border-left: 5px solid var(--green-light); border-radius: 8px;
  color: inherit; text-decoration: none; background: #fcfbf8; min-height: 44px;
}
.home-job.overdue { border-left-color: var(--red); }
.home-job strong { font-size: 0.97rem; overflow-wrap: anywhere; }
.home-job span { color: var(--muted); font-size: 0.83rem; overflow-wrap: anywhere; }
.plain-list li { font-size: 0.88rem; padding: 0.25rem 0; overflow-wrap: anywhere; }

/* The full notifications list uses the drop-down's rows (switcher.css). */
.home-notify-list { border: 1px solid #eceef2; border-radius: 8px; margin-top: 0.5rem; overflow: hidden; }

/* The crew panel (moved from the board). */
.crew-list { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.5rem 0; }
.crew-row { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem; }
.crew-name { font-weight: 600; }
.crew-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; font-size: 0.82rem; }
.crew-email { color: var(--muted); overflow-wrap: anywhere; }
.crew-seen { font-size: 0.75rem; color: var(--muted); }
.crew-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.crew-feedback:empty { display: none; }
.chip { font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--border); font-weight: 600; }
.pending-chip { background: #fef3c7; color: #854d0e; }
.role-owner { background: #fef3c7; color: #92400e; }
.role-picker { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; flex-wrap: wrap; }
.role-legend { margin: 0.4rem 0; font-size: 0.88rem; }
.role-legend summary { cursor: pointer; color: var(--green); font-weight: 600; }
.role-legend dt { font-weight: 700; margin-top: 0.4rem; }
.role-legend dd { margin: 0.1rem 0 0; color: var(--muted); }
.reset-requests { border: 1px solid #f0d9a8; background: #fffaf0; border-radius: 8px; padding: 0.6rem; margin: 0.5rem 0; }
.reset-row { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.4rem 0; border-top: 1px solid #f0e3c4; }
.reset-row:first-of-type { border-top: 0; }
.reset-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.reset-when, .crew-phone-readout { font-size: 0.8rem; color: var(--muted); margin-left: 0.3rem; }
.code-panel { border: 2px solid var(--green); border-radius: 10px; padding: 0.8rem; margin-top: 0.6rem; background: #f3f8f2; }
.code-value { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.12em; margin: 0.3rem 0; font-family: ui-monospace, Menlo, monospace; }
.code-note { font-size: 0.82rem; color: var(--muted); }
.code-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.business-row { padding: 0.5rem 0; border-top: 1px solid #eee8db; }
.business-row:first-child { border-top: 0; }
.preview-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.view-as-banner {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  background: #eef4ff; border: 1px solid #c9d8f5; border-radius: 8px;
  padding: 0.55rem 0.75rem; margin: 0 0 0.8rem; font-size: 0.88rem;
}
.view-as-banner span { flex: 1 1 14rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Register and parts sections on Home (HOME_EXTENSIONS, none yet). Its sections take their own
   places in the desktop grid; while there are none it takes no place at all (an empty div
   was a grid item of its own, leaving a gap in the two columns). */
#home-extensions { display: contents; }
#home-extensions:empty { display: none; }

/* ===========================================================================
   KEEP THIS BLOCK LAST.
   Media queries add no specificity, so any rule written below this point wins
   over its desktop override on source order alone. New styles go ABOVE here.
   =========================================================================== */
@media (min-width: 900px) {
  main { max-width: 1100px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; align-items: start; }
  #offline-note, #view-as-banner, #org-deleted-banner { grid-column: 1 / -1; }
  #crew, #my-jobs { grid-column: 1 / -1; }
  .form-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .crew-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; }
}
