:root {
  color-scheme: light;
  --ink: #1d2b37;
  --muted: #647483;
  --line: #dce3e8;
  --surface: #fff;
  --canvas: #f5f7f8;
  --navy: #18384f;
  --blue: #245c7a;
  --blue-light: #edf4f8;
  --green: #2d6948;
  --green-light: #eaf4ed;
  --amber: #805c16;
  --amber-light: #fbf3df;
  --red: #943d38;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.55 "Segoe UI", "Microsoft YaHei", sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 max(28px, calc((100vw - 1120px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { color: var(--navy); font-size: 17px; font-weight: 700; white-space: nowrap; }
.topbar nav { display: flex; align-items: center; gap: 24px; }
.user-label, .muted, small { color: var(--muted); }
.user-label { font-size: 13px; }
.page { width: min(1120px, calc(100% - 48px)); margin: 40px auto 72px; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-panel, .form-panel, .detail-panel, .update-panel, .notification-panel, .member-list-panel, .error-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.auth-panel { width: min(420px, 100%); padding: 36px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; color: var(--navy); font-size: 26px; font-weight: 650; }
h2 { color: var(--navy); font-size: 17px; font-weight: 650; }
.auth-panel h1 { font-size: 23px; }
.auth-panel > .muted { margin-bottom: 26px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 26px; }
.page-heading p { margin-bottom: 0; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 8px 16px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.button:hover { text-decoration: none; filter: brightness(.97); }
.button.primary { color: white; background: var(--navy); }
.button.secondary { color: var(--navy); background: white; border-color: #bdc9d1; }
.button.full { width: 100%; margin-top: 4px; }
.filters { display: flex; align-items: end; gap: 12px; margin-bottom: 18px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
input:not([type=checkbox]), select, textarea { width: 100%; min-height: 40px; padding: 9px 11px; color: var(--ink); background: white; border: 1px solid #bdc9d1; border-radius: 4px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #aac7d7; outline-offset: 1px; border-color: var(--blue); }
.search-field { width: min(360px, 45%); }
.filters label:not(.search-field) { width: 170px; }
.clear-link { padding: 9px 2px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 14px 16px; border-bottom: 1px solid #e8edef; vertical-align: middle; }
th { color: var(--muted); background: #f9fafb; font-size: 12px; font-weight: 650; letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: 0; }
.task-link { color: var(--navy); font-weight: 650; }
.empty { padding: 34px; color: var(--muted); text-align: center; }
.status { display: inline-block; padding: 3px 9px; border-radius: 3px; font-size: 13px; white-space: nowrap; }
.status-todo { color: #536271; background: #edf0f2; }
.status-doing { color: var(--amber); background: var(--amber-light); }
.status-done { color: var(--green); background: var(--green-light); }
.status-revoked { color: var(--red); background: #faecea; }
.form-panel { padding: 26px; }
.form-stack { display: grid; gap: 18px; }
.form-panel.form-stack { width: min(760px, 100%); }
.form-stack label { max-width: 100%; }
fieldset { padding: 14px; border: 1px solid var(--line); border-radius: 4px; }
legend { padding: 0 5px; font-weight: 600; }
.member-options { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.checkbox-label { display: flex; align-items: center; gap: 7px; font-weight: 400; }
.checkbox-label input { accent-color: var(--navy); }
.date-field { max-width: 260px; }
.form-note { margin: -4px 0; color: var(--muted); font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.detail-heading { align-items: end; }
.detail-heading h1 { margin-top: 10px; }
.heading-actions { display: flex; align-items: center; gap: 8px; }
.danger-button { color: var(--red); background: white; border-color: #d7aaa6; }
.revoked-notice { margin: 0 0 12px; color: var(--red); font-weight: 600; }
.back-link { font-size: 13px; }
.detail-panel { padding: 26px; }
.detail-status { margin-bottom: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px 28px; margin: 0 0 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.detail-grid dt { margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.detail-grid dd { margin: 0; }
.description-block { margin-top: 22px; }
.description-block h2 { margin-bottom: 8px; }
.preserve-lines { margin-bottom: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.update-panel, .notification-panel, .member-list-panel { margin-top: 20px; padding: 24px 26px; }
.completion-form { max-width: 560px; display: grid; gap: 12px; margin-top: 22px; }
.completion-form .button { justify-self: start; }
.notification-list { margin: 0; padding: 0; list-style: none; }
.notification-list li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px 18px; padding: 11px 0; border-top: 1px solid #edf0f2; }
.notification-sent { color: var(--green); }
.notification-failed, .notification-error { color: var(--red); }
.notification-error { flex-basis: 100%; font-size: 13px; }
.member-create-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: end; }
.member-create-form button { justify-self: start; }
.password-field small { font-weight: 400; }
.member-list-panel { padding: 24px 0 0; border: 0; background: transparent; }
.member-list-panel h2 { padding: 0 2px; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--blue); cursor: pointer; }
.danger-link { color: var(--red); }
.inline-form { display: inline; }
.messages { margin-bottom: 18px; }
.message { margin: 0 0 8px; padding: 10px 13px; border-radius: 4px; }
.message.success { color: var(--green); background: var(--green-light); }
.message.error { color: var(--red); background: #faecea; }
.message.info { color: var(--blue); background: var(--blue-light); }
.error-panel { max-width: 560px; padding: 32px; margin: 5vh auto; }
.eyebrow { color: var(--muted); font-size: 13px; }
.error-panel h1 { margin-bottom: 24px; font-size: 21px; }
.password-change-form { max-width: 560px; }

@media (max-width: 700px) {
  .topbar { height: auto; min-height: 60px; padding: 12px 18px; align-items: flex-start; }
  .topbar nav { flex-wrap: wrap; justify-content: flex-end; gap: 8px 14px; }
  .user-label { flex-basis: 100%; text-align: right; }
  .page { width: calc(100% - 32px); margin-top: 26px; }
  .page-heading { align-items: flex-start; }
  .heading-actions { flex-wrap: wrap; }
  .page-heading .heading-actions { justify-content: flex-start; }
  .filters { align-items: stretch; flex-wrap: wrap; }
  .search-field, .filters label:not(.search-field) { width: calc(50% - 6px); }
  th, td { padding: 12px 11px; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .member-create-form { grid-template-columns: 1fr; }
  .form-panel, .detail-panel, .update-panel, .notification-panel { padding: 20px; }
}

@media (max-width: 430px) {
  .topbar { flex-direction: column; }
  .topbar nav { width: 100%; justify-content: space-between; }
  .user-label { flex-basis: auto; }
  .page-heading { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 18px 12px; }
  .auth-panel { padding: 26px 22px; }
}
