/* Infirmary sub-pages — shared layout (Town Hall Connectors / Audit pattern) */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

.infirmary-page {
  width: 100%;
  margin: 0 auto;
  padding: 0 0 60px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
}
.subtitle {
  margin: 6px 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
}
.infirmary-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  padding: 16px;
}

.btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.btn-primary {
  background: linear-gradient(90deg, var(--brand1), var(--brand2));
  color: #fff;
  border: none;
}
.btn-primary:hover { opacity: 0.9; }
.btn-danger {
  background: var(--surface);
  color: var(--danger, #f87171);
  border-color: var(--danger, #f87171);
}
.btn-danger:hover { opacity: 0.85; }

.conn-section { margin-bottom: 32px; }
.conn-section-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
}
.conn-section-desc {
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.provider-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 600;
}
.provider-summary-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.provider-summary.active-2 { color: var(--ok, #34d399); }
.provider-summary.active-2 .provider-summary-dot { background: var(--ok, #34d399); }
.provider-summary.active-1 { color: var(--brand-orange, #FF6A3D); }
.provider-summary.active-1 .provider-summary-dot { background: var(--brand-orange, #FF6A3D); }
.provider-summary.active-0 { color: var(--muted); }
.provider-summary.active-0 .provider-summary-dot { background: var(--muted); }

.connector-card { padding: 24px; margin-bottom: 20px; }
.connector-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.connector-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 28px;
  flex-shrink: 0;
}
.connector-icon img {
  width: 26px;
  height: 26px;
  filter: grayscale(1);
  opacity: 0.7;
}
.connector-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.connector-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.connector-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}
.connector-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}
.connector-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
}
.connector-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.connector-status.status-on {
  color: var(--ok, #34d399);
  border-color: var(--ok, #34d399);
  background: var(--surface);
}
.connector-status.status-on .status-dot {
  background: var(--ok, #34d399);
  box-shadow: 0 0 6px var(--ok, #34d399);
}
.connector-status.status-off { color: var(--muted); }
.connector-domain-hint {
  font-size: 0.78rem;
  color: var(--warn, #fbbf24);
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 12px;
}
.connector-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
}
.connector-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.connector-detail-label {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 100px;
}
.connector-detail-value {
  color: var(--ink);
  word-break: break-all;
}
.connector-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.crm-reuse-panel {
  margin: 10px 0 12px;
}
.crm-reuse-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.crm-reuse-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.crm-reuse-email {
  margin-top: 4px;
  font-weight: 650;
  color: var(--ink);
  word-break: break-all;
}
.crm-reuse-help {
  margin: 8px 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
.crm-reuse-btn { width: auto; }
.privacy-toggle { margin-top: 12px; }
.privacy-toggle-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.privacy-toggle-btn:hover { color: var(--ink); }
.privacy-content {
  display: none;
  margin-top: 8px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
}
.privacy-content.open { display: block; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
}
.summary-card .label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.summary-card .value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ink);
}
.summary-card .sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.sync-status-inner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sync-dot.ok { background: #20a35a; box-shadow: 0 0 6px #20a35a80; }
.sync-dot.warn { background: #e89d0e; box-shadow: 0 0 6px #e89d0e80; }
.sync-dot.off { background: #8b93a3; }
.sync-label { font-size: 0.92rem; color: var(--ink); }
.sync-label strong { font-weight: 700; }

.runs-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
}
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.infirmary-page table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.infirmary-page thead { background: var(--bg); }
.infirmary-page th {
  padding: 10px 14px;
  font-weight: 700;
  text-align: left;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.infirmary-page td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  color: var(--ink);
}
.infirmary-page tbody tr:last-child td { border-bottom: none; }
.infirmary-page tbody tr:hover { background: var(--bg); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.tag.email { background: #4285f420; color: #4285f4; }
.tag.chat { background: #20a35a20; color: #20a35a; }
.tag.new { background: #6e3ff320; color: #6e3ff3; }
.tag.updated { background: #e89d0e20; color: #b47d0a; }
.tag.skipped { background: #8b93a320; color: #636b7d; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--muted); }

.mock-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--brand-orange, #FF6A3D) 25%, var(--line));
  background: color-mix(in srgb, var(--brand-orange, #FF6A3D) 8%, var(--surface));
  color: var(--ink);
  font-size: 0.82rem;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  color: var(--ink);
}

@media (max-width: 760px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
