:root {
  color-scheme: light;
  --bg: #eef6f8;
  --panel: #ffffff;
  --ink: #15343d;
  --muted: #647883;
  --line: #cbdde3;
  --accent: #0b7285;
  --accent-2: #1da7c2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f7fbfc 0%, var(--bg) 100%);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 0 max(18px, calc((100vw - 1100px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  color: var(--ink);
  text-decoration: none;
}

.app-brand strong,
.app-brand small {
  display: block;
}

.app-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-nav a,
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.top-nav a:hover,
.link-button:hover {
  background: #eaf7fa;
}

.nav-form {
  margin: 0;
}

.shell {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.shell.wide {
  width: min(1100px, calc(100% - 32px));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 18px 44px rgba(35, 72, 84, 0.12);
}

.brand,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  justify-content: flex-start;
  margin-bottom: 36px;
}

.mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: var(--accent);
}

.mark.compact {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 32px;
}

h2 {
  margin: 28px 0 16px;
  font-size: 20px;
}

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

.upload-form {
  display: grid;
  gap: 14px;
}

label {
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

input[type="file"] {
  width: 100%;
  padding: 18px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: #f8fdfe;
}

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

.field-grid label {
  display: grid;
  gap: 8px;
}

.consent {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.consent legend {
  padding: 0 6px;
  font-weight: 700;
}

.consent label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.consent input {
  width: auto;
  min-height: auto;
}

.search-form,
.patient-form {
  display: grid;
  gap: 14px;
}

.search-form {
  grid-template-columns: 1fr auto;
}

button,
.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.back:hover {
  background: #075c6b;
}

.back.secondary {
  color: var(--accent);
  background: #eaf7fa;
}

.back.secondary:hover {
  background: #d8eef3;
}

.danger-button {
  background: #a33b3b;
}

.danger-button:hover {
  background: #842b2b;
}

.delete-form {
  margin-top: 18px;
}

.notice {
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid #b8dbe3;
  border-radius: 8px;
  background: #effbfe;
  color: #244b55;
}

.notice.danger {
  border-color: #e4b6b6;
  background: #fff1f1;
  color: #792828;
}

.action-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

a {
  color: var(--accent);
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  color: #075c6b;
  background: #dff5f8;
  font-weight: 700;
}

.result-card {
  display: grid;
  gap: 8px;
  margin-top: 24px;
  padding: 24px;
  border-radius: 8px;
  background: #eef9fb;
  border: 1px solid #c6e8ee;
}

.result-card strong {
  font-size: 28px;
}

.probabilities {
  display: grid;
  gap: 14px;
}

.prob-row {
  display: grid;
  grid-template-columns: 180px 1fr 72px;
  gap: 12px;
  align-items: center;
}

.bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dcebef;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
}

.scan-preview {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfc;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  background: #f6fbfc;
}

tr:last-child td {
  border-bottom: 0;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.meta-list.single {
  grid-template-columns: 1fr;
}

.owner-list {
  margin: 0;
  padding-left: 20px;
}

code {
  padding: 2px 6px;
  border-radius: 4px;
  background: #dff1f5;
}

.meta-list div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.meta-list dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.meta-list dd {
  margin: 0;
}

details {
  margin-top: 24px;
}

pre {
  overflow-x: auto;
  padding: 16px;
  border-radius: 8px;
  background: #f3f7f8;
}

@media (max-width: 640px) {
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .top-nav {
    justify-content: flex-start;
  }

  .shell {
    width: min(100% - 20px, 760px);
    padding: 20px 0;
  }

  .panel {
    padding: 22px;
  }

  .field-grid,
  .search-form,
  .meta-list {
    grid-template-columns: 1fr;
  }

  .prob-row {
    grid-template-columns: 1fr;
  }
}
