/* =====================================================================
   MAHAM v6 — design system
   Source of truth: docs/design/maham-v6-design-reference.png
   Arabic RTL · Blue system · Cairo (headings) + Tajawal (body)
   Rules: flat (no gradients / glass / dark mode / 3D), only the three
   shadows below, brass = emphasis never action, one primary per screen.
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
    /* Blues */
    --mh-primary: #1E3A52;        /* buttons, sidebar, links, active nav — 11.8:1 */
    --mh-primary-hover: #2B4C65;  /* hover / v5 blue — 9.0:1 */
    --mh-mid-blue: #6B8BA4;       /* in-progress dot, 3rd chart series (no white text) */
    --mh-light-blue: #95B4CC;     /* charts, illustration (dark text only) */
    --mh-wash: #E8EEF3;           /* selected rows, active nav fill */

    /* Accent — emphasis only, never a button fill */
    --mh-brass: #C9A227;          /* callouts, highlighted rows, key figures (dark text) */
    --mh-sand: #D6B08B;           /* pending status, illustration (dark text) */

    /* Semantic */
    --mh-success: #0F7B5F;        /* done, saved — 5.2:1 */
    --mh-danger: #B4472F;         /* delete, overdue, errors — 5.4:1 */
    --mh-stone: #7C8892;          /* closed / archived */

    /* Neutrals & text */
    --mh-ink: #101418;            /* body text (not pure black) */
    --mh-text-secondary: #5A6570; /* 6.0:1 */
    --mh-text-disabled: #9AA3AB;
    --mh-canvas: #F7F8F9;         /* page background */
    --mh-surface: #FFFFFF;
    --mh-border: #DDE2E6;
    --mh-table-header: #F0F3F5;

    /* Tints (fills behind status pills / alerts) */
    --mh-success-wash: #E4F1EC;
    --mh-danger-wash: #F8E9E5;
    --mh-brass-wash: #FAF6E8;
    --mh-sand-wash: #F8EFE6;
    --mh-stone-wash: #EDEFF1;

    /* Chart series — fixed order */
    --mh-chart-1: #1E3A52;
    --mh-chart-2: #2B4C65;
    --mh-chart-3: #6B8BA4;
    --mh-chart-4: #95B4CC;
    --mh-chart-5: #C9A227;
    --mh-chart-6: #D6B08B;
    --mh-chart-7: #0F7B5F;
    --mh-chart-8: #7C8892;

    /* Typography */
    --mh-font-heading: 'Cairo', 'Tajawal', system-ui, sans-serif;
    --mh-font-body: 'Tajawal', 'Cairo', system-ui, sans-serif;

    /* Spacing — 4px base */
    --mh-space-4: 4px;
    --mh-space-8: 8px;
    --mh-space-12: 12px;
    --mh-space-16: 16px;
    --mh-space-24: 24px;
    --mh-space-32: 32px;
    --mh-space-48: 48px;

    /* Shape */
    --mh-radius-sm: 4px;
    --mh-radius: 8px;
    --mh-radius-pill: 999px;

    /* Depth — the only three shadows */
    --mh-shadow-card: 0 1px 2px rgba(16, 20, 24, 0.06);
    --mh-shadow-menu: 0 4px 12px rgba(16, 20, 24, 0.10);
    --mh-shadow-modal: 0 12px 32px rgba(16, 20, 24, 0.18);

    /* Layout */
    --mh-sidebar-width: 264px;
    --mh-sidebar-collapsed-width: 72px;
    --mh-topbar-height: 64px;
    --mh-page-padding: 24px;
    --mh-mobile-nav-height: 64px;  /* phone bottom tab bar (MobileNav) */
    --mh-control-height: 40px;
    --mh-row-height: 44px;
    --mh-row-height-compact: 34px;
    --mh-focus-ring: 0 0 0 2px #fff, 0 0 0 4px var(--mh-primary);

    /* Bootstrap bridge */
    --bs-body-font-family: var(--mh-font-body);
    --bs-body-font-size: 14px;
    --bs-body-line-height: 1.6;
    --bs-body-color: var(--mh-ink);
    --bs-body-color-rgb: 16, 20, 24;
    --bs-body-bg: var(--mh-canvas);
    --bs-emphasis-color: var(--mh-ink);
    --bs-secondary-color: var(--mh-text-secondary);
    --bs-border-color: var(--mh-border);
    --bs-border-radius: var(--mh-radius-sm);
    --bs-border-radius-sm: var(--mh-radius-sm);
    --bs-border-radius-lg: var(--mh-radius);
    --bs-primary: var(--mh-primary);
    --bs-primary-rgb: 30, 58, 82;
    --bs-success-rgb: 15, 123, 95;
    --bs-danger-rgb: 180, 71, 47;
    --bs-secondary-rgb: 90, 101, 112;
    --bs-link-color: var(--mh-primary);
    --bs-link-color-rgb: 30, 58, 82;
    --bs-link-hover-color: var(--mh-primary-hover);
    --bs-link-hover-color-rgb: 43, 76, 101;
    --bs-heading-color: var(--mh-primary);
    --bs-focus-ring-color: rgba(30, 58, 82, 0.25);
}

/* ---------- 2. Base & typography ---------- */
html, body {
    font-family: var(--mh-font-body);
    background-color: var(--mh-canvas);
    color: var(--mh-ink);
}

body {
    font-size: 14px;
    line-height: 1.6;
}

/* Scrollbars — thin, light and rounded everywhere (pages, panels, tables, forms).
   Chromium/Edge/Safari get the styled pill below; Firefox gets the standard thin + colours. */
:root {
    --mh-scroll-thumb: #CDD5DC;
    --mh-scroll-thumb-hover: #A9B5BF;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--mh-scroll-thumb);
    background-clip: padding-box;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--mh-scroll-thumb-hover);
        background-clip: padding-box;
    }

::-webkit-scrollbar-corner {
    background: transparent;
}

@supports not selector(::-webkit-scrollbar) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--mh-scroll-thumb) transparent;
    }
}

/* On the dark sidebar the thumb is a soft translucent white */
.sidebar {
    --mh-scroll-thumb: rgba(255, 255, 255, 0.18);
    --mh-scroll-thumb-hover: rgba(255, 255, 255, 0.32);
}

/* Arabic: never letter-spacing, uppercase or italic */
* {
    letter-spacing: normal;
}

em, i {
    font-style: normal;
    font-weight: 700;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--mh-font-heading);
    color: var(--mh-primary);
    line-height: 1.6;
}

h1, .h1 { font-size: 24px; font-weight: 700; }
h2, .h2 { font-size: 20px; font-weight: 600; }
h3, .h3 { font-size: 16px; font-weight: 600; }
h4, .h4, h5, .h5, h6, .h6 { font-size: 14px; font-weight: 600; }

small, .small { font-size: 13px; }
.mh-text-secondary { color: var(--mh-text-secondary); }

/* Western digits, tabular */
.mh-num {
    font-variant-numeric: tabular-nums;
}

a, .btn-link {
    color: var(--mh-primary);
}

    a:hover {
        color: var(--mh-primary-hover);
    }

/* Page titles get focus after navigation (FocusOnNavigate, for screen readers): no visible box */
h1:focus, h1:focus-visible, h1[tabindex="-1"]:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Lock page scroll while the mobile sidebar drawer is open */
.sidebar-open body {
    overflow: hidden;
}

:focus-visible {
    outline: none;
    box-shadow: var(--mh-focus-ring);
}

.content {
    padding: var(--mh-page-padding);
}

.mh-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mh-space-16);
    margin-bottom: var(--mh-space-24);
}

    .mh-page-header h1 {
        margin: 0;
    }

/* ---------- 3. Icons (mask-based, inherit text colour) ---------- */
.mh-icon {
    display: inline-block;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask: var(--mh-icon) center / contain no-repeat;
    mask: var(--mh-icon) center / contain no-repeat;
}

.mh-icon-sm { width: 16px; height: 16px; }

