/* =========================================================
   المؤسسة العامة للتبغ (Regi) — Design System
   NativePHP Desktop App — Modern Arabic/English UI
   ========================================================= */

/* ─── Google Fonts (Loaded asynchronously via layout <link> for high performance) ─── */

/* ─── CSS Variables (Design Tokens) ─── */
:root {
    /* ── Color Palette ──
       Taken from the sign-in screen: Syrian-emblem gold on warm cream, with
       near-black ink for primary actions. No purple anywhere. */
    --color-primary: #7a6535;
    --color-primary-light: #b9a57b;
    --color-primary-dark: #5e4e29;
    --color-primary-glow: rgba(154, 131, 82, 0.24);

    --color-secondary: #9a8352;
    --color-secondary-light: #c9b27f;

    /* Primary buttons are ink, like the sign-in button. */
    --color-action: #1d1f23;
    --color-action-hover: #33363c;
    --color-action-text: #ffffff;

    --color-accent: #2f7d74;
    --color-accent-light: #4f9d93;

    --color-success: #1f8a5b;
    --color-success-light: #34a874;
    --color-warning: #c7861a;
    --color-warning-light: #e0a53c;
    --color-danger: #c2412d;
    --color-danger-light: #d9624f;
    --color-info: #2f6690;
    --color-info-light: #4b86b3;

    /* ── Surfaces (Light Mode) ── */
    color-scheme: light;
    --bg-primary: #ffffff;
    --bg-secondary: #faf8f3;
    --bg-body: #f6f4ef;
    --bg-sidebar: #ece8de;
    --bg-card: #ffffff;
    --bg-card-hover: #fcfbf8;
    --bg-input: #fbfaf7;
    --bg-topbar: #ffffff;
    --bg-overlay: rgba(29, 31, 35, 0.72);
    --bg-badge: #f3eee2;
    --bg-hover: #f3eee2;

    /* ── Text ── */
    --text-primary: #1d1f23;
    --text-secondary: #5f5c55;
    --text-tertiary: #8a857a;
    --text-muted: #77736a;
    --text-inverse: #ffffff;
    --text-link: var(--color-primary);

    /* ── Borders ── */
    --border-color: #e6e0d3;
    --border-color-hover: #b9a57b;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
    --border-radius-full: 9999px;

    /* Short aliases used by inline styles in Blade views */
    --radius-sm: var(--border-radius-sm);
    --radius-md: var(--border-radius-md);
    --radius-lg: var(--border-radius-lg);
    --radius-xl: var(--border-radius-xl);
    --radius-full: var(--border-radius-full);

    /* ── Shadows (warm, low) ── */
    --shadow-sm: 0 1px 2px rgba(60, 50, 30, 0.05);
    --shadow-md: 0 4px 12px rgba(60, 50, 30, 0.07);
    --shadow-lg: 0 8px 28px rgba(60, 50, 30, 0.09);
    --shadow-xl: 0 20px 56px rgba(60, 50, 30, 0.12);
    --shadow-glow: 0 0 0 3px var(--color-primary-glow);
    --shadow-card: 0 1px 3px rgba(60, 50, 30, 0.05);

    /* ── Spacing ── */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* ── Typography ── */
    --font-ar: 'Tajawal', sans-serif;
    --font-en: 'Tajawal', sans-serif;
    --font-mono: 'Fira Code', 'Consolas', monospace;

    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --font-size-4xl: 2.5rem;

    /* ── Layout ── */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 64px;

    /* ── Transitions ── */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ── Solid Surfaces (no transparency / no blur) ── */
    --glass-bg: #ffffff;
    --glass-border: #e6e0d3;
}

/* ─── Dark Mode ─── */
[data-theme="dark"] {
    color-scheme: dark;
    --color-primary: #d3bd8a;
    --color-primary-light: #e2d2ab;
    --color-primary-dark: #c9b27f;
    --color-primary-glow: rgba(201, 178, 127, 0.22);
    --color-secondary: #c9b27f;
    --color-secondary-light: #d8c496;

    /* The sign-in button turns gold with dark text in the dark theme. */
    --color-action: #c9b27f;
    --color-action-hover: #d8c496;
    --color-action-text: #17181c;

    --bg-primary: #17181c;
    --bg-secondary: #1b1c21;
    --bg-body: #131418;
    --bg-sidebar: #17181c;
    --bg-card: #1b1c21;
    --bg-card-hover: #212329;
    --bg-input: #1b1c21;
    --bg-topbar: #17181c;
    --bg-overlay: rgba(10, 10, 12, 0.8);
    --bg-badge: #262420;
    --bg-hover: #25262c;

    --text-primary: #ecebe7;
    --text-secondary: #a4a29b;
    --text-tertiary: #7d7b75;
    --text-muted: #8f8c85;

    --border-color: #2e2f35;
    --border-color-hover: #8f7c52;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04);

    --glass-bg: #1b1c21;
    --glass-border: #2e2f35;
}

/* ─── Base Reset ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif !important;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: 'Tajawal', sans-serif !important;
}

body,
button,
input,
select,
textarea,
optgroup,
span,
p,
h1,
h2,
h3,
h4,
h5,
h6,
a,
label {
    font-family: 'Tajawal', sans-serif !important;
}

/* ─── Language-Based Font Selection ─── */
html[lang="ar"],
html[lang="en"] {
    font-family: 'Tajawal', sans-serif !important;
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.7;
    overflow: hidden;
    height: 100vh;
    /* Phones: 100vh includes the area under the browser's address bar, which
       cut off the footer and the pagination. dvh is the visible height. */
    height: 100dvh;
    font-family: 'Tajawal', sans-serif !important;
}

/* ─── App Layout ─── */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-inline-end: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    z-index: 50;
    transition: width var(--transition-base), transform var(--transition-base);
    overflow: hidden;
    /* Logical edge: the right side in Arabic (RTL), the left side in LTR languages. */
    inset-inline-start: 0;
}

.sidebar-brand {
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    background: var(--color-action);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--color-action-text);
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-brand-text h1 {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-brand-emblem {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: var(--border-radius-md);
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 2px;
}

.sidebar-brand .official-heading {
    flex: 1;
    min-width: 0;
}

/* =========================================================
   Official letterhead (x-official-heading)
   ========================================================= */
.official-heading {
    display: flex;
    flex-direction: column;
    gap: 1px;
    text-align: start;
    line-height: 1.35;
}

.official-heading-line {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.official-heading-institution {
    font-size: var(--font-size-base, 15px);
    font-weight: 800;
    color: var(--text-primary);
}

.official-banner {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-inline-start: 4px solid var(--color-primary);
    border-radius: var(--border-radius-lg);
}

.official-banner-emblem {
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    object-fit: contain;
}

.official-banner .official-heading-line {
    font-size: var(--font-size-sm);
}

.official-banner .official-heading-institution {
    font-size: var(--font-size-lg);
}

.sidebar-brand-text span {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    font-weight: 400;
}

/* ── Nav Items ── */
.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--border-radius-full);
}

.nav-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--space-md) var(--space-sm) var(--space-sm);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-badge);
    color: var(--color-primary);
    transform: translateX(0);
}

[dir="rtl"] .nav-item:hover {
    transform: translateX(0);
}

.nav-item.active {
    background: var(--bg-card);
    color: var(--color-primary);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--color-primary);
    border-radius: var(--border-radius-full);
}

.nav-item.active::before {
    inset-inline-start: 0;
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.main-content {
    margin-inline-start: var(--sidebar-width);
}

/* ─── Topbar ─── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    position: sticky;
    top: 0;
    z-index: 40;
    flex-shrink: 0;
}

.topbar-title {
    display: flex;
    flex-direction: column;
}

.topbar-title h2 {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.topbar-title span {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

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

/* ─── Page Content ─── */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
    scroll-behavior: smooth;
}

.page-content::-webkit-scrollbar {
    width: 6px;
}

.page-content::-webkit-scrollbar-track {
    background: transparent;
}

.page-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--border-radius-full);
}

.page-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ─── Cards (Glassmorphism) ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.card:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

/* ─── Stats Cards Grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-sm, 12px);
    margin-bottom: var(--space-lg, 20px);
}

@media (max-width: 1280px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* =========================================================
   Dashboard statistics tiles (the key figures on لوحة التحكم)
   One headline figure (total workforce, ≥ 48px) and four tiles. Each has a two-tone icon
   (x-duo-icon) in a tinted badge, a readable label, a large figure in the text colour, and a
   meter or split bar under it. The accent colour marks only the badge and the meter; figures
   and labels stay in text colours. The grid answers to its own width (container queries), so
   the tiles fill whole rows whether the sidebar is open or not.
   ========================================================= */
