:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #667085;
  --line: #d7dce4;
  --brand: #12395f;
  --brand2: #1f6feb;
  --ok: #1a7f37;
  --nok: #b42318;
  --na: #667085;
  --warn: #b25e09;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --card: #171e28; --ink: #e8edf4; --muted: #9aa7b8;
    --line: #2b3542; --brand: #0d2a45; --brand2: #4b9bff;
  }
}
*, *::before, *::after { box-sizing: inherit; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand2); }

#topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--brand); color: #fff; padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  background: #fff2; border: 1px solid #fff4; border-radius: 8px;
  padding: 6px 9px; font-weight: 700; letter-spacing: .5px; font-size: 13px;
}
.brand small { display: block; opacity: .75; font-size: 11.5px; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; }

main { max-width: 900px; margin: 0 auto; padding: 14px 12px 60px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label.block { margin-bottom: 6px; }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 10px 11px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
}
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

button, .btnlike {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 10px 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: inline-block; text-decoration: none;
}
button.primary { background: var(--brand2); border-color: var(--brand2); color: #fff; font-weight: 600; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.big { width: 100%; padding: 14px; font-size: 16px; }
button.ghost { background: transparent; }
button.small, .small.btnlike { padding: 6px 10px; font-size: 12.5px; }

.periods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 560px) { .periods { grid-template-columns: 1fr; } }
.period { padding: 14px; text-align: left; }
.period small { display: block; color: var(--muted); font-size: 12px; }
.period.sel { border-color: var(--brand2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand2) 25%, transparent); }
.check { display: block; margin: 8px 0 16px; color: var(--ink); font-size: 14px; }
.check input { width: auto; margin-right: 6px; }
.check small { display: block; margin-left: 22px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.sticky {
  position: sticky; top: 52px; z-index: 10; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 14px;
}
.wlhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.wlhead small { display: block; }
.progress { height: 8px; background: var(--line); border-radius: 99px; margin: 10px 0 6px; overflow: hidden; }
#progFill { height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.progrow { display: flex; justify-content: space-between; align-items: center; font-size: 13px; gap: 8px; flex-wrap: wrap; }

.item { border-top: 1px solid var(--line); padding: 12px 0; }
.item:first-of-type { border-top: 0; }
.item.nok { background: color-mix(in srgb, var(--nok) 6%, transparent); border-radius: 8px; padding: 12px 10px; }
.item.note { background: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: 8px; padding: 12px 10px; }
.task { font-weight: 600; font-size: 14.5px; }
.freq { font-weight: 400; font-size: 11.5px; color: var(--muted); border: 1px solid var(--line);
        border-radius: 99px; padding: 1px 7px; margin-left: 6px; white-space: nowrap; }
.req { color: var(--muted); font-size: 13px; margin-top: 4px; }
.tag { display: inline-block; margin-top: 6px; font-size: 11.5px; color: var(--warn); }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.res-btn { padding: 9px 12px; font-size: 13.5px; }
.res-btn.ok.sel { background: var(--ok); border-color: var(--ok); color: #fff; }
.res-btn.nok.sel { background: var(--nok); border-color: var(--nok); color: #fff; }
.res-btn.na.sel { background: var(--na); border-color: var(--na); color: #fff; }
.measurebox { display: inline-flex; align-items: center; gap: 6px; }
.measurebox input { width: 110px; margin-top: 0; }
.measurebox .unit { font-size: 13px; color: var(--muted); }
.comment { margin-top: 8px; }

.submitbar { position: sticky; bottom: 0; }
.big-ok { font-size: 44px; color: var(--ok); }
.warntext { color: var(--warn); }

table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th, table.list td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
.pill { font-size: 11.5px; border-radius: 99px; padding: 2px 9px; border: 1px solid var(--line); }
.pill.draft { color: var(--warn); }
.pill.submitted { color: var(--brand2); }
.pill.uploaded { color: var(--ok); }
.pill.offline { background: var(--warn); color: #fff; border: 0; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: #16202e; color: #fff; padding: 12px 16px; border-radius: 10px;
  max-width: 90vw; z-index: 50; font-size: 14px; box-shadow: 0 6px 24px #0004;
}
#toast.err { background: var(--nok); }
#toast.ok { background: var(--ok); }
#toast.warn { background: var(--warn); }
