/* ==========================================================================
   Zorraga Connect — shared design system (back-office AND customer space)
   --------------------------------------------------------------------------
   Loaded first by both documents (templates/_ui/_head.html.twig), then the space stylesheet:
   app.css (back-office only) or client.css (customer space only). docs/UI_HARMONISATION.md.
   Bootstrap 5.3 is customised through its CSS variables (no Sass build).
   One section per reusable component; every class is defined ONCE (ui.css + app.css + client.css).
   Logical properties only (margin-inline, inset-inline, text-align: start): identical in French
   (LTR), mirrored by itself in Arabic (RTL, customer space with bootstrap.rtl.min.css).

    1. Fonts & tokens            8. Badges & chips
    2. Base & utilities          9. Dropdowns & notifications
    3. Buttons                  10. Tables & data cards (mobile)
    4. Forms                    11. Filters, search & tabs
    5. App shell                12. Pagination & empty states
    6. Page headers             13. Toasts, alerts & modals
    7. Cards, panels & tones    14. Touch, right-to-left & motion preferences
                                15. Dashboards: greeting banner & KPI cards
                                16. Detail blocks: facts, items, timeline, files
                                17. Authentication, offline page & password field
   ========================================================================== */
/* 1. Fonts & tokens ======================================================== */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("../fonts/inter-latin-wght-normal-Gz7AlRl.woff2") format('woff2-variations');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("../fonts/inter-latin-ext-wght-normal-1Br77OV.woff2") format('woff2-variations');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    /* Brand */
    --ap-primary: #107948;
    --ap-primary-rgb: 16, 121, 72;
    --ap-primary-600: #0d6a3e;
    --ap-primary-700: #0a5632;
    --ap-primary-50: #EAF7F0;
    --ap-primary-100: #D3EEE0;

    /* Surfaces & text */
    --ap-bg: #F7FAFF;
    --ap-surface: #FFFFFF;
    --ap-surface-2: #FAFCFF;       /* very light panel: table headers, footers */
    --ap-hover: #F0F9F4;           /* row / item hover */
    --ap-border: #E8EEF5;
    --ap-border-strong: #D9E2EC;   /* inputs, outlined buttons */
    --ap-text: #172B4D;
    --ap-text-2: #475569;
    --ap-text-3: #64748B;          /* secondary text — 4.8:1 on white */
    --ap-muted-bg: #F1F5F9;

    /* Pastel feature colours (background / readable foreground) */
    --ap-info: #1D5FD1;      --ap-info-bg: #E9F2FF;
    --ap-warning: #9A5200;   --ap-warning-bg: #FFF2DB;
    --ap-danger: #C0262D;    --ap-danger-bg: #FDEEEE;
    --ap-success: #107948;   --ap-success-bg: #EAF7F0;
    --ap-dark: #172B4D;      --ap-dark-bg: #E8EDF5;
    --ap-violet: #6B3FC9;    --ap-violet-bg: #F2EBFF;
    --ap-teal: #0B7F82;      --ap-teal-bg: #E2F7F6;
    --ap-orange: #C2410C;    --ap-orange-bg: #FFE6CC;

    /* Shape & depth */
    --ap-radius: 16px;
    --ap-radius-sm: 10px;
    --ap-radius-xs: 8px;
    --ap-shadow-sm: 0 1px 2px rgba(23, 43, 77, .04);
    --ap-shadow: 0 1px 2px rgba(23, 43, 77, .04), 0 6px 18px -12px rgba(23, 43, 77, .14);
    --ap-shadow-lg: 0 18px 40px -16px rgba(23, 43, 77, .28);
    --ap-ring: 0 0 0 4px rgba(var(--ap-primary-rgb), .14);
    --ap-sidebar-w: 264px;
    --ap-topbar-h: 64px;

    /* Bootstrap mapping */
    --bs-primary: var(--ap-primary);
    --bs-primary-rgb: var(--ap-primary-rgb);
    --bs-link-color: var(--ap-primary);
    --bs-link-color-rgb: var(--ap-primary-rgb);
    --bs-link-hover-color: var(--ap-primary-700);
    --bs-link-hover-color-rgb: 10, 86, 50;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-font-size: .9375rem;
    --bs-body-color: var(--ap-text);
    --bs-body-bg: var(--ap-bg);
    --bs-border-color: var(--ap-border);
    --bs-border-radius: var(--ap-radius-sm);
    --bs-border-radius-lg: var(--ap-radius);
    --bs-secondary-color: var(--ap-text-3);
    --bs-focus-ring-color: rgba(var(--ap-primary-rgb), .25);
    --bs-success: var(--ap-success);
    --bs-danger: var(--ap-danger);
    --bs-emphasis-color: var(--ap-text);
}

/* 2. Base & utilities ====================================================== */
body {
    background: var(--ap-bg);
    color: var(--ap-text);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4, h5, h6 { color: var(--ap-text); font-weight: 680; letter-spacing: -.015em; }
a { text-decoration: none; }
::selection { background: var(--ap-primary-100); }

/* Bootstrap utilities are !important themselves: overriding their colours requires it too. */
.text-secondary, .text-muted { color: var(--ap-text-3) !important; }
.text-primary { color: var(--ap-primary) !important; }
.bg-primary-subtle { background: var(--ap-primary-50) !important; }
.border-dashed { border-style: dashed !important; }
.badge.text-bg-primary { background-color: var(--ap-primary) !important; }

.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875em; }
.small-caps { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 650; color: var(--ap-text-3); }
.min-w-0 { min-width: 0; }
.ap-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-divider { height: 1px; background: var(--ap-border); margin: 1.25rem 0; }
.ap-scroll-panel { max-height: 420px; overflow: auto; }
svg[data-icon], .ap-icon { flex-shrink: 0; }
.ap-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ap-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ap-primary); margin-top: 6px; flex-shrink: 0; box-shadow: 0 0 0 3px var(--ap-primary-50); }

