:root {
    --app-section-heading-size: 22px;
    --accent: #ed6c3b;
    --accent-dark: #d95b2f;
    --ink: #1f252b;
    --muted: #69737d;
    --surface: #ffffff;
    --page: #f4f6f8;
    --line: #dce2e7;
    --sidebar: #10171b;
}

html,
body {
    background: var(--page);
    color: var(--ink);
    font-family: "Segoe UI", Arial, sans-serif;
    margin: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

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

.login-shell {
    display: block;
}

.app-sidebar {
    background: linear-gradient(180deg, #141b20 0%, #081013 100%);
    border-right: 1px solid #253036;
    color: #fff;
    flex: 0 0 252px;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    min-width: 0;
}

.app-topbar {
    align-items: center;
    background: #1b1b1b;
    border-bottom: 1px solid #303030;
    color: #fff;
    display: flex;
    justify-content: space-between;
    min-height: 76px;
    padding: 0 24px;
}

.topbar-title {
    display: block;
    font-size: 20px;
    font-weight: 700;
}

.topbar-user {
    color: #b8c0c8;
    font-size: 14px;
}

.app-content {
    padding: 28px 32px 40px;
}

.brand {
    align-items: center;
    border-bottom: 1px solid #263137;
    display: flex;
    gap: 12px;
    padding: 22px 18px;
}

.brand-mark {
    align-items: center;
    background: var(--accent);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    font-weight: 800;
    height: 44px;
    justify-content: center;
    letter-spacing: .02em;
    width: 44px;
}

.brand-title {
    font-size: 18px;
    font-weight: 800;
}

.brand-subtitle {
    color: #aeb9c2;
    font-size: 12px;
}

.side-nav {
    display: grid;
    gap: 6px;
    padding: 18px 12px;
}

.side-link {
    border-radius: 8px;
    color: #d8dee3;
    display: block;
    font-size: 15px;
    padding: 12px 14px;
}

.side-link:hover,
.side-link.active {
    background: #263137;
    color: #fff;
}

.page-title {
    margin-bottom: 22px;
}

.page-title h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 0;
}

.page-title p {
    color: var(--muted);
    margin: 4px 0 0;
}

.metric-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 22px;
}

.metric-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 2px 9px rgba(20, 30, 40, .07);
}

.metric-card {
    padding: 20px;
}

.metric-card span {
    color: var(--muted);
    display: block;
    font-size: 14px;
}

.metric-card strong {
    display: block;
    font-size: 34px;
    line-height: 1.1;
}

.metric-card.warning strong {
    color: var(--accent);
}

.content-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: 1.45fr .9fr;
}

.content-grid.two-columns {
    grid-template-columns: minmax(0, 1.2fr) minmax(420px, .9fr);
}

.panel {
    padding: 22px;
}

.panel h2 {
    font-size: var(--app-section-heading-size,22px);
    margin: 0 0 16px;
}

.panel h3 {
    font-size: 18px;
}

.panel-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-header h2 {
    margin: 0;
}

.app-table {
    margin-bottom: 0;
}

.app-table th {
    border-bottom: 1px solid var(--bs-border-color);
    font-weight: 700;
}

.app-table td,
.app-table th {
    vertical-align: middle;
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    background: var(--app-selected-bg);
}

.status-pill {
    background: var(--bs-secondary-bg);
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
}

.stack-list {
    display: grid;
    gap: 10px;
}

.stack-row {
    border: 1px solid var(--line);
    border-radius: 6px;
    display: grid;
    gap: 2px;
    padding: 12px;
}

.stack-row span {
    color: var(--muted);
    font-size: 13px;
}