/* app mark (wwwroot/icon-512.png): slanted bar, three pillars, two diamonds */
.mh-icon-brand { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3.6 8.6 20.6 4.2 20.6 6 3.6 10.4Z'/%3E%3Crect x='7.6' y='10.6' width='2' height='10' rx='1'/%3E%3Crect x='11' y='9.8' width='2' height='10.8' rx='1'/%3E%3Crect x='14.4' y='8.9' width='2' height='8.3' rx='1'/%3E%3Cpath d='M19 8.4 20.4 9.8 19 11.2 17.6 9.8Z'/%3E%3Cpath d='M4.6 12.6 6 14 4.6 15.4 3.2 14Z'/%3E%3C/svg%3E"); }
.mh-icon-dashboard { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='9' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='5' rx='1.5'/%3E%3Crect x='14' y='12' width='7' height='9' rx='1.5'/%3E%3Crect x='3' y='16' width='7' height='5' rx='1.5'/%3E%3C/svg%3E"); }
.mh-icon-sessions { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E"); }
.mh-icon-documents { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h6'/%3E%3C/svg%3E"); }
.mh-icon-search { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); }
.mh-icon-plus { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.mh-icon-folder { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E"); }
.mh-icon-gavel { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 12.5l-8 8a2.12 2.12 0 1 1-3-3l8-8M16 16l6-6M8 8l6-6M9 7l8 8M21 11l-8-8'/%3E%3C/svg%3E"); }
.mh-icon-user { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4 3.6-7 8-7s8 3 8 7'/%3E%3C/svg%3E"); }
.mh-icon-tasks { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h11'/%3E%3Cpath d='M8 11l3 3 10-10'/%3E%3C/svg%3E"); }
.mh-icon-reports { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round'%3E%3Cpath d='M6 20v-5M12 20v-9M18 20V4'/%3E%3C/svg%3E"); }
.mh-icon-settings { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.mh-icon-bell { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0'/%3E%3C/svg%3E"); }
.mh-icon-chevron { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E"); }
.mh-icon-list { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round'%3E%3Cpath d='M9 6h12M9 12h12M9 18h12M4 6h.01M4 12h.01M4 18h.01'/%3E%3C/svg%3E"); }
.mh-icon-pin { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s-7-6.2-7-11.5a7 7 0 0 1 14 0C19 14.8 12 21 12 21z'/%3E%3Ccircle cx='12' cy='9.5' r='2.5'/%3E%3C/svg%3E"); }
.mh-icon-print { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9V3h12v6M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2'/%3E%3Crect x='6' y='14' width='12' height='7'/%3E%3C/svg%3E"); }
.mh-icon-shield-user { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l7 3v5c0 4.5-3 8.3-7 10-4-1.7-7-5.5-7-10V6z'/%3E%3Ccircle cx='12' cy='10' r='2.5'/%3E%3Cpath d='M8.5 16.5c.8-1.6 2-2.5 3.5-2.5s2.7.9 3.5 2.5'/%3E%3C/svg%3E"); }
.mh-icon-id { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='9' cy='11' r='2'/%3E%3Cpath d='M6 16c.5-1.3 1.6-2 3-2s2.5.7 3 2M14 10h4M14 14h4'/%3E%3C/svg%3E"); }
.mh-icon-calendar { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4'/%3E%3C/svg%3E"); }
.mh-icon-clock { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.mh-icon-building { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='3' width='16' height='18' rx='1.5'/%3E%3Cpath d='M9 7h1.5M13.5 7H15M9 11h1.5M13.5 11H15M9 15h1.5M13.5 15H15M10 21v-3h4v3'/%3E%3C/svg%3E"); }
.mh-icon-eye { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.mh-icon-eye-off { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.6 5.1A9.9 9.9 0 0 1 12 5c6.4 0 10 7 10 7a17.6 17.6 0 0 1-3.2 4.2M6.6 6.6C3.8 8.4 2 12 2 12s3.6 7 10 7a9.6 9.6 0 0 0 5.4-1.6'/%3E%3Cpath d='M9.9 9.9a3 3 0 0 0 4.2 4.2M3 3l18 18'/%3E%3C/svg%3E"); }
.mh-icon-logout { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 4h3a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-3M10 17l-5-5 5-5M5 12h11'/%3E%3C/svg%3E"); }
.mh-icon-phone { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.7a2 2 0 0 1-.5 2.1L8 9.8a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.7.7a2 2 0 0 1 1.7 2z'/%3E%3C/svg%3E"); }
.mh-icon-arrow-back { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E"); }
.mh-icon-edit { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E"); }
.mh-icon-trash { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E"); }
.mh-icon-check { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E"); }
.mh-icon-undo { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 14L4 9l5-5'/%3E%3Cpath d='M4 9h10.5a5.5 5.5 0 0 1 0 11H11'/%3E%3C/svg%3E"); }
.mh-icon-swap { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 3l4 4-4 4M20 7H4M8 21l-4-4 4-4M4 17h16'/%3E%3C/svg%3E"); }
.mh-icon-menu { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6h16M4 12h16M4 18h16'/%3E%3C/svg%3E"); }
.mh-icon-clients { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3.5'/%3E%3Cpath d='M2.5 20c0-3.6 2.9-6 6.5-6s6.5 2.4 6.5 6M16 4.6a3.5 3.5 0 0 1 0 6.8M18 14.3c2.1.7 3.5 2.8 3.5 5.7'/%3E%3C/svg%3E"); }
.mh-icon-bolt { --mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2L4 14h7l-1 8 9-12h-7z'/%3E%3C/svg%3E"); }
.mh-icon-close {--mh-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }

/* ---------- 4. Buttons — one primary per screen ---------- */
.btn {
    --bs-btn-padding-x: 16px;
    --bs-btn-padding-y: 0;
    --bs-btn-font-family: var(--mh-font-body);
    --bs-btn-font-size: 14px;
    --bs-btn-font-weight: 500;
    --bs-btn-line-height: 1.6;
    --bs-btn-border-radius: var(--mh-radius-sm);
    --bs-btn-disabled-opacity: 1;
    --bs-btn-focus-box-shadow: var(--mh-focus-ring);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--mh-space-8);
    min-height: var(--mh-control-height);
}

.btn-sm {
    --bs-btn-padding-x: 12px;
    --bs-btn-padding-y: 0;
    --bs-btn-font-size: 13px;
    --bs-btn-border-radius: var(--mh-radius-sm);
    min-height: 32px;
}

.btn-lg {
    --bs-btn-padding-x: 24px;
    --bs-btn-padding-y: 0;
    --bs-btn-font-size: 16px;
    --bs-btn-border-radius: var(--mh-radius-sm);
    min-height: 48px;
}

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--mh-primary);
    --bs-btn-border-color: var(--mh-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--mh-primary-hover);
    --bs-btn-hover-border-color: var(--mh-primary-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--mh-primary-hover);
    --bs-btn-active-border-color: var(--mh-primary-hover);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--mh-text-disabled);
    --bs-btn-disabled-border-color: var(--mh-text-disabled);
}

/* Secondary = outlined */
.btn-secondary, .btn-outline-secondary, .btn-outline-primary {
    --bs-btn-color: var(--mh-ink);
    --bs-btn-bg: var(--mh-surface);
    --bs-btn-border-color: var(--mh-border);
    --bs-btn-hover-color: var(--mh-primary);
    --bs-btn-hover-bg: var(--mh-canvas);
    --bs-btn-hover-border-color: var(--mh-border);
    --bs-btn-active-color: var(--mh-primary);
    --bs-btn-active-bg: var(--mh-wash);
    --bs-btn-active-border-color: var(--mh-border);
    --bs-btn-disabled-color: var(--mh-text-disabled);
    --bs-btn-disabled-bg: var(--mh-surface);
    --bs-btn-disabled-border-color: var(--mh-border);
}

/* Ghost / plain text */
.btn-ghost, .btn-link {
    --bs-btn-color: var(--mh-primary);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--mh-primary);
    --bs-btn-hover-bg: var(--mh-wash);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--mh-primary);
    --bs-btn-active-bg: var(--mh-wash);
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-color: var(--mh-text-disabled);
    text-decoration: none;
}

/* Destruction */
.btn-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--mh-danger);
    --bs-btn-border-color: var(--mh-danger);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #9A3B26;
    --bs-btn-hover-border-color: #9A3B26;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #9A3B26;
    --bs-btn-active-border-color: #9A3B26;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--mh-text-disabled);
    --bs-btn-disabled-border-color: var(--mh-text-disabled);
}

/* ---------- 5. Form fields — label above, always visible ---------- */
.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--mh-ink);
    margin-bottom: 6px;
}

.mh-required::after {
    content: " *";
    color: var(--mh-danger);
    font-weight: 700;
}

/* "الحقول المميزة بعلامة * مطلوبة." at the top of edit forms */
.mh-required-note {
    margin: 0 0 var(--mh-space-12);
    color: var(--mh-text-secondary);
    font-size: 12px;
}

    .mh-required-note span {
        color: var(--mh-danger);
        font-weight: 700;
    }

.form-control, .form-select {
    min-height: var(--mh-control-height);
    font-size: 14px;
    color: var(--mh-ink);
    background-color: var(--mh-surface);
    border-color: var(--mh-border);
    border-radius: var(--mh-radius-sm);
}

    .form-control::placeholder {
        color: var(--mh-text-disabled);
    }

    .form-control:focus, .form-select:focus {
        border-color: var(--mh-primary);
        box-shadow: 0 0 0 3px rgba(30, 58, 82, 0.15);
    }

    .form-control.is-invalid, .form-control.invalid,
    .form-select.is-invalid, .form-select.invalid {
        border-color: var(--mh-danger);
        background-color: var(--mh-danger-wash);
        background-image: none;
    }

.form-text {
    font-size: 13px;
    color: var(--mh-text-secondary);
}

.invalid-feedback, .validation-message {
    font-size: 13px;
    color: var(--mh-danger);
}

.form-check-input {
    border-color: var(--mh-text-disabled);
}

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

    .form-check-input:focus {
        border-color: var(--mh-primary);
        box-shadow: var(--mh-focus-ring);
    }

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Filter chip */
.mh-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 12px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius-pill);
    background: var(--mh-surface);
    font-size: 13px;
    color: var(--mh-ink);
}

/* ---------- 6. Status — always fill + dot + Arabic label ---------- */
.mh-status {
    --mh-status-bg: var(--mh-wash);
    --mh-status-fg: var(--mh-primary);
    --mh-status-dot: var(--mh-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--mh-radius-pill);
    background: var(--mh-status-bg);
    color: var(--mh-status-fg);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

    .mh-status::before {
        content: "";
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--mh-status-dot);
    }

.mh-status--active { --mh-status-bg: var(--mh-wash); --mh-status-fg: var(--mh-primary); --mh-status-dot: var(--mh-primary); }
.mh-status--progress { --mh-status-bg: var(--mh-wash); --mh-status-fg: var(--mh-primary-hover); --mh-status-dot: var(--mh-mid-blue); }
.mh-status--done { --mh-status-bg: var(--mh-success-wash); --mh-status-fg: var(--mh-success); --mh-status-dot: var(--mh-success); }
.mh-status--pending { --mh-status-bg: var(--mh-sand-wash); --mh-status-fg: var(--mh-ink); --mh-status-dot: var(--mh-sand); }
.mh-status--overdue { --mh-status-bg: var(--mh-danger-wash); --mh-status-fg: var(--mh-danger); --mh-status-dot: var(--mh-danger); }
.mh-status--closed { --mh-status-bg: var(--mh-stone-wash); --mh-status-fg: var(--mh-text-secondary); --mh-status-dot: var(--mh-stone); }
/* Case status (القضية) — one distinct colour per status, used by the pills, the list tab counts
   and the case header. Defaults below; the server can override them in lookups.json →
   "CaseStatusColors" (written into the page as --case-* variables). Tint = 12% of the colour. */
:root {
    --case-active: #0F7B5F;     /* متداولة — green */
    --case-execution: #A86B00;  /* قيد التنفيذ — amber */
    --case-closed: #5A6570;     /* مغلقة — slate grey */
    --case-deleted: #B4472F;    /* محذوفة — red */
}

.mh-case-status--active    { --case-color: var(--case-active); }
.mh-case-status--execution { --case-color: var(--case-execution); }
.mh-case-status--closed    { --case-color: var(--case-closed); }
.mh-case-status--deleted   { --case-color: var(--case-deleted); }

.mh-case-status--active, .mh-case-status--execution, .mh-case-status--closed, .mh-case-status--deleted {
    --mh-status-fg: var(--case-color);
    --mh-status-dot: var(--case-color);
    --mh-status-bg: color-mix(in srgb, var(--case-color) 12%, #fff);
}


/* ---------- 7. Alerts, toast, callout ---------- */
.mh-alert {
    display: flex;
    align-items: center;
    gap: var(--mh-space-12);
    padding: 12px 16px;
    border-radius: var(--mh-radius-sm);
    border-inline-start: 3px solid var(--mh-primary);
    background: var(--mh-wash);
    color: var(--mh-ink);
}

.mh-alert--danger { background: var(--mh-danger-wash); border-inline-start-color: var(--mh-danger); }
.mh-alert--success { background: var(--mh-success-wash); border-inline-start-color: var(--mh-success); }
.mh-alert--warning { background: var(--mh-brass-wash); border-inline-start-color: var(--mh-brass); }

.mh-toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mh-space-16);
    padding: 12px 16px;
    background: var(--mh-surface);
    border: 1px solid var(--mh-border);
    border-inline-start: 3px solid var(--mh-primary);
    border-radius: var(--mh-radius-sm);
    box-shadow: var(--mh-shadow-menu);
}

/* Brass: emphasis only */
.mh-callout {
    padding: 12px 16px;
    background: var(--mh-brass-wash);
    border-inline-start: 3px solid var(--mh-brass);
    border-radius: var(--mh-radius-sm);
}

/* ---------- 8. Progress, skeleton, avatar ---------- */
.progress {
    --bs-progress-height: 4px;
    --bs-progress-bg: var(--mh-wash);
    --bs-progress-bar-bg: var(--mh-primary);
    --bs-progress-border-radius: var(--mh-radius-pill);
}

.mh-skeleton {
    display: block;
    height: 12px;
    background: var(--mh-wash);
    border-radius: var(--mh-radius-sm);
    animation: mh-pulse 1.4s ease-in-out infinite;
}

@keyframes mh-pulse {
    50% { opacity: 0.55; }
}

.mh-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mh-wash);
    color: var(--mh-primary);
    font-family: var(--mh-font-heading);
    font-size: 13px;
    font-weight: 700;
}


/* ---------- 9. Cards & KPI ---------- */
.mh-card {
    background: var(--mh-surface);
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius);
    box-shadow: var(--mh-shadow-card);
    padding: var(--mh-space-24);
}

/* ---------- 10. Tabs & menus ---------- */
.mh-tabs {
    display: flex;
    gap: var(--mh-space-24);
    border-bottom: 1px solid var(--mh-border);
}

.mh-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--mh-space-8);
    padding: 10px 0;
    margin-bottom: -1px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--mh-text-secondary);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

    .mh-tab:hover { color: var(--mh-ink); }

    .mh-tab.active {
        color: var(--mh-primary);
        font-weight: 700;
        border-bottom-color: var(--mh-primary);
    }

.mh-count {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: var(--mh-radius-pill);
    background: var(--mh-stone-wash);
    color: var(--mh-text-secondary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.dropdown-menu {
    --bs-dropdown-font-size: 14px;
    --bs-dropdown-color: var(--mh-ink);
    --bs-dropdown-border-color: var(--mh-border);
    --bs-dropdown-border-radius: var(--mh-radius);
    --bs-dropdown-box-shadow: var(--mh-shadow-menu);
    --bs-dropdown-link-color: var(--mh-ink);
    --bs-dropdown-link-hover-bg: var(--mh-canvas);
    --bs-dropdown-link-active-color: var(--mh-primary);
    --bs-dropdown-link-active-bg: var(--mh-wash);
    box-shadow: var(--bs-dropdown-box-shadow);
}

.dropdown-item {
    display: flex;
    align-items: center;
    min-height: 36px;
}

    .dropdown-item.mh-danger { color: var(--mh-danger); }

.modal-content {
    border-color: var(--mh-border);
    border-radius: var(--mh-radius);
    box-shadow: var(--mh-shadow-modal);
}

/* ---------- 11. Data table — first column on the right ---------- */
.mh-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--mh-surface);
}

    .mh-table th {
        height: var(--mh-row-height);
        padding: 0 16px;
        background: var(--mh-table-header);
        color: var(--mh-text-secondary);
        font-size: 13px;
        font-weight: 500;
        text-align: start;
        white-space: nowrap;
        border-bottom: 1px solid var(--mh-border);
    }

    .mh-table td {
        height: var(--mh-row-height);
        padding: 0 16px;
        border-bottom: 1px solid var(--mh-border);
    }

    .mh-table tbody tr:hover { background: var(--mh-canvas); }
    .mh-table tbody tr.is-selected { background: var(--mh-wash); }
    .mh-table tbody tr.is-highlighted td:first-child { box-shadow: inset -3px 0 0 var(--mh-brass); }

    /* Dates and numbers aligned to the far edge */
    .mh-table .mh-cell-num {
        text-align: end;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .mh-table .is-overdue { color: var(--mh-danger); }

/* ---------- 12. Empty state ---------- */
.mh-empty {
    text-align: center;
    padding: var(--mh-space-48) var(--mh-space-24);
    color: var(--mh-text-secondary);
}

/* ---------- 13. Editing: icon buttons, side panel, dialog, toasts, forms ---------- */
.mh-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--mh-radius-sm);
    background: transparent;
    color: var(--mh-text-secondary);
}

    .mh-icon-btn:hover {
        background: var(--mh-wash);
        color: var(--mh-primary);
    }

    .mh-icon-btn.mh-danger:hover {
        background: var(--mh-danger-wash);
        color: var(--mh-danger);
    }

    .mh-icon-btn.mh-success:hover {
        background: var(--mh-success-wash);
        color: var(--mh-success);
    }

    .mh-icon-btn:disabled {
        opacity: 0.4;
        pointer-events: none;
    }

.mh-icon-btn--sm {
    width: 24px;
    height: 24px;
}

.mh-row-actions {
    display: inline-flex;
    gap: 2px;
    white-space: nowrap;
}

/* Side panel (drawer) — slides in from the left (inline-end in RTL), BELOW the top bar.
   Always in the DOM; .is-open drives a transform/opacity transition so it glides in and out. */
.mh-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(16, 20, 24, 0.4);
    animation: mh-fade-in 150ms ease;
}

/* Shades the page content only: the top bar and the sidebar stay clear */
.mh-drawer-backdrop {
    position: fixed;
    top: var(--mh-topbar-height);
    bottom: 0;
    inset-inline-start: var(--mh-sidebar-width);
    inset-inline-end: 0;
    z-index: 900;
    background: rgba(16, 20, 24, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 280ms ease, inset-inline-start 200ms ease;
}

:root.sidebar-collapsed .mh-drawer-backdrop {
    inset-inline-start: var(--mh-sidebar-collapsed-width);
}

    .mh-drawer-backdrop.is-open {
        opacity: 1;
        pointer-events: auto;
        cursor: pointer;
    }

.mh-drawer {
    position: fixed;
    top: var(--mh-topbar-height);
    bottom: 0;
    inset-inline-end: 0;
    z-index: 901;
    display: flex;
    flex-direction: column;
    width: min(560px, 100vw);
    border-top: 1px solid var(--mh-border);
    background: var(--mh-surface);
    box-shadow: var(--mh-shadow-modal);
    outline: none;
    /* closed: parked just off the left edge */
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 320ms;
    will-change: transform;
}

    .mh-drawer.is-open {
        transform: translateX(0);
        visibility: visible;
        transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
    }

@media (max-width: 767.98px) {
    .mh-drawer-backdrop, :root.sidebar-collapsed .mh-drawer-backdrop {
        inset-inline-start: 0;
    }
}

.mh-drawer--wide {
    width: min(720px, 100vw);
}

.mh-drawer-header {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--mh-space-16);
    padding: 16px var(--mh-space-24);
    border-bottom: 3px solid var(--mh-brass);
    background: var(--mh-primary);
    color: #fff;
}

    .mh-drawer-header h2 {
        margin: 0;
        color: #fff;
        font-size: 18px;
    }

    .mh-drawer-header p {
        margin: 2px 0 0;
        color: rgba(255, 255, 255, 0.72);
        font-size: 13px;
    }

    .mh-drawer-header .mh-icon-btn {
        color: rgba(255, 255, 255, 0.8);
    }

        .mh-drawer-header .mh-icon-btn:hover {
            background: rgba(255, 255, 255, 0.12);
            color: #fff;
        }

.mh-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--mh-space-24);
    padding-bottom: 0;
}

/* Footer lives inside the form so the submit button works; it sticks to the bottom of the panel */
.mh-drawer-footer {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: var(--mh-space-8);
    margin: var(--mh-space-24) calc(-1 * var(--mh-space-24)) 0;
    padding: var(--mh-space-16) var(--mh-space-24);
    border-top: 1px solid var(--mh-border);
    background: var(--mh-surface);
}

    /* "يوجد حقلان يحتاجان إلى إكمال" next to the save button after a failed submit */
    .mh-drawer-footer .mh-drawer-footer-alert {
        align-self: center;
        margin-inline-start: auto;
        color: var(--mh-danger);
        font-size: 12.5px;
        font-weight: 500;
    }

@keyframes mh-slide-in {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes mh-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Confirmation dialog */
.mh-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 901;
    width: min(440px, calc(100vw - 32px));
    padding: var(--mh-space-24);
    transform: translate(-50%, -50%);
    border-radius: var(--mh-radius);
    background: var(--mh-surface);
    box-shadow: var(--mh-shadow-modal);
    outline: none;
}

    .mh-dialog h2 {
        margin: var(--mh-space-12) 0 var(--mh-space-8);
        font-size: 18px;
    }

    .mh-dialog p {
        color: var(--mh-text-secondary);
    }

.mh-dialog-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--mh-danger-wash);
    color: var(--mh-danger);
}

.mh-dialog-actions {
    display: flex;
    gap: var(--mh-space-8);
    margin-top: var(--mh-space-16);
}

/* Toasts — bottom-left (inline-end) */
.mh-toast-stack {
    position: fixed;
    bottom: var(--mh-space-24);
    inset-inline-end: var(--mh-space-24);
    z-index: 950;
    display: grid;
    gap: var(--mh-space-8);
    width: min(380px, calc(100vw - 32px));
}

    .mh-toast-stack .mh-toast {
        animation: mh-fade-in 150ms ease;
    }

.mh-toast--success { border-inline-start-color: var(--mh-success); }
.mh-toast--error { border-inline-start-color: var(--mh-danger); }

/* Form layout inside panels */
.mh-form-grid {
    display: grid;
    gap: var(--mh-space-16);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mh-span-2 {
    grid-column: 1 / -1;
}

.mh-form-section {
    margin: var(--mh-space-24) 0 var(--mh-space-12);
    padding-top: var(--mh-space-16);
    border-top: 1px solid var(--mh-border);
    color: var(--mh-primary);
    font-family: var(--mh-font-heading);
    font-size: 14px;
    font-weight: 600;
}

    .mh-form-section:first-child {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

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

.mh-switch {
    display: flex;
    align-items: center;
    gap: var(--mh-space-12);
    padding: 12px 16px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius-sm);
}

    .mh-switch .form-check-input {
        float: none;
        margin: 0;
    }

    .mh-switch small {
        display: block;
        color: var(--mh-text-secondary);
    }

@media (max-width: 575.98px) {
    .mh-form-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mh-drawer, .mh-drawer-backdrop, .mh-modal-backdrop, .mh-toast-stack .mh-toast {
        animation: none;
    }

    .mh-drawer, .mh-drawer.is-open, .mh-drawer-backdrop {
        transition: none;
    }
}

/* ---------- 13b. List pages (الجلسات، المهام، العملاء) ----------
   Same frame as the cases list: on desktop the page fills the window, the header / tabs / toolbar
   stay put and only the results scroll (wheel / touchpad / keyboard; the scrollbar is hidden).
   Markup: .mh-listpage > [.mh-page-header, .mh-tabs, .mh-toolbar] + .mh-listpage-body > .mh-listpage-scroll + pager */
@media (min-width: 992px) and (min-height: 600px) {
    .mh-listpage {
        display: flex;
        flex-direction: column;
        height: calc(100dvh - var(--mh-topbar-height) - 2 * var(--mh-page-padding));
    }

        .mh-listpage > :not(.mh-listpage-body) {
            flex-shrink: 0;
        }

    .mh-listpage-body {
        display: flex;
        flex: 1;
        flex-direction: column;
        min-height: 0;
    }

    .mh-listpage-scroll {
        flex: 1;
        min-height: 0;
        margin-inline: -4px;
        padding: 0 4px var(--mh-space-12);
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
    }

        .mh-listpage-scroll::-webkit-scrollbar {
            display: none;
        }

    .mh-listpage-body > .pager, .mh-listpage-body > .mh-more {
        flex-shrink: 0;
    }
}

.mh-listpage .mh-page-header {
    margin-bottom: var(--mh-space-16);
}

.mh-listpage .mh-tabs {
    margin-bottom: var(--mh-space-16);
}

.mh-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--mh-space-12);
    margin-bottom: var(--mh-space-16);
}

.mh-search {
    position: relative;
    flex: 1 1 300px;
}

    .mh-search .mh-icon {
        position: absolute;
        top: 50%;
        inset-inline-start: 14px;
        color: var(--mh-text-secondary);
        transform: translateY(-50%);
        pointer-events: none;
    }

    .mh-search input {
        padding-inline-start: 40px;
    }

.mh-filter {
    flex: 0 0 auto;
    width: auto;
    min-width: 160px;
}

/* Segmented switch: [تقويم | قائمة], [شهر | أسبوع] */
.mh-segmented {
    display: inline-flex;
    flex-shrink: 0;
    height: var(--mh-control-height);
    padding: 3px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius-sm);
    background: var(--mh-surface);
}

    .mh-segmented button, .mh-segmented a {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 0 12px;
        border: 0;
        border-radius: 3px;
        background: transparent;
        color: var(--mh-text-secondary);
        font-size: 13px;
        font-weight: 500;
    }

        .mh-segmented button:hover, .mh-segmented a:hover {
            color: var(--mh-primary);
        }

        .mh-segmented button.active, .mh-segmented a.active {
            background: var(--mh-wash);
            color: var(--mh-primary);
            font-weight: 700;
        }

        .mh-segmented button:focus-visible, .mh-segmented a:focus-visible {
            outline: none;
            box-shadow: var(--mh-focus-ring);
        }

/* "عرض المزيد" under a long agenda */
.mh-more {
    display: flex;
    justify-content: center;
    padding-top: var(--mh-space-8);
}

/* Row cards: one item per line — [tile] [title] [facts] [chips] [status] [actions] */
.mh-rows {
    display: grid;
    gap: var(--mh-space-8);
    margin: 0;
    padding: 0;
    list-style: none;
}

.mh-rowcard {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--mh-space-16);
    min-height: 64px;
    padding: 10px 14px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius);
    background: var(--mh-surface);
    color: var(--mh-ink);
    text-decoration: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

    a.mh-rowcard:hover, .mh-rowcard.is-link:hover {
        border-color: var(--mh-light-blue);
        box-shadow: var(--mh-shadow-card);
        color: var(--mh-ink);
    }

    .mh-rowcard:focus-visible {
        outline: none;
        box-shadow: var(--mh-focus-ring);
    }

    .mh-rowcard.is-active {
        border-color: #D3E0EA;
        border-inline-start: 3px solid var(--mh-primary);
        background: #F4F8FB;
    }

    .mh-rowcard.is-muted .mh-rowcard-title strong {
        color: var(--mh-text-secondary);
    }

.mh-rowcard-title {
    display: flex;
    flex: 0 1 280px;
    flex-direction: column;
    min-width: 150px;
    line-height: 1.4;
}

    .mh-rowcard-title strong {
        display: -webkit-box;
        overflow: hidden;
        font-family: var(--mh-font-heading);
        font-size: 15px;
        font-weight: 700;
        color: var(--mh-ink);
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .mh-rowcard-title span {
        overflow: hidden;
        color: var(--mh-text-secondary);
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.mh-rowcard-facts {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: 4px var(--mh-space-24);
    min-width: 0;
    margin: 0;
}

    .mh-rowcard-facts > div {
        min-width: 84px;
        max-width: 260px;
        line-height: 1.35;
    }

    .mh-rowcard-facts dt {
        color: var(--mh-text-secondary);
        font-size: 11px;
        font-weight: 500;
    }

    .mh-rowcard-facts dd {
        overflow: hidden;
        margin: 0;
        font-size: 13px;
        font-weight: 600;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.mh-rowcard-end {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--mh-space-12);
}

/* Date tile: day big, month/year small */
.mh-date-tile {
    display: inline-flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius);
    background: var(--mh-surface);
    color: var(--mh-text-secondary);
    line-height: 1.1;
}

    .mh-date-tile strong {
        font-family: var(--mh-font-heading);
        font-size: 18px;
        font-weight: 700;
        color: var(--mh-ink);
    }

    .mh-date-tile small {
        font-size: 10px;
        font-weight: 600;
    }

.mh-rowcard.is-active .mh-date-tile {
    border-color: var(--mh-primary);
    background: var(--mh-primary);
    color: rgba(255, 255, 255, 0.8);
}

    .mh-rowcard.is-active .mh-date-tile strong {
        color: #fff;
    }

/* Small pill for a relative day ("بعد 3 أيام") */
.mh-hint-pill {
    display: inline-block;
    margin-inline-start: 4px;
    padding: 0 6px;
    border-radius: var(--mh-radius-pill);
    background: var(--mh-wash);
    color: var(--mh-primary);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
}

/* Day heading in an agenda; sticks to the top while its rows scroll */
.mh-day-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: baseline;
    gap: var(--mh-space-8);
    margin: var(--mh-space-12) 0 var(--mh-space-8);
    padding: 6px 2px;
    background: var(--mh-canvas);
    color: var(--mh-ink);
    font-family: var(--mh-font-heading);
    font-size: 14px;
    font-weight: 700;
}

    .mh-day-head:first-child {
        margin-top: 0;
    }

    .mh-day-head small {
        color: var(--mh-text-secondary);
        font-family: var(--mh-font-body);
        font-size: 12px;
        font-weight: 500;
    }

    .mh-day-head .mh-count {
        margin-inline-start: auto;
    }

    .mh-day-head.is-today {
        color: var(--mh-primary);
    }

@media (max-width: 1199.98px) {
    .mh-rowcard {
        flex-wrap: wrap;
        row-gap: var(--mh-space-8);
    }

    .mh-rowcard-facts {
        order: 10;
        flex-basis: 100%;
    }
}

@media (max-width: 767.98px) {
    .mh-filter {
        flex: 1 1 140px;
    }
}

/* ---------- 13c. Phones & touch ----------
   Phones (< 768 px): tighter spacing, a 56 px top bar, a bottom tab bar (MobileNav), tabs that scroll
   sideways instead of wrapping, full-width toolbars, bigger touch targets, 16 px inputs (no iOS zoom). */
@media (max-width: 767.98px) {
    :root {
        --mh-topbar-height: 56px;
        --mh-page-padding: 16px;
    }

    /* room for the bottom tab bar */
    .content {
        padding-bottom: calc(var(--mh-page-padding) + var(--mh-mobile-nav-height) + env(safe-area-inset-bottom)) !important;
    }

    h1 {
        font-size: 22px;
    }

    /* Page header: title on its own row, actions under it */
    .mh-page-header {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: var(--mh-space-12);
        margin-bottom: var(--mh-space-16);
    }

        .mh-page-header > div:first-child {
            flex: 1 1 100%;
        }

        .mh-page-header .btn {
            white-space: nowrap;
        }

    /* Tabs: one row that scrolls sideways (no wrapping, no cut-off labels) */
    .mh-tabs {
        gap: var(--mh-space-16);
        margin-inline: calc(-1 * var(--mh-page-padding));
        padding-inline: var(--mh-page-padding);
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

        .mh-tabs::-webkit-scrollbar {
            display: none;
        }

    .mh-tab {
        min-height: 44px;
    }

    /* Toolbars: search on its own row, filters share the next row */
    .mh-toolbar {
        gap: var(--mh-space-8);
    }

    .mh-search {
        flex: 1 1 100%;
    }

    .mh-filter {
        flex: 1 1 0;
        min-width: 0;
    }

    /* Inputs at 16 px so iOS doesn't zoom in when a field is tapped */
    .form-control, .form-select {
        font-size: 16px;
    }

    /* Side panel: full screen width; footer buttons share the row */
    .mh-drawer, .mh-drawer--wide {
        width: 100vw;
    }

    .mh-drawer-header {
        padding: 12px var(--mh-space-16);
    }

    .mh-drawer-body {
        padding: var(--mh-space-16);
        padding-bottom: 0;
    }

    .mh-drawer-footer {
        margin-inline: calc(-1 * var(--mh-space-16));
        padding: 12px var(--mh-space-16) calc(12px + env(safe-area-inset-bottom));
    }

        .mh-drawer-footer .btn {
            flex: 1;
            min-height: 46px;
        }

    .mh-form-grid {
        grid-template-columns: 1fr;
    }

    /* Toasts above the bottom tab bar, full width */
    .mh-toast-stack {
        bottom: calc(var(--mh-mobile-nav-height) + env(safe-area-inset-bottom) + 12px);
        inset-inline: 12px;
        width: auto;
    }

    /* Confirmation dialog: full width, big buttons */
    .mh-dialog {
        width: calc(100vw - 32px);
    }

        .mh-dialog .btn {
            min-height: 46px;
        }

    /* Row cards (hearings list, tasks): title row, details, then lawyer / status / actions across the bottom */
    .mh-rowcard {
        gap: var(--mh-space-8) var(--mh-space-12);
        padding: 12px;
    }

    .mh-rowcard-title {
        flex: 1 1 0;
        min-width: 0;
    }

    .mh-rowcard-facts {
        gap: 6px var(--mh-space-16);
    }

        .mh-rowcard-facts > div {
            min-width: 0;
        }

    .mh-rowcard-end {
        order: 11;
        flex: 1 1 100%;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: var(--mh-space-8);
        padding-top: var(--mh-space-8);
        border-top: 1px dashed var(--mh-border);
    }

    .mh-day-head {
        margin-inline: calc(-1 * var(--mh-page-padding));
        padding-inline: var(--mh-page-padding);
    }

    /* Pager: bigger, wraps if needed */
    .pager {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--mh-space-8);
    }
}

/* Touch screens (phones and tablets): icon buttons and small buttons are at least ~40 px */
@media (pointer: coarse) {
    .mh-icon-btn {
        width: 40px;
        height: 40px;
    }

    .btn-sm {
        min-height: 38px;
    }

    .mh-segmented {
        height: 42px;
    }
}

/* ---------- 13d. Calendar (CalendarGrid: الجلسات، المهام) ----------
   Month / week grid + the selected day's panel. Event chips: .is-scheduled (navy), .is-missing (amber), .is-held / .is-done (grey), .is-overdue (red). */
/* Calendar (start) + selected-day panel (end). On desktop it fills the page height. */
.hc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: var(--mh-space-16);
    flex: 1;
    height: 100%;
    min-height: 0;
}

.hc-calendar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius);
    background: var(--mh-surface);
    box-shadow: var(--mh-shadow-card);
}

.hc-weekdays {
    display: grid;
    flex-shrink: 0;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-bottom: 1px solid var(--mh-border);
    background: var(--mh-table-header);
}

    .hc-weekdays span {
        padding: 8px;
        color: var(--mh-text-secondary);
        font-size: 12px;
        font-weight: 700;
        text-align: center;
    }

.hc-grid {
    display: grid;
    flex: 1;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(var(--hc-weeks), minmax(92px, 1fr));
    min-height: 0;
}

.hc-calendar.is-week .hc-grid {
    grid-template-rows: minmax(0, 1fr);
}

/* One day */
.hc-day {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    min-height: 0;
    padding: 6px;
    overflow: hidden;
    border: 0;
    border-bottom: 1px solid var(--mh-border);
    border-inline-start: 1px solid var(--mh-border);
    background: var(--mh-surface);
    color: var(--mh-ink);
    text-align: start;
    transition: background-color 120ms ease;
}

    .hc-day:nth-child(7n + 1) {
        border-inline-start: 0;
    }

    .hc-day:hover {
        background: var(--mh-canvas);
    }

    .hc-day:focus-visible {
        outline: none;
        box-shadow: inset var(--mh-focus-ring);
    }

    .hc-day.is-weekend {
        background: #FBFCFD;
    }

    .hc-day.is-outside {
        background: var(--mh-canvas);
    }

        .hc-day.is-outside .hc-day-no {
            color: var(--mh-text-disabled);
        }

    .hc-day.is-selected {
        background: #F4F8FB;
        box-shadow: inset 0 0 0 2px var(--mh-primary);
    }


.hc-calendar.is-week .hc-day {
    gap: 6px;
    padding: 8px;
    overflow-y: auto;
    scrollbar-width: none;
}

.hc-day-head {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.hc-day-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 4px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
}

.hc-day.is-today .hc-day-no {
    background: var(--mh-primary);
    color: #fff;
}

.hc-day-count {
    padding: 0 6px;
    border-radius: var(--mh-radius-pill);
    background: var(--mh-wash);
    color: var(--mh-primary);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
}

/* Event chips: scheduled = navy, held = grey */
.hc-event {
    flex-shrink: 0;
    overflow: hidden;
    padding: 2px 6px;
    border-inline-start: 3px solid var(--mh-primary);
    border-radius: 3px;
    background: var(--mh-wash);
    color: var(--mh-primary);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .hc-event.is-held {
        border-inline-start-color: var(--mh-stone);
        background: var(--mh-stone-wash);
        color: var(--mh-ink);
    }

    .hc-event.is-detailed {
        display: flex;
        flex-direction: column;
        padding: 5px 8px;
        white-space: normal;
    }

        .hc-event.is-detailed strong {
            font-size: 12px;
        }

        .hc-event.is-detailed span {
            overflow: hidden;
            font-size: 12px;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .hc-event.is-detailed small {
            overflow: hidden;
            color: var(--mh-text-secondary);
            font-size: 11px;
            font-weight: 500;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

.hc-more {
    flex-shrink: 0;
    color: var(--mh-text-secondary);
    font-size: 11px;
    font-weight: 700;
}

/* ---------- Selected day panel ---------- */
.hc-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius);
    background: var(--mh-surface);
    box-shadow: var(--mh-shadow-card);
}

.hc-panel-head {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: var(--mh-space-8);
    padding: 12px 14px;
    border-bottom: 1px solid var(--mh-border);
    background: var(--mh-table-header);
}

    .hc-panel-head strong {
        font-family: var(--mh-font-heading);
        font-size: 15px;
        font-weight: 700;
        color: var(--mh-primary);
    }

.hc-panel-empty {
    margin: 0;
    padding: var(--mh-space-24) var(--mh-space-16);
    color: var(--mh-text-secondary);
    text-align: center;
}

.hc-panel-list {
    display: grid;
    gap: var(--mh-space-8);
    margin: 0;
    padding: var(--mh-space-12);
    overflow-y: auto;
    list-style: none;
    scrollbar-width: none;
}

    .hc-panel-list::-webkit-scrollbar {
        display: none;
    }

.hc-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid var(--mh-border);
    border-inline-start: 3px solid var(--mh-primary);
    border-radius: var(--mh-radius);
    background: var(--mh-surface);
    color: var(--mh-ink);
    font-size: 13px;
    text-decoration: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

    .hc-item.is-held {
        border-inline-start-color: var(--mh-stone);
    }

    .hc-item:hover {
        border-color: var(--mh-light-blue);
        box-shadow: var(--mh-shadow-card);
        color: var(--mh-ink);
    }

.hc-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

    .hc-item-top strong {
        font-size: 14px;
    }

.hc-item-parties {
    font-weight: 600;
}

.hc-item-court {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--mh-ink);
    font-size: 12px;
}

    .hc-item-court .mh-icon {
        color: var(--mh-text-secondary);
    }

.hc-item-decision {
    padding: 4px 8px;
    border-radius: var(--mh-radius-sm);
    background: var(--mh-canvas);
    font-size: 12px;
}

    .hc-item-decision b {
        color: var(--mh-primary);
    }

.hc-item-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

.hc-item-next {
    color: var(--mh-text-secondary);
    font-size: 11px;
}

@media (max-width: 1199.98px) {
    .hc-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .hc-grid {
        grid-template-rows: repeat(var(--hc-weeks), minmax(86px, auto));
    }

    .hc-calendar.is-week .hc-grid {
        grid-template-rows: minmax(220px, auto);
    }
}

@media (max-width: 767.98px) {
    .hc-event:not(.is-detailed) {
        font-size: 0;           /* phone: a coloured bar per hearing, no text */
        height: 5px;
        padding: 0;
    }

    .hc-calendar.is-week .hc-grid {
        grid-template-columns: 1fr;
        grid-template-rows: none;
    }

    .hc-calendar.is-week .hc-weekdays {
        display: none;
    }

    .hc-calendar.is-week .hc-day {
        border-inline-start: 0;
    }
}

/* Scheduled but the date has passed and nothing was recorded yet: amber (brass) */
.hc-event.is-missing {
    border-inline-start-color: var(--mh-brass);
    background: var(--mh-brass-wash);
    color: #6B5410;
}

.hc-item.is-missing {
    border-inline-start-color: var(--mh-brass);
}

/* Phones, month view: a clean grid — day number + a count pill; tap a day to see its hearings below */
@media (max-width: 767.98px) {
    .hc-layout {
        gap: var(--mh-space-12);
    }

    .hc-calendar.is-month .hc-grid {
        grid-template-rows: repeat(var(--hc-weeks), minmax(54px, auto));
    }

    .hc-calendar.is-month .hc-day {
        align-items: center;
        justify-content: flex-start;
        gap: 2px;
        padding: 6px 2px;
    }

    .hc-calendar.is-month .hc-day-head {
        flex-direction: column;
        gap: 3px;
    }

    .hc-calendar.is-month .hc-event,
    .hc-calendar.is-month .hc-more {
        display: none;
    }

    .hc-calendar.is-month .hc-day-count {
        min-width: 20px;
        padding: 0 5px;
        background: var(--mh-primary);
        color: #fff;
        font-size: 10px;
        line-height: 16px;
        text-align: center;
    }

    .hc-weekdays span {
        padding: 6px 0;
        font-size: 11px;
    }

    .hc-day-no {
        min-width: 28px;
        height: 28px;
    }

    /* the selected day's list: no inner scrolling on phones, the page scrolls */
    .hc-panel {
        overflow: visible;
    }

    .hc-panel-list {
        overflow: visible;
        padding: var(--mh-space-8);
    }
}

/* Tasks on the calendar */
.hc-event.is-overdue { border-inline-start-color: var(--mh-danger); background: var(--mh-danger-wash); color: var(--mh-danger); }
.hc-event.is-done { border-inline-start-color: var(--mh-stone); background: var(--mh-stone-wash); color: var(--mh-text-secondary); text-decoration: line-through; }
.hc-item.is-overdue { border-inline-start-color: var(--mh-danger); }
.hc-item.is-done { border-inline-start-color: var(--mh-stone); }

/* Calendar pages (الجلسات، المهام): header actions, calendar toolbar, legend */
/* The decision is the most useful fact on a hearing row: give it the most room */
.hr-decision {
    flex: 1 1 200px;
    max-width: none !important;
}

.hp-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--mh-space-8);
}

/* Calendar toolbar: [شهر|أسبوع] [‹ اليوم ›] title ……… legend · lawyer */
.hp-cal-toolbar {
    gap: var(--mh-space-12) var(--mh-space-16);
}

.hp-nav {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* RTL: "previous" points right (the chevron as drawn), "next" points left */
.hp-next .mh-icon {
    transform: rotate(180deg);
}

.hp-period {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--mh-ink);
}

.hp-legend {
    display: inline-flex;
    gap: var(--mh-space-12);
    margin-inline-start: auto;
    color: var(--mh-text-secondary);
    font-size: 12px;
}

    .hp-legend span {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .hp-legend i {
        width: 12px;
        height: 12px;
        border-inline-start: 3px solid var(--mh-primary);
        border-radius: 2px;
        background: var(--mh-wash);
    }

        .hp-legend i.is-held {
            border-inline-start-color: var(--mh-stone);
            background: var(--mh-stone-wash);
        }

@media (max-width: 767.98px) {
    .hp-legend {
        display: none;
    }

    .hp-period {
        flex-basis: 100%;
        order: -1;
    }
}

.hp-legend i.is-missing {
    border-inline-start-color: var(--mh-brass);
    background: var(--mh-brass-wash);
}

/* Phones: header actions on their own row; calendar controls in two tidy rows */
@media (max-width: 767.98px) {
    .hp-header-actions {
        flex: 1 1 100%;
        justify-content: space-between;
    }

    .hp-cal-toolbar {
        gap: var(--mh-space-8);
    }

        .hp-cal-toolbar .hp-period {
            order: -1;
            flex: 1 1 100%;
            font-size: 17px;
        }

    .hp-nav {
        margin-inline-start: auto;
    }
}

.hp-legend i.is-overdue { border-inline-start-color: var(--mh-danger); background: var(--mh-danger-wash); }

/* ---------- 13e. Quick add panel, case / party pickers ----------
   QuickAddPanel (Layout), CasePicker and PartyPicker (Shared). */
.qa-kinds {
    display: flex;
    width: 100%;
    margin-bottom: var(--mh-space-16);
}

    .qa-kinds button {
        display: inline-flex;
        flex: 1;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

.qa-editor { margin-top: var(--mh-space-8); }

.cp-search {
    position: relative;
}

    .cp-search .mh-icon {
        position: absolute;
        top: 50%;
        inset-inline-start: 12px;
        color: var(--mh-text-secondary);
        transform: translateY(-50%);
        pointer-events: none;
    }

    .cp-search input { padding-inline-start: 36px; }

.cp-results {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 300px;
    margin-top: 6px;
    overflow-y: auto;
}

    .cp-results .mh-skeleton { display: block; height: 44px; margin: 4px 0; }

.cp-empty {
    margin: 8px 2px;
    font-size: 13px;
    color: var(--mh-text-secondary);
}

.cp-result, .cp-chosen {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: var(--mh-radius);
    background: transparent;
    color: var(--mh-ink);
    text-align: start;
}

.cp-result:hover, .cp-result:focus-visible {
    outline: none;
    border-color: var(--mh-border);
    background: var(--mh-canvas);
}

.cp-chosen {
    border-color: var(--mh-border);
    background: var(--mh-wash);
}

.cp-no {
    flex-shrink: 0;
    min-width: 48px;
    padding: 2px 8px;
    border-radius: var(--mh-radius-sm);
    background: var(--mh-wash);
    font-weight: 700;
    color: var(--mh-primary);
    text-align: center;
}

.cp-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--mh-surface);
    color: var(--mh-primary);
}

.cp-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    line-height: 1.45;
}

    .cp-text strong, .cp-text small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .cp-text strong { font-size: 13.5px; font-weight: 600; }
    .cp-text strong i { font-style: normal; font-weight: 400; color: var(--mh-text-secondary); }
    .cp-text small { font-size: 12px; color: var(--mh-text-secondary); }

