:root {
  --blue: #084486;
  --blue-strong: #2563eb;
  --panel: #ffffff;
  --page: #f5f6fb;
  --border: #d8deea;
  --text: #1e2330;
  --muted: #64748b;
  --danger: #dc2626;
  --warning: #b45309;
  --ok: #166534;
  --toc-width: 21.7rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

body[data-authenticated="false"] .app-header,
body[data-authenticated="false"] .session-bar,
body[data-authenticated="false"] .layout,
body[data-authenticated="pending"] .app-header,
body[data-authenticated="pending"] .session-bar,
body[data-authenticated="pending"] .layout,
body[data-authenticated="true"] .auth-screen {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.auth-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #f5f6fb;
}

.auth-panel {
  width: min(100%, 380px);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}

.auth-panel[hidden] {
  display: none;
}

.auth-panel h1 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--blue);
}

.auth-logo {
  width: 42px;
  height: auto;
}

.btn-secondary {
  border: 1px solid #cbd5f5;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-weight: 700;
}

.app-header {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 1rem;
  background: var(--blue);
  color: #fff;
}

.app-title,
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.45rem;
}

.partner-logo {
  height: 28px;
  width: auto;
}

.session-bar {
  min-height: 42px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.35rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.header-logout {
  min-height: 32px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-weight: 700;
}

.header-logout:hover,
.header-logout:focus-visible {
  border-color: var(--blue-strong);
  background: #eff6ff;
  outline: none;
}

.bestand-switcher {
  min-width: 13rem;
  color: #e2e8f0;
  font-size: 0.76rem;
}

.bestand-switcher select {
  min-height: 34px;
  border-color: rgba(255, 255, 255, 0.4);
  background: #ffffff;
  color: var(--text);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
}

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem 1rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #475569;
  padding: 0.58rem 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  color: var(--blue-strong);
  border-bottom-color: var(--blue-strong);
}

.screen {
  display: none;
  flex: 1;
  min-height: 0;
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.screen-header {
  display: grid;
  grid-template-columns: 26rem minmax(560px, 1fr);
  grid-template-rows: auto auto;
  align-items: start;
  gap: 0.45rem 1rem;
  margin-bottom: 0.7rem;
}

.title-block {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.header-controls {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: end;
  display: flex;
  align-items: end;
  gap: 0.55rem;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: end;
}

.risk-screen-header {
  grid-template-columns: minmax(22rem, 30rem) minmax(420px, 1fr);
}

.register-tabs {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.35rem;
}

.register-tab {
  min-height: 38px;
  border: 1px solid #cbd5f5;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-weight: 800;
}

.register-tab.active {
  border-color: var(--blue-strong);
  background: #eff6ff;
  color: var(--blue-strong);
}

.title-block h2,
.panel h3 {
  margin: 0;
}

.heading-summary {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 400;
  white-space: nowrap;
}

.title-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.15rem;
  width: 100%;
}

.title-block p,
.status-line {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.status-line.status-error {
  margin-top: 0.45rem;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fef2f2;
  color: var(--danger);
  padding: 0.55rem 0.7rem;
  font-weight: 800;
}

.btn-primary {
  border: 0;
  border-radius: 6px;
  background: var(--blue-strong);
  color: #fff;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-weight: 700;
}

.btn-compact {
  min-height: 32px;
  padding: 0.35rem 0.7rem;
  font-size: 0.86rem;
}

.filter-bar {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-columns:
    minmax(210px, 1.25fr)
    minmax(210px, 1.25fr)
    minmax(120px, 0.75fr)
    minmax(120px, 0.75fr);
  align-items: end;
  gap: 0.45rem 0.65rem;
  margin-left: 0.35rem;
  min-width: 0;
}

.filter-control,
label {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: #334155;
  font-weight: 700;
  font-size: 0.82rem;
}

.filter-label {
  display: block;
}

.document-control-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.document-control-buttons #refreshBtn {
  margin-left: 0.45rem;
  min-height: 38px;
}

.search-filter {
  grid-column: 1 / span 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.45rem;
  min-width: 0;
}

.search-input-label {
  min-width: 0;
}

.search-content-option {
  min-height: 38px;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #cbd5f5;
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem 0.65rem;
  white-space: nowrap;
  cursor: pointer;
}

.search-content-option input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--blue-strong);
  cursor: pointer;
}