:root {
    --kpi-tone-brand: var(--color-primary);
    --kpi-tone-blue: var(--viz-series-1, #2a78d6);
    --kpi-tone-teal: #2f7d74;
    --kpi-tone-neutral: #5f5c55;
    --kpi-tone-good: #1f8a5b;
    --kpi-tone-warn: #b87a14;
    --kpi-gender-male: #2563eb;
    --kpi-gender-female: #ec4899;
}

[data-theme="dark"] {
    --kpi-tone-teal: #4f9d93;
    --kpi-tone-neutral: #a4a29b;
    --kpi-tone-good: #34a874;
    --kpi-tone-warn: #e0a53c;
}

.kpi-tone-brand { --kpi-accent: var(--kpi-tone-brand); }
.kpi-tone-blue { --kpi-accent: var(--kpi-tone-blue); }
.kpi-tone-teal { --kpi-accent: var(--kpi-tone-teal); }
.kpi-tone-neutral { --kpi-accent: var(--kpi-tone-neutral); }
.kpi-tone-good { --kpi-accent: var(--kpi-tone-good); }
.kpi-tone-warn { --kpi-accent: var(--kpi-tone-warn); }

.kpi-section {
    container-type: inline-size;
    margin-bottom: var(--space-xl, 24px);
}

.kpi-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

/* Two per row; the headline tile takes a full row. */
@container (min-width: 520px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi-tile--hero {
        grid-column: span 2;
    }
}

/* Three per row: headline (2) + 1, then 3. */
@container (min-width: 820px) {
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* One row: headline (2) + 4. */
@container (min-width: 1180px) {
    .kpi-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.kpi-tile {
    /* The tone classes set --kpi-accent; tiles without one fall back to the brand colour. */
    --kpi-tint: color-mix(in srgb, var(--kpi-accent, var(--kpi-tone-brand)) 14%, var(--bg-card));
    --kpi-track: color-mix(in srgb, var(--kpi-accent, var(--kpi-tone-brand)) 18%, var(--bg-card));
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    min-height: 188px;
    padding: 22px 22px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(29, 31, 35, 0.04), 0 10px 28px -18px rgba(29, 31, 35, 0.22);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kpi-tile::before {
    content: '';
    position: absolute;
    inset-block-start: 0;
    inset-inline: 22px;
    block-size: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--kpi-accent, var(--kpi-tone-brand));
}

.kpi-tile:hover {
    border-color: color-mix(in srgb, var(--kpi-accent, var(--kpi-tone-brand)) 45%, var(--border-color));
    box-shadow: 0 1px 2px rgba(29, 31, 35, 0.05), 0 16px 32px -18px rgba(29, 31, 35, 0.28);
}

[data-theme="dark"] .kpi-tile {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -18px rgba(0, 0, 0, 0.6);
}

.kpi-tile-interactive {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.kpi-tile-interactive:hover {
    transform: translateY(-3px);
    text-decoration: none;
    color: inherit;
}

.kpi-tile-interactive:focus-visible {
    outline: 2px solid var(--kpi-accent, var(--kpi-tone-brand));
    outline-offset: 2px;
}

.kpi-tile-interactive:active {
    transform: translateY(-1px);
}

.kpi-tile-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
    inline-size: 28px;
    block-size: 28px;
    border-radius: 8px;
    background: var(--kpi-tint);
    color: var(--kpi-accent, var(--kpi-tone-brand));
    opacity: 0.65;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}

.kpi-tile-interactive:hover .kpi-tile-action-icon {
    opacity: 1;
    transform: scale(1.1) translate(-2px, -2px);
    background: color-mix(in srgb, var(--kpi-accent, var(--kpi-tone-brand)) 25%, var(--bg-card));
}

[dir="ltr"] .kpi-tile-interactive:hover .kpi-tile-action-icon {
    transform: scale(1.1) translate(2px, -2px);
}

.kpi-tile-head {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.kpi-tile-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    inline-size: 56px;
    block-size: 56px;
    border-radius: 16px;
    background: var(--kpi-tint);
    color: var(--kpi-accent, var(--kpi-tone-brand));
}

.kpi-tile-label {
    margin: 0;
    min-width: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-secondary);
}

.kpi-tile-value {
    margin: 0;
    font-size: clamp(2.1rem, 1.7rem + 1.1cqi, 2.6rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    /* Large standalone figures keep proportional digits. */
    font-variant-numeric: normal;
}

.kpi-tile--hero .kpi-tile-value {
    font-size: clamp(3rem, 2.5rem + 1.4cqi, 3.75rem);
}

.kpi-tile-foot {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: auto;
}

.kpi-meter {
    block-size: 8px;
    border-radius: 999px;
    background: var(--kpi-track);
    overflow: hidden;
}

.kpi-meter > span {
    display: block;
    block-size: 100%;
    inline-size: var(--kpi-fill, 0%);
    max-inline-size: 100%;
    border-radius: inherit;
    background: var(--kpi-accent, var(--kpi-tone-brand));
}

.kpi-tile-note {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 0;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-secondary);
}

.kpi-tile-note strong {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-primary);
}

/* A figure with its status beside it (the quota). */
.kpi-tile-value-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
}

/* Status of the quota: an icon and a word, never colour alone. */
.kpi-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--kpi-tint);
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.kpi-status .lucide-icon {
    color: var(--kpi-accent, var(--kpi-tone-brand));
}

/* Gender tile: two figures and a split bar in the charts' own colours. */
.kpi-tile-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.kpi-pair-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    min-width: 0;
}

.kpi-pair-item-interactive {
    padding: 6px 10px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-pair-item-interactive:hover {
    background: color-mix(in srgb, var(--color-primary) 8%, var(--bg-secondary));
    transform: translateY(-1px);
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .kpi-pair-item-interactive:hover {
    background: rgba(255, 255, 255, 0.08);
}

.kpi-pair-item-interactive:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.kpi-pair-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.kpi-pair-value {
    font-size: clamp(1.6rem, 1.35rem + 0.7cqi, 2rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}

.kpi-dot {
    inline-size: 10px;
    block-size: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kpi-dot--male,
.kpi-split-male {
    background: var(--kpi-gender-male);
}

.kpi-dot--female,
.kpi-split-female {
    background: var(--kpi-gender-female);
}

.kpi-split {
    display: flex;
    gap: 2px;
    block-size: 10px;
    border-radius: 999px;
    overflow: hidden;
}

.kpi-split-male {
    flex: 0 0 auto;
    inline-size: var(--kpi-fill, 50%);
    min-inline-size: 2px;
}

.kpi-split-female {
    flex: 1 1 auto;
    min-inline-size: 2px;
}

@media print {
    .kpi-tile {
        box-shadow: none;
        break-inside: avoid;
    }
}

/* ─── Premium Chart Container Header ─── */
.chart-card-box {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e6e0d3);
    border-radius: var(--radius-xl, 16px);
    padding: var(--space-md, 16px);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.05));
    transition: all 0.2s ease;
}

[data-theme="dark"] .chart-card-box {
    background: #1b1c21;
    border-color: rgba(255, 255, 255, 0.08);
}

.chart-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
}

[data-theme="dark"] .chart-box-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.chart-box-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-box-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--kpi-accent, var(--kpi-tone-brand)) 14%, var(--bg-card));
    color: var(--kpi-accent, var(--kpi-tone-brand));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chart-box-title {
    font-size: 13.5px;
    font-weight: 800;
    color: var(--text-primary, #1d1f23);
    margin: 0;
}

[data-theme="dark"] .chart-box-title {
    color: #efece5;
}

.chart-box-subtitle {
    font-size: 11px;
    color: var(--text-muted, #6b675e);
    margin: 0;
}

[data-theme="dark"] .chart-box-subtitle {
    color: #a4a29b;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    transition: all var(--transition-base);
    cursor: default;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--stat-color, var(--color-primary)), transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    background: var(--stat-bg, var(--bg-badge));
    color: var(--stat-color, var(--color-primary));
}

.stat-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card.primary {
    --stat-color: #7a6535;
    --stat-bg: rgba(154, 131, 82, 0.1);
}

.stat-card.success {
    --stat-color: #1f8a5b;
    --stat-bg: rgba(31, 138, 91, 0.1);
}

.stat-card.warning {
    --stat-color: #c7861a;
    --stat-bg: rgba(199, 134, 26, 0.1);
}

.stat-card.info {
    --stat-color: #2f7d74;
    --stat-bg: rgba(47, 125, 116, 0.1);
}

.stat-card.danger {
    --stat-color: #c2412d;
    --stat-bg: rgba(194, 65, 45, 0.1);
}

/* ─── Content Grid ─── */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: var(--space-lg);
}

.content-grid-full {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.06);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after {
    opacity: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--color-action);
    color: var(--color-action-text);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--color-action-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--border-color-hover);
    background: var(--bg-card-hover);
}

.btn-success {
    background: var(--color-success);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--bg-badge);
    color: var(--color-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: var(--font-size-xs);
    border-radius: var(--border-radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: var(--font-size-base);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--border-radius-md);
}

.btn-group {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* ─── Form Elements ─── */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-control,
.form-textarea,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"] {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-family: 'Tajawal', sans-serif !important;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.form-input:focus,
.form-control:focus,
.form-textarea:focus,
.form-select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus {
    border-color: var(--color-primary);
    background: var(--bg-card-hover);
    box-shadow: 0 0 0 4px var(--color-primary-glow);
}

.form-control.is-invalid,
.form-input.is-invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(194, 65, 45, 0.2);
}

.form-input::placeholder,
.form-control::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ─── Select & Dropdown Options (Prevent Chromium Dark Popup Blackout) ─── */
.form-select,
select {
    cursor: pointer;
    background-color: #ffffff;
    color: var(--text-primary);
    color-scheme: light;
}