.pp-mode { margin-bottom: 10px; }

/* "يوجد طرف مسجل مشابه" while typing a new party (PartyPicker) */
.pp-similar { margin-top: 10px; font-size: 13px; }
.pp-similar ul { display: grid; gap: 6px; margin: 8px 0; padding: 0; list-style: none; }
.pp-similar li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pp-similar li > span { display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.pp-similar li small { font-weight: 400; color: var(--mh-text-secondary); }
.pp + .validation-message, .cp-results + .validation-message { margin-top: 4px; }

/* Print dialog: the page's own filters (markup from the page, so global) */
.pe-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}

    .pe-filters label {
        display: flex;
        flex-direction: column;
        gap: 4px;
        font-size: 12.5px;
        font-weight: 600;
        color: var(--mh-ink);
    }

    .pe-filters .pe-wide { grid-column: 1 / -1; }

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

/* ---------- 13f. Charts (Shared/Charts: ColumnChart, BarList, Sparkline) ----------
   One quiet system: single-hue marks (navy), light-blue context, hairline solid gridlines, text in text
   tokens (never the series colour), values at the bar tip, peak + latest labelled on columns, a hover /
   focus tooltip on every mark, and a table view. Bars ≤ 24px with a 4px rounded data end. */
.ch-col {
    display: flex;
    flex-direction: column;
    container-type: inline-size;
    height: 100%;
    min-height: 150px;
}

