:root {
  /* warm cream & beige palette */
  --navy: #5b4636;      /* dark brown: buttons, outlines */
  --navy-2: #7a6250;
  --teal: #8a6a3e;      /* caramel: ticks, progress, main action */
  --teal-soft: #f1e6d3;
  --bg: #f7f1e6;        /* cream page */
  --card: #fffdf8;
  --card-alt: #fbf6ec;
  --text: #3b2f25;
  --muted: #7d6c5b;
  --line: #e5d9c4;
  --header: #efe3cf;    /* beige header */
  --section: #e6d6ba;   /* beige section bars */
  --warn: #b5541c;
  --warn-soft: #fbeee6;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }

.top { background: var(--header); color: var(--text); border-bottom: 4px solid var(--teal); padding-top: env(safe-area-inset-top); }
.top-inner { max-width: 760px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-small { color: var(--teal); font-weight: 700; letter-spacing: .06em; font-size: 13px; }
.brand-big { font-weight: 800; font-size: 24px; line-height: 1.15; }
.link-btn { background: var(--card); border: 1px solid var(--line); color: var(--navy); border-radius: 8px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(22,40,58,.06); }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], textarea {
  width: 100%; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, textarea:focus, button:focus-visible { outline: 3px solid #d9bf94; outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px 16px; border-radius: 9px; border: 0; background: var(--navy); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.btn.teal { background: var(--teal); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.warn { background: var(--warn); }
.btn:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
input[type=date] { min-width: 0; -webkit-appearance: none; appearance: none; min-height: 48px; }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.choice button { padding: 14px 10px; border-radius: 9px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; }
.choice button[aria-pressed=true] { border-color: var(--teal); background: var(--teal-soft); color: var(--navy); }
.error { color: var(--warn); font-weight: 600; margin: 8px 0 0; }

/* Checklist */
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.meta .k { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.meta .v { font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
.progress { margin-top: 12px; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--teal); width: 0; transition: width .3s; }
.save-state { font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 18px; }
.save-state.bad { color: var(--warn); font-weight: 600; }

.section { margin-bottom: 14px; border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 2px rgba(22,40,58,.06); }
.section-head { background: var(--section); color: var(--text); padding: 12px 16px; font-weight: 800; font-size: 18px; }
.item { background: var(--card); padding: 14px 16px; border-top: 1px solid #eef2f4; }
.item:nth-child(odd) { background: var(--card-alt); }
.item-main { display: flex; gap: 12px; align-items: flex-start; }
.tick { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 6px; border: 2px solid var(--navy-2); background: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; margin-top: 1px; }
.tick[aria-checked=true] { background: var(--teal); border-color: var(--teal); }
.tick svg { width: 20px; height: 20px; }
.item-text { flex: 1; min-width: 0; }
.item-label { cursor: pointer; }
.ticked { color: var(--teal); font-weight: 700; font-size: 15px; margin-top: 3px; }
.note-view { color: var(--muted); font-size: 15px; margin-top: 4px; white-space: pre-wrap; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 99px; padding: 7px 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: #e9dfcd; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb .rm { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(22,40,58,.8); color: #fff; font-size: 16px; line-height: 26px; cursor: pointer; padding: 0; }
.thumb.loading { display: grid; place-items: center; font-size: 12px; color: var(--muted); text-align: center; padding: 4px; line-height: 1.2; }
textarea.note { margin-top: 10px; min-height: 70px; resize: vertical; }

.sig-wrap { border: 2px dashed var(--line); border-radius: 8px; background: #fff; touch-action: none; }
canvas.sig { display: block; width: 100%; height: 170px; }
.sig-img { max-width: 320px; width: 100%; background: #fff; border-radius: 6px; }
.banner { background: var(--teal-soft); color: var(--navy); border-radius: var(--radius); padding: 12px 16px; font-weight: 600; margin-bottom: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

/* Chief dashboard */
.list-day { font-weight: 800; margin: 18px 0 8px; color: var(--navy); }
.sheet-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 0; border-radius: 9px; padding: 12px 14px; margin-bottom: 8px; font: inherit; color: var(--text); cursor: pointer; box-shadow: 0 1px 2px rgba(22,40,58,.06); }
.sheet-row .who { flex: 1; min-width: 0; }
.sheet-row .who b { display: block; overflow-wrap: anywhere; }
.pill { font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 5px 9px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: var(--teal-soft); color: var(--teal); }
.pill.open { background: var(--warn-soft); color: var(--warn); }

/* Tasks from Chief Stew */
.section-head.task-head { background: var(--navy); color: #fffdf8; }
.task-title { font-weight: 700; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; }
.pill.due { background: var(--teal-soft); color: var(--navy); }
.task-notes { margin: 6px 0 0; padding-left: 18px; font-size: 15px; color: var(--text); }
.task-notes li { margin-top: 3px; }
select.select { width: 100%; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); min-height: 48px; }

.lightbox { position: fixed; inset: 0; background: rgba(10,18,26,.92); display: grid; place-items: center; z-index: 50; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 9px; font-weight: 600; z-index: 60; max-width: calc(100% - 32px); }

@media (max-width: 420px) {
  .brand-big { font-size: 20px; }
  .meta .v { font-size: 17px; }
}

@media print {
  body { background: #fff; }
  .top { border-bottom-width: 3px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print, #logoutBtn, .toast { display: none !important; }
  main { max-width: none; padding: 12px 0; }
  .section-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .item, .card { break-inside: avoid; box-shadow: none; }
  .thumb { width: 150px; height: 150px; }
}
.chip:disabled { opacity: .55; cursor: default; }
.section-head.today { background: var(--teal); color: #fffdf8; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.today-pill { background: #fffdf8; color: var(--teal); }

/* Phone-friendly task rows: small photo / note icons on the right */
.item-tools { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; margin-left: 4px; }
.icon-btn { min-width: 44px; height: 36px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--navy); font: inherit; font-size: 18px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 3px; }
.icon-btn.on { border-color: var(--teal); background: var(--teal-soft); }
.icon-btn .count { font-size: 12px; font-weight: 800; }
.icon-btn:disabled { opacity: .55; cursor: default; }
.ticked { font-size: 14px; }
.missed-label { color: var(--warn); font-weight: 800; font-size: 14px; margin-top: 3px; }
.item.is-missed { background: var(--warn-soft) !important; }

/* Sticky progress bar while scrolling */
.sticky-bar { position: sticky; top: 0; z-index: 20; background: var(--header); margin: 0 -16px 14px; padding: 8px 16px 10px; border-bottom: 1px solid var(--line); box-shadow: 0 2px 6px rgba(59,47,37,.08); }
.sb-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.sb-row b { flex: 1; min-width: 0; }
.sb-save { color: var(--muted); font-size: 13px; }
.sb-save.bad { color: var(--warn); font-weight: 700; }
.progress.slim { height: 5px; margin-top: 6px; }

/* Role buttons: one neat column on phones, three across on wide screens */
.choice.roles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* Today's weekly task inside the daily checklist */
.section-head.week-head { background: var(--teal); color: #fffdf8; }

/* Chief / EVA report */
.banner.checked { background: #e4efdc; color: #3d6b2a; }
.summary .sum-line { display: flex; flex-wrap: wrap; gap: 6px 16px; font-weight: 700; }
.sum-bad { color: var(--warn); }
.sum-ok { color: #3d6b2a; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.filters .chip[aria-pressed=true] { background: var(--navy); color: #fff; border-color: var(--navy); }
.filtered-out { display: none !important; }
.pill.due { background: var(--teal-soft); color: var(--navy); }

/* Today board */
.board-card h2 { margin-bottom: 8px; }
.board-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.board-card .board-row.sheet-row { box-shadow: none; border-radius: 0; margin: 0; padding: 10px 0; background: transparent; }
.board-row .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }

@media print {
  .item.is-missed { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Daily report for Captain */
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check-line input { width: 22px; height: 22px; }
.rep-head .rep-date { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.rep-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.rep-kpis > div { background: var(--card-alt); border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.rep-kpis b { display: block; font-size: 22px; color: var(--navy); }
.rep-kpis span { font-size: 13px; color: var(--muted); }
.rep-role { border-top: 1px solid var(--line); padding: 12px 0; break-inside: avoid; }
.rep-role:first-of-type { border-top: 0; padding-top: 0; }
.rep-role-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rep-stat { margin-top: 6px; font-weight: 600; }
.rep-sub { margin-top: 8px; font-size: 15px; }
.rep-sub ul { margin: 4px 0 0; padding-left: 20px; }
.rep-sub li { margin-top: 2px; }
.rep-bad { color: var(--warn); }
.rep-good { color: #3d6b2a; font-weight: 600; }
@media print {
  .rep-kpis > div, .progress > div, .pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rep-role { break-inside: avoid; }
}

/* Interior SOP page */
.sop-sec h3 { font-size: 16px; margin: 14px 0 6px; color: var(--navy); }
.sop-list { margin: 0; padding-left: 22px; }
.sop-list li { margin: 5px 0; }

/* Job list: stewardess name on each job */
.stew-field { display: flex; align-items: center; gap: 8px; margin: 10px 0 0 42px; font-size: 14px; color: var(--muted); }
.stew-field span { white-space: nowrap; font-weight: 700; }
.stew-field input { flex: 1; min-width: 0; padding: 8px 10px; font: inherit; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: inherit; }

/* "New version ready" bar */
.update-bar { position: sticky; top: 0; z-index: 50; display: block; width: 100%; border: 0; padding: 12px 16px; background: #8a6a3f; color: #fff; font: inherit; font-weight: 700; font-size: 15px; text-align: center; cursor: pointer; }

/* Second tap needed (Remove / Delete / Reopen) */
.confirming { background: #b3261e !important; border-color: #b3261e !important; color: #fff !important; }
