/* ==========================================================================
   Application stylesheet

   One set of tokens and components for every page. Brand colours arrive from
   DojoonAMLPlaform/server_theme.py through the inline block in base.html;
   the values here are the fallbacks.

   Rule of the design: the brand lives in the chrome (top bar, navigation,
   focus rings). Page content stays neutral, so red, orange and green always
   mean risk and never decoration.

   Contents
     1. Tokens            5. Buttons          9. Status and risk
     2. Base              6. Forms           10. Page furniture
     3. Layout chrome     7. Cards           11. Legacy class names
     4. Typography        8. Tables          12. Print
   ========================================================================== */

/* 1. Tokens
   ========================================================================== */
:root {
    /* Brand */
    --brand: #efb727;
    --brand-ink: #8a6a16;
    --brand-tint: #fdf5dd;
    --brand-focus: rgba(239, 183, 39, 0.45);
    --primary: #1f2328;
    --primary-dark: #15181c;
    --primary-light: #3b4148;
    --primary-lighter: #555c65;

    /* Ink and surfaces */
    --ink-900: #1f2328;
    --ink-700: #3b4148;
    --ink-600: #555c65;
    --ink-500: #6f7780;
    --ink-400: #949aa2;
    --ink-300: #b9bec4;
    --line-strong: #d3d6da;
    --line: #e4e6e9;
    --line-soft: #eff0f2;
    --surface: #ffffff;
    --surface-sunken: #f8f8f7;
    --canvas: #f4f4f2;

    /* Status. Each has a solid, a text colour for tinted backgrounds, a tint and a line.
       The three risk solids (success, warning, danger) stay distinguishable under
       colour-vision deficiency; check any change with a palette validator. */
    --danger: #c0352b;
    --danger-ink: #9b2219;
    --danger-bg: #fcecea;
    --danger-line: #f1c1bc;
    --warning: #e9a23b;
    --warning-ink: #8f4c07;
    --warning-bg: #fff1e0;
    --warning-line: #f4cfa2;
    --success: #0f7a55;
    --success-ink: #166a39;
    --success-bg: #e7f5ec;
    --success-line: #b5dfc5;
    --info: #2467b0;
    --info-ink: #1b4f88;
    --info-bg: #e9f1fb;
    --info-line: #bcd3ee;
    --neutral-ink: #555c65;
    --neutral-bg: #eff0f2;
    --neutral-line: #d9dcdf;

    /* Chrome */
    --header-bg: #efb727;
    --header-text: #1f2328;
    --header-text-soft: #4f4a35;
    --header-border: #efb727;
    --header-hover-bg: rgba(31, 35, 40, 0.08);
    --sidebar-bg: #ffffff;
    --sidebar-text: #1f2328;
    --sidebar-text-soft: #6b7079;
    --sidebar-border: #e4e6e9;
    --sidebar-hover-bg: #f4f4f5;
    --sidebar-active-bg: #fdf5dd;
    --sidebar-hover-text: #1f2328;
    --sidebar-active-text: #1f2328;
    --sidebar-active-indicator: #efb727;
    --sidebar-scroll-thumb: #cfd2d6;
    --sidebar-scroll-thumb-hover: #a5a9ae;
    --btn-primary-bg: #1f2328;
    --btn-primary-text: #ffffff;
    --btn-primary-hover-bg: #3b4148;
    --btn-primary-hover-text: #ffffff;
    --btn-accent-bg: #efb727;
    --btn-accent-text: #1f2328;
    --btn-accent-hover-bg: #dca824;
    --btn-accent-hover-text: #1f2328;

    /* Type */
    --font-sans: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system,
                 "Segoe UI", Tahoma, sans-serif;
    --text-xs: 0.75rem;     /* 12px */
    --text-sm: 0.8125rem;   /* 13px */
    --text-base: 0.875rem;  /* 14px */
    --text-md: 0.9375rem;   /* 15px */
    --text-lg: 1.125rem;    /* 18px */
    --text-xl: 1.375rem;    /* 22px */
    --text-2xl: 1.75rem;    /* 28px */

    /* Shape and depth */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.06);
    --shadow-md: 0 4px 12px rgba(31, 35, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(31, 35, 40, 0.14);
    --shadow-xl: 0 12px 32px rgba(31, 35, 40, 0.14);

    /* Layout */
    --sidebar-width: 252px;
    --navbar-height: 60px;

    /* Names used by older page styles, mapped onto the tokens above. */
    --accent-gold: var(--brand);
    --accent-bronze: var(--brand-ink);
    --secondary: var(--ink-500);
    --light: var(--surface-sunken);
    --dark: var(--ink-900);
    --bg-cream: var(--canvas);
    --bg-light: var(--surface-sunken);
    --bg-white: var(--surface);
    --text-dark: var(--ink-900);
    --text-medium: var(--ink-600);
    --text-light: var(--ink-500);
    --border-color: var(--line);
    --border-light: var(--line-soft);
    --gold-10: var(--brand-tint);
    --gold-15: var(--brand-tint);
    --gold-20: var(--brand-focus);
    --brown-10: var(--line-soft);
    --brown-15: var(--line);
    --brown-20: var(--line-strong);
    --white-80: rgba(255, 255, 255, 0.8);
    --white-60: rgba(255, 255, 255, 0.6);
    --white-20: rgba(255, 255, 255, 0.2);
    --white-15: rgba(255, 255, 255, 0.15);
    --white-10: rgba(255, 255, 255, 0.1);

    /* Bootstrap hooks */
    --bs-body-font-family: var(--font-sans);
    --bs-body-font-size: var(--text-base);
    --bs-body-color: var(--ink-900);
    --bs-body-bg: var(--canvas);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius);
    --bs-link-color: var(--info-ink);
    --bs-link-color-rgb: 27, 79, 136;
    --bs-link-hover-color: var(--ink-900);
    --bs-link-hover-color-rgb: 31, 35, 40;
    --bs-secondary-color: var(--ink-500);
    --bs-emphasis-color: var(--ink-900);
}

