:root {
  color-scheme: light;
  --bg: #eef3f0;
  --surface: #ffffff;
  --surface-raised: #f8faf9;
  --surface-strong: #e3ebe7;
  --ink: #17211d;
  --muted: #60706a;
  --line: #d3ded9;
  --line-strong: #aebdb6;
  --accent: #176b58;
  --accent-dark: #104d41;
  --accent-soft: #dff3ec;
  --accent-ink: #ffffff;
  --warn: #8a4d08;
  --warn-soft: #fff0d3;
  --ok: #17633a;
  --ok-soft: #dcf3e7;
  --danger: #a33232;
  --canvas-bg: #ffffff;
  --canvas-ink: #111917;
  --shadow: 0 16px 40px rgba(23, 33, 29, 0.08);
  --shadow-soft: 0 8px 20px rgba(23, 33, 29, 0.06);
  font-family: "Segoe UI", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --surface: #1f2937;
  --surface-raised: #172033;
  --surface-strong: #293548;
  --ink: #f3f6fb;
  --muted: #aeb8c7;
  --line: #334155;
  --line-strong: #52627a;
  --accent: #7cb4f8;
  --accent-dark: #b7d5ff;
  --accent-soft: #263852;
  --accent-ink: #0d1726;
  --warn: #f8d48b;
  --warn-soft: #46351b;
  --ok: #b7d5ff;
  --ok-soft: #263852;
  --danger: #ffb4b4;
  --canvas-bg: #ffffff;
  --canvas-ink: #111917;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

body:not(.issue-mode):not(.success-mode):not(.terms-mode):not(.volunteers-mode) .app-shell {
  height: 100vh;
  overflow: hidden;
}

.topbar {
  min-height: 92px;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(320px, 1fr);
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-block h1,
.login-panel h1 {
  margin: 3px 0 0;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.topbar-status p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.stat-pill {
  min-width: 94px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ok-soft);
  color: var(--ok);
  display: grid;
  place-items: center;
}

.stat-pill.pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.stat-pill span {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-pill strong {
  font-size: 22px;
  line-height: 1;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.view {
  min-height: 0;
}

.roster-view {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.roster-toolbar {
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(250px, 1.15fr) minmax(220px, 0.9fr) minmax(220px, 0.75fr);
  gap: 14px;
  align-items: center;
}

.roster-grid {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(360px, 46vw) minmax(360px, 1fr);
}

.list-panel {
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface-raised);
  display: grid;
  grid-template-rows: auto 1fr;
}

.selection-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 26px;
}

.selection-actions {
  display: flex;
  justify-content: flex-end;
}

.selection-actions .button {
  min-width: 210px;
  min-height: 56px;
  font-size: 18px;
}

.issue-view,
.success-view,
.volunteers-view,
.terms-view {
  padding: 26px;
}

.issue-mode .topbar,
.success-mode .topbar {
  display: none;
}

.issue-mode .issue-view,
.success-mode .success-view,
.volunteers-mode .volunteers-view {
  min-height: 100vh;
}

.success-view {
  display: grid;
  place-items: center;
}

.success-card {
  width: min(100%, 620px);
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.success-card h2 {
  margin: 8px 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

.success-card p:not(.eyebrow) {
  margin: 0 auto 24px;
  max-width: 440px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.success-proof {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 24px;
}

.success-proof div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.success-proof strong {
  display: block;
}

.success-mark {
  width: 96px;
  min-height: 54px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 20px;
  font-weight: 900;
}

.issue-header {
  width: min(100%, 1080px);
  margin: 0 auto 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.issue-header h2 {
  margin: 3px 0 5px;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

.issue-header p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.issue-layout {
  width: min(100%, 1080px);
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.issue-card-summary {
  box-shadow: var(--shadow);
}

.terms-editor,
.volunteer-manager {
  width: min(100%, 900px);
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.terms-editor .issue-header,
.volunteer-manager .issue-header {
  width: 100%;
  margin-bottom: 0;
  grid-template-columns: auto minmax(0, 1fr);
}

.terms-editor textarea {
  min-height: 340px;
  line-height: 1.45;
}

.volunteer-manager-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.volunteer-manager-add input,
.volunteer-manager-add .button {
  min-height: 58px;
}

.volunteer-manager-add input {
  font-weight: 750;
}

.volunteer-list {
  display: grid;
  gap: 10px;
}

.volunteer-row {
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.volunteer-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.muted-panel {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--muted);
  font-weight: 750;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
}

.roster-panel {
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface-raised);
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.search-area {
  padding: 18px;
  display: grid;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.step-label {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
}

.step-label span {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 20px;
  font-weight: 900;
}

.step-label strong {
  display: block;
  font-size: 18px;
}

.step-label small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 600;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 13px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input[type="search"] {
  min-height: 58px;
  padding: 0 16px;
  font-size: 20px;
  font-weight: 650;
}

.volunteer-picker {
  display: grid;
  gap: 8px;
}

.volunteer-picker select {
  min-height: 58px;
  font-weight: 750;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
.signature-canvas:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(23, 107, 88, 0.2);
}

.segmented,
.status-toggles {
  min-height: 50px;
  display: grid;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-raised);
}

.segmented {
  grid-template-columns: repeat(3, 1fr);
}

.status-toggles {
  grid-template-columns: repeat(2, 1fr);
}

.segmented button,
.status-toggles button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segmented button:last-child,
.status-toggles button:last-child {
  border-right: 0;
}

.segmented button.active,
.status-toggles button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.list-meta {
  min-height: 42px;
  padding: 10px 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}

.people-list {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.person-row {
  width: 100%;
  min-height: 86px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.person-row:hover,
.person-row.active {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.person-row.active {
  border-left: 5px solid var(--accent);
  padding-left: 10px;
}

.person-name {
  display: block;
  font-weight: 850;
  line-height: 1.22;
}

.person-card {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin-top: 5px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 32px;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 900;
}

.chip.pending {
  color: var(--warn);
  background: var(--warn-soft);
}

.chip.received {
  color: var(--ok);
  background: var(--ok-soft);
}

.detail-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 26px;
}

.empty-state,
.person-detail {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.empty-state {
  min-height: calc(100vh - 150px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin: 6px 0;
  color: var(--ink);
  font-size: 34px;
  letter-spacing: 0;
}

.empty-state p {
  max-width: 480px;
  margin: 0;
  line-height: 1.45;
}

.person-detail {
  display: grid;
  gap: 16px;
}

.detail-head,
.detail-section,
.receipt-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.detail-head {
  padding: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.detail-head h2 {
  margin: 4px 0 7px;
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: 0;
}

.detail-head p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.status-badge {
  flex: 0 0 auto;
}

.detail-section,
.receipt-section {
  padding: 20px;
}

.section-head,
.signature-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head h3,
.signature-title h3 {
  margin: 3px 0 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.receipt-section {
  display: grid;
  gap: 14px;
}

.receipt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.receipt-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.receipt-grid div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 5px;
}

.receipt-signature {
  width: 100%;
  max-height: 170px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.signature-form {
  display: grid;
  gap: 16px;
}

.terms-box {
  display: grid;
  gap: 9px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--ink);
  line-height: 1.45;
}

.terms-box p {
  margin: 0;
}

.check-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.check-row input {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.notes-field textarea {
  min-height: 78px;
}

.signature-title {
  align-items: center;
}

.signature-title h3 {
  margin: 3px 0 0;
}

.signature-canvas {
  width: 100%;
  height: 270px;
  display: block;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background: var(--canvas-bg);
  touch-action: none;
}

.save-row {
  min-height: 82px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow);
}

.save-row p {
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.button,
.icon-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
}

.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary,
.icon-button {
  background: var(--surface);
  color: var(--accent-dark);
  border-color: var(--line-strong);
}

.button.secondary:hover,
.icon-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.button.ghost:hover {
  color: var(--ink);
  background: var(--surface-raised);
}

.button.danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
}

.button.danger:hover {
  background: rgba(163, 50, 50, 0.12);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #17211d;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-shell {
  width: min(100%, 470px);
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.login-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.login-divider {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.login-divider strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.login-message {
  min-height: 20px;
  margin: 0 !important;
  color: var(--danger) !important;
  font-weight: 850;
}

@media (max-width: 1160px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar-status {
    justify-content: flex-start;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .roster-toolbar,
  .roster-grid {
    grid-template-columns: 1fr;
  }

  .list-panel {
    min-height: 420px;
    max-height: 52vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 900px) {
  .topbar {
    position: static;
  }

  .topbar-status {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-status p {
    grid-column: 1 / -1;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .roster-toolbar {
    padding: 14px;
  }

  .selection-panel,
  .issue-view,
  .success-view,
  .volunteers-view,
  .terms-view {
    padding: 18px;
  }

  .issue-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .roster-panel {
    min-height: 410px;
    max-height: 52vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-panel {
    padding: 18px;
  }

  .detail-head,
  .section-head,
  .signature-title,
  .save-row,
  .selection-actions,
  .volunteer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .volunteer-manager-add {
    grid-template-columns: 1fr;
  }

  .receipt-grid,
  .form-grid,
  .success-proof {
    grid-template-columns: 1fr;
  }

  .receipt-actions {
    flex-direction: column;
  }

  .success-card {
    padding: 24px;
  }

  .button,
  .icon-button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .topbar,
  .detail-panel,
  .selection-panel,
  .issue-view,
  .success-view,
  .volunteers-view,
  .terms-view,
  .search-area {
    padding: 14px;
  }

  .brand-block h1,
  .login-panel h1 {
    font-size: 23px;
  }

  .detail-head h2 {
    font-size: 29px;
  }

  .person-row {
    grid-template-columns: 1fr;
  }

  .chip {
    justify-self: start;
  }
}
