:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --text: #15232a;
  --muted: #5b6b72;
  --line: #dbe3e6;
  --brand: #0e4f5c;
  --brand-text: #ffffff;
  --needs: #b3261e;
  --needs-bg: #fdecea;
  --answer: #0b6b3a;
  --answer-bg: #e6f4ec;
  --job: #8a5a00;
  --job-bg: #fdf3e1;
  --info: #45555c;
  --info-bg: #eef2f3;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f171a;
    --surface: #172327;
    --text: #e6eef0;
    --muted: #9aabb1;
    --line: #2a3a40;
    --brand: #4fb3c6;
    --brand-text: #071316;
    --needs: #ff8a80;
    --needs-bg: #3a1714;
    --answer: #7fd6a5;
    --answer-bg: #10301f;
    --job: #f2c062;
    --job-bg: #33270d;
    --info: #b5c3c8;
    --info-bg: #1f2d32;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--brand);
  color: var(--brand-text);
}
.bar h1 { margin: 0; font-size: 1.15rem; font-weight: 650; }
.count {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.85rem;
  font-weight: 600;
}

main { max-width: 640px; margin: 0 auto; padding: 16px; }

.panel {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; }
.notice { border-color: var(--brand); }
.notice p { margin: 0 0 12px; }
.notice p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { margin: 12px 0 0; color: var(--needs); }
.status { min-height: 1.2em; margin: 0 0 8px; color: var(--muted); font-size: 0.9rem; }

label { display: block; margin-bottom: 6px; font-weight: 600; }
input[type="password"] {
  width: 100%;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

button {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: default; }
button.secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-weight: 500;
}
button.link {
  min-height: 0;
  padding: 8px 0 0;
  background: none;
  color: var(--brand);
  font-weight: 500;
  text-decoration: underline;
}
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs button {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}
.tabs button[aria-selected="true"] { border-color: var(--brand); background: var(--brand); color: var(--brand-text); font-weight: 600; }

.day { margin: 20px 0 8px; color: var(--muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.day:first-child { margin-top: 4px; }

.item {
  margin: 0 0 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 12px;
  background: var(--surface);
}
.item[data-group="needs-paul"] { border-left-color: var(--needs); }
.item[data-group="can-answer"] { border-left-color: var(--answer); }
.item[data-group="job"] { border-left-color: var(--job); }
.item.is-done { opacity: 0.65; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.badge { padding: 1px 8px; border-radius: 999px; background: var(--info-bg); color: var(--info); font-weight: 600; }
.item[data-group="needs-paul"] .badge { background: var(--needs-bg); color: var(--needs); }
.item[data-group="can-answer"] .badge { background: var(--answer-bg); color: var(--answer); }
.item[data-group="job"] .badge { background: var(--job-bg); color: var(--job); }
.client { color: var(--text); font-weight: 600; }
.when { margin-left: auto; }
.subject { margin: 6px 0 4px; font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }
.outcome { margin: 0 0 4px; font-weight: 500; }
.note { margin: 0 0 4px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 10px; }
.actions .open {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-text);
  font-weight: 600;
  text-decoration: none;
}
.actions .done { margin-left: auto; }

details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 8px; }