/* 2. Base
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--ink-900);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

a:hover {
    color: var(--ink-900);
    text-decoration: underline;
}

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

::selection {
    background: var(--brand-tint);
    color: var(--ink-900);
}

hr {
    border-color: var(--line);
    opacity: 1;
}

/* Arabic runs get the room their ascenders and marks need. */
[lang="ar"],
[dir="rtl"],
.text-arabic {
    font-family: "IBM Plex Sans Arabic", var(--font-sans);
    line-height: 1.7;
}

.tabular,
.table td,
.table th {
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* 3. Layout chrome
   ========================================================================== */
.main-navbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 1030;
    height: var(--navbar-height);
    padding: 0;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    box-shadow: none;
}

.main-navbar > .container-fluid {
    height: 100%;
    padding: 0 1.25rem 0 0;
    flex-wrap: nowrap;
}

.navbar-brand {
    display: flex;
    align-items: center;
    width: var(--sidebar-width);
    height: 100%;
    margin: 0;
    padding: 0 1.25rem;
    color: var(--header-text) !important;
}

.navbar-brand img {
    height: 42px;
    width: auto;
    max-width: 240px;
    object-fit: contain;
    filter: none;
}

.navbar-product {
    display: none;
    padding-left: 1.25rem;
    border-left: 1px solid var(--header-hover-bg);
    color: var(--header-text);
    font-size: var(--text-md);
    font-weight: 500;
    letter-spacing: 0.005em;
}

@media (min-width: 992px) {
    .navbar-product {
        display: block;
    }
}

.main-navbar .navbar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius);
    color: var(--header-text);
    font-weight: 500;
}

.main-navbar .navbar-nav .nav-link:hover,
.main-navbar .navbar-nav .nav-link[aria-expanded="true"] {
    background: var(--header-hover-bg);
    text-decoration: none;
}

.user-chip {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--header-text);
    color: var(--header-bg);
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.user-meta {
    display: none;
    line-height: 1.25;
    text-align: left;
}

.user-meta strong {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
}

.user-meta small {
    font-size: var(--text-xs);
    color: var(--header-text-soft);
}

@media (min-width: 768px) {
    .user-meta {
        display: block;
    }
}

.main-navbar .text-muted {
    color: var(--header-text-soft) !important;
}

.navbar-toggler {
    margin-left: 0.75rem;
    border: 0;
    padding: 0.25rem 0.5rem;
    color: var(--header-text);
}

.dropdown-menu {
    padding: 0.375rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    font-size: var(--text-base);
}

.dropdown-item {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--ink-900);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--surface-sunken);
    color: var(--ink-900);
    text-decoration: none;
}

.dropdown-item i {
    width: 1.1rem;
    color: var(--ink-500);
}

.dropdown-header {
    padding: 0.5rem 0.75rem 0.25rem;
    color: var(--ink-500);
    font-size: var(--text-xs);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    z-index: 1020;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    padding: 0.75rem 0 1.5rem;
    overflow-y: auto;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: none;
    transition: transform 0.2s ease;
}

.sidebar .nav {
    padding: 0 0.625rem;
    gap: 2px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.5625rem 0.75rem;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--sidebar-text);
    font-size: var(--text-base);
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
}

.sidebar .nav-link i {
    flex: none;
    width: 18px;
    margin-right: 0.75rem;
    color: var(--sidebar-text-soft);
    font-size: 0.875rem;
    text-align: center;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-hover-text);
    text-decoration: none;
}

.sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

.sidebar .nav-link.active > i,
.sidebar .nav-link.active .accordion-label > i {
    color: var(--sidebar-active-text);
}

/* A group heading is "active" when one of its pages is open: mark it, do not fill it. */
.sidebar .sidebar-accordion-toggle.active {
    background: transparent;
    font-weight: 600;
}

.sidebar .sidebar-accordion-toggle {
    justify-content: space-between;
    cursor: pointer;
}

.sidebar .sidebar-accordion-toggle .accordion-label {
    display: inline-flex;
    align-items: center;
}

.sidebar .sidebar-accordion-toggle .accordion-chevron {
    width: auto;
    margin: 0 0 0 0.5rem;
    font-size: 0.625rem;
    color: var(--sidebar-text-soft);
    transition: transform 0.15s ease;
}

.sidebar .sidebar-accordion-toggle:not(.collapsed) .accordion-chevron {
    transform: rotate(180deg);
}

.sidebar .sidebar-subnav {
    margin: 2px 0 0.375rem 1.3125rem;
    padding: 0 0 0 0.625rem;
    border-left: 1px solid var(--sidebar-border);
    gap: 1px;
}

.sidebar .sidebar-subnav .nav-link {
    position: relative;
    padding: 0.4375rem 0.625rem;
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--sidebar-text-soft);
}

.sidebar .sidebar-subnav .nav-link:hover {
    color: var(--sidebar-hover-text);
}

.sidebar .sidebar-subnav .nav-link i {
    display: none;
}

.sidebar .sidebar-subnav .nav-link.active {
    color: var(--sidebar-active-text);
    font-weight: 600;
}

.sidebar .sidebar-subnav .nav-link.active::before {
    content: "";
    position: absolute;
    left: calc(-0.625rem - 1px);
    top: 0.375rem;
    bottom: 0.375rem;
    width: 2px;
    border-radius: 2px;
    background: var(--sidebar-active-indicator);
}

.sidebar-section,
.sidebar-header {
    padding: 1rem 1.375rem 0.375rem;
}

.sidebar-section h6,
.sidebar-header h6 {
    margin: 0;
    color: var(--sidebar-text-soft);
    font-size: var(--text-xs);
    font-weight: 600;
}

