html, body { height: 100%; margin: 0; padding: 0; }
:root {
  --bg: #f4f6fb;
  --ink: #141826;
  --muted: #6b7280;
  --brand: #2d6cdf;
  --brand-dark: #244ea6;
  --sidebar: #0f1324;
  --sidebar-accent: #1b2140;
  --card: #ffffff;
  --border: #e6e8f0;
  --success: #1fbf75;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 18px 45px rgba(19, 27, 51, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Sora', system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }

.container {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 24px rgba(45, 108, 223, 0.25);
}

.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}

.btn-ghost:hover { border-color: #cbd5f5; }

.btn:disabled,
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.hero {
  background: url('assets/imgs/splash-bg.jpg') center/75% no-repeat;
  padding: 80px 0 120px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12, 18, 35, 0.72), rgba(12, 18, 35, 0.55));
  z-index: 0;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 10%, rgba(61, 120, 255, 0.25), transparent 55%);
  z-index: 1;
}

.hero .container {
  position: relative;
  z-index: 2;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
}

.badge-success { background: #e7f7ee; color: #1f7a4b; border-color: #cdeedb; }
.badge-warning { background: #fff4d9; color: #9a6a00; border-color: #ffe3a3; }
.badge-danger { background: #fde8e8; color: #b42318; border-color: #f7c2c2; }
.badge-info { background: #e8f2ff; color: #2b5fd2; border-color: #cfe0ff; }
.badge-proband { background: #e8f2ff; color: #2b5fd2; border-color: #cfe0ff; margin-left: 8px; }
.badge-proband i { font-size: 10px; }
.badge-variation { background: #f2ecff; color: #5a35b5; border-color: #decfff; margin-left: 8px; }
.badge-variation i { font-size: 10px; }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(18, 24, 40, 0.45);
  z-index: 1000;
  padding: 24px;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  max-width: 760px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #e6e9f3;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.modal-header h3 { margin: 0; }

.modal-header p {
  margin: 4px 0 0 0;
  color: #667085;
  font-size: 13px;
}

.modal-close {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 20px;
  cursor: pointer;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #344054;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 14px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2d6cdf;
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.15);
  background: #fff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.modal-feedback {
  margin-top: 12px;
  font-size: 13px;
  color: #475467;
}

@media (max-width: 820px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 10px;
}

.navbar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  letter-spacing: 0.5px;
  color: #f8fbff;
}

.navbar .logo img {
  height: 36px;
  width: auto;
  display: block;
}

.navbar .links {
  display: flex;
  gap: 16px;
  align-items: center;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 40px;
  align-items: center;
  margin-top: 40px;
}

.hero h1 {
  font-size: clamp(32px, 4vw, 46px);
  margin: 0 0 16px;
  color: #f8fbff;
}

.hero p {
  color: rgba(248, 251, 255, 0.85);
  font-size: 16px;
  line-height: 1.6;
}

.hero-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(3px);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero .btn-ghost {
  color: #f8fbff;
  border-color: rgba(248, 251, 255, 0.5);
}

.hero .btn-ghost:hover {
  border-color: #f8fbff;
}

.section {
  padding: 60px 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.feature {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
}

.feature i {
  color: var(--brand);
  font-size: 22px;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 16px;
  background: linear-gradient(135deg, #f0f4ff 0%, #ffffff 55%, #f7f8ff 100%);
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--card);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.auth-card-wide {
  width: min(560px, 92vw);
}

.auth-card h2 { margin: 0 0 6px; }

.auth-card .muted { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.auth-links a {
  color: var(--brand);
  font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  padding: 12px 14px;
  margin: 6px 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  outline: none;
  font-size: 14px;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 104px;
}

input:focus,
textarea:focus { border-color: #9bb9ff; box-shadow: 0 0 0 3px rgba(45,108,223,0.12); }

.error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }

.success {
  color: #147a4c;
  background: #e7f7ee;
  border: 1px solid #cdeedb;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 14px;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  min-height: 100vh;
  background: var(--sidebar);
  color: #d6dbff;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar .brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .brand img {
  height: 30px;
  width: auto;
  display: block;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #b9c1ff;
}

.sidebar a.active,
.sidebar a:hover {
  background: var(--sidebar-accent);
  color: #fff;
}

.sidebar-account {
  display: grid;
  gap: 3px;
  margin-top: auto;
  color: #7e88c8;
  font-size: 12px;
  line-height: 1.25;
}

.sidebar-account strong {
  color: #9aa4e8;
  font-weight: 700;
  word-break: break-word;
}

.sidebar-api-status {
  margin-top: 8px;
  font-weight: 700;
}

.sidebar-api-status.is-connected {
  color: #58d68d;
}

.sidebar-api-status.is-warning {
  color: #f7bf54;
}

.main {
  padding: 24px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.search {
  flex: 1;
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.search input::placeholder {
  color: var(--muted);
}

.table-card {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.dashboard-table-card {
  min-height: 780px;
}

.table-card h3 { margin-top: 0; }

#pedigrees-table {
  table-layout: auto;
}

#pedigrees-table th:nth-child(1),
#pedigrees-table td:nth-child(1) {
  width: 46%;
}

#pedigrees-table th:nth-child(2),
#pedigrees-table td:nth-child(2) {
  width: 25%;
}

#pedigrees-table th:nth-child(3),
#pedigrees-table td:nth-child(3) {
  width: 29%;
}

#pedigrees-table td:nth-child(1) {
  word-break: break-word;
}

.pedigree-match-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.recent-pedigrees-table .dataTables_info {
  color: var(--muted);
}

.recent-pedigrees-table .dataTables_paginate {
  display: none;
}

.recent-pedigrees-table.is-searching .dataTables_paginate {
  display: block;
}

.section-kicker {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.compliance-card {
  margin-bottom: 20px;
}

.compliance-page-card {
  margin-bottom: 18px;
}

.compliance-header,
.compliance-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.compliance-header h3 {
  margin: 0;
}

.compliance-copy {
  margin: 12px 0 18px;
  max-width: 840px;
  color: var(--muted);
  line-height: 1.55;
}

.compliance-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.compliance-status-ok {
  color: #136a43;
  background: #e7f7ee;
  border: 1px solid #cdeedb;
}

.compliance-status-warning,
.compliance-status-loading {
  color: #8a5f00;
  background: #fff4d9;
  border: 1px solid #ffe3a3;
}

.compliance-status-attention {
  color: #b42318;
  background: #fde8e8;
  border: 1px solid #f7c2c2;
}

.compliance-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .9fr);
  gap: 18px;
}

.compliance-grid h4 {
  margin: 0 0 10px;
  color: #344054;
  font-size: 14px;
}

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

.compliance-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfcff;
}

.compliance-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.compliance-item strong,
.compliance-item span,
.compliance-item small {
  display: block;
}

.compliance-item strong {
  font-size: 13px;
  color: var(--ink);
}

.compliance-item span,
.compliance-item small,
.compliance-placeholder,
.compliance-footer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.compliance-item small {
  margin-top: 2px;
}

.compliance-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.compliance-note-card {
  max-width: 920px;
}

.compliance-note-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.pedigree-data-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

#people-table tbody tr {
  cursor: pointer;
}

#people-table tbody tr.is-selected td {
  background: #eef4ff !important;
}

.person-detail-card {
  position: sticky;
  top: 16px;
}

.person-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  margin-bottom: 12px;
}