input,
select,
textarea {
  min-height: 38px;
  border: 1px solid #cbd5f5;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0.5rem 0.65rem;
}

.filter-bar input,
.filter-bar select {
  padding-right: 2.45rem;
}

.filter-bar .search-content-option input {
  padding-right: 0;
}

.filter-active {
  color: var(--blue);
}

.filter-input-active {
  border-color: var(--blue-strong);
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.filter-clear {
  position: absolute;
  right: 0.42rem;
  bottom: 0.37rem;
  width: 26px;
  height: 26px;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.filter-clear:hover,
.filter-clear:focus-visible {
  border-color: var(--blue-strong);
  background: #dbeafe;
}

textarea {
  resize: vertical;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(760px, 50%) 0.9rem minmax(300px, var(--toc-width)) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  flex: 1;
  transition: grid-template-columns 0.18s ease;
}

.workspace.list-collapsed {
  grid-template-columns: minmax(300px, var(--toc-width)) minmax(0, 1fr);
}

.document-table-panel,
.document-workspace-header,
.toc-panel,
.detail-panel,
.panel {
  background: var(--panel);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  min-height: 0;
  overflow: auto;
}

.document-table-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.document-workspace-header {
  grid-column: 3 / 5;
  grid-row: 1;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  padding: 0.85rem 1rem;
  overflow: hidden;
}

.document-workspace-header h3 {
  margin: 0 0 0.25rem;
  color: #64748b;
  font-size: 1.05rem;
  line-height: 1.25;
}

.document-workspace-header .status-line {
  font-size: 0.92rem;
  line-height: 1.2;
}

.toc-panel {
  grid-column: 3;
  grid-row: 2;
  border-right: 0;
  border-radius: 0 0 0 10px;
}

.detail-panel {
  grid-column: 4;
  grid-row: 2;
  border-radius: 0 0 10px 0;
}

.workspace.list-collapsed .document-workspace-header {
  grid-column: 1 / 3;
}

.workspace.list-collapsed .toc-panel {
  grid-column: 1;
}

.workspace.list-collapsed .detail-panel {
  grid-column: 2;
}

.workspace.original-only .toc-panel {
  display: none;
}

.risk-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 0.8rem;
  min-height: 0;
  flex: 1;
}

.register-panel,
.register-form {
  display: flex;
  flex-direction: column;
}

.register-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.8rem;
  padding: 0.85rem;
  border-bottom: 1px solid #e2e8f0;
}

.register-panel-header h3,
.register-form h3 {
  margin: 0;
}

.register-table-wrap {
  min-height: 0;
  overflow: auto;
}

.register-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.82rem;
}

.register-table th,
.register-table td {
  padding: 0.42rem 0.38rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.register-table th {
  position: sticky;
  top: 0;
  background: #eef2ff;
  z-index: 1;
  color: #334155;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.register-table tr {
  cursor: pointer;
}

.register-table tbody tr:hover {
  background: #f8fbff;
}

.register-table tbody tr.displayed {
  background: #e6f0fb;
  box-shadow: inset 4px 0 0 var(--blue);
}

.inline-register-input {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 0.25rem 0.35rem;
  font: inherit;
  line-height: 1.25;
}

.inline-register-input:hover {
  border-color: #cbd5e1;
}

.inline-register-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(47, 111, 167, 0.16);
}

.inline-register-input:disabled {
  color: var(--muted);
  background: #f8fafc;
}

.register-form {
  padding: 0.85rem;
  gap: 0.75rem;
}

.register-form-fields {
  display: grid;
  gap: 0.8rem;
}

.register-form textarea {
  min-height: 86px;
}