.sidebar-footer {
    margin: 1.25rem 1.375rem 0;
    padding-top: 0.875rem;
    border-top: 1px solid var(--sidebar-border);
    color: var(--sidebar-text-soft);
    font-size: var(--text-xs);
    line-height: 1.5;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
    border: 2px solid var(--sidebar-bg);
    border-radius: 8px;
    background: var(--sidebar-scroll-thumb);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-scroll-thumb-hover);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: var(--navbar-height) 0 0 0;
    z-index: 1010;
    background: rgba(31, 35, 40, 0.4);
}

/* Main column */
.main-content {
    width: calc(100vw - var(--sidebar-width));
    max-width: calc(100vw - var(--sidebar-width));
    min-height: calc(100vh - var(--navbar-height));
    margin: var(--navbar-height) 0 0 var(--sidebar-width);
    padding: 1.75rem 2rem 3rem;
    overflow-x: hidden;
    background: var(--canvas);
}

.main-content .container-fluid {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

.main-content > .container,
.main-content > .container-fluid,
.main-content > .page-wrap {
    max-width: 1560px;
}

.page-wrap {
    padding: 0;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .navbar-brand {
        width: auto;
    }

    .main-content {
        width: 100vw;
        max-width: 100vw;
        margin-left: 0;
        padding: 1.25rem 1rem 2.5rem;
    }
}

/* Pages without chrome: sign-in */
.login-page .main-navbar,
.login-page .sidebar,
.login-page .sidebar-overlay {
    display: none !important;
}

.login-page .main-content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* 4. Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    margin-top: 0;
    color: var(--ink-900);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.005em;
}

h1, .h1 { font-size: var(--text-xl); }
h2, .h2 { font-size: var(--text-xl); }
h3, .h3 { font-size: var(--text-xl); }
h4, .h4 { font-size: var(--text-lg); }
h5, .h5 { font-size: var(--text-md); }
h6, .h6 { font-size: var(--text-base); }

small, .small {
    font-size: var(--text-sm);
}

.text-muted {
    color: var(--ink-500) !important;
}

.text-primary { color: var(--ink-900) !important; }
.text-success { color: var(--success-ink) !important; }
.text-danger { color: var(--danger-ink) !important; }
.text-warning { color: var(--warning-ink) !important; }
.text-info { color: var(--info-ink) !important; }
.text-secondary { color: var(--ink-600) !important; }

code,
.font-monospace {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.92em;
    color: var(--ink-700);
}

/* 5. Buttons
   ========================================================================== */
.btn {
    --bs-btn-font-size: var(--text-base);
    --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: 0.375rem;
    border-width: 1px;
    line-height: 1.4;
    box-shadow: none;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover {
    text-decoration: none;
    transform: none;
}

.btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    box-shadow: none;
}

.btn i.me-1,
.btn i.me-2 {
    margin-right: 0 !important;
}

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

.btn-lg {
    --bs-btn-font-size: var(--text-md);
    --bs-btn-padding-x: 1.25rem;
    --bs-btn-padding-y: 0.625rem;
    --bs-btn-border-radius: var(--radius);
}

.btn-primary,
.btn-dark,
.btn-gradient,
.ewra-btn-primary {
    background: var(--btn-primary-bg);
    border-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    box-shadow: none;
}

.btn-primary:hover,
.btn-dark:hover,
.btn-gradient:hover,
.ewra-btn-primary:hover,
.btn-primary:focus,
.btn-dark:focus,
.btn-gradient:focus {
    background: var(--btn-primary-hover-bg) !important;
    border-color: var(--btn-primary-hover-bg) !important;
    color: var(--btn-primary-hover-text) !important;
    box-shadow: none;
    transform: none;
}

.btn-primary:active,
.btn-dark:active,
.btn-gradient:active {
    background: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    color: var(--btn-primary-text) !important;
}

.btn-primary:disabled,
.btn-primary.disabled,
.btn-gradient:disabled {
    background: var(--ink-300);
    border-color: var(--ink-300);
    color: #fff;
}

/* The one brand-coloured button. Use for the single most important action on a page. */
.btn-accent,
.btn-warning {
    background: var(--btn-accent-bg);
    border-color: var(--btn-accent-bg);
    color: var(--btn-accent-text);
}

.btn-accent:hover,
.btn-warning:hover,
.btn-accent:focus,
.btn-warning:focus {
    background: var(--btn-accent-hover-bg);
    border-color: var(--btn-accent-hover-bg);
    color: var(--btn-accent-hover-text);
}

.btn-secondary,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-dark,
.btn-light,
.btn-white,
.btn-neutral,
.ewra-btn-secondary {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink-900);
}

.btn-secondary:hover,
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-dark:hover,
.btn-light:hover,
.btn-white:hover,
.btn-neutral:hover,
.ewra-btn-secondary:hover,
.btn-outline-primary:focus,
.btn-outline-secondary:focus,
.btn-outline-primary:active,
.btn-outline-secondary:active {
    background: var(--surface-sunken) !important;
    border-color: var(--ink-400) !important;
    color: var(--ink-900) !important;
    transform: none;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-success:hover,
.btn-success:focus {
    background: var(--success-ink);
    border-color: var(--success-ink);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-danger:hover,
.btn-danger:focus {
    background: var(--danger-ink);
    border-color: var(--danger-ink);
    color: #fff;
}

.btn-outline-success {
    background: var(--surface);
    border-color: var(--success-line);
    color: var(--success-ink);
}

.btn-outline-success:hover,
.btn-outline-success:focus {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success-ink);
}

.btn-outline-danger {
    background: var(--surface);
    border-color: var(--danger-line);
    color: var(--danger-ink);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger-ink);
}

.btn-outline-warning,
.btn-outline-info {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink-900);
}

.btn-outline-warning:hover,
.btn-outline-info:hover {
    background: var(--surface-sunken);
    border-color: var(--ink-400);
    color: var(--ink-900);
}