.form-grid {
    display: grid;
    gap: 14px 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid label {
    color: var(--muted);
    font-weight: 600;
}

.span-2 {
    grid-column: 1 / -1;
}

.check-line {
    align-items: center;
    color: var(--ink) !important;
    display: flex;
    gap: 10px;
    min-height: 38px;
}

.check-line input {
    height: 18px;
    width: 18px;
}

.action-row {
    flex-wrap: wrap;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 18px;
}

.form-panel {
    width: 100%;
    max-width: none;
    min-width: 0;
}

.order-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.request-file-summary {
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding: 10px 12px;
}

.request-file-summary span {
    color: var(--muted);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-outline-primary {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.token-box {
    font-family: Consolas, monospace;
    min-height: 92px;
}

.login-page {
    align-items: center;
    background: radial-gradient(circle at bottom, rgba(237, 108, 59, .22), transparent 35%), #12181d;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
    max-width: 430px;
    padding: 34px;
    width: 100%;
}

.login-brand {
    align-items: center;
    display: flex;
    gap: 16px;
    margin-bottom: 26px;
}

.login-brand h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 0;
}

.login-brand span {
    color: var(--muted);
}

.captcha-panel {
    display: flex;
    justify-content: center;
    min-height: 65px;
}

#blazor-error-ui {
    background: #b32121;
    bottom: 0;
    color: #fff;
    display: none;
    left: 0;
    padding: 1rem;
    position: fixed;
    right: 0;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: #fff;
    font-weight: 700;
    margin-left: 1rem;
}

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

.req-drop-overlay {
    align-items: center;
    background: rgba(10, 16, 28, .72);
    backdrop-filter: blur(2px);
    display: flex;
    inset: 0;
    justify-content: center;
    pointer-events: none;
    position: fixed;
    z-index: 1200;
}

.req-drop-card {
    align-items: center;
    background: #fff;
    border: 2px dashed var(--primary);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-width: min(420px, calc(100vw - 48px));
    padding: 2rem;
}

.req-drop-card i {
    color: var(--primary);
    font-size: 3rem;
    line-height: 1;
}

.req-drop-card strong {
    font-size: 1.5rem;
}

@media (max-width: 1100px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        min-height: auto;
    }

    .content-grid,
    .content-grid.two-columns,
    .metric-grid {
        grid-template-columns: 1fr;
    }
}

.app-shell {
    background-color: #f6f7f9;
    display: block;
    min-height: 100vh;
}

.login-shell {
    background: #12181d;
}

.login-shell .app-main {
    min-height: 100vh;
}

.app-header {
    background-color: #1a1a1a;
    border-bottom: 1px solid #0f0f0f;
    color: #fff;
}

.app-header-inner {
    align-items: center;
    display: flex;
    gap: 1rem;
    height: 80px;
    padding: 0 1.5rem;
}

.app-logo {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
}

.app-logo img {
    display: block;
    height: 54px;
    margin: 13px 0;
    object-fit: contain;
    width: auto;
}

.app-header-title {
    border-left: 1px solid rgba(255, 255, 255, .14);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding-left: 1rem;
}

.app-header-title span {
    color: #fff;
    font-weight: 700;
    line-height: 1.1;
}

.app-header-title small {
    color: rgba(255, 255, 255, .62);
    line-height: 1.1;
}

.app-header-actions {
    align-items: center;
    display: flex;
    gap: .5rem;
    margin-left: auto;
}

.btn-mobile-menu i::before {
    transform: scale(1.35);
}

.btn-mobile-menu i:last-child {
    display: none;
}

.btn-mobile-menu.openned i:first-child {
    display: none;
}

.btn-mobile-menu.openned i:last-child {
    display: inline;
}

.app-body {
    display: flex;
    min-height: calc(100vh - 80px);
}

.app-sidebar {
    background-color: #1a1a1a;
    border-right: 1px solid #0f0f0f;
    color: #fff;
    display: flex;
    flex: 0 0 250px;
    min-height: calc(100vh - 80px);
    padding: .5rem;
    width: 250px;
}