.register-field-group {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.register-field-group h4 {
  margin: 0;
  color: #334155;
  font-size: 0.88rem;
}

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

.register-field-grid label {
  min-width: 0;
}

.register-field-grid small {
  color: var(--muted);
  font-weight: 600;
  line-height: 1.25;
}

.register-field-grid .wide-field {
  grid-column: 1 / -1;
}

.register-id-box {
  margin: 0;
}

.register-document-ref {
  display: block;
  margin-top: 0.25rem;
  color: #334155;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.2rem;
}

.unavailable-panel {
  padding: 1rem;
  color: var(--muted);
  font-weight: 700;
}

.workspace.original-only .detail-panel {
  grid-column: 3 / 5;
  border-radius: 0 0 10px 10px;
}

.workspace.list-collapsed.original-only .detail-panel {
  grid-column: 1 / 3;
}

.toc-panel {
  padding: 0.8rem;
}

.document-table-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-toggle {
  width: 88px;
  min-height: 38px;
  border: 1px solid #cbd5f5;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  padding: 0.25rem 0.35rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.document-nav-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #cbd5f5;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.list-toggle:hover,
.list-toggle:focus-visible,
.document-nav-button:hover,
.document-nav-button:focus-visible {
  border-color: var(--blue-strong);
  color: var(--blue-strong);
  outline: none;
}

.list-toggle:disabled,
.document-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.list-toggle:disabled:hover,
.list-toggle:disabled:focus-visible,
.document-nav-button:disabled:hover,
.document-nav-button:disabled:focus-visible {
  border-color: #cbd5f5;
  color: var(--blue);
}

.list-toggle-collapsed {
  display: none;
}

.document-table-wrap {
  min-height: 0;
  overflow: auto;
}

.workspace.list-collapsed .document-table-panel {
  display: none;
}

.workspace.list-collapsed .document-table-wrap {
  display: none;
}

.list-toggle.collapsed .list-toggle-expanded {
  display: none;
}

.list-toggle.collapsed .list-toggle-collapsed {
  display: inline;
}

.document-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.8rem;
}

.document-table th,
.document-table td {
  padding: 0.48rem 0.3rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.document-table th {
  position: sticky;
  top: 0;
  background: #eef2ff;
  z-index: 1;
  color: #334155;
  font-size: 0.72rem;
  text-transform: uppercase;
  overflow-wrap: normal;
  white-space: nowrap;
}

.column-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.16rem;
  width: 100%;
  position: relative;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 0.16rem;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  white-space: nowrap;
}

.column-help {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #dbeafe;
  color: var(--blue);
  font-size: 0.62rem;
  line-height: 1;
  text-transform: none;
  position: relative;
  cursor: help;
  z-index: 3;
}

.column-help-popup {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  width: max-content;
  max-width: 280px;
  transform: translateX(-50%);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  color: #1f2937;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 0.45rem 0.55rem;
  text-transform: none;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  z-index: 20;
}

.column-help-popup ul {
  margin: 0.35rem 0 0;
  padding-left: 1rem;
}

.column-help-popup li {
  margin: 0.1rem 0;
}

.column-help:hover .column-help-popup,
.column-help:focus-visible .column-help-popup {
  opacity: 1;
  visibility: visible;
}

.document-table th:nth-child(-n+3) .column-help-popup {
  left: 0;
  transform: none;
}

.document-table th:nth-last-child(-n+2) .column-help-popup {
  right: 0;
  left: auto;
  transform: none;
}

.sort-icon {
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1;
}

.document-table tr {
  cursor: pointer;
}

.document-table tbody tr:hover {
  background: #f8fbff;
}

.document-table tbody tr:focus-within {
  background: #fff7ed;
  outline: 2px solid #f59e0b;
  outline-offset: -2px;
}

.document-table tbody tr.displayed,
.document-table tbody tr.displayed:hover {
  background: #e6f0fb;
  box-shadow: inset 4px 0 0 var(--blue);
}

.document-table tbody tr.displayed:focus-within {
  background: #dbeafe;
  outline: 2px solid var(--blue-strong);
  outline-offset: -2px;
}

.document-open {
  display: inline;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
}

.document-open:hover,
.document-open:focus-visible {
  color: var(--blue-strong);
  text-decoration: underline;
}

.document-action-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #cbd5f5;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
}

.document-action-button:hover,
.document-action-button:focus-visible {
  border-color: var(--blue-strong);
  background: #eff6ff;
  color: var(--blue-strong);
  outline: none;
}

