:root {
    --font-ar: 'Segoe UI', 'Tahoma', 'Arial', sans-serif;
    --font-ar-display: 'Segoe UI', 'Tahoma', 'Arial', sans-serif;
    --font-en: 'Segoe UI', 'Trebuchet MS', 'Arial', sans-serif;
    --font-ui: var(--font-ar);
    --lh-ar: 1.72;
    --lh-en: 1.58;
    --fs-body: 0.97rem;
    --fs-small: 0.88rem;
    --fs-h1: clamp(1.5rem, 1.15rem + 1.1vw, 2.15rem);
    --fs-h2: clamp(1.24rem, 1.05rem + 0.58vw, 1.62rem);
    --fs-h3: clamp(1.05rem, 0.96rem + 0.36vw, 1.28rem);
    --bg: #f2f6fc;
    --surface: #ffffff;
    --surface-2: #e9f0fb;
    --ink: #0d1f34;
    --muted: #4a607d;
    --line: #c7d6ea;
    --brand: #0d63c8;
    --brand-strong: #083f8a;
    --brand-rgb: 13, 99, 200;
    --ok: #0f7a3d;
    --ok-bg: #e8f8ef;
    --danger: #be1e3c;
    --danger-bg: #ffe8ed;
    --warn: #8a5a00;
    --warn-bg: #fff3d9;
    --shadow-soft: 0 14px 34px rgba(10, 29, 53, 0.12);
    --shadow-strong: 0 30px 62px rgba(10, 24, 45, 0.22);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-ui);
    font-size: var(--fs-body);
    line-height: var(--lh-ar);
    direction: rtl;
    text-align: right;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background:
        radial-gradient(1200px 520px at 88% -12%, rgba(40, 124, 220, 0.18), transparent 56%),
        radial-gradient(840px 430px at 0% 0%, rgba(18, 172, 157, 0.13), transparent 58%),
        linear-gradient(180deg, #f7fbff 0%, #eef4fc 48%, #e8f0fb 100%);
    color: var(--ink);
}

p,
li,
td,
th,
input,
select,
textarea {
    font-size: 1rem;
    line-height: 1.78;
}

/* English/LTR fragments across the app use a dedicated latin stack for readability. */
:lang(en),
[dir="ltr"],
.en,
.latin {
    font-family: var(--font-en);
    line-height: var(--lh-en);
    letter-spacing: 0.01em;
}

[dir="rtl"] .en,
[dir="rtl"] .latin {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(700px 280px at 15% -10%, rgba(14, 106, 210, 0.13), transparent 60%),
        radial-gradient(640px 260px at 85% 0%, rgba(8, 158, 144, 0.10), transparent 58%);
    z-index: -1;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: var(--brand-strong);
}

/* ═══════════════════════════════════════════
   APP SHELL — sidebar layout
═══════════════════════════════════════════ */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
    gap: 12px;
    padding: 10px;
}

/* ── Sidebar ── */
.sidebar {
    width: 246px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #0b2442 0%, #0f3158 55%, #0a2340 100%);
    color: #c8d8e8;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 10px;
    height: calc(100vh - 20px);
    overflow-y: auto;
    z-index: 50;
    transition: transform 0.26s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 12px 28px rgba(8, 16, 28, 0.30);
}

.sidebar-head {
    padding: 16px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.09);
    display: flex;
    align-items: center;
    gap: 9px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-brand {
    font-family: var(--font-ar-display);
    font-weight: 800;
    font-size: 0.96rem;
    color: #f0f6ff;
    line-height: 1.3;
    letter-spacing: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    color: #b7c8d9;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: 12px;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
    border: 1px solid transparent;
    position: relative;
    text-align: right;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.09);
    color: #e8f2ff;
    transform: translateX(-2px);
}

.sidebar-link.is-active {
    background: linear-gradient(135deg, rgba(24, 125, 235, 0.36), rgba(16, 95, 196, 0.32));
    color: #e3f2ff;
    border-color: rgba(111, 185, 255, 0.45);
    font-weight: 800;
}

.sidebar-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
}

.sidebar-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-foot {
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(255,255,255,0.09);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 9px;
}

.sidebar-user-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }

.sidebar-user-name {
    font-size: 0.87rem;
    font-weight: 700;
    color: #d8e8f5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.74rem;
    color: #7a9ab8;
    text-transform: lowercase;
}

.sidebar-foot-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-theme-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    color: #c8d8e8;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.15s;
}

.sidebar-theme-btn:hover { background: rgba(255,255,255,0.14); }

.sidebar-logout {
    font-size: 0.82rem;
    font-weight: 700;
    color: #ff8a80;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,120,80,0.28);
    transition: background 0.15s;
}

.sidebar-logout:hover {
    background: rgba(255,100,60,0.14);
    color: #ffb3ab;
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 49;
}
.sidebar-overlay.is-open { display: block; }

