:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #17221e;
  --ink-2: #4b5a54;
  --muted: #7b8a84;
  --line: #e2e8e5;
  --brand: #0f6b57;
  --brand-2: #0b5444;
  --brand-soft: #e3f1ec;
  --ok: #188a5b;
  --ok-soft: #e6f5ee;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --err: #c0392b;
  --err-soft: #fbe9e7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 40, 32, .06), 0 4px 16px rgba(16, 40, 32, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: .35rem; }
.muted { color: var(--muted); margin: .25rem 0 0; }
.small { font-size: .85rem; }
.right { text-align: right; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Topbar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-text small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; margin-top: -2px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; font-weight: 700; font-size: .85rem; letter-spacing: .02em; }
.brand-mark.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 1.15rem; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav > a { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav > a:hover { background: var(--bg); text-decoration: none; }
.nav > a.on { background: var(--brand-soft); color: var(--brand-2); }
.nav-user { display: flex; align-items: center; gap: 8px; margin-left: 10px; padding-left: 14px; border-left: 1px solid var(--line); font-weight: 500; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-2); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.logout { font-size: .85rem; color: var(--muted); margin-left: 4px; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; cursor: pointer; }

/* ---------- Layout ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Alerts / chips ---------- */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-error { background: var(--err-soft); color: var(--err); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-2); font-size: .72rem; font-weight: 600; vertical-align: middle; border: 1px solid var(--line); }
.chip-today { background: var(--brand-soft); color: var(--brand-2); border-color: transparent; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-err { background: var(--err-soft); color: var(--err); border-color: transparent; }

/* ---------- Forms / buttons ---------- */
.form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 500; font-size: .88rem; color: var(--ink-2); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input:disabled, textarea:disabled { background: var(--bg); color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border-radius: 9px; padding: 9px 16px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--bg); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { min-width: 150px; }

/* ---------- Auth ---------- */
.page-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), var(--bg)); }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 1.35rem; margin-top: 12px; }
.auth-brand p { color: var(--muted); margin: 4px 0 0; font-size: .9rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: .82rem; margin: 18px 0 0; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 70px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--brand); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; padding: 6px; }

/* ---------- Check list ---------- */
.cl-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.cl-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg a { padding: 7px 14px; border-radius: 8px; color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.seg a:hover { text-decoration: none; }
.seg a.on { background: var(--brand); color: #fff; }
.datenav { display: flex; gap: 6px; align-items: center; }
.datenav input[type=date] { width: auto; }
.datenav .btn { padding: 8px 12px; }

.progress-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; box-shadow: var(--shadow); position: sticky; top: 68px; z-index: 10; }
.progress-top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.pct { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #23a383); border-radius: 99px; transition: width .35s ease; }

.cl-section { margin-bottom: 22px; }
.cl-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--brand-2); font-weight: 700; margin: 0 0 8px 4px; }
.cl-items { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cl-item { display: flex; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); transition: background .2s; }
.cl-item:first-child { border-top: 0; }
.cl-item.done { background: #f7fbf9; }
.cl-item.done .cl-title { color: var(--ink-2); }
.cl-item.busy { opacity: .7; }
.cl-check { position: relative; flex: 0 0 auto; display: block; padding-top: 1px; cursor: pointer; }
.cl-check input { position: absolute; opacity: 0; width: 26px; height: 26px; margin: 0; cursor: pointer; }
.cl-check .box { display: block; width: 26px; height: 26px; border: 2px solid #c5d1cc; border-radius: 8px; background: #fff; transition: all .15s; }
.cl-check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--brand-soft); border-color: var(--brand); }
.cl-check input:checked + .box { background: var(--ok); border-color: var(--ok); }
.cl-check input:checked + .box::after { content: ""; position: absolute; left: 9px; top: 5px; width: 7px; height: 13px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.cl-check input:disabled + .box { opacity: .6; cursor: default; }
.cl-body { flex: 1; min-width: 0; }
.cl-title { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cl-title .num { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; min-width: 1.6em; }
.cl-desc { color: var(--ink-2); font-size: .9rem; margin-top: 2px; }
.cl-meta { display: flex; justify-content: space-between; gap: 10px; font-size: .78rem; min-height: 1.2em; margin-top: 4px; }
.cl-meta .who { color: var(--ok); font-weight: 600; }
.saved { color: var(--brand); opacity: 0; transition: opacity .25s; font-size: .78rem; font-weight: 600; }
.saved.show { opacity: 1; }
.cl-note { margin-top: 6px; font-size: .88rem !important; padding: 7px 10px !important; background: var(--bg) !important; border-color: transparent !important; }
.cl-note:focus { background: #fff !important; border-color: var(--brand) !important; }

.report-card { margin-top: 28px; }
.report-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.report-grid .full { grid-column: 1 / -1; }
.report-grid .total output { display: block; padding: 9px 11px; background: var(--brand-soft); border-radius: 9px; font-weight: 700; color: var(--brand-2); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500; opacity: 0; transition: all .25s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); }

/* ---------- Admin ---------- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--ink-2); font-size: .82rem; margin-top: 2px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfb; white-space: nowrap; }
.tbl tr:hover td { background: #fafcfb; }
.tbl .nowrap { white-space: nowrap; }
.minibar { display: inline-block; width: 80px; height: 6px; background: var(--bg); border-radius: 9px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.minibar span { display: block; height: 100%; background: var(--brand); }
.minibar.low span { background: var(--err); }
.minibar.mid span { background: var(--warn); }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: .85rem; }
.pager span.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 92px; }
.matrix td, .matrix th { text-align: center; padding: 5px 4px; font-size: .78rem; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: #fff; min-width: 220px; z-index: 1; }
.mx-ok { color: var(--ok); font-weight: 700; }
.mx-no { color: #d3dad7; }
details.card summary { cursor: pointer; font-weight: 600; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 60px; background: #fff; border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 8px 16px 14px; }
  body.nav-open .nav { display: flex; }
  .nav-user { margin: 8px 0 0; padding: 10px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .progress-card { top: 64px; }
}
@media (max-width: 520px) {
  .h1 { font-size: 1.2rem; }
  .cl-item { padding: 12px; gap: 10px; }
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cl-controls { width: 100%; }
}
@media print {
  .topbar, .no-print, .toast { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .page { padding: 0; max-width: none; }
  .card, .stat { box-shadow: none; break-inside: avoid; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .table-wrap { overflow: visible; }
}
