/* DMS visual design. Tokens first; every component uses them. */
:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #1c2230;
  --text-2: #3d4657;
  --muted: #6b7382;
  --line: #e6e8ef;
  --line-strong: #d6d9e3;
  --accent: #3f4fd8;
  --accent-2: #7b86ee;
  --accent-3: #98b7ff;
  --accent-soft: #eef0fd;
  --accent-text: #ffffff;
  --gradient: linear-gradient(90deg, #4148d6 0%, #7b86ee 100%);
  /* Bloom around the active nav tab. Biased upward: the bar sits on the topbar's bottom edge,
     and an even spread would smudge the light page below it. */
  --glow: 0 0 4px rgba(179, 187, 255, 0.95), 0 -3px 12px rgba(161, 171, 255, 0.7), 0 -6px 22px rgba(80, 97, 255, 0.5);
  --topbar: #1f2233;
  --topbar-text: #ffffff;
  --topbar-muted: #8f95a8;
  --error: #c1352b;
  --ok: #1d7a4f;
  --ok-soft: #e4f4ea;
  --warn: #b25b0f;
  --warn-soft: #fff1e1;
  --danger-soft: #fdeae7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 6px rgba(28, 34, 48, .04), 0 12px 32px rgba(28, 34, 48, .06);
  /* Open Sans is self-hosted under vendor/opensans; the rest catches the moment
     before it loads and any browser that refuses woff2. */
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* beats any display rule below */
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2, h3 { font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .92rem; }
.error { color: var(--error); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: stretch; gap: 1.5rem; padding: 0 2rem; height: 64px; background: var(--topbar); color: var(--topbar-text); }
.topbar .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.55rem; letter-spacing: -.03em; color: var(--topbar-text); margin-right: .5rem; }
.brand .mark { width: 1.5em; height: 1.5em; flex: none; display: block; }
.brand-lg { display: flex; align-items: center; gap: .7rem; font-weight: 700; font-size: 2rem; letter-spacing: -.03em; color: var(--text); }
.topbar .brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: .25rem; }
.topbar nav a { display: flex; align-items: center; padding: 0 .9rem; color: var(--topbar-text); font-weight: 500; font-size: 1.02rem; position: relative; }
.topbar nav a:hover { text-decoration: none; color: #fff; }
.topbar nav a.active::after { content: ""; position: absolute; left: .9rem; right: .9rem; bottom: 0; height: 5px; border-radius: 3px; background: var(--accent-3); box-shadow: var(--glow); }
.topbar nav a[aria-disabled="true"] { color: var(--topbar-muted); cursor: default; }
.topbar .spacer { flex: 1; }
.topbar #me { display: flex; align-items: center; color: #cfd3e0; }
.topbar form { display: flex; align-items: center; }
.topbar button.link { color: #8fa2ff; font-weight: 600; font-size: 1rem; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { text-decoration: underline; }

/* ---------- layout & cards ---------- */
/* minmax(0, 1fr): grid items default to min-width:auto, which would let a wide
   table stretch its card past max-width and scroll the whole page sideways. */
main { max-width: 1280px; margin: 2rem auto; padding: 0 1.25rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
main > * { min-width: 0; }
.card { background: var(--card); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem 2rem 2rem; }
.card h2 { margin: 0 0 1rem; font-size: 1.45rem; }
.card h3 { margin: 1.25rem 0 .5rem; font-size: 1.05rem; }
.card-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }
.crumbs { margin: 0; color: var(--muted); }

/* ---------- buttons ---------- */
button, .btn { background: var(--gradient); color: var(--accent-text); border: 0; border-radius: var(--radius-sm); padding: .7rem 1.4rem; font: inherit; font-weight: 600; font-size: 1rem; cursor: pointer; transition: filter .15s, transform .05s; }
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; }
button.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line-strong); }
button.secondary:hover { background: #f7f8fb; filter: none; }
button.small-btn { padding: .4rem .8rem; font-size: .88rem; margin-top: .45rem; }
button.link.danger { color: var(--error); font-weight: 500; }

/* ---------- inputs ---------- */
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .7rem .9rem; min-width: 0; }
input::placeholder, textarea::placeholder { color: #9aa1b1; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 0; border-color: var(--accent-2); }
select { appearance: none; -webkit-appearance: none; padding-right: 2.2rem; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%233d4657' stroke-width='1.8' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right .9rem center; }
input[type="date"] { color: var(--text-2); }

/* ---------- upload ---------- */
.dropzone { border: 2px dashed #c9cff2; border-radius: 14px; padding: 2.4rem 1rem 2rem; text-align: center; background: #fbfbfe; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus { outline: 2px solid var(--accent-2); }
.dropzone .icon { font-size: 2.6rem; margin: 0 auto .7rem; display: block; width: fit-content; color: var(--accent); }
.dropzone p { margin: .3rem 0; }
.dropzone p:first-of-type { font-size: 1.2rem; }
.dropzone p strong { font-weight: 650; }
.link-label { color: var(--accent); cursor: pointer; font-weight: 600; }
.link-label:hover { text-decoration: underline; }
.inline { display: inline-flex; gap: .75rem; align-items: center; margin-top: 1rem; color: var(--text-2); }
.inline select { padding: .6rem 2.2rem .6rem 1rem; }
.upload-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .4rem; }
.upload-item { display: grid; grid-template-columns: minmax(0, 1fr) 180px minmax(0, 1.2fr); gap: .75rem; align-items: center; font-size: .92rem; }
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item.ok span:last-child { color: var(--ok); }
.upload-item.error { color: var(--error); grid-template-columns: 1fr; }
.upload-item.error span:last-child { color: var(--error); }
progress { width: 100%; height: 8px; accent-color: var(--accent); border-radius: 4px; overflow: hidden; }

/* ---------- filters ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin: 1rem 0 1.25rem; align-items: center; }
.input-icon { position: relative; display: block; }
.input-icon > i { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: .9rem; }
.input-icon > input { width: 100%; padding-left: 2.5rem; }
.filters .grow { grid-column: span 2; }
.filters button { width: 100%; }
@media (max-width: 640px) { .filters { grid-template-columns: 1fr 1fr; } .filters .grow { grid-column: span 2; } }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
.table td { padding: .9rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table td.wrap { white-space: normal; }
.table tbody tr:hover td { background: #fafbfe; }
.table tr:last-child td { border-bottom: 0; }
.table td a { font-weight: 600; }
.table .num, .table th.num { text-align: right; }
/* max-width:0 lets these columns absorb the leftover width and ellipsize,
   instead of forcing the table wider than its card. */
.table .ellipsis { max-width: 0; min-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Name and Counterparty share whatever the fixed-content columns leave, in
   this ratio; Name gets the larger share because file names are long. */
#doc-table th:nth-child(1), #doc-table td:nth-child(1) { width: 38%; }
#doc-table th:nth-child(6), #doc-table td:nth-child(6) { width: 20%; }
/* Workflows: fixed layout; the small columns are sized in pixels (Chrome resolves
   percentage <col> widths inconsistently) so Name takes the remainder — 60% at
   the card's full width, more on wider screens. */
#wf-table { table-layout: fixed; min-width: 900px; }
#wf-table th, #wf-table td { padding-left: .4rem; padding-right: .4rem; }
#wf-table .actions > * { margin-left: .45rem; }
#wf-table td { overflow: hidden; text-overflow: ellipsis; }
#wf-table td.ellipsis { min-width: 0; }
#wf-table th:nth-child(1), #wf-table td:nth-child(1) { width: 100%; min-width: 640px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { margin-left: .85rem; font-weight: 500; }
.table.edit input, .table.edit select { width: 100%; min-width: 80px; padding: .45rem .6rem; border-radius: 8px; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: flex-end; margin-top: 1rem; }
.pager button { padding: .5rem 1rem; font-size: .9rem; }

/* ---------- badges & stats ---------- */
.badge { display: inline-block; padding: .2rem .75rem; border-radius: 999px; font-size: .84rem; font-weight: 500; background: #eef0f3; color: var(--muted); }
.badge.status-new { background: var(--accent-soft); color: var(--accent); }
.badge.status-processing, .badge.status-review { background: var(--warn-soft); color: var(--warn); }
.badge.status-done { background: var(--ok-soft); color: var(--ok); }
.badge.status-failed { background: var(--danger-soft); color: var(--error); }
.stats { display: flex; gap: 2.5rem; margin: .5rem 0 1rem; }
.stats div { display: grid; }
.stats dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.stats dd { margin: 0; font-size: 1.7rem; font-weight: 650; }
.row, #debug-tools { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem; width: min(400px, 92vw); display: grid; gap: .9rem; }
.login-card h1 { margin: 0; font-size: 2rem; letter-spacing: -.02em; }
.login-card .brand-lg { margin-bottom: .1rem; }
.login-card p { margin: 0; }
.login-card form { display: grid; gap: .9rem; margin-top: .5rem; }
.login-card label { display: grid; gap: .35rem; font-size: .92rem; color: var(--text-2); }
.login-card button { margin-top: .25rem; }

/* ---------- detail ---------- */
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .9rem 1.5rem; margin: 1.25rem 0; }
.meta div { display: grid; gap: .15rem; }
.meta dt { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.meta dd { margin: 0; font-size: 1.02rem; }
.prewrap { white-space: pre-wrap; color: var(--text-2); }
.exform { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem 1.2rem; margin: 1rem 0 1.25rem; }
.exform .field { display: grid; gap: .3rem; }
.exform .field > span { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.exform .field.wide, .exform fieldset.nested { grid-column: 1 / -1; }
.exform input, .exform select, .exform textarea { width: 100%; }
.exform fieldset.nested { border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem 1.2rem; margin: 0; }
.exform legend { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 0 .4rem; }
.history { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .45rem; font-size: .95rem; }

/* ---------- search ---------- */

/* ---------- ask ---------- */
.ask-layout { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.ask-layout > * { min-width: 0; }
@media (max-width: 860px) { .ask-layout { grid-template-columns: 1fr; } }
.conv-list { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .6rem; }
.conv-list li { display: grid; font-size: .95rem; }
.conv-list li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.conv-list li.active a { font-weight: 650; }
.chat { display: grid; gap: 1rem; margin: 1.25rem 0; max-height: 60vh; overflow-y: auto; padding-right: .25rem; }
.msg { display: grid; gap: .35rem; max-width: 85%; }
.msg.user { justify-self: end; }
.msg .bubble { padding: .8rem 1rem; border-radius: 14px; background: #f1f2f7; line-height: 1.5; }
.msg.user .bubble { background: var(--gradient); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.assistant .bubble { border-bottom-left-radius: 4px; }
.msg.error .bubble { background: var(--danger-soft); color: var(--error); }
.msg .cite { font-size: .8rem; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; padding: .05rem .4rem; margin-left: .2rem; font-weight: 600; }
.trace { font-size: .82rem; color: var(--muted); }
.trace summary { cursor: pointer; }
.trace-item { margin: .25rem 0 0 .5rem; }
.trace-item code { font-size: .78rem; word-break: break-all; }
.ask-form { display: flex; gap: .75rem; align-items: flex-end; }
.ask-form textarea { flex: 1; resize: vertical; border-radius: 14px; padding: .9rem 1rem; }
.table-wrap { overflow-x: auto; min-width: 0; max-width: 100%; }

/* ---------- icons (Font Awesome, vendored) ---------- */
button > i, a > i, .link-label > i, .topbar nav a > i, .status > i, .card-head a > i, .small > i { margin-right: .5rem; }
button > i.trail { margin-right: 0; margin-left: .5rem; }
.topbar nav a > i { font-size: .95rem; opacity: .9; }
.table .actions i { margin-right: .35rem; font-size: .9rem; }
.trace-item i { margin-right: .3rem; }

/* ---------- search results inside the list ---------- */
.table tr.snippet-row td { padding-top: 0; border-bottom: 1px solid var(--line); white-space: normal; }
.table tr.snippet-row + tr td { border-top: 0; }
.table tr:has(+ tr.snippet-row) td { border-bottom: 0; }
.table .snippet { margin: 0 0 .25rem; font-size: .92rem; color: var(--text-2); }
.table .snippet i { margin-right: .35rem; }

/* ---------- document types (settings) ---------- */
.type-form { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.type-form h3 { margin: 0 0 .75rem; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem 1.2rem; margin-bottom: .5rem; }
.type-grid .field { display: grid; gap: .3rem; }
.type-grid .field > span { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.type-grid .field > span .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.type-grid .field.wide { grid-column: 1 / -1; }
.type-grid input, .type-grid textarea { width: 100%; }
.type-grid textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; line-height: 1.4; }
input[readonly] { background: #f5f6fa; color: var(--muted); }
.table code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; background: #f1f2f7; padding: .1rem .4rem; border-radius: 5px; }

/* ---------- list: search bar, sortable headers, filter popovers, chips ---------- */
.searchbar { display: flex; gap: .8rem; margin: 1rem 0 .75rem; align-items: center; flex-wrap: wrap; }
.searchbar .grow { flex: 1; min-width: 260px; }
.chips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .4rem .25rem .7rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .85rem; font-weight: 500; }
.chip button { background: none; border: 0; color: inherit; padding: 0 .2rem; font-size: .8rem; line-height: 1; cursor: pointer; }
.chip button i { margin: 0; }
.table th { white-space: nowrap; }
.th-sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.th-sort i { margin: 0; font-size: .72rem; line-height: 1; vertical-align: middle; }
.th-sort:hover, .th-sort.active { color: var(--text); }
.th-sort.active i { color: var(--accent); }
.th-filter { background: none; border: 0; padding: .1rem .3rem; margin-left: .35rem; color: #b8bdcb; cursor: pointer; font-size: .78rem; border-radius: 4px; }
.th-filter i { margin: 0; }
.th-filter:hover { color: var(--text); background: var(--accent-soft); }
.th-filter.active { color: var(--accent); }
.popover { z-index: 50; min-width: 240px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: .9rem 1rem; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .95rem; color: var(--text); text-align: left; white-space: normal; }
.popover-title { font-weight: 600; margin-bottom: .6rem; }
.popover-body { display: grid; gap: .5rem; }
.popover-body label { display: grid; grid-template-columns: 3.2rem 1fr; align-items: center; gap: .4rem; color: var(--muted); font-size: .9rem; }
.popover-body input, .popover-body select { width: 100%; padding: .5rem .7rem; font-size: .95rem; }
.popover-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.popover-actions .small-btn { margin-top: 0; }

/* ---------- type colour picker ---------- */
.color-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.color-row > input { flex: 1 1 240px; width: auto; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .25rem; }
.form-actions button { width: auto; }
input[type="color"] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card); cursor: pointer; }
.swatches { display: flex; gap: .3rem; }
.swatch { width: 22px; height: 22px; padding: 0; border-radius: 6px; border: 1px solid rgba(0,0,0,.12); box-shadow: none; cursor: pointer; }
.swatch:hover { transform: scale(1.12); }

/* ---------- workflows ---------- */
.badge.status-rejected { background: var(--danger-soft); color: var(--error); }
.badge.status-archived { background: #eef0f3; color: var(--muted); }
textarea.code, .code-view { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; line-height: 1.45; }
textarea.code { width: 100%; }
.code-view { background: #f7f8fb; border: 1px solid var(--line); border-radius: 10px; padding: 1rem; overflow-x: auto; margin: 0; white-space: pre; }
.problems:empty { display: none; }
.problems { display: grid; gap: .3rem; margin: .75rem 0; }
.problem { color: var(--error); font-size: .92rem; }
.problem code { background: var(--danger-soft); padding: .05rem .4rem; border-radius: 4px; margin-right: .3rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1rem 0 1rem; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--muted); padding: .6rem 1rem; font-weight: 600; }
.tab:hover { color: var(--text); filter: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { min-height: 4rem; }
.nl { font-size: 1rem; line-height: 1.55; margin: 0; }
.nl-line { margin: .5rem 0 .4rem; }
.nl-line:first-child { margin-top: 0; }
.nl-list { margin: .35rem 0; padding-left: 1.2rem; display: grid; gap: .35rem; }
.nl-list li::marker { color: var(--muted); }
/* Flowchart canvas: dotted grid, centred diagram, soft shadowed nodes.
   Node fills/strokes come from the classDefs in the Mermaid source. */
/* Centred with auto margins, not flex: a centred flex child that overflows
   becomes unreachable on the left when the box scrolls. */
.chart { overflow-x: auto; padding: 1.5rem 1rem;
  border: 1px solid var(--line); border-radius: 14px;
  background-color: #fbfbfe;
  background-image: radial-gradient(circle, #d6dae7 1px, transparent 1.3px);
  background-size: 18px 18px; background-position: center center; }
.chart svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.chart .node rect, .chart .node polygon, .chart .node circle, .chart .node ellipse, .chart .node path {
  rx: 10px; ry: 10px; stroke-width: 1.5px; stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(28, 34, 48, .10)) drop-shadow(0 4px 10px rgba(28, 34, 48, .07)); }
.chart .node .nodeLabel { line-height: 1.35; }
/* Mermaid sizes edge-label boxes from the measured text, so only the colour
   is ours — changing the size or padding here clips the label. */
.chart .edgeLabel, .chart .edgeLabel p, .chart .edgeLabel span { color: var(--text-2); white-space: nowrap; }
.chart .edgeLabels foreignObject, .chart .edgeLabel { overflow: visible; }
.chart .flowchart-link, .chart .edgePath path { stroke-width: 1.5px; }
.chart .marker { stroke-width: 1px; }
.approve-card { width: min(560px, 94vw); }
.approve-card textarea { width: 100%; font: inherit; padding: .6rem .8rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.approve-card label { display: grid; gap: .35rem; }
button.danger-btn { color: var(--error); border-color: #f1c4bf; }

/* ---------- designer ---------- */
.design-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1.5rem; align-items: start; }
@media (max-width: 1000px) { .design-layout { grid-template-columns: 1fr; } }
.design-layout > * { min-width: 0; }
.design-messages { max-height: 55vh; }
.msg .bubble.edit { background: var(--accent-soft); color: var(--accent); font-style: italic; }
.change { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: .6rem .9rem; font-size: .92rem; margin: .5rem 0; }
.dryrun { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1rem; }
.dryrun h3 { margin: 0 0 .6rem; }
.dryrun select { min-width: 280px; }
.dry-result { margin-top: .75rem; font-size: .92rem; }
.dry-result .ok { color: var(--ok); margin: .25rem 0; }
.dry-result .error { margin: .25rem 0; }
.dry-steps { margin: .25rem 0; padding-left: 1.4rem; display: grid; gap: .3rem; }
.dry-steps code { background: #f1f2f7; padding: .05rem .4rem; border-radius: 4px; font-size: .85rem; }

/* ---------- users ---------- */
.badge.role-admin { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge.role-user { background: #eef0f3; color: var(--muted); }

/* ---------- icon-only actions ---------- */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border-radius: 7px; color: var(--accent); }
.icon-btn i { margin: 0; font-size: .95rem; }
.icon-btn:hover { background: var(--accent-soft); text-decoration: none; }
button.link.danger.icon-btn { color: var(--error); }
button.link.danger.icon-btn:hover { background: var(--danger-soft); }
#doc-table .actions > * { margin-left: .2rem; }

/* ---------- approvals ---------- */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin-left: .45rem;
  padding: 0 .35rem; border-radius: 999px; background: #ef6461; color: #fff; font-size: .72rem; font-weight: 700; }
.approvals { display: grid; gap: .9rem; margin-top: .5rem; }
.approval { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; display: grid; gap: .5rem; }
.approval:hover { border-color: var(--line-strong); }
.approval-head { display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
.approval-head strong { font-size: 1.05rem; }
.approval .ap-comment { width: 100%; font: inherit; padding: .5rem .7rem; border: 1px solid var(--line-strong); border-radius: 8px; resize: vertical; }
#ap-history { table-layout: fixed; min-width: 860px; }
#ap-history td.ellipsis { max-width: 0; }

/* ---------- workflow overview: the two readable views side by side ---------- */
.wf-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .25rem 0 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.wf-actions .link.danger { margin-left: auto; }
.wf-views { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.75rem; margin-top: .5rem; align-items: start; }
/* Workflow details as one running line: "Steps: 3, Version: 2, …". */
.meta-inline { display: flex; flex-wrap: wrap; gap: .2rem .55rem; margin: 0 0 1.1rem; padding-bottom: .85rem; font-size: .85rem; border-bottom: 1px solid var(--line); }
.meta-inline > div { display: flex; gap: .35rem; }
/* The comma hangs off the value, not the flex row, so it does not pick up the gap. */
.meta-inline > div:not(:last-child) dd::after { content: ","; color: var(--muted); }
.meta-inline dt { color: var(--muted); font-weight: 500; }
.meta-inline dd { margin: 0; color: var(--text); }
.wf-views > * { min-width: 0; }
@media (max-width: 960px) { .wf-views { grid-template-columns: 1fr; } }

/* ---------- audit log viewer (settings) ---------- */
#audit-table tbody tr.clickable { cursor: pointer; }
#audit-table tbody tr.clickable:hover { background: #f7f8fb; }
#audit-table tbody tr.clickable:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
#audit-table tbody tr.selected, #audit-table tbody tr.selected:hover { background: var(--accent-soft); }
#audit-table code { font-size: .85rem; }
.audit-detail { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.audit-detail .card-head { margin-bottom: .75rem; }
/* A recorded prompt runs to thousands of characters, so the panel scrolls
   rather than pushing the pager off the screen. */
.audit-detail .code-view { max-height: 26rem; overflow: auto; white-space: pre-wrap; word-break: break-word; }
