/* Data Requirements reader — dashboard panel / ink colours (Doc 51). */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #fcfdfe;
  --muted: #c9d3e1;
  --accent: #3b82f6;
  --highlight: #60a5fa;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --kind-bank: #0d9488;
  --kind-customer: #3b82f6;
  --kind-exposure: #f59e0b;
  --kind-product: #a855f7;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 var(--font);
}

body {
  display: flex;
  flex-direction: column;
}

html.drs-embed .drs-header,
html.drs-embed footer.drs-foot {
  display: none;
}

.drs-viewtabs {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  padding: 6px 12px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.drs-viewtab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
}
.drs-viewtab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.drs-viewtab.is-active {
  color: var(--text);
  border-color: var(--border);
  border-bottom-color: var(--bg);
  background: var(--bg);
}

.drs-structure {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
.drs-structure[hidden] { display: none !important; }
/* Mermaid parse banner is appended to body and would sit on the table list. */
body.drs-view-structure .error-icon,
body.drs-view-structure svg[aria-roledescription="error"] {
  display: none !important;
}
.drs-structure-tree {
  flex: 0 0 16rem;
  overflow: auto;
  padding: 0.75rem 0.85rem 2rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.drs-structure-tree h2 {
  border: 0;
  margin: 0.85rem 0 0.35rem;
  padding: 0;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.drs-structure-tree h2:first-child { margin-top: 0; }
.drs-structure-tree ul { list-style: none; margin: 0; padding: 0; }
.drs-structure-tree li { margin: 0; }
.drs-stem {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0.32rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
}
.drs-stem:hover { background: var(--surface-hover); }
.drs-stem.is-active { background: rgba(59, 130, 246, 0.18); }
.drs-structure-detail {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drs-structure-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.drs-structure-head h2 {
  border: 0;
  margin: 0;
  padding: 0;
}
.drs-structure-meta { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.85rem; }
.drs-structure-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}
.drs-download {
  flex-shrink: 0;
  color: var(--text);
  background: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  border: 1px solid transparent;
}
button.drs-download {
  cursor: pointer;
  font: inherit;
}
.drs-download:hover { color: #fff; }
.drs-download-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.drs-download-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.drs-structure-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem 1.25rem 2rem;
}
.structure-facts {
  display: grid;
  gap: 0.55rem 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin: 0 0 1rem;
}
.structure-facts div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
}
.structure-facts dt {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.2rem;
}
.structure-facts dd { margin: 0; }
.structure-role { margin: 0 0 0.85rem; }
.structure-h { font-size: 0.92rem; margin: 0.4rem 0 0.35rem; }
.structure-constraints { margin: 0 0 0.85rem; padding-left: 1.2rem; color: var(--muted); }
.structure-legend { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.85rem; }
.structure-fk { font-size: 11px; color: var(--muted); margin-top: 0.15rem; }

a { color: var(--highlight); }
a:hover { color: #93c5fd; }

.drs-header {
  flex-shrink: 0;
  padding: 1.75rem 1.5rem 1.25rem;
  background: linear-gradient(165deg, #122033 0%, #1a2332 55%, #163044 100%);
  border-bottom: 1px solid var(--border);
}
.drs-header h1 {
  margin: 0 0 0.35rem;
  font: 600 1.55rem/1.2 var(--font);
}
.drs-header p {
  margin: 0.25rem 0;
  color: var(--muted);
  max-width: 52rem;
}

.drs-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(12rem, 16rem) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}
.drs-wrap[hidden] {
  display: none !important;
}

.drs-toc {
  overflow: auto;
  min-height: 0;
  padding: 1rem 0.85rem 2rem 1rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.drs-toc h2 {
  margin: 0 0 0.6rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.drs-toc ol {
  margin: 0;
  padding: 0 0 0 1.1rem;
  font-size: 0.82rem;
}
.drs-toc li { margin: 0.28rem 0; }
.drs-toc a { color: var(--muted); text-decoration: none; }
.drs-toc a:hover { color: var(--text); }

main.drs-main {
  overflow: auto;
  min-height: 0;
  padding: 1.25rem 1.5rem 3rem;
  max-width: none;
}
/* Text stays on the reading measure. The ER stage uses the full column so a
   larger sheet is not fitted back down to 980px. */
main.drs-main > :not(.er-stage) {
  max-width: 980px;
}

h2 {
  font: 600 1.2rem/1.3 var(--font);
  margin: 2rem 0 0.6rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
}
h2:first-child { border-top: 0; margin-top: 0; }
h3 { font-size: 1.02rem; margin: 1.35rem 0 0.45rem; color: var(--highlight); }
h4 { font-size: 0.92rem; margin: 1rem 0 0.4rem; color: var(--muted); }

p { margin: 0.45rem 0 0.7rem; }
ul, ol { margin: 0.3rem 0 0.8rem; padding-left: 1.3rem; }
li { margin: 0.2rem 0; }

code, .mono {
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(255,255,255,0.05);
  padding: 0.05em 0.3em;
  border-radius: 3px;
}

pre.tree {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.85rem 1rem;
  overflow: auto;
  font: 12px/1.45 var(--mono);
  color: var(--muted);
}

.er-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  margin: 0.35rem 0 0.65rem;
}
.er-toolbar .er-tool {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.er-sheet {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.1rem;
}
.er-sheet button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 0.85rem/1 var(--font);
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border-radius: 3px;
  cursor: pointer;
}
.er-sheet button:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}
.er-sheet button:disabled {
  opacity: 0.35;
  cursor: default;
}
.er-sheet-label {
  min-width: 8.6rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}
.er-glyph {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.er-glyph:hover { background: var(--surface-hover); color: var(--text); }
.er-glyph[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }
.er-glyph svg { display: block; }
.er-glyph .er-glyph-restore { display: none; }
.er-glyph[aria-pressed="true"] .er-glyph-expand { display: none; }
.er-glyph[aria-pressed="true"] .er-glyph-restore { display: block; }
.er-stage:fullscreen,
.er-stage:-webkit-full-screen {
  background: var(--bg);
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.er-stage:fullscreen .er-toolbar,
.er-stage:-webkit-full-screen .er-toolbar,
.er-stage:fullscreen .er-view-status,
.er-stage:-webkit-full-screen .er-view-status,
.er-stage:fullscreen .er-hide,
.er-stage:-webkit-full-screen .er-hide {
  flex-shrink: 0;
}
.er-stage:fullscreen .er-wrap,
.er-stage:-webkit-full-screen .er-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}
.er-stage:fullscreen .er-diagram,
.er-stage:-webkit-full-screen .er-diagram {
  flex: 1;
  min-height: 0;
  height: auto;
  max-height: none;
}
.er-stage:fullscreen .er-drawio-host,
.er-stage:-webkit-full-screen .er-drawio-host {
  min-height: 0;
}
.er-view-status {
  min-height: 1.1em;
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.er-hide {
  margin: 0 0 0.65rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.84rem;
}
.er-hide summary {
  cursor: pointer;
  font-weight: 600;
}
.er-hide-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.85rem;
  margin-top: 0.45rem;
}
.er-hide-item {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}
.er-wrap {
  margin: 0 0 1.2rem;
}
.er-diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.75rem;
  overflow: auto;
  min-height: 44rem;
  height: min(75vh, 56rem);
  color: var(--muted);
}
.er-diagram[data-status="error"] {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
}
.er-diagram svg {
  max-width: none;
  height: auto;
  display: block;
}
.er-drawio-host {
  min-height: 42rem;
  background: #f8fafc;
  border-radius: 4px;
}
.er-diagram .geDiagramContainer,
.er-diagram .mxgraph {
  background: #f8fafc;
}
.er-diagram .geToolbarContainer {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

table.fields {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 0.5rem 0 1.1rem;
  font-size: 0.86rem;
}
table.fields th, table.fields td {
  text-align: left;
  vertical-align: top;
  padding: 0.42rem 0.55rem;
  border-bottom: 1px solid var(--border);
}
table.fields th {
  background: #243044;
  font-weight: 600;
  position: sticky;
  top: 0;
}
table.fields td code { white-space: nowrap; }

.ob {
  display: inline-block;
  min-width: 1.15rem;
  text-align: center;
  font: 700 0.72rem/1.2 var(--font);
  padding: 0.12rem 0.35rem;
  border-radius: 3px;
}
.ob-m { background: rgba(239, 68, 68, 0.22); color: #fecaca; }
.ob-o { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }
.ob-c { background: rgba(245, 158, 11, 0.22); color: #fde68a; }

.note {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  padding: 0.65rem 0.9rem;
  margin: 0.7rem 0 1rem;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
  margin: 0.8rem 0 1.2rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.75rem 0.85rem;
}
.card .n { font: 600 1.05rem/1.2 var(--font); color: var(--highlight); }
.card .l { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }

.tpl-list { columns: 2; gap: 1.5rem; }
@media (max-width: 720px) {
  .drs-wrap { grid-template-columns: 1fr; overflow: auto; }
  .drs-toc { border-right: 0; border-bottom: 1px solid var(--border); max-height: none; }
  .tpl-list { columns: 1; }
}

footer.drs-foot {
  flex-shrink: 0;
  padding: 1rem 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #111; --muted: #333; --border: #ccc; --highlight: #123; }
  html, body { height: auto; overflow: visible; }
  body { display: block; }
  .drs-toc { display: none; }
  .drs-viewtabs { display: none; }
  .drs-structure { display: none !important; }
  .drs-wrap { display: block; overflow: visible; }
  .drs-wrap[hidden] { display: block !important; }
  .drs-header { background: #fff !important; color: #000; border: 0; }
  .drs-header p { color: #333 !important; }
  main.drs-main { overflow: visible; }
  table.fields { break-inside: avoid; }
}
