/* =============================================================================
   Web.MVC.MainWL design system.
   Calm, neutral shell: white sidebar, light-gray canvas, white cards, one brand
   color. No gradients, glows or hover-lifts; hierarchy comes from type, spacing
   and 1px borders, the way a product (not a template) reads.
   Token-driven: _BrandingTokens overrides --brand-*, --accent and --sidebar-*
   per deployment. Load order: bootstrap (grid/utility base) -> THIS FILE ->
   branding tokens -> kendo theme -> kendo-overrides.
   ============================================================================= */

:root {
    /* Brand (overridden per deployment by _BrandingTokens) */
    --brand-500: #3170e8;
    --brand-600: #1f5ad6;
    --brand-700: #1848ad;
    --accent: #0e9384;
    /* Tints follow whatever brand the tokens set. */
    --brand-50: color-mix(in srgb, var(--brand-600) 7%, #fff);
    --brand-100: color-mix(in srgb, var(--brand-600) 14%, #fff);

    /* Sidebar (overridable) */
    --sidebar-bg: #ffffff;
    --sidebar-ink: #4b5563;
    --sidebar-active: #1f5ad6;
    --sidebar-w: 248px;
    --sidebar-w-collapsed: 64px;

    /* Neutrals */
    --ink: #111827;
    --ink-2: #374151;
    --muted: #6b7280;
    --subtle: #9ca3af;
    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --surface: #ffffff;
    --bg: #f5f6f8;
    --hover: #f3f4f6;

    /* Semantic */
    --danger: #d92d20;
    --success: #079455;
    --warning: #dc6803;
    --info: #0b75c9;

    /* Module hues (kept for views that reference them; now quiet) */
    --hue-cc: var(--brand-600);
    --hue-int: #6941c6;
    --hue-sales: #b54708;
    --hue-bill: #067647;
    --hue-admin: #b42318;

    /* Shape / elevation / type / motion */
    --radius: 10px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--brand-500) 22%, transparent);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --topbar-h: 56px;
    --ease: cubic-bezier(.2, .7, .3, 1);
}

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink); letter-spacing: -.01em; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; text-underline-offset: 2px; }

::selection { background: var(--brand-100); }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* ---------------------------------------------------------------- app shell */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    transition: grid-template-columns .2s var(--ease);
}

.app-shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.app-main { display: flex; flex-direction: column; min-width: 0; }

/* ------------------------------------------------------------------ sidebar */
.app-sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    scrollbar-width: thin;
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--line);
    flex: none;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--ink);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -.01em;
}

.sidebar-brand-link:hover { color: var(--ink); text-decoration: none; }
.sidebar-brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logo { max-height: 30px; max-width: 168px; object-fit: contain; }

/* Monogram used when no logo is configured (sidebar + sign-in page). */
.sidebar-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--brand-600);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}

.sidebar-nav { padding: 10px 10px 16px; flex: 1; }

.nav-section {
    padding: 16px 10px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--subtle);
}

.sidebar-nav .nav-link,
.nav-group-toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    margin: 1px 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--sidebar-ink);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.sidebar-nav .nav-link:hover,
.nav-group-toggle:hover { background: var(--hover); color: var(--ink); text-decoration: none; }

.sidebar-nav .nav-link.active {
    background: var(--brand-50);
    color: var(--sidebar-active);
    font-weight: 600;
}

.sidebar-nav .nav-link.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--sidebar-active);
}

/* Icons: monochrome, take the link's color. */
.nav-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex: none;
    color: var(--subtle);
    transition: color .12s;
}

.nav-ico svg { width: 17px; height: 17px; }
.sidebar-nav .nav-link:hover .nav-ico,
.nav-group-toggle:hover .nav-ico,
.nav-group.open > .nav-group-toggle .nav-ico { color: var(--ink-2); }
.sidebar-nav .nav-link.active .nav-ico { color: var(--sidebar-active); }
.nav-group.open > .nav-group-toggle { color: var(--ink); }