[data-theme="dark"] .form-select,
[data-theme="dark"] select {
    background-color: var(--bg-card, #1b1c21);
    color: var(--text-primary);
    color-scheme: dark;
}

select option,
select optgroup,
.form-select option,
.form-select optgroup {
    background-color: #ffffff !important;
    color: #1d1f23 !important;
    padding: 10px 14px !important;
    font-family: 'Tajawal', sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
}

[data-theme="dark"] select option,
[data-theme="dark"] select optgroup,
[data-theme="dark"] .form-select option,
[data-theme="dark"] .form-select optgroup {
    background-color: #1b1c21 !important;
    color: #efece5 !important;
}

select option:checked,
.form-select option:checked {
    background-color: #f3eee2 !important;
    color: #5e4e29 !important;
    font-weight: 700 !important;
}

[data-theme="dark"] select option:checked,
[data-theme="dark"] .form-select option:checked {
    background-color: #5e4e29 !important;
    color: #ffffff !important;
}

.form-select:disabled,
select:disabled {
    background-color: #efece5 !important;
    color: #6b675e !important;
    border-color: #e6e0d3 !important;
    cursor: not-allowed !important;
    opacity: 0.85 !important;
}

[data-theme="dark"] .form-select:disabled,
[data-theme="dark"] select:disabled {
    background-color: #17181c !important;
    color: #a4a29b !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* ─── Livewire Loading States ─── */
[wire\:loading],
[wire\:loading\.delay],
[wire\:loading\.inline-block],
[wire\:loading\.inline],
[wire\:loading\.block],
[wire\:loading\.flex],
[wire\:loading\.table] {
    display: none !important;
}

.btn-loading-active [wire\:loading],
.btn-loading-active[wire\:loading] {
    display: inline-flex !important;
}

/* ─── Toggle Switch ─── */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.toggle {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: var(--border-radius-full);
    transition: all var(--transition-base);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    transition: all var(--transition-spring);
    box-shadow: var(--shadow-sm);
}

[dir="ltr"] .toggle-slider::before {
    left: 3px;
}

[dir="rtl"] .toggle-slider::before {
    right: 3px;
}

.toggle input:checked+.toggle-slider {
    background: var(--color-primary);
}

[dir="ltr"] .toggle input:checked+.toggle-slider::before {
    transform: translateX(22px);
}

[dir="rtl"] .toggle input:checked+.toggle-slider::before {
    transform: translateX(-22px);
}

/* ─── Badge ─── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--border-radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: var(--bg-badge);
    color: var(--color-primary);
}

.badge-success {
    background: rgba(31, 138, 91, 0.1);
    color: var(--color-success);
}

.badge-warning {
    background: rgba(199, 134, 26, 0.1);
    color: var(--color-warning);
}

.badge-danger {
    background: rgba(194, 65, 45, 0.1);
    color: var(--color-danger);
}

/* ─── Alert / Toast ─── */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: var(--font-size-sm);
    animation: slideIn var(--transition-spring) forwards;
}

.alert-success {
    background: rgba(31, 138, 91, 0.1);
    border: 1px solid rgba(31, 138, 91, 0.2);
    color: var(--color-success);
}

.alert-danger {
    background: rgba(194, 65, 45, 0.1);
    border: 1px solid rgba(194, 65, 45, 0.2);
    color: var(--color-danger);
}

.alert-warning {
    background: rgba(199, 134, 26, 0.1);
    border: 1px solid rgba(199, 134, 26, 0.2);
    color: var(--color-warning);
}

.alert-info {
    background: rgba(47, 102, 144, 0.1);
    border: 1px solid rgba(47, 102, 144, 0.2);
    color: var(--color-info);
}

/* ─── Notes List ─── */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: var(--space-md);
}

.note-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
    cursor: pointer;
}

.note-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--note-color, var(--color-primary));
}

.note-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.note-card-title {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.note-card-content {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-md);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.note-card-date {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.note-card-actions {
    display: flex;
    gap: var(--space-xs);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.note-card:hover .note-card-actions {
    opacity: 1;
}

/* ─── Empty State ─── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.3;
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.empty-state-text {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    margin-bottom: var(--space-lg);
}

/* ─── Feature Demo Card ─── */
.feature-demo {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
}

.feature-demo-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.feature-demo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: var(--bg-badge);
    color: var(--color-primary);
}

.feature-demo-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.feature-demo-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.feature-demo-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* ─── Result Box ─── */
.result-box {
    background: var(--bg-input);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-md);
    padding: var(--space-md);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    min-height: 48px;
    display: flex;
    align-items: center;
    word-break: break-all;
}

/* ─── Settings Section ─── */
.settings-section {
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) 0;
    gap: var(--space-lg);
}

.settings-row-info {
    flex: 1;
}

.settings-row-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.settings-row-description {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: 2px;
}

.settings-row-action {
    flex-shrink: 0;
}

/* ─── Language Switcher ─── */
.lang-switcher {
    display: flex;
    background: var(--bg-input);
    border-radius: var(--border-radius-full);
    padding: 3px;
    border: 1px solid var(--border-color);
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: none;
    border-radius: var(--border-radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.lang-btn.active {
    background: var(--color-action);
    color: var(--color-action-text);
    box-shadow: var(--shadow-sm);
}

/* ─── Theme Toggle ─── */
.theme-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    border-color: var(--border-color-hover);
    color: var(--color-primary);
    background: var(--bg-badge);
}

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xl);
    padding: var(--space-xl);
    width: 90%;
    max-width: 520px;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-spring);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.modal-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-xl);
}

/* ─── Features Overview Grid ─── */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-md);
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    text-align: center;
    transition: all var(--transition-base);
    cursor: pointer;
    text-decoration: none;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-color-hover);
}

.feature-card-icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
    display: block;
}

.feature-card-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── Animations ─── */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-base) ease-out forwards;
}

.animate-slide-in {
    animation: slideIn var(--transition-spring) forwards;
}

.animate-scale-in {
    animation: scaleIn var(--transition-spring) forwards;
}

/* Staggered children animation */
.stagger-children>*:nth-child(1) {
    animation-delay: 0ms;
}

.stagger-children>*:nth-child(2) {
    animation-delay: 60ms;
}

.stagger-children>*:nth-child(3) {
    animation-delay: 120ms;
}

.stagger-children>*:nth-child(4) {
    animation-delay: 180ms;
}

.stagger-children>*:nth-child(5) {
    animation-delay: 240ms;
}

.stagger-children>*:nth-child(6) {
    animation-delay: 300ms;
}

/* ─── Utility Classes ─── */
.text-center {
    text-align: center;
}

.text-start {
    text-align: start;
}

.text-end {
    text-align: end;
}

.text-muted {
    color: var(--text-tertiary);
}

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

.text-xs {
    font-size: var(--font-size-xs);
}

.font-bold {
    font-weight: 700;
}

.mt-sm {
    margin-top: var(--space-sm);
}

.mt-md {
    margin-top: var(--space-md);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.w-full {
    width: 100%;
}

.hidden {
    display: none !important;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

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

    .main-content {
        margin-inline-start: 0 !important;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   Unified Design System Extensions
   Centralized Tables, Badges, Diffs, Filters & User Controls
   ========================================================= */

/* ── Unified Action Buttons ── */
.btn-info {
    background: var(--color-info);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-info:hover {
    box-shadow: var(--shadow-md);
}

/* ── Unified Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--border-radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-primary {
    background: rgba(154, 131, 82, 0.12);
    color: var(--color-primary);
    border-color: rgba(154, 131, 82, 0.25);
}

.badge-secondary {
    background: rgba(122, 101, 53, 0.12);
    color: var(--color-secondary);
    border-color: rgba(122, 101, 53, 0.25);
}

.badge-success {
    background: rgba(31, 138, 91, 0.12);
    color: var(--color-success);
    border-color: rgba(31, 138, 91, 0.25);
}

.badge-danger {
    background: rgba(194, 65, 45, 0.12);
    color: var(--color-danger);
    border-color: rgba(194, 65, 45, 0.25);
}

.badge-warning {
    background: rgba(199, 134, 26, 0.12);
    color: var(--color-warning);
    border-color: rgba(199, 134, 26, 0.25);
}

.badge-info {
    background: rgba(47, 125, 116, 0.12);
    color: var(--color-info);
    border-color: rgba(47, 125, 116, 0.25);
}

/* ── Filter Bar ── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-card);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: var(--space-lg);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 180px;
}

.filter-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition-fast);
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* ── Unified Data Tables ── */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: start;
    font-size: var(--font-size-sm);
}

.data-table thead {
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .data-table thead {
    background: rgba(255, 255, 255, 0.02);
}

.data-table th {
    padding: 14px 18px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: var(--font-size-xs);
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.data-table td {
    padding: 14px 18px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Unified Pagination Controls ── */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.pagination-info {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

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

/* ── Diff Viewer (كيف كانت وكيف صارت) ── */
.diff-modal-body {
    max-height: 65vh;
    overflow-y: auto;
    padding: var(--space-md);
}

.diff-header-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--bg-badge);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--space-lg);
}

.diff-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

@media (max-width: 640px) {
    .diff-grid {
        grid-template-columns: 1fr;
    }
}

.diff-pane {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.diff-pane-title {
    padding: 10px 14px;
    font-weight: 700;
    font-size: var(--font-size-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.diff-pane-title.old {
    background: rgba(194, 65, 45, 0.1);
    color: var(--color-danger);
    border-bottom: 1px solid rgba(194, 65, 45, 0.2);
}

.diff-pane-title.new {
    background: rgba(31, 138, 91, 0.1);
    color: var(--color-success);
    border-bottom: 1px solid rgba(31, 138, 91, 0.2);
}

.diff-pane-content {
    padding: var(--space-md);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 250px;
    overflow-y: auto;
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-lg);
}

.diff-table th,
.diff-table td {
    padding: 8px 12px;
    font-size: var(--font-size-xs);
    border: 1px solid var(--border-color);
}

.diff-cell-old {
    background: rgba(194, 65, 45, 0.08);
    color: var(--color-danger);
}

.diff-cell-new {
    background: rgba(31, 138, 91, 0.08);
    color: var(--color-success);
}

.raw-json-box {
    background: #1d1f23;
    color: #ecebe7;
    padding: var(--space-md);
    border-radius: var(--border-radius-md);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    overflow-x: auto;
    direction: ltr;
    text-align: left;
    max-height: 220px;
}

/* ── Topbar Active User & Switcher ── */
.user-topbar-card {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-topbar-card:hover {
    border-color: var(--color-primary);
    background: var(--bg-card-hover);
}

.user-avatar-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-action);
    color: var(--color-action-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-xs);
}

.user-topbar-name {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--text-primary);
}

.user-switch-dropdown {
    position: relative;
}

/* ─── Dropdowns (100% Solid Opaque - NEVER TRANSPARENT) ─── */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    background: #ffffff !important;
    border: 1.5px solid rgba(0, 0, 0, 0.12) !important;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.16), 0 5px 15px rgba(0, 0, 0, 0.08) !important;
    padding: var(--space-sm);
    min-width: 260px;
    z-index: 1000 !important;
    opacity: 1 !important;
}

[data-theme="dark"] .dropdown-menu {
    background: #1b1c21 !important;
    border: 1.5px solid rgba(255, 255, 255, 0.14) !important;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05) inset !important;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-badge);
    color: var(--color-primary);
}

