:root {
  --bg: #f4f6f8; --card: #ffffff; --ink: #14202b; --muted: #5d6b79; --line: #dde3ea;
  --brand: #0e5a6e; --brand-ink: #ffffff; --brand-soft: #e1f0f4;
  --good: #1a7f4b; --good-soft: #e0f3e8; --bad: #b3261e; --bad-soft: #fbe5e3; --warn: #8a5a00; --warn-soft: #fff1cf;
  --shadow: 0 1px 2px rgba(20,32,43,.06), 0 4px 14px rgba(20,32,43,.05);
  --r: 14px;
}
:root[data-theme="dark"] {
  --bg: #0f161c; --card: #172028; --ink: #e8eef3; --muted: #98a7b5; --line: #2a3742;
  --brand: #3fb0c9; --brand-ink: #06232b; --brand-soft: #14323b;
  --good: #4cc98a; --good-soft: #143325; --bad: #ff8a80; --bad-soft: #3a1b19; --warn: #f1c35a; --warn-soft: #3a2f12;
  --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: .2rem 0 .8rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.hide { display: none !important; }

/* shell */
#top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
#top .brand { flex: 1; font-weight: 700; font-size: 1.05rem; color: inherit; text-decoration: none; line-height: 1.15; }
#top .brand small { display: block; font-weight: 500; opacity: .85; font-size: .75rem; }
#top button { background: rgba(255,255,255,.18); color: inherit; border: 0; border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; }
#drawer { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); background: var(--card); box-shadow: var(--shadow); transform: translateX(-105%); transition: transform .18s; overflow-y: auto; padding: 14px 10px 30px; border-right: 1px solid var(--line); }
#drawer.open { transform: none; }
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
#drawer .grp { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 14px 10px 4px; }
#drawer a { display: block; padding: 11px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; }
#drawer a:hover, #drawer a.on { background: var(--brand-soft); color: var(--brand); }
#main { max-width: 760px; margin: 0 auto; padding: 14px 14px 30px; min-height: 70vh; }
#main.wide { max-width: 1100px; }
#foot { text-align: center; padding: 18px 14px 30px; color: var(--muted); font-size: .85rem; }
#foot a, #foot button { color: var(--muted); background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; padding: 6px; }
@media (min-width: 980px) {
  #drawer { transform: none; top: 56px; width: 250px; }
  #scrim, #menuBtn { display: none !important; }
  #main, #foot { margin-left: 250px; max-width: none; padding-left: 28px; padding-right: 28px; }
  #main > * { max-width: 860px; }
  #main.wide > * { max-width: 1100px; }
  #foot { margin-left: 250px; }
}

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 0 0 12px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.good { background: var(--good-soft); border-color: transparent; }
.card.bad { background: var(--bad-soft); border-color: transparent; }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.card.info { background: var(--brand-soft); border-color: transparent; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.grid.g3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
@media (min-width: 640px) { .grid.t3 { grid-template-columns: repeat(3, 1fr); } }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 12px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); min-height: 84px; }
.tile b { display: block; font-size: 1.02rem; }
.tile span { color: var(--muted); font-size: .85rem; }
.tile .ico { font-size: 1.5rem; display: block; margin-bottom: 2px; }
.tile.done { border-color: var(--good); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.sp { justify-content: space-between; }
.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.back { display: inline-block; margin: 0 0 6px; text-decoration: none; font-weight: 600; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 18px; min-height: 48px; font: inherit; font-weight: 700; cursor: pointer; background: var(--brand); color: var(--brand-ink); text-decoration: none; }
.btn.sm { min-height: 38px; padding: 7px 12px; font-size: .9rem; border-radius: 10px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.line { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn.good { background: var(--good); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn.huge { min-height: 76px; font-size: 1.4rem; border-radius: 18px; }
.btn[disabled] { opacity: .55; cursor: default; }
.link { background: none; border: 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; padding: 4px 0; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--brand-soft); color: var(--brand); }
.bar { height: 8px; border-radius: 9px; background: var(--line); overflow: hidden; margin: 6px 0 2px; }
.bar i { display: block; height: 100%; background: var(--good); }

/* forms */
label.f { display: block; margin: 0 0 14px; font-weight: 600; }
label.f > .hint { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); margin-top: 4px; min-height: 48px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.seg { display: flex; gap: 8px; margin-top: 4px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 48px; border: 1.5px solid var(--line); border-radius: 10px; font-weight: 700; cursor: pointer; background: var(--card); }
.seg input:checked + span { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg.warnyes input[value="1"]:checked + span { background: var(--bad); border-color: var(--bad); color: #fff; }
.checks label { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; margin: 6px 0; font-weight: 500; cursor: pointer; background: var(--card); }
.checks input { width: 22px; height: 22px; margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 99px; padding: 7px 14px; font: inherit; cursor: pointer; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters label { margin: 0; font-size: .8rem; font-weight: 600; color: var(--muted); flex: 1 1 130px; }
.filters input, .filters select { margin-top: 2px; min-height: 42px; padding: 8px 10px; }

/* duty rows */
.duty { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.duty:first-child { border-top: 0; }
.tick { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: transparent; font-size: 1.5rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.duty.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.duty.unable .tick { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.duty.missed .tick { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.duty .t { flex: 1; min-width: 0; }
.duty .t b { font-weight: 600; }
.duty.done .t b { color: var(--muted); }
.duty .meta { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.reminder { border-left: 5px solid var(--brand); background: var(--brand-soft); padding: 11px 13px; border-radius: 10px; margin: 0 0 12px; font-weight: 500; }
.reminder.warn { border-color: var(--warn); background: var(--warn-soft); }

/* photos */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.thumbs img, .thumbs .ph { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; background: var(--line); }
.thumbs .ph { position: relative; }
.thumbs .ph button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; font-weight: 800; cursor: pointer; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pgrid figure { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .8rem; }
.pgrid img { width: 100%; height: 130px; object-fit: cover; display: block; cursor: zoom-in; }
.pgrid figcaption { padding: 6px 8px; }
#light { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 10px; }
#light img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* modal + toast */
#modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
#modal .box { background: var(--card); width: min(560px, 100%); max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px 24px; }
@media (min-width: 640px) { #modal { align-items: center; } #modal .box { border-radius: 18px; } }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(440px, 92vw); pointer-events: none; }
#toast div { background: var(--good); color: #fff; padding: 13px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#toast div.bad { background: var(--bad); }

/* login */
.login { max-width: 400px; margin: 24px auto; }
.login h1 { text-align: center; }

/* guides */
.guide h2 { margin-top: 1.8rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.guide ol, .guide ul { padding-left: 1.3rem; }
.guide li { margin: .25rem 0; }
.shot { border: 2px dashed var(--line); border-radius: 12px; padding: 22px 12px; text-align: center; color: var(--muted); margin: 10px 0; background: var(--card); font-size: .9rem; }

pre.diff { white-space: pre-wrap; word-break: break-word; font-size: .78rem; background: var(--bg); border-radius: 8px; padding: 8px; margin: 6px 0 0; }
.void { opacity: .55; text-decoration: line-through; }
@media print { #top, #drawer, #foot, .noprint { display: none !important; } #main { margin: 0 !important; max-width: none !important; } .shot { break-inside: avoid; } }
