/* CTD Rescue — mobile-first, large tap targets */

:root {
  --bg: #f4f7f4;
  --surface: #ffffff;
  --ink: #1a2a1a;
  --muted: #4a5a4a;
  --brand: #1f6b3a;
  --brand-dark: #15502b;
  --accent: #e8f5ec;
  --border: #c5d5c8;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #027a48;
  --radius: 12px;
  --tap: 48px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow: 0 2px 10px rgba(26, 42, 26, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #e8f2ea 0%, var(--bg) 180px);
  line-height: 1.45;
  min-height: 100vh;
}

a {
  color: var(--brand);
}

img {
  max-width: 100%;
}

.wrap {
  width: min(720px, 100% - 1.5rem);
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.site-header {
  background: var(--brand);
  color: #fff;
  padding: 1rem 0;
  box-shadow: var(--shadow);
}

.site-header .wrap {
  padding-bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.site-header a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
}

.site-header nav a {
  font-weight: 600;
  font-size: 1rem;
  opacity: 0.95;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}

.site-header nav a:hover,
.site-header nav a:focus {
  background: rgba(255, 255, 255, 0.15);
}

h1 {
  font-size: 1.6rem;
  margin: 1rem 0 0.5rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--brand-dark);
}

h3 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.5rem;
}

.lead {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

/* Home buttons */
.form-grid {
  display: grid;
  gap: 0.75rem;
}

.form-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 56px;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: var(--shadow);
}

.form-btn:hover,
.form-btn:focus {
  border-color: var(--brand);
  background: var(--accent);
}

.form-btn:active {
  transform: scale(0.99);
}

/* Forms */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.section-title {
  background: var(--accent);
  margin: -1rem -1rem 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 700;
  color: var(--brand-dark);
  border-bottom: 1px solid var(--border);
}

label {
  display: block;
  font-weight: 600;
  margin: 0.85rem 0 0.35rem;
}

label .req {
  color: var(--danger);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.65rem 0.75rem;
  font: inherit;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231f6b3a' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(31, 107, 58, 0.35);
  border-color: var(--brand);
}

.row-2 {
  display: grid;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .row-2 {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  .wrap {
    width: min(820px, 100% - 2rem);
  }
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0.75rem 0;
  min-height: var(--tap);
}

.check input {
  width: 28px;
  height: 28px;
  min-height: 28px;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.check label {
  margin: 0;
  font-weight: 500;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.35rem 0 0.75rem;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-weight: 500;
  min-height: var(--tap);
  padding-right: 0.5rem;
}

.radio-group input {
  width: 24px;
  height: 24px;
}

.hint {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.error {
  color: var(--danger);
  font-size: 0.95rem;
  margin: 0.25rem 0 0;
}

.field-error input,
.field-error select,
.field-error textarea {
  border-color: var(--danger);
}

/* Signature pad */
.sig-wrap {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fafcfa;
  overflow: hidden;
  touch-action: none;
}

.sig-wrap canvas {
  display: block;
  width: 100%;
  height: 180px;
  touch-action: none;
  cursor: crosshair;
}

.sig-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0.75rem 1.25rem;
  font: inherit;
  font-weight: 700;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--brand-dark);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--bg) 30%);
  padding: 1rem 0;
}

@media (min-width: 640px) {
  .actions {
    flex-direction: row;
    position: static;
  }
}

.turnstile-box {
  margin: 1rem 0;
  min-height: 65px;
}

.success {
  text-align: center;
  padding: 2rem 1rem;
}

.success h1 {
  color: var(--ok);
}

.badge {
  display: inline-block;
  background: var(--accent);
  color: var(--brand-dark);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.form-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.form-table th,
table.form-table td {
  border: 1px solid var(--border);
  padding: 0.4rem;
  vertical-align: top;
}

table.form-table input,
table.form-table select {
  min-height: 40px;
  font-size: 0.95rem;
}

/* Admin */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin: 0.75rem 0 1rem;
  font-size: 0.95rem;
}

.breadcrumbs a {
  font-weight: 600;
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-list .meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input {
  flex: 1;
}

.hidden {
  display: none !important;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2rem 1rem;
}