.btn-info {
    background: var(--info);
    border-color: var(--info);
    color: #fff;
}

.btn-info:hover {
    background: var(--info-ink);
    border-color: var(--info-ink);
    color: #fff;
}

.btn-link {
    color: var(--info-ink);
    font-weight: 500;
}

.btn-close:focus {
    box-shadow: 0 0 0 2px var(--brand-focus);
}

/* 6. Forms
   ========================================================================== */
.form-label,
.form-group > label,
.col-form-label {
    margin-bottom: 0.375rem;
    color: var(--ink-900);
    font-size: var(--text-sm);
    font-weight: 600;
}

.form-control,
.form-select,
.custom-select,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    min-height: 38px;
    padding: 0.4375rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background-color: var(--surface);
    color: var(--ink-900);
    font-size: var(--text-base);
    line-height: 1.5;
    box-shadow: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-select,
.custom-select {
    padding-right: 2.25rem;
}

.custom-select {
    display: block;
    width: 100%;
    appearance: none;
    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='%23555c65' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px 10px;
}

.form-control-lg,
.form-select-lg {
    min-height: 44px;
    padding: 0.5625rem 0.875rem;
    font-size: var(--text-md);
    border-radius: var(--radius);
}

.form-control-sm,
.form-select-sm {
    min-height: 32px;
    padding: 0.25rem 0.625rem;
    font-size: var(--text-sm);
}

textarea.form-control {
    min-height: 88px;
}

.form-control::placeholder {
    color: var(--ink-400);
}

.form-control:hover,
.form-select:hover,
.custom-select:hover {
    border-color: var(--ink-400);
}

.form-control:focus,
.form-select:focus,
.custom-select:focus {
    border-color: var(--ink-700);
    outline: 0;
    box-shadow: 0 0 0 3px var(--brand-focus);
    background-color: var(--surface);
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
    background-color: var(--surface-sunken);
    color: var(--ink-600);
}

.form-control.is-invalid,
.form-select.is-invalid,
.was-validated .form-control:invalid {
    border-color: var(--danger);
    background-image: none;
    padding-right: 0.75rem;
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(192, 53, 43, 0.2);
}

.invalid-feedback,
.errorlist {
    margin: 0.25rem 0 0;
    padding: 0;
    list-style: none;
    color: var(--danger-ink);
    font-size: var(--text-sm);
}

.invalid-feedback strong {
    font-weight: 500;
}

.form-text,
.help-block,
small.form-text {
    display: block;
    margin-top: 0.25rem;
    color: var(--ink-500);
    font-size: var(--text-xs);
}

.asteriskField {
    margin-left: 2px;
    color: var(--danger);
    font-weight: 500;
}

.form-check-input {
    border-color: var(--ink-400);
}

.form-check-input:checked {
    background-color: var(--ink-900);
    border-color: var(--ink-900);
}

.form-check-input:focus {
    border-color: var(--ink-700);
    box-shadow: 0 0 0 3px var(--brand-focus);
}

.form-check-label {
    color: var(--ink-900);
}

.input-group-text {
    border-color: var(--line-strong);
    background: var(--surface-sunken);
    color: var(--ink-600);
    font-size: var(--text-base);
}

/* crispy-forms renders Bootstrap 4 markup; give it Bootstrap 5 behaviour. */
.form-group {
    margin-bottom: 1rem;
}

/* A from/to pair of inputs (date ranges) sits on one line. */
.form-group > div:has(> input + input) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink-500);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.custom-control {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    min-height: 1.5rem;
}

.custom-control-input {
    width: 1rem;
    height: 1rem;
    margin-top: 0.25rem;
    accent-color: var(--ink-900);
}

.custom-control-label {
    margin: 0;
    font-weight: 400;
    font-size: var(--text-base);
}

.custom-file {
    display: block;
}

.custom-file-input {
    display: block;
    width: 100%;
    padding: 0.4375rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: var(--text-base);
}

.custom-file-label {
    display: none;
}

input[type="file"].form-control,
input[type="file"].custom-file-input {
    padding: 0.375rem 0.5rem;
}

input[type="file"]::file-selector-button {
    margin: -0.375rem 0.75rem -0.375rem -0.5rem;
    padding: 0.4375rem 0.875rem;
    border: 0;
    border-right: 1px solid var(--line-strong);
    background: var(--surface-sunken);
    color: var(--ink-900);
    font: inherit;
    font-weight: 500;
}

/* select2 */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding: 0;
    color: var(--ink-900);
    line-height: 1.5;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    top: 6px;
    right: 8px;
}

.select2-dropdown {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: var(--text-base);
}

.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: var(--ink-900);
    color: #fff;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
}

/* 7. Cards
   ========================================================================== */
.card,
.ewra-card,
.info-card,
.content-card,
.admin-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: none;
    backdrop-filter: none;
    transition: none;
}

.card:hover,
.ewra-card:hover,
.info-card:hover {
    box-shadow: none;
    transform: none;
    border-color: var(--line);
}

.card-header,
.ewra-card .card-header,
.ewra-card-header,
.info-card-header,
.content-card-header,
.admin-card-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--surface);
    color: var(--ink-900);
    font-size: var(--text-md);
    font-weight: 600;
}

.card-header:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-header h1, .card-header h2, .card-header h3,
.card-header h4, .card-header h5, .card-header h6,
.card-header .card-title {
    margin: 0;
    font-size: var(--text-md);
    font-weight: 600;
    color: inherit;
}

.card-header i {
    color: var(--ink-500);
}

/* Coloured headers become a plain header; the colour was decoration. */
.card-header.bg-primary,
.card-header.bg-brand,
.card-header.bg-dark,
.card-header.bg-secondary,
.card-header.bg-info,
.card-header.bg-gradient {
    background: var(--surface) !important;
    background-image: none !important;
    color: var(--ink-900) !important;
    border-bottom: 1px solid var(--line);
}

