/* ==========================================================================
   BdREN Service Portal — design system
   Loaded after Bootstrap 5.3. Sections:
     1. Fonts            6. Components
     2. Tokens           7. Dashboard
     3. Bootstrap bridge 8. (Bootstrap 4 compatibility → bs4-compat.css)
     4. Base             9. Legacy srtdash content classes (legacy pages)
     5. Layout          10. Print / reduced motion
   ========================================================================== */

/* 1. Fonts ---------------------------------------------------------------- */
@font-face {
    font-family: "Noto Sans Bengali";
    src: url("../fonts/NotoSansBengali-VariableFont_wdth,wght.ttf") format("truetype");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0980-09FF, U+200C-200D, U+25CC;
}

/* 2. Tokens --------------------------------------------------------------- */
:root,
[data-bs-theme="light"] {
    --app-font: "Inter", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --app-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* surfaces & ink */
    --app-bg: #f5f6f8;
    --app-surface: #ffffff;
    --app-surface-2: #f8f9fb;
    --app-surface-3: #f1f3f6;
    --app-border: #e4e7ec;
    --app-border-strong: #d0d5dd;
    --app-text: #101828;
    --app-text-2: #344054;
    --app-text-muted: #667085;

    /* brand */
    --app-primary: #4f46e5;
    --app-primary-rgb: 79, 70, 229;
    --app-primary-hover: #4338ca;
    --app-primary-active: #3730a3;
    --app-primary-text: #4338ca;
    --app-primary-subtle: #eef2ff;
    --app-primary-border: #c7d2fe;

    /* status: Confirmed = success, Pending = warning, Rejected = danger, Update = info */
    --app-success: #079455;
    --app-success-text: #067647;
    --app-success-subtle: #ecfdf3;
    --app-success-border: #abefc6;
    --app-warning: #dc6803;
    --app-warning-text: #b54708;
    --app-warning-subtle: #fffaeb;
    --app-warning-border: #fedf89;
    --app-danger: #d92d20;
    --app-danger-text: #b42318;
    --app-danger-subtle: #fef3f2;
    --app-danger-border: #fecdca;
    --app-info: #1570ef;
    --app-info-text: #175cd3;
    --app-info-subtle: #eff8ff;
    --app-info-border: #b2ddff;
    --app-neutral-text: #475467;
    --app-neutral-subtle: #f2f4f7;
    --app-neutral-border: #e4e7ec;

    /* charts (status pair is fixed across themes) */
    --app-chart-confirmed: #0ca30c;
    --app-chart-pending: #fab219;
    --app-chart-series: #4f46e5;
    --app-chart-grid: #eaecf0;
    --app-chart-axis: #98a2b3;

    /* chrome */
    --app-sidebar-bg: #ffffff;
    --app-sidebar-hover: #f2f4f7;
    --app-topbar-bg: rgba(255, 255, 255, 0.85);
    --app-backdrop: rgba(16, 24, 40, 0.45);

    /* spacing (4px scale) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* shape & depth */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.12), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
    --focus-ring: 0 0 0 3px rgba(var(--app-primary-rgb), 0.28);

    /* layout */
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 60px;
    --content-max: 1440px;
    --ease: cubic-bezier(0.2, 0, 0, 1);
}

[data-bs-theme="dark"] {
    --app-bg: #0c0e12;
    --app-surface: #13161b;
    --app-surface-2: #181b21;
    --app-surface-3: #1f232b;
    --app-border: #262a33;
    --app-border-strong: #343a46;
    --app-text: #f0f1f3;
    --app-text-2: #cdd0d5;
    --app-text-muted: #949aa6;

    --app-primary: #4f46e5;
    --app-primary-hover: #5b54ea;
    --app-primary-active: #6d67ee;
    --app-primary-text: #a5b4fc;
    --app-primary-subtle: rgba(99, 102, 241, 0.16);
    --app-primary-border: rgba(129, 140, 248, 0.4);

    --app-success: #17b26a;
    --app-success-text: #75e0a7;
    --app-success-subtle: rgba(23, 178, 106, 0.14);
    --app-success-border: rgba(23, 178, 106, 0.32);
    --app-warning: #f79009;
    --app-warning-text: #fec84b;
    --app-warning-subtle: rgba(247, 144, 9, 0.14);
    --app-warning-border: rgba(247, 144, 9, 0.32);
    --app-danger: #f04438;
    --app-danger-text: #fda29b;
    --app-danger-subtle: rgba(240, 68, 56, 0.14);
    --app-danger-border: rgba(240, 68, 56, 0.32);
    --app-info: #2e90fa;
    --app-info-text: #84caff;
    --app-info-subtle: rgba(46, 144, 250, 0.14);
    --app-info-border: rgba(46, 144, 250, 0.32);
    --app-neutral-text: #cdd0d5;
    --app-neutral-subtle: rgba(255, 255, 255, 0.06);
    --app-neutral-border: rgba(255, 255, 255, 0.1);

    --app-chart-series: #818cf8;
    --app-chart-grid: #232730;
    --app-chart-axis: #6b7280;

    --app-sidebar-bg: #101317;
    --app-sidebar-hover: #1b1f26;
    --app-topbar-bg: rgba(12, 14, 18, 0.82);
    --app-backdrop: rgba(0, 0, 0, 0.6);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 32px -8px rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.45);
}

/* 3. Bootstrap bridge ------------------------------------------------------ */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
    --bs-body-font-family: var(--app-font);
    --bs-body-font-size: 0.875rem;
    --bs-body-line-height: 1.5;
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text-2);
    --bs-emphasis-color: var(--app-text);
    --bs-heading-color: inherit;
    --bs-secondary-color: var(--app-text-muted);
    --bs-tertiary-color: var(--app-text-muted);
    --bs-secondary-bg: var(--app-surface-3);
    --bs-tertiary-bg: var(--app-surface-2);
    --bs-border-color: var(--app-border);
    --bs-border-color-translucent: var(--app-border);
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: var(--radius-sm);
    --bs-border-radius-lg: var(--radius-lg);
    --bs-primary: var(--app-primary);
    --bs-primary-rgb: var(--app-primary-rgb);
    --bs-primary-text-emphasis: var(--app-primary-text);
    --bs-primary-bg-subtle: var(--app-primary-subtle);
    --bs-primary-border-subtle: var(--app-primary-border);
    --bs-link-color: var(--app-primary-text);
    --bs-link-color-rgb: var(--app-primary-rgb);
    --bs-link-hover-color: var(--app-primary-hover);
    --bs-focus-ring-color: rgba(var(--app-primary-rgb), 0.28);
    --bs-success-text-emphasis: var(--app-success-text);
    --bs-success-bg-subtle: var(--app-success-subtle);
    --bs-success-border-subtle: var(--app-success-border);
    --bs-warning-text-emphasis: var(--app-warning-text);
    --bs-warning-bg-subtle: var(--app-warning-subtle);
    --bs-warning-border-subtle: var(--app-warning-border);
    --bs-danger-text-emphasis: var(--app-danger-text);
    --bs-danger-bg-subtle: var(--app-danger-subtle);
    --bs-danger-border-subtle: var(--app-danger-border);
    --bs-info-text-emphasis: var(--app-info-text);
    --bs-info-bg-subtle: var(--app-info-subtle);
    --bs-info-border-subtle: var(--app-info-border);
}

[data-bs-theme="dark"] .text-primary { color: var(--app-primary-text) !important; }

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-hover);
    --bs-btn-hover-border-color: var(--app-primary-hover);
    --bs-btn-active-bg: var(--app-primary-active);
    --bs-btn-active-border-color: var(--app-primary-active);
    --bs-btn-disabled-bg: var(--app-primary);
    --bs-btn-disabled-border-color: var(--app-primary);
    --bs-btn-focus-shadow-rgb: var(--app-primary-rgb);
}

.btn-outline-primary {
    --bs-btn-color: var(--app-primary-text);
    --bs-btn-border-color: var(--app-primary-border);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary-active);
    --bs-btn-active-border-color: var(--app-primary-active);
}

/* 4. Base ----------------------------------------------------------------- */
[hidden] { display: none !important; }   /* components that set display (grid, flex) must still honour hidden */
html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--app-bg);
    color: var(--app-text-2);
    font-family: var(--app-font);
    font-size: 0.875rem;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* headings inherit colour (legacy headers set white text on coloured bars); new components set it explicitly */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

h1, .h1 { font-size: 1.5rem; }
h2, .h2 { font-size: 1.25rem; }
h3, .h3 { font-size: 1.125rem; }
h4, .h4 { font-size: 1rem; }
h5, .h5 { font-size: 0.9375rem; }
h6, .h6 { font-size: 0.875rem; }

a { color: var(--app-primary-text); text-decoration: none; }
a:hover { color: var(--app-primary-hover); }
[data-bs-theme="dark"] a:hover { color: #c7d2fe; }

:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus { box-shadow: var(--focus-ring); }

.tabular-nums, .table, .stat-value, .num { font-variant-numeric: tabular-nums; }

.text-muted, .text-body-secondary { color: var(--app-text-muted) !important; }

::selection { background: rgba(var(--app-primary-rgb), 0.18); }

.skip-link {
    position: absolute;
    left: var(--space-4);
    top: -100px;
    z-index: 2000;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    background: var(--app-primary);
    color: #fff;
}

.skip-link:focus { top: var(--space-3); color: #fff; }

/* 5. Layout --------------------------------------------------------------- */
.app-shell { min-height: 100vh; }

.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    padding-left: var(--sidebar-w);
    transition: padding-left 0.2s var(--ease);
}

.app-content { flex: 1 0 auto; outline: none; }

.app-container {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-6);
}

/* Sidebar */
.app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    background: var(--app-sidebar-bg);
    border-right: 1px solid var(--app-border);
    transition: width 0.2s var(--ease), transform 0.25s var(--ease), box-shadow 0.2s;
}

.sidebar-brand {
    display: flex;
    flex: 0 0 var(--topbar-h);
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    border-bottom: 1px solid var(--app-border);
    overflow: hidden;
}

.sidebar-brand__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    color: var(--app-text);
}

.sidebar-brand__link:hover { color: var(--app-text); }

.sidebar-brand__logo {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: var(--radius);
}

