@import url('https://fonts.googleapis.com/css2?family=UnifrakturMaguntia&display=swap');
:root { --blue:#005bbb; --red:#d40000; --white:#fff; --ink:#1f2430; --paper:#fbfaf6; --line:#d9d5cc; }
* { box-sizing:border-box; }
body { margin:0; font-family: Georgia, 'Times New Roman', serif; color:var(--ink); background:var(--paper); }
a { color:#004a99; text-decoration:none; } a:hover { text-decoration:underline; }
.site-header { display:flex; align-items:center; gap:18px; padding:14px 24px; background:linear-gradient(90deg,var(--blue),#2d79d3); color:#fff; border-bottom:8px solid var(--white); box-shadow:0 8px 0 var(--red); }
.crest-link img { width:64px; height:72px; display:block; }
.fraktur-title { font-family:'UnifrakturMaguntia', Georgia, serif; font-size:42px; line-height:1; letter-spacing:.02em; }
.subtitle { font-size:16px; margin-top:4px; }
.title-block { flex:1; }
.topnav { display:flex; gap:14px; flex-wrap:wrap; align-items:center; }
.topnav a { color:#fff; font-weight:bold; padding:8px 10px; border-radius:6px; }
.topnav a:hover { background:rgba(255,255,255,.15); text-decoration:none; }
.site-body { max-width:1640px; margin:34px auto; padding:0 22px; min-height:70vh; }
.site-footer { background:var(--red); color:#fff; padding:22px; text-align:center; border-top:8px solid #fff; }
.card { background:#fff; border:1px solid var(--line); border-radius:12px; padding:22px; box-shadow:0 2px 10px rgba(0,0,0,.05); margin-bottom:18px; }
.hero { border-left:10px solid var(--blue); }
h1,h2,h3 { margin-top:0; }
.btn, button, input[type=submit] { display:inline-block; background:var(--blue); color:#fff; border:0; padding:10px 14px; border-radius:8px; cursor:pointer; font-weight:bold; }
.btn.red { background:var(--red); }
.btn.light { background:#eef4ff; color:#123; }
input, textarea, select { width:100%; padding:10px; border:1px solid var(--line); border-radius:8px; font:inherit; background:#fff; }
textarea { min-height:120px; }
label { display:block; margin:12px 0 5px; font-weight:bold; }
.grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(250px,1fr)); gap:18px; }
.searchbar { display:flex; gap:8px; }
.searchbar input { flex:1; }
.filter-form { display:grid; grid-template-columns:2fr 1fr 150px 150px 1fr 1fr auto; gap:14px; align-items:end; }
.filter-form .form-row { min-width:0; }
.filter-form .buttons { display:flex; gap:8px; align-items:end; }
.filter-form .buttons label { display:none; }

.table { width:100%; border-collapse:collapse; background:#fff; }
.table th,.table td { padding:10px; border-bottom:1px solid var(--line); vertical-align:top; text-align:left; }
.badge { display:inline-block; padding:3px 8px; border-radius:999px; background:#eef4ff; margin:2px; font-size:13px; }
.law-layout { display:grid; grid-template-columns:minmax(300px, 1.1fr) minmax(300px,.9fr); gap:18px; }
.viewer img { max-width:100%; border:1px solid var(--line); background:#fff; }
.ocr-box { white-space:pre-wrap; background:#fff; border:1px solid var(--line); padding:16px; border-radius:10px; overflow:auto; }
.ocr-box.full { max-height:none; overflow:visible; }
.ocr-edit { min-height:520px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space:pre-wrap; }
.small-help { font-size:13px; color:#555; }
.merge-form { display:grid; grid-template-columns:1fr 1fr auto; gap:14px; align-items:end; }
.notice { background:#fff5d6; border-left:6px solid #e1a600; padding:12px 14px; border-radius:6px; }
.error { background:#ffe8e8; border-left:6px solid var(--red); padding:12px 14px; border-radius:6px; }
.meta-list dt { font-weight:bold; margin-top:8px; }
.meta-list dd { margin-left:0; }
@media (max-width:1200px) { .filter-form{grid-template-columns:1fr 1fr;} .merge-form{grid-template-columns:1fr;} }
@media (max-width:800px) { .site-header { align-items:flex-start; flex-direction:column; } .law-layout{grid-template-columns:1fr;} .searchbar{flex-direction:column;} .filter-form{grid-template-columns:1fr;} }

/* v4 OCR/admin fixes */
.admin-panel { border-left: 8px solid var(--red); }
.ocr-window {
  display: block;
  width: 100%;
  min-height: 420px;
  max-height: 620px;
  overflow: auto;
  white-space: pre-wrap;
  background: #fffdf7;
  border: 1px solid #d8d0c2;
  border-radius: 10px;
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .95rem;
  line-height: 1.55;
  box-sizing: border-box;
}
textarea.ocr-window {
  resize: vertical;
  white-space: pre-wrap;
}
.audit-row {
  border-bottom: 1px solid #eee;
  padding: .7rem 0;
}

/* v5 law page: metadata top, image/OCR parallel columns */
.law-top { border-left: 10px solid var(--blue); }
.law-top-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}
.law-top-heading h1 { margin-bottom: .25rem; }
.law-top-actions { flex: 0 0 auto; }
.metadata-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(260px, .9fr) minmax(280px, .7fr);
  gap: 1.25rem;
  align-items: start;
}
.metadata-grid section { min-width: 0; }
.meta-list.compact dd { margin-bottom: .75rem; }
.entity-heading {
  font-size: 1rem;
  margin: .7rem 0 .35rem;
  text-transform: capitalize;
}
.inline-admin {
  padding: 1rem;
  border-radius: 10px;
  background: #fff9f9;
}
.page-ocr-list { margin-top: 1.25rem; }
.page-pair {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.page-image-col img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
}
.page-ocr-col h2,
.page-image-col h2 { margin-bottom: .25rem; }
.page-ocr-form { margin: 0; }
.page-save-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: .75rem;
}
.page-pair .ocr-window {
  min-height: 680px;
  max-height: 82vh;
}
@media (max-width: 1200px) {
  .metadata-grid { grid-template-columns: 1fr 1fr; }
  .metadata-grid .inline-admin { grid-column: 1 / -1; }
  .page-pair { grid-template-columns: 1fr; }
  .page-pair .ocr-window { min-height: 420px; max-height: 70vh; }
}
@media (max-width: 760px) {
  .law-top-heading { flex-direction: column; }
  .metadata-grid { grid-template-columns: 1fr; }
}

/* v6 entity administration */
.entity-filter-form {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) minmax(280px, 1.5fr) minmax(150px, .7fr) minmax(140px, .6fr) auto;
  gap: 14px;
  align-items: end;
}
.entity-filter-buttons > div { display: flex; gap: 8px; }
.entity-table-card { padding: 0; overflow: hidden; }
.entity-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.entity-table-toolbar > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.entity-table-wrap { overflow-x: auto; }
.entity-admin-table { min-width: 1080px; margin: 0; }
.entity-admin-table thead th { background: #eef3fa; position: sticky; top: 0; z-index: 1; }
.entity-select-col,
.entity-target-col { width: 64px; text-align: center !important; }
.entity-inline-edit-cell { padding: 7px 10px !important; }
.entity-row-form { margin: 0; }
.entity-row-fields {
  display: grid;
  grid-template-columns: minmax(180px, .9fr) minmax(320px, 1.8fr) 70px 78px;
  gap: 10px;
  align-items: center;
}
.entity-row-fields input,
.entity-row-fields select { width: 100%; box-sizing: border-box; }
.entity-law-count { text-align: center; font-variant-numeric: tabular-nums; }
.entity-target { visibility: hidden; transform: scale(1.2); }
.target-available .entity-target { visibility: visible; }
.entity-check { transform: scale(1.2); }
.button.secondary,
button.secondary {
  display: inline-block;
  background: #eef1f5;
  color: #1d2733;
  border: 1px solid #c8d0da;
  text-decoration: none;
}
@media (max-width: 1100px) {
  .entity-filter-form { grid-template-columns: 1fr 1fr; }
  .entity-filter-buttons { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .entity-filter-form { grid-template-columns: 1fr; }
  .entity-filter-buttons { grid-column: auto; }
  .entity-table-toolbar { align-items: flex-start; flex-direction: column; }
}

.entity-admin-link { text-decoration: none; }
.entity-admin-link:hover { text-decoration: underline; filter: brightness(.96); }
.narrow-card { max-width: 860px; margin-left: auto; margin-right: auto; }