/* ─── Topbar Buttons (Bell, Theme Toggle, etc.) ─── */
.topbar-btn,
.topbar-bell-btn,
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--border-radius-full);
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    position: relative;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-btn:hover,
.topbar-bell-btn:hover,
.theme-toggle:hover {
    background: var(--bg-card-hover);
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(154, 131, 82, 0.18);
}

.topbar-btn:active,
.topbar-bell-btn:active,
.theme-toggle:active {
    transform: translateY(0);
}

/* ─── Universal Loading Spinner ─── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spinRotate 0.65s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;
}

.spinner-primary {
    border-color: rgba(154, 131, 82, 0.2);
    border-top-color: var(--color-primary);
}

@keyframes spinRotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ─── Language Switcher Flags ─── */
.lang-switcher .flag-icon {
    display: inline-block;
    vertical-align: middle;
}

/* ── Mobile Navigation & Drawer ── */
.mobile-menu-btn {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 8px;
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.sidebar-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
}

.sidebar-close-btn:hover {
    color: var(--color-danger);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 80;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* ── SweetAlert2 Luxury Global Theme ── */
.swal2-container {
    z-index: 99999 !important;
}

.regi-swal-popup {
    border-radius: 24px !important;
    border: 1.5px solid var(--border-color) !important;
    font-family: 'Tajawal', sans-serif !important;
    padding: 32px 28px !important;
    background: var(--bg-card) !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.1) inset !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

[data-theme="dark"] .regi-swal-popup {
    background: #1b1c21 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) inset !important;
}

/* Status-specific Luxury Borders and Dynamic Glows */
.regi-swal-popup.regi-swal-success {
    border-color: rgba(31, 138, 91, 0.45) !important;
    box-shadow: 0 20px 60px rgba(31, 138, 91, 0.18), 0 0 35px rgba(31, 138, 91, 0.12) !important;
}

.regi-swal-popup.regi-swal-error {
    border-color: rgba(194, 65, 45, 0.45) !important;
    box-shadow: 0 20px 60px rgba(194, 65, 45, 0.22), 0 0 35px rgba(194, 65, 45, 0.12) !important;
    animation: swalShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.regi-swal-popup.regi-swal-warning {
    border-color: rgba(199, 134, 26, 0.45) !important;
    box-shadow: 0 20px 60px rgba(199, 134, 26, 0.18), 0 0 35px rgba(199, 134, 26, 0.1) !important;
}

.regi-swal-popup.regi-swal-info {
    border-color: rgba(154, 131, 82, 0.45) !important;
    box-shadow: 0 20px 60px rgba(154, 131, 82, 0.2), 0 0 35px rgba(154, 131, 82, 0.12) !important;
}

@keyframes swalShake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-3px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(3px, 0, 0);
    }
}

.regi-swal-title {
    font-size: 22px !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
    letter-spacing: -0.01em !important;
    margin-top: 14px !important;
}

.regi-swal-text {
    font-size: 15px !important;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
    line-height: 1.6 !important;
    margin-top: 8px !important;
}

.regi-swal-confirm-btn {
    border-radius: 12px !important;
    padding: 12px 28px !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em !important;
    box-shadow: 0 8px 20px rgba(154, 131, 82, 0.3) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.regi-swal-confirm-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 12px 25px rgba(154, 131, 82, 0.4) !important;
}

.regi-swal-cancel-btn {
    border-radius: 12px !important;
    padding: 12px 24px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border: 1px solid var(--border-color) !important;
    transition: all 0.2s ease !important;
}

.regi-swal-cancel-btn:hover {
    background: var(--bg-body) !important;
    transform: translateY(-1px) !important;
}

.regi-swal-close-btn {
    border-radius: 50% !important;
    transition: all 0.2s ease !important;
    color: var(--text-tertiary) !important;
}

.regi-swal-close-btn:hover {
    color: var(--text-primary) !important;
    background: var(--bg-badge) !important;
}

/* Floating Luxury Toast */
.regi-swal-toast {
    border-radius: 16px !important;
    border: 1.5px solid var(--border-color) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15) !important;
    padding: 14px 18px !important;
    font-family: 'Tajawal', sans-serif !important;
}

[data-theme="dark"] .regi-swal-toast {
    background: #1b1c21 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.45) !important;
}

.regi-swal-toast.regi-swal-success {
    border-color: rgba(31, 138, 91, 0.4) !important;
}

.regi-swal-toast.regi-swal-error {
    border-color: rgba(194, 65, 45, 0.5) !important;
    box-shadow: 0 15px 45px rgba(194, 65, 45, 0.25) !important;
}

.regi-swal-toast-title {
    font-size: 15px !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
    letter-spacing: -0.01em !important;
    margin-bottom: 2px !important;
}

.regi-swal-toast-text {
    font-size: 13.5px !important;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
    line-height: 1.5 !important;
}

.regi-swal-toast .swal2-actions {
    margin: 10px 0 0 0 !important;
    padding: 0 !important;
    width: 100% !important;
    display: flex !important;
    justify-content: flex-end !important;
}

.regi-swal-toast-confirm-btn {
    padding: 6px 16px !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    border: none !important;
    background: #c2412d !important;
    color: #ffffff !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(194, 65, 45, 0.35) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.regi-swal-toast-confirm-btn:hover {
    background: #a8321f !important;
    transform: translateY(-1.5px) !important;
    box-shadow: 0 6px 16px rgba(194, 65, 45, 0.5) !important;
}

.regi-swal-toast-confirm-btn:active {
    transform: translateY(0) !important;
}

.regi-swal-toast.regi-swal-warning {
    border-color: rgba(199, 134, 26, 0.4) !important;
}

.regi-swal-toast.regi-swal-info {
    border-color: rgba(154, 131, 82, 0.4) !important;
}

.regi-swal-toast .swal2-timer-progress-bar {
    background: var(--color-primary) !important;
}

/* ── Universal Interactive Button Feedback ── */
@keyframes regiSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes animate-scale-in {
    0% {
        transform: scale(0.92);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes animate-fade-out {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.95);
    }
}

.animate-scale-in {
    animation: animate-scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.animate-fade-out {
    animation: animate-fade-out 0.15s ease-in forwards !important;
}

.btn-loading {
    position: relative !important;
    pointer-events: none !important;
    opacity: 0.85 !important;
    cursor: wait !important;
    transition: all 0.2s ease !important;
}

.btn-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-inline-start: 8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: regiSpin 0.65s linear infinite;
    vertical-align: middle;
}

.form-input.is-invalid,
.form-textarea.is-invalid {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 3px rgba(194, 65, 45, 0.2) !important;
}

/* ── Dedicated Full-Page View Components (NO MODAL ARCHITECTURE) ── */
.full-page-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    animation: fadeIn 0.2s ease-in-out;
}

.full-page-header {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg) var(--space-xl);
    box-shadow: var(--shadow-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.full-page-title-group {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.full-page-title {
    font-size: var(--font-size-xl);
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.full-page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.full-page-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.back-to-list-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    padding: 10px 18px;
    border-radius: var(--border-radius-md);
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.back-to-list-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateX(4px);
}

[dir="ltr"] .back-to-list-btn:hover {
    transform: translateX(-4px);
}

/* ── Super Responsive Layout Adjustments ── */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: inline-flex;
    }

    .sidebar-close-btn {
        display: inline-flex;
    }

    .sidebar-brand {
        justify-content: space-between;
    }

    .sidebar {
        z-index: 90;
    }

    .topbar {
        padding: var(--space-md);
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
        gap: var(--space-xs);
    }

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

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        min-width: 100%;
    }
}



/* =========================================================
   Data Visualization — مخططات الإحصاءات
   ---------------------------------------------------------
   لوحة ألوان مُتحقَّق منها لعمى الألوان (adjacent ΔE ≥ 8 في
   الوضعين). ترتيب الفئات ثابت: اللون يتبع الفئة لا مرتبتها،
   فلا تتبدّل ألوان المخطط كلما تغيّر الفلتر.
   ========================================================= */

:root {
    /* سطح المخطط: تقريب معتم للبطاقة الزجاجية — تفصل به الفجوات بين الشرائح */
    --viz-surface: #f9f7f2;
    --viz-track: rgba(29, 31, 35, 0.06);
    --viz-grid: rgba(29, 31, 35, 0.10);

    --viz-series-1: #2a78d6;
    --viz-series-2: #eb6834;
    --viz-series-3: #1baf7a;
    --viz-series-4: #eda100;
    --viz-series-5: #e87ba4;
}

[data-theme="dark"] {
    /* خطوات مُختارة للسطح الداكن، لا انعكاس آلي لخطوات الوضع الفاتح */
    --viz-surface: #17181c;
    --viz-track: rgba(255, 255, 255, 0.07);
    --viz-grid: rgba(255, 255, 255, 0.12);

    --viz-series-1: #3987e5;
    --viz-series-2: #d95926;
    --viz-series-3: #199e70;
    --viz-series-4: #c98500;
    --viz-series-5: #d55181;
}

