:root { font-family: system-ui, sans-serif; color: #1e293b; background: #f4f6f8; }
body { margin: 0; }
header { background: #003A70; color: #fff; padding: 1.4rem max(1rem, calc((100% - 1100px) / 2)); }
header h1 { margin: 0; }
header p { margin: .35rem 0 0; }
.principle { font-weight: 700; }
main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.card { background: #fff; border: 1px solid #d9e0e6; border-radius: 8px; padding: 1.1rem; margin-bottom: 1rem; box-shadow: 0 1px 2px #0000000b; }
h2 { margin-top: 0; }
h3 { margin: 1.3rem 0 .5rem; font-size: 1rem; }
form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: .8rem; min-width: 0; }
form > label { min-width: 0; }
label { display: grid; gap: .3rem; font-weight: 600; }
input, select, textarea, button { font: inherit; padding: .55rem; border: 1px solid #94a3b8; border-radius: 4px; }
input[type="file"] { box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; }
textarea { resize: vertical; }
button { background: #003A70; color: #fff; border: 0; cursor: pointer; font-weight: 700; }
button:disabled { background: #94a3b8; cursor: not-allowed; }
.secondary { background: #e6eef6; color: #003A70; border: 1px solid #9db9d3; }
.actions { display: flex; gap: .6rem; align-items: end; }
.field-help { font-size: .8rem; font-weight: 400; color: #64748b; }
.field-wide { grid-column: 1 / -1; }
.hint { margin: .9rem 0 0; color: #475569; }
.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: .7rem; }
.source, .external-service { border: 1px solid #d9e0e6; border-radius: 5px; padding: .7rem; }
.source h3, .external-service h3 { margin: 0 0 .25rem; font-size: 1rem; }
.source p { margin: 0; font-size: .9rem; }
.status { font-size: .75rem; font-weight: 800; letter-spacing: .02em; }
.searched { color: #166534; }
.unavailable { color: #9a3412; }
.skipped { color: #64748b; }
.candidates { display: grid; gap: .7rem; }
.candidate { border: 1px solid #bfd1e0; border-left: 4px solid #003A70; border-radius: 5px; padding: .8rem; }
.candidate h3 { margin: 0; }
.candidate p { margin: .35rem 0; }
.candidate button { margin-top: .35rem; }
.match { font-weight: 800; color: #003A70; }
.marc-leader, .marc-control, .marc-field { border: 1px solid #d9e0e6; border-radius: 6px; padding: .8rem; margin: .8rem 0; background: #fff; }
.marc-leader, .marc-control-row, .marc-field-header, .marc-subfield { display: flex; gap: .5rem; align-items: center; }
.marc-leader label, .marc-control-row label { white-space: nowrap; }
.marc-leader input, .marc-control-row input, .marc-field input, .marc-subfield input { min-width: 0; }
.marc-leader input, .marc-control-row input, .subfield-value { flex: 1; }
.marc-field-header { display: grid; grid-template-columns: 5rem 1fr 1fr auto; gap: .5rem; }
.marc-field-header label, .marc-subfield label { display: grid; gap: .25rem; font-size: .78rem; font-weight: 700; }
.marc-field-header input { width: 100%; box-sizing: border-box; }
.marc-subfields { margin: .8rem 0; }
.marc-subfield { margin: .5rem 0; }
.subfield-code { width: 4.5rem; }
.marc-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.small-button { padding: .35rem .5rem; font-size: .82rem; }
.export-bar { display: flex; justify-content: flex-end; padding: 0 0 2rem; }
.external-services { display: grid; gap: .8rem; }
.external-service { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .9fr) auto; gap: 1rem; align-items: start; }
.external-service p { margin: .3rem 0; }
.service-category { color: #64748b; font-size: .8rem; font-weight: 700; }
.external-service dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem .8rem; margin: 0; font-size: .85rem; }
.external-service dl div { min-width: 0; }
.external-service dt { color: #475569; font-weight: 700; }
.external-service dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
.masked { letter-spacing: .08em; }
.book-only, .thesis-only, .ebook-only { display: none; }
.resource-book .book-only, .resource-thesis .thesis-only, .resource-ebook .ebook-only { display: grid; }
@media (max-width: 750px) {
  .sources { grid-template-columns: 1fr; }
  .actions { grid-column: 1 / -1; }
  .marc-leader, .marc-control-row, .marc-subfield { align-items: stretch; flex-wrap: wrap; }
  .marc-field-header { grid-template-columns: 1fr 1fr; }
  .external-service { grid-template-columns: 1fr; }
  .external-service dl { grid-template-columns: 1fr; }
  .export-bar { justify-content: stretch; }
  .export-bar button { width: 100%; }
}
