/* ===================================================================
   /protocols  /screenings  /family — shared shell styles
   ===================================================================
   Three Tools-tab parity surfaces. Pulls all design tokens from
   main.css; this file only defines page-local layouts. The three
   pages share enough UI (auth gate + header + cards + modals + form
   fields) that one stylesheet keeps churn low.
   =================================================================== */

/* ---------- Page shells (reuse the /log shape) ---------- */
.tba-hero {
  padding: 116px 0 64px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
.tba-hero .pill { margin-bottom: 1rem; }
.tba-hero h1 {
  font-size: clamp(2.2rem, 4.4vw, 3.2rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 0.8rem;
}
.tba-hero p.lede {
  max-width: 38rem;
  margin: 0 auto 2rem;
  color: var(--ink-3);
  font-size: 1.05rem;
  line-height: 1.55;
}

.tba-shell { padding: 116px 0 80px; }
.tba-shell > .container { max-width: 880px; }

/* ---------- Auth card (shared with /log) ---------- */
.tba-auth-card {
  max-width: 380px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  text-align: left;
}
.tba-auth-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 0.4rem;
}
.tba-auth-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  margin-bottom: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.tba-auth-input:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(14, 132, 121, 0.15);
}
.tba-auth-status {
  margin: 0.7rem 0 0;
  font-size: 0.88rem;
  min-height: 1.2em;
}
.tba-auth-status.error { color: var(--crimson-500, #C0392B); }
.tba-auth-status.success { color: var(--teal-700); }
.tba-auth-fineprint {
  margin: 0.9rem 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--ink-4);
  text-align: center;
}

/* ---------- Page header (signed-in surface) ---------- */
.tba-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.tba-header h1 {
  font-size: clamp(1.8rem, 3.2vw, 2.2rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}
.tba-header p.sub {
  margin: 0;
  color: var(--ink-3);
  font-size: 0.95rem;
}
.tba-meta {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.tba-user {
  font-size: 0.85rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- Banner stack (shared with /log) ---------- */
.tba-banner-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}
.tba-banner {
  position: relative;
  padding: 0.7rem 2.4rem 0.7rem 0.95rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: var(--shadow-xs);
}
.tba-banner-info    { background: var(--teal-50);  border-color: var(--teal-200); color: var(--teal-700); }
.tba-banner-success { background: var(--teal-50);  border-color: var(--teal-200); color: var(--teal-700); }
.tba-banner-error   { background: #FFF5F3;          border-color: #F2BCB1;        color: #8B2616; }
.tba-banner-close {
  position: absolute;
  right: 0.4rem;
  top: 0.3rem;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  color: inherit;
  padding: 0.1rem 0.5rem;
  opacity: 0.6;
}
.tba-banner-close:hover { opacity: 1; }

/* ---------- Card containers ---------- */
.tba-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem 1.4rem 1.6rem;
  margin-bottom: 1.2rem;
}
.tba-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tba-card-head h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.tba-card-sub {
  color: var(--ink-3);
  font-size: 0.85rem;
}

/* ---------- Empty state ---------- */
.tba-empty {
  padding: 1.6rem 1rem;
  text-align: center;
  color: var(--ink-3);
  font-size: 0.95rem;
  background: var(--bg-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
}
.tba-empty strong { color: var(--ink-2); display: block; margin-bottom: 0.3rem; }

/* ---------- Toolbar / CTAs ---------- */
.tba-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.tba-toolbar .tba-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.tba-tab {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.tba-tab.is-active {
  background: var(--teal-700);
  color: white;
  border-color: var(--teal-700);
}
.tba-tab:hover:not(.is-active) {
  border-color: var(--teal-500);
  color: var(--teal-700);
}

/* ---------- Item rows ---------- */
.tba-item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1rem 1.1rem;
  background: var(--surface);
  margin-bottom: 0.8rem;
  transition: border-color 120ms ease;
}
.tba-item:hover { border-color: var(--line-strong); }
.tba-item.is-overdue { border-color: #F2BCB1; background: #FFFBFA; }
.tba-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.tba-item-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink-1, var(--ink-2));
  margin: 0;
}
.tba-item-meta {
  font-size: 0.82rem;
  color: var(--ink-3);
  margin: 0.2rem 0 0;
  font-variant-numeric: tabular-nums;
}
.tba-item-body {
  color: var(--ink-3);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0.4rem 0;
}
.tba-item-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}
.tba-item-actions .btn { font-size: 0.85rem; padding: 0.4rem 0.85rem; }

/* ---------- Pills + status chips ---------- */
.tba-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tba-pill-active   { background: var(--teal-100);  color: var(--teal-700); }
.tba-pill-done     { background: #E6E6E6;          color: var(--ink-3); }
.tba-pill-overdue  { background: #FFE0DB;          color: #8B2616; }
.tba-pill-upcoming { background: var(--bg-3);      color: var(--ink-3); }
.tba-pill-snoozed  { background: #FFF3CC;          color: #8B6500; }
.tba-pill-skipped  { background: var(--bg-2);      color: var(--ink-4); }
.tba-pill-paused   { background: #FFF3CC;          color: #8B6500; }
.tba-pill-abandoned{ background: var(--bg-2);      color: var(--ink-4); }

/* ---------- Progress bar ---------- */
.tba-progress {
  height: 6px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.4rem 0;
}
.tba-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-700));
  border-radius: 999px;
  transition: width 220ms ease;
}

/* ---------- Modal ---------- */
.tba-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 30, 30, 0.45);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 2rem;
  overflow-y: auto;
}
.tba-modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: 620px;
  width: 100%;
  padding: 1.6rem 1.6rem 1.8rem;
  position: relative;
}
.tba-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.tba-modal-head h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.tba-modal-close {
  background: transparent;
  border: 0;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
  padding: 0.1rem 0.4rem;
}
.tba-modal-close:hover { color: var(--ink-1, var(--ink-2)); }
.tba-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.4rem;
  flex-wrap: wrap;
}

