:root {
    --blue: #1F4E79;
    --blue2: #2E6CA4;
    --ink: #1f2430;
    --muted: #6B7280;
    --place: #9aa0a6;
    --line: #e2e6ea;
    --ctrl: #f4f6f8;
    --ctrlbd: #c8ced4;
    --auto: #e7eaee;
    --req: #c0392b;
    --bg: #f6f8fa;
    --card: #ffffff;
    --group: #e8f0f9;
    --sidebar: #12324e;
    --registry-nav-width: 210px;
    --registry-bg: var(--bg);
    --registry-surface: var(--card);
    --registry-ink: var(--ink);
    --registry-muted: var(--muted);
    --registry-accent: var(--blue);
    --registry-border: var(--line);
    --registry-font: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

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

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--registry-font);
    color: var(--ink);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.4;
}

a.entity-link {
    color: var(--blue2);
    text-decoration: underline;
}

a.entity-link:hover {
    color: var(--blue);
}

/* —— Shell —— */
.registry-shell {
    display: grid;
    grid-template-columns: var(--registry-nav-width) 1fr;
    min-height: 100vh;
}

.registry-nav {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--sidebar);
    color: #dce6f1;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
}

.registry-brand a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.2px;
    display: block;
    margin: 2px 6px;
}

.registry-brand-sub {
    font-size: 11px;
    color: #9db6d0;
    margin: 0 6px 14px;
}

.registry-nav-foot {
    font-size: 10.5px;
    color: #7f9bb8;
    margin: auto 6px 0;
    padding-top: 16px;
    line-height: 1.5;
}

.registry-nav-foot b {
    color: #b9cee3;
}

.sitemap-area {
    margin-bottom: 0.35rem;
}

.sitemap-area-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 14px 0 4px;
    padding: 8px 8px 6px;
    border: none;
    border-top: 1px solid #24405e;
    background: transparent;
    color: #7f9bb8;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
    border-radius: 7px;
}

.sitemap-area:first-child .sitemap-area-toggle {
    margin-top: 0;
    padding-top: 8px;
    border-top: none;
}

.sitemap-area-toggle:hover {
    background: #1b4467;
    color: #cfe0f2;
}

.sitemap-area-toggle:focus-visible {
    outline: 2px solid var(--blue2);
    outline-offset: 1px;
}

.sitemap-area-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    color: #9db6d0;
}

.sitemap-area-toggle.expanded .sitemap-area-symbol {
    color: #cfe0f2;
}

.sitemap-area-title-text {
    flex: 1;
}

.sitemap-area-principals .sitemap-area-toggle {
    color: #a8c4de;
}

.sitemap-nodes {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sitemap-nodes-submenu {
    padding-left: 8px;
    margin-bottom: 4px;
}

.sitemap-nodes-submenu .sitemap-link {
    padding-left: 18px;
}

.sitemap-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 7px;
    font-size: 13px;
    color: #cfe0f2;
    text-decoration: none;
}

.sitemap-link:hover {
    background: #1b4467;
    color: #fff;
}

.sitemap-link.active {
    background: var(--blue2);
    color: #fff;
    font-weight: 600;
}


.registry-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.registry-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(246, 248, 250, 0.96);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
    padding: 12px 26px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.registry-env-build {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    flex-shrink: 0;
    min-width: 0;
}

.registry-environment {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--blue);
    white-space: nowrap;
}

.registry-build {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    white-space: nowrap;
    user-select: all;
}

.registry-header-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.registry-auth {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 12.5px;
    color: #33404f;
}