.card-header.bg-primary *,
.card-header.bg-dark *,
.card-header.bg-gradient *,
.card-header.text-white * {
    color: var(--ink-900) !important;
}

.card-header.bg-danger {
    background: var(--danger-bg) !important;
    color: var(--danger-ink) !important;
}

.card-header.bg-warning {
    background: var(--warning-bg) !important;
    color: var(--warning-ink) !important;
}

.card-header.bg-success {
    background: var(--success-bg) !important;
    color: var(--success-ink) !important;
}

.card-body,
.ewra-card .card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--line);
    background: var(--surface-sunken);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.card-title {
    font-size: var(--text-md);
    font-weight: 600;
}

/* 8. Tables
   ========================================================================== */
.table,
.ewra-table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: var(--surface-sunken);
    --bs-table-hover-bg: var(--surface-sunken);
    --bs-table-border-color: var(--line);
    margin-bottom: 0;
    color: var(--ink-900);
    font-size: var(--text-base);
    border-color: var(--line);
}

.table > thead > tr > th,
.table thead th,
.ewra-table thead th {
    padding: 0.625rem 0.875rem;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface-sunken);
    background-image: none;
    color: var(--ink-600);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    vertical-align: middle;
}

.table thead th a,
.table thead th.orderable a {
    color: var(--ink-600);
    text-decoration: none;
}

.table thead th a:hover {
    color: var(--ink-900);
}

.table thead th.asc a::after { content: " \2191"; color: var(--ink-900); }
.table thead th.desc a::after { content: " \2193"; color: var(--ink-900); }

.table > tbody > tr > td,
.table tbody td,
.ewra-table tbody td {
    padding: 0.6875rem 0.875rem;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

.table > tbody > tr:last-child > td {
    border-bottom: 0;
}

.table-hover > tbody > tr:hover > *,
.ewra-table tbody tr:hover > * {
    background: var(--surface-sunken);
    transform: none;
    box-shadow: none;
}

.ewra-table tbody tr,
.table tbody tr {
    transform: none !important;
    box-shadow: none !important;
}

.table-sm > :not(caption) > * > * {
    padding: 0.4375rem 0.625rem;
}

.table-responsive,
.table-container {
    border-radius: var(--radius-lg);
}

.card > .table-responsive,
.card > .table-container,
.card-body.p-0 > .table-responsive {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Whole rows are not tinted: a page of pink rows makes everything shout.
   A narrow marker on the leading edge carries the state instead. */
tr.table-danger > *,
tr.table-warning > *,
tr.table-success > *,
tr.table-info > *,
tr.table-danger-row > * {
    --bs-table-bg: transparent;
    --bs-table-bg-state: transparent;
    background: transparent !important;
    color: var(--ink-900);
    box-shadow: none;
}

tr.table-danger > :first-child,
tr.table-danger-row > :first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.table-warning > :first-child { box-shadow: inset 3px 0 0 var(--warning); }
tr.table-success > :first-child { box-shadow: inset 3px 0 0 var(--success); }

.table-light,
.table-light > th,
.table-light > td {
    --bs-table-bg: var(--surface-sunken);
    background: var(--surface-sunken) !important;
    color: var(--ink-600);
}

.table-dark,
.table-dark > th {
    --bs-table-bg: var(--surface-sunken);
    --bs-table-color: var(--ink-600);
    background: var(--surface-sunken) !important;
    color: var(--ink-600) !important;
}

/* Expandable row detail */
.clickable-row {
    cursor: pointer;
}

.toggle-icon {
    color: var(--ink-400);
    font-size: 0.6875rem;
    transition: transform 0.15s ease;
}

[aria-expanded="true"] .toggle-icon,
.toggle-icon.rotated,
.toggle-icon.open {
    transform: rotate(90deg);
}

.details-panel {
    padding: 1rem 1.25rem;
    border: 0;
    border-left: 2px solid var(--line-strong);
    border-radius: 0;
    background: var(--surface-sunken);
    box-shadow: none;
    animation: none;
}

.detail-label,
.detail-heading {
    color: var(--ink-500);
    font-size: var(--text-xs);
    font-weight: 600;
}

.detail-value {
    color: var(--ink-900);
    font-size: var(--text-base);
}

/* Pagination */
.pagination,
.pagination-modern {
    gap: 4px;
    margin: 0;
}

.pagination .page-link,
.pagination-modern .page-link {
    min-width: 34px;
    padding: 0.3125rem 0.625rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius) !important;
    background: var(--surface);
    background-image: none;
    color: var(--ink-900);
    font-size: var(--text-sm);
    font-weight: 500;
    text-align: center;
    box-shadow: none;
    transform: none;
}

.pagination .page-link:hover,
.pagination-modern .page-link:hover {
    background: var(--surface-sunken);
    border-color: var(--ink-400);
    color: var(--ink-900);
    text-decoration: none;
    transform: none;
}

.pagination .page-item.active .page-link,
.pagination-modern .page-item.active .page-link {
    background: var(--ink-900);
    background-image: none;
    border-color: var(--ink-900);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink-300);
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 3px var(--brand-focus);
}

/* Actions on the ticked rows of a table, above it. */
.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface-sunken);
}

.bulk-bar .count {
    color: var(--ink-600);
    font-variant-numeric: tabular-nums;
}

/* 9. Status and risk
   ========================================================================== */
.badge,
.badge-soft,
.status-badge,
.status-pill,
.case-pill,
.risk-badge,
.rule-pill,
.severity-chip,
.stat-pill,
.count-badge,
.table-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--neutral-line);
    border-radius: var(--radius-sm);
    background: var(--neutral-bg);
    background-image: none;
    color: var(--neutral-ink);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    vertical-align: middle;
    box-shadow: none;
}

.badge.rounded-pill {
    border-radius: var(--radius-sm) !important;
}