.default-gradient-vertical {
    background-image: linear-gradient(180deg, #1a1a1a 0%, #252b30 100%);
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: 100%;
}

.app-nav-group {
    background: rgba(0, 0, 0, .5);
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: .25rem .5rem .5rem;
}

.app-nav-group:hover {
    border-color: #3a3a3a;
    box-shadow: 0 0 10px rgba(255, 255, 255, .18);
}

.app-nav-summary {
    cursor: pointer;
    font-weight: 500;
    list-style: none;
    padding: .5rem;
}

.app-nav-summary i {
    margin-right: 6px;
    opacity: .45;
}

.app-nav-summary:hover i {
    color: var(--accent);
    opacity: 1;
}

.app-nav-summary::-webkit-details-marker {
    display: none;
}

.app-nav-group[open] .app-nav-summary::after {
    content: "v";
    float: right;
}

.app-nav-group:not([open]) .app-nav-summary::after {
    content: ">";
    float: right;
}

.app-nav-group-links {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    padding: .25rem .25rem .5rem;
}

.app-nav-link {
    border-radius: 6px;
    color: #fff;
    font-weight: 400;
    opacity: .68;
    padding: .5rem .75rem;
    text-decoration: none;
    transition: all ease-in-out .15s;
}

.app-nav-link i {
    margin-right: 4px;
    opacity: .7;
}

.app-nav-link:hover i {
    color: var(--accent);
    opacity: 1;
}

.app-nav-link.active,
.app-nav-link:hover {
    background-color: #2a2a2a;
    color: #fff;
    opacity: 1;
}

.app-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
}

@media (max-width: 991.98px) {
    .app-header-inner {
        padding: 0 1rem;
    }

    .app-logo img {
        height: 48px;
    }

    .app-header-title {
        display: none;
    }

    .app-body {
        display: block;
        min-height: calc(100vh - 80px);
    }

    .app-sidebar {
        display: none;
        left: 0;
        min-height: calc(100vh - 80px);
        position: absolute;
        top: 80px;
        width: 100%;
        z-index: 999;
    }

    .app-sidebar.openned {
        display: flex;
    }

    .app-content {
        padding: 1rem;
    }
}

@media (min-width: 992px) {
    .btn-mobile-menu {
        display: none;
    }

    .app-sidebar {
        display: flex !important;
    }
}

.table-actions {
    display: inline-flex;
    gap: .35rem;
    justify-content: flex-end;
}

.btn-icon {
    align-items: center;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    padding: 0;
    width: 34px;
}

.permission-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.permission-group h3 {
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 .75rem;
}

.permission-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
}

.app-modal {
    display: block;
}

.app-modal .modal-dialog {
    margin-top: 12vh;
}