/* 3. Buttons =============================================================== */
.btn {
    --bs-btn-font-weight: 600; --bs-btn-padding-x: 1rem; --bs-btn-padding-y: .55rem; --bs-btn-font-size: .9rem;
    --bs-btn-focus-box-shadow: var(--ap-ring);
    border-radius: var(--ap-radius-sm); display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { --bs-btn-padding-x: .75rem; --bs-btn-padding-y: .38rem; --bs-btn-font-size: .825rem; border-radius: var(--ap-radius-xs); }
.btn-lg { --bs-btn-padding-y: .75rem; --bs-btn-font-size: 1rem; }
.btn-primary {
    --bs-btn-bg: var(--ap-primary); --bs-btn-border-color: var(--ap-primary);
    --bs-btn-hover-bg: var(--ap-primary-600); --bs-btn-hover-border-color: var(--ap-primary-600);
    --bs-btn-active-bg: var(--ap-primary-700); --bs-btn-active-border-color: var(--ap-primary-700);
    --bs-btn-disabled-bg: var(--ap-primary); --bs-btn-disabled-border-color: var(--ap-primary);
    box-shadow: 0 6px 14px -8px rgba(16, 121, 72, .7);
}
.btn-outline-primary {
    --bs-btn-color: var(--ap-primary); --bs-btn-border-color: rgba(var(--ap-primary-rgb), .45);
    --bs-btn-hover-bg: var(--ap-primary-50); --bs-btn-hover-color: var(--ap-primary-700); --bs-btn-hover-border-color: var(--ap-primary);
    --bs-btn-active-bg: var(--ap-primary-100); --bs-btn-active-color: var(--ap-primary-700); --bs-btn-active-border-color: var(--ap-primary);
}
.btn-light, .btn-white {
    --bs-btn-bg: var(--ap-surface); --bs-btn-border-color: var(--ap-border-strong); --bs-btn-color: var(--ap-text);
    --bs-btn-hover-bg: var(--ap-hover); --bs-btn-hover-border-color: rgba(var(--ap-primary-rgb), .35); --bs-btn-hover-color: var(--ap-primary-700);
    --bs-btn-active-bg: var(--ap-primary-50); --bs-btn-active-border-color: var(--ap-primary);
    box-shadow: var(--ap-shadow-sm);
}
.btn-ghost {
    --bs-btn-color: var(--ap-text-2); --bs-btn-hover-bg: var(--ap-hover); --bs-btn-hover-color: var(--ap-primary-700);
    --bs-btn-border-color: transparent; --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: var(--ap-primary-50);
}
.btn-danger { --bs-btn-bg: var(--ap-danger); --bs-btn-border-color: var(--ap-danger); --bs-btn-hover-bg: #A31F25; --bs-btn-hover-border-color: #A31F25; }
.btn-outline-danger {
    --bs-btn-color: var(--ap-danger); --bs-btn-border-color: #F2C4C6; --bs-btn-bg: var(--ap-surface);
    --bs-btn-hover-bg: var(--ap-danger-bg); --bs-btn-hover-color: #A31F25; --bs-btn-hover-border-color: var(--ap-danger);
    --bs-btn-active-bg: #FBE0E1; --bs-btn-active-color: #A31F25; --bs-btn-active-border-color: var(--ap-danger);
}
.btn-whatsapp {
    --bs-btn-bg: #1FAF55; --bs-btn-border-color: #1FAF55; --bs-btn-color: #fff; --bs-btn-hover-bg: #17964A; --bs-btn-hover-border-color: #17964A;
    --bs-btn-hover-color: #fff; --bs-btn-active-bg: #128040; box-shadow: 0 6px 14px -8px rgba(31, 175, 85, .8);
}
.btn-icon { --bs-btn-padding-x: .5rem; width: 2.3rem; height: 2.3rem; }
.btn-sm.btn-icon { width: 2rem; height: 2rem; }
.btn.is-loading { pointer-events: none; opacity: .8; }
.btn.is-loading > :not(.spinner-border) { opacity: .6; }
.btn-group > .btn { border-radius: var(--ap-radius-xs); }

/* 4. Forms ================================================================= */
.form-label { font-weight: 600; font-size: .85rem; color: var(--ap-text); margin-bottom: .4rem; }
.form-control, .form-select {
    background-color: var(--ap-surface); border: 1px solid var(--ap-border-strong); border-radius: var(--ap-radius-sm);
    padding: .6rem .85rem; font-size: .9375rem; color: var(--ap-text); box-shadow: var(--ap-shadow-sm);
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.form-control-sm, .form-select-sm { padding: .38rem .6rem; font-size: .85rem; border-radius: var(--ap-radius-xs); }
.form-control-lg { padding: .75rem 1rem; }
.form-control:hover, .form-select:hover { border-color: #C5D1DE; }
.form-control:focus, .form-select:focus { border-color: var(--ap-primary); box-shadow: var(--ap-ring); background-color: var(--ap-surface); }
.form-control::placeholder { color: #94A3B8; }
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background-color: var(--ap-muted-bg); color: var(--ap-text-3); box-shadow: none; }
textarea.form-control { min-height: 2.8rem; }
.form-text { color: var(--ap-text-3); font-size: .8rem; margin-top: .35rem; }
.form-check-input { border-color: var(--ap-border-strong); }
.form-check-input:checked { background-color: var(--ap-primary); border-color: var(--ap-primary); }
.form-check-input:focus { box-shadow: var(--ap-ring); border-color: var(--ap-primary); }
.form-switch .form-check-input { width: 2.5em; height: 1.35em; cursor: pointer; }
.input-group-text { background: var(--ap-surface-2); border-color: var(--ap-border-strong); color: var(--ap-text-3); }
.required-mark::after, label.required::after { content: ' *'; color: var(--ap-danger); }
/* Validation messages: soft red field, readable message with an icon */
.form-control.is-invalid, .form-select.is-invalid { border-color: #E58C90; background-color: #FFFAFA; }
.form-control.is-invalid:focus, .form-select.is-invalid:focus { box-shadow: 0 0 0 4px rgba(192, 38, 45, .12); }
.invalid-feedback { align-items: center; gap: .35rem; font-size: .8rem; font-weight: 550; color: var(--ap-danger); margin-top: .35rem; }
.invalid-feedback::before { content: '!'; display: inline-grid; place-items: center; width: 1rem; height: 1rem; border-radius: 50%; background: var(--ap-danger); color: #fff; font-size: .65rem; font-weight: 800; flex-shrink: 0; }
.was-validated .invalid-feedback, .is-invalid ~ .invalid-feedback, .invalid-feedback.d-block { display: flex !important; } /* Bootstrap uses display:block */
/* Form blocks */
.ap-qty-input { max-width: 92px; }
.ap-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .45rem .6rem; }
.ap-check-grid .form-check { padding: .55rem .7rem .55rem 2.2rem; border: 1px solid var(--ap-border); border-radius: var(--ap-radius-sm); background: var(--ap-surface); margin: 0; transition: border-color .15s, background .15s; cursor: pointer; }
.ap-check-grid .form-check:hover { border-color: rgba(var(--ap-primary-rgb), .35); background: var(--ap-hover); }
.ap-check-grid .form-check:has(input:checked) { border-color: rgba(var(--ap-primary-rgb), .55); background: var(--ap-primary-50); }
.ap-check-grid .form-check-label { cursor: pointer; font-weight: 550; font-size: .86rem; }
/* Segmented control (radio group: availability…) */
.ap-segmented { display: flex; flex-wrap: wrap; gap: .45rem; }
.ap-segmented .form-check { margin: 0; padding: 0; flex: 1 1 0; min-width: 110px; }
.ap-segmented .form-check-input { position: absolute; opacity: 0; pointer-events: none; }
.ap-segmented .form-check-label { display: block; text-align: center; padding: .6rem .5rem; border: 1px solid var(--ap-border-strong); border-radius: var(--ap-radius-sm); background: var(--ap-surface); font-weight: 600; font-size: .86rem; cursor: pointer; transition: background .12s, border-color .12s, color .12s, box-shadow .12s; }
.ap-segmented .form-check-label:hover { background: var(--ap-hover); }
.ap-segmented .form-check-input:checked + .form-check-label { background: var(--ap-primary-50); border-color: var(--ap-primary); color: var(--ap-primary-700); box-shadow: var(--ap-ring); }
.ap-segmented .form-check-input:focus-visible + .form-check-label { outline: 2px solid var(--ap-primary); }
.ap-segmented .form-check-label.required::after { content: none; } /* the field is required, not each option */
/* Sticky action bar at the bottom of long forms */
.ap-sticky-actions {
    position: sticky; bottom: .75rem; z-index: 5; display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap;
    margin-top: 1.25rem; padding: .85rem 1rem; background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px);
    border: 1px solid var(--ap-border); border-radius: var(--ap-radius); box-shadow: 0 -8px 24px -18px rgba(23, 43, 77, .35);
}
@media (max-width: 991.98px) {
    .ap-sticky-actions { bottom: calc(72px + env(safe-area-inset-bottom)); }
    .ap-sticky-actions > .btn { flex: 1; }
}

/* 5. App shell ============================================================= */
.ap-shell { min-height: 100vh; }
/* Keyboard users: "skip to content" link, visible only when focused; the content takes the focus without a ring. */
.ap-skip { position: absolute; inset-inline-start: .75rem; top: -4rem; z-index: 1100; padding: .55rem 1rem; border-radius: var(--ap-radius-sm); background: var(--ap-surface); font-weight: 650; }
.ap-skip:focus { top: .75rem; box-shadow: var(--ap-shadow-lg); }
.ap-content:focus { outline: none; }
.ap-sidebar {
    position: fixed; inset-block: 0; inset-inline: 0 auto; width: var(--ap-sidebar-w); z-index: 1030;
    display: flex; flex-direction: column; background: var(--ap-surface); border-inline-end: 1px solid var(--ap-border);
}
/* Official logo (templates/_partials/brand_logo.html.twig): only the height is set, the ratio is the file's. */
.ap-logo { display: block; height: var(--ap-logo-h, 40px); width: auto; max-width: 100%; object-fit: contain; flex-shrink: 0; }
.ap-brand { height: calc(var(--ap-topbar-h) + 8px); display: flex; align-items: center; padding: 0 1.25rem; --ap-logo-h: 46px; }
.ap-brand-mark { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, #18A262, var(--ap-primary-700)); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 14px -6px rgba(16, 121, 72, .6); flex-shrink: 0; }
/* The green text of the logo needs a light background: white plate on the green login panel. */
.ap-logo-plate { display: inline-flex; align-self: flex-start; background: #fff; border-radius: 16px; padding: .6rem .9rem; box-shadow: 0 10px 28px -14px rgba(0, 0, 0, .45); --ap-logo-h: 50px; }
.ap-auth-logo { --ap-logo-h: 52px; margin: 0 auto 1.75rem; }
.ap-topbar-brand { align-items: center; min-width: 0; }
.ap-topbar-logo { --ap-logo-h: 30px; }
.ap-offline-logo { --ap-logo-h: 44px; margin: 0 auto 1.25rem; }
.ap-nav { padding: .5rem .85rem 1rem; overflow-y: auto; flex: 1; }
.ap-nav-section { margin: 1.1rem .65rem .4rem; }
.ap-nav-section:first-child { margin-top: .5rem; }
.ap-nav-link {
    position: relative; display: flex; align-items: center; gap: .7rem; padding: .58rem .75rem; margin-bottom: 2px;
    border-radius: var(--ap-radius-sm); color: var(--ap-text-2); font-weight: 550; font-size: .9rem; transition: background .15s, color .15s;
}
.ap-nav-link svg { width: 18px; height: 18px; color: #94A3B8; transition: color .15s; }
.ap-nav-link:hover { background: var(--ap-hover); color: var(--ap-primary-700); }
.ap-nav-link:hover svg { color: var(--ap-primary); }
.ap-nav-link.active { background: var(--ap-primary-50); color: var(--ap-primary-700); font-weight: 650; }
.ap-nav-link.active::before { content: ''; position: absolute; inset-inline-start: -.85rem; top: 8px; bottom: 8px; width: 4px; border-start-end-radius: 4px; border-end-end-radius: 4px; background: var(--ap-primary); }
.ap-nav-link.active svg { color: var(--ap-primary); }
.ap-nav-link .badge { margin-inline-start: auto; }
.ap-sidebar-footer { border-top: 1px solid var(--ap-border); padding: .9rem 1rem 1rem; background: var(--ap-surface-2); }
.ap-user { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.ap-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--ap-primary-50), var(--ap-primary-100)); color: var(--ap-primary-700); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.ap-avatar--sm { width: 30px; height: 30px; font-size: .7rem; }
.ap-avatar--md { width: 32px; height: 32px; font-size: .72rem; }
.ap-user-name { font-weight: 650; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-user-role { font-size: .74rem; color: var(--ap-text-3); }
.ap-user-toggle { padding: 0; width: 2.4rem; height: 2.4rem; border-radius: 50%; }

.ap-main { margin-inline-start: var(--ap-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.ap-topbar {
    position: sticky; top: 0; z-index: 1020; height: var(--ap-topbar-h); display: flex; align-items: center; gap: .75rem;
    padding: 0 1.75rem; background: rgba(247, 250, 255, .85); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid transparent;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.ap-topbar.is-scrolled { background: rgba(255, 255, 255, .92); border-bottom-color: var(--ap-border); box-shadow: 0 6px 20px -16px rgba(23, 43, 77, .35); }
.ap-topbar-title { font-weight: 650; font-size: 1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-topbar .btn-ghost.btn-icon { border-radius: 50%; }
.ap-content { padding: 1.5rem 1.75rem 3rem; flex: 1; width: 100%; max-width: 1440px; }
.ap-bell { position: relative; }
.ap-bell .ap-dot {
    position: absolute; top: 2px; inset-inline-end: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--ap-danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--ap-bg);
}
.ap-mobile-only { display: none !important; }      /* display utilities: must beat the component display rules */
.offcanvas.ap-offcanvas { --bs-offcanvas-width: 292px; }
.offcanvas.ap-offcanvas .ap-sidebar { display: flex; position: static; width: 100%; height: 100%; border-inline-end: 0; }
.ap-bottom-nav { display: none; }

@media (max-width: 991.98px) {
    .ap-sidebar { display: none; }
    .ap-main { margin-inline-start: 0; }
    .ap-topbar { padding: 0 1rem; background: rgba(255, 255, 255, .94); border-bottom-color: var(--ap-border); }
    .ap-content { padding: 1rem 1rem calc(88px + env(safe-area-inset-bottom)); }
    .ap-mobile-only { display: inline-flex !important; }
    .ap-desktop-only { display: none !important; }
    .ap-bottom-nav {
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset: auto 0 0 0; z-index: 1030;
        background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px); border-top: 1px solid var(--ap-border);
        padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px -18px rgba(23, 43, 77, .4);
    }
    .ap-bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: .3rem 0; font-size: .68rem; font-weight: 600; color: var(--ap-text-3); border-radius: 12px; }
    .ap-bottom-nav a svg { width: 22px; height: 22px; }
    .ap-bottom-nav a.active { color: var(--ap-primary); }
    .ap-bottom-nav a.ap-fab-link { color: #fff; }
    .ap-bottom-nav a.ap-fab-link span.ap-fab { width: 46px; height: 46px; margin-top: -20px; border-radius: 15px; background: linear-gradient(135deg, #18A262, var(--ap-primary-700)); display: grid; place-items: center; box-shadow: 0 8px 18px -6px rgba(16, 121, 72, .65); }
    .ap-bottom-nav a.ap-fab-link small { color: var(--ap-text-3); }
}

/* 6. Page headers ========================================================== */
.ap-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.ap-page-header h1 { font-size: 1.55rem; margin: 0; }
.ap-page-header .ap-subtitle { color: var(--ap-text-3); margin: .3rem 0 0; font-size: .9rem; }
.ap-breadcrumb { font-size: .8rem; color: var(--ap-text-3); margin-bottom: .35rem; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.ap-breadcrumb a { color: var(--ap-text-3); }
.ap-breadcrumb a:hover { color: var(--ap-primary); }
.ap-breadcrumb svg { width: 14px; height: 14px; opacity: .6; }
.ap-back {
    display: inline-flex; align-items: center; gap: .35rem; font-size: .84rem; font-weight: 600; color: var(--ap-text-3); margin-bottom: .6rem;
    padding: .25rem .65rem .25rem .45rem; border-radius: 999px; background: var(--ap-surface); border: 1px solid var(--ap-border); transition: color .15s, border-color .15s, background .15s;
}
.ap-back:hover { color: var(--ap-primary-700); border-color: rgba(var(--ap-primary-rgb), .35); background: var(--ap-hover); }
.ap-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
/* Detail pages: header card with reference + status */
.ap-page-header--detail {
    align-items: center; padding: 1.25rem 1.4rem 1.25rem 1.6rem; background: var(--ap-surface); border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius); box-shadow: var(--ap-shadow); position: relative; overflow: hidden;
}
.ap-page-header--detail::before { content: ''; position: absolute; inset-block: 0; inset-inline: 0 auto; width: 5px; background: linear-gradient(180deg, #18A262, var(--ap-primary-700)); }
.ap-page-header--detail h1 { font-size: 1.4rem; }
.ap-page-header--detail h1 .font-mono { font-size: 1.1rem; letter-spacing: 0; padding: .15rem .55rem; border-radius: var(--ap-radius-xs); background: var(--ap-primary-50); color: var(--ap-primary-700); }
.ap-page-header--detail .ap-back { margin-bottom: .75rem; }
@media (max-width: 575.98px) {
    .ap-page-header h1 { font-size: 1.25rem; }
    .ap-page-header .ap-actions { width: 100%; }
    .ap-page-header .ap-actions > .btn, .ap-page-header .ap-actions > form { flex: 1; }
    .ap-page-header .ap-actions > form .btn { width: 100%; }
    .ap-page-header--detail { padding: 1rem 1rem 1rem 1.25rem; }
}

/* 7. Cards, panels & tones ================================================= */
.card {
    --bs-card-bg: var(--ap-surface); --bs-card-border-color: var(--ap-border); --bs-card-border-radius: var(--ap-radius);
    --bs-card-inner-border-radius: calc(var(--ap-radius) - 1px); --bs-card-cap-bg: transparent;
    box-shadow: var(--ap-shadow);
}
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--ap-border); display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card-header h2, .card-header h3, .card-title { font-size: 1rem; margin: 0; font-weight: 680; display: inline-flex; align-items: center; gap: .5rem; }
.card-header h2 svg, .card-header h3 svg { color: var(--ap-primary); width: 18px; height: 18px; }
.card-body { padding: 1.25rem; }
.card-footer { background: var(--ap-surface-2); border-top: 1px solid var(--ap-border); padding: .9rem 1.25rem; }
.card.border-warning { border-color: #F5D58F; background: linear-gradient(180deg, #FFFBF2, var(--ap-surface) 60%); }

/* Legacy stat card (kept for compatibility; dashboards use .ap-kpi) */
.ap-stat { padding: 1.15rem 1.25rem; display: flex; gap: 1rem; align-items: flex-start; height: 100%; }
.ap-stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.ap-stat-icon svg { width: 20px; height: 20px; }
.ap-stat-label { font-size: .8rem; color: var(--ap-text-3); font-weight: 550; }
.ap-stat-value { font-size: 1.65rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; color: var(--ap-text); }
.ap-stat-hint { font-size: .78rem; color: var(--ap-text-3); }
a.card.ap-stat-card { color: inherit; transition: box-shadow .15s, transform .15s, border-color .15s; }
a.card.ap-stat-card:hover { box-shadow: var(--ap-shadow-lg); border-color: var(--ap-border-strong); transform: translateY(-2px); }
@media (max-width: 575.98px) {
    .ap-stat { flex-direction: column; gap: .6rem; padding: 1rem; }
    .ap-stat-icon { width: 34px; height: 34px; border-radius: 9px; }
    .ap-stat-value { font-size: 1.4rem; }
}

/* Tones: pastel background + readable foreground (≥ 4.5:1) */
.tone-primary, .tone-success { background: var(--ap-success-bg); color: var(--ap-success); }
.tone-info { background: var(--ap-info-bg); color: var(--ap-info); }
.tone-warning { background: var(--ap-warning-bg); color: var(--ap-warning); }
.tone-danger { background: var(--ap-danger-bg); color: var(--ap-danger); }
.tone-dark { background: var(--ap-dark-bg); color: var(--ap-dark); }
.tone-neutral { background: var(--ap-muted-bg); color: var(--ap-text-2); }
.tone-muted { background: var(--ap-muted-bg); color: var(--ap-text-3); }
.tone-violet { background: var(--ap-violet-bg); color: var(--ap-violet); }
.tone-teal { background: var(--ap-teal-bg); color: var(--ap-teal); }
.tone-orange { background: var(--ap-orange-bg); color: var(--ap-orange); }

/* 8. Badges & chips ======================================================== */
.ap-badge { display: inline-flex; align-items: center; gap: .38rem; padding: .25rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 650; white-space: nowrap; line-height: 1.35; border: 1px solid transparent; }
.ap-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.ap-badge.no-dot::before { display: none; }
.ap-badge svg { width: 13px; height: 13px; }
.ap-badge.tone-primary, .ap-badge.tone-success { border-color: #CBEBD9; }
.ap-badge.tone-info { border-color: #CFE0FC; }
.ap-badge.tone-warning { border-color: #F7DDA9; }
.ap-badge.tone-danger { border-color: #F5CDCF; }
.ap-badge.tone-violet { border-color: #E0D2FC; }
.ap-badge.tone-dark { border-color: #D3DCE8; }
.ap-badge.tone-neutral, .ap-badge.tone-muted { border-color: var(--ap-border); }
.ap-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: var(--ap-radius-xs); font-size: .76rem; font-weight: 600; background: var(--ap-surface-2); color: var(--ap-text-2); border: 1px solid var(--ap-border); white-space: nowrap; }
.ap-qty { display: inline-flex; align-items: center; justify-content: center; min-width: 2.1rem; height: 1.7rem; padding: 0 .5rem; border-radius: var(--ap-radius-xs); background: var(--ap-primary-50); color: var(--ap-primary-700); font-weight: 750; font-size: .8rem; font-variant-numeric: tabular-nums; }
.ap-price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ap-margin-pos { color: var(--ap-primary-700); font-weight: 650; }
.ap-margin-neg { color: var(--ap-danger); font-weight: 650; }

/* 9. Dropdowns & notification items ======================================== */
.dropdown-menu {
    --bs-dropdown-border-color: var(--ap-border); --bs-dropdown-border-radius: 14px; --bs-dropdown-link-hover-bg: var(--ap-hover);
    --bs-dropdown-link-active-bg: var(--ap-primary-50); --bs-dropdown-link-active-color: var(--ap-primary-700);
    box-shadow: var(--ap-shadow-lg); padding: .45rem; font-size: .875rem;
}
.ap-dropdown-wide { min-width: 248px; }
.dropdown-item { border-radius: var(--ap-radius-xs); padding: .5rem .7rem; display: flex; align-items: center; gap: .55rem; font-weight: 550; }
.dropdown-item svg { width: 16px; height: 16px; color: var(--ap-text-3); }
.dropdown-item:hover svg { color: var(--ap-primary); }
.dropdown-item.text-danger:hover { background: var(--ap-danger-bg); }
.ap-notif-menu { width: min(390px, calc(100vw - 2rem)); padding: 0; overflow: hidden; }
.ap-notif-item { display: flex; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--ap-border); color: var(--ap-text); font-size: .86rem; transition: background .12s; }
.ap-notif-item:last-child { border-bottom: 0; }
.ap-notif-item:hover { background: var(--ap-hover); color: var(--ap-text); }
.ap-notif-item.is-unread { background: #F6FCF9; }
.ap-notif-item .ap-notif-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.ap-notif-item time { font-size: .74rem; color: var(--ap-text-3); }

/* 10. Tables & data cards ================================================== */
/* Positioned scroll container: absolutely positioned content (e.g. a .visually-hidden column title) stays inside it
   instead of widening the whole page (admin request list at 768–1024 px). */
.table-responsive { position: relative; }
.ap-table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--ap-hover); margin: 0; font-size: .875rem; color: var(--ap-text); }
.ap-table > thead th {
    background: var(--ap-surface-2); color: var(--ap-text-3); font-weight: 650; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    border-bottom: 1px solid var(--ap-border); padding: .8rem 1.1rem; white-space: nowrap;
}
.ap-table > tbody td { padding: .95rem 1.1rem; border-color: var(--ap-border); vertical-align: middle; }
.ap-table > tbody tr:last-child td { border-bottom: 0; }
.ap-table > tbody tr { transition: background-color .12s; }
.ap-table.ap-table-hover > tbody tr:hover > td { background: var(--ap-hover); }
.ap-table > tfoot td { background: var(--ap-surface-2); border-top: 1px solid var(--ap-border); border-bottom: 0; }
.ap-cell-title { font-weight: 650; color: var(--ap-text); }
.ap-cell-sub { font-size: .8rem; color: var(--ap-text-3); margin-top: .1rem; }
.ap-td-actions .btn-ghost { color: var(--ap-text-3); }
.ap-td-actions .btn-ghost:hover { color: var(--ap-primary-700); }
/* Clickable rows and references */
tr.ap-row-link, tr[data-href] { cursor: pointer; }
tr[data-href]:focus-visible { outline: 2px solid var(--ap-primary); outline-offset: -2px; }
a.ap-ref {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; font-weight: 700; color: var(--ap-primary-700);
    padding: .12rem .45rem; border-radius: 6px; background: var(--ap-primary-50); border: 1px solid transparent; transition: border-color .15s, background .15s;
}
a.ap-ref:hover, a.ap-ref:focus-visible { border-color: rgba(var(--ap-primary-rgb), .4); background: var(--ap-primary-100); color: var(--ap-primary-700); }
/* Phones: each row becomes a data card */
@media (max-width: 767.98px) {
    .ap-table-stack thead { display: none; }
    .ap-table-stack, .ap-table-stack tbody, .ap-table-stack tr, .ap-table-stack td { display: block; width: 100%; }
    .ap-table-stack > tbody { padding: .75rem; }
    .ap-table-stack > tbody tr { padding: .9rem 1rem; margin-bottom: .65rem; border: 1px solid var(--ap-border); border-radius: var(--ap-radius-sm); background: var(--ap-surface); box-shadow: var(--ap-shadow-sm); }
    .ap-table-stack > tbody tr:last-child { margin-bottom: 0; }
    .ap-table.ap-table-hover.ap-table-stack > tbody tr:hover { border-color: rgba(var(--ap-primary-rgb), .35); }
    .ap-table.ap-table-hover.ap-table-stack > tbody tr:hover > td { background: transparent; }
    .ap-table-stack > tbody td { padding: .2rem 0; border: 0; text-align: end; overflow: hidden; }
    .ap-table-stack > tbody td[data-label]::before { content: attr(data-label); float: inline-start; margin-inline-end: 1rem; color: var(--ap-text-3); font-size: .78rem; font-weight: 600; text-align: start; line-height: 1.9; }
    .ap-table-stack > tbody td.ap-td-main { text-align: start; padding-bottom: .5rem; margin-bottom: .3rem; border-bottom: 1px dashed var(--ap-border); }
    .ap-table-stack > tbody td.ap-td-main::before { display: none; }
    .ap-table-stack > tbody td.ap-td-actions { padding-top: .55rem; }
    .ap-table-stack > tfoot, .ap-table-stack > tfoot tr, .ap-table-stack > tfoot td { display: block; }
}

/* 11. Filters, search & tabs =============================================== */
.ap-filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--ap-border); background: var(--ap-surface); }
.ap-filters .ap-search { position: relative; flex: 1 1 260px; }
.ap-filters .ap-search svg { position: absolute; inset-inline-start: .85rem; top: 50%; transform: translateY(-50%); color: #94A3B8; width: 17px; height: 17px; pointer-events: none; }
.ap-filters .ap-search .form-control { padding-inline-start: 2.45rem; border-radius: 999px; background: var(--ap-surface-2); }
.ap-filters .ap-search .form-control:focus { background: var(--ap-surface); }
.ap-filters .form-select, .ap-filters .form-control[type=date] { width: auto; flex: 0 1 auto; min-width: 145px; border-radius: 999px; font-size: .86rem; padding-top: .5rem; padding-bottom: .5rem; }
@media (max-width: 575.98px) {
    .ap-filters { padding: .85rem; }
    .ap-filters .form-select { flex: 1 1 calc(50% - .6rem); min-width: 0; }
    .ap-filters .form-control[type=date] { display: none; } /* date range: desktop only */
}
.ap-tabs { display: flex; gap: .35rem; overflow-x: auto; padding: .7rem .9rem; border-bottom: 1px solid var(--ap-border); scrollbar-width: none; background: var(--ap-surface); border-radius: var(--ap-radius) var(--ap-radius) 0 0; }
.ap-tabs::-webkit-scrollbar { display: none; }
.ap-tabs a { padding: .42rem .85rem; color: var(--ap-text-2); font-weight: 600; font-size: .85rem; border-radius: 999px; white-space: nowrap; display: inline-flex; gap: .4rem; align-items: center; border: 1px solid transparent; transition: background .15s, color .15s, border-color .15s; }
.ap-tabs a:hover { background: var(--ap-hover); color: var(--ap-primary-700); }
.ap-tabs a.active { background: var(--ap-primary-50); color: var(--ap-primary-700); border-color: #CBEBD9; }
.ap-tabs a .ap-count { background: var(--ap-surface); border: 1px solid var(--ap-border); border-radius: 999px; padding: 0 .45rem; font-size: .72rem; font-weight: 700; color: var(--ap-text-2); }
.ap-tabs a.active .ap-count { border-color: #CBEBD9; color: var(--ap-primary-700); }
.ap-tabs--standalone { border: 1px solid var(--ap-border); border-radius: var(--ap-radius); box-shadow: var(--ap-shadow-sm); }

/* 12. Pagination & empty states ============================================ */
.pagination {
    --bs-pagination-color: var(--ap-text-2); --bs-pagination-bg: var(--ap-surface); --bs-pagination-border-color: var(--ap-border);
    --bs-pagination-hover-color: var(--ap-primary-700); --bs-pagination-hover-bg: var(--ap-hover); --bs-pagination-hover-border-color: rgba(var(--ap-primary-rgb), .35);
    --bs-pagination-active-bg: var(--ap-primary); --bs-pagination-active-border-color: var(--ap-primary);
    --bs-pagination-disabled-color: #A0AEC0; --bs-pagination-disabled-bg: var(--ap-surface); --bs-pagination-focus-box-shadow: var(--ap-ring);
    --bs-pagination-border-radius: var(--ap-radius-xs);
    gap: .3rem; margin: 0;
}
.pagination .page-item .page-link { border-radius: var(--ap-radius-xs); margin-inline-start: 0; min-width: 2.1rem; text-align: center; font-weight: 600; }
.ap-pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .9rem 1.25rem; border-top: 1px solid var(--ap-border); font-size: .85rem; color: var(--ap-text-3); background: var(--ap-surface-2); border-radius: 0 0 var(--ap-radius) var(--ap-radius); }
.ap-empty { text-align: center; padding: 3.25rem 1.5rem; color: var(--ap-text-3); }
.ap-empty-icon { width: 68px; height: 68px; border-radius: 22px; background: linear-gradient(135deg, var(--ap-primary-50), var(--ap-info-bg)); display: grid; place-items: center; margin: 0 auto 1rem; color: var(--ap-primary); box-shadow: inset 0 0 0 1px rgba(var(--ap-primary-rgb), .12); }
.ap-empty-icon svg { width: 30px; height: 30px; }
.ap-empty h3 { font-size: 1.02rem; margin-bottom: .35rem; }
.ap-empty p { max-width: 420px; margin-inline: auto; }
[data-ajax-region] { position: relative; transition: opacity .15s; }
[data-ajax-region].is-loading { opacity: .55; pointer-events: none; }
.ap-progress { position: fixed; top: 0; inset-inline-start: 0; height: 3px; width: 0; background: linear-gradient(90deg, #18A262, var(--ap-info)); z-index: 2000; transition: width .25s ease, opacity .3s; opacity: 0; }
.ap-progress.is-active { opacity: 1; }

/* 13. Toasts, alerts & modals ============================================== */
/* Top right under the top bar (desktop), full width under the top bar (phone); newest first. */
.ap-toasts { position: fixed; inset-inline-end: 1rem; top: calc(var(--ap-topbar-h) + .75rem); z-index: 1090; display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: .55rem; width: min(410px, calc(100vw - 2rem)); }
@media (max-width: 991.98px) { .ap-toasts { top: calc(var(--ap-topbar-h) + env(safe-area-inset-top) + .5rem); inset-inline: 16px; width: auto; } }
.ap-toast {
    display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1rem; background: var(--ap-surface); border: 1px solid var(--ap-border);
    border-inline-start: 5px solid var(--ap-primary); border-radius: 14px; box-shadow: var(--ap-shadow-lg); font-size: .875rem; animation: ap-in .25s ease;
}
.ap-toast[data-href] { cursor: pointer; }
.ap-toast.is-danger { border-inline-start-color: var(--ap-danger); }
.ap-toast.is-warning, .ap-toast.is-warning-alert { border-inline-start-color: #F59E0B; }
.ap-toast.is-info, .ap-toast.is-offer { border-inline-start-color: var(--ap-info); }
.ap-toast .btn-close { margin-inline-start: auto; font-size: .65rem; }
.ap-toast.is-leaving { animation: ap-out .2s ease forwards; }
.ap-toast-body { min-width: 0; }
.ap-toast-title { font-weight: 700; display: block; }
.ap-toast-text { color: var(--ap-text-2); font-size: .82rem; display: block; }
.ap-toast-time { color: var(--ap-text-3); font-size: .74rem; display: block; margin-bottom: .1rem; }
.ap-toast-link { display: inline-flex; align-items: center; gap: .25rem; margin-top: .35rem; font-weight: 650; font-size: .8rem; }
.ap-toast-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--ap-success-bg); color: var(--ap-primary); }
.ap-toast.is-offer .ap-toast-icon { background: var(--ap-info-bg); color: var(--ap-info); }
.ap-toast.is-warning-alert .ap-toast-icon { background: var(--ap-warning-bg); color: var(--ap-warning); }
.ap-toast.is-order { border-inline-start: 6px solid var(--ap-violet); padding: 1rem 1.1rem; box-shadow: 0 18px 40px -12px rgba(107, 63, 201, .45); animation: ap-in .25s ease, ap-toast-attention .6s ease .3s 1; }
.ap-toast.is-order .ap-toast-icon { background: var(--ap-violet); color: #fff; width: 40px; height: 40px; }
.ap-toast.is-order .ap-toast-title { font-size: .98rem; }
@keyframes ap-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes ap-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes ap-toast-attention { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-3px); } }

.alert { border-radius: var(--ap-radius-sm); font-size: .875rem; border: 1px solid; border-inline-start-width: 4px; display: flex; gap: .65rem; align-items: flex-start; padding: .85rem 1rem; }
.alert svg { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; }
.alert a { font-weight: 650; }
.alert-warning { background: var(--ap-warning-bg); border-color: #F5D58F; border-inline-start-color: #F59E0B; color: #6B3A00; }
.alert-danger { background: var(--ap-danger-bg); border-color: #F4C5C7; border-inline-start-color: var(--ap-danger); color: #8F1C21; }
.alert-info { background: var(--ap-info-bg); border-color: #CFE0FC; border-inline-start-color: var(--ap-info); color: #173F8A; }
.alert-success { background: var(--ap-success-bg); border-color: #CBEBD9; border-inline-start-color: var(--ap-primary); color: var(--ap-primary-700); }

.modal-content { border: 0; border-radius: 20px; box-shadow: 0 30px 60px -20px rgba(23, 43, 77, .45); }
.modal-backdrop { --bs-backdrop-bg: #0F1E36; --bs-backdrop-opacity: .45; }
.modal-header { border-bottom: 0; padding: 1.4rem 1.5rem .5rem; }
.modal-body { padding: .5rem 1.5rem 1rem; color: var(--ap-text-2); }
.modal-footer { border-top: 0; padding: .5rem 1.5rem 1.4rem; gap: .5rem; }
.modal-title { font-size: 1.08rem; font-weight: 700; }

/* 14. Touch, right-to-left & motion preferences ============================ */
/* Touch screens (phones, tablets): every button and field keeps a 44 px target; mouse screens keep the denser sizes. */
@media (pointer: coarse) {
    .btn, .form-control, .form-select { min-height: 44px; }
}
/* Inter has no Arabic glyphs: Arabic text falls back to a readable Arabic face, Latin text stays in Inter. */
/* Right to left: the arrows of the back links and of the pagination point the reading direction. */
html[dir="rtl"] .ap-back svg, html[dir="rtl"] .pagination .page-link svg, html[dir="rtl"] .ap-kpi-go svg { transform: scaleX(-1); }
html[dir="rtl"] { --bs-body-font-family: 'Inter', 'Noto Sans Arabic', Tahoma, 'Segoe UI', Arial, sans-serif; }
/* Accessibility: no motion for users who asked for it (covers every animation of the application). */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 15. Dashboards: greeting banner & KPI cards (back-office and customer dashboards) ====== */
.ap-hello { background: linear-gradient(120deg, #107948 0%, #13985A 55%, #1D5FD1 140%); color: #fff; border-radius: 22px; padding: 1.45rem 1.55rem; margin-bottom: 1.5rem; position: relative; overflow: hidden; box-shadow: 0 16px 32px -20px rgba(16, 121, 72, .8); }
.ap-hello::after { content: ''; position: absolute; inset-inline-end: -60px; bottom: -90px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .09); }
.ap-hello h1 { color: #fff; font-size: 1.45rem; margin: 0 0 .25rem; }
.ap-hello p { color: rgba(255, 255, 255, .88); margin: 0; font-size: .9rem; }
.ap-hello .btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: #fff; --bs-btn-color: var(--ap-primary-700); }
.ap-hello .btn-group .btn { --bs-btn-color: #fff; --bs-btn-border-color: rgba(255, 255, 255, .45); --bs-btn-hover-bg: rgba(255, 255, 255, .15); --bs-btn-hover-color: #fff; --bs-btn-bg: transparent; box-shadow: none; }
.ap-hello .btn-group .btn.is-active { --bs-btn-bg: #fff; --bs-btn-color: var(--ap-primary-700); --bs-btn-border-color: #fff; }
.ap-hello-inner { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }

.ap-kpi {
    --kpi-fg: var(--ap-primary); --kpi-bg: var(--ap-success-bg); --kpi-strong: var(--ap-primary);
    position: relative; display: flex; flex-direction: column; gap: .9rem; height: 100%; overflow: hidden; text-decoration: none;
    padding: 1.15rem 1.2rem 1.1rem; border-radius: 18px; background: var(--ap-surface); color: var(--ap-text);
    border: 1px solid var(--ap-border); box-shadow: var(--ap-shadow); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.ap-kpi::after { content: ''; position: absolute; inset-inline-end: -40px; top: -40px; width: 130px; height: 130px; border-radius: 50%; background: var(--kpi-bg); opacity: .9; pointer-events: none; transition: transform .25s ease; }
a.ap-kpi:hover, a.ap-kpi:focus-visible { transform: translateY(-3px); box-shadow: 0 12px 28px -12px rgba(23, 43, 77, .28); border-color: var(--kpi-fg); color: var(--ap-text); }
a.ap-kpi:hover::after { transform: scale(1.15); }
a.ap-kpi:focus-visible { outline: 3px solid rgba(var(--ap-primary-rgb), .35); outline-offset: 2px; }
.ap-kpi-head { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.ap-kpi-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--kpi-bg); color: var(--kpi-fg); }
.ap-kpi-icon svg { width: 22px; height: 22px; }
.ap-kpi-value { position: relative; z-index: 1; font-size: 2.15rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--ap-text); font-variant-numeric: tabular-nums; }
.ap-kpi-value.is-text { font-size: 1.45rem; }
.ap-kpi-label { position: relative; z-index: 1; font-weight: 650; font-size: .92rem; color: var(--ap-text); margin-top: -.35rem; }
.ap-kpi-hint { position: relative; z-index: 1; font-size: .78rem; color: var(--ap-text-3); }
.ap-kpi-flag { display: none; align-items: center; gap: .35rem; padding: .2rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 700; background: var(--kpi-strong); color: #fff; white-space: nowrap; }
.ap-kpi-flag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.ap-kpi-go { position: relative; z-index: 1; margin-top: auto; font-size: .78rem; font-weight: 650; color: var(--kpi-fg); display: inline-flex; align-items: center; gap: .3rem; }
.ap-kpi--green  { --kpi-fg: #107948; --kpi-bg: #EAF7F0; --kpi-strong: #107948; }
.ap-kpi--blue   { --kpi-fg: #1D5FD1; --kpi-bg: #E9F2FF; --kpi-strong: #1D5FD1; }
.ap-kpi--orange { --kpi-fg: #9A5200; --kpi-bg: #FFF2DB; --kpi-strong: #D97706; }
.ap-kpi--violet { --kpi-fg: #6B3FC9; --kpi-bg: #F2EBFF; --kpi-strong: #6B3FC9; }
.ap-kpi--amber  { --kpi-fg: #C2410C; --kpi-bg: #FFE6CC; --kpi-strong: #EA580C; }
.ap-kpi--teal   { --kpi-fg: #0B7F82; --kpi-bg: #E2F7F6; --kpi-strong: #0B7F82; }
.ap-kpi--navy   { --kpi-fg: #172B4D; --kpi-bg: #E8EDF5; --kpi-strong: #172B4D; }
.ap-kpi.is-attention { border: 2px solid var(--kpi-strong); background: linear-gradient(180deg, var(--kpi-bg) 0%, var(--ap-surface) 70%); box-shadow: 0 10px 26px -14px var(--kpi-strong); }
.ap-kpi.is-attention .ap-kpi-icon { background: var(--kpi-strong); color: #fff; }
.ap-kpi.is-attention .ap-kpi-flag { display: inline-flex; }
.ap-kpi.is-attention .ap-kpi-value { color: var(--kpi-fg); }
@keyframes ap-kpi-bump {
    0% { transform: scale(1); box-shadow: 0 0 0 0 var(--kpi-strong); }
    25% { transform: scale(1.035); box-shadow: 0 0 0 6px color-mix(in srgb, var(--kpi-strong) 25%, transparent); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}
@keyframes ap-value-pop { 0% { transform: translateY(6px); opacity: .2; } 100% { transform: none; opacity: 1; } }
.ap-kpi.is-bumped { animation: ap-kpi-bump 1.2s ease-out 2; }
.ap-kpi.is-bumped .ap-kpi-value { animation: ap-value-pop .45s ease-out; }
@media (max-width: 575.98px) {
    .ap-kpi { padding: .95rem; gap: .7rem; border-radius: 16px; }
    .ap-kpi-icon { width: 38px; height: 38px; border-radius: 11px; }
    .ap-kpi-value { font-size: 1.75rem; }
    .ap-kpi-label { font-size: .85rem; }
    .ap-kpi-go { display: none; }
}

/* 16. Detail blocks: facts, items, timeline, files ======================================== */
.ap-dl { display: grid; grid-template-columns: minmax(110px, 35%) 1fr; gap: .6rem 1rem; margin: 0; font-size: .875rem; }
.ap-dl dt { color: var(--ap-text-3); font-weight: 550; }
.ap-dl dd { margin: 0; font-weight: 600; word-break: break-word; }
.ap-item-card { border: 1px solid var(--ap-border); border-radius: var(--ap-radius-sm); padding: 1rem 1.1rem; background: var(--ap-surface); transition: border-color .15s, box-shadow .15s; }
.ap-item-card:hover { border-color: #D7E3EF; box-shadow: var(--ap-shadow-sm); }
.ap-item-card + .ap-item-card { margin-top: .75rem; }
.ap-item-card.is-cancelled { opacity: .6; background: var(--ap-surface-2); }
/* Timeline */
.ap-timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.ap-timeline::before { content: ''; position: absolute; inset-inline-start: 16px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(180deg, var(--ap-primary-100), var(--ap-border)); border-radius: 2px; }
.ap-timeline li { position: relative; padding-block: 0 1.2rem; padding-inline: 2.9rem 0; }
.ap-timeline li:last-child { padding-block-end: 0; }
.ap-timeline .ap-tl-icon { position: absolute; inset-inline-start: 0; top: 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ap-surface); border: 2px solid var(--ap-primary-100); color: var(--ap-primary); box-shadow: 0 0 0 4px var(--ap-surface); }
.ap-timeline .ap-tl-icon svg { width: 15px; height: 15px; }
.ap-timeline li:last-child .ap-tl-icon { background: var(--ap-primary); border-color: var(--ap-primary); color: #fff; }
.ap-timeline .ap-tl-title { font-weight: 650; font-size: .88rem; padding-top: .35rem; }
.ap-timeline .ap-tl-meta { font-size: .78rem; color: var(--ap-text-3); }
/* Files */
.ap-dropzone { border: 2px dashed #CFDAE6; border-radius: var(--ap-radius); padding: 1.6rem; text-align: center; color: var(--ap-text-3); background: var(--ap-surface-2); transition: border-color .15s, background .15s; cursor: pointer; }
.ap-dropzone:hover, .ap-dropzone.is-dragover { border-color: var(--ap-primary); background: var(--ap-primary-50); color: var(--ap-primary-700); }
.ap-dropzone svg { width: 30px; height: 30px; margin-bottom: .4rem; color: var(--ap-primary); }
.ap-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.ap-file { display: flex; gap: .7rem; align-items: center; padding: .6rem; border: 1px solid var(--ap-border); border-radius: var(--ap-radius-sm); background: var(--ap-surface); min-width: 0; position: relative; transition: border-color .15s, box-shadow .15s; color: var(--ap-text); }
.ap-file:hover { border-color: #D7E3EF; box-shadow: var(--ap-shadow-sm); color: var(--ap-text); }
.ap-file-thumb { width: 50px; height: 50px; border-radius: var(--ap-radius-xs); background: var(--ap-muted-bg); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; color: var(--ap-text-3); }
.ap-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ap-file-name { font-weight: 650; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-file-meta { font-size: .74rem; color: var(--ap-text-3); }
.ap-file .progress { height: 4px; margin-top: .35rem; }
.ap-file.is-error { border-color: #F4C5C7; background: var(--ap-danger-bg); }
/* 17. Authentication, offline page & password field ====================================== */
.ap-auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--ap-bg); }
.ap-auth-aside { background: radial-gradient(900px 500px at -10% -10%, #22B36D 0%, transparent 60%), linear-gradient(140deg, #107948 0%, #0C6A3D 55%, #1D4FA8 140%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.ap-auth-aside::after { content: ''; position: absolute; inset-block: auto -160px; inset-inline: auto -120px; width: 440px; height: 440px; border-radius: 50%; border: 64px solid rgba(255, 255, 255, .06); }
.ap-auth-aside h2 { color: #fff; font-size: 2.05rem; line-height: 1.2; max-width: 470px; }
.ap-auth-aside p { color: rgba(255, 255, 255, .85); max-width: 440px; }
.ap-auth-feature { display: flex; gap: .75rem; align-items: center; color: rgba(255, 255, 255, .92); font-size: .9rem; margin-top: .8rem; }
.ap-auth-feature span { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .14); display: grid; place-items: center; }
.ap-auth-main { display: grid; place-items: center; padding: 2rem 1.25rem; }
.ap-auth-card { width: 100%; max-width: 420px; background: var(--ap-surface); border: 1px solid var(--ap-border); border-radius: 22px; padding: 2.25rem 2rem; box-shadow: var(--ap-shadow-lg); }
/* Show / hide password (assets/js/password-toggle.js) */
.ap-password { position: relative; }
.ap-password > .form-control { padding-inline-end: 3rem; }
/* The eye button sits where Bootstrap draws its error icon: no icon, the red border and the message remain. */
.ap-password > .form-control.is-invalid { background-image: none; }
.ap-password-toggle { position: absolute; top: 50%; inset-inline-end: .35rem; transform: translateY(-50%); width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--ap-text-3); }
.ap-password-toggle:hover { color: var(--ap-text); background: var(--ap-surface-2); }
.ap-password-toggle:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 1px; }
@media (max-width: 991.98px) { .ap-auth { grid-template-columns: 1fr; } .ap-auth-aside { display: none; } }
@media (max-width: 575.98px) { .ap-auth-card { padding: 1.6rem 1.25rem; border-radius: 18px; } .ap-auth-logo { --ap-logo-h: 46px; } }
/* Offline page of the Progressive Web App (back-office and customer space). */
.ap-offline { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; background: var(--ap-bg); }
.ap-offline-card { max-width: 420px; width: 100%; text-align: center; background: var(--ap-surface); border: 1px solid var(--ap-border); border-radius: 20px; padding: 2rem 1.5rem; box-shadow: var(--ap-shadow-sm); }
.ap-offline-mark { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 1rem; display: grid; place-items: center; }
/* Mini bar chart (pure CSS, ui.bars): admin dashboards, fuel consumption of the customer space */
.ap-bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: .5rem; }
.ap-bars .ap-bar { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.ap-bars .ap-bar span { display: block; width: 100%; max-width: 28px; background: linear-gradient(180deg, #BFE6D1, var(--ap-primary-100)); border-radius: 6px 6px 2px 2px; transition: background .15s; min-height: 3px; }
.ap-bars .ap-bar:hover span, .ap-bars .ap-bar.is-today span { background: linear-gradient(180deg, #18A262, var(--ap-primary)); }
.ap-bars .ap-bar small { font-size: .62rem; color: var(--ap-text-3); margin-top: 4px; white-space: nowrap; }
@media (max-width: 575.98px) { .ap-bars .ap-bar:nth-child(odd) small { visibility: hidden; } }

/* Tunisian registration plate, customer space and back-office (TunisianPlate, _partials/plate.html.twig): black plate, white border, white characters —
   TU "215 تونس 4512", RS "123456 ن.ت". Same layout in French and Arabic pages. */
.ap-plate { display: inline-flex; align-items: center; gap: .55em; padding: .2em .75em; background: #111; color: #fff; border: 2px solid #fff; border-radius: 6px; box-shadow: 0 0 0 1px #111; font-weight: 700; line-height: 1.2; white-space: nowrap; vertical-align: middle; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.ap-plate-num { font-family: var(--bs-font-monospace, ui-monospace, monospace); font-size: 1.05em; letter-spacing: .08em; }
.ap-plate-word { font-family: 'Noto Sans Arabic', Tahoma, Arial, sans-serif; font-size: 1.1em; }
.ap-plate--sm { font-size: .82rem; padding: .12em .6em; }