/* Tones. Every name a template or table class uses today is listed once. */
.badge.bg-danger, .bg-danger.badge,
.badge-danger, .badge-danger-soft,
.badge-severity-high, .severity-high,
.risk-badge.high-risk, .risk-badge.very-high-risk,
.case-pill-danger, .tone-danger {
    background: var(--danger-bg) !important;
    border-color: var(--danger-line);
    color: var(--danger-ink) !important;
}

.badge.bg-warning, .bg-warning.badge,
.badge-warning, .badge-warning-soft,
.badge-severity-medium, .severity-medium,
.risk-badge.medium-risk,
.case-pill-warning, .tone-warning {
    background: var(--warning-bg) !important;
    border-color: var(--warning-line);
    color: var(--warning-ink) !important;
}

.badge.bg-success, .bg-success.badge,
.badge-success, .badge-success-soft,
.risk-badge.low-risk, .badge-cr,
.case-pill-success, .tone-success {
    background: var(--success-bg) !important;
    border-color: var(--success-line);
    color: var(--success-ink) !important;
}

.badge.bg-info, .bg-info.badge,
.badge-info, .badge-info-soft, .badge-purple-soft,
.badge-severity-low, .severity-low,
.case-pill-info, .tone-info {
    background: var(--info-bg) !important;
    border-color: var(--info-line);
    color: var(--info-ink) !important;
}

.badge.bg-primary, .badge.bg-dark, .badge.bg-secondary, .badge.bg-light,
.bg-primary.badge, .bg-dark.badge, .bg-secondary.badge, .bg-light.badge,
.badge-secondary, .badge-secondary-soft, .badge-neutral, .badge-dark-gray,
.badge-country, .tone-neutral {
    background: var(--neutral-bg) !important;
    border-color: var(--neutral-line);
    color: var(--neutral-ink) !important;
}

.badge-dr {
    background: var(--surface) !important;
    border-color: var(--line-strong);
    color: var(--ink-700) !important;
}

/* A solid tone for the rare count that must be seen first. */
.badge-solid {
    background: var(--ink-900) !important;
    border-color: var(--ink-900);
    color: #fff !important;
}

/* A small dot in front of a status word. */
.status-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.risk-high, .control-weak { color: var(--danger-ink); font-weight: 600; }
.risk-moderate, .control-satisfactory { color: var(--warning-ink); font-weight: 600; }
.risk-low, .control-strong { color: var(--success-ink); font-weight: 600; }

/* Large score readout */
.score-number {
    margin-bottom: 0.25rem;
    font-size: 2.5rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--ink-900);
}

.score-number.low-risk { color: var(--success-ink); }
.score-number.medium-risk { color: var(--warning-ink); }
.score-number.high-risk,
.score-number.very-high-risk { color: var(--danger-ink); }

.result-score-display {
    margin-bottom: 1.25rem;
    padding: 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    text-align: center;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink-900);
    font-size: var(--text-base);
    box-shadow: none;
}

.alert-danger {
    border-color: var(--danger-line);
    background: var(--danger-bg);
    color: var(--danger-ink);
}

.alert-warning {
    border-color: var(--warning-line);
    background: var(--warning-bg);
    color: var(--warning-ink);
}

.alert-success {
    border-color: var(--success-line);
    background: var(--success-bg);
    color: var(--success-ink);
}

.alert-info,
.alert-primary,
.alert-secondary,
.alert-light {
    border-color: var(--info-line);
    background: var(--info-bg);
    color: var(--info-ink);
}

.alert-secondary,
.alert-light {
    border-color: var(--line);
    background: var(--surface-sunken);
    color: var(--ink-700);
}