.nav-caret {
    margin-left: auto;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform .15s var(--ease);
    opacity: .5;
}

.nav-group.open > .nav-group-toggle .nav-caret { transform: rotate(45deg); }

.nav-sub {
    list-style: none;
    margin: 2px 0 6px 20px;
    padding: 0 0 0 10px;
    border-left: 1px solid var(--line);
    display: none;
}

.nav-group.open > .nav-sub { display: block; }

.nav-sub a {
    display: block;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--sidebar-ink);
    font-size: 13px;
}

.nav-sub a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav-sub a.active { color: var(--sidebar-active); font-weight: 600; background: var(--brand-50); }

.nav-pending { color: var(--subtle); font-size: 12.5px; padding: 6px 10px; font-style: italic; }

.sidebar-support { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.sidebar-support-title { text-transform: uppercase; letter-spacing: .06em; font-size: 11px; font-weight: 600; color: var(--subtle); margin-bottom: 4px; }
.sidebar-support a { display: block; color: var(--muted); padding: 2px 0; }
.sidebar-support a:hover { color: var(--brand-600); }

/* Collapsed rail */
.app-shell.collapsed .sidebar-brand { justify-content: center; padding: 0; }
.app-shell.collapsed .sidebar-brand-name,
.app-shell.collapsed .sidebar-logo,
.app-shell.collapsed .nav-text,
.app-shell.collapsed .nav-caret,
.app-shell.collapsed .nav-sub,
.app-shell.collapsed .sidebar-support { display: none; }

.app-shell.collapsed .nav-section { font-size: 0; padding: 0; margin: 10px 8px; border-top: 1px solid var(--line); }
.app-shell.collapsed .sidebar-nav .nav-link,
.app-shell.collapsed .nav-group-toggle { justify-content: center; padding: 9px 0; }

/* ------------------------------------------------------------------- topbar */
.app-topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-topbar-solo { position: static; padding-left: 24px; }

.topbar-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.topbar-burger:hover { background: var(--hover); color: var(--ink); }

.topbar-title { font-size: 15px; font-weight: 600; margin: 0; }
.topbar-brand { font-weight: 600; color: var(--ink); padding-right: 12px; margin-right: 4px; border-right: 1px solid var(--line); }
.topbar-spacer { flex: 1; }

/* user menu */
.user-menu { position: relative; }

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    background: transparent;
    padding: 4px 10px 4px 4px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    color: var(--ink);
}

.user-menu-btn:hover,
.user-menu.open .user-menu-btn { background: var(--hover); }
.user-menu-btn .nav-caret { color: var(--muted); }

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-100);
    color: var(--brand-700);
    font-weight: 600;
    font-size: 12px;
}

.user-name { font-size: 13px; font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-menu-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    display: none;
    z-index: 60;
}

.user-menu.open .user-menu-pop { display: block; }

.user-menu-pop a,
.user-menu-pop button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    border-radius: 6px;
    color: var(--ink-2);
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
}

.user-menu-pop a:hover,
.user-menu-pop button:hover { background: var(--hover); color: var(--ink); text-decoration: none; }

/* ------------------------------------------------------------------ content */
.app-content { padding: 24px 28px 32px; flex: 1; min-width: 0; }
.app-content-wide { padding: 14px 16px; }

.app-footer {
    padding: 14px 28px;
    border-top: 1px solid var(--line);
    color: var(--subtle);
    font-size: 12.5px;
}

.impersonation-banner {
    background: #fffaeb;
    border: 1px solid #fedf89;
    color: #93370d;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 16px;
}