.registry-user {
    color: var(--muted);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.registry-auth-link {
    color: var(--blue2);
    text-decoration: underline;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.registry-auth-link:hover {
    color: var(--blue);
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: #33404f;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    accent-color: var(--blue);
    width: 15px;
    height: 15px;
}

.registry-content {
    padding: 18px 26px 80px;
    max-width: 1080px;
    width: 100%;
}

/* Entity lists / detail tab strips use the full main column. */
.registry-content:has(.entity-list-page),
.registry-content:has(.entity-detail-page) {
    max-width: none;
}

/* —— Breadcrumbs —— */
.crumbbar {
    font-size: 12px;
    color: #6b7686;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.crumbbar .bcitem {
    padding: 3px 4px;
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
}

.crumbbar a.bcitem:hover {
    background: var(--ctrl);
    color: var(--blue);
}

.crumbbar .bcitem:last-child {
    color: var(--blue);
    font-weight: 700;
}

.crumbbar .sep {
    margin: 0 2px;
    color: #b7c0ca;
}

/* —— Cards —— */
.card-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(16, 40, 64, 0.04);
    margin-bottom: 1.25rem;
}

.card-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #1f4e79, #1b4467);
    color: #fff;
    border-radius: 8px 8px 0 0;
}

.card-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.card-head .meta {
    font-size: 11.5px;
    color: #c7d8ea;
    margin-top: 3px;
}

.card-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.newregbtn {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    border-radius: 7px;
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.newregbtn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}

.newregbtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.card-body {
    padding: 8px 18px 18px;
}

.intro {
    color: #42505f;
    font-size: 13px;
    margin: 0 0 14px;
    max-width: 840px;
}

.intro a {
    color: var(--blue);
    font-weight: 600;
}

/* —— Home Principal tiles —— */
.principal-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

a.principal-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: var(--ctrl);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    min-height: 112px;
}

a.principal-tile:hover,
a.principal-tile:focus-visible {
    border-color: var(--blue2);
    background: #eef4fa;
    box-shadow: 0 1px 3px rgba(31, 78, 121, 0.12);
    outline: none;
}

.principal-tile-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.principal-tile-count {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--blue);
    letter-spacing: -0.02em;
}

.principal-tile-link {
    margin-top: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--blue2);
    text-decoration: underline;
}

a.principal-tile:hover .principal-tile-link,
a.principal-tile:focus-visible .principal-tile-link {
    color: var(--blue);
}

@media (max-width: 640px) {
    .principal-tile-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .principal-tile-count {
        font-size: 24px;
    }
}


.command-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.btn-wire {
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 7px;
    border: 1px solid var(--ctrlbd);
    background: #fff;
    color: #33404f;
    cursor: pointer;
}

.btn-wire:hover:not(:disabled) {
    background: #eef6fc;
    border-color: var(--blue2);
    color: var(--blue);
}

.btn-wire.primary {
    background: var(--blue2);
    border-color: var(--blue2);
    color: #fff;
}

.btn-wire.primary:hover:not(:disabled) {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.btn-wire:disabled {
    background: #c6cdd4;
    border-color: #c6cdd4;
    color: #8892a0;
    cursor: not-allowed;
}

/* —— List shell —— */
.listshell {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card);
}

.listsearchbar {
    padding: 8px 10px;
    background: #fbfcfd;
    border-bottom: 1px solid var(--line);
}

.listsearchbar .listsearch {
    width: 100%;
    max-width: 340px;
    padding: 6px 10px;
    border: 1px solid var(--ctrlbd);
    border-radius: 6px;
    font-size: 12.5px;
    background: #fff;
    color: var(--ink);
    font-family: inherit;
}

.listsearchbar .listsearch:focus {
    outline: 2px solid var(--blue2);
    outline-offset: -1px;
}

.listshell .lhead {
    display: flex;
    background: #eef2f6;
    border-bottom: 1px solid var(--line);
}