/* ---------- Form fields (mirrors /log) ---------- */
.tba-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.2rem;
}
.tba-field { display: flex; flex-direction: column; gap: 0.35rem; }
.tba-field-full { grid-column: 1 / -1; }
.tba-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
}
.tba-field input,
.tba-field select,
.tba-field textarea {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}
.tba-field textarea { resize: vertical; min-height: 4em; }
.tba-field input:focus,
.tba-field select:focus,
.tba-field textarea:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(14, 132, 121, 0.15);
}
.tba-field-hint {
  font-size: 0.78rem;
  color: var(--ink-4);
  line-height: 1.35;
}

/* ---------- Template picker (Protocols add-modal) ---------- */
.tba-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.8rem;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 0.4rem;
}
.tba-template {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 0.9rem;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 120ms ease, background 120ms ease;
}
.tba-template:hover { border-color: var(--teal-500); background: var(--teal-50); }
.tba-template.is-selected {
  border-color: var(--teal-700);
  background: var(--teal-50);
  box-shadow: 0 0 0 2px rgba(7, 86, 79, 0.1);
}
.tba-template-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-2);
}
.tba-template-sub {
  color: var(--ink-3);
  font-size: 0.82rem;
  line-height: 1.4;
}
.tba-template-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ---------- Family tree summary tiles ---------- */
.tba-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.4rem;
}
.tba-summary-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow-xs);
}
.tba-summary-tile .label {
  font-size: 0.78rem;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.3rem;
}
.tba-summary-tile .value {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.tba-summary-tile .value.muted { color: var(--ink-4); font-size: 1rem; }
.tba-summary-tile .delta {
  font-size: 0.82rem;
  color: var(--ink-3);
  margin: 0.2rem 0 0;
}

/* ---------- Calendar groups (Screenings) ---------- */
.tba-cal-group {
  margin-bottom: 1.4rem;
}
.tba-cal-group-head {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-4);
  margin: 0 0 0.6rem;
  font-weight: 600;
}

/* ---------- Member chip + condition tag (Family) ---------- */
.tba-tag {
  display: inline-block;
  background: var(--bg-3);
  color: var(--ink-3);
  border-radius: 999px;
  font-size: 0.78rem;
  padding: 0.18rem 0.55rem;
  margin: 0.2rem 0.25rem 0 0;
}

/* ---------- Action buttons inline ---------- */
.tba-link-btn {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--teal-600);
  cursor: pointer;
  text-decoration: underline;
}
.tba-link-btn:hover { color: var(--teal-700); }
.tba-link-btn.danger { color: #8B2616; }
.tba-link-btn.danger:hover { color: #5C1810; }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 640px) {
  .tba-shell { padding: 96px 0 60px; }
  .tba-card { padding: 1.1rem; }
  .tba-modal { padding: 1.2rem; }
  .tba-toolbar { flex-direction: column; align-items: stretch; }
  .tba-toolbar .btn { width: 100%; }
}
