/* Palette: ink (brand), paper, surface, text, muted + error red. */
:root {
    --ink: #1e3a5f;
    --ink-tint: #e6ecf3;
    --paper: #f4f6f9;
    --surface: #ffffff;
    --text: #14181f;
    --muted: #5b6573;
    --error: #b3261e;
    --error-tint: #fbeceb;
    --line: #dde2e9;
    --radius: 8px;
    --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--paper); }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.01em; }
h1:focus { outline: none; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--ink); }
code, pre, .mono { font-family: var(--font-mono); font-size: 0.86em; }

/* Shell */

.shell { display: flex; flex-direction: column; min-height: 100vh; }

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    background: var(--ink);
    color: var(--surface);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    border: 2px solid currentColor;
    font-family: var(--font-mono); font-size: 0.8rem; font-weight: 500;
}
.brand-text { display: flex; flex-direction: column; font-weight: 600; line-height: 1.2; }
.brand-text small { font-weight: 400; font-size: 0.78rem; opacity: 0.7; }

.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav-group { display: none; }
.nav-link {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 10px; border-radius: 6px;
    color: inherit; text-decoration: none; white-space: nowrap;
    opacity: 0.8;
}
.nav-link code { font-size: 0.72rem; opacity: 0.7; }
.nav-link:hover { opacity: 1; background: rgb(255 255 255 / 0.08); }
.nav-link.active { opacity: 1; background: rgb(255 255 255 / 0.14); }

.content {
    display: flex; flex-direction: column; gap: 24px;
    flex: 1; min-width: 0;
    padding: 24px 16px 48px;
}

@media (min-width: 900px) {
    .shell { flex-direction: row; }
    .sidebar {
        position: sticky; top: 0; height: 100vh;
        width: 264px; flex-shrink: 0; padding: 24px 16px; gap: 28px;
    }
    .nav { flex-direction: column; overflow: visible; }
    .nav-group {
        display: block; margin: 16px 10px 4px;
        font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
        opacity: 0.55;
    }
    .content { padding: 40px 48px 64px; max-width: 1180px; }
}

/* Page header */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-header-text { display: flex; flex-direction: column; gap: 6px; max-width: 70ch; }
.page-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.eyebrow { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink); letter-spacing: 0.04em; }
.lede { color: var(--muted); }

/* Panels and grids */

.panel {
    display: flex; flex-direction: column; gap: 16px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.panel-note { color: var(--muted); font-size: 0.9rem; }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .span-2 { grid-column: span 2; }
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Forms */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 0.86rem; font-weight: 500; }
.field .hint { font-size: 0.8rem; color: var(--muted); }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], input:not([type]),
select, textarea {
    width: 100%;
    padding: 9px 11px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}
textarea { font-family: var(--font-mono); font-size: 0.85rem; min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
    outline: 2px solid var(--ink); outline-offset: 2px;
}
input[type="file"] { font-size: 0.86rem; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 0.92rem; }
.check input { margin-top: 4px; accent-color: var(--ink); }
.check small { display: block; color: var(--muted); }

.modified.invalid, .invalid { border-color: var(--error); }
.validation-message { font-size: 0.8rem; color: var(--error); }
.validation-errors { margin: 0; padding: 12px 12px 12px 28px; color: var(--error); background: var(--error-tint); border-radius: 6px; font-size: 0.88rem; }

/* Buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px;
    font: inherit; font-weight: 500; font-size: 0.92rem;
    color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: 6px;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { color: var(--surface); background: var(--ink); border-color: var(--ink); }
.btn-primary:hover { background: #172e4c; }
.btn-danger { color: var(--error); }
.btn-danger:hover { border-color: var(--error); }
.btn-small { padding: 4px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Alerts */

.alert { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 6px; font-size: 0.92rem; border: 1px solid; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-title { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.alert-error { color: var(--error); background: var(--error-tint); border-color: color-mix(in srgb, var(--error) 30%, transparent); }
.alert-success, .alert-info { color: var(--ink); background: var(--ink-tint); border-color: color-mix(in srgb, var(--ink) 25%, transparent); }
.alert-info { background: var(--surface); }

/* Badges */

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px; border-radius: 999px;
    font-size: 0.78rem; font-weight: 500; white-space: nowrap;
    border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral { color: var(--muted); border-color: var(--line); }
.badge-progress { color: var(--ink); background: var(--ink-tint); }
.badge-done { color: var(--surface); background: var(--ink); }
.badge-error { color: var(--error); background: var(--error-tint); }

/* Tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.76rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; background: var(--paper); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--ink-tint) 45%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* Definition list */

.facts { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.facts > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { font-size: 0.78rem; color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
@media (min-width: 760px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; } }

/* Code block */

.codeblock { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.codeblock-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--paper); font-size: 0.8rem; color: var(--muted); }
.codeblock pre { margin: 0; padding: 10px 12px; max-height: 160px; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 0.78rem; background: var(--surface); }

/* Signing items */

.doc-item { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.doc-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.doc-index { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }

/* Signature seal — the one decorative signature element, shown when a request is signed. */
.seal {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 20px;
    border: 2px solid var(--ink); border-radius: var(--radius);
    background: var(--ink-tint); color: var(--ink);
}
.seal-ring {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 52px; height: 52px; border-radius: 50%;
    border: 2px solid var(--ink); outline: 1px solid var(--ink); outline-offset: 3px;
    font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.06em;
}
.seal strong { display: block; font-size: 1rem; }
.seal span { font-size: 0.88rem; }

.sign-image { max-width: 220px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 8px; }

/* Flow map on the overview */

.flow { display: flex; flex-direction: column; gap: 8px; }
.flow-step {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 6px;
    color: var(--text); text-decoration: none;
    border: 1px solid var(--line); background: var(--surface);
}
.flow-step:hover { border-color: var(--ink); }
.flow-step code { color: var(--ink); min-width: 3.2em; }
.flow-step small { display: block; color: var(--muted); font-size: 0.8rem; }

.health { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot-ok { background: var(--ink); box-shadow: 0 0 0 3px var(--ink-tint); }
.dot-bad { background: var(--error); box-shadow: 0 0 0 3px var(--error-tint); }

.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* Blazor error bar */

#blazor-error-ui {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    padding: 12px 20px;
    color: var(--surface); background: var(--error);
}
#blazor-error-ui .reload { color: inherit; margin-left: 12px; }
#blazor-error-ui .dismiss { float: right; background: none; border: 0; color: inherit; font-size: 1.2rem; cursor: pointer; }
