:root {
  --ink: #1f2937;
  --muted: #687385;
  --line: #dbeafe;
  --surface: #ffffff;
  --soft: #f5fbff;
  --teal: #38bdf8;
  --teal-dark: #075985;
  --gold: #d97706;
  --green: #0ea5e9;
  --red: #e11d48;
  --shadow: 0 18px 48px rgba(14, 165, 233, 0.13);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #e0f2fe 0%, #f5fbff 52%, #ffffff 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
.api-link,
.report-row a,
.danger-link {
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--teal), #0ea5e9);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0.72rem 1rem;
  text-decoration: none;
}

button:hover,
.api-link:hover,
.report-row a:hover {
  filter: brightness(0.96);
}

.danger-button {
  background: #fb7185;
}

.danger-button:hover,
.danger-link:hover {
  background: #e11d48;
}

.danger-link {
  background: #fb7185;
}

.login-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: center;
  gap: 2rem;
  padding: 1.5rem;
}

.login-copy {
  min-height: 520px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(14, 165, 233, 0.28), rgba(14, 165, 233, 0.18)),
    url("images/medical-genetics-hero.698d4c0cfd19.png");
  background-position: center;
  background-size: cover;
  color: #fff;
  padding: clamp(2rem, 5vw, 4rem);
}

.login-copy p,
.page-header p,
.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.login-copy p {
  color: #e0f2fe;
  font-weight: 700;
}

.login-copy h1 {
  max-width: 390px;
  margin: 1rem 0;
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  line-height: 1.08;
}

.login-copy span {
  display: block;
  max-width: 620px;
  color: #e0f2fe;
  font-size: 1.08rem;
  line-height: 1.8;
}

.login-form,
.patient-form,
.inline-form {
  display: grid;
  gap: 1rem;
}

.login-form,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.login-form {
  box-shadow: var(--shadow);
  padding: 1.4rem;
}

.login-form h2 {
  margin: 0;
}

label {
  display: grid;
  gap: 0.42rem;
  color: #334155;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0.72rem 0.78rem;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
  outline: 0;
}

.hint,
.empty {
  color: var(--muted);
}

.form-error,
.messages .error {
  border-radius: 6px;
  background: #fee2e2;
  color: var(--red);
  padding: 0.75rem;
}

.messages .success {
  border-radius: 6px;
  background: #dbeafe;
  color: #166534;
  padding: 0.75rem;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 1.5rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  padding: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), #0ea5e9);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span,
.operator-card span,
.operator-card strong {
  display: block;
}

.brand span,
.operator-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

nav {
  display: grid;
  gap: 0.35rem;
}

nav a {
  border-radius: 6px;
  color: var(--ink);
  padding: 0.75rem 0.8rem;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  background: #e0f2fe;
  color: var(--teal-dark);
}

.portfolio-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  background: #eff6ff;
  color: #0f5f8f;
  font-weight: 700;
  padding: 0.75rem 0.8rem;
  text-decoration: none;
}

.portfolio-link:hover {
  background: #dbeafe;
  color: #0f3f6b;
}

.operator-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1rem;
}

.operator-card button {
  margin-top: 0.8rem;
  width: 100%;
  background: #60a5fa;
}

.workspace {
  display: grid;
  gap: 1.2rem;
  padding: 1.5rem;
}

.page-header,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-header h1,
.panel-head h2 {
  margin: 0.2rem 0 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.metric,
.panel {
  box-shadow: 0 12px 32px rgba(30, 41, 59, 0.06);
}

.metric {
  color: inherit;
  padding: 1rem;
  text-decoration: none;
}

.metric-link:hover {
  border-color: rgba(14, 165, 233, 0.5);
  transform: translateY(-1px);
}

.metric span {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 2rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 1rem;
}

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

.panel {
  padding: 1rem;
}

.inline-form {
  margin-top: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
}

.snp-upload-form {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
}

.demo-form {
  margin-top: 0.8rem;
}

.status-pill {
  border-radius: 999px;
  background: #fef3c7;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
}

.table-wrap {
  margin-top: 1rem;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.78rem 0.55rem;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
}

td a {
  color: var(--teal-dark);
  font-weight: 700;
}

.ready {
  color: var(--green);
  font-weight: 800;
}

.report-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.compact-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.compact-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
}

.compact-list span {
  display: block;
  color: var(--muted);
  margin-top: 0.25rem;
}

.text-link {
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
}

.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
}

.report-row span {
  display: block;
  color: var(--muted);
  margin-top: 0.25rem;
}

.selected-row {
  background: #e0f2fe;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.inline-delete-form {
  margin: 0;
}

.inline-delete-form button {
  padding: 0.72rem 1rem;
}

.hidden-form {
  display: none;
}

.check {
  border-radius: 999px;
  display: inline-block;
  font-weight: 800;
  min-width: 58px;
  padding: 0.28rem 0.55rem;
  text-align: center;
}

.check.pass {
  background: #dbeafe;
  color: #166534;
}

.check.fail {
  background: #fee2e2;
  color: var(--red);
}

.check-grid,
.report-meta,
.risk-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check-card,
.info-box,
.risk-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
}

.check-card span,
.info-box span,
.risk-item span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
}

.pass-text {
  color: var(--green);
}

.fail-text {
  color: var(--red);
}

.raw-preview {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #334155;
  margin: 1rem 0 0;
  max-height: 420px;
  overflow: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

.report-sheet {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.report-title {
  border-bottom: 2px solid var(--teal);
  padding-bottom: 0.8rem;
}

.report-title h3 {
  margin: 0;
  font-size: 1.45rem;
}

.report-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.risk-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-section {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.report-section h4 {
  color: var(--ink);
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.advice-list {
  display: grid;
  gap: 0.75rem;
}

.advice-item {
  background: #e0f2fe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
}

.advice-item strong {
  color: var(--teal-dark);
  display: block;
  margin-bottom: 0.35rem;
}

.advice-item p,
.disclaimer-box p {
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

.disclaimer-box {
  background: #ffffff;
  border: 1px solid #fdba74;
  border-radius: 8px;
  padding: 1rem;
}

.compact-risk-grid {
  grid-template-columns: 1fr;
}

.mini-snp-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.mini-snp-list em {
  background: #f1f5f9;
  border-radius: 999px;
  color: #334155;
  font-size: 0.78rem;
  font-style: normal;
  padding: 0.25rem 0.45rem;
}

@media (max-width: 1100px) {
  .app-shell,
  .login-layout,
  .content-grid,
  .overview-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar,
  .login-layout {
    padding: 1rem;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .check-grid,
  .report-meta,
  .risk-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .panel-head,
  .report-row {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
