:root {
  --ui-bg:#f2f2f7;
  --ui-surface:#fff;
  --ui-surface-muted:#f9f9fb;
  --ui-text:#1c1c1e;
  --ui-text-secondary:#6e6e73;
  --ui-line:#d8d8de;
  --ui-accent:#0a84ff;
  --ui-action:#0066cc;
  --ui-success:#248a58;
  --ui-warning:#a85e0a;
  --ui-danger:#b53b3b;
  --ui-radius-control:6px;
  --ui-radius-card:8px;
  --ui-radius:var(--ui-radius-card);
  --ui-touch-min:44px;
  --ui-focus:0 0 0 3px rgba(10,132,255,.18);
  --blue: var(--ui-action);
  --blue-weak: var(--ui-surface-muted);
  --green: var(--ui-success);
  --green-weak: var(--ui-surface-muted);
  --amber: var(--ui-warning);
  --amber-weak: var(--ui-surface-muted);
  --red: var(--ui-danger);
  --red-weak: var(--ui-surface-muted);
  --ink: var(--ui-text);
  --muted: var(--ui-text-secondary);
  --line: var(--ui-line);
  --bg: var(--ui-bg);
  --surface: var(--ui-surface);
  --shadow: 0 1px 3px rgba(28, 28, 30, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; display: flex; flex-direction: column; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; letter-spacing: 0; }
#app { flex: 1 0 auto; }
.site-filing {
  flex: 0 0 auto;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.site-filing a { color: inherit; text-decoration: none; }
.site-filing a:hover { text-decoration: underline; }
body:has(.bottom-nav) .site-filing {
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:where(button, input, select, textarea):focus-visible { outline: 0; box-shadow: var(--ui-focus); }
.boot { padding: 32px 20px; color: var(--muted); text-align: center; }
.toast {
  position: fixed; top: calc(72px + env(safe-area-inset-top)); left: 50%; z-index: 60;
  transform: translateX(-50%); min-width: 108px; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 8px; background: var(--ink); color: #fff;
  box-shadow: var(--shadow); text-align: center; font-size: 14px;
}

.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 62px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid rgba(216, 216, 222, .82);
  background: rgba(255, 255, 255, .88); color: var(--ink);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
}
.top-title { min-width: 0; }
.top-title h1 { margin: 0; overflow: hidden; font-size: 20px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.top-title small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.topbar > .top-actions:first-child { flex: 1 1 auto; min-width: 0; }
.user-chip { max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.password-action { min-height: var(--ui-touch-min); padding: 6px 8px; border: 0; background: transparent; color: var(--ui-action); font: inherit; font-size: 13px; white-space: nowrap; }

.page { width: min(100%, 980px); margin: 0 auto; padding: 16px 14px calc(88px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 21px; }
.section { margin: 0 0 24px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section h2, .section h3 { margin: 0; font-size: 18px; }
.section-count { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 10px; }
.empty { padding: 22px 8px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.task-card, .notice-row, .account-row {
  width: 100%; min-width: 0; display: block; border: 1px solid var(--line); border-radius: var(--ui-radius-card);
  background: var(--surface); box-shadow: var(--shadow); color: inherit; text-align: left;
}
.task-card { padding: 14px; }
.task-card:active { background: var(--ui-surface-muted); }
.task-card.is-pending { padding-left: 11px; border-left: 4px solid var(--ui-action); }
.task-card.is-confirmed { border-color: rgba(36, 138, 88, .32); }
.task-card.is-draft { border-style: dashed; background: var(--ui-surface-muted); }
.task-card.is-cancelled { border-color: rgba(181, 59, 59, .28); background: #fffafa; color: var(--ui-text-secondary); }
.task-card.is-archived { border-color: #e4e4e8; background: var(--ui-surface-muted); color: var(--ui-text-secondary); }
.task-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-card h3 { margin: 0; min-width: 0; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.task-card-category { margin-top: 5px; color: var(--muted); font-size: 13px; }
.task-card-meta { display: grid; gap: 7px; margin-top: 12px; }
.task-card-meta .meta-item { min-width: 0; display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: baseline; gap: 8px; }
.task-card-meta .meta-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.task-card-meta .meta-value { min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.task-card-meta .meta-time .meta-value { font-size: 15px; font-weight: 700; }
.task-card-meta .meta-location .meta-value { font-size: 14px; font-weight: 550; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); font-size: 14px; }
.task-duty { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--blue); font-weight: 600; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border: 1px solid currentColor; border-radius: 999px; font-size: 12px; line-height: 1.2; white-space: nowrap; }
.badge.blue { color: var(--blue); background: var(--blue-weak); }
.badge.green { color: var(--green); background: var(--green-weak); }
.badge.amber { color: var(--amber); background: var(--amber-weak); }
.badge.red { color: var(--red); background: var(--red-weak); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(216, 216, 222, .82); background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
}
.nav-btn { min-height: var(--ui-touch-min); min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 0; background: transparent; color: var(--muted); font-size: 13px; border-radius: var(--ui-radius-control); }
.nav-btn.active { color: var(--ui-action); background: var(--ui-surface-muted); font-weight: 700; }
.nav-btn:focus-visible { position: relative; z-index: 1; box-shadow: var(--ui-focus); }
.nav-label { min-width: 0; line-height: 1.2; white-space: normal; overflow-wrap: anywhere; }
.nav-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 3px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; }

.btn { min-height: var(--ui-touch-min); border: 1px solid transparent; border-radius: var(--ui-radius-control); padding: 9px 14px; background: var(--ui-action); color: #fff; font-weight: 650; }
.btn.secondary { background: var(--surface); color: var(--ui-action); border-color: var(--ui-action); }
.btn.quiet { background: transparent; color: inherit; border-color: var(--line); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { min-height: var(--ui-touch-min); padding: 6px 10px; font-size: 14px; }
.icon-btn { width: var(--ui-touch-min); height: var(--ui-touch-min); flex: 0 0 var(--ui-touch-min); display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: var(--ui-radius-control); background: var(--surface); color: var(--ink); font-size: 22px; }
.topbar .icon-btn { border-color: var(--line); background: rgba(249, 249, 251, .88); color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.actions .btn { flex: 1 1 140px; }

.auth-shell { min-height: calc(100vh - 46px); display: grid; align-items: start; justify-items: center; padding: 13vh 16px 32px; background: var(--bg); }
.auth-box { width: min(100%, 420px); min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--ui-radius-card); background: var(--surface); box-shadow: var(--shadow); }
.auth-brand { color: var(--ui-action); font-size: 25px; font-weight: 750; margin-bottom: 20px; overflow-wrap: anywhere; }
.auth-box h1 { margin: 0 0 6px; font-size: 20px; overflow-wrap: anywhere; }
.auth-copy { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.form-grid > .full { grid-column: 1 / -1; }
.field label { display: block; margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.field-note { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
input, select, textarea {
  display: block; width: 100%; max-width: 100%; min-width: 0; min-height: var(--ui-touch-min);
  border: 1px solid var(--line); border-radius: var(--ui-radius-control); background: #fff; color: var(--ink);
  padding: 10px 11px; line-height: 1.3; outline: 0;
}
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ui-accent); box-shadow: var(--ui-focus); }
input[type="datetime-local"] { appearance: none; -webkit-appearance: none; }
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; }
.form-error { min-height: 20px; margin-top: 10px; color: var(--red); font-size: 14px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; margin-bottom: 14px; padding: 4px; border-radius: 8px; background: #e8edf4; }
.segment { min-height: var(--ui-touch-min); border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.segment.active { background: #fff; color: var(--blue); box-shadow: 0 1px 4px rgba(20,40,70,.12); font-weight: 700; }

.detail-band { padding: 16px 0; border-bottom: 1px solid var(--line); }
.detail-band:first-child { padding-top: 0; }
.detail-band h2, .detail-band h3 { margin: 0 0 10px; }
.detail-copy { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; color: var(--ink); }
.own-assignment { padding: 12px; border-left: 4px solid var(--blue); background: var(--blue-weak); }
.followup-summary, .followup-preview, .manual-note { display: grid; gap: 4px; margin-top: 14px; padding: 11px 12px; border-left: 4px solid var(--ui-action); background: var(--blue-weak); }
.followup-summary span, .followup-preview span, .manual-note span { color: var(--muted); font-size: 12px; font-weight: 700; }
.followup-preview small { color: var(--muted); line-height: 1.45; }
.people-list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.person-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, .7fr); gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.person-row.is-muted { color: var(--muted); background: var(--ui-surface-muted); }
.person-main { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.person-role { color: var(--muted); text-align: right; overflow-wrap: anywhere; }

.assignment-editor { grid-column: 1 / -1; display: grid; gap: 10px; }
.assignment-editor .section-head { margin-bottom: 0; }
.assignment-editor .section-head > div { min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; }
.assignment-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.assignment-toolbar .btn { flex: 1 1 132px; }
.assignment-bulk-duty { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.assignment-people { display: grid; border: 1px solid var(--line); border-radius: var(--ui-radius-control); overflow: hidden; }
.assignment-person { min-width: 0; display: grid; grid-template-columns: minmax(130px, .8fr) minmax(0, 1fr); align-items: center; gap: 12px; padding: 10px 11px; border-bottom: 1px solid var(--line); background: var(--surface); }
.assignment-person:last-child { border-bottom: 0; }
.assignment-person.is-selected { background: var(--blue-weak); }
.assignment-person-check { min-width: 0; display: flex; align-items: center; gap: 9px; }
.assignment-person-check input { width: 20px; min-height: 20px; flex: 0 0 auto; }
.assignment-person-check span { min-width: 0; display: grid; gap: 2px; }
.assignment-person-check strong { overflow-wrap: anywhere; }
.assignment-person-check small { color: var(--muted); font-size: 12px; }
.assignment-duty-field { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; }
.assignment-duty-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.assignment-duty-field input:disabled { background: var(--ui-surface-muted); color: var(--muted); opacity: .72; }
.work-duty-with-attendance { row-gap: 6px; }
.work-duty-with-attendance select:disabled { background: var(--ui-surface-muted); color: var(--muted); opacity: .72; }

.preview-facts { display: grid; gap: 8px; margin-top: 14px; }
.preview-facts > div { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: baseline; gap: 8px; }
.preview-facts span { color: var(--muted); font-size: 12px; font-weight: 700; }
.preview-people { display: grid; border-top: 1px solid var(--line); }
.preview-person { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, .7fr); gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.preview-person strong { text-align: right; overflow-wrap: anywhere; }
.preview-note { margin: 16px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.notice-row { padding: 13px 14px; }
.notice-row.unread { border-left: 4px solid var(--blue); }
.notice-row h3 { margin: 0 0 5px; font-size: 16px; }
.notice-row p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.notice-time { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }

.status-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.status-table th, .status-table td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.status-table th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }

.account-row { padding: 12px; }
.account-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.account-controls { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.reset-password-form { display: grid; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.reset-password-form[hidden] { display: none; }
.check-label { min-height: var(--ui-touch-min); display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.check-label input { width: 20px; min-height: 20px; }

.section-copy { margin: 4px 0 12px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.work-entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.work-entry, .record-card { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: var(--ui-radius-card); background: var(--surface); color: var(--ink); text-align: left; box-shadow: var(--shadow); }
.work-entry { min-height: 92px; display: grid; align-content: center; gap: 6px; padding: 14px; }
.work-entry strong { color: var(--ui-action); font-size: 16px; }
.work-entry span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.record-card { display: block; padding: 14px; }
.record-card:active, .work-entry:active { background: var(--ui-surface-muted); }
.record-card-top { min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.record-card-top > div { min-width: 0; }
.record-card h3 { margin: 3px 0 0; font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
.record-card small { color: var(--muted); }
.record-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 9px; color: var(--muted); font-size: 13px; }
.record-brief { margin-top: 14px; }
.section-action { margin-top: 12px; }
.evidence-list { display: grid; gap: 8px; }
.evidence-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--ui-radius-control); background: var(--surface); color: var(--ui-action); text-decoration: none; }
.evidence-row small { color: var(--muted); text-align: right; }
.audit-trail { display: grid; border-top: 1px solid var(--line); }
.audit-trail > div { min-width: 0; display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.audit-trail span:first-child { color: var(--muted); font-size: 13px; }
.audit-trail strong { overflow-wrap: anywhere; }
.published-link { display: block; color: var(--ui-action); overflow-wrap: anywhere; }
.inline-upload { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.inline-upload .form-error { grid-column: 1 / -1; }

@media (max-width: 560px) {
  .user-chip { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-grid > .full { grid-column: auto; }
  .assignment-editor { grid-column: auto; }
  .assignment-bulk-duty { grid-template-columns: 1fr; }
  .assignment-person { grid-template-columns: 1fr; gap: 8px; }
  .assignment-duty-field { margin-left: 29px; }
  .account-controls { grid-template-columns: 1fr; }
  .person-row { grid-template-columns: minmax(0, 1fr) minmax(86px, .65fr); }
  .page-head { align-items: flex-start; }
  .page-head .btn { flex: 0 0 auto; }
  .work-entry-grid { grid-template-columns: 1fr; }
  .inline-upload { grid-template-columns: 1fr; }
  .inline-upload .form-error { grid-column: auto; }
  .evidence-row { align-items: flex-start; flex-direction: column; gap: 4px; }
  .evidence-row small { text-align: left; }
}