.viz {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.viz-row {
    display: grid;
    grid-template-columns: minmax(96px, 30%) 1fr auto;
    align-items: center;
    gap: var(--space-sm);
}

/* النص يلبس رموز النص لا لون السلسلة — الهوية يحملها الشاهد الملوّن بجانبه */
.viz-row-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.viz-row-value {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 3.5rem;
    text-align: start;
}

.viz-row-value small {
    color: var(--text-secondary);
    font-weight: 500;
}

/* المسار = المتبقي حتى أكبر قيمة؛ العمود ينمو من خط أساس واحد */
.viz-track {
    position: relative;
    height: 14px;
    border-radius: 4px;
    background: var(--viz-track);
    overflow: hidden;
}

.viz-bar {
    height: 100%;
    /* الطرف البياني مدوّر، وطرف خط الأساس مربّع */
    border-start-end-radius: 4px;
    border-end-end-radius: 4px;
    transition: width var(--transition-base);
}

/* المكدّس: الفجوة بلون السطح هي الفاصل، لا إطار مرسوم حول الشرائح */
.viz-stack {
    display: flex;
    height: 100%;
    gap: 2px;
    background: var(--viz-surface);
    border-start-end-radius: 4px;
    border-end-end-radius: 4px;
    overflow: hidden;
    transition: width var(--transition-base);
}

.viz-stack-segment {
    height: 100%;
    min-width: 0;
}

.viz-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.viz-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 600;
}

.viz-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.viz-empty {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    padding: var(--space-md) 0;
}

/* جدول البيانات: قناة الوصول البديلة حين يتعذّر تمييز الألوان أو عند الطباعة */
.viz-table-toggle {
    margin-top: var(--space-md);
    font-size: var(--font-size-xs);
}

.viz-table-toggle>summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    list-style: none;
}

.viz-table-toggle>summary::-webkit-details-marker {
    display: none;
}

.viz-table-toggle>summary::before {
    content: '▾ ';
    display: inline-block;
    transition: transform var(--transition-fast);
}

.viz-table-toggle[open]>summary::before {
    content: '▴ ';
}

.viz-table {
    width: 100%;
    margin-top: var(--space-sm);
    border-collapse: collapse;
    font-size: var(--font-size-xs);
    font-variant-numeric: tabular-nums;
}

.viz-table th,
.viz-table td {
    padding: 6px 8px;
    text-align: start;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.viz-table th {
    color: var(--text-secondary);
    font-weight: 600;
}

/* طبقة التمرير: تلميح لكل علامة، بلا اعتماد على جافاسكربت */
.viz-tip {
    position: relative;
}

.viz-tip::after {
    content: attr(data-tip);
    position: absolute;
    inset-inline-start: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(50%);
    white-space: nowrap;
    background: var(--text-primary);
    color: var(--bg-body);
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    font-size: 11px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 20;
}

[dir="ltr"] .viz-tip::after {
    transform: translateX(-50%);
}

.viz-tip:hover::after,
.viz-tip:focus-visible::after {
    opacity: 1;
}

@media print {
    .viz-table-toggle>summary {
        display: none;
    }

    .viz-table-toggle>.viz-table {
        display: table;
    }
}
/* =========================================================
   Alpine cloak — keeps x-show elements hidden until Alpine boots
   ========================================================= */
[x-cloak] {
    display: none !important;
}

/* =========================================================
   Searchable Select (x-searchable-select)
   Hoisted out of the Blade component: the page renders up to a
   dozen instances and the rules were being duplicated in every one.
   ========================================================= */
.searchable-select-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    cursor: pointer !important;
    text-align: start !important;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-family: 'Tajawal', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-sizing: border-box !important;
}

.searchable-select-btn:focus,
.searchable-select-btn.is-active {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px var(--color-primary-glow) !important;
}

.searchable-select-btn.is-disabled {
    opacity: 0.65 !important;
    cursor: not-allowed !important;
    background: var(--bg-primary) !important;
}

.searchable-select-chevron,
.searchable-select-clear {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    min-height: 14px !important;
    max-width: 14px !important;
    max-height: 14px !important;
    flex-shrink: 0 !important;
}

.searchable-select-chevron {
    color: var(--text-secondary);
    transition: transform 0.2s ease !important;
    display: inline-block !important;
}

.searchable-select-chevron.is-open {
    transform: rotate(180deg) !important;
}

.searchable-select-clear {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
}

/* A dropdown's options menu is an absolutely positioned child of its trigger,
   so any ancestor that clips its overflow cuts the list off mid-option, and
   `.card` clips by default. Every dropdown wrapper carries `.dropdown-host`
   (searchable-select, searchable-employee-select, and the hand-rolled
   employee filters) so one rule covers them all; a new dropdown only has to
   add the class. Cards that really need the clip (the table card, for its
   rounded corners) still set `overflow: hidden` inline and keep winning. */
.card:has(.dropdown-host) {
    overflow: visible;
    /* `.card` is `position: relative`, so without this bump the following card
       paints over the open list. Stays under the topbar (40), the sidebar
       (50) and the modal overlay (100). */
    z-index: 30;
}

/* Two dropdown cards in a row tie at 30 and the later one wins. The card in
   use goes on top: focus covers typing, hover covers pointing at the list
   (a DOM descendant), which still holds after the input blurs on mousedown. */
.card:has(.dropdown-host):is(:focus-within, :hover) {
    z-index: 31;
}

/* =========================================================
   Tajawal — self-hosted (was fonts.googleapis.com).
   Removes two external round trips from first paint and lets the
   desktop/NativePHP build render correctly with no internet access.
   ========================================================= */