.alert a:not(.btn),
.alert .alert-link {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.alert-dismissible {
    padding-right: 2.75rem;
}

.alert-dismissible .btn-close {
    padding: 0.9375rem 1rem;
    font-size: 0.6875rem;
}

.alert-fade-out {
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

.messages-container {
    margin-bottom: 1.25rem;
}

/* Progress */
.progress {
    height: 8px;
    border-radius: 8px;
    background: var(--neutral-bg);
}

.progress-bar {
    background-color: var(--ink-900);
    background-image: none;
}

.progress-bar.bg-success { background-color: var(--success) !important; }
.progress-bar.bg-warning { background-color: var(--warning) !important; }
.progress-bar.bg-danger { background-color: var(--danger) !important; }
.progress-bar.bg-info { background-color: var(--info) !important; }

.progress-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Background utilities, toned down to tints. Badges are handled above. */
.bg-primary:not(.badge):not(.progress-bar):not(.card-header) {
    background-color: var(--ink-900) !important;
}

.bg-light {
    background-color: var(--surface-sunken) !important;
}

/* 10. Page furniture
   ========================================================================== */
/* Page header: title and subtitle on the left, actions on the right. */
.page-header,
.ewra-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin: 0 0 1.5rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
}

.page-title,
.ewra-page-title {
    margin: 0;
    color: var(--ink-900);
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.page-title i,
.ewra-page-title i {
    display: none;
}

.page-subtitle,
.ewra-subtitle {
    margin: 0.25rem 0 0;
    color: var(--ink-500);
    font-size: var(--text-base);
}

.page-actions,
.header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breadcrumb {
    margin: 0 0 0.5rem;
    padding: 0;
    background: none;
    font-size: var(--text-sm);
}

.breadcrumb-item a {
    color: var(--ink-500);
}

.breadcrumb-item.active {
    color: var(--ink-900);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--ink-300);
}

/* Bordered summary band used at the top of job and run pages. */
.ewra-hero,
.dashboard-header,
.profile-header {
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    background-image: none;
    color: var(--ink-900);
    box-shadow: none;
}

.ewra-hero::after,
.ewra-hero::before {
    content: none;
}

/* Figures: a label, a number and an optional note. */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-tile,
.stat-card,
.stats-card,
.metric-card,
.bulk-summary-metric {
    position: relative;
    padding: 1rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    background-image: none;
    color: var(--ink-900);
    box-shadow: none;
    transform: none;
    transition: none;
}

.stat-tile:hover,
.stat-card:hover,
.stats-card:hover,
.metric-card:hover {
    border-color: var(--line);
    box-shadow: none;
    transform: none;
}

a.stat-tile:hover {
    border-color: var(--ink-400);
    text-decoration: none;
}

.stat-label {
    color: var(--ink-500);
    font-size: var(--text-sm);
    font-weight: 500;
}

.stat-value {
    margin-top: 0.25rem;
    color: var(--ink-900);
    font-size: var(--text-2xl);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.stat-note {
    margin-top: 0.25rem;
    color: var(--ink-500);
    font-size: var(--text-xs);
}

.stat-tile.is-alert {
    border-color: var(--danger-line);
}

.stat-tile.is-alert .stat-value {
    color: var(--danger-ink);
}

/* Label and value pairs */
.definition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem 1.5rem;
    margin: 0;
}

.definition-grid dt {
    color: var(--ink-500);
    font-size: var(--text-xs);
    font-weight: 500;
}

.definition-grid dd {
    margin: 0.125rem 0 0;
    color: var(--ink-900);
    font-weight: 500;
    overflow-wrap: anywhere;
}

/* Tabs */
.nav-tabs,
.custom-tabs,
.customer-tabs {
    gap: 0.25rem;
    border-bottom: 1px solid var(--line);
}

.nav-tabs .nav-link,
.custom-tabs .nav-link,
.customer-tabs .nav-link {
    margin-bottom: -1px;
    padding: 0.625rem 0.875rem;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none !important;
    color: var(--ink-600) !important;
    font-size: var(--text-base);
    font-weight: 500;
    box-shadow: none;
}

.nav-tabs .nav-link:hover,
.custom-tabs .nav-link:hover,
.customer-tabs .nav-link:hover {
    border-bottom-color: var(--line-strong);
    color: var(--ink-900) !important;
    text-decoration: none;
}

.nav-tabs .nav-link.active,
.custom-tabs .nav-link.active,
.customer-tabs .nav-link.active {
    border-bottom-color: var(--brand);
    color: var(--ink-900) !important;
    font-weight: 600;
}

.nav-pills .nav-link {
    border-radius: var(--radius);
    color: var(--ink-600);
    font-weight: 500;
}

.nav-pills .nav-link.active {
    background: var(--ink-900);
    color: #fff;
}

/* Filter bar */
.filter-bar {
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

/* A Bootstrap gutter row pulls itself up by its gutter and gives each field
   the gutter back as a top margin. Undo the pull so the bar keeps its place. */
.filter-bar.row {
    margin-top: 0;
    padding-top: 0;
}

.filter-bar .form-group,
.filter-bar .mb-3 {
    margin-bottom: 0;
}

/* Notes and guidance */
.info-box,
.notes-box {
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--line);
    border-left: 3px solid var(--ink-300);
    border-radius: var(--radius);
    background: var(--surface-sunken);
}

.info-box h6 {
    margin-bottom: 0.5rem;
    color: var(--ink-900);
    font-weight: 600;
}

.info-box ul,
.info-box ol {
    margin-bottom: 0;
    padding-left: 1.125rem;
}

.info-box li {
    margin-bottom: 0.25rem;
    color: var(--ink-700);
    font-size: var(--text-sm);
}

.section-divider {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink-900);
    font-size: var(--text-md);
    font-weight: 600;
}

/* Empty state */
.empty-state {
    padding: 2.5rem 1.5rem;
    color: var(--ink-500);
    text-align: center;
}

.empty-state-icon,
.empty-state i {
    margin-bottom: 0.75rem;
    color: var(--ink-300);
    font-size: 1.75rem;
}

.empty-state h5,
.empty-state h6 {
    margin-bottom: 0.25rem;
    color: var(--ink-900);
    font-size: var(--text-md);
}

/* Timeline */
.timeline {
    position: relative;
    margin: 0;
    padding: 0 0 0 1.25rem;
    list-style: none;
    border-left: 1px solid var(--line);
}

.timeline-item {
    position: relative;
    padding: 0 0 1.125rem 0.5rem;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: calc(-1.25rem - 4px);
    top: 0.4375rem;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink-400);
    box-shadow: 0 0 0 3px var(--surface);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

/* Modals */
.modal-content {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
}

.modal-title {
    font-size: var(--text-md);
    font-weight: 600;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--line);
    background: var(--surface-sunken);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.list-group-item {
    border-color: var(--line);
    color: var(--ink-900);
}

.accordion-button:not(.collapsed) {
    background: var(--surface-sunken);
    color: var(--ink-900);
    box-shadow: none;
}

.accordion-button:focus {
    border-color: var(--line-strong);
    box-shadow: 0 0 0 3px var(--brand-focus);
}

/* Customer block on the rating pages */
.customer-info {
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-sunken);
}

.customer-info-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.375rem;
}

.customer-info-item:last-child {
    margin-bottom: 0;
}

.customer-info-label {
    min-width: 110px;
    color: var(--ink-500);
    font-size: var(--text-sm);
    font-weight: 500;
}

.customer-info-value {
    color: var(--ink-900);
    font-weight: 500;
}

.breakdown-table {
    width: 100%;
    margin-top: 1rem;
}

.breakdown-table tr {
    border-bottom: 1px solid var(--line-soft);
}

.breakdown-table tr:last-child {
    border-bottom: 0;
}

.breakdown-table td {
    padding: 0.5625rem 0;
}

.breakdown-label {
    color: var(--ink-700);
    font-size: var(--text-sm);
    font-weight: 500;
}

.breakdown-score {
    color: var(--ink-900);
    font-weight: 600;
    text-align: right;
}

