html, body { height: 100%; margin: 0; }
.nav-link.active { font-weight: 600; }

/* =============================================================
   App shell — top bar + sidebar + main
   ============================================================= */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar main";
    height: 100vh;
    transition: grid-template-columns 0.2s ease;
}

.app-shell.sidebar-collapsed {
    grid-template-columns: 56px 1fr;
}

/* --- Top bar -------------------------------------------------- */
.app-topbar {
    grid-area: topbar;
    background: #1f3a5f;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
    position: relative;
}

.topbar-toggle {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 22px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    border-radius: 4px;
}

.topbar-toggle:hover { background: rgba(255,255,255,0.12); }

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: 0.04em;
    min-width: 120px;
    color: #fff;
}

.topbar-search {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
}

.topbar-search .global-search { width: 100%; }

.topbar-right {
    position: relative;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #D6296F;
    color: #fff;
    border: 0;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.user-avatar:hover { background: #b8225f; }

.user-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 260px;
    background: #fff;
    color: #222;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    padding: 12px;
    z-index: 100;
}

.user-menu-header { padding: 4px 0; }
.user-menu-name  { font-weight: 600; }
.user-menu-email { font-size: 12px; color: #666; }
.user-menu hr    { margin: 8px 0; border-color: #e5e5e5; }

.user-menu-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
}
.user-menu-item:hover { background: #f3f3f3; }

/* --- Sidebar -------------------------------------------------- */
.app-sidebar {
    grid-area: sidebar;
    background: #fafafa;
    border-right: 1px solid #e5e5e5;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-nav {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 8px 0;
}

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

.nav-bottom {
    margin-top: auto;                 /* pins Admin to the bottom */
    border-top: 1px solid #e5e5e5;
    padding-top: 4px;
}

.nav-section {
    margin: 16px 0 4px 0;
    border-top: 1px solid #e5e5e5;
}

.nav-section-heading {
    padding: 10px 16px 6px 16px;
    font-size: 14px;
    font-weight: 700;
    color: #222;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    color: #222;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}

.nav-item:hover { background: #f0f0f0; }

.app-nav .nav-item.active,
.app-nav .nav-item.active:hover {
    background: rgba(214, 41, 111, 0.15);
    color: #222;
    font-weight: 600;
}

.nav-item i { font-size: 16px; width: 18px; text-align: center; }

/* Expandable group toggle (Recent) */
button.nav-item {
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}

.nav-chevron {
    margin-left: auto;
    transition: transform 0.15s ease;
    font-size: 12px;
}

.nav-toggle.open .nav-chevron { transform: rotate(180deg); }

.nav-sub {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-sub .nav-empty {
    padding: 6px 16px 6px 46px;
    font-size: 13px;
    color: #999;
    font-style: italic;
}

.nav-sub .nav-item { padding-left: 62px; font-size: 13px; }
.nav-sub .nav-empty { padding-left: 62px; font-size: 13px; color: #999; font-style: italic; }

/* Expandable section heading inside Recent (Companies, Contacts, Load All).
   Indented to align with the word "Recent" (icon width + gap + outer padding). */
.nav-sub .nav-subheading-toggle {
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 46px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    text-decoration: none;
}
.nav-sub .nav-subheading-toggle:hover { background: #f0f0f0; color: #222; }
.nav-sub .nav-subheading-toggle.open .nav-chevron { transform: rotate(180deg); }
.nav-sub .nav-subheading-toggle .nav-chevron { margin-left: auto; font-size: 10px; }

/* Load All — same heading style, no chevron, no separator. */
.nav-sub .nav-loadall { /* inherits .nav-subheading-toggle */ }

/* Collapsed sidebar: hide labels + section headings */
.app-shell.sidebar-collapsed .nav-item span,
.app-shell.sidebar-collapsed .nav-section-heading {
    display: none;
}

.app-shell.sidebar-collapsed .nav-item { justify-content: center; padding: 8px 0; }

/* --- Main content -------------------------------------------- */
.app-main {
    grid-area: main;
    overflow: auto;
    padding: 24px;
    background: #fff;
}

/* --- Page title -------------------------------------------- */
.app-main > h1,
.page-title {
    margin: 0 0 16px 0;
    font-size: 28px;
    font-weight: 600;
    color: #222;
}

/* Suppress focus outline on programmatically-focused page titles (Blazor FocusOnNavigate) */
.app-main > h1:focus,
.page-title:focus {
    outline: none;
}

/* Subtitle — smaller heading shown under a page-title (e.g. "Welcome X" on Home). */
.page-subtitle {
    margin: -8px 0 12px 0;
    font-size: 18px;
    font-weight: 500;
    color: #444;
}

/* --- DxTabs visual override (used app-wide) ----------------- */
/* Plain black text, no borders/background. Selected tab gets bold + blue underline. */
.dxbl-tabs,
.dxbl-tabs [class*="dxbl-tabs-nav"] {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* Thin grey line along the bottom of the tab nav (separator from content) */
.dxbl-tabs > [class*="dxbl-tabs-nav"] {
    border-bottom: 1px solid #f4f4f4 !important;
}

.dxbl-tabs [class*="dxbl-tabs-item"] {
    background: transparent !important;
    border: 0 !important;
    border-bottom: 2px solid transparent !important;
    color: #222 !important;
    font-weight: 400 !important;
    padding: 10px 18px !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.dxbl-tabs [class*="dxbl-tabs-item"]:hover {
    color: #000 !important;
    background: transparent !important;
}

.dxbl-tabs [class*="dxbl-tabs-item"].dxbl-active,
.dxbl-tabs [class*="dxbl-tabs-item-active"],
.dxbl-tabs [class*="dxbl-tabs-item"][aria-selected="true"] {
    color: #000 !important;
    font-weight: 600 !important;
    border-bottom: 2px solid #1f3a5f !important;
    background: transparent !important;
    box-shadow: inset 0 -2px 0 #1f3a5f !important;
}

.dxbl-tabs [class*="dxbl-tabs-item"].dxbl-active::after,
.dxbl-tabs [class*="dxbl-tabs-item-active"]::after,
.dxbl-tabs [class*="dxbl-tabs-item"][aria-selected="true"]::after {
    background-color: #1f3a5f !important;
    border-color: #1f3a5f !important;
}

/* The sliding indicator line under the active tab (some DevExpress versions) */
.dxbl-tabs [class*="indicator"] {
    background: #1f3a5f !important;
    background-color: #1f3a5f !important;
    color: #1f3a5f !important;
    border-color: #1f3a5f !important;
}

/* Override the theme's accent variables within tabs */
.dxbl-tabs {
    --dxbl-color-primary: #1f3a5f;
    --dxbl-tabs-active-color: #1f3a5f;
    --dxbl-tabs-active-border-color: #1f3a5f;
    --dxbl-tabs-active-text-color: #000;
    --dxbl-tabs-indicator-color: #1f3a5f;
    --bs-primary: #1f3a5f;
    --bs-link-color: #1f3a5f;
}


/* --- Dashboards page ---------------------------------------- */
/* Make the page fill the remaining height of .app-main so iframes can stretch */
.app-main:has(.dashboards-page) {
    display: flex;
    flex-direction: column;
}

.dashboards-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;             /* allow flex children to shrink within parent */
}

/* Standard breathing room between tab strip and content — applies to all DxTabs. */
.dxbl-tabs-content,
.dxbl-tabs-content-holder,
.dxbl-tab-page-content {
    padding-top: 10px;
}

/* DevExpress DxTabs internals — force tab content to fill (Dashboards only) */
.dashboards-page .dxbl-tabs,
.dashboards-page .dashboards-tabs,
.dashboards-page .dashboards-tabs-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.dashboards-page .dxbl-tabs-content,
.dashboards-page .dxbl-tabs-content-holder,
.dashboards-page .dxbl-tab-page-content {
    flex: 1;
    display: flex;
    min-height: 0;
    background: #ffffff;
}

/* Clip Klipfolio's top header by shifting the iframe up. Tweak --klip-header-height
   to match Klipfolio's actual header pixel size if it changes. */
.dashboard-frame-wrap {
    --klip-header-height: 60px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.dashboard-iframe {
    width: 100%;
    border: 0;
    background: #fafafa;
    margin-top: calc(var(--klip-header-height) * -1);
    height: calc(100% + var(--klip-header-height));
    flex: none;
}

.dashboard-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-style: italic;
}



/* --- List view (D365-style Companies / future entities) ----- */
.list-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-commandbar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 8px;
}

.cmd-btn {
    background: transparent;
    border: 0;
    padding: 6px 12px;
    font-size: 14px;
    color: #222;
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cmd-btn:hover:not(:disabled) { background: #f0f0f0; }
.cmd-btn:disabled { color: #999; cursor: default; }

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.view-selector {
    font-size: 18px;
    font-weight: 600;
    color: #222;
    border: 0;
    background: transparent;
    padding: 4px 8px;
    cursor: pointer;
}
.view-selector:focus { outline: 1px solid #1f3a5f; border-radius: 4px; }

.list-search {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #c8c8c8;
    border-radius: 6px;
    padding: 4px 10px;
    width: 280px;
}
.list-search i { color: #888; margin-right: 6px; }
.list-search input {
    border: 0;
    outline: none;
    flex: 1;
    font-size: 14px;
    background: transparent;
}

.list-grid { margin-top: 4px; }

/* Status icons inside grids (Primary / Live etc.) */
.icon-primary  { color: #f5b301; font-size: 16px; }   /* gold star */
.icon-live     { color: #2ea043; font-size: 16px; }   /* green tick */
.icon-inactive { color: #999;    font-size: 16px; }   /* grey dash */

/* Prevent grid data cells from wrapping; overflow shows ellipsis instead.
   Lender (no fixed width) will absorb remaining space and only ellipsise
   when the table is too narrow for full content. */
.list-grid [class*="dxbl-grid-table"] td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* D365-style: remove vertical column borders from all DxGrids in the app.
   Keep horizontal row separators (those come from <tr>/border-bottom on td). */
.dxbl-grid .dxbl-grid-table > thead > tr > th,
.dxbl-grid .dxbl-grid-table > tbody > tr > td,
.dxbl-grid .dxbl-grid-table > tfoot > tr > td {
    border-left: 0 !important;
    border-right: 0 !important;
}

.grid-link {
    color: #0066cc;
    text-decoration: none;
    font-weight: 500;
}
.grid-link:hover { text-decoration: underline; }

/* --- Company detail info panels (read-only) ----------------- */
.info-panels {
    max-width: 900px;              /* enough for the 2-col Company Info layout */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-panel {
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
}

.info-panel-header {
    background: #f0f0f0;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #222;
    border-bottom: 1px solid #e5e5e5;
}

/* Default: 2-col grid (label / value). */
.info-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 10px 16px;
    padding: 16px;
    margin: 0;
    background: #fff;
}

/* Optional 4-col variant: (label / value / label / value) for denser panels. */
.info-grid-2col {
    grid-template-columns: 200px 1fr 200px 1fr;
}

/* Recent page lists */
.recent-list { padding: 16px; background: #fff; }
.recent-list ul { list-style: none; margin: 0; padding: 0; }
.recent-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}
.recent-list li:last-child { border-bottom: 0; }
.recent-when { color: #888; font-size: 12px; }

/* Two side-by-side label/value lists inside a single panel. */
.info-twocol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
    background: #fff;
}
.info-twocol > .info-grid {
    padding: 16px;
}

.info-grid dt {
    color: #555;
    font-weight: 400;
    font-size: 14px;
    align-self: center;
}

.info-grid dd {
    margin: 0;
    color: #222;
    font-size: 14px;
    font-weight: 600;
    align-self: center;
}

/* Gap between the two panels */
.company-form [class*="layout-group"] + [class*="layout-group"],
.company-form [class*="flg"] + [class*="flg"] {
    margin-top: 16px;
}


/* --- Detail view -------------------------------------------- */
.detail-view { display: flex; flex-direction: column; gap: 12px; }

.detail-breadcrumb {
    font-size: 13px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}
.detail-breadcrumb a { color: #0066cc; text-decoration: none; }
.detail-breadcrumb a:hover { text-decoration: underline; }
.detail-breadcrumb .sep { color: #999; }

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ececec;
    font-family: "Segoe UI", "Microsoft Sans Serif", Tahoma, sans-serif;
}

.login-card {
    position: relative;
    width: 420px;
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.10);
    padding: 32px;
    box-sizing: border-box;
    overflow: hidden;
    display: grid;
    row-gap: 10px;
}

/* Sits above the card's normal content; negative margins extend it edge-to-edge */
.login-titlebar {
    background: #1f3a5f;
    color: #fff;
    padding: 12px 20px;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.06em;
    margin: -32px -32px 8px -32px;
}

/* Let the form's children participate in the parent grid */
.login-form {
    display: contents;
}

.login-logo {
    grid-column: 1;
    grid-row: 1 / span 2;
    aspect-ratio: 1 / 1;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-row {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.login-row label {
    width: 100px;
    color: #222;
}

.login-row input {
    flex: 1;
    height: 32px;
    padding: 4px 10px;
    border: 1px solid #b0b0b0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    box-sizing: border-box;
}

.login-row input:focus {
    outline: none;
    border-color: #0078d4;
    box-shadow: 0 0 0 2px rgba(0,120,212,0.15);
}

.login-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.login-message {
    margin-left: auto;
    margin-right: 16px;
    white-space: nowrap;
    font-family: Tahoma, sans-serif;
    font-size: 16px;
    font-style: italic;
    color: #c0392b;
}

.login-button {
    min-width: 110px;
    height: 36px;
    padding: 0 18px;
    font-size: 14px;
    font-family: inherit;
    background: linear-gradient(to bottom, #f6f6f6, #e1e1e1);
    border: 1px solid #909090;
    border-radius: 6px;
    cursor: pointer;
}

.login-button:hover {
    background: linear-gradient(to bottom, #ffffff, #e8e8e8);
    border-color: #0078d4;
}

.login-button:active {
    background: linear-gradient(to bottom, #d8d8d8, #c8c8c8);
}

.login-version {
    position: absolute;
    bottom: 8px;
    left: 10px;
    font-family: Tahoma, sans-serif;
    font-size: 13px;
    font-style: italic;
    color: #666;
}