/* ── Main wrap ── */
.main-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Topbar: desktop = thin strip; mobile = full bar */
.topbar {
    top: 0;
    z-index: 40;
    backdrop-filter: blur(10px);
    background: linear-gradient(180deg, rgba(251, 254, 255, 0.96), rgba(237, 245, 255, 0.94));
    border-bottom: 1px solid rgba(154, 181, 214, 0.82);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Hide topbar brand on desktop (sidebar has brand) */
@media (min-width: 901px) {
    .topbar {
        display: none;
    }
}

.brand {
    font-weight: 800;
    font-size: 1.2rem;
    font-family: var(--font-ar-display);
    color: #173b55;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.nav-toggle {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--ink);
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

/* Mobile: hide sidebar off-screen, toggle with .is-open */
@media (max-width: 900px) {
    .app-shell {
        padding: 0;
        gap: 0;
    }

    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        transform: translateX(100%);
        width: 240px;
        height: 100%;
        border-radius: 0;
        border: 0;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .topbar {
        display: flex;
        position: sticky;
        border-radius: 0;
    }

    .page-container {
        width: min(1180px, 96vw);
        margin: 14px auto 20px;
    }
}

.page-container {
    width: min(1180px, 96vw);
    margin: 18px auto 26px;
}

.page-container > * {
    animation: cardIn 240ms ease;
}



/* Dark theme sidebar */
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #111a26 0%, #152030 100%);
}

/* ═══════════════════════════════════════════
   TOP NAV MODE (restore old style)
═══════════════════════════════════════════ */
.app-shell,
.main-wrap {
    display: block;
    min-height: 0;
    padding: 0;
    gap: 0;
}

.sidebar,
.sidebar-overlay {
    display: none !important;
}

.topbar {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 40;
    flex-wrap: wrap;
}

.top-actions {
    margin-inline-start: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.nav-links a {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 8px 14px;
    color: var(--ink);
    font-weight: 800;
    font-size: 0.95rem;
    transition: all 0.18s ease;
    background: transparent;
}

.nav-links a:hover {
    background: var(--surface-2);
    border-color: var(--line);
}

.nav-links a.is-active {
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 22px rgba(var(--brand-rgb), 0.30);
}

@media (min-width: 901px) {
    .nav-toggle {
        display: none;
    }
}

@media (max-width: 900px) {
    .topbar {
        padding: 10px 12px;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        width: 100%;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding-top: 6px;
    }

    .nav-links.is-open {
        display: flex;
    }

    .nav-links a {
        border-radius: 12px;
        text-align: center;
    }
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 22px;
    backdrop-filter: blur(2px);
}

.login-wrap {
    width: min(460px, 96vw);
    margin: 8vh auto;
    animation: cardIn 420ms ease;
}

.page-index {
    background:
        radial-gradient(860px 360px at 85% -8%, rgba(33, 126, 164, 0.20), transparent 60%),
        radial-gradient(620px 280px at 8% 4%, rgba(16, 93, 128, 0.16), transparent 62%),
        linear-gradient(180deg, #edf4fb 0%, #e8f0f8 46%, #dee9f3 100%) !important;
}

.page-index .login-wrap {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(245, 251, 255, 0.87));
    border: 1px solid rgba(166, 191, 214, 0.72);
    box-shadow: 0 30px 64px rgba(9, 31, 49, 0.22);
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
}

.page-index .login-wrap::before {
    content: '';
    position: absolute;
    inset-inline-start: -84px;
    top: -90px;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 30%, rgba(47, 150, 193, 0.30), rgba(47, 150, 193, 0.09) 66%, transparent 72%);
    filter: blur(0.2px);
    animation: floatOrb 8s ease-in-out infinite;
}

.page-index .login-wrap::after {
    content: '';
    position: absolute;
    inset-inline-end: -92px;
    bottom: -94px;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle at 60% 58%, rgba(22, 110, 147, 0.23), rgba(22, 110, 147, 0.06) 66%, transparent 72%);
    animation: floatOrb 10s ease-in-out infinite reverse;
}

.page-index .login-wrap > * {
    position: relative;
    z-index: 2;
}

.page-index .login-wrap > * {
    animation: loginItemIn 480ms ease both;
}

.page-index .login-wrap > *:nth-child(2) { animation-delay: 60ms; }
.page-index .login-wrap > *:nth-child(3) { animation-delay: 110ms; }
.page-index .login-wrap > *:nth-child(4) { animation-delay: 150ms; }
.page-index .login-wrap > *:nth-child(5) { animation-delay: 190ms; }
.page-index .login-wrap > *:nth-child(6) { animation-delay: 220ms; }

.page-index .login-wrap h1 {
    font-size: 2.25rem;
    margin-bottom: 8px;
    line-height: 1.25;
    color: #0f2f4e;
}

.page-index .login-head {
    margin-bottom: 12px;
}

.page-index .login-kicker {
    margin: 0 0 6px;
    color: #1f5f84;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.page-index .login-sub {
    margin: 0;
    color: #486179;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.75;
}

.page-index .login-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.page-index .login-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #b9d3e3;
    background: linear-gradient(180deg, #f4fbff, #e8f2f8);
    color: #1f4f6c;
    font-size: 0.78rem;
    font-weight: 700;
}

.page-index .login-form {
    display: grid;
    gap: 10px;
}

.page-index .login-form input {
    background: linear-gradient(180deg, #ffffff, #f9fcff);
}

.page-index .login-wrap .help {
    font-size: 0.92rem;
    font-weight: 600;
}

h1,
h2,
h3 {
    font-family: var(--font-ar-display);
    line-height: 1.48;
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--ink);
}

h1 {
    font-size: var(--fs-h1);
    font-weight: 800;
}

h2 {
    font-size: var(--fs-h2);
    font-weight: 800;
}

h3 {
    font-size: var(--fs-h3);
    font-weight: 800;
}

label {
    display: block;
    margin-bottom: 7px;
    font-weight: 800;
    font-size: 0.95rem;
    color: #1b4f84;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea,
button,
.btn,
table,
th,
td,
label,
.help {
    font-family: var(--font-ui);
}

.help,
.muted,
.small {
    font-size: var(--fs-small);
}

/* Keep technical values readable regardless of page direction. */
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="search"],
code,
pre,
.mono {
    font-family: var(--font-en);
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 11px 13px;
    text-align: right;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.topbar {
    direction: rtl;
}

.top-actions {
    margin-inline-start: auto;
}

.page-title,
.settings-section-title,
.brand {
    letter-spacing: 0;
}

.page-title {
    font-family: var(--font-ar-display);
    font-size: clamp(1.45rem, 1.05rem + 1.2vw, 2.05rem);
    line-height: 1.5;
    margin-bottom: 14px;
}

.settings-section-title {
    font-family: var(--font-ar-display);
    line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.20);
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.95rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
}

.btn-primary,
button[type="submit"] {
    background: linear-gradient(135deg, var(--brand), #1a78df);
    color: #fff;
    box-shadow: 0 10px 24px rgba(var(--brand-rgb), 0.30);
}

.btn-primary:hover,
button[type="submit"]:hover {
    box-shadow: 0 14px 28px rgba(var(--brand-rgb), 0.38);
}

.btn-danger {
    background: #fff6f8;
    color: var(--danger);
    border-color: #f9bcc8;
}

.btn-secondary {
    background: #edf4ff;
    color: #154e86;
    border-color: #b9d0ee;
}

.btn-secondary:hover {
    background: #e1edff;
    border-color: #9fbeea;
}

.alert {
    border-radius: 12px;
    padding: 12px 13px;
    margin: 10px 0;
    font-weight: 700;
    line-height: 1.7;
}

.alert.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fecdd3;
}

.alert.success {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid #bbf7d0;
}

.help {
    color: var(--muted);
    margin: 8px 0;
    line-height: 1.75;
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid #e0e9f2;
    text-align: right;
    vertical-align: middle;
    line-height: 1.7;
}