.breakdown-score .badge {
    min-width: 40px;
    justify-content: center;
}

.threshold-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.threshold-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.threshold-badge {
    min-width: 104px;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    text-align: center;
}

.threshold-range {
    color: var(--ink-600);
    font-size: var(--text-sm);
}

/* Forms that stand alone on a page stay at a readable width. */
.form-card {
    max-width: 860px;
}

/* File drop area for the upload pages. */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 1.75rem 1.25rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-sunken);
    color: var(--ink-600);
    text-align: center;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragover {
    border-color: var(--ink-500);
    background: var(--surface);
}

.dropzone.has-file {
    border-style: solid;
    border-color: var(--success-line);
    background: var(--success-bg);
    color: var(--success-ink);
}

.dropzone strong {
    color: var(--ink-900);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.dropzone.has-file strong {
    color: var(--success-ink);
}

.dropzone.is-invalid {
    border-color: var(--danger);
    background: var(--danger-bg);
}

/* The input stays in the page for keyboard and screen reader users. */
.dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    clip-path: inset(50%);
}

.dropzone:focus-within {
    outline: 3px solid var(--brand-focus);
    outline-offset: 2px;
}

/* Two inputs that make one range, such as from and to dates. */
.range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink-500);
}

.range-inputs > input,
.range-inputs > select {
    flex: 1 1 0;
    min-width: 0;
}

/* A plain list of what a file has to contain. */
.column-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.5rem 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-sm);
}

.column-list li {
    color: var(--ink-600);
}

.column-list strong {
    display: block;
    color: var(--ink-900);
    font-weight: 600;
}

/* Small avatar with initials. */
.avatar {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--neutral-bg);
    color: var(--ink-700);
    font-size: var(--text-xs);
    font-weight: 600;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: var(--text-md);
}

/* Names in either script read in their own direction but stay on the page's
   leading edge, so a column of Arabic and Latin names lines up. */
.name-cell {
    unicode-bidi: plaintext;
    font-weight: 500;
    text-align: left;
}

td[dir="auto"],
dd[dir="auto"],
td [dir="auto"],
dd [dir="auto"] {
    text-align: left;
}

/* Charts built from plain elements.
   Marks carry colour; labels and values stay in ink. Every chart shows its
   values as text, so nothing depends on hover or on colour alone. */
.chart-title {
    margin: 0 0 0.75rem;
    color: var(--ink-600);
    font-size: var(--text-sm);
    font-weight: 500;
}

/* Part-to-whole: one stacked horizontal bar. */
.stack-bar {
    display: flex;
    gap: 2px;
    height: 16px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--surface);
}

.stack-bar > span {
    min-width: 3px;
    background: var(--ink-300);
}

.stack-bar > .is-low { background: var(--success); }
.stack-bar > .is-medium { background: var(--warning); }
.stack-bar > .is-high { background: var(--danger); }
.stack-bar > .is-none { background: var(--ink-300); }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin: 0.875rem 0 0;
    padding: 0;
    list-style: none;
}

.legend li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    color: var(--ink-600);
    font-size: var(--text-sm);
}

.legend strong {
    color: var(--ink-900);
    font-weight: 600;
}

.legend-key {
    flex: none;
    align-self: center;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--ink-300);
}

.legend-key.is-low { background: var(--success); }
.legend-key.is-medium { background: var(--warning); }
.legend-key.is-high { background: var(--danger); }

/* Magnitude: a list of horizontal bars, one series, one colour. */
.bar-list {
    display: grid;
    gap: 0.625rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bar-list li {
    display: grid;
    grid-template-columns: minmax(0, 13rem) minmax(0, 1fr) 2.5rem;
    align-items: center;
    gap: 0.75rem;
    font-size: var(--text-sm);
}

.bar-list .bar-label {
    overflow: hidden;
    color: var(--ink-700);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-list .bar-track {
    height: 12px;
}

.bar-list .bar-fill {
    display: block;
    height: 100%;
    min-width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--info);
}

.bar-list .bar-value {
    color: var(--ink-900);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

@media (max-width: 575.98px) {
    .bar-list li {
        grid-template-columns: minmax(0, 1fr) 2.5rem;
    }

    .bar-list .bar-label {
        grid-column: 1 / -1;
    }
}

/* A thin meter for one score against its maximum. */
.meter {
    height: 6px;
    border-radius: 6px;
    background: var(--neutral-bg);
    overflow: hidden;
}

.meter > span {
    display: block;
    height: 100%;
    border-radius: 6px;
    background: var(--ink-700);
}

.stat-tile .meter {
    margin: 0.625rem 0 0.5rem;
}

.meter.is-low > span { background: var(--success); }
.meter.is-medium > span { background: var(--warning); }
.meter.is-high > span { background: var(--danger); }

/* 11. Legacy class names
   Older templates style these per page. Until a page is cleaned up, these
   rules keep it in line with the system.
   ========================================================================== */
.shadow,
.shadow-sm,
.shadow-lg {
    box-shadow: none !important;
}

.rounded-3,
.rounded-4,
.rounded-5 {
    border-radius: var(--radius-lg) !important;
}

.border-primary { border-color: var(--line-strong) !important; }

.text-white.bg-primary,
.text-white.bg-dark {
    color: #fff !important;
}

/* Hidden until the page script has started. */
[x-cloak] {
    display: none !important;
}

/* 12. Print
   ========================================================================== */
@media print {
    .sidebar,
    .main-navbar,
    .sidebar-overlay,
    .messages-container,
    .page-actions,
    .header-actions,
    .btn,
    form.filter-bar,
    .pagination {
        display: none !important;
    }

    body,
    .main-content {
        background: #fff;
    }

    .main-content {
        width: auto;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .card,
    .ewra-card,
    .stat-tile {
        border-color: #999;
        break-inside: avoid;
    }
}