.impersonation-banner .impersonation-stop { margin-left: 10px; font-weight: 600; color: #93370d; }

/* -------------------------------------------------------------- page blocks */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin: 0 0 20px; flex-wrap: wrap; }
.page-head h1, .page-head h2 { font-size: 20px; font-weight: 600; margin: 0; }
.page-head p { color: var(--muted); margin: 4px 0 0; width: 100%; }
.page-head > div:first-child p { width: auto; }
.page-head .page-actions { margin-left: auto; display: flex; gap: 8px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.card.lift { transition: border-color .15s; }
.card.lift:hover { border-color: var(--line-strong); }

.card .card-title { font-size: 14.5px; font-weight: 600; margin: 0 0 12px; }

.card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.card-head .card-title { margin: 0; }
.card-head .card-sub { color: var(--muted); font-size: 12.5px; }
.card-head .card-link { margin-left: auto; font-size: 13px; font-weight: 500; }
.card-flush { padding: 0; }
.card-flush > .card-head { padding: 16px 20px 0; }

/* KPI cards (dashboards) */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-grid > .card { margin-bottom: 0; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }

.kpi-ico {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-50);
    color: var(--brand-600);
}

.kpi-ico.ok { background: #ecfdf3; color: var(--success); }
.kpi-ico.live { background: #fffaeb; color: var(--warning); }
.kpi-ico.neutral { background: var(--hover); color: var(--ink-2); }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-meta { color: var(--muted); font-size: 12.5px; min-height: 18px; }

/* Older KPI markup (stat-card) */
.stat-card { display: flex; align-items: center; gap: 14px; }

.stat-ico {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    background: var(--brand-50);
    color: var(--brand-600);
}

.stat-ico.bill { background: #ecfdf3; color: var(--success); }
.stat-ico.sales { background: #fffaeb; color: var(--warning); }
.stat-ico.int { background: var(--hover); color: var(--ink-2); }
.stat-value { font-size: 22px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 12.5px; }

/* Dashboard rows */
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 20px; }
.dash-grid > .card { margin-bottom: 0; }
.dash-grid.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Segmented control (date-range toggles) */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--hover); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.seg button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.perf-note { color: var(--muted); font-size: 12.5px; margin: -4px 0 0; }

/* Ranked list with inline bars (top languages etc.) */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank-list li:last-child { border-bottom: 0; }
.rank-name { font-weight: 500; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.rank-bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--hover); overflow: hidden; }
.rank-bar > span { display: block; height: 100%; background: var(--brand-500); border-radius: 2px; }
.rank-list .rank-empty { display: block; color: var(--muted); border: 0; padding: 24px 0; text-align: center; }

/* Plain data table (non-Kendo) */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 10px 20px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table td { padding: 11px 20px; border-bottom: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fafbfc; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .strong { color: var(--ink); font-weight: 500; }
.data-table .empty { text-align: center; color: var(--muted); padding: 28px 20px; }
/* Narrow cards: tighter cells, long first-column names truncate instead of forcing a scroll. */
.data-table.compact th, .data-table.compact td { padding-left: 12px; padding-right: 12px; }
.data-table.compact th:first-child, .data-table.compact td:first-child { padding-left: 20px; }
.data-table.compact th:last-child, .data-table.compact td:last-child { padding-right: 20px; }
.data-table.compact td:first-child { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}

/* ------------------------------------------------------------------ buttons */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 13.5px;
    transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}

.btn:focus, .btn.focus { box-shadow: var(--focus-ring); }

/* .btn-purple = the ported views' refresh/submit buttons (old template class). */
.btn-primary,
.btn-purple {
    background: var(--brand-600);
    border: 1px solid var(--brand-600);
    color: #fff;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.btn-primary:hover, .btn-primary:focus,
.btn-purple:hover, .btn-purple:focus,
.btn-primary:not(:disabled):not(.disabled):active {
    background: var(--brand-700);
    border-color: var(--brand-700);
    color: #fff;
}

.btn-purple:disabled { opacity: .55; cursor: default; }

.btn-secondary {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    color: var(--ink-2);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover, .btn-secondary:focus,
.btn-secondary:not(:disabled):not(.disabled):active {
    background: var(--hover);
    border-color: var(--line-strong);
    color: var(--ink);
}

.btn-ghost { background: transparent; border: 0; color: var(--brand-600); box-shadow: none; }
.btn-ghost:hover { background: var(--brand-50); color: var(--brand-700); }

.btn-danger { background: var(--danger); border: 1px solid var(--danger); color: #fff; }
.btn-danger:hover { background: #b42318; border-color: #b42318; color: #fff; }

/* Legacy .btn-info links from ported views: themed secondary buttons. */
.btn-info { background: var(--surface); border: 1px solid var(--line-strong); color: var(--brand-600); }
.btn-info:hover, .btn-info:focus { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }

/* -------------------------------------------------------------------- forms */
.form-control, .form-select {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    transition: border-color .12s, box-shadow .12s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-500);
    box-shadow: var(--focus-ring);
    outline: none;
}

.form-control::placeholder { color: var(--subtle); }

label { font-weight: 500; font-size: 13px; color: var(--ink-2); }

.validation-summary-errors, .field-validation-error { color: var(--danger); font-size: 13px; }
.validation-summary-errors ul { padding-left: 18px; margin-bottom: 8px; }

/* ---------------------------------------------------------- status pills */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
}

.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-success { background: #ecfdf3; color: #067647; }
.pill-danger { background: #fef3f2; color: #b42318; }
.pill-warning { background: #fffaeb; color: #b54708; }
.pill-info { background: #eff8ff; color: #175cd3; }
.pill-brand { background: var(--brand-50); color: var(--brand-700); }
.pill-muted { background: var(--hover); color: var(--muted); }

/* ------------------------------------------------------------ sign-in page */
.auth-body { background: var(--surface); }

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(340px, 42%) 1fr;
}

.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
    padding: 36px 48px;
    background-color: var(--brand-700);
    background-image:
        linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px);
    background-size: 36px 36px;
    color: #fff;
}

.auth-aside-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.auth-aside-brand .sidebar-mark { background: rgba(255, 255, 255, .16); }
.auth-aside-copy h2 { color: #fff; font-size: 28px; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; max-width: 440px; margin: 0; }
.auth-aside-foot { font-size: 12.5px; color: rgba(255, 255, 255, .7); }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { display: block; max-height: 40px; max-width: 220px; object-fit: contain; margin-bottom: 24px; }
.auth-title { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-sub { color: var(--muted); margin: 0 0 28px; }
.auth-card .form-group { margin-bottom: 4px; }
.auth-card .form-control { height: 40px; }
.auth-card .btn-primary { width: 100%; padding: 9px; font-weight: 600; }
.auth-card .checkbox label { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; color: var(--muted); }

/* -------------------------------------------------- modal / screen variants */
.modal-body-page { background: var(--surface); padding: 14px 16px; }

.screen-body { background: #0f172a; color: #e2e8f0; padding: 8px; font-size: 12.5px; }

/* ---------------------------------------- ported Bootstrap form layout repair
   Main's views were authored for the Fonik/Bootstrap-5 theme; two patterns break
   under the stock grid in the new shell:
   1) Horizontal-form fields — <label class="col-md-2 control-label"> + <div class="col-md-10">
      live inside a non-flex .mb-*/.form-group wrapper, so the col max-width caps squish
      the label (character-wrapping in narrow cards). Reset the DIRECT-CHILD field columns
      to full width so the field stacks (label above input). Real grid columns are
      children of .row, so they are untouched.
   2) A .row nested directly inside another .row (no intervening col) shrink-wraps as a
      flex item to ~content width — force it to fill. */
.mb-1 > [class*="col-"], .mb-2 > [class*="col-"], .mb-3 > [class*="col-"],
.mb-4 > [class*="col-"], .mb-5 > [class*="col-"],
.form-group > [class*="col-"] {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
}

.control-label, .form-control-label {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-bottom: 4px;
}

.row > .row { flex: 1 1 100%; width: 100%; }

/* ---- ported nested card system ----
   Main's views nest .card > .card-body, and cards inside cards. The design-system .card
   carries the box (border/shadow/padding); normalize the nesting so it reads as one clean
   surface instead of mismatched floating boxes. */
.card-body { padding: 0; }                 /* the .card already provides padding */
.card .card {                              /* inner cards = flat sections, not floating boxes */
    box-shadow: none;
    margin-bottom: 14px;
}
.card .card:last-child { margin-bottom: 0; }

/* Paired cards in a tab row stretch to equal height so they line up. */
.tab-content .row { align-items: stretch; }
.tab-content .row > [class*="col-"] { display: flex; flex-direction: column; }
.tab-content .row > [class*="col-"] > .card { flex: 1 1 auto; }

/* Collapse ported cards that rendered empty — the Kendo grids are hidden until a record is
   saved (new-record state), which otherwise leaves an empty panel. :has() = modern browsers;
   older ones simply show the empty card as before (graceful). */
.tab-content .card:has(> .card-body:not(:has(*))) { display: none; }

/* ---------------------------------------- demo mode
   Applied to grid cells/fields when the demo account is signed in — hides PII on
   screen without touching the data. */
.demo-obscure {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* -------------------------------------------- legacy template class shim
   The ported Main views carry utility classes from the old Fonik/slim themes.
   Map the common ones onto the design system so bulk-ported views look right
   without editing each file. Extend as porting surfaces more. */
.tx-danger { color: var(--danger) !important; }
.tx-success { color: var(--success) !important; }
.mg-b-10, .mg-b-10-force { margin-bottom: 10px !important; }
.mg-t-10, .mg-t-10-force { margin-top: 10px !important; }
.form-control-label { font-weight: 500; font-size: 13px; color: var(--ink-2); }
.label { display: inline-block; padding: .2em .6em; border-radius: 999px; font-size: 11.5px; font-weight: 500; }
.label-default { background: var(--hover); color: var(--muted); }
.card-box, .page-title-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 20px; }
.header-bg { background: transparent; }
.padTop30 { padding-top: 0; }

/* -------------------------------------------------- Bootstrap 5 utility shim
   Base layer is stock Bootstrap 4; Main's views occasionally use BS5 utilities.
   Extend as porting surfaces more. */
.ms-1 { margin-left: .25rem !important; } .ms-2 { margin-left: .5rem !important; } .ms-3 { margin-left: 1rem !important; } .ms-auto { margin-left: auto !important; }
.me-1 { margin-right: .25rem !important; } .me-2 { margin-right: .5rem !important; } .me-3 { margin-right: 1rem !important; } .me-auto { margin-right: auto !important; }
.ps-2 { padding-left: .5rem !important; } .pe-2 { padding-right: .5rem !important; }
.fw-bold { font-weight: 700 !important; } .fw-semibold { font-weight: 600 !important; }
.text-end { text-align: right !important; } .text-start { text-align: left !important; }
.gap-1 { gap: .25rem !important; } .gap-2 { gap: .5rem !important; } .gap-3 { gap: 1rem !important; }

/* --------------------------------------------------------------- scrollbars */
.app-sidebar::-webkit-scrollbar { width: 8px; }
.app-sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ------------------------------------------------------------------- mobile */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-grid, .dash-grid.even { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-w);
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .2s var(--ease);
    }

    .app-shell.mobile-open .app-sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }

    .app-content { padding: 16px; }
    .app-topbar { padding: 0 16px 0 8px; }
    .user-name { display: none; }

    .auth-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .auth-aside { padding: 16px 20px; }
    .auth-aside-copy, .auth-aside-foot { display: none; }
    .auth-main { align-items: flex-start; padding: 32px 16px; }
}

@media (max-width: 600px) {
    .kpi-grid { gap: 10px; }
    .kpi { padding: 14px; }
    .kpi-ico { display: none; }
    .kpi-value { font-size: 22px; }
    .page-head .page-actions { margin-left: 0; }
}