[data-bs-theme="dark"] .sidebar-brand__logo { background: #fff; padding: 3px; }

.sidebar-brand__text { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
.sidebar-brand__text strong { font-size: 0.9375rem; font-weight: 700; letter-spacing: -0.01em; }
.sidebar-brand__text small { font-size: 0.75rem; color: var(--app-text-muted); }

.sidebar-close { margin-left: auto; }

.sidebar-nav {
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: var(--space-3) var(--space-3) var(--space-4);
    scrollbar-width: thin;
}

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

.nav-section {
    margin: var(--space-4) var(--space-3) var(--space-1);
    color: var(--app-text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    min-height: 36px;
    margin: 1px 0;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--app-text-2);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s;
}

.nav-item-link:hover { background: var(--app-sidebar-hover); color: var(--app-text); }

.nav-item-link.active {
    background: var(--app-primary-subtle);
    color: var(--app-primary-text);
}

.nav-icon {
    flex: 0 0 20px;
    width: 20px;
    color: var(--app-text-muted);
    font-size: 0.9375rem;
    text-align: center;
}

.nav-item-link:hover .nav-icon { color: var(--app-text-2); }
.nav-item-link.active .nav-icon,
.nav-group.has-active > .nav-item-link .nav-icon { color: var(--app-primary-text); }
.nav-group.has-active > .nav-item-link { color: var(--app-text); }

.nav-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.nav-caret {
    flex: 0 0 auto;
    color: var(--app-text-muted);
    font-size: 0.6875rem;
    transition: transform 0.2s var(--ease);
}

.nav-item-link[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }

.nav-sub {
    position: relative;
    margin: 2px 0 var(--space-2) 21px;
    padding-left: var(--space-3);
    border-left: 1px solid var(--app-border);
}

.nav-sub__link {
    display: block;
    padding: 6px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--app-text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-sub__link:hover { background: var(--app-sidebar-hover); color: var(--app-text); }

.nav-sub__link.active {
    position: relative;
    color: var(--app-primary-text);
    background: var(--app-primary-subtle);
}

.nav-sub__link.active::before {
    content: "";
    position: absolute;
    left: calc(-1 * var(--space-3) - 1px);
    top: 6px;
    bottom: 6px;
    width: 2px;
    border-radius: 2px;
    background: var(--app-primary);
}

.sidebar-user {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--app-border);
    overflow: hidden;
}

.avatar {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--app-primary-subtle);
    color: var(--app-primary-text);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-user__meta { min-width: 0; line-height: 1.25; }
.sidebar-user__name { display: block; color: var(--app-text); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user__role { display: block; color: var(--app-text-muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: var(--app-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

/* Desktop: collapsible to an icon rail; hover/focus temporarily expands over content */
@media (min-width: 992px) {
    .sidebar-collapsed .app-main { padding-left: var(--sidebar-w-collapsed); }
    .sidebar-collapsed .app-sidebar { width: var(--sidebar-w-collapsed); }

    .sidebar-collapsed .app-sidebar:hover,
    .sidebar-collapsed .app-sidebar:focus-within {
        width: var(--sidebar-w);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) :is(.nav-text, .nav-caret, .sidebar-brand__text, .sidebar-user__meta) { display: none; }
    .sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .nav-group > .collapse { display: none !important; }
    .sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .nav-item-link { justify-content: center; padding: 0; }
    .sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sidebar-brand { padding: 0; justify-content: center; }
    .sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sidebar-user { justify-content: center; padding-left: 0; padding-right: 0; }

    .sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .nav-section {
        height: 1px;
        margin: var(--space-3) var(--space-2);
        overflow: hidden;
        background: var(--app-border);
        color: transparent;
    }
}

/* Tablet & mobile: off-canvas drawer, content never shifts or gets covered without a backdrop */
@media (max-width: 991.98px) {
    .app-main { padding-left: 0; }

    .app-sidebar {
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.25s var(--ease), visibility 0s linear 0.25s;
    }

    .sidebar-open .app-sidebar {
        transform: none;
        visibility: visible;
        box-shadow: var(--shadow-lg);
        transition: transform 0.25s var(--ease), visibility 0s;
    }

    .sidebar-open .app-sidebar-backdrop { opacity: 1; visibility: visible; }
    .sidebar-open body { overflow: hidden; }
}

/* Topbar */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--topbar-h);
    padding: 0 var(--space-6);
    background: var(--app-topbar-bg);
    border-bottom: 1px solid var(--app-border);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    backdrop-filter: saturate(180%) blur(8px);
}

.topbar-crumbs { flex: 1 1 auto; min-width: 0; }

.topbar-crumbs .breadcrumb {
    flex-wrap: nowrap;
    margin: 0;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.topbar-crumbs .breadcrumb-item { overflow: hidden; text-overflow: ellipsis; }
.topbar-crumbs .breadcrumb-item a { color: var(--app-text-muted); }
.topbar-crumbs .breadcrumb-item a:hover { color: var(--app-text); }
.topbar-crumbs .breadcrumb-item.active { color: var(--app-text); font-weight: 600; }
.topbar-crumbs .crumb-parent { color: var(--app-text-muted); }

@media (max-width: 575.98px) {
    .topbar-crumbs .breadcrumb-item:first-child,
    .topbar-crumbs .crumb-parent { display: none; }
    .topbar-crumbs .breadcrumb-item + .breadcrumb-item { padding-left: 0; }
    .topbar-crumbs .breadcrumb-item + .breadcrumb-item::before { display: none; }
}

.topbar-actions { display: flex; align-items: center; gap: var(--space-1); }

.icon-btn {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--app-text-muted);
    font-size: 0.9375rem;
    transition: background-color 0.15s, color 0.15s;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] { background: var(--app-surface-3); color: var(--app-text); }

.icon-btn .count-dot {
    position: absolute;
    top: 3px;
    right: 2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border: 2px solid var(--app-surface);
    border-radius: 999px;
    background: var(--app-danger);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 13px;
    text-align: center;
}

.theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: inline-block; }

.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: var(--space-1);
    padding: 2px var(--space-2) 2px 2px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--app-text);
    font-size: 0.8125rem;
    font-weight: 500;
}

.topbar-user:hover,
.topbar-user[aria-expanded="true"] { background: var(--app-surface-3); }
.topbar-user__name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Topbar menu search */
.topbar-search { position: relative; width: 260px; }

.topbar-search .form-control {
    height: 36px;
    padding-left: 34px;
    padding-right: 44px;
    background: var(--app-surface-2);
}

.topbar-search__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--app-text-muted);
    font-size: 0.8125rem;
    pointer-events: none;
}

.topbar-search__kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 1px 6px;
    border: 1px solid var(--app-border);
    border-radius: 4px;
    background: var(--app-surface);
    color: var(--app-text-muted);
    font-family: var(--app-font);
    font-size: 0.6875rem;
    pointer-events: none;
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 360px;
    margin: 0;
    padding: var(--space-1);
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--app-border);
    border-radius: var(--radius);
    background: var(--app-surface);
    box-shadow: var(--shadow-lg);
}

.search-results [role="option"] {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 7px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--app-text-2);
    cursor: pointer;
}

.search-results [role="option"] small { margin-left: auto; color: var(--app-text-muted); font-size: 0.75rem; }
.search-results [role="option"][aria-selected="true"] { background: var(--app-primary-subtle); color: var(--app-primary-text); }
.search-results .search-empty { padding: var(--space-3); color: var(--app-text-muted); }

/* Page header */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.page-title { margin: 0; color: var(--app-text); font-size: 1.375rem; font-weight: 650; letter-spacing: -0.02em; }
.page-title:empty { display: none; }
.page-subtitle { margin: var(--space-1) 0 0; color: var(--app-text-muted); font-size: 0.875rem; }
.page-subtitle:empty { display: none; }
.page-header > div:first-child { flex: 1 1 320px; min-width: 0; }
.page-subtitle { overflow-wrap: anywhere; }
.page-actions { display: flex; flex-wrap: wrap; flex: 0 1 auto; min-width: 0; gap: var(--space-2); }   /* may shrink and wrap: 3+ buttons overflowed on phones */
.page-actions:empty { display: none; }

@media (max-width: 767.98px) {
    .app-container { padding: var(--space-4); }
    .app-topbar { gap: var(--space-2); padding: 0 var(--space-4); }
    .page-header { align-items: flex-start; margin-bottom: var(--space-5); }
}

/* 6. Components ------------------------------------------------------------ */

/* Cards */
.card {
    --bs-card-bg: var(--app-surface);
    --bs-card-border-color: var(--app-border);
    --bs-card-border-radius: var(--radius-lg);
    --bs-card-inner-border-radius: calc(var(--radius-lg) - 1px);
    --bs-card-cap-bg: transparent;
    --bs-card-spacer-x: var(--space-5);
    --bs-card-spacer-y: var(--space-5);
    --bs-card-cap-padding-y: var(--space-4);
    --bs-card-cap-padding-x: var(--space-5);
    box-shadow: var(--shadow-sm);
}

.card-header { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; }

.card-title { margin: 0; color: var(--app-text); font-size: 0.9375rem; font-weight: 600; }
.card-subtitle { margin: 2px 0 0; color: var(--app-text-muted); font-size: 0.8125rem; }

/* Buttons */
.btn {
    --bs-btn-font-size: 0.875rem;
    --bs-btn-font-weight: 500;
    --bs-btn-padding-x: 0.875rem;
    --bs-btn-padding-y: 0.4375rem;
    --bs-btn-border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-sm {
    --bs-btn-font-size: 0.8125rem;
    --bs-btn-padding-x: 0.625rem;
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-border-radius: var(--radius-sm);
}

.btn-secondary-soft,
.btn-light {
    --bs-btn-color: var(--app-text);
    --bs-btn-bg: var(--app-surface);
    --bs-btn-border-color: var(--app-border-strong);
    --bs-btn-hover-color: var(--app-text);
    --bs-btn-hover-bg: var(--app-surface-3);
    --bs-btn-hover-border-color: var(--app-border-strong);
    --bs-btn-active-color: var(--app-text);
    --bs-btn-active-bg: var(--app-surface-3);
    --bs-btn-active-border-color: var(--app-border-strong);
    box-shadow: var(--shadow-sm);
}

.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-icon.btn-sm { width: 28px; height: 28px; }

.btn.is-loading { position: relative; pointer-events: none; }
.btn.is-loading > :not(.btn-spinner) { visibility: hidden; }
.btn.is-loading .btn-spinner { position: absolute; inset: 0; margin: auto; }

/* Status pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid var(--app-neutral-border);
    border-radius: 999px;
    background: var(--app-neutral-subtle);
    color: var(--app-neutral-text);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-pill.no-dot::before { display: none; }

.status-pill.is-confirmed, .status-pill.is-success { background: var(--app-success-subtle); border-color: var(--app-success-border); color: var(--app-success-text); }
.status-pill.is-pending, .status-pill.is-warning { background: var(--app-warning-subtle); border-color: var(--app-warning-border); color: var(--app-warning-text); }
.status-pill.is-rejected, .status-pill.is-danger { background: var(--app-danger-subtle); border-color: var(--app-danger-border); color: var(--app-danger-text); }
.status-pill.is-update, .status-pill.is-info { background: var(--app-info-subtle); border-color: var(--app-info-border); color: var(--app-info-text); }
.status-pill.is-archived { background: var(--app-neutral-subtle); border-color: var(--app-neutral-border); color: var(--app-text-muted); }
.status-pill.is-archived::before { display: none; }

/* Bootstrap badges follow the same system */
.badge { --bs-badge-font-weight: 600; --bs-badge-padding-x: 0.5rem; --bs-badge-padding-y: 0.25rem; --bs-badge-border-radius: 999px; }

/* Forms */
.form-label,
.col-form-label { margin-bottom: 6px; color: var(--app-text); font-size: 0.8125rem; font-weight: 500; }

.form-control,
.form-select {
    --bs-border-color: var(--app-border-strong);
    min-height: 38px;
    border-radius: var(--radius);
    background-color: var(--app-surface);
    color: var(--app-text);
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
}

.form-control::placeholder { color: var(--app-text-muted); opacity: 0.8; }

.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary);
    background-color: var(--app-surface);
    color: var(--app-text);
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled { background-color: var(--app-surface-2); color: var(--app-text-muted); }

.form-text { color: var(--app-text-muted); font-size: 0.75rem; }
.form-check-input { border-color: var(--app-border-strong); }
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }
.invalid-feedback { font-size: 0.75rem; }

/* crispy-forms (bootstrap4 pack) labels & required marker, in the app's form style */
.form-group > label,
.form-group > .col-form-label { margin-bottom: 6px; color: var(--app-text); font-size: 0.8125rem; font-weight: 500; }
.asteriskField { margin-left: 2px; color: var(--app-danger); }

/* Tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--app-text-2);
    --bs-table-border-color: var(--app-border);
    --bs-table-striped-bg: var(--app-surface-2);
    --bs-table-hover-bg: var(--app-surface-3);
    --bs-table-hover-color: var(--app-text);
    margin-bottom: 0;
    font-size: 0.8125rem;
    vertical-align: middle;
}

.table > :not(caption) > * > * { padding: 10px var(--space-4); }

.table > thead > tr > th,
.table > thead > tr > td {
    background: var(--app-surface-2);
    border-bottom-color: var(--app-border);
    color: var(--app-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table-sticky > thead > tr > th { position: sticky; top: 0; z-index: 1; }

.card > .table-responsive:last-child .table > tbody > tr:last-child > *,
.card > .table:last-child > tbody > tr:last-child > * { border-bottom: 0; }

/* DataTables 2 (Bootstrap 5 integration) */
div.dt-container { font-size: 0.8125rem; }
div.dt-container .dt-layout-row { margin: var(--space-3) 0 !important; }
div.dt-container .dt-search input,
div.dt-container .dt-length select { min-height: 34px; border-radius: var(--radius); }
div.dt-container .dt-search input { min-width: 240px; margin-left: var(--space-2); }
div.dt-container .dt-info { color: var(--app-text-muted); }

div.dt-container div.dt-processing {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--app-border);
    border-radius: var(--radius);
    background: var(--app-surface);
    box-shadow: var(--shadow-lg);
    color: var(--app-text);
}

div.dt-container div.dt-processing > div:last-child { display: none; }
table.dataTable td.dt-empty { padding: var(--space-8) !important; color: var(--app-text-muted); }

@media (max-width: 767.98px) {
    div.dt-container .dt-search input { min-width: 0; width: 100%; margin-left: 0; }
    div.dt-container .dt-layout-row:not(.dt-layout-table) > * { width: 100%; text-align: left !important; }
}

/* Pagination */
.pagination {
    --bs-pagination-color: var(--app-text-2);
    --bs-pagination-bg: var(--app-surface);
    --bs-pagination-border-color: var(--app-border);
    --bs-pagination-hover-color: var(--app-text);
    --bs-pagination-hover-bg: var(--app-surface-3);
    --bs-pagination-hover-border-color: var(--app-border);
    --bs-pagination-active-bg: var(--app-primary);
    --bs-pagination-active-border-color: var(--app-primary);
    --bs-pagination-disabled-bg: var(--app-surface);
    --bs-pagination-disabled-color: var(--app-text-muted);
    --bs-pagination-font-size: 0.8125rem;
    --bs-pagination-padding-x: 0.7rem;
    --bs-pagination-padding-y: 0.3rem;
}

/* Select2 (bootstrap-5 theme) */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
    border-color: var(--app-border-strong);
    border-radius: var(--radius);
    background-color: var(--app-surface);
    color: var(--app-text);
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection { border-color: var(--app-primary); box-shadow: var(--focus-ring); }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { color: var(--app-text); }
.select2-container--bootstrap-5 .select2-dropdown { border-color: var(--app-border); background: var(--app-surface); color: var(--app-text); box-shadow: var(--shadow-lg); }
.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field { border-color: var(--app-border-strong); background: var(--app-surface); color: var(--app-text); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option { color: var(--app-text-2); font-size: 0.875rem; }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted { background: var(--app-primary-subtle); color: var(--app-primary-text); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--selected { background: var(--app-primary); color: #fff; }

/* Dropdowns, modals, toasts */
.dropdown-menu {
    --bs-dropdown-bg: var(--app-surface);
    --bs-dropdown-border-color: var(--app-border);
    --bs-dropdown-border-radius: var(--radius);
    --bs-dropdown-link-color: var(--app-text-2);
    --bs-dropdown-link-hover-color: var(--app-text);
    --bs-dropdown-link-hover-bg: var(--app-surface-3);
    --bs-dropdown-link-active-bg: var(--app-primary);
    --bs-dropdown-font-size: 0.875rem;
    --bs-dropdown-item-padding-y: 0.4375rem;
    --bs-dropdown-padding-x: 0.25rem;
    --bs-dropdown-item-border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.dropdown-item { display: flex; align-items: center; gap: var(--space-2); border-radius: var(--radius-sm); }
.dropdown-item > i { width: 16px; color: var(--app-text-muted); text-align: center; }
.dropdown-header { color: var(--app-text-muted); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

.modal {
    --bs-modal-bg: var(--app-surface);
    --bs-modal-border-color: var(--app-border);
    --bs-modal-border-radius: var(--radius-lg);
    --bs-modal-header-border-color: var(--app-border);
    --bs-modal-footer-border-color: var(--app-border);
    --bs-modal-padding: var(--space-5);
    --bs-modal-header-padding: var(--space-4) var(--space-5);
}

.modal-title { color: var(--app-text); font-size: 1rem; font-weight: 600; }
.modal-backdrop { --bs-backdrop-bg: #101828; --bs-backdrop-opacity: 0.5; }

.confirm-icon {
    display: inline-flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--app-primary-subtle);
    color: var(--app-primary-text);
}

.confirm-icon.is-danger { background: var(--app-danger-subtle); color: var(--app-danger-text); }
.confirm-icon.is-warning { background: var(--app-warning-subtle); color: var(--app-warning-text); }

.toast-stack {
    position: fixed;
    right: var(--space-5);
    bottom: var(--space-5);
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: min(380px, calc(100vw - 32px));
}

.app-toast {
    --bs-toast-bg: var(--app-surface);
    --bs-toast-border-color: var(--app-border);
    --bs-toast-border-radius: var(--radius);
    --bs-toast-max-width: 100%;
    --bs-toast-padding-x: var(--space-4);
    --bs-toast-padding-y: var(--space-3);
    width: 100%;
    color: var(--app-text);
    box-shadow: var(--shadow-lg);
}

.app-toast .toast-body { display: flex; align-items: flex-start; gap: var(--space-3); font-size: 0.875rem; }
.app-toast__icon { flex: 0 0 auto; margin-top: 2px; }
.app-toast__msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.app-toast .btn-close { flex: 0 0 auto; margin-top: 2px; font-size: 0.625rem; }
.app-toast.is-success .app-toast__icon { color: var(--app-success); }
.app-toast.is-danger .app-toast__icon { color: var(--app-danger); }
.app-toast.is-warning .app-toast__icon { color: var(--app-warning); }
.app-toast.is-info .app-toast__icon { color: var(--app-info); }

@media (max-width: 575.98px) {
    .toast-stack { right: var(--space-4); left: var(--space-4); bottom: var(--space-4); width: auto; }
}

/* Global AJAX progress bar */
.app-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    width: 0;
    height: 2px;
    background: var(--app-primary);
    opacity: 0;
    transition: width 0.4s var(--ease), opacity 0.3s;
}

.app-progress.is-active { width: 70%; opacity: 1; }
.app-progress.is-done { width: 100%; opacity: 0; }

/* Empty state & skeleton */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-10) var(--space-6);
    color: var(--app-text-muted);
    text-align: center;
}

.empty-state__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: var(--space-1);
    border-radius: var(--radius-lg);
    background: var(--app-surface-3);
    color: var(--app-text-muted);
    font-size: 1.125rem;
}

.empty-state__title { margin: 0; color: var(--app-text); font-size: 0.9375rem; font-weight: 600; }

.skeleton {
    display: block;
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--app-surface-3) 25%, var(--app-surface-2) 37%, var(--app-surface-3) 63%);
    background-size: 400% 100%;
    animation: skeleton 1.4s ease infinite;
}

@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* 6b. Data card: a card hosting a DataTable (or plain table) edge to edge -----
   Markup:  <div class="card data-card"> <div class="data-card__table"> <table class="table …">
   DataTables 2 builds .dt-container > .row (toolbar) / .row.dt-layout-table / .row (footer)
   inside .data-card__table; only the table row scrolls horizontally, never the toolbar. */
.data-card { overflow: hidden; }
.data-card__table { min-width: 0; }

.data-card .dt-container { font-size: 0.8125rem; }

.data-card .dt-container > .row {
    --bs-gutter-x: 0;
    margin: 0 !important;
    padding: var(--space-3) var(--space-4);
    row-gap: var(--space-2);
    align-items: center;
}

.data-card .dt-container > .row:first-child { border-bottom: 1px solid var(--app-border); }
.data-card .dt-container > .row:last-child { border-top: 1px solid var(--app-border); }
.data-card .dt-container > .row.dt-layout-table { padding: 0; }
.data-card .dt-container > .row > [class*="col"] { gap: var(--space-3); }