.listshell .lhead div {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 11.5px;
    font-weight: 700;
    color: #4a5563;
    border-right: 1px solid var(--line);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listshell .lhead div:last-child {
    border-right: none;
}

.listshell .lhead div.sortcol {
    cursor: pointer;
    user-select: none;
}

.listshell .lhead div.sortcol:hover {
    background: #e2e9f0;
    color: var(--blue);
}

.listshell .lhead div.sortcol.sorted {
    color: var(--blue2);
}

.listshell .lrow {
    display: flex;
    border-top: 1px solid var(--line);
    background: #fff;
}

.listshell .lrow:first-of-type {
    border-top: none;
}

.listshell .lrow div {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    font-size: 12.5px;
    color: #2b3440;
    border-right: 1px solid #f1f3f5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listshell .lrow div:last-child {
    border-right: none;
}

.listshell .lrow.clickable {
    cursor: pointer;
}

.listshell .lrow.clickable:hover {
    background: #eef6fc;
}

.listshell .lrow.empty div {
    color: var(--place);
    font-style: italic;
}

.listshell .lbody {
    max-height: min(60vh, 640px);
    overflow: auto;
}

/* —— Detail / grow form —— */
.tabbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0;
}

.tabbar button {
    font-size: 13px;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-bottom: none;
    background: #eef2f6;
    color: #3a4653;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-family: inherit;
}

.tabbar button.active {
    background: var(--card);
    color: var(--blue);
    font-weight: 700;
    border-color: var(--line);
}

.tabpanel {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 0 0 8px 8px;
    margin-top: 0;
    padding: 8px 0 4px;
}

.grow {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 0;
    align-items: start;
    border-bottom: 1px solid #eef1f4;
    padding: 11px 0;
}

.grow:last-child {
    border-bottom: 0;
}

.grow .lab {
    font-size: 13px;
    padding-top: 7px;
    color: #2b3440;
}

.grow .fieldwrap {
    min-width: 0;
}

.ctl {
    width: 100%;
    max-width: 440px;
    padding: 8px 10px;
    border: 1px solid var(--ctrlbd);
    border-radius: 8px;
    background: var(--ctrl);
    font-size: 13px;
    color: var(--ink);
    font-family: inherit;
    display: block;
}

.ctl[disabled],
.ctl.disabled {
    background: var(--auto);
    color: #7b8085;
    font-style: italic;
    cursor: not-allowed;
}

.field-meta {
    font-size: 11px;
    color: var(--muted);
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.field-meta .fk {
    color: #5b78a6;
}

.field-meta .desc {
    color: #9aa0a6;
    font-style: italic;
    flex-basis: 100%;
}

.lookupwrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.lookupwrap .ctl {
    max-width: 340px;
}

.pdfbtn {
    background: #fff;
    border: 1px solid var(--blue2);
    color: var(--blue2);
    border-radius: 6px;
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.pdfbtn:hover {
    background: #eef6fc;
}

.lab .star {
    color: var(--req);
    font-weight: 700;
    margin-left: 3px;
}

.status-message {
    color: var(--muted);
    font-size: 13px;
    margin: 0.5rem 0;
}

.filter-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.workbook-picker {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 18rem;
}

.workbook-picker span {
    font-size: 0.75rem;
    color: var(--muted);
}

.workbook-picker select,
.filter-input {
    font: inherit;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--ctrlbd);
    border-radius: 6px;
    background: var(--card);
    color: var(--ink);
    min-height: 2rem;
}

/* Legacy table chrome (admin results) */
.entity-grid-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
}

.entity-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.entity-grid th,
.entity-grid td {
    text-align: left;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.entity-grid th {
    background: #eef2f6;
    font-weight: 600;
    color: #4a5563;
    font-size: 11.5px;
}

.entity-grid tbody tr:hover {
    background: #eef6fc;
}

.lead {
    max-width: 42rem;
    color: var(--muted);
    line-height: 1.5;
    font-size: 13px;
}

/* Fluent overrides — keep chrome wireframe-aligned */
fluent-button {
    --accent-fill-rest: var(--blue2);
    --accent-fill-hover: var(--blue);
    --accent-fill-active: var(--blue);
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--blue2);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    text-align: center;
    font-weight: bold;
    color: var(--blue);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 900px) {
    .registry-shell {
        grid-template-columns: 1fr;
    }

    .registry-nav {
        position: sticky;
        top: 0;
        z-index: 2;
        height: auto;
        max-height: 40vh;
    }

    .grow {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .grow .lab {
        padding-top: 0;
    }
}