@font-face {
    font-family: 'Tajawal';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/tajawal-arabic-400.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
    font-family: 'Tajawal';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/tajawal-latin-400.woff2') format('woff2');
    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: 'Tajawal';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/tajawal-arabic-500.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
    font-family: 'Tajawal';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/tajawal-latin-500.woff2') format('woff2');
    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: 'Tajawal';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/tajawal-arabic-700.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
    font-family: 'Tajawal';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/tajawal-latin-700.woff2') format('woff2');
    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: 'Tajawal';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('../fonts/tajawal-arabic-800.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
    font-family: 'Tajawal';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('../fonts/tajawal-latin-800.woff2') format('woff2');
    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: 'Tajawal';
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: url('../fonts/tajawal-arabic-900.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
    font-family: 'Tajawal';
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: url('../fonts/tajawal-latin-900.woff2') format('woff2');
    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;
}

/* =========================================================
   AG Charts — RTL tooltips and chart wrappers.
   Hoisted out of the reports component: the rules travelled with
   every Livewire response before.
   ========================================================= */
.ag-chart-wrapper-box,
[id^="ag-chart-"] {
    direction: ltr !important;
    position: relative;
}

.ag-charts-tooltip,
.ag-chart-tooltip {
    direction: rtl !important;
    text-align: right !important;
    font-family: 'Tajawal', sans-serif !important;
    background: var(--bg-card, #ffffff) !important;
    color: var(--text-primary, #1d1f23) !important;
    border: 1px solid var(--border-color, #e6e0d3) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
    pointer-events: none !important;
    z-index: 999999 !important;
    line-height: 1.5 !important;
}

[data-theme="dark"] .ag-charts-tooltip,
[data-theme="dark"] .ag-chart-tooltip {
    background: #1b1c21 !important;
    color: #efece5 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

.ag-charts-tooltip-title,
.ag-chart-tooltip-title {
    direction: rtl !important;
    text-align: right !important;
    font-family: 'Tajawal', sans-serif !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    color: inherit !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    padding-bottom: 4px !important;
    margin-bottom: 4px !important;
}

[data-theme="dark"] .ag-charts-tooltip-title,
[data-theme="dark"] .ag-chart-tooltip-title {
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

.ag-charts-tooltip-content,
.ag-chart-tooltip-content {
    direction: rtl !important;
    text-align: right !important;
    font-family: 'Tajawal', sans-serif !important;
    font-size: 11.5px !important;
    color: inherit !important;
}

/* =========================================================
   Chart legends on the right (RTL reading order)
   The legend is first in the DOM, so in an RTL document the first
   grid column lands on the right-hand side of the bars.
   ========================================================= */
.viz-layout {
    display: grid;
    grid-template-columns: minmax(150px, 210px) minmax(0, 1fr);
    gap: var(--space-md);
    align-items: start;
}

.viz-layout-bare {
    grid-template-columns: minmax(0, 1fr);
}

.viz-legend-side {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 0;
    padding: 10px 12px;
    background: var(--bg-secondary, rgba(0, 0, 0, 0.02));
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    max-height: 340px;
    overflow-y: auto;
}

.viz-legend-side .viz-legend-item {
    align-items: flex-start;
    gap: 7px;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.45;
}

.viz-legend-side .viz-legend-swatch {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    margin-top: 4px;
}

.viz-legend-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.viz-legend-value {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    margin-inline-start: auto;
    white-space: nowrap;
}

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

    .viz-legend-side {
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
    }

    .viz-legend-value {
        margin-inline-start: 4px;
    }
}

@media print {
    .viz-layout {
        grid-template-columns: minmax(140px, 190px) minmax(0, 1fr);
    }
}

/* =========================================================
   Application footer — developer credit
   ========================================================= */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 12px var(--space-xl);
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
}

.app-footer-compact {
    justify-content: center;
    border-top: none;
    background: transparent;
    padding: 16px 0 0;
}

.app-footer-credit {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* The logo is dark artwork; an opaque light plate keeps it legible in the dark theme too. */
.app-footer-logo-plate {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--border-radius-md);
    background: #ffffff;
    border: 1px solid var(--border-color);
}

.app-footer-logo {
    display: block;
    width: auto;
    height: 30px;
}

.app-footer-meta {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
}

.app-footer-copyright {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    color: var(--text-primary);
}

.app-footer-link {
    color: var(--color-primary);
    font-weight: 800;
    text-decoration: none;
    transition: color var(--transition-fast, 0.15s), text-decoration-color 0.15s;
}

.app-footer-link:hover,
.app-footer-link:focus-visible {
    color: var(--color-primary-dark, var(--color-primary));
    text-decoration: underline;
}

.app-footer-sep {
    opacity: 0.45;
}

.app-footer-auth {
    justify-content: center;
}

@media (max-width: 680px) {
    .app-footer {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        padding: 12px var(--space-md);
    }

    .app-footer-meta {
        justify-content: center;
    }

    .app-footer-logo {
        height: 26px;
    }
}

@media print {
    .app-footer {
        border-top: 1px solid #e6e0d3;
        background: transparent;
        color: #57534b;
    }
}

/* =========================================================
   Role titles
   ========================================================= */
.role-title {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
}

.role-title-slug {
    font-family: var(--font-mono, monospace);
    font-size: 10.5px;
    font-weight: 600;
    opacity: 0.6;
    direction: ltr;
}

/* =========================================================
   Employees screen — stopwatch banner, official card sheet and its
   print rules. Hoisted out of the Livewire component: ~14KB of CSS
   used to travel with every response from that screen.
   ========================================================= */
.execution-stopwatch-banner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--border-radius-full, 9999px);
    font-size: var(--font-size-xs, 12px);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    animation: slideInDown 0.2s ease-out;
}

.execution-stopwatch-banner.loading-state {
    background: rgba(154, 131, 82, 0.12);
    border: 1px solid rgba(154, 131, 82, 0.3);
    color: var(--color-primary, #7a6535);
}

.execution-stopwatch-banner.success-state {
    background: rgba(31, 138, 91, 0.12);
    border: 1px solid rgba(31, 138, 91, 0.3);
    color: #14543a;
}

.stopwatch-badge {
    background: var(--bg-card, #ffffff);
    padding: 2px 8px;
    border-radius: var(--border-radius-full, 9999px);
    font-family: var(--font-mono, monospace);
    font-weight: 800;
    font-size: 11px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
}

.pulse-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.official-card-sheet {
    background: #ffffff !important;
    color: #111827 !important;
    border: 2px solid #1f2937;
    border-radius: 6px;
    padding: 36px 44px;
    margin: 0 auto 30px auto;
    max-width: 1040px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    position: relative;
    font-family: 'Amiri', 'Traditional Arabic', 'Simplified Arabic', Tahoma, sans-serif;
    font-size: 11pt;
    line-height: 1.6;
    direction: rtl;
}

.official-card-sheet .sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #1f2937;
    padding-bottom: 14px;
    margin-bottom: 16px;
    gap: 16px;
}

.official-card-sheet .sheet-header-titles {
    flex: 1;
    text-align: right;
}

.official-card-sheet .sheet-header-titles h1 {
    font-size: 13.5pt;
    font-weight: 800;
    margin: 0;
    color: #111827 !important;
    line-height: 1.4;
}

.official-card-sheet .sheet-header-titles h2 {
    font-size: 11pt;
    font-weight: 600;
    margin: 4px 0 0 0;
    color: #374151 !important;
    line-height: 1.4;
}

.official-card-sheet .sheet-header-emblem {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    padding: 0 16px;
}

.official-card-sheet .sheet-official-logo {
    height: 75px;
    max-width: 140px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
}

.official-card-sheet .sheet-header-meta {
    flex: 1;
    text-align: left;
    font-size: 10pt;
    color: #374151 !important;
    line-height: 1.7;
}

.official-card-sheet .sheet-header-meta strong {
    color: #111827 !important;
}

.official-card-sheet .sheet-doc-title-wrapper {
    text-align: center;
    margin: 12px 0 18px 0;
}

.official-card-sheet .sheet-doc-title {
    display: inline-block;
    font-size: 15pt;
    font-weight: 900;
    color: #111827 !important;
    padding: 4px 32px;
    border-bottom: 2px solid #1f2937;
    border-top: 1px solid #d1d5db;
    letter-spacing: 1px;
    background: #f9fafb;
    border-radius: 4px;
}

.official-card-sheet .sheet-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px 14px;
    background: #faf8f3;
    border: 1px solid #e6e0d3;
    border-radius: 6px;
}

.official-card-sheet .sheet-name-field {
    font-size: 12pt;
    color: #1f2937 !important;
}

.official-card-sheet .sheet-name-field strong {
    font-size: 14.5pt;
    font-weight: 800;
    color: #1e3a8a !important;
}

.official-card-sheet .sheet-parent-names {
    font-size: 10pt;
    color: #4b5563 !important;
    margin-inline-start: 6px;
}

.official-card-sheet .sheet-status-group {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

.official-card-sheet .sheet-badge-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10pt;
}

.official-card-sheet .badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 9.5pt;
    font-weight: 700;
    line-height: 1.4;
}

.official-card-sheet .badge-primary {
    background: rgba(122, 101, 53, 0.1);
    color: #5e4e29 !important;
    border: 1px solid rgba(122, 101, 53, 0.25);
}

.official-card-sheet .badge-success {
    background: rgba(31, 138, 91, 0.1);
    color: #14543a !important;
    border: 1px solid rgba(31, 138, 91, 0.25);
}

.official-card-sheet .badge-danger {
    background: rgba(194, 65, 45, 0.1);
    color: #8f2a1a !important;
    border: 1px solid rgba(194, 65, 45, 0.25);
}

.official-card-sheet .badge-warning {
    background: rgba(199, 134, 26, 0.1);
    color: #7a4d0c !important;
    border: 1px solid rgba(199, 134, 26, 0.25);
}

.official-card-sheet .badge-secondary {
    background: rgba(107, 114, 128, 0.1);
    color: #374151 !important;
    border: 1px solid rgba(107, 114, 128, 0.25);
}

.official-card-sheet .sheet-card-block {
    border: 1.5px solid #1f2937;
    background: #ffffff;
    padding: 10px 16px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.official-card-sheet .sheet-card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    align-items: baseline;
}

.official-card-sheet .sheet-card-subrow {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    align-items: baseline;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #d8d3c7;
}

.official-card-sheet .sheet-card-field {
    flex: 1 1 auto;
    font-size: 10.5pt;
    color: #111827 !important;
}

.official-card-sheet .sheet-field-label {
    font-weight: 700;
    color: #374151 !important;
    margin-inline-end: 4px;
}

.official-card-sheet .sheet-card-line {
    border: 1px solid #d8d3c7;
    background: #faf8f3;
    padding: 8px 14px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 10.5pt;
    color: #111827 !important;
}

.official-card-sheet .sheet-org-crumbs {
    font-size: 9.5pt;
    color: #4b5563 !important;
    margin-top: 4px;
    padding-inline-start: 12px;
    line-height: 1.6;
}

.official-card-sheet .sheet-meta-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    background: #faf8f3;
    border: 1px dashed #a4a29b;
    padding: 10px 14px;
    margin-bottom: 14px;
    border-radius: 4px;
    font-size: 9.5pt;
    color: #111827 !important;
}

.official-card-sheet .sheet-section-title {
    font-size: 11.5pt;
    font-weight: 800;
    text-align: center;
    margin: 22px 0 10px 0;
    padding-bottom: 4px;
    border-bottom: 1.5px solid #1f2937;
    color: #111827 !important;
}

.official-card-sheet table.sheet-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
    background: #ffffff;
}

.official-card-sheet table.sheet-table th,
.official-card-sheet table.sheet-table td {
    border: 1px solid #4b5563;
    padding: 6px 10px;
    text-align: right;
    font-size: 9.5pt;
    color: #111827 !important;
}

.official-card-sheet table.sheet-table th {
    background-color: #f3f4f6 !important;
    font-weight: 700;
    color: #111827 !important;
}

.official-card-sheet table.sheet-table tbody tr:hover {
    background-color: rgba(154, 131, 82, 0.04);
}

