:root {
  --paper: #F2EEEA;
  --paper-line: #e3dcd6;
  --ink: #221B1B;
  --ink-soft: #5c5250;
  --steel: #7A3B3B;
  --line: #d8c9c6;
  --accent: #8B1E24;
  --accent-dark: #6e161b;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --danger: #c0392b;
  --danger-bg: #fde8e8;
  --card: #ffffff;
  --radius: 4px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'IBM Plex Mono', monospace; }
a { color: var(--steel); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent); color: #fff; }

/* Focus visibility */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 0 20px 80px; }

/* Header / Title Block */
header.titleblock {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fdf6f1;
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
}

.tb-inner { max-width: 900px; margin: 0 auto; padding: 32px 20px; }
.tb-top { display: flex; flex-direction: column; align-items: flex-start; }
.tb-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #e9c48f;
  margin-bottom: 8px;
  font-weight: 500;
}
.tb-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.15;
  margin: 0;
  max-width: 650px;
}
.tb-rule {
  height: 5px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 18px, transparent 18px 26px);
}

/* Nav */
.topnav {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.admin-link, .nav-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: .05em;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: var(--shadow-sm);
}
.admin-link:hover, .nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Share Bar */
.share-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.share-bar .k {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--steel);
  font-weight: 600;
}
.share-bar input {
  flex: 1;
  min-width: 200px;
  border: 1px solid var(--line);
  background: #fcfbfa;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--ink-soft);
}
.copy-btn {
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  transition: all .15s ease;
}
.copy-btn:hover { border-color: var(--steel); color: var(--steel); }

/* Form Elements */
.intro p {
  color: var(--ink-soft);
  line-height: 1.65;
  font-size: 15.5px;
  max-width: 720px;
  margin-bottom: 24px;
}

.respondent {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 24px 0 32px;
  box-shadow: var(--shadow-sm);
}

.block-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--steel);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.block-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field label .opt { font-weight: 400; color: #88929a; text-transform: none; }

.field input[type=text], .field input[type=email], .field textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 30, 36, 0.12);
  outline: none;
}
.field textarea { resize: vertical; min-height: 75px; line-height: 1.5; }

/* PEO Cards */
.peo-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease;
}
.peo-card:hover { box-shadow: var(--shadow-md); }

.peo-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fdfdfd, #f6f5f3);
}
.peo-num {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 12.5px;
  color: #fff;
  background: var(--ink);
  border-radius: var(--radius);
  padding: 5px 10px;
  letter-spacing: .04em;
  white-space: nowrap;
}
.peo-text { font-size: 15px; line-height: 1.55; color: var(--ink); font-weight: 400; }
.peo-body { padding: 20px 22px; }

/* Segmented Buttons */
.seg { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.seg-btn {
  flex: 1;
  min-width: 100px;
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: .04em;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all .15s ease;
  font-weight: 500;
  user-select: none;
}
.seg-btn:hover { border-color: var(--steel); color: var(--steel); background: #fbf9f8; }
.seg-btn.active[data-val="Yes"] { background: var(--success); border-color: var(--success); color: #fff; box-shadow: 0 2px 6px rgba(46, 125, 50, 0.3); }
.seg-btn.active[data-val="Partially"] { background: var(--warn); border-color: var(--warn); color: #fff; box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3); }
.seg-btn.active[data-val="No"] { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: 0 2px 6px rgba(192, 57, 43, 0.3); }

.req-mark { color: var(--danger); font-weight: 700; }

/* Submit Section */
.submit-row { display: flex; justify-content: space-between; align-items: center; margin-top: 32px; gap: 16px; flex-wrap: wrap; }
.submit-note { font-size: 13px; color: #78828a; }

.btn-primary {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .02em;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px 30px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: 0 3px 8px rgba(139, 30, 36, 0.25);
}
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-danger {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s ease;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  display: none;
  padding: 10px 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

/* Confirmation View */
.confirm {
  text-align: center;
  padding: 60px 20px;
  max-width: 540px;
  margin: 40px auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.confirm .mark {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 28px;
  font-weight: bold;
}
.confirm h2 { font-family: 'Space Grotesk', sans-serif; margin: 0 0 12px; font-size: 24px; }
.confirm p { color: var(--ink-soft); line-height: 1.6; margin-bottom: 24px; }

/* Admin Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 12, 12, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal h3 { font-family: 'Space Grotesk', sans-serif; margin: 0 0 8px; font-size: 20px; }
.modal p { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 18px; }
.modal input { width: 100%; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn-ghost {
  flex: 1;
  background: #fff;
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: all .15s ease;
}
.btn-ghost:hover { border-color: var(--steel); color: var(--steel); }

/* Admin Dashboard */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card .num { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 32px; color: var(--ink); line-height: 1; }
.stat-card .lbl { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #88929a; margin-top: 8px; }

.peo-summary {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.peo-summary-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.peo-summary-head .lab { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 13px; color: var(--ink); }
.bar-track { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #eee; margin-bottom: 10px; }
.bar-seg.Yes { background: var(--success); }
.bar-seg.Partially { background: var(--warn); }
.bar-seg.No { background: var(--danger); }
.bar-legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; }
.bar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.Yes { background: var(--success); }
.dot.Partially { background: var(--warn); }
.dot.No { background: var(--danger); }

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 28px 0 20px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.toolbar select, .toolbar input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13.5px;
}
.toolbar input { flex: 1; min-width: 200px; }

.btn-export {
  background: var(--steel);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13.5px;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 600;
  transition: all .15s ease;
}
.btn-export:hover { background: #5c2b2b; }

.resp-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease;
}
.resp-card:hover { box-shadow: var(--shadow-md); }

.resp-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  flex-wrap: wrap;
  background: #fff;
}
.resp-who { font-weight: 600; font-size: 15px; color: var(--ink); }
.resp-org { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.resp-date { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: #88929a; white-space: nowrap; }

.resp-detail {
  display: none;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
  background: #fdfdfc;
}
.resp-detail.open { display: block; }
.detail-peo { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.detail-peo:last-child { border-bottom: none; }
.detail-peo .lab { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.status-chip { font-size: 10.5px; padding: 2px 8px; border-radius: 10px; color: #fff; font-family: 'IBM Plex Mono', monospace; font-weight: 600; }
.status-chip.Yes { background: var(--success); }
.status-chip.Partially { background: var(--warn); }
.status-chip.No { background: var(--danger); }
.detail-peo .txt { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; margin: 4px 0; }
.detail-peo .txt .k { color: var(--ink); font-weight: 600; }

.empty-state { text-align: center; padding: 60px 20px; color: #88929a; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state .big { font-family: 'Space Grotesk', sans-serif; font-size: 20px; color: var(--ink); margin-bottom: 8px; }

.back-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: var(--steel);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.back-link:hover { color: var(--accent); }

@media (max-width: 600px) {
  .field-row { grid-template-columns: 1fr; }
  .seg { flex-direction: column; }
  .seg-btn { width: 100%; }
  .submit-row { flex-direction: column; align-items: stretch; }
  .btn-primary { width: 100%; }
}
