* { box-sizing: border-box; margin: 0; }
:root {
  --bg: #f4f5f7; --card: #ffffff; --line: #e4e7ec;
  --text: #1a202c; --muted: #667085; --accent: #2563eb;
  --green: #16a34a; --red: #dc2626; --orange: #d97706;
  --r: 12px;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 12px 12px 48px; }
.wrap-wide { max-width: 960px; }
header.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 4px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 19px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 12px; display: block; }
.bar-right { display: flex; align-items: center; gap: 8px; }

h2.section {
  font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 18px 4px 8px; font-weight: 600;
}
h2.section.danger { color: var(--red); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; margin-bottom: 8px;
}
.card.overdue { border-color: #fecaca; background: #fffbfb; }
.card.done-card { opacity: .72; }
.task-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.task-title { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.task-title.struck { text-decoration: line-through; font-weight: 400; }
.task-desc { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-meta { margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.note-row { display: flex; gap: 8px; margin-top: 10px; }
.note-row input { flex: 1; }

.chip {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; white-space: nowrap;
}
.chip-amber { background: #faeeda; color: #633806; }
.chip-teal { background: #e1f5ee; color: #085041; }
.chip-purple { background: #eeedfe; color: #3c3489; }

.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.badge.ok { background: #ecfdf3; color: #067647; }
.badge.late { background: #fffaeb; color: #b54708; }
.badge.missed { background: #fef3f2; color: #b42318; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 15px;
  min-height: 44px;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-done { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 6px 10px; min-height: 0; }
.btn-ghost.danger { color: var(--red); }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: 14px; }

input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays label {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; cursor: pointer; background: #fff; display: flex; gap: 6px; align-items: center;
}
.weekdays input { width: auto; min-height: 0; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.metric .v.red { color: var(--red); }

.hh-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.hist-row {
  display: flex; justify-content: space-between; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid var(--line); font-size: 14px; align-items: flex-start;
}
.hist-row:last-child { border-bottom: none; }
.hist-row .l { min-width: 0; }
.hist-row .note { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.hist-row .d { color: var(--muted); white-space: nowrap; font-size: 13px; text-align: right; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }

details.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin: 10px 0; }
details.box summary { font-weight: 600; cursor: pointer; min-height: 32px; display: flex; align-items: center; }

.login-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.login-card form > * { margin-bottom: 12px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1a202c; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50;
  max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 4px; }