.data-card .dt-layout-table > .dt-layout-full {
    display: block !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* toolbar: page size + search */
.data-card .dt-length { display: flex; align-items: center; gap: var(--space-2); color: var(--app-text-muted); }
.data-card .dt-length label { margin: 0; }
.data-card .dt-length select { width: auto; min-width: 72px; min-height: 32px; padding-top: 0.25rem; padding-bottom: 0.25rem; }

.data-card .dt-search { position: relative; display: flex; align-items: center; }
.data-card .dt-search label { margin: 0 var(--space-2) 0 0; color: var(--app-text-muted); }

.data-card .dt-search input {
    width: 320px;
    min-width: 0;
    min-height: 34px;
    margin: 0 !important;
    padding-left: 32px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23667085' stroke-linecap='round' stroke-width='1.6' d='m14 14-3.2-3.2M12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0Z'/%3e%3c/svg%3e");
    background-position: 11px center;
    background-repeat: no-repeat;
    background-size: 14px;
}

.data-card .dt-info { color: var(--app-text-muted); font-variant-numeric: tabular-nums; }
.data-card .dt-paging .pagination { margin: 0; gap: 2px; }
.data-card .dt-paging .page-link { min-width: 32px; border-radius: var(--radius-sm) !important; text-align: center; }
.data-card .dt-paging .page-item:not(.active) .page-link { border-color: transparent; background: transparent; }
.data-card .dt-paging .page-item:not(.active):not(.disabled) .page-link:hover { background: var(--app-surface-3); }

/* table */
.data-card .table { margin: 0 !important; border-collapse: collapse !important; }
.data-card .table > :not(caption) > * > * { padding: 10px var(--space-3); }
.data-card .table > :not(caption) > * > :first-child { padding-left: var(--space-5); }
.data-card .table > :not(caption) > * > :last-child { padding-right: var(--space-5); }
.data-card .table > thead > tr > th { border-top: 0; }
.data-card .table > tbody > tr:last-child > * { border-bottom: 0; }
.data-card .table > tbody > tr > td:first-child { color: var(--app-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-card .table > tbody > tr > td { color: var(--app-text-2); }
.data-card .table td small,
.data-card .table td .text-muted { color: var(--app-text-muted) !important; }

/* sortable header affordance (DataTables 2) */
.data-card table.dataTable thead > tr > th.dt-orderable-asc,
.data-card table.dataTable thead > tr > th.dt-orderable-desc { cursor: pointer; }
.data-card table.dataTable thead > tr > th.dt-orderable-asc:hover,
.data-card table.dataTable thead > tr > th.dt-orderable-desc:hover { color: var(--app-text); }

/* status pills: Python-built rows emit `badge badge-*`; render them as dot pills */
.data-card .table .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid var(--app-neutral-border);
    border-radius: 999px;
    background: var(--app-neutral-subtle);
    color: var(--app-neutral-text);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.data-card .table .badge::before { content: ""; flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.data-card .table .badge.badge-success { background: var(--app-success-subtle); border-color: var(--app-success-border); color: var(--app-success-text); }
.data-card .table .badge.badge-warning { background: var(--app-warning-subtle); border-color: var(--app-warning-border); color: var(--app-warning-text); }
.data-card .table .badge.badge-danger { background: var(--app-danger-subtle); border-color: var(--app-danger-border); color: var(--app-danger-text); }
.data-card .table .badge.badge-info { background: var(--app-info-subtle); border-color: var(--app-info-border); color: var(--app-info-text); }
.badge.badge-warning.is-update,
.data-card .table .badge.badge-warning.is-update { background: var(--app-info-subtle); border-color: var(--app-info-border); color: var(--app-info-text); }
.data-card .table .badge.badge-primary { background: var(--app-primary-subtle); border-color: var(--app-primary-border); color: var(--app-primary-text); }

/* DataTables 2 paints stripes / hover as inset shadows on top of Bootstrap's: use the app tokens only */
.data-card table.table.dataTable.table-striped > tbody > tr:nth-of-type(2n+1) > *,
.data-card table.table.dataTable.table-hover > tbody > tr:hover > * { box-shadow: none; }
.data-card .table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--app-surface-3); }

/* Python-built name / IP cells arrive as "<p>Name<p><span>date</span>": collapse paragraph margins */
.data-card .table td p { margin: 0; }
.data-card .table td p:first-child { color: var(--app-text); font-weight: 500; }
.data-card .table td p > span { margin-top: 2px; color: var(--app-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* keep action / status cells on one line; the table scrolls horizontally instead */
.data-card .table td:has(> .btn),
.data-card .table td:has(> .dropdown),
.data-card .table td:has(> .badge) { white-space: nowrap; }

/* row actions */
.data-card .table td .btn { --bs-btn-font-size: 0.75rem; white-space: nowrap; }
.data-card .table td .btn.mx-1 { margin-right: 2px !important; margin-left: 2px !important; }
.data-card .table td .btn:first-child.mx-1 { margin-left: 0 !important; }

/* icon-only row buttons (edit / view / delete): quiet 28px squares, colour on the icon */
.data-card .table td .btn-xs:has(> i:only-child),
.data-card .table td .btn-sm:has(> i:only-child) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--app-border);
    border-radius: var(--radius-sm);
    background: var(--app-surface);
    font-size: 0.75rem;
}

.data-card .table td .btn-outline-primary:has(> i:only-child) { color: var(--app-primary-text); }
.data-card .table td .btn-outline-success:has(> i:only-child) { color: var(--app-success-text); }
.data-card .table td .btn-outline-danger:has(> i:only-child) { color: var(--app-danger-text); }
.data-card .table td .btn-outline-warning:has(> i:only-child) { color: var(--app-warning-text); }
.data-card .table td .btn-light:has(> i:only-child) { color: var(--app-text-2); }

.data-card .table td .btn-outline-primary:has(> i:only-child):hover { border-color: var(--app-primary-border); background: var(--app-primary-subtle); }
.data-card .table td .btn-outline-success:has(> i:only-child):hover { border-color: var(--app-success-border); background: var(--app-success-subtle); }
.data-card .table td .btn-outline-danger:has(> i:only-child):hover { border-color: var(--app-danger-border); background: var(--app-danger-subtle); }
.data-card .table td .btn-light:has(> i:only-child):hover,
.data-card .table td .btn-light[aria-expanded="true"] { background: var(--app-surface-3); color: var(--app-text); }

/* text decision buttons (Authorize / Reject / Served) */
.data-card .table td .btn-xs:not(:has(> i:only-child)) { --bs-btn-padding-x: 0.625rem; --bs-btn-padding-y: 0.25rem; }
.data-card .table td .btn-danger.btn-xs:not(:has(> i:only-child)) {
    --bs-btn-color: var(--app-danger-text);
    --bs-btn-bg: var(--app-danger-subtle);
    --bs-btn-border-color: var(--app-danger-border);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--app-danger);
    --bs-btn-hover-border-color: var(--app-danger);
}

/* Space the Computing / GPU response controls without changing table-cell layout. */
.service-response-cell > .dropdown + .btn,
.service-response-cell > .btn + .btn { margin-inline-start: 6px; }

/* Computing / GPU response menu: labels with icons, matching the user actions menu. */
.service-response-cell .service-response-menu { min-width: 218px; border-radius: 12px; }
.service-response-menu .dropdown-item { gap: .8rem; padding: .65rem .9rem; }
.service-response-menu .dropdown-item > i { width: 1rem; color: inherit; text-align: center; }

/* the ⋮ admin menu */
.data-card .table td .dropdown { display: inline-block; }
.data-card .table td .dropdown-item.text-success { color: var(--app-success-text) !important; }
.data-card .table td .dropdown-item.text-warning { color: var(--app-warning-text) !important; }
.data-card .table td .dropdown-item.text-danger { color: var(--app-danger-text) !important; }
.data-card .dropdown-menu { min-width: 160px; }

/* empty / loading states inside the table */
.data-card table.dataTable td.dt-empty { padding: 0 !important; background: transparent !important; }
.data-card table.dataTable td.dt-empty .empty-state { padding: var(--space-10) var(--space-6); }
.data-card div.dt-processing { top: 56px; margin-top: 0; }

/* processing: dim stale rows while a request is running */
.data-card .dt-container.dt-processing-active .dt-layout-table tbody { opacity: 0.5; transition: opacity 0.15s; }

@media (max-width: 767.98px) {
    .data-card .dt-container > .row { padding: var(--space-3); }
    .data-card .dt-container > .row > div { display: flex !important; flex-wrap: wrap; width: 100% !important; margin: 0 !important; }
    .data-card .dt-search { flex: 1 1 100%; width: 100%; }
    .data-card .dt-search input { width: 100%; }
    .data-card .dt-paging { width: 100%; overflow-x: auto; }
    .data-card .table > :not(caption) > * > :first-child { padding-left: var(--space-3); }
    .data-card .table > :not(caption) > * > :last-child { padding-right: var(--space-3); }
}

/* Archived services (Zoom): informational, deliberately not styled as a warning */
.archive-note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface-2);
    color: var(--app-text-muted);
    font-size: 0.8125rem;
}

.archive-note > i { margin-top: 3px; color: var(--app-text-muted); }
.archive-note p { margin: 0; }

.archive-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--app-border);
}

.archive-footer .page-link { min-width: 32px; text-align: center; }
.data-card .table-responsive { margin: 0; }

/* 6c. Service detail pages -------------------------------------------------
   <div class="detail-layout"> <div class="detail-main">cards…</div> <aside class="detail-aside">cards…</aside> */
.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: var(--space-4);
    align-items: start;
}

.detail-main,
.detail-aside { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }

@media (max-width: 991.98px) {
    .detail-layout { grid-template-columns: minmax(0, 1fr); }
}

.detail-card { margin: 0; }
.detail-card > .card-header { min-height: 52px; }
.detail-card > .card-header .card-title i { width: 16px; margin-right: var(--space-2); color: var(--app-text-muted); text-align: center; }
.detail-card > .card-body { padding: var(--space-4) var(--space-5); }

/* key / value rows */
.kv-list { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); margin: 0; }
.kv-list > dt,
.kv-list > dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--app-border); }
.kv-list > dt:last-of-type,
.kv-list > dd:last-of-type { border-bottom: 0; }
.kv-list > dt { padding-right: var(--space-3); color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 500; }
.kv-list > dd { min-width: 0; color: var(--app-text); font-size: 0.875rem; overflow-wrap: anywhere; }
.kv-list .kv-unit { margin-left: 4px; color: var(--app-text-muted); font-size: 0.8125rem; }
.kv-empty { color: var(--app-text-muted); }

.kv-list.is-stacked { grid-template-columns: minmax(0, 1fr); }
.kv-list.is-stacked > dt { padding-bottom: 0; border-bottom: 0; }
.kv-list.is-stacked > dd { padding-top: 2px; }

@media (max-width: 575.98px) {
    .kv-list { grid-template-columns: minmax(0, 1fr); }
    .kv-list > dt { padding-bottom: 0; border-bottom: 0; }
    .kv-list > dd { padding-top: 2px; }
}

.mono { font-family: var(--app-font-mono); font-size: 0.8125rem; letter-spacing: 0; }

/* long free text (additional software, descriptions, purpose) */
.detail-text { margin: 0; color: var(--app-text-2); font-size: 0.875rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* yes / no values */
.yesno { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 500; }
.yesno::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--app-border-strong); }
.yesno.is-yes { color: var(--app-success-text); }
.yesno.is-yes::before { background: var(--app-success); }
.yesno.is-no { color: var(--app-text-muted); }

/* resource tiles (computing / GPU) */
.resource-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); }

.resource-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
    box-shadow: var(--shadow-sm);
}