.app-modal .modal-content {
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.app-modal .modal-header,
.app-modal .modal-footer {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.modal-w-70 {
    max-width: 70vw;
}

.modal-w-80 {
    max-width: 80vw;
}

.modal-w-95 {
    max-width: 95vw;
}

.modal-h-70 .modal-content {
    min-height: 70vh;
}

.modal-h-80 .modal-content {
    min-height: 80vh;
}

.modal-h-95 .modal-content {
    min-height: 95vh;
}

.app-loader {
    align-items: center;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(2px);
    display: flex;
    inset: 0;
    justify-content: center;
    position: fixed;
    z-index: 2147483000;
}

.app-loader-card {
    align-items: center;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-width: 148px;
    padding: 1.35rem 1.6rem;
}

.app-loader-spinner {
    animation: app-loader-spin .75s linear infinite;
    border: 4px solid var(--line);
    border-radius: 50%;
    border-top-color: var(--accent);
    height: 42px;
    width: 42px;
}

.app-loader-text {
    color: var(--ink);
    font-size: .95rem;
    font-weight: 600;
}

.toastx-container {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    position: fixed;
    right: 50%;
    top: 1.25rem;
    transform: translateX(50%);
    z-index: 2147483001;
}

.toastx {
    align-items: center;
    animation: toast-in .25s ease-out;
    border-radius: 8px;
    display: flex;
    gap: .75rem;
    justify-content: space-between;
    max-width: min(420px, calc(100vw - 2rem));
    min-width: min(260px, calc(100vw - 2rem));
    padding: .75rem;
}

.toastx-body {
    overflow-wrap: anywhere;
    font-size: .9rem;
    line-height: 1.3;
}

.toastx-close {
    color: inherit;
    flex: 0 0 auto;
}

.fade-out {
    animation: toast-out .8s ease-in forwards;
}

@keyframes app-loader-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

/* Responsive registration forms beside the company hierarchy. */
.registration-layout {display:grid;grid-template-columns:minmax(0,1fr) minmax(260px,340px);gap:24px;align-items:start;width:100%;max-width:none;}
.registration-layout.no-hierarchy {grid-template-columns:minmax(0,1fr);max-width:none;}
.registration-form {min-width:0;}
.type-options {display:flex;flex-wrap:wrap;gap:16px;}
.hierarchy-container {position:sticky;top:24px;max-height:80vh;overflow:auto;}
.party-tree,.party-tree ul {list-style:none;padding-left:16px;}
.party-tree {padding-left:0;}
.party-tree li {display:block;margin:2px 0;}
.tree-node {display:flex;align-items:flex-start;gap:2px;border-radius:5px;padding:3px 2px;font-size:12px;line-height:1.4;}
.tree-toggle,.tree-toggle-spacer {flex:0 0 18px;width:18px;height:20px;}
.tree-toggle {border:0;background:none;padding:0;font-size:12px;}
.tree-select {display:flex;align-items:flex-start;gap:6px;margin:0;min-width:0;cursor:pointer;font-size:inherit;font-weight:400;}
.tree-select input {flex:0 0 auto;width:13px;height:13px;margin:2px 0 0;}
.tree-select i {flex:0 0 auto;}
.tree-select span {overflow-wrap:anywhere;}
.tree-node.selected {background:#e8efff;}
.settings-field-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
@media(max-width:900px){.registration-layout{grid-template-columns:minmax(0,1fr);}.hierarchy-container{position:static;max-height:none;}}
@media(max-width:600px){.settings-field-grid{grid-template-columns:minmax(0,1fr);}}

/* Catalog editors follow the shared ServerApp form shell. */
.catalog-tabs{display:flex;flex-wrap:wrap;gap:.5rem;margin-bottom:1.5rem}.catalog-tabs .btn{font-size:.85rem}.catalog-entry{border:1px solid var(--bs-border-color,#ddd);border-radius:.4rem;padding:1rem;margin:1rem 0}fieldset{min-width:0}.catalog-entry legend{float:none;width:auto}.catalog-snapshot{white-space:pre-wrap;overflow-wrap:anywhere}

.company-google-map { width:100%; height:65vh; min-height:360px; border-radius:8px; }
.company-map-label { display:flex; flex-direction:column; gap:2px; background:#fff; color:#172033; border:1px solid #3b6ea8; border-radius:6px; padding:6px 10px; box-shadow:0 2px 6px #0003; font-size:13px; max-width:240px; }
.company-map-label small { color:#44536a; }

/* Field columns follow the available form card width, including nested editors. */
.form-panel,
.registration-form,
.panel:has(.form-grid),
.panel:has(.settings-field-grid) {
    container-type: inline-size;
}
.form-grid > *,
.settings-field-grid > * {
    min-width: 0;
}
@container (max-width: 640px) {
    .form-grid,
    .settings-field-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
@media (max-width: 767.98px) {
    .form-grid,
    .settings-field-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.user-avatar { display:inline-flex; width:36px; height:36px; border-radius:50%; align-items:center; justify-content:center; background:#edf2f7; color:#24364b; font-weight:600; overflow:hidden; vertical-align:middle; flex-shrink:0; }
.user-avatar-preview { width:80px; height:80px; font-size:1.5rem; }
.user-avatar img, .app-user-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.avatar-crop { display:block; max-width:100%; height:auto; margin:auto; touch-action:none; cursor:move; }

.avatar-crop-controls { display:flex; flex-direction:column; align-items:center; }
.avatar-crop-zoom { display:block; width:300px; max-width:100%; text-align:center; }

.app-modal .modal-dialog.avatar-crop-dialog{max-width:380px;width:calc(100% - 2rem)}
.app-modal .modal-dialog.login-settings-dialog{max-width:32rem;width:calc(100% - 2rem)}