thead th {
    background: linear-gradient(180deg, #dce9fb, #eff5ff);
    color: #1a4d83;
    font-weight: 800;
    font-size: 0.93rem;
}

tbody tr:hover {
    background: #ebf3ff;
}

.site-footer {
    border-top: 1px solid #c2d4eb;
    background: rgba(242, 248, 255, 0.93);
    backdrop-filter: blur(8px);
    margin-top: 20px;
}

.site-footer-inner {
    width: min(1180px, 96vw);
    margin: 0 auto;
    padding: 14px 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.site-rights {
    color: #2f4d6f;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 14px;
    border: 1px solid #c7d8ea;
    background: linear-gradient(180deg, #ffffff 0%, #f3f8ff 100%);
    box-shadow: 0 6px 14px rgba(18, 50, 86, 0.10);
}

.rights-stamp-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f63c8, #0a4b9d);
    color: #f4f9ff;
    font-size: 1rem;
    line-height: 1;
    box-shadow: 0 4px 10px rgba(12, 66, 138, 0.32);
}

.rights-stamp-content {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
}

.rights-stamp-title {
    font-size: 0.84rem;
    font-weight: 800;
    color: #3e5d7f;
}

.rights-stamp-owner {
    font-size: 0.96rem;
    font-weight: 900;
    color: #0f3a66;
}

.site-socials {
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-socials a {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid #bfd2ea;
    border-radius: 999px;
    background: #fff;
    font-weight: 700;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 900px) {
    .page-container {
        width: min(100%, 97vw);
        margin-top: 12px;
    }

    .card {
        padding: 14px;
        border-radius: 14px;
    }

    .topbar {
        padding: 10px 12px;
        position: sticky;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        display: none;
        width: 100%;
        background: rgba(255, 255, 255, 0.96);
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 8px;
        box-shadow: var(--shadow-soft);
    }

    .nav-links.is-open {
        display: flex;
    }

    .nav-links a {
        width: 100%;
        justify-content: center;
    }

    .nav-links a {
        padding: 7px 11px;
        font-size: 0.92rem;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        border-radius: 12px;
    }

    th,
    td {
        padding: 9px 8px;
        font-size: 0.92rem;
    }
}

@media (max-width: 560px) {
    .login-wrap {
        margin-top: 18px;
        width: min(95vw, 460px);
    }

    h1 {
        font-size: 1.3rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    .row {
        flex-direction: column;
        align-items: stretch;
    }

    button,
    .btn {
        width: 100%;
    }

    .site-footer-inner {
        justify-content: center;
        text-align: center;
    }

    .site-rights {
        width: 100%;
        justify-content: center;
    }

    .page-index .login-badges {
        gap: 6px;
    }

    .page-index .login-badge {
        font-size: 0.74rem;
        padding: 4px 8px;
    }
}

@media (max-width: 380px) {
    .card {
        padding: 12px;
    }

    .topbar {
        padding: 8px 10px;
    }

    .brand {
        font-size: 1rem;
    }
}

/* ===== Unified Page System ===== */

.grid {
    display: grid;
    gap: 12px;
}

.grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-wrap,
.table-scroll,
.archive-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.kpi {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
}

.kpi .label,
.kpi .k-label {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 4px;
}

.kpi .value,
.kpi .k-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ink);
}

.settings-card,
.reports-filter-card,
.reports-hero,
.archive-hero,
.trend-card,
.salary-summary-card,
.att-kpi,
.emp-card {
    border-radius: 16px;
}

.settings-section-title,
.ed-section-title {
    font-weight: 800;
    font-size: 1.06rem;
    margin-bottom: 6px;
    color: #174764;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #c7d9e8;
    background: #eef6fc;
    font-weight: 700;
    font-size: 0.84rem;
    color: #1b4f6f;
}

/* Salaries */
.salary-filters,
.reports-filters,
.archive-filters,
.att-filters {
    gap: 10px;
}

.salary-tools,
.reports-actions,
.archive-actions,
.bulk-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.salary-search,
.reports-search {
    min-width: 220px;
}

.salary-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.salary-summary-card {
    background: linear-gradient(160deg, #eaf2ff, #ffffff);
    border: 1px solid #c7d8ee;
    box-shadow: var(--shadow-soft);
    padding: 12px;
}

.salary-summary-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.salary-summary-value {
    font-size: 1.16rem;
    font-weight: 800;
    margin-top: 4px;
    color: #0f4f95;
}

.salary-pagination,
.reports-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.salary-page-link,
.salary-page-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid #c9dceb;
    background: #fff;
    font-weight: 700;
}

.salary-page-current {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

/* Reports */
.hero-meta,
.archive-meta,
.selected-month-info,
.reports-live-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.hero-pill,
.archive-pill,
.selected-month-pill,
.reports-live-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 11px;
    border: 1px solid #c3d6ef;
    background: #ebf3ff;
    color: #1c4f84;
    font-weight: 700;
    font-size: 0.85rem;
}

.reports-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.reports-kpi {
    background: var(--surface);
    border: 1px solid #cfe0ed;
    border-radius: 14px;
    padding: 12px;
}

.reports-kpi .label {
    color: var(--muted);
    font-size: 0.84rem;
}

.reports-kpi .value {
    font-weight: 800;
    font-size: 1.1rem;
    margin-top: 4px;
    color: #0f4f90;
}

.reports-kpi.is-positive {
    border-color: #9be5c0;
    background: #ecfaf2;
}

.reports-kpi.is-negative {
    border-color: #f7b8c2;
    background: #fff2f4;
}

.trend-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 6px;
    align-items: end;
    min-height: 170px;
}

.trend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.trend-bar-wrap {
    width: 100%;
    height: 110px;
    display: flex;
    align-items: flex-end;
}

.trend-bar {
    width: 100%;
    border-radius: 8px 8px 4px 4px;
    background: linear-gradient(180deg, #20b5ad, var(--brand));
}

.month-summary-row {
    cursor: pointer;
}

.month-summary-row:hover {
    background: #ecf5fc;
}

/* Archive */
.archive-state {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.82rem;
}

.archive-state.open {
    background: #e7f9ef;
    color: #14633d;
}

.archive-state.closed {
    background: #e7f1fe;
    color: #1e4b8f;
}

.archive-state.archived {
    background: #fff0d8;
    color: #8c4a17;
}

/* Attendance */
.att-page .att-hero,
.reports-hero,
.archive-hero {
    border: 0;
    color: #fff;
    box-shadow: 0 20px 48px rgba(13, 66, 91, 0.24);
    background: linear-gradient(128deg, #0a3470 0%, #0d63c8 56%, #11a9a0 100%);
}

.att-page .att-hero {
    background: linear-gradient(128deg, #0a3470 0%, #0d63c8 56%, #11a9a0 100%);
}

.day-nav {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 12px;
}

.day-nav a,
.day-nav span {
    min-width: 40px;
    text-align: center;
    border-radius: 10px;
    border: 1px solid #cbddec;
    background: #fff;
    padding: 6px 8px;
    font-weight: 700;
}

.day-nav .is-selected {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.att-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.att-kpi {
    border: 1px solid #cfdeea;
    background: #fff;
    padding: 12px;
}

.k-total { border-color: #cfdeea; }
.k-present { border-color: #9be5c0; background: #ecfaf2; }
.k-absent { border-color: #f7b8c2; background: #fff2f4; }
.k-leave { border-color: #f6d28f; background: #fff9ed; }

.emp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.emp-card {
    position: relative;
    border: 1px solid #cfdeea;
    background: #fff;
    padding: 12px;
    box-shadow: var(--shadow-soft);
}

.emp-card.is-present { border-color: #9be5c0; }
.emp-card.is-absent { border-color: #f7b8c2; }
.emp-card.is-leave { border-color: #f6d28f; }

.emp-name {
    font-weight: 800;
    margin-bottom: 2px;
    color: #13526e;
}

.emp-meta {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 8px;
}

.att-toggle {
    display: flex;
    gap: 6px;
}

.att-btn {
    flex: 1;
    border-radius: 10px;
    border: 1px solid #c8dbea;
    padding: 8px;
    font-weight: 700;
    background: #fff;
}

.att-btn.active {
    box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.20);
}

/* Global interaction layer */
.card,
.kpi,
.reports-kpi,
.salary-summary-card,
.emp-card,
.employees-page .kpi-card,
.employees-page .search-card,
.employees-page .table-wrap,
.db-stat,
.db-breakdown-card,
.archive-table-wrap,
.table-wrap {
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background-color 0.22s ease;
}

.card:hover,
.kpi:hover,
.reports-kpi:hover,
.salary-summary-card:hover,
.emp-card:hover,
.employees-page .kpi-card:hover,
.employees-page .search-card:hover,
.employees-page .table-wrap:hover,
.db-stat:hover,
.db-breakdown-card:hover,
.archive-table-wrap:hover,
.table-wrap:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(14, 36, 54, 0.14);
}

.btn,
button {
    position: relative;
    overflow: hidden;
}

.btn::after,
button::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.18) 50%, transparent 100%);
    transform: translateX(-120%);
    transition: transform 0.45s ease;
    pointer-events: none;
}

.btn:hover::after,
button:hover::after {
    transform: translateX(120%);
}

body.reveal-ready .reveal-on-scroll {
    opacity: 0;
    transform: translateY(16px);
}

body.reveal-ready .reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

@media (prefers-reduced-motion: reduce) {
    .card,
    .kpi,
    .reports-kpi,
    .salary-summary-card,
    .emp-card,
    .employees-page .kpi-card,
    .employees-page .search-card,
    .employees-page .table-wrap,
    .db-stat,
    .db-breakdown-card,
    .archive-table-wrap,
    .table-wrap,
    .btn,
    button,
    body.reveal-ready .reveal-on-scroll,
    body.reveal-ready .reveal-on-scroll.is-visible {
        transition: none !important;
        transform: none !important;
        animation: none !important;
    }
}

/* Employee Details */
.employee-details-page .ed-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.ed-title {
    margin: 0;
    font-size: 1.4rem;
}

.ed-sub {
    margin-top: 4px;
    color: var(--muted);
}

.ed-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.ed-chip {
    border: 1px solid #d1e0ec;
    border-radius: 999px;
    padding: 5px 10px;
    background: #f2f8fc;
    font-weight: 700;
    font-size: 0.84rem;
}

.att-badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.82rem;
    font-weight: 700;
    border: 1px solid #d7e2f0;
}

.att-badge.present { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.att-badge.absent { background: #fff1f2; color: #9f1239; border-color: #fecdd3; }
.att-badge.leave { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* Responsive refinements */
@media (max-width: 900px) {
    .grid.cols-2 {
        grid-template-columns: 1fr;
    }

    .salary-tools,
    .reports-actions,
    .archive-actions,
    .bulk-btns,
    .reports-page-actions {
        width: 100%;
    }

    .salary-tools .btn,
    .reports-actions .btn,
    .archive-actions .btn,
    .bulk-btns .btn,
    .reports-page-actions .btn {
        flex: 1;
        min-width: 130px;
    }

    .trend-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .hero-meta,
    .archive-meta,
    .selected-month-info,
    .reports-live-stats,
    .ed-meta {
        gap: 6px;
    }

    .hero-pill,
    .archive-pill,
    .selected-month-pill,
    .reports-live-pill,
    .ed-chip {
        font-size: 0.8rem;
        padding: 5px 9px;
    }

    .salary-search,
    .reports-search {
        min-width: 100%;
    }

    .emp-grid {
        grid-template-columns: 1fr;
    }

    .day-nav a,
    .day-nav span {
        min-width: 36px;
        padding: 5px 6px;
        font-size: 0.86rem;
    }

    .trend-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Employees page (moved from employees.php for maintainability) */
.employees-page {
    display: grid;
    gap: 16px;
}

.employees-page .card {
    border-radius: 16px;
    border: 1px solid #d8e4ee;
    box-shadow: 0 10px 26px rgba(16, 33, 50, 0.08);
}

.employees-page .employees-hero {
    background:
        radial-gradient(420px 180px at 90% -10%, rgba(255, 255, 255, 0.2), transparent 68%),
        radial-gradient(360px 160px at 0% 0%, rgba(255, 255, 255, 0.16), transparent 62%),
        linear-gradient(132deg, #0a346d 0%, #0d63c8 52%, #13aaa2 100%);
    box-shadow: 0 16px 34px rgba(19, 58, 78, 0.28);
    position: relative;
    overflow: hidden;
}

.employees-page .employees-hero::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    left: -70px;
    bottom: -120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.09);
    pointer-events: none;
}

.employees-page .employees-hero h1,
.employees-page .employees-hero p {
    color: #f5fcff;
}

.employees-page .employees-hero-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.employees-page .kpi-card {
    min-height: 104px;
}

.employees-page .employees-kpis {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
    align-items: stretch;
}

.employees-page .search-card {
    grid-column: 1 / -1;
    padding: 16px;
    border: 1px solid #cfdeea;
    background: linear-gradient(180deg, #ffffff, #f2f8fd);
}

.employees-page .kpi-card {
    grid-column: span 4;
    display: grid;
    gap: 9px;
    align-content: center;
    padding: 16px 18px;
    border: 1px solid #d3e1ec;
    background: linear-gradient(180deg, #ffffff, #f5f9fd);
    position: relative;
    overflow: hidden;
}

.employees-page .kpi-card::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(180deg, #0d63c8, #16b2a8);
}

.employees-page .kpi-title {
    color: #355269;
    font-weight: 700;
}

.employees-page .kpi-number {
    font-size: 1.72rem;
    font-weight: 800;
    color: #17364e;
}

.employees-page table th,
.employees-page table td {
    padding: 10px 9px;
}

.employees-page table th {
    background: #eaf1f7;
    color: #2d4559;
    font-weight: 800;
}

.employees-page .btn {
    border-radius: 12px;
    padding: 8px 13px;
}

.employees-page .dept-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: #ecf9ff;
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: 999px;
    font-size: 0.88rem;
    padding: 8px 14px;
    font-weight: 700;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.employees-page .dept-chip:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.3);
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(13, 42, 61, 0.22);
}

.employees-page .dept-chip:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.employees-page .dept-chip.is-active {
    background: #fff;
    color: #1f5f79;
    border-color: #ffffff;
    box-shadow: 0 12px 24px rgba(9, 39, 57, 0.24);
}

.employees-page .dept-chip.is-active::before {
    content: '✓';
    font-size: 0.8rem;
    font-weight: 800;
}

.employees-page .filters-form {
    display: grid;
    grid-template-columns: minmax(220px, 1.35fr) minmax(180px, 1fr);
    gap: 11px;
    margin: 0;
    align-items: end;
}

.employees-page .filters-form > * {
    min-width: 0;
}

.employees-page .filters-form .field {
    display: grid;
    gap: 6px;
}

.employees-page .filters-form label {
    font-size: 0.84rem;
    color: #445f74;
    font-weight: 700;
}

.employees-page .filters-actions,
.employees-page .report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.employees-page .filters-actions {
    align-self: stretch;
    grid-column: 1 / -1;
}

.employees-page .filters-actions .btn {
    min-width: 130px;
}

.employees-page .report-actions {
    margin-top: 12px;
}

.employees-page .muted-summary {
    margin-top: 10px;
    color: #4f677a;
    font-weight: 600;
}

.employees-page .duplicate-summary {
    margin-top: 8px;
    color: #9f1239;
    font-weight: 800;
}

.employees-page .table-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.employees-page .table-wrap {
    border-radius: 14px;
    border: 1px solid #d0dee9;
    overflow: hidden;
    background: #fff;
}

.employees-page .table-card {
    padding: 12px;
}

.employees-page tbody tr:nth-child(even) {
    background: #fafcff;
}

.employees-page tbody tr:hover {
    background: #f3f9ff;
}

.employees-page tbody tr.employee-row-duplicate {
    background: linear-gradient(180deg, #fff1f5, #ffe4ec);
}

.employees-page tbody tr.employee-row-duplicate:hover {
    background: linear-gradient(180deg, #ffe6ef, #ffd9e7);
}

.employees-page .employee-link {
    color: #0f4f7b;
    font-weight: 800;
}

.employees-page .employee-link:hover {
    color: #0c628a;
    text-decoration: underline;
}

.employees-page .duplicate-badge {
    display: inline-flex;
    align-items: center;
    margin-inline-start: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #be123c;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 800;
    vertical-align: middle;
}

@media print {
    .employees-page .alert,
    .employees-page .js-auto-hide-alert {
        display: none !important;
    }
}

@media (max-width: 980px) {
    .employees-page .kpi-card {
        grid-column: span 6;
    }
}

@media (max-width: 720px) {
    .employees-page .employees-hero-head {
        flex-direction: column;
        align-items: stretch;
    }

    .employees-page .employees-kpis {
        grid-template-columns: 1fr;
    }

    .employees-page .search-card,
    .employees-page .kpi-card {
        grid-column: 1 / -1;
    }

    .employees-page .kpi-number {
        font-size: 1.45rem;
    }

    .employees-page .filters-form {
        grid-template-columns: 1fr;
    }

    .employees-page .filters-actions .btn {
        min-width: 0;
        flex: 1;
    }
}

.print-only {
    display: none;
}

.print-logo {
    max-height: 72px;
    max-width: 220px;
    object-fit: contain;
    margin: 0 auto 6px;
    display: block;
}

.print-sheet,
.report-print-shell {
    display: none;
}

.print-sheet {
    position: relative;
    overflow: hidden;
    border: 1px solid #b8c4d3;
    border-radius: 10px;
    background: #fff;
}

.print-sheet::before,
.print-sheet::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

.print-sheet::before {
    inset: 10px;
    border: 1px solid #dbe3ec;
    border-radius: 6px;
}

.print-sheet::after {
    display: none;
}

.print-sheet-watermark {
    display: none;
}

.print-sheet-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: start;
    padding: 20px 18px 14px;
    border-bottom: 1px solid #cfd8e3;
    background: linear-gradient(180deg, #f8fafc 0, #f8fafc 8px, #fff 8px, #fff 100%);
}

.print-sheet-logo {
    width: 92px;
    max-width: 92px;
    max-height: 92px;
    object-fit: contain;
    padding: 6px;
    border: 1px solid #d4dde7;
    border-radius: 8px;
    background: #fff;
}

.print-sheet-brand {
    min-width: 0;
}

.print-sheet-eyebrow {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    margin-bottom: 8px;
    font-size: 0.76rem;
    font-weight: 800;
    color: #304255;
    letter-spacing: 0;
    border: 1px solid #d7e0e8;
    border-radius: 999px;
    background: #f6f9fc;
}

.print-sheet-system {
    margin-bottom: 4px;
    font-family: var(--font-ar-display);
    font-size: 1.1rem;
    font-weight: 800;
    color: #203244;
}

.print-sheet-title {
    margin: 0 0 6px;
    font-family: var(--font-ar-display);
    font-size: 1.34rem;
    font-weight: 800;
    color: #102233;
}

.print-sheet-subtitle {
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 600;
    line-height: 1.7;
}

.print-sheet-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 8px;
    min-width: min(280px, 100%);
}

.print-sheet-meta-item,
.print-sheet-stat {
    border: 1px solid #dbe3ec;
    border-radius: 8px;
    background: #fbfcfe;
}

.print-sheet-meta-item {
    padding: 10px 12px;
}

.print-sheet-label {
    display: block;
    margin-bottom: 2px;
    font-size: 0.76rem;
    font-weight: 800;
    color: #607284;
}

.print-sheet-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
}

.print-sheet-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 0;
    padding: 14px 18px 0;
}

.print-sheet-stat {
    padding: 12px;
    position: relative;
    overflow: hidden;
}

.print-sheet-stat::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #38506a;
}

.print-sheet-stat .print-sheet-label {
    margin-bottom: 4px;
}

.print-sheet-stat .print-sheet-value {
    font-size: 1.08rem;
}

.print-sheet-note {
    margin: 14px 18px 0;
    padding: 10px 12px;
    border: 1px dashed #d2dae3;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    color: #475569;
    background: #fafcff;
}

.print-sheet-footer {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 14px 18px 18px;
}

.print-sheet-signature {
    min-height: 76px;
    padding: 12px 12px 8px;
    border: 1px dashed #d1d9e2;
    border-radius: 8px;
    background: #fcfdff;
}

.print-sheet-signature-title {
    margin-bottom: 28px;
    font-size: 0.82rem;
    font-weight: 800;
    color: #334155;
}

.print-sheet-signature-line {
    border-top: 1px solid #94a3b8;
    padding-top: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    color: #64748b;
}

@media (max-width: 980px) {
    .employees-page .kpi-card {
        grid-column: span 6;
    }
}

@media (max-width: 768px) {
    .employees-page {
        gap: 10px;
    }

    .employees-page .employees-kpis {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .employees-page .kpi-card,
    .employees-page .search-card {
        grid-column: 1 / -1;
    }

    .employees-page .kpi-number {
        font-size: 1.4rem;
    }

    .employees-page .filters-form {
        grid-template-columns: 1fr;
    }

    .employees-page .employees-hero-head {
        flex-direction: column;
        align-items: stretch;
    }

    .employees-page .filters-actions {
        width: 100%;
    }

    .employees-page .filters-actions .btn,
    .employees-page .report-actions .btn {
        flex: 1 1 calc(50% - 6px);
        min-width: 150px;
        text-align: center;
    }

    .employees-page .table-wrap table,
    .employees-page .table-wrap thead,
    .employees-page .table-wrap tbody,
    .employees-page .table-wrap th,
    .employees-page .table-wrap td,
    .employees-page .table-wrap tr {
        display: block;
        width: 100%;
    }

    .employees-page .table-wrap thead {
        display: none;
    }

    .employees-page .table-wrap tr {
        border: 1px solid #d6dde8;
        border-radius: 12px;
        padding: 8px;
        margin-bottom: 10px;
        background: #fff;
    }

    .employees-page .table-wrap td {
        border: 0;
        border-bottom: 1px dashed #e2e8f0;
        text-align: right;
        padding: 7px 6px;
    }

    .employees-page .table-wrap td:last-child {
        border-bottom: 0;
    }

    .employees-page .table-wrap td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #334155;
        display: block;
        margin-bottom: 2px;
        font-size: 0.82rem;
    }
}

/* ===== Professional Unified Theme Layer ===== */

body {
    transition: background-color 0.25s ease, color 0.25s ease;
}

.top-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    border-radius: 999px;
    padding: 7px 12px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(20, 35, 58, 0.09);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(20, 35, 58, 0.14);
}

.topbar,
.card,
table,
thead th,
tbody tr,
input,
select,
textarea,
button,
.btn,
.site-footer,
.nav-links a,
.login-wrap,
.kpi,
.reports-kpi,
.salary-summary-card,
.emp-card,
.employees-page .kpi-card,
.employees-page .search-card,
.employees-page .table-wrap,
.archive-state,
.badge,
.hero-pill,
.archive-pill,
.selected-month-pill,
.reports-live-pill,
.ed-chip {
    transition:
        background-color 0.22s ease,
        color 0.22s ease,
        border-color 0.22s ease,
        box-shadow 0.22s ease;
}

.nav-links a.is-active,
.btn-primary,
button[type="submit"] {
    background: linear-gradient(135deg, var(--brand), #1492ab);
    box-shadow: 0 11px 24px rgba(var(--brand-rgb), 0.30);
}

.nav-links a.is-active:hover,
.btn-primary:hover,
button[type="submit"]:hover {
    box-shadow: 0 14px 28px rgba(var(--brand-rgb), 0.36);
}

/* Dark mode variables */
body[data-theme="dark"] {
    --bg: #0f1724;
    --surface: #111b2b;
    --surface-2: #142235;
    --ink: #e5eefb;
    --muted: #97a7bd;
    --line: #23344c;
    --brand: #3cc7bd;
    --brand-strong: #63d6cc;
    --ok-bg: #113020;
    --danger-bg: #3a1620;
    --warn-bg: #3a2b12;
    --shadow-soft: 0 14px 36px rgba(4, 9, 19, 0.45);
    --shadow-strong: 0 18px 48px rgba(4, 9, 19, 0.60);

    background:
        radial-gradient(1050px 420px at 88% -12%, rgba(27, 158, 146, 0.20), transparent 55%),
        radial-gradient(700px 320px at 0% 0%, rgba(167, 124, 56, 0.18), transparent 60%),
        linear-gradient(180deg, #0b1320 0%, #101a2a 46%, #0f1724 100%);
}

body[data-theme="dark"] body::before,
body[data-theme="dark"]::before {
    background:
        radial-gradient(680px 260px at 14% -12%, rgba(34, 197, 184, 0.18), transparent 65%),
        radial-gradient(520px 210px at 85% 0%, rgba(217, 159, 77, 0.14), transparent 65%);
}

body[data-theme="dark"] .topbar {
    background: linear-gradient(180deg, rgba(13, 23, 36, 0.88), rgba(14, 24, 38, 0.82));
    border-bottom-color: rgba(49, 70, 99, 0.78);
}

body[data-theme="dark"] .brand {
    color: #e9f3ff;
    text-shadow: none;
}

body[data-theme="dark"] .nav-links a,
body[data-theme="dark"] .theme-toggle,
body[data-theme="dark"] .nav-toggle {
    background: #152338;
    color: #d7e4f6;
    border-color: #2a3d5a;
}

body[data-theme="dark"] .nav-links a:hover {
    background: #1c2d47;
    border-color: #345074;
}

body[data-theme="dark"] .card,
body[data-theme="dark"] table,
body[data-theme="dark"] .site-footer,
body[data-theme="dark"] .salary-summary-card,
body[data-theme="dark"] .reports-kpi,
body[data-theme="dark"] .kpi,
body[data-theme="dark"] .emp-card,
body[data-theme="dark"] .employees-page .kpi-card,
body[data-theme="dark"] .employees-page .search-card,
body[data-theme="dark"] .employees-page .table-wrap,
body[data-theme="dark"] .table-wrap,
body[data-theme="dark"] .table-scroll,
body[data-theme="dark"] .archive-table-wrap {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
    box-shadow: var(--shadow-soft);
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea {
    background: #0f1b2c;
    border-color: #2b3f5d;
    color: #dbe7f7;
}

body[data-theme="dark"] input:focus,
body[data-theme="dark"] select:focus,
body[data-theme="dark"] textarea:focus {
    border-color: #4bd3c9;
    box-shadow: 0 0 0 3px rgba(60, 199, 189, 0.22);
}

body[data-theme="dark"] thead th {
    background: linear-gradient(180deg, #172a42, #12243a);
    color: #dbe9fb;
}

body[data-theme="dark"] tbody tr:hover,
body[data-theme="dark"] .month-summary-row:hover {
    background: #15283f;
}

body[data-theme="dark"] .site-rights,
body[data-theme="dark"] .help,
body[data-theme="dark"] .muted,
body[data-theme="dark"] .small,
body[data-theme="dark"] .employees-page .kpi-title,
body[data-theme="dark"] .employees-page .filters-form label,
body[data-theme="dark"] .salary-summary-label,
body[data-theme="dark"] .kpi .label,
body[data-theme="dark"] .kpi .k-label,
body[data-theme="dark"] .reports-kpi .label,
body[data-theme="dark"] .emp-meta,
body[data-theme="dark"] .ed-sub {
    color: var(--muted);
}

body[data-theme="dark"] .badge,
body[data-theme="dark"] .hero-pill,
body[data-theme="dark"] .archive-pill,
body[data-theme="dark"] .selected-month-pill,
body[data-theme="dark"] .reports-live-pill,
body[data-theme="dark"] .ed-chip,
body[data-theme="dark"] .archive-state {
    background: #15283f;
    border-color: #2b4363;
    color: #d4e6fb;
}

body[data-theme="dark"] .site-socials a {
    background: #16253a;
    border-color: #2a3f5c;
    color: #d8e9ff;
}

body[data-theme="dark"] .site-rights {
    background: linear-gradient(180deg, #14263c 0%, #132338 100%);
    border-color: #28405f;
    box-shadow: 0 6px 14px rgba(4, 12, 20, 0.36);
}

body[data-theme="dark"] .rights-stamp-title {
    color: #a4bdd8;
}

body[data-theme="dark"] .rights-stamp-owner {
    color: #e3f0ff;
}

body[data-theme="dark"] .page-index .login-wrap {
    background: linear-gradient(180deg, rgba(17, 27, 43, 0.96), rgba(16, 32, 51, 0.94));
    border-color: #2a3c57;
    box-shadow: var(--shadow-strong);
}

body[data-theme="dark"] .page-index .login-badge {
    background: #18324b;
    border-color: #2d4f73;
    color: #d9ecff;
}

/* Global print refinements for all pages */
@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    * {
        box-shadow: none !important;
        text-shadow: none !important;
        background-image: none !important;
        color: #111 !important;
    }

    html,
    body {
        background: #fff !important;
        direction: rtl !important;
    }

    body {
        font-family: 'Tajawal', Tahoma, Arial, sans-serif !important;
        font-size: 10.5pt !important;
        line-height: 1.45 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .topbar,
    .site-footer,
    .nav-links,
    .nav-toggle,
    .theme-toggle,
    .btn,
    button,
    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }
}

/* ═══════════════════════════════════════════════
   PR-DOC  —  Row-per-employee print layout
   Hidden on screen; visible only in @media print
═══════════════════════════════════════════════ */
.pr-doc {
    display: none;
}

@media print {
    /* Reset & page */
    @page { size: A4 landscape; margin: 12mm 10mm; }

    .pr-doc {
        display: block;
        font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
        font-size: 8.5pt;
        color: #1a2535;
        direction: rtl;
        unicode-bidi: embed;
        width: 100%;
    }

    /* ── Header ── */
    .pr-header {
        display: grid;
        grid-template-columns: 52px 1fr auto;
        gap: 8px;
        align-items: start;
        border-bottom: 2px solid #304255;
        padding-bottom: 6px;
        margin-bottom: 8px;
    }
    .pr-logo {
        width: 48px;
        height: 48px;
        object-fit: contain;
    }
    .pr-header-body {
        padding: 0 4px;
    }
    .pr-org {
        font-size: 9pt;
        font-weight: 700;
        color: #304255;
        margin-bottom: 2px;
    }
    .pr-title {
        font-size: 11pt;
        font-weight: 800;
        color: #1a2535;
        margin-bottom: 2px;
    }
    .pr-sub {
        font-size: 7.5pt;
        color: #4a5f78;
    }
    .pr-header-meta {
        font-size: 7pt;
        min-width: 140px;
        border-right: 1px solid #dbe3ec;
        padding-right: 8px;
    }
    .pr-meta-row {
        display: flex;
        justify-content: space-between;
        gap: 6px;
        padding: 1px 0;
        border-bottom: 1px dotted #dbe3ec;
    }
    .pr-meta-row span { color: #5a6f88; }
    .pr-meta-row strong { color: #304255; }

    /* ── Summary cards ── */
    .pr-totals {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        margin-bottom: 8px;
    }
    .pr-total-card {
        border: 1px solid #dbe3ec;
        border-radius: 3px;
        padding: 4px 6px;
        text-align: center;
        background: #f8fafc;
    }
    .pr-total-net {
        background: #edf3f8;
        border-color: #38506a;
    }
    .pr-total-label {
        font-size: 7pt;
        color: #4a5f78;
        margin-bottom: 2px;
    }
    .pr-total-value {
        font-size: 9.5pt;
        font-weight: 700;
        color: #304255;
    }
    .pr-total-net .pr-total-value { color: #1a2535; }

    /* ── Employee rows ── */
    .pr-rows {
        border: 1px solid #dbe3ec;
        border-radius: 3px;
        overflow: hidden;
        margin-bottom: 10px;
    }
    .pr-rows-head,
    .pr-emp-row {
        display: grid;
        grid-template-columns:
            28px          /* seq */
            1.8fr         /* name */
            1fr           /* dept */
            1fr           /* job */
            56px          /* period */
            74px          /* base */
            64px          /* bonus */
            64px          /* deductions */
            44px          /* absent */
            74px;         /* net */
        gap: 0;
        padding: 3px 5px;
        align-items: center;
    }
    .pr-rows-head {
        background: #edf3f8;
        font-size: 7.5pt;
        font-weight: 700;
        color: #304255;
        border-bottom: 2px solid #38506a;
    }
    .pr-emp-row {
        font-size: 7.5pt;
        border-bottom: 1px solid #edf3f8;
    }
    .pr-row-even { background: #f8fafc; }
    .pr-row-duplicate {
        background: #fff1f5 !important;
        border-bottom-color: #f3c4d2;
    }

    /* Column alignment */
    .pr-col-seq    { text-align: center; color: #7a8fa8; }
    .pr-col-name   { font-weight: 600; }
    .pr-col-dept,
    .pr-col-job    { color: #4a5f78; }
    .pr-col-period { text-align: center; color: #4a5f78; }
    .pr-col-num    { text-align: left; direction: ltr; }
    .pr-col-absent { text-align: center; color: #8a4040; }
    .pr-col-net    { text-align: left; direction: ltr; font-weight: 700; color: #304255; }

    .duplicate-mark {
        display: inline-block;
        margin-inline-start: 4px;
        padding: 1px 5px;
        border-radius: 999px;
        background: #be123c;
        color: #fff;
        font-size: 6.5pt;
        font-weight: 800;
        vertical-align: middle;
    }

    .pr-empty-row {
        padding: 10px;
        text-align: center;
        color: #7a8fa8;
        font-style: italic;
    }

    /* ── Signature footer ── */
    .pr-footer {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        margin-top: 14px;
        padding-top: 8px;
        border-top: 1px solid #dbe3ec;
    }
    .pr-sign-box {
        text-align: center;
    }
    .pr-sign-title {
        font-size: 7.5pt;
        font-weight: 700;
        color: #304255;
        margin-bottom: 18px;
    }
    .pr-sign-name {
        font-size: 7pt;
        color: #4a5f78;
        margin-bottom: 4px;
    }
    .pr-sign-line {
        border-top: 1px solid #304255;
        margin: 0 20px;
    }

    .page-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0;
    }

    .print-meta-row {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        justify-content: space-between;
        gap: 8mm;
        margin: 0 0 3mm 0 !important;
        padding: 2.5mm 3mm;
        background: #edf2f8 !important;
        border-bottom: 1px solid #b4c0cf;
    }

    .print-meta-item {
        display: inline-flex;
        align-items: center;
        gap: 2mm;
        font-size: 9.6pt !important;
        font-weight: 700;
        white-space: nowrap;
    }

    h1,
    .page-title {
        font-family: 'Cairo', Tahoma, Arial, sans-serif !important;
        font-size: 15.5pt !important;
        font-weight: 800 !important;
        margin: 0 0 4mm 0 !important;
        padding: 0 3mm;
    }

    h2,
    h3,
    .settings-section-title {
        font-family: 'Cairo', Tahoma, Arial, sans-serif !important;
        font-size: 11.8pt !important;
        margin: 0 0 2.5mm 0 !important;
        padding: 0 3mm;
    }

    .card,
    .table-wrap,
    .table-scroll,
    .archive-table-wrap {
        border: 0 !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .report-print-shell,
    .print-sheet {
        display: block !important;
    }

    .print-sheet {
        margin: 0 0 5mm 0 !important;
        border: 0.3mm solid #9fb0c2 !important;
        border-radius: 2.5mm !important;
        overflow: hidden !important;
        background: #fff !important;
    }

    .print-sheet::before,
    .print-sheet::after {
        content: '' !important;
        position: absolute !important;
        pointer-events: none !important;
    }

    .print-sheet::before {
        inset: 3mm !important;
        border: 0.2mm solid #dce5ee !important;
        border-radius: 1.5mm !important;
    }

    .print-sheet::after {
        display: none !important;
    }

    .print-sheet-watermark {
        display: none !important;
    }

    .print-sheet-header {
        display: grid !important;
        grid-template-columns: auto 1fr auto;
        gap: 4mm;
        align-items: start;
        padding: 5.5mm 5mm 4mm !important;
        background: linear-gradient(180deg, #f8fafc 0, #f8fafc 2.2mm, #fff 2.2mm, #fff 100%) !important;
        border-bottom: 0.25mm solid #cfd8e3 !important;
        position: relative !important;
        z-index: 1 !important;
    }

    .print-sheet-logo {
        width: 24mm !important;
        max-width: 24mm !important;
        max-height: 24mm !important;
        margin: 0 !important;
        padding: 1.5mm !important;
        border: 0.25mm solid #d4dde7 !important;
        border-radius: 2mm !important;
        background: #fff !important;
    }

    .print-sheet-eyebrow {
        display: inline-flex !important;
        align-items: center !important;
        min-height: 8mm !important;
        margin: 0 0 2mm 0 !important;
        padding: 0 3mm !important;
        font-size: 8.4pt !important;
        font-weight: 800 !important;
        color: #304255 !important;
        border: 0.25mm solid #d7e0e8 !important;
        border-radius: 999px !important;
        background: #f6f9fc !important;
    }

    .print-sheet-system {
        margin: 0 0 1.5mm 0 !important;
        padding: 0 !important;
        font-size: 13.4pt !important;
        font-weight: 800 !important;
        color: #203244 !important;
    }

    .print-sheet-title {
        margin: 0 0 1.5mm 0 !important;
        padding: 0 !important;
        font-size: 18pt !important;
        font-weight: 800 !important;
        color: #102233 !important;
    }

    .print-sheet-subtitle {
        font-size: 9pt !important;
        font-weight: 700 !important;
        color: #475569 !important;
        line-height: 1.7 !important;
    }

    .print-sheet-meta {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 2.5mm;
        min-width: 56mm;
    }

    .print-sheet-meta-item,
    .print-sheet-stat {
        background: #fbfcfe !important;
        border: 1px solid #dbe3ec !important;
        border-radius: 2mm !important;
    }

    .print-sheet-meta-item {
        padding: 2.6mm 3mm !important;
    }

    .print-sheet-label {
        margin: 0 0 1mm 0 !important;
        font-size: 7.6pt !important;
        font-weight: 800 !important;
        color: #607284 !important;
    }

    .print-sheet-value {
        font-size: 9.4pt !important;
        font-weight: 800 !important;
        color: #0f172a !important;
    }

    .print-sheet-stats {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 2.5mm;
        padding: 4mm 5mm 0 !important;
        margin: 0 !important;
        position: relative !important;
        z-index: 1 !important;
    }

    .print-sheet-stat {
        padding: 2.8mm 3mm 2.8mm 4.5mm !important;
        position: relative !important;
        overflow: hidden !important;
    }

    .print-sheet-stat::before {
        content: '' !important;
        position: absolute !important;
        inset-inline-start: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 0.9mm !important;
        background: #38506a !important;
    }

    .print-sheet-stat .print-sheet-value {
        font-size: 10pt !important;
    }

    .print-sheet-note {
        margin: 3mm 5mm 0 !important;
        padding: 3mm !important;
        border: 0.25mm dashed #d2dae3 !important;
        border-radius: 2mm !important;
        font-size: 8pt !important;
        font-weight: 700 !important;
        color: #475569 !important;
        background: #fafcff !important;
        position: relative !important;
        z-index: 1 !important;
    }

    .print-sheet-footer {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 3mm;
        padding: 4mm 5mm 5mm !important;
        position: relative !important;
        z-index: 1 !important;
    }

    .print-sheet-signature {
        min-height: 22mm !important;
        padding: 3mm 3mm 2mm !important;
        border: 0.25mm dashed #d1d9e2 !important;
        border-radius: 2mm !important;
        background: #fcfdff !important;
    }

    .print-sheet-signature-title {
        margin: 0 0 8mm 0 !important;
        font-size: 7.8pt !important;
        font-weight: 800 !important;
        color: #334155 !important;
    }

    .print-sheet-signature-line {
        border-top: 0.25mm solid #94a3b8 !important;
        padding-top: 1.5mm !important;
        font-size: 7.2pt !important;
        font-weight: 700 !important;
        color: #64748b !important;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: fixed;
        border: 1px solid #8f9bab !important;
        margin: 0 !important;
        page-break-inside: auto;
    }

    thead {
        display: table-header-group;
    }

    tbody tr {
        background: #fff !important;
    }

    tbody tr:nth-child(even) {
        background: #f8fafc !important;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    th,
    td {
        text-align: right !important;
        vertical-align: middle !important;
        padding: 4.3px 6px !important;
        font-size: 9.2pt !important;
        line-height: 1.35 !important;
        border: 1px solid #b6c1cf !important;
        word-break: break-word;
    }

    th {
        background: #edf3f8 !important;
        color: #1f2937 !important;
        font-weight: 800 !important;
    }

    td {
        color: #111827 !important;
    }

    a,
    a:visited {
        color: #111 !important;
        text-decoration: none !important;
    }
}