.official-card-sheet .sheet-clean-notice {
    text-align: center;
    font-weight: 700;
    font-size: 10.5pt;
    margin: 12px 0 14px 0;
    padding: 10px 16px;
    border-radius: 4px;
    background: rgba(31, 138, 91, 0.08);
    color: #14543a !important;
    border: 1px solid rgba(31, 138, 91, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.official-card-sheet .sheet-signatures-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 36px;
    text-align: center;
    page-break-inside: avoid;
}

.official-card-sheet .sheet-signature-box {
    font-weight: 700;
    font-size: 10.5pt;
    color: #111827 !important;
}

.official-card-sheet .sheet-signature-line {
    margin-top: 45px;
    border-top: 1px dashed #5f5c55;
    font-weight: normal;
    font-size: 9pt;
    padding-top: 4px;
    color: #4b5563 !important;
}

.official-card-sheet .sheet-footer {
    margin-top: 30px;
    font-size: 8.5pt;
    color: #4b5563 !important;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #d1d5db;
    padding-top: 8px;
    page-break-inside: avoid;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm 14mm 12mm 14mm;
    }

    body,
    html {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .no-print,
    header,
    nav,
    aside,
    .app-sidebar,
    .app-header,
    .navbar,
    .execution-stopwatch-banner,
    .back-to-list-btn,
    .full-page-header,
    .full-page-actions {
        display: none !important;
    }

    .full-page-container {
        position: static !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #ffffff !important;
        overflow: visible !important;
    }

    #official-decision-sheet {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 10px 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: #ffffff !important;
        color: #000000 !important;
        page-break-inside: avoid;
    }

    #official-decision-sheet table {
        border-collapse: collapse !important;
        page-break-inside: avoid !important;
    }

    .official-card-sheet {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    .official-card-sheet .sheet-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        border-bottom: 2px solid #000000 !important;
        padding-bottom: 12px !important;
        margin-bottom: 14px !important;
        page-break-inside: avoid !important;
    }

    .official-card-sheet .sheet-header-titles {
        flex: 1 !important;
        text-align: right !important;
    }

    .official-card-sheet .sheet-header-emblem {
        flex: 0 0 auto !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
        padding: 0 14px !important;
    }

    .official-card-sheet .sheet-official-logo {
        height: 75px !important;
        max-width: 140px !important;
        object-fit: contain !important;
        display: block !important;
        margin: 0 auto !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .official-card-sheet .sheet-header-meta {
        flex: 1 !important;
        text-align: left !important;
    }

    .official-card-sheet .sheet-card-block,
    .official-card-sheet .sheet-card-line,
    .official-card-sheet .sheet-meta-strip {
        border-color: #000000 !important;
        background: #ffffff !important;
    }

    .official-card-sheet table.sheet-table th,
    .official-card-sheet table.sheet-table td {
        border-color: #000000 !important;
    }
}

/* =========================================================
   Dashboard — organizational level tabs.
   Hoisted out of the Livewire component so the rules are not
   re-sent with every response.
   ========================================================= */
.level-tabs-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.level-tabs-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 600;
}
.level-tabs-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary, rgba(0,0,0,0.04));
    padding: 4px;
    border-radius: var(--border-radius-full, 9999px);
    border: 1px solid var(--border-color);
}
.level-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: var(--border-radius-full, 9999px);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}
.level-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(154, 131, 82, 0.08);
}
.level-tab-btn.active {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px var(--color-primary-glow, rgba(154,131,82,0.4));
}

.hub-modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 14px;
}
.hub-module-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg, 12px);
    padding: 16px;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.hub-module-card:hover {
    transform: translateY(-3px);
    border-color: var(--color-primary);
    box-shadow: 0 8px 24px -4px rgba(154, 131, 82, 0.15), 0 4px 8px -4px rgba(0, 0, 0, 0.06);
    background: var(--bg-card-hover, var(--bg-card));
}
.hub-module-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid transparent;
    transition: transform 0.25s ease;
}
.hub-module-card:hover .hub-module-icon-box {
    transform: scale(1.08);
}
.hub-module-info {
    flex: 1;
    min-width: 0;
}
.hub-module-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hub-module-desc {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.hub-module-action {
    color: var(--text-muted);
    transition: transform 0.25s ease, color 0.25s ease;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.hub-module-card:hover .hub-module-action {
    color: var(--color-primary);
    transform: translateX(-4px);
}

/* =========================================================
   Gender pill — employees list
   ========================================================= */
.gender-pill {
    display: inline-flex;
    align-items: center;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.gender-pill-male {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.25);
}

.gender-pill-female {
    color: #ec4899;
    background: rgba(236, 72, 153, 0.1);
    border-color: rgba(236, 72, 153, 0.25);
}

/* =========================================================
   Writing direction (RTL / LTR)
   Everything here keys off <html dir>, which SetLocale derives from the
   interface language: Arabic renders right-to-left, English left-to-right.
   Prefer logical properties (inline-start / inline-end) so one rule serves
   both directions.
   ========================================================= */

/* Arrows and chevrons are drawn for the Arabic reading order (back = arrow-right,
   forward = chevron-left); x-icon marks them and they mirror in LTR. */
[dir="ltr"] .lucide-icon.icon-directional {
    transform: scaleX(-1);
}

/* Text fields, selects and filters start at the reading edge. */
.form-input,
.form-control,
.form-textarea,
.form-select,
.filter-input,
.filter-select,
select,
textarea,
input[type="text"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="date"] {
    text-align: start;
}

/* User agents centre <th>; table headings and cells follow the reading edge instead. */
.table th,
.table td,
.data-table th,
.data-table td {
    text-align: start;
}

/* Searchable select (x-searchable-select): the chosen value and every option show their
   full text, wrapping instead of being cut with an ellipsis. */
.searchable-select-value {
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: start;
    line-height: 1.45;
}

.searchable-select-option-label {
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: start;
    line-height: 1.5;
}

.searchable-select-menu {
    position: absolute;
    z-index: 1050;
    top: calc(100% + 4px);
    inset-inline: 0;
    display: flex;
    flex-direction: column;
    max-height: 320px;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    text-align: start;
}

/* Icons inside text fields: the search glyph sits at the reading start, the clear button at the end. */
.field-icon-start,
.field-icon-end {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.field-icon-start {
    inset-inline-start: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.field-icon-end {
    inset-inline-end: 8px;
}

/* Chart tooltips are right-to-left above; left-to-right pages flip them back. */
[dir="ltr"] .ag-charts-tooltip,
[dir="ltr"] .ag-chart-tooltip,
[dir="ltr"] .ag-charts-tooltip-title,
[dir="ltr"] .ag-chart-tooltip-title,
[dir="ltr"] .ag-charts-tooltip-content,
[dir="ltr"] .ag-chart-tooltip-content {
    direction: ltr !important;
    text-align: left !important;
}

[dir="ltr"] .hub-module-card:hover .hub-module-action {
    transform: translateX(4px);
}


/* =========================================================
   Mobile & theme layer
   ---------------------------------------------------------
   1. The sign-in palette (gold on cream, ink actions) carried into
      every screen.
   2. Classes the views use that the live stylesheet never defined
      (.table-responsive, .btn-outline, .text-danger, ...).
   3. Pagination, collapsible filters, table-to-card lists.
   4. Phone and tablet layout.
   ========================================================= */

:root {
    --bg-nav-hover: #f4f1ea;
    --bg-nav-active: #ffffff;
    --border-field: #d8d3c7;
    --focus-ring: #eee5d1;
    --gold-rule: #b9a57b;
}

[data-theme="dark"] {
    --bg-nav-hover: #1f2025;
    --bg-nav-active: #25262c;
    --border-field: #35363d;
    --focus-ring: #3a3426;
    --gold-rule: #8f7c52;
}

::selection {
    background: #eee5d1;
    color: #1d1f23;
}

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

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--color-primary);
}

/* ── Sidebar: the cream panel of the sign-in page ── */
.sidebar-brand {
    border-bottom-color: var(--border-color);
}

.nav-section-title {
    color: var(--gold-rule);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 700;
}

.nav-item:hover {
    background: var(--bg-nav-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-nav-active);
    color: var(--color-primary);
}

.sidebar-footer .badge {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

/* ── Fields: the sign-in form's fill, border and soft gold ring ── */
.form-input,
.form-control,
.form-textarea,
.form-select,
.filter-input,
.filter-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="date"],
textarea,
select {
    background-color: var(--bg-input);
    border-color: var(--border-field);
    box-shadow: none;
}

.form-input:focus,
.form-control:focus,
.form-textarea:focus,
.form-select:focus,
.filter-input:focus,
.filter-select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    background-color: var(--bg-input);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
    outline: none;
}

.searchable-select-btn {
    background: var(--bg-input);
    border-color: var(--border-field);
}

.searchable-select-btn:focus,
.searchable-select-btn.is-active {
    box-shadow: 0 0 0 4px var(--focus-ring) !important;
}

/* ── Buttons the views use but the stylesheet never defined ── */
.btn-outline {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-field);
}

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
}

.btn-xs {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 6px;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.text-danger {
    color: var(--color-danger) !important;
}

.form-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}

.mb-xl {
    margin-bottom: var(--space-xl);
}

.badge-secondary {
    background: #f1eee7;
    color: #57534b;
    border-color: #e0dacd;
}

[data-theme="dark"] .badge-secondary {
    background: #25262c;
    color: #c9c6be;
    border-color: #35363d;
}

/* Big containers (filter panels, tables) no longer jump or change colour under the pointer. */
.card:hover {
    transform: none;
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
}

/* ── Tables ── */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.table th {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
    background: var(--bg-secondary);
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table thead,
[data-theme="dark"] .data-table thead {
    background: var(--bg-secondary);
}

/* Wide tables scroll sideways inside their card instead of being clipped by it. */
.table-responsive,
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* ── Pagination (resources/views/vendor/livewire/tailwind.blade.php) ── */
.regi-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.regi-pagination-info {
    margin: 0;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.regi-pagination-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.regi-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-field);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

button.regi-page:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--bg-hover);
}

.regi-page.is-current {
    background: var(--color-action);
    border-color: var(--color-action);
    color: var(--color-action-text);
    cursor: default;
}

.regi-page.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.regi-page-dots {
    border-color: transparent;
    background: transparent;
    min-width: 24px;
    padding: 0;
    cursor: default;
}

/* ── Applied scope at the foot of the sidebar (replaces the locked level boxes in filters) ── */
.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-scope {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-inline-start: 3px solid var(--gold-rule);
    border-radius: var(--border-radius-md);
}

.sidebar-scope-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--gold-rule);
}

.sidebar-scope-row {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
}

.sidebar-scope-level {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-tertiary);
}