.resource-tile__label { display: flex; align-items: center; gap: var(--space-2); color: var(--app-text-muted); font-size: 0.75rem; font-weight: 500; }
.resource-tile__label i { width: 14px; text-align: center; }
.resource-tile__value { color: var(--app-text); font-size: 1.375rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.resource-tile__value .kv-unit { margin-left: 4px; color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; }

/* current vs requested (update requests) */
.compare-table { width: 100%; margin: 0; font-size: 0.875rem; }
.compare-table th,
.compare-table td { padding: 9px var(--space-3); border-bottom: 1px solid var(--app-border); vertical-align: top; overflow-wrap: anywhere; }
.compare-table thead th { background: var(--app-surface-2); color: var(--app-text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.compare-table tbody th { width: 30%; color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 500; }
.compare-table tbody td { width: 35%; color: var(--app-text); }
.compare-table tbody tr:last-child > * { border-bottom: 0; }
.compare-table tr.is-changed td:last-child { background: var(--app-info-subtle); color: var(--app-info-text); font-weight: 600; }
.compare-table tr.is-changed th::after { content: "changed"; display: inline-block; white-space: nowrap; margin-left: var(--space-2); padding: 0 6px; border-radius: 999px; background: var(--app-info-subtle); color: var(--app-info-text); font-size: 0.6875rem; font-weight: 600; }
.compare-table .detail-text { font-size: 0.8125rem; }
.compare-table .kv-unit { margin-left: 4px; opacity: 0.75; font-size: 0.8125rem; font-weight: 500; }

/* requester mini profile */
.person { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.person .avatar { width: 40px; height: 40px; font-size: 0.875rem; }
.person__name { display: block; color: var(--app-text); font-weight: 600; overflow-wrap: anywhere; }
.person__meta { display: block; color: var(--app-text-muted); font-size: 0.8125rem; overflow-wrap: anywhere; }

/* 6d. Request forms (new / edit / update share one template per service) ---
   <form class="request-form"> <div class="form-layout"> <div class="form-main"> .form-section cards </div>
   [<aside class="form-aside">estimate</aside>] </div> <div class="form-actions"> </form>
   Fields are crispy-forms (bootstrap4 pack) output: .form-group > label + div > control. */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.form-layout.has-aside { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
/* The tall aside spans both rows so it can't stretch row 1 and push the action bar away from the form. */
.form-layout.has-aside { grid-template-rows: auto 1fr; align-items: start; }
.form-layout.has-aside > .form-aside { grid-column: 2; grid-row: 1 / span 2; }
.form-layout.has-aside > .form-main { grid-row: 1; }
.form-layout.has-aside > .form-actions { grid-row: 2; align-self: start; }
.form-main { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; max-width: 920px; }
.form-aside { position: sticky; top: calc(var(--topbar-h) + var(--space-4)); display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }

@media (max-width: 991.98px) {
    .form-layout.has-aside { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
    .form-layout.has-aside > .form-aside, .form-layout.has-aside > .form-main, .form-layout.has-aside > .form-actions { grid-column: 1; grid-row: auto; }
    .form-aside { position: static; }
}

.form-section { margin: 0; }
.form-section > .card-header { min-height: 52px; }
.form-section > .card-header .card-title i { width: 16px; margin-right: var(--space-2); color: var(--app-text-muted); text-align: center; }
.form-section > .card-body { padding: var(--space-5); }
.form-section__hint { margin: -4px 0 var(--space-4); color: var(--app-text-muted); font-size: 0.8125rem; }

.form-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.form-grid.cols-3 { --cols: 3; }
.form-grid.cols-1 { --cols: 1; }
.form-grid > .span-all { grid-column: 1 / -1; }
.form-grid .form-group { margin-bottom: 0; }
.request-form .form-group > label { color: var(--app-text); }
.request-form .form-group .form-check { min-height: 38px; display: flex; align-items: center; gap: var(--space-2); padding-left: 0; margin: 0; }
.request-form .form-group .form-check .form-check-input { float: none; margin: 0; }
.request-form .form-group .form-check .form-check-label { margin: 0; color: var(--app-text-2); }
.request-form textarea.form-control { min-height: 96px; }
.request-form input[type="file"] { display: block; width: 100%; padding: 0.375rem 0.75rem; border: 1px solid var(--app-border-strong); border-radius: var(--radius); background: var(--app-surface); color: var(--app-text-2); font-size: 0.8125rem; }
.request-form input[type="file"]::file-selector-button { margin-right: var(--space-3); padding: 0.25rem 0.75rem; border: 0; border-radius: var(--radius-sm); background: var(--app-surface-3); color: var(--app-text); }
.request-form .invalid-feedback strong { font-weight: 500; }

@media (max-width: 767.98px) {
    .form-grid, .form-grid.cols-3 { --cols: 1; }
}

/* inline JS notes (#text / #textG "additional charge", #cpu-error …): keep ids, calmer look */
.request-form #messages,
.form-note {
    margin: var(--space-2) 0 0;
    padding: 6px 10px;
    border: 1px solid var(--app-warning-border);
    border-radius: var(--radius-sm);
    background: var(--app-warning-subtle);
    color: var(--app-warning-text);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
}

.field-limit-error { display: block; margin-top: 4px; color: var(--app-danger-text) !important; font-size: 0.75rem; font-weight: 500; }

/* terms row + action footer */
.terms-check { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.terms-check .form-check-input { margin: 0; }
.terms-check label { margin: 0; color: var(--app-text-2); }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    max-width: 920px;
    margin-top: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
    box-shadow: var(--shadow-sm);
}

/* Match the main form column; the grid gap supplies spacing above the footer. */
.form-layout > .form-actions { grid-column: 1; min-width: 0; margin-top: 0; }

.form-actions__buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }

/* error summary (non-field errors and errors of hidden fields that crispy cannot show inline) */
.error-summary { margin: 0 0 var(--space-4); max-width: 920px; }
.error-summary ul { margin: var(--space-1) 0 0; padding-left: 1.1rem; }

/* computing cost estimate (ids filled by recalcCost() in jss/events.js) */
.estimate-table { width: 100%; margin: 0; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.estimate-table th, .estimate-table td { padding: 7px 0; border-bottom: 1px solid var(--app-border); }
.estimate-table thead th { color: var(--app-text-muted); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.estimate-table td:not(:first-child), .estimate-table th:not(:first-child) { text-align: right; }
.estimate-table tfoot th { border-bottom: 0; padding-top: var(--space-3); color: var(--app-text); font-size: 0.9375rem; }

/* colocation calculator (popupTC.css .cost_bkgr_fricc, toggled by .trigger_cost in jss/events.js) */
.request-form .cost_bkgr_fricc { margin-top: var(--space-3); cursor: default; }
.request-form .cost_bkgr_fricc > div {
    position: relative;
    display: block;
    width: 100%;
    max-width: 560px;
    margin: 0;
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface-2);
    box-shadow: none;
    color: var(--app-text);
}

.request-form .cost_bkgr_fricc table { width: 100%; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.request-form .cost_bkgr_fricc th, .request-form .cost_bkgr_fricc td { padding: 6px 4px; border-bottom: 1px solid var(--app-border); }
.request-form .cost_bkgr_fricc .costpopupClose { position: absolute; top: 10px; right: 10px; width: auto; height: auto; padding: 6px; border: 0; background-color: transparent; color: inherit; line-height: 1; }
.request-form .cost_bkgr_fricc .costpopupClose:hover { background-color: transparent; }

/* service-limit warning (openLimitWarningModal() / closeLimitWarningModal() in jss/events.js) */
.limit-warning { position: fixed; inset: 0; z-index: 1080; background: var(--app-backdrop); }
.limit-warning__dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(520px, calc(100vw - 32px));
    padding: var(--space-5);
    transform: translate(-50%, -50%);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
    box-shadow: var(--shadow-lg);
}

.limit-warning__dialog h2 { margin: 0 0 var(--space-2); color: var(--app-text); font-size: 1rem; }
.limit-warning__dialog #warning_text { margin: 0 0 var(--space-4); color: var(--app-text-2); white-space: pre-line; }

/* GPU packages */
.package-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-4); }
.package-card { display: flex; flex-direction: column; height: 100%; }
.package-card .card-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: var(--space-3); }
.package-card__name { margin: 0; color: var(--app-text); font-size: 0.9375rem; font-weight: 600; }
.package-card__price { color: var(--app-text); font-size: 1.375rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.package-card__price small { color: var(--app-text-muted); font-size: 0.75rem; font-weight: 500; letter-spacing: 0; }
.package-card__specs { flex: 1 1 auto; margin: 0; padding: 0; list-style: none; font-size: 0.8125rem; }
.package-card__specs li { display: flex; justify-content: space-between; gap: var(--space-2); padding: 6px 0; border-bottom: 1px solid var(--app-border); }
.package-card__specs li span:first-child { color: var(--app-text-muted); }
.package-card__specs li span:last-child { color: var(--app-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.package-card.is-custom { border-style: dashed; }

/* legacy popupTC.css rules that fight the button / link styles inside request forms */
.request-form .trigger_cost { display: inline-flex; font-size: var(--bs-btn-font-size); font-weight: var(--bs-btn-font-weight); }
.request-form .trigger_popup_fricc { display: inline; margin: 0; font-size: inherit; font-weight: 500; }
.request-form .mail_selectBox select { font-weight: 400; pointer-events: none; }
.request-form .mail_selectBox:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; border-radius: var(--radius); }

/* T&C modal body */
.terms-list { margin: 0; padding-left: 1.1rem; color: var(--app-text-2); font-size: 0.875rem; line-height: 1.6; list-style: disc; }
.terms-list li + li { margin-top: var(--space-2); }

/* 6e. Users: activity log + filters ---------------------------------------- */
.filter-bar .form-grid { --cols: 3; }
@media (min-width: 1600px) { .filter-bar .form-grid { --cols: 5; } }
@media (max-width: 767.98px)  { .filter-bar .form-grid { --cols: 1; } }
.filter-bar .form-label { margin-bottom: 4px; }
.filter-bar__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }

.method-pill { display: inline-block; min-width: 54px; padding: 2px 8px; border: 1px solid var(--app-neutral-border); border-radius: var(--radius-sm); background: var(--app-neutral-subtle); color: var(--app-neutral-text); font-family: var(--app-font-mono); font-size: 0.6875rem; font-weight: 600; text-align: center; }
.method-pill.is-GET { border-color: var(--app-info-border); background: var(--app-info-subtle); color: var(--app-info-text); }
.method-pill.is-POST { border-color: var(--app-success-border); background: var(--app-success-subtle); color: var(--app-success-text); }
.method-pill.is-PUT, .method-pill.is-PATCH { border-color: var(--app-warning-border); background: var(--app-warning-subtle); color: var(--app-warning-text); }
.method-pill.is-DELETE { border-color: var(--app-danger-border); background: var(--app-danger-subtle); color: var(--app-danger-text); }

.http-status { font-family: var(--app-font-mono); font-size: 0.75rem; font-weight: 600; }
.http-status.is-2xx { color: var(--app-success-text); }
.http-status.is-3xx { color: var(--app-info-text); }
.http-status.is-4xx { color: var(--app-danger-text); }

.log-path { max-width: 360px; overflow: hidden; font-family: var(--app-font-mono); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.log-path .log-query { color: var(--app-text-muted); }

.top-users { margin: 0; padding: var(--space-2); list-style: none; }
.top-users__item {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: inherit;
    text-align: left;
}
.top-users__item:hover { background: var(--app-surface-3); }
.top-users__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.top-users__name { overflow: hidden; color: var(--app-text); font-size: 0.8125rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.top-users__email { display: block; overflow: hidden; color: var(--app-text-muted); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.top-users__count { flex: 0 0 auto; color: var(--app-text); font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.top-users__bar { height: 4px; margin-top: 6px; overflow: hidden; border-radius: 2px; background: var(--app-surface-3); }
.top-users__bar > span { display: block; height: 100%; border-radius: 2px; background: var(--app-primary); }

.logs-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: var(--space-4); align-items: start; }
@media (max-width: 1199.98px) { .logs-layout { grid-template-columns: minmax(0, 1fr); } }

/* 6f. Auth pages (login, sign-up, password reset) and error pages ---------- */
.auth-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-10) var(--space-4);
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(var(--app-primary-rgb), 0.10), transparent 60%),
        var(--app-bg);
}

.auth-theme { position: absolute; top: var(--space-4); right: var(--space-4); }

.auth-brand { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-bottom: var(--space-6); color: var(--app-text); }
.auth-brand:hover { color: var(--app-text); }
.auth-brand img { width: 44px; height: 44px; object-fit: contain; border-radius: var(--radius); }
[data-bs-theme="dark"] .auth-brand img { padding: 3px; background: #fff; }
.auth-brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.auth-brand__text strong { font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.01em; }
.auth-brand__text small { color: var(--app-text-muted); font-size: 0.8125rem; }

.auth-card { width: 100%; max-width: 420px; margin: 0; }
.auth-card.is-wide { max-width: 760px; }
.auth-card > .card-body { padding: var(--space-8); }
.auth-title { margin: 0 0 var(--space-1); color: var(--app-text); font-size: 1.375rem; font-weight: 650; letter-spacing: -0.02em; }
.auth-lead { margin: 0 0 var(--space-6); color: var(--app-text-muted); font-size: 0.875rem; }
.auth-card .form-group { margin-bottom: var(--space-4); }
.auth-card .btn-block-auth { width: 100%; justify-content: center; padding-top: 0.55rem; padding-bottom: 0.55rem; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.auth-row .form-label { margin: 0; }
.auth-row a { font-size: 0.8125rem; }
.auth-footer { margin: var(--space-5) 0 0; color: var(--app-text-muted); font-size: 0.875rem; text-align: center; }
.auth-legal { margin-top: var(--space-6); color: var(--app-text-muted); font-size: 0.75rem; text-align: center; }
.auth-icon { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin-bottom: var(--space-4); border-radius: 50%; background: var(--app-primary-subtle); color: var(--app-primary-text); font-size: 1.125rem; }
.auth-icon.is-success { background: var(--app-success-subtle); color: var(--app-success-text); }
.auth-icon.is-danger { background: var(--app-danger-subtle); color: var(--app-danger-text); }

/* input with leading icon (login) */
.input-icon { position: relative; }
.input-icon > i { position: absolute; top: 50%; left: 12px; color: var(--app-text-muted); font-size: 0.875rem; transform: translateY(-50%); pointer-events: none; }
.input-icon > .form-control { padding-left: 36px; }

/* captcha (django-simple-captcha) */
.auth-card img.captcha { display: block; height: 44px; margin-bottom: var(--space-2); border: 1px solid var(--app-border); border-radius: var(--radius-sm); background: #fff; }
.auth-card .captcha-refresh { margin-left: var(--space-2); font-size: 0.8125rem; font-weight: 500; cursor: pointer; }

@media (max-width: 575.98px) {
    .auth-card > .card-body { padding: var(--space-5); }
    .auth-shell { justify-content: flex-start; padding-top: var(--space-10); }
}

.error-code { margin: 0 0 var(--space-2); color: var(--app-text-muted); font-family: var(--app-font-mono); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.08em; }

/* Modals used by list pages (VM details, notes, CPanel details) */
.modal-header .btn-close { font-size: 0.75rem; }
.modal-body .form-label,
.modal-body .form-group > label { color: var(--app-text); }
.modal-footer { gap: var(--space-2); }
.modal-footer > * { margin: 0; }

/* 6g. Reports, service limit and finance -------------------------------------------- */
.filter-bar .form-grid.report-filter { --cols: 2; max-width: 720px; }
@media (max-width: 767.98px) { .filter-bar .form-grid.report-filter { --cols: 1; } }
.filter-bar .form-grid.limit-filter { --cols: 1; max-width: 480px; }
.report-sections { display: flex; flex-direction: column; gap: var(--space-5); }
.report-sections > .card { min-width: 0; max-width: 100%; }   /* let wide tables scroll inside the card */
.report-table { font-size: 0.8125rem; }
.report-table th, .report-table td { white-space: nowrap; vertical-align: middle; }
.report-sections .report-table td:nth-child(2) { white-space: normal; min-width: 300px; }   /* Organisation column on the report */
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table .mono { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 0.75rem; }
.data-card .report-table > tbody > tr > td:first-child { color: var(--app-text); font-variant-numeric: normal; }
.report-table > tfoot > tr > * { border-top: 1px solid var(--app-border-strong, var(--app-border)); border-bottom: 0; background: var(--app-surface-2); color: var(--app-text); font-weight: 600; }
.data-card .report-table > tfoot > tr > :first-child { padding-left: var(--space-5); }
#reportGenBtn.is-waiting { opacity: 0.65; }

/* Finance */
#packages-table td:nth-child(2), #members-table td:nth-child(2) { min-width: 240px; }
/* order_datatable marks a service that is not part of the order as a red "N/A" badge; it is not an error */
.data-card #packages-table .badge.badge-danger { background: var(--app-neutral-subtle); border-color: var(--app-neutral-border); color: var(--app-text-muted); }
.data-card #packages-table .badge.badge-danger::before { display: none; }
.kpi__value--text { font-size: 1.125rem; line-height: 1.35; overflow-wrap: anywhere; }
.package-search { max-width: 640px; }
.package-search__row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.package-search__row .form-control { flex: 1 1 240px; }
.record-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: end; justify-content: space-between; }

.limit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin: 0 0 var(--space-4); }
@media (max-width: 991.98px) { .limit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 479.98px) { .limit-grid { grid-template-columns: minmax(0, 1fr); } }
.limit-item { padding: var(--space-4); border: 1px solid var(--app-border); border-radius: var(--radius-lg); background: var(--app-surface-2); }
.limit-item dt { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 500; }
.limit-item dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: 0; }
.limit-item__value { color: var(--app-text); font-size: 1.75rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
.limit-item .unit { color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 500; }
.limit-item .status-pill { align-self: center; margin-left: auto; }
.limit-item.is-over { border-color: var(--app-danger-border); background: var(--app-danger-subtle); }
.limit-item.is-over .limit-item__value { color: var(--app-danger-text); }
.limit-note { display: flex; align-items: flex-start; gap: var(--space-2); color: var(--app-text-muted); font-size: 0.8125rem; }
.limit-note i { margin-top: 3px; }
.limit-note.is-danger { color: var(--app-danger-text); }

/* 6h. Finance: services, packages, orders, invoices --------------------- */

/* — Service catalogue — */
/* services/service_create_step1.html */
.svc-type-select { max-width: 480px; }
.svc-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.svc-type-card { display: flex; flex-direction: column; gap: 6px; padding: var(--space-4); border: 1px solid var(--app-border); border-radius: var(--radius-lg); background: var(--app-surface); color: var(--app-text); text-align: left; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.svc-type-card:hover { border-color: var(--app-border-strong); background: var(--app-surface-2); }
.svc-type-card:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.svc-type-card[aria-pressed="true"] { border-color: var(--app-primary); background: var(--app-primary-subtle); box-shadow: 0 0 0 1px var(--app-primary); }
.svc-type-card__name { font-weight: 600; }
.svc-type-card__desc { color: var(--app-text-muted); font-size: 0.8125rem; }
.svc-type-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; color: var(--app-text-2); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }

/* services/service_create_step2.html */
.calc-total { display: flex; align-items: center; min-height: 38px; padding: 0 var(--space-3); border: 1px dashed var(--app-border-strong); border-radius: var(--radius); background: var(--app-surface-2); color: var(--app-text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* services/service_dashboard.html */
.svc-dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
@media (max-width: 991.98px) { .svc-dash-grid { grid-template-columns: minmax(0, 1fr); } }
.svc-dash-grid > .card { min-width: 0; margin: 0; }
.svc-dash-grid--wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 991.98px) { .svc-dash-grid--wide { grid-template-columns: minmax(0, 1fr); } }
/* a KPI group whose last row stretches to the full width instead of leaving gaps */
/* Dashboard KPI grid: roomy equal-width cards (a lone last card keeps the same width, it is not stretched). */
.kpi-grid.kpi-grid--fill { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-5, 1.25rem); }
.kpi-grid.kpi-grid--fill > .kpi { min-width: 0; min-height: 132px; padding: var(--space-5, 1.25rem); gap: var(--space-2, .5rem); }
.kpi-grid.kpi-grid--fill .kpi__label { font-size: 0.8125rem; }
.kpi-grid.kpi-grid--fill .kpi__value { font-size: 1.75rem; overflow-wrap: anywhere; }
.kpi-grid.kpi-grid--fill .kpi__meta { font-size: 0.8125rem; margin-top: auto; }
.dash-heading { margin: var(--space-6) 0 var(--space-3); color: var(--app-text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.dash-heading:first-child { margin-top: 0; }
a.kpi--link { color: inherit; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease; }
a.kpi--link:hover { border-color: var(--app-primary-border); box-shadow: var(--shadow-sm, 0 1px 2px rgba(16, 24, 40, .06)); }
a.kpi--link:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.kpi.is-alert { border-color: var(--app-danger-border); background: var(--app-danger-subtle); }
.kpi.is-alert .kpi__value { color: var(--app-danger-text); }
.kpi-dot { font-size: 0.5rem; vertical-align: middle; color: var(--app-text-muted); }
.kpi-dot.is-active { color: var(--app-success); }
.kpi-dot.is-pending { color: var(--app-warning); }
.kpi-dot.is-approved { color: var(--app-info); }
.kpi-dot.is-suspended, .kpi-dot.is-cancelled { color: var(--app-danger); }
.report-table tr.is-overdue > td { background: var(--app-warning-subtle); }

/* services/service_delete.html */
.svc-delete { max-width: 640px; }
.svc-delete__head { display: flex; align-items: center; gap: var(--space-3); }
.svc-delete__head .auth-icon { margin: 0; flex: none; }
.svc-delete > .form-actions { margin: 0; border-top: 1px solid var(--app-border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* services/service_list.html */
.filter-bar .form-grid.svc-filter { --cols: 4; }
@media (max-width: 1199.98px) { .filter-bar .form-grid.svc-filter { --cols: 2; } }
@media (max-width: 575.98px) { .filter-bar .form-grid.svc-filter { --cols: 1; } }

/* — Packages (services app) — */
/* services/packages/package_detail.html */
.pkg-items__service { min-width: 160px; white-space: normal !important; }
.pkg-items__notes { min-width: 90px; max-width: 200px; white-space: normal !important; }
.pkg-items .pkg-custom { display: table; margin: 2px 0 0 auto; }
.pkg-props { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 2px; font-size: 0.75rem; }
.pkg-props__item { white-space: nowrap; }
.pkg-custom { padding: 0 6px; font-size: 0.6875rem; }
.pkg-custom::before { display: none; }
.pkg-summary__list { margin: 0 0 var(--space-3); }
.pkg-summary__list > div { display: flex; justify-content: space-between; gap: var(--space-3); padding: 8px 0; border-bottom: 1px solid var(--app-border); }
.pkg-summary__list dt { color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 500; }
.pkg-summary__list dd { margin: 0; color: var(--app-text); font-variant-numeric: tabular-nums; }
.pkg-summary__total { border-bottom: 0 !important; padding-top: 12px !important; }
.pkg-summary__total dt { color: var(--app-text); font-size: 0.9375rem; font-weight: 600; }
.pkg-summary__total dd { color: var(--app-success-text); font-size: 1.375rem; font-weight: 700; }
@media (min-width: 992px) { .pkg-summary { position: sticky; top: calc(var(--topbar-h, 60px) + var(--space-4)); } }
.pkg-config { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--app-border); }
.pkg-config__title { margin: 0 0 var(--space-3); color: var(--app-text); font-size: 0.9375rem; font-weight: 600; }
.pkg-autofill { margin-bottom: var(--space-4); padding: var(--space-4); border: 1px solid var(--app-info-border); border-radius: var(--radius-lg); background: var(--app-info-subtle); }
.pkg-autofill__title { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); color: var(--app-info-text); font-size: 0.875rem; font-weight: 600; }
.pkg-config .configuration-set { margin-bottom: var(--space-4); }
.pkg-config .configuration-set.is-boxed { padding: var(--space-4); border: 1px solid var(--app-border); border-radius: var(--radius-lg); background: var(--app-surface-2); }
.pkg-config .configuration-set__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.pkg-config .configuration-set__head h4 { margin: 0; color: var(--app-text); font-size: 0.875rem; font-weight: 600; }
.pkg-config .configuration-set .config-field { margin-bottom: var(--space-3); }
.pkg-item-total { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-5); padding: var(--space-3) var(--space-4); border: 1px solid var(--app-border); border-radius: var(--radius); background: var(--app-surface-2); }
.pkg-item-total strong { color: var(--app-text); font-size: 1.125rem; font-variant-numeric: tabular-nums; }

/* services/packages/package_list.html */
.pkg-table__name { min-width: 240px; white-space: normal !important; }
.pkg-table__name a { color: var(--app-text); text-decoration: none; }
.pkg-table__name a:hover { color: var(--app-primary); text-decoration: underline; }

/* — Orders — */
/* services/order_create.html */
.order-type-list { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.order-type-list li { display: flex; flex-direction: column; gap: 4px; padding: var(--space-3); border: 1px solid var(--app-border); border-radius: var(--radius); background: var(--app-surface-2); }
.order-type-list__name { color: var(--app-text); font-size: 0.875rem; font-weight: 600; }
.order-type-list__desc { color: var(--app-text-muted); font-size: 0.8125rem; }
.order-type-list__meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: 2px; }
.order-steps { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.order-steps li { display: flex; align-items: center; gap: var(--space-3); color: var(--app-text-muted); font-size: 0.875rem; }
.order-steps li.is-current { color: var(--app-text); font-weight: 600; }
.order-steps__num { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--app-surface-3); color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 600; }
.order-steps li.is-current .order-steps__num { background: var(--app-primary); color: #fff; }

/* services/order_detail.html */
.kpi__value--pill .status-pill { font-size: 0.875rem; }
.report-table .num-sub,
.data-card .num-sub { display: block; color: var(--app-text-muted); font-size: 0.75rem; }
.report-table td.order-item-name { white-space: normal; min-width: 160px; }
.detail-subhead { margin: var(--space-4) 0 var(--space-2); color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* services/order_edit.html */
.order-readonly select:disabled { background-color: var(--app-surface-2); color: var(--app-text-2); cursor: not-allowed; opacity: 1; }

/* services/order_list.html */
.filter-bar .form-grid.order-filter { --cols: 3; }
@media (min-width: 1400px) { .filter-bar .form-grid.order-filter { --cols: 6; } }
@media (max-width: 767.98px) { .filter-bar .form-grid.order-filter { --cols: 1; } }
.form-grid > .span-2 { grid-column: span 2; }
@media (max-width: 767.98px) { .form-grid > .span-2 { grid-column: 1 / -1; } }
.order-table__title { max-width: 260px; }
.order-table .order-table__uni { white-space: normal; min-width: 200px; }

/* — Order items (add / edit) — */
/* services/_partials_orders/item_styles.html */
.item-form .form-text { font-size: 0.75rem; }
.item-form .item-subtotal { font-weight: 600; font-variant-numeric: tabular-nums; }
.item-options { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.item-options .form-check { margin: 0; }
.item-loader { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) 0; color: var(--app-text-muted); font-size: 0.8125rem; }

/* configuration sets generated by the script */
.configurations { display: flex; flex-direction: column; gap: var(--space-4); }
.item-form .configuration-set { padding: var(--space-4); border: 1px solid var(--app-border); border-radius: var(--radius-lg); background: var(--app-surface-2); }
.item-form .configuration-set__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.item-form .configuration-set__head h6 { margin: 0; color: var(--app-text); font-size: 0.875rem; font-weight: 600; }
.item-form .configuration-set .form-label { font-size: 0.8125rem; }
.item-form .configuration-set input[readonly] { background: var(--app-surface-3); color: var(--app-text-2); }
.item-form .configuration-set .form-check { display: flex; align-items: center; gap: var(--space-2); min-height: 38px; margin: 0; padding-left: 0; }
.item-form .configuration-set .form-check .form-check-input { float: none; margin: 0; }

/* price summary table rendered by shoPriceSummary() */
.price-summary { width: 100%; margin: 0; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.price-summary td { padding: 8px 0; border-bottom: 1px solid var(--app-border); color: var(--app-text-2); }
.price-summary td:last-child { text-align: right; color: var(--app-text); }
.price-summary tr.is-total td { border-bottom: 0; padding-top: var(--space-3); color: var(--app-text); font-size: 1rem; font-weight: 600; }

/* service type tiles (add page) */
.service-type-list { display: flex; flex-direction: column; gap: var(--space-2); }
.service-type-card { padding: var(--space-3); border: 1px solid var(--app-border); border-radius: var(--radius); background: var(--app-surface); cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.service-type-card:hover { border-color: var(--app-primary-border); }
.service-type-card:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.service-type-card.border-primary { border-color: var(--app-primary) !important; box-shadow: inset 0 0 0 1px var(--app-primary); }
.service-type-card.bg-light { background: var(--app-primary-subtle) !important; }
.service-type-card__name { margin: 0 0 2px; color: var(--app-text); font-size: 0.875rem; font-weight: 600; }
.service-type-card__desc { margin: 0 0 var(--space-2); color: var(--app-text-muted); font-size: 0.75rem; }
.service-type-card__meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.service-type-card__price { color: var(--app-text); font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* usage history tables rendered by the script */
.item-history { font-size: 0.8125rem; }
.item-history .table { margin: 0; font-size: 0.75rem; }
.item-history .table th { color: var(--app-text-muted); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; }
.item-history .history-totals { margin-top: var(--space-3); padding: var(--space-3); border: 1px solid var(--app-info-border); border-radius: var(--radius); background: var(--app-info-subtle); color: var(--app-info-text); }
.item-history .history-totals h6 { margin: 0 0 var(--space-2); font-size: 0.8125rem; font-weight: 600; }
.item-history .table th, .item-history .table td { white-space: nowrap; }
.form-aside .item-history .table-responsive { max-height: 360px; overflow: auto; }
.form-aside .item-history .history-totals .row > [class*="col-"] { flex: 0 0 50%; max-width: 50%; }

/* edit page: locked service type and configuration count */
.locked-type { padding: var(--space-3); border: 1px dashed var(--app-border-strong); border-radius: var(--radius); background: var(--app-surface-2); }
.locked-type h3 { margin: 0 0 2px; font-size: 0.875rem; font-weight: 600; }
.config-summary { padding: var(--space-3); border: 1px solid var(--app-info-border); border-radius: var(--radius); background: var(--app-info-subtle); color: var(--app-info-text); font-size: 0.8125rem; }

/* — Invoices (services app) — */
/* services/create_invoice.html */
.invoice-pick .invoice-pick__check { width: 44px; text-align: center; }
.invoice-pick thead th { white-space: normal; vertical-align: bottom; }
.invoice-pick > :not(caption) > * > * { padding-left: 10px; padding-right: 10px; }
.invoice-pick td:nth-child(2) { white-space: normal; min-width: 160px; }
.invoice-pick .item-checkbox, .invoice-pick #selectAll { width: 1.1rem; height: 1.1rem; margin: 0; cursor: pointer; }
.invoice-pick .clickable-cell { cursor: pointer; }
.invoice-pick tbody tr:has(.item-checkbox:checked) > * { background: var(--app-primary-subtle); }
.invoice-pick tfoot th, .invoice-pick tfoot td { border-top: 1px solid var(--app-border); background: var(--app-surface-2); color: var(--app-text); font-weight: 600; }
.invoice-half { display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 6px; }
.invoice-period { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--app-surface-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.invoice-period > div { display: flex; flex-direction: column; gap: 2px; }
.invoice-period__label { color: var(--app-text-muted); font-size: 0.75rem; font-weight: 500; }
@media (max-width: 575.98px) { .invoice-period { grid-template-columns: minmax(0, 1fr); } }
#calculationBreakdown { max-height: 240px; overflow-y: auto; }
#calculationBreakdown .calc-row { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; border-bottom: 1px solid var(--app-border); }
#calculationBreakdown .calc-row:last-child { border-bottom: 0; }
.invoice-totals { width: 100%; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.invoice-totals th { padding: 6px 0; color: var(--app-text-muted); font-weight: 500; }
.invoice-totals td { padding: 6px 0; color: var(--app-text); text-align: right; white-space: nowrap; }
.invoice-totals__grand > * { padding-top: 10px !important; border-top: 1px solid var(--app-border); color: var(--app-text) !important; font-size: 1rem; font-weight: 600 !important; }
.invoice-logic li + li { margin-top: 4px; }
.invoice-existing { margin: 0; padding: 0; list-style: none; }
.invoice-existing li + li { border-top: 1px solid var(--app-border); }
.invoice-existing a { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3) var(--space-4); color: inherit; text-decoration: none; }
.invoice-existing a:hover { background: var(--app-surface-3); }
.invoice-existing__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }

/* services/invoice_delete.html */
.confirm-card { max-width: 640px; }
.confirm-card .card-body { padding: var(--space-6); }
.confirm-card__head { display: flex; gap: var(--space-4); align-items: flex-start; margin-bottom: var(--space-5); }
.confirm-card__icon { display: inline-flex; flex: 0 0 44px; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: var(--app-neutral-subtle); color: var(--app-text-muted); font-size: 1.125rem; }
.confirm-card__icon.is-danger { background: var(--app-danger-subtle); color: var(--app-danger-text); }
.confirm-card__icon.is-warning { background: var(--app-warning-subtle); color: var(--app-warning-text); }
.confirm-card__title { margin: 0 0 4px; color: var(--app-text); font-size: 1.0625rem; font-weight: 600; }
.confirm-card__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--app-border); }
@media (max-width: 575.98px) { .confirm-card .card-body { padding: var(--space-4); } }

/* services/invoice_detail.html */
.invoice-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.page-actions:has(> .invoice-actions) { min-width: 0; max-width: 100%; flex-wrap: wrap; }
.page-actions > .invoice-actions { max-width: 100%; }
.invoice-kpis .kpi__meta .status-pill { vertical-align: middle; }
.invoice-sheet .card-body { padding: var(--space-6); }
.invoice-sheet__head { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-start; justify-content: space-between; padding-bottom: var(--space-4); margin-bottom: var(--space-5); border-bottom: 1px solid var(--app-border); }
.invoice-sheet__kicker { margin: 0; color: var(--app-text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.invoice-sheet__number { margin: 2px 0 0; color: var(--app-text); font-size: 1.5rem; font-weight: 600; }
.invoice-sheet__pills { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.invoice-sheet__parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); margin-bottom: var(--space-6); }
@media (max-width: 767.98px) { .invoice-sheet__parties { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); } .invoice-sheet .card-body { padding: var(--space-4); } }
.invoice-sheet__parties address { color: var(--app-text-2); font-size: 0.875rem; line-height: 1.6; }
.invoice-sheet__label { margin: 0 0 var(--space-2); color: var(--app-text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.invoice-sheet__section { margin: var(--space-6) 0 var(--space-3); color: var(--app-text); font-size: 0.9375rem; font-weight: 600; }
.invoice-sheet .table-responsive { border: 1px solid var(--app-border); border-radius: var(--radius); }
.invoice-sheet .report-table { margin: 0; }
.invoice-sheet .report-table > :not(caption) > * > * { padding: 9px var(--space-3); }
.invoice-items__desc { white-space: normal !important; min-width: 180px; }
.invoice-sheet .report-table thead th { white-space: normal; vertical-align: bottom; }
.invoice-sheet__foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); gap: var(--space-6); margin-top: var(--space-5); }
@media (max-width: 767.98px) { .invoice-sheet__foot { grid-template-columns: minmax(0, 1fr); } }
.invoice-totals__due > * { color: var(--app-warning-text) !important; font-weight: 600 !important; }
.invoice-summary__item + .invoice-summary__item { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--app-border); }
.invoice-vm tbody th { color: var(--app-text); font-weight: 600; }
.erp-voucher { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); margin-bottom: var(--space-3); }
@media (max-width: 575.98px) { .erp-voucher { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.erp-particular { white-space: normal !important; min-width: 220px; }

@media print {
    body.invoice-print .page-header, body.invoice-print .invoice-actions, body.invoice-print .invoice-kpis, body.invoice-print .modal, body.invoice-print .modal-backdrop { display: none !important; }
    body.invoice-print .invoice-sheet { border: 0 !important; }
    body.invoice-print .invoice-sheet .card-body { padding: 0; }
    body.invoice-print .invoice-sheet .table-responsive { overflow: visible; border-color: #000; }
    body.invoice-print .invoice-sheet .report-table th, body.invoice-print .invoice-sheet .report-table td { border-color: #999 !important; color: #000 !important; white-space: normal !important; }
    body.invoice-print .invoice-summary { break-before: page; }
    body.invoice-print .status-pill { border: 1px solid #000 !important; background: none !important; color: #000 !important; }
    body.invoice-print a[href] { color: #000; text-decoration: none; }
}

/* services/invoice_list.html */
.filter-bar .form-grid.invoice-filter { --cols: 4; }
@media (max-width: 1199.98px) { .filter-bar .form-grid.invoice-filter { --cols: 2; } }
@media (max-width: 575.98px)  { .filter-bar .form-grid.invoice-filter { --cols: 1; } }
.invoice-filter > .span-2 { grid-column: span 2; }
@media (max-width: 575.98px)  { .invoice-filter > .span-2 { grid-column: auto; } }
.invoice-filter__check { display: flex; align-items: flex-end; padding-bottom: 6px; }
.invoice-table__org { white-space: normal !important; min-width: 150px; }
.invoice-pager { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; background: transparent; }

/* DataTable toolbar filters (orders / invoices lists) */
.dt-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-right: var(--space-3); }
/* every toolbar filter, the university one included, is the same small select */
/* the searchable university filter (Select2) is sized and rounded exactly like the plain selects beside it */
.dt-filters .select2-container--bootstrap-5 .select2-selection--single { display: flex; align-items: center; min-height: 38px; border-radius: var(--radius); }
.dt-filters .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { padding: 0; line-height: 21px; }
.dt-filters .select2-container { flex: none; }
.dt-filters .form-control { width: auto; min-width: 140px; max-width: 160px; }
.dt-filters .form-select { width: auto; min-width: 130px; max-width: 200px; text-overflow: ellipsis; }
@media (max-width: 767.98px) { .dt-filters { width: 100%; margin: 0 0 var(--space-2); } .dt-filters .form-select { flex: 1 1 140px; max-width: none; } }
/* long organisation names stay on one line in the list tables; the full name is the tooltip */
.data-card .cell-truncate { display: inline-block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* layout fixes after merge (1280px): */
.pill-stack { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.invoice-sheet .report-table td:not(.num) { white-space: normal; }
.invoice-sheet .report-table td:nth-child(2), .invoice-sheet .report-table td:nth-child(3) { min-width: 96px; }

/* — Status › Invoices (legacy) — */
/* invoice/invoiceList.html */
.inv-uni { min-width: 150px; white-space: normal !important; }
/* FilterForm widgets carry an inline height:45px; match the other filter inputs */
#invoiceFilterForm .form-control { height: auto !important; }

/* invoice/updateInvoice.html */
.invoice-update-form .form-control[readonly] { background: var(--app-surface-2); color: var(--app-text-muted); cursor: default; }

/* 7. Dashboard ------------------------------------------------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

/* 3 request tiles + 1 grouped resources card */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 2.4fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

@media (max-width: 1439.98px) {
    .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpi-row > .kpi-resources { grid-column: 1 / -1; }
}

@media (max-width: 575.98px) {
    .kpi-row { grid-template-columns: minmax(0, 1fr); }
}

.kpi-resources { padding: 0; }
.kpi-resources .kpi__label { padding: var(--space-4) var(--space-4) 0; }

.kpi-resources__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 1 1 auto;
    padding: var(--space-2) 0 var(--space-4);
}

.kpi-resources__item { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--space-4); }
.kpi-resources__item + .kpi-resources__item { border-left: 1px solid var(--app-border); }
.kpi-resources__item .kpi__value { font-size: 1.25rem; }
.kpi-resources__item .unit,
.kpi__value .unit { color: var(--app-text-muted); font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; }

@media (max-width: 575.98px) {
    .kpi-resources__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--space-4); }
    .kpi-resources__item:nth-child(3) { border-left: 0; }
}

.kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-4);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
    box-shadow: var(--shadow-sm);
}

.kpi__label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--app-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.kpi__label i { width: 14px; font-size: 0.75rem; text-align: center; }
.kpi__value { color: var(--app-text); font-size: 1.5rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.kpi__meta { color: var(--app-text-muted); font-size: 0.75rem; }
.kpi.is-attention { border-color: var(--app-warning-border); background: linear-gradient(0deg, var(--app-warning-subtle), var(--app-warning-subtle)), var(--app-surface); }
.kpi.is-attention .kpi__label { color: var(--app-warning-text); }
.kpi.is-info.is-attention { border-color: var(--app-info-border); background: linear-gradient(0deg, var(--app-info-subtle), var(--app-info-subtle)), var(--app-surface); }
.kpi.is-info.is-attention .kpi__label { color: var(--app-info-text); }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.section-title { margin: 0; color: var(--app-text); font-size: 0.9375rem; font-weight: 600; }
.section-hint { color: var(--app-text-muted); font-size: 0.8125rem; }

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.service-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.service-card:hover,
.service-card:focus-within { border-color: var(--app-border-strong); box-shadow: var(--shadow); }
.service-card.has-pending { border-color: var(--app-warning-border); }
.service-card.has-pending::after {
    content: "";
    position: absolute;
    left: -1px;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--app-warning);
}

.service-card__head { display: flex; align-items: center; gap: var(--space-3); }

/* Retired service card (Zoom): readable, but visibly not an active/actionable service */
.service-card.is-retired { border-style: dashed; background: var(--app-surface-2); box-shadow: none; }
.service-card.is-retired .service-card__icon { background: var(--app-neutral-subtle); color: var(--app-text-muted); }
.service-card.is-retired .service-card__stat { background: var(--app-surface); }
.service-card.is-retired .service-card__stat.is-archived dd { color: var(--app-text-muted); }

.service-card__icon {
    display: inline-flex;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--app-primary-subtle);
    color: var(--app-primary-text);
    font-size: 0.9375rem;
}

.service-card__title { margin: 0; color: var(--app-text); font-size: 0.875rem; font-weight: 600; }

/* whole card is clickable via the title link */
.service-card__title a { color: inherit; }
.service-card__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.service-card__title a:focus-visible { outline: none; }
.service-card:has(.service-card__title a:focus-visible) { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.service-card__go { margin-left: auto; color: var(--app-text-muted); font-size: 0.75rem; transition: transform 0.15s, color 0.15s; }
.service-card:hover .service-card__go { color: var(--app-text); transform: translateX(2px); }

.service-card__stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin: 0; }
.service-card__stat { padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--app-surface-2); }
.service-card__stat dt { color: var(--app-text-muted); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.service-card__stat dd { margin: 0; color: var(--app-text); font-size: 1.125rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.service-card__stat.is-pending dd { color: var(--app-warning-text); }

.service-card__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: 22px; color: var(--app-text-muted); font-size: 0.75rem; }
.service-card__res { display: inline-flex; gap: var(--space-3); font-variant-numeric: tabular-nums; }
.service-card__res span { white-space: nowrap; }
.service-card__res b { color: var(--app-text-2); font-weight: 600; }

.dash-panels {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.85fr);
    gap: var(--space-4);
}

@media (max-width: 1439.98px) {
    .dash-panels { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .dash-panels > .dash-attention { grid-column: 1 / -1; }
}

@media (max-width: 767.98px) {
    .dash-panels { grid-template-columns: minmax(0, 1fr); }
}

.chart-box { position: relative; height: 280px; }

.chart-legend { display: flex; flex-wrap: wrap; margin-bottom: var(--space-2) !important; gap: var(--space-4); margin: 0; padding: 0; list-style: none; color: var(--app-text-2); font-size: 0.75rem; }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

.attention-list { margin: 0; padding: 0; list-style: none; }
.attention-list li + li { border-top: 1px solid var(--app-border); }

.attention-list a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    color: var(--app-text-2);
}

.attention-list a:hover { background: var(--app-surface-2); color: var(--app-text); }
.attention-list .attention-name { flex: 1 1 auto; font-weight: 500; }
.attention-list .attention-pills { display: inline-flex; gap: var(--space-1); }

/* 8. Bootstrap 4 compatibility → moved to static/css/bs4-compat.css (loaded after this file) */

/* 9. Legacy srtdash content classes (only pages still extending dashboard/main.html) */
/* element-level specificity (0,0,1) replicating srtdash typography.css: beats Bootstrap reboot by
   source order, while any component class (.pagination, .dropdown-menu, .list-*) still wins */
:where(.legacy-page .app-content) ul { margin: 0; padding: 0; list-style: none; }
:where(.legacy-page .app-content) ol { margin: 0; padding-left: 1.25rem; }
:where(.legacy-page .app-content) p { margin-bottom: 0; line-height: 1.6; }

.main-content-inner { padding: 0; }
.main-content-inner > .row + .row,
.main-content-inner > .card + .card { margin-top: var(--space-4); }

.legacy-page .app-content .card { margin-bottom: var(--space-4); }
.legacy-page .app-content .card.mt-5 { margin-top: 0 !important; }

.header-title,
.tab-title {
    margin-bottom: var(--space-4);
    color: var(--app-text);
    font-size: 0.9375rem;
    font-weight: 600;
    text-transform: none;
}

.search-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.search-box form { position: relative; }
.search-box input { width: 300px; max-width: 100%; }

.page-title-area {
    position: relative;
    margin-bottom: var(--space-5);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
}

.page-title-area .page-title { font-size: 1.125rem; }
ul.breadcrumbs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-1) 0 0; padding: 0; list-style: none; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--app-text-muted); font-size: 0.8125rem; }
.breadcrumbs li + li::before { content: "/"; color: var(--app-border-strong); }
.breadcrumbs li a { color: var(--app-primary-text); }
.breadcrumbs li span { color: var(--app-text-muted); }

table.dbkit-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
table.dbkit-table tr { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; padding: 0 var(--space-4); border: 1px solid var(--app-border); border-radius: var(--radius); background: var(--app-surface-2); }
table.dbkit-table tr:hover { border-color: var(--app-border-strong); }
table.dbkit-table tr td { min-width: 141px; padding: var(--space-3) var(--space-2); color: var(--app-text-2); font-size: 0.875rem; }
table.dbkit-table .heading-td td { color: var(--app-text-muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }

.seo-fact { border: 1px solid var(--app-border); border-left-width: 3px; border-radius: var(--radius-lg); background: var(--app-surface); }
.seo-fact.sbg1 { border-left-color: var(--app-primary); }
.seo-fact.sbg2 { border-left-color: var(--app-info); }
.seo-fact.sbg3 { border-left-color: var(--app-success); }
.seo-fact.sbg4 { border-left-color: var(--app-warning); }
.seo-fact h2 { margin: 0; color: var(--app-text); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.seofct-icon { color: var(--app-text-muted); font-size: 0.875rem; font-weight: 500; }
.seofct-icon i { margin-right: var(--space-3); color: var(--app-text-muted); font-size: 1.5rem; vertical-align: middle; }

.pagination_area ul { display: flex; gap: var(--space-1); }
.pagination_area ul li a { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--app-border); border-radius: var(--radius); color: var(--app-text-2); }
.pagination_area ul li a:hover,
.pagination_area ul li.active a { border-color: var(--app-primary); background: var(--app-primary); color: #fff; }

.pricing-list { overflow: hidden; border: 1px solid var(--app-border); border-radius: var(--radius-lg); background: var(--app-surface); text-align: center; }
.prc-head h4 { margin: 0; padding: var(--space-5); background: var(--app-primary); color: #fff; font-weight: 600; }
.prc-list { padding: var(--space-5); }
.prc-list li a { display: block; margin: var(--space-3) 0; color: var(--app-text-2); font-size: 0.875rem; }
.prc-list li.bold { font-weight: 600; }

.datatable-primary thead { background: var(--app-surface-2); color: var(--app-text-muted); }

/* Mail "users" multi-select (toggled by mail_showCheckboxes() in jss/events.js) */
.mail_selectBox { position: relative; }
.mail_selectBox select { width: 100%; font-weight: 600; }
.mail_overSelect { position: absolute; inset: 0; }
#mail_checkboxes { display: none; padding: var(--space-2) var(--space-3); border: 1px solid var(--app-border); border-radius: 0 0 var(--radius) var(--radius); background: var(--app-surface); }
#mail_checkboxes label { display: block; font-weight: 600; }

@media (min-width: 1200px) and (max-width: 1440px) {
    .col-ml-6 { flex: 0 0 50%; max-width: 50%; }
}

@media (min-width: 992px) and (max-width: 1364px) {
    .col-mdl-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
}

/* Legacy popups (popupTC.css) in dark mode */
[data-bs-theme="dark"] .hover_bkgr_fricc > div,
[data-bs-theme="dark"] .cost_bkgr_fricc > div { background-color: var(--app-surface-2); border-color: var(--app-border); box-shadow: var(--shadow-lg); color: var(--app-text); }

/* 10. Print / reduced motion ----------------------------------------------- */
@media print {
    .app-sidebar, .app-sidebar-backdrop, .app-topbar, .page-actions, .toast-stack, .app-progress, .skip-link { display: none !important; }
    .app-main { padding-left: 0 !important; }
    .app-container { max-width: none; padding: 0; }
    body { background: #fff; color: #000; }
    .card, .kpi, .service-card { box-shadow: none !important; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* invoicing monitor: links inside the tables underline on hover / keyboard focus */
.monitor-links a:not(.btn):hover,
.monitor-links a:not(.btn):focus-visible { text-decoration: underline; }