.ch-col-plot {
    position: relative;
    flex: 1;
    min-height: 110px;
    margin-inline-start: 34px;   /* room for the y ticks */
}

.ch-col-grid {
    position: absolute;
    inset: 18px 0 0;
    pointer-events: none;
}

    .ch-col-grid span {
        position: absolute;
        inset-inline: 0;
        border-top: 1px solid #E8ECEF;
    }

        .ch-col-grid span:first-child { border-top-color: #C9D1D7; }   /* baseline */

    .ch-col-grid em {
        position: absolute;
        inset-inline-start: -34px;
        top: -8px;
        width: 28px;
        font-size: 10.5px;
        font-style: normal;
        color: var(--mh-text-secondary);
        text-align: end;
        font-variant-numeric: tabular-nums;
    }

.ch-col-bars {
    position: absolute;
    inset: 18px 0 0;
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 2px;
}

.ch-col-slot {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-radius: var(--mh-radius-sm);
    outline: none;
}

    .ch-col-slot:hover, .ch-col-slot:focus-visible { background: rgba(30, 58, 82, .05); }
    .ch-col-slot:focus-visible { box-shadow: var(--mh-focus-ring); }

.ch-col-bar {
    position: relative;
    display: block;
    width: min(24px, 64%);
    min-height: 0;
    border-radius: 4px 4px 0 0;
    background: var(--mh-light-blue);
    transform-origin: bottom;
    animation: ch-grow-up 600ms cubic-bezier(.2, .7, .2, 1) both;
}

.ch-col-slot.is-highlight .ch-col-bar { background: var(--mh-chart-2); }

.ch-col-value {
    position: absolute;
    bottom: 100%;
    left: 50%;
    padding-bottom: 3px;
    font-size: 11px;
    font-weight: 700;
    color: var(--mh-ink);
    transform: translateX(-50%);
    white-space: nowrap;
}

.ch-col-axis {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 2px;
    margin-inline-start: 34px;
    padding-top: 6px;
}

    .ch-col-axis span {
        overflow: hidden;
        font-size: 10.5px;
        color: var(--mh-text-secondary);
        text-align: center;
        text-overflow: clip;
        white-space: nowrap;
    }

.ch-tip {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    z-index: 6;
    display: none;
    padding: 5px 10px;
    border-radius: var(--mh-radius-sm);
    background: var(--mh-ink);
    font-size: 11.5px;
    color: #fff;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
}

    .ch-tip strong { font-weight: 700; }

.ch-col-slot:hover .ch-tip, .ch-col-slot:focus-visible .ch-tip { display: block; }
.ch-col-slot:first-child .ch-tip { left: auto; right: 0; transform: none; }
.ch-col-slot:last-child .ch-tip { left: 0; transform: none; }

/* Narrow charts: label every other column (the tooltip and table still give every month) */
@container (max-width: 560px) {
    .ch-col-axis span:nth-child(even) { visibility: hidden; }
}

/* Horizontal bars */
.ch-bars {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .ch-bars li > a, .ch-bars li > div {
        display: grid;
        grid-template-columns: minmax(80px, 34%) minmax(0, 1fr) 70px;
        align-items: center;
        gap: 10px;
        min-height: 30px;
        padding: 3px 6px;
        border-radius: var(--mh-radius-sm);
        color: var(--mh-ink);
        text-decoration: none;
    }

    .ch-bars li > a:hover { background: var(--mh-canvas); color: var(--mh-ink); }
    .ch-bars li > a:focus-visible { outline: none; box-shadow: var(--mh-focus-ring); }

.ch-bars-label {
    overflow: hidden;
    font-size: 12.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-bars-track {
    height: 10px;
}

.ch-bars-bar {
    display: block;
    height: 100%;
    border-start-end-radius: 4px;
    border-end-end-radius: 4px;
    background: var(--mh-chart-2);
    transform-origin: right;
    animation: ch-grow-side 650ms cubic-bezier(.2, .7, .2, 1) both;
}

.ch-bars-value {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

    .ch-bars-value strong { font-size: 12.5px; font-weight: 700; }
    .ch-bars-value small { min-width: 30px; font-size: 11px; color: var(--mh-text-secondary); text-align: end; }

.ch-empty {
    margin: 0;
    padding: 24px 8px;
    font-size: 12.5px;
    color: var(--mh-text-secondary);
    text-align: center;
}

/* Sparkline */
.ch-spark {
    display: block;
    width: 100%;
    height: 28px;
    overflow: visible;
}

    .ch-spark polyline {
        fill: none;
        stroke: var(--mh-light-blue);
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
        vector-effect: non-scaling-stroke;
    }

    .ch-spark circle {
        fill: var(--mh-chart-2);
        stroke: var(--mh-surface);
        stroke-width: 2;
        vector-effect: non-scaling-stroke;
    }

/* Table view of a chart */
.ch-table {
    width: 100%;
    font-size: 12.5px;
    border-collapse: collapse;
}

    .ch-table th, .ch-table td {
        padding: 5px 8px;
        border-bottom: 1px solid var(--mh-border);
        text-align: start;
    }

    .ch-table th { background: var(--mh-table-header); font-weight: 700; color: var(--mh-text-secondary); }
    .ch-table td:last-child, .ch-table th:last-child { text-align: end; }
    .ch-table tr.is-highlight td { font-weight: 700; }

@keyframes ch-grow-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes ch-grow-side { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
    .ch-col-bar, .ch-bars-bar { animation: none; }
}

@media print {
    .ch-col-bar, .ch-bars-bar, .ch-spark, .ch-col-grid span { print-color-adjust: exact; -webkit-print-color-adjust: exact; animation: none !important; }
    .ch-tip { display: none !important; }
}

/* ---------- 14. Print ----------
   Hide the app shell and interactive controls; .print-only shows extra headings on paper. */
.print-only {
    display: none;
}

/* A4 portrait for official documents; page number at the bottom of every sheet */
@page {
    size: A4 portrait;
    margin: 14mm 13mm 16mm;

    @bottom-center {
        content: "صفحة " counter(page) " من " counter(pages);
        font-family: "Tajawal", sans-serif;
        font-size: 8pt;
        color: #555;
    }
}

/* Wide printouts (خطة الأسبوع): A4 landscape via a named page */
@page landscape {
    size: A4 landscape;
    margin: 10mm 10mm 14mm;
}

.ps-landscape {
    page: landscape;
}

@media print {
    .sidebar, .sidebar-backdrop, .topbar, .mobile-nav, .no-print, #blazor-error-ui, #components-reconnect-modal,
    .mh-drawer, .mh-drawer-backdrop, .mh-modal-backdrop, .mh-dialog, .mh-toast-stack,
    .screen-only {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    html, body {
        background: #fff !important;
    }

    .content {
        padding: 0 !important;
    }

    .mh-card {
        box-shadow: none !important;
        break-inside: avoid;
    }

    a {
        color: inherit !important;
        text-decoration: none !important;
    }
}

/* ---------- 15. Blazor framework ---------- */
.blazor-error-boundary {
    background: var(--mh-danger);
    padding: 1rem 1.5rem;
    color: white;
    border-radius: var(--mh-radius-sm);
}

    .blazor-error-boundary::after {
        content: "حدث خطأ غير متوقع.";
    }

/* ---------- 16. Sign-in pages (LoginPage, ChangePasswordPage — AuthLayout) ---------- */
/* docs/design/maham-v6-login.png. Brand on the navy background, then a white card. */

.lg {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 440px;
    animation: lg-in 420ms cubic-bezier(.2, .7, .2, 1) both;
}

@keyframes lg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Brand ---------- */
.lg-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 26px;
    color: #fff;
    text-align: center;
}

.lg-logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    font-family: var(--mh-font-heading);
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
}

    .lg-logo .mh-icon {
        width: 38px;
        height: 38px;
    }

.lg-brand p {
    margin: 10px 0 0;
    font-size: 14px;
    color: rgba(255, 255, 255, .78);
}

.lg-rule {
    width: 40px;
    height: 3px;
    margin-top: 18px;
    border-radius: 2px;
    background: var(--mh-brass);
}

/* ---------- Card ---------- */
.lg-card {
    width: 100%;
    padding: 32px 33px;
    border-radius: 14px;
    background: var(--mh-surface);
    box-shadow: 0 24px 60px rgba(5, 14, 24, .35), var(--mh-shadow-modal);
}

    .lg-card h1 {
        margin: 0;
        font-size: 22px;
        font-weight: 700;
        line-height: 1.4;
        color: var(--mh-ink);
    }

.lg-sub {
    margin: 2px 0 22px;
    font-size: 13px;
    color: var(--mh-text-secondary);
}

.lg-card .mh-alert { margin-bottom: 16px; font-size: 13px; }

/* ---------- Fields ---------- */
.lg-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

    .lg-field label {
        margin-bottom: 7px;
        font-size: 13px;
        font-weight: 700;
        color: var(--mh-ink);
    }

.lg-card .lg-control {
    height: 44px;
    padding-inline: 14px;
    border-color: var(--mh-border);
    border-radius: 6px;
    font-size: 14.5px;
    text-align: right;   /* LTR text (login, password) still starts on the right, like the design */
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

    .lg-card .lg-control:focus {
        border-color: var(--mh-primary);
        box-shadow: 0 0 0 3px rgba(30, 58, 82, .14);
    }

    .lg-card .lg-control.invalid { border-color: var(--mh-danger); }

.lg-card .validation-message {
    margin-top: 5px;
    font-size: 12px;
    color: var(--mh-danger);
}

.lg-password {
    position: relative;
}

    .lg-password .lg-control { padding-inline-end: 46px; }

/* The eye sits at the left end of the field (RTL end) */
.lg-reveal {
    position: absolute;
    top: 50%;
    inset-inline-end: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--mh-text-secondary);
    transform: translateY(-50%);
}

    .lg-reveal:hover { background: var(--mh-canvas); color: var(--mh-primary); }
    .lg-reveal:focus-visible { outline: none; box-shadow: var(--mh-focus-ring); }

/* ---------- Remember / forgot ---------- */
.lg-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin: 4px 0 22px;
}

.lg-remember {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    color: var(--mh-ink);
    cursor: pointer;
    user-select: none;
}

    .lg-remember input[type="checkbox"] {
        width: 18px;
        height: 18px;
        margin: 0;
        accent-color: var(--mh-primary);
        cursor: pointer;
    }

.lg-submit {
    width: 100%;
    height: 46px;
    border-radius: 6px;
    font-size: 15.5px;
    font-weight: 600;
}

.lg-policy {
    margin: 22px 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, .6);
    text-align: center;
}

/* ---------- Phones ---------- */
@media (max-width: 767.98px) {
    .lg-brand { margin-bottom: 20px; }
    .lg-logo { font-size: 30px; }
    .lg-card { padding: 26px 20px; }
    .lg-card .lg-control { height: 48px; font-size: 16px; }   /* 16px: no zoom on iOS */
    .lg-submit { height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
    .lg { animation: none; }
}

/* ---------- كلمة مرور جديدة (ChangePasswordPage uses the same card) ---------- */
.lg-card .cp-rules,
.cp-rules {
    margin-top: 5px;
    font-size: 12px;
    color: var(--mh-text-secondary);
}

.cp-out { margin-top: 12px; text-align: center; }
.cp-out .btn-link { font-size: 13px; color: var(--mh-text-secondary); }