.person-detail-grid span,
.person-detail-block .muted {
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}

.person-detail-grid strong {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.person-detail-block {
  margin: 12px 0;
}

.person-detail-block p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}

.webform-clinical-card {
  margin-top: 20px;
}

.clinical-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.clinical-card-header h3,
.clinical-card-header p {
  margin: 0;
}

.clinical-card-header p {
  margin-top: 4px;
}

.clinical-empty {
  color: var(--muted);
  font-size: 14px;
}

.clinical-summary-body {
  display: grid;
  gap: 18px;
}

.clinical-overview,
.clinical-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.clinical-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.clinical-field {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcff;
  min-width: 0;
}

.clinical-field span,
.clinical-list-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.clinical-field strong,
.clinical-list-item strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}

.clinical-list {
  display: grid;
  gap: 8px;
}

.clinical-list-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.clinical-json {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.clinical-json summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
  font-size: 13px;
}

.clinical-json pre {
  margin: 12px 0 0;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #0f1324;
  color: #eef4ff;
  font-size: 12px;
  line-height: 1.45;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

@media (max-width: 980px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar {
  min-height: 100vh; flex-direction: row; flex-wrap: wrap; }
  .compliance-grid {
    grid-template-columns: 1fr;
  }
  .pedigree-data-layout {
    grid-template-columns: 1fr;
  }
  .person-detail-card {
    position: static;
  }
  .clinical-card-header {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; }
}
.btn-sm { padding: 6px 10px; font-size: 11px; }

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 8px !important;
  border: 1px solid transparent !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--brand) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
}
.muted { color: var(--muted); }