.sidebar-scope-name {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

/* Filter panels name the applied scope in one quiet line instead of locked boxes. */
.scope-chain {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Every level fixed by the scope: the level row has nothing left to offer. */
.org-levels-grid:not(:has(> div)) {
    display: none !important;
}

/* ── Filter panels: folded by default, applied filters shown as removable chips ── */
.filters-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.filters-panel.is-open .filters-bar {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.filters-panel:not(.is-open)> :not(.filters-bar) {
    display: none !important;
}

.filters-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 8px 12px;
    border: 1px solid var(--border-field);
    border-radius: var(--border-radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.filters-toggle:hover,
.filters-panel.is-open .filters-toggle {
    border-color: var(--color-primary);
    background: var(--bg-hover);
}

.filters-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.filters-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--border-radius-full);
    background: var(--color-action);
    color: var(--color-action-text);
    font-size: 11px;
    font-weight: 800;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding-block: 3px;
    padding-inline: 10px 4px;
    background: var(--bg-badge);
    border: 1px solid var(--border-field);
    border-radius: var(--border-radius-full);
    font-size: 12px;
    line-height: 1.4;
}

.filter-chip-label {
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.filter-chip-value {
    color: var(--text-primary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-chip-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.filter-chip-clear:hover {
    background: var(--bg-card);
    color: var(--color-danger);
}

.filter-chips-reset {
    padding: 3px 6px;
    border: 0;
    background: transparent;
    color: var(--color-danger);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.filter-chips-empty {
    font-size: 12px;
    color: var(--text-tertiary);
}

.filters-toggle-chevron {
    transition: transform var(--transition-fast);
}

.filters-panel.is-open .filters-toggle-chevron {
    transform: rotate(180deg);
}

/* ── Touch screens: no hover lifts that stick after a tap, and no hover-only controls ── */
@media (hover: none) {

    .card:hover,
    .stat-card:hover,
    .kpi-tile:hover,
    .note-card:hover,
    .feature-card:hover,
    .hub-module-card:hover,
    .btn:hover,
    .btn:active,
    .topbar-btn:hover,
    .topbar-bell-btn:hover,
    .theme-toggle:hover,
    .back-to-list-btn:hover,
    .hub-module-card:hover .hub-module-icon-box,
    .hub-module-card:hover .hub-module-action {
        transform: none !important;
    }

    .note-card-actions {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Tablets ── */
@media (max-width: 1024px) {
    :root {
        --space-xl: 24px;
    }
}

/* ── Phones and small tablets ── */
@media (max-width: 768px) {

    /* The views size themselves with these tokens (mostly inline), so shrinking the
       tokens tightens every screen at once. */
    :root {
        --space-2xl: 32px;
        --space-xl: 20px;
        --space-lg: 16px;
        --font-size-3xl: 1.6rem;
        --font-size-2xl: 1.25rem;
        --font-size-xl: 1.125rem;
        --font-size-lg: 1.05rem;
    }

    /* Drawer */
    .sidebar {
        width: min(86vw, 300px);
        box-shadow: var(--shadow-xl);
        visibility: hidden;
        transition: transform var(--transition-base), visibility 0s linear 250ms;
    }

    .sidebar.open {
        visibility: visible;
        transition: transform var(--transition-base), visibility 0s;
    }

    .sidebar-backdrop {
        background: rgba(29, 31, 35, 0.55);
    }

    .nav-item {
        padding: 11px 14px;
        font-size: 15px;
    }

    /* Topbar: one compact row */
    .topbar {
        height: auto;
        min-height: 56px;
        padding: 8px 12px;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .topbar>div:first-child {
        min-width: 0;
        flex: 1;
        gap: 8px !important;
    }

    .topbar-title {
        min-width: 0;
    }

    .topbar-title h2 {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-title span {
        display: none;
    }

    .topbar-actions {
        width: auto;
        flex-shrink: 0;
        gap: 6px;
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    .topbar-btn,
    .topbar-bell-btn,
    .theme-toggle {
        width: 38px;
        height: 38px;
    }

    .user-topbar-card {
        padding: 3px;
        gap: 0;
    }

    .user-topbar-card> :not(.user-avatar-circle) {
        display: none;
    }

    .user-avatar-circle {
        width: 32px;
        height: 32px;
    }

    .lang-btn {
        padding: 5px 8px;
    }

    .lang-btn span {
        display: none;
    }

    /* Menus open as full-width sheets under the topbar instead of running off-screen. */
    .user-switch-dropdown .dropdown-menu,
    .notification-bell-wrapper .dropdown-menu {
        position: fixed !important;
        top: 60px !important;
        inset-inline: 8px !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: calc(100dvh - 76px);
        overflow-y: auto !important;
    }

    /* Page */
    .page-content {
        padding: 12px;
        overscroll-behavior-y: contain;
    }

    .official-banner {
        padding: 12px;
        gap: 12px;
    }

    .official-banner-emblem {
        width: 44px;
        height: 44px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch !important;
    }

    .page-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px !important;
    }

    .page-actions .btn {
        width: 100%;
        white-space: normal;
        line-height: 1.3;
        padding: 10px 12px;
    }

    .page-actions>.btn:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .full-page-header {
        padding: 14px;
    }

    .card {
        padding: 14px;
    }

    .filter-bar {
        padding: 12px;
    }

    /* Filter bar: the toggle spans the width, chips wrap under it */
    .filters-toggle {
        width: 100%;
        justify-content: space-between;
        padding: 10px 12px;
        font-size: 14px;
    }

    .filter-chips {
        flex-basis: 100%;
    }

    .filter-chip-value {
        max-width: 150px;
    }

    /* Stat cards: two per row (the dashboard tiles size themselves by container) */
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .kpi-tile {
        min-height: 0;
        padding: 18px 16px 16px;
    }

    .stat-card {
        padding: 14px;
    }

    /* Charts */
    .ag-chart-wrapper-box {
        height: 300px !important;
    }

    .chart-card-box {
        padding: 12px;
    }

    .chart-box-title {
        font-size: 13px;
    }

    /* Lists become cards: each row stacks its cells with their column name. */
    .table-cards thead {
        display: none;
    }

    .table-cards,
    .table-cards tbody,
    .table-cards tr,
    .table-cards td {
        display: block;
        width: 100%;
    }

    .table-cards tr {
        padding: 12px 14px;
        border-bottom: 1px solid var(--border-color);
    }

    .table-cards tbody tr:hover {
        background: transparent;
    }

    .table-cards td {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 5px 0 !important;
        border: 0 !important;
        text-align: start !important;
    }

    .table-cards td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 32%;
        max-width: 130px;
        font-size: 11.5px;
        font-weight: 700;
        line-height: 1.5;
        color: var(--text-tertiary);
    }

    .table-cards td>* {
        min-width: 0;
        flex: 1;
    }

    .table-cards td.cell-actions {
        justify-content: flex-end;
        padding-top: 8px !important;
        margin-top: 4px;
        border-top: 1px dashed var(--border-color) !important;
    }

    .table-cards td.cell-actions>* {
        flex: 0 0 auto;
    }

    .table-cards td.cell-empty {
        display: block;
    }

    /* Pagination: previous, the current page, next */
    .regi-pagination {
        justify-content: center;
        text-align: center;
    }

    .regi-pagination-info {
        width: 100%;
    }

    .regi-pagination-links {
        justify-content: center;
        width: 100%;
    }

    .regi-page {
        min-width: 40px;
        height: 40px;
    }

    .regi-pagination-links>button.regi-page:not(.regi-page-step),
    .regi-page-dots {
        display: none;
    }

    .regi-page-step {
        flex: 1;
        max-width: 140px;
    }

    /* Settings rows and diff panes stack */
    .settings-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    /* Official employee sheet (profile view) */
    .official-card-sheet {
        padding: 16px 14px;
        font-size: 10.5pt;
    }

    .official-card-sheet .sheet-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .official-card-sheet .sheet-header-titles,
    .official-card-sheet .sheet-header-meta {
        text-align: center;
    }

    .official-card-sheet .sheet-signatures-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .official-card-sheet .sheet-doc-title {
        padding: 4px 12px;
    }

    /* Dialogs */
    .regi-swal-popup {
        padding: 22px 16px !important;
        border-radius: 18px !important;
    }

    .regi-swal-title {
        font-size: 18px !important;
    }

    .swal2-container.swal2-bottom-start,
    .swal2-container.swal2-bottom-end {
        padding: 8px !important;
    }

    .swal2-container .regi-swal-toast {
        width: 100% !important;
    }

    .app-footer {
        padding: 10px 12px;
        font-size: 11.5px;
    }
}

/* Touch phones: 16px text in fields stops iOS from zooming the page on focus. */
@media (max-width: 768px) and (pointer: coarse) {

    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ── Small phones ── */
@media (max-width: 400px) {
    .page-content {
        padding: 10px;
    }

    .page-actions {
        grid-template-columns: 1fr;
    }

    .table-cards td[data-label]::before {
        flex-basis: 36%;
    }
}

/* Global employee search: one large box over every field, full width above the table. */
.global-search-bar {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease;
}

.global-search-bar:focus-within {
    border-color: var(--color-primary);
}

.global-search-icon {
    position: absolute;
    inset-inline-start: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    pointer-events: none;
    line-height: 1;
}

.global-search-input {
    width: 100%;
    min-height: 52px;
    padding: 12px 50px;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: 600;
    outline: none;
}

.global-search-input::-webkit-search-cancel-button {
    display: none;
}

.global-search-clear {
    position: absolute;
    inset-inline-end: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Day-month-year date field with its calendar button. */
.date-input-wrap .date-input {
    font-variant-numeric: tabular-nums;
}

/* Position of a dashboard chart in the user's order (1., 2., 3. …). */
.chart-order-number {
    display: inline-block;
    min-width: 1.4em;
    margin-inline-end: 4px;
    color: var(--color-primary);
    font-weight: 800;
}