.document-table th:nth-child(1) { width: 54px; }
.document-table th:nth-child(2) { width: 110px; }
.document-table th:nth-child(3) { width: 146px; }
.document-table th:nth-child(4) { width: 72px; }
.document-table th:nth-child(5) { width: 42px; }
.document-table th:nth-child(6) { width: 76px; }
.document-table th:nth-child(7) { width: 76px; }
.document-table th:nth-child(8) { width: 88px; }
.document-table th:nth-child(9) { width: 104px; }
.document-table th:nth-child(10) { width: 58px; }
.document-table th:nth-child(11) { width: 64px; }

.document-table th:nth-child(2),
.document-table td:nth-child(2) {
  white-space: nowrap;
  overflow-wrap: normal;
}

.mapping-compact {
  display: inline-block;
  max-width: 100%;
  color: #334155;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-panel {
  padding: 1rem;
}

.toc-panel h3 {
  margin: 0 0 0.6rem;
  color: #334155;
  font-size: 0.86rem;
  text-transform: uppercase;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-link {
  display: block;
  border-radius: 6px;
  color: #0f3f75;
  padding: 0.32rem 0.4rem;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
}

.toc-link:hover,
.toc-link:focus-visible {
  background: #eff6ff;
  color: var(--blue-strong);
  outline: none;
}

.toc-level-3 { padding-left: 0.9rem; font-weight: 650; }
.toc-level-4,
.toc-level-5,
.toc-level-6 { padding-left: 1.55rem; font-weight: 600; }

.preview-tabs {
  margin-top: 0;
}

.preview-tab-list {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #eef2f7;
  padding: 0.18rem;
  margin-bottom: 0.95rem;
}

.preview-tab {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
}

.preview-tab.active {
  border-color: #bfdbfe;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  color: var(--blue);
}

.preview-tab:focus-visible {
  outline: 2px solid var(--blue-strong);
  outline-offset: 2px;
}

.preview-panel[hidden] {
  display: none;
}

.jp-original-reference {
  display: grid;
  gap: 1rem;
  max-width: 980px;
}

.original-ticket-toolbar {
  display: flex;
  justify-content: flex-start;
}

.original-ticket-toolbar a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  padding: 0.35rem 0.75rem;
  font-weight: 800;
  text-decoration: none;
}

.original-ticket-toolbar a:hover,
.original-ticket-toolbar a:focus-visible {
  background: #eff6ff;
  outline: none;
}

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

.meta-box,
.admin-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  padding: 0.55rem;
  min-width: 0;
}

.meta-box strong,
.admin-card strong {
  display: block;
  color: #475569;
  font-size: 0.74rem;
  text-transform: uppercase;
}

.prompt-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  padding: 0.75rem;
  max-height: 42vh;
  overflow: auto;
}

.markdown-preview {
  overflow-wrap: anywhere;
  color: #1e293b;
  font-size: 0.92rem;
  line-height: 1.4;
}

.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
  color: #0f172a;
  line-height: 1.25;
  margin: 0.85rem 0 0.3rem;
  scroll-margin-top: 0.75rem;
}

.markdown-preview h2 {
  font-size: 1.25rem;
}

.markdown-preview h3 {
  font-size: 1.1rem;
}

.markdown-preview p,
.markdown-preview ul,
.markdown-preview ol,
.markdown-preview blockquote {
  margin: 0.35rem 0;
}

.markdown-preview ul,
.markdown-preview ol {
  padding-left: 1.25rem;
}

.markdown-preview li {
  margin: 0.12rem 0;
}

.markdown-preview ul + ul,
.markdown-preview ol + ol {
  margin-top: -0.18rem;
}

.markdown-preview blockquote {
  border-left: 3px solid #bfdbfe;
  color: #475569;
  padding-left: 0.75rem;
}

.markdown-preview code {
  border-radius: 4px;
  background: #e2e8f0;
  padding: 0.08rem 0.25rem;
}

.markdown-preview pre {
  overflow: auto;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem;
}

.markdown-preview img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.35rem auto;
}

.markdown-preview figure {
  margin: 0.45rem 0 0.75rem;
}

.markdown-preview figure img {
  margin-bottom: 0.25rem;
}

.markdown-preview figcaption {
  color: #64748b;
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: center;
}

.markdown-preview figcaption p {
  margin: 0;
}

.markdown-preview a,
.markdown-preview a:visited {
  color: #0000ee;
}

.markdown-preview .table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.markdown-preview th,
.markdown-preview td {
  border: 1px solid #dbe3ef;
  padding: 0.45rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.markdown-preview th {
  background: #eef2ff;
  color: #334155;
}

.external-link-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1rem;
  margin-left: 0.2rem;
  border: 1px solid #ef476f;
  border-radius: 3px;
  background: #fff;
  color: #111827;
  padding: 0 0.18rem;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  vertical-align: baseline;
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  min-height: 22px;
  max-width: 100%;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  background: #e0f2fe;
  color: #1d4ed8;
  font-size: 0.76rem;
  font-weight: 800;
}

.tag.changed,
.finding-error {
  background: #fee2e2;
  color: var(--danger);
}

.tag.clean,
.finding-info {
  background: #dcfce7;
  color: var(--ok);
}

.finding-warning {
  background: #fef3c7;
  color: var(--warning);
}

.change-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.75fr) minmax(420px, 1fr);
  gap: 0.9rem;
  flex: 1;
  min-height: 0;
}

.form-panel {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
}

.item-list,
.finding-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.curation-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(420px, 0.8fr);
  gap: 0.9rem;
  align-items: start;
}

.curation-panel {
  padding: 1rem;
}

.curation-panel h3 {
  margin: 0 0 0.8rem;
  color: var(--ink);
}

.pipeline-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pipeline-card {
  border: 1px solid #dbe4f2;
  border-radius: 8px;
  background: #fff;
  padding: 0.9rem;
}

.pipeline-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.pipeline-head h4 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink);
}

.pipeline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 0;
  text-align: left;
}

.pipeline-toggle span:first-child {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  line-height: 1;
}

.pipeline-toggle:hover span:first-child,
.pipeline-toggle:focus-visible span:first-child {
  border-color: var(--blue-strong);
  color: var(--blue-strong);
}

.pipeline-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.pipeline-state {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e8f5ee;
  color: #147246;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
}

.pipeline-blocked .pipeline-state {
  background: #fde8e8;
  color: #b91c1c;
}

.pipeline-not_run .pipeline-state {
  background: #fde8e8;
  color: #b91c1c;
}

.pipeline-failed .pipeline-state {
  background: #fef3c7;
  color: #92400e;
}

.pipeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.pipeline-meta span {
  border: 1px solid #dbe4f2;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  padding: 0.25rem 0.45rem;
  font-size: 0.82rem;
}

.pipeline-steps {
  display: grid;
  gap: 0.45rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}

.pipeline-step {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) 110px minmax(220px, 1fr);
  gap: 0.65rem;
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem;
}

.pipeline-step span strong {
  display: block;
  color: var(--ink);
}

.pipeline-step span small {
  display: block;
  margin-top: 0.2rem;
  line-height: 1.35;
}

.pipeline-step > strong {
  color: #147246;
}

.pipeline-step small {
  color: var(--muted);
}

.step-blocked > strong {
  color: #b91c1c;
}

.step-not_run > strong {
  color: #b91c1c;
}

.step-failed > strong {
  color: #92400e;
}

.pipeline-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.item-list {
  padding: 1rem;
}

.finding-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 0.7rem;
}

.finding-item strong {
  display: block;
}

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

@media (max-width: 980px) {
  .filter-bar,
  .workspace,
  .change-layout,
  .curation-layout {
    grid-template-columns: 1fr;
  }

  .screen-header {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    align-items: stretch;
  }

  .title-block,
  .header-controls,
  .filter-bar {
    grid-column: auto;
    grid-row: auto;
  }

  .filter-bar {
    margin-left: 0;
  }

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

  .workspace {
    grid-template-rows: none;
    gap: 0.9rem;
  }

  .document-table-panel,
  .document-workspace-header,
  .toc-panel,
  .detail-panel,
  .workspace.list-collapsed .document-workspace-header,
  .workspace.list-collapsed .toc-panel,
  .workspace.list-collapsed .detail-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .document-workspace-header,
  .toc-panel,
  .detail-panel {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
  }

  .document-table-panel {
    min-height: 420px;
  }
}
