:root {
    --navy: #123a8f;
    --blue: #1f64ff;
    --green: #0ea76b;
    --green-2: #1cc980;
    --bg: #f5f8fc;
    --panel: #ffffff;
    --panel-2: #f8fbff;
    --text: #132238;
    --muted: #6b7280;
    --border: #dbe5f0;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    --danger: #dc2626;
    --sidebar-open: 272px;
    --sidebar-closed: 86px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background:
      radial-gradient(circle at top right, rgba(31,100,255,.08), transparent 20%),
      linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, sans-serif;
}

a { text-decoration: none; }

.app-shell {
    min-height: 100vh;
    padding-left: var(--sidebar-closed);
    transition: padding-left .25s ease;
}
.app-shell.sidebar-pinned { padding-left: var(--sidebar-open); }

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-closed);
    background: linear-gradient(180deg, #0f2f73 0%, #1648a5 52%, #0d8f61 100%);
    color: #fff;
    box-shadow: 16px 0 42px rgba(15, 23, 42, .18);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    padding: 14px 12px;
    transition: width .25s ease, transform .25s ease;
    overflow: hidden;
}
.app-shell.sidebar-pinned .sidebar,
.sidebar:hover {
    width: var(--sidebar-open);
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    min-width: 0;
}
.brand-logo-wrap {
    min-width: 54px;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: rgba(255,255,255,.14);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
}
.brand-logo-wrap img {
    width: 40px;
    height: auto;
    background: #fff;
    padding: 4px 6px;
    border-radius: 12px;
}
.brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    opacity: 0;
    transform: translateX(-8px);
    transition: all .2s ease;
    white-space: nowrap;
}
.brand-copy strong { letter-spacing: .08em; font-size: .95rem; }
.brand-copy small { color: rgba(255,255,255,.75); font-size: .78rem; }
.app-shell.sidebar-pinned .brand-copy,
.sidebar:hover .brand-copy { opacity: 1; transform: translateX(0); }

.sidebar-pin,
.mobile-menu-btn {
    border: 0;
    border-radius: 14px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 1.15rem;
}
.sidebar-pin:hover,
.mobile-menu-btn:hover { background: rgba(255,255,255,.22); }
.sidebar-pin { flex: 0 0 auto; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 99px; }

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 10px 12px;
    color: rgba(255,255,255,.92);
    border-radius: 16px;
    transition: background .2s ease, transform .2s ease, color .2s ease;
    white-space: nowrap;
}
.sidebar-link:hover { background: rgba(255,255,255,.12); color: #fff; transform: translateX(2px); }
.sidebar-link.active {
    background: linear-gradient(90deg, rgba(255,255,255,.18), rgba(255,255,255,.12));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 999px;
    background: #fff;
}
.sidebar-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.10);
    font-size: 1.08rem;
    flex: 0 0 auto;
}
.sidebar-label {
    opacity: 0;
    transform: translateX(-8px);
    transition: all .2s ease;
    font-weight: 600;
    letter-spacing: .01em;
}
.app-shell.sidebar-pinned .sidebar-label,
.sidebar:hover .sidebar-label {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,.16);
}
.user-mini-card {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255,255,255,.10);
    margin-bottom: 10px;
}
.user-mini-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255,255,255,.14);
    font-size: 1.15rem;
    flex: 0 0 auto;
}
.user-mini-text {
    opacity: 0;
    transform: translateX(-8px);
    transition: all .2s ease;
    min-width: 0;
}
.user-mini-text strong,
.user-mini-text small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-mini-text small { color: rgba(255,255,255,.75); }
.app-shell.sidebar-pinned .user-mini-text,
.sidebar:hover .user-mini-text { opacity: 1; transform: translateX(0); }
.sidebar-logout { margin-top: 4px; }

.app-main {
    min-height: 100vh;
    padding: 20px 22px;
}
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 18px 22px;
    border-radius: 24px;
    background: rgba(255,255,255,.88);
    border: 1px solid rgba(219,229,240,.85);
    backdrop-filter: blur(10px);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
}
.top-header-left,
.top-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.page-eyebrow {
    color: var(--blue);
    text-transform: uppercase;
    font-size: .75rem;
    letter-spacing: .14em;
    font-weight: 700;
    margin-bottom: 4px;
}
.page-title {
    font-size: clamp(1.3rem, 2vw, 1.9rem);
    font-weight: 800;
    color: #0f172a;
}
.user-badge,
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 600;
}
.user-badge {
    background: #eef5ff;
    color: #1e3a8a;
}
.role-badge {
    background: #ecfdf5;
    color: #047857;
}
.mobile-menu-btn { display: none; background: linear-gradient(135deg, var(--navy), var(--blue)); }

.page-wrap { padding: 0; }
.card {
    border: 1px solid rgba(219,229,240,.92);
    border-radius: 24px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    box-shadow: var(--shadow);
}
.btn {
    border-radius: 14px;
    font-weight: 600;
    padding: .62rem 1rem;
}
.btn-sm {
    border-radius: 12px;
    padding: .5rem .85rem;
}
.btn-primary { background: linear-gradient(135deg, var(--navy), var(--blue)); border-color: transparent; }
.btn-primary:hover { opacity: .95; }
.btn-success { background: linear-gradient(135deg, #0b8f5e, var(--green-2)); border-color: transparent; }
.btn-outline-brand { border-color: #b6c9ff; color: var(--blue); background: #fff; }
.btn-outline-brand:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-light { background: #fff; border-color: #d7e3f4; }
.kpi { padding: 18px; border-radius: 20px; color:#fff; }
.kpi.blue { background: linear-gradient(135deg, var(--navy), var(--blue)); }
.kpi.green { background: linear-gradient(135deg, #0f9f66, var(--green-2)); }
.kpi.gray { background: linear-gradient(135deg, #475569, #64748b); }
.badge-credit { background: var(--green); }
.badge-debit { background: var(--danger); }
.table {
    --bs-table-bg: transparent;
}
.table thead th {
    background: linear-gradient(180deg, #f3f8ff 0%, #eaf2ff 100%);
    border-bottom: 0;
    color: #274163;
    font-size: .88rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.table > :not(caption) > * > * {
    padding: .9rem .8rem;
    border-color: #e8eff7;
}
.table tbody tr:hover { background: #f8fbff; }
.login-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; background: linear-gradient(135deg, var(--navy), var(--green)); }
.login-card { width:100%; max-width:420px; border-radius:24px; overflow:hidden; }
.logo-box { text-align:center; padding-top:8px; }
.logo-box img { max-height:64px; background:#fff; padding:8px 12px; border-radius:12px; }
.section-title { font-size: 1.1rem; font-weight:800; margin-bottom: 14px; color:#11233e; }
.muted { color: var(--muted); }
.table-sm td, .table-sm th { font-size: .92rem; }
.chip { display:inline-block; padding:6px 11px; border-radius:999px; background:#eef2ff; color:#1E3A8A; font-size:.82rem; font-weight:700; }
.lang-pair .en { display:block; font-weight:700; }
.lang-pair .ar { display:block; color:var(--muted); font-size:.86rem; direction:rtl; }
.stat-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:14px; }
.stat-box { background:#fff; border:1px solid var(--border); border-radius:18px; padding:16px; box-shadow: 0 8px 22px rgba(15,23,42,.04); }
.toolbar { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.step-pending { color:#9A6700; font-weight:700; }
.step-approved { color:#0f9f66; font-weight:700; }
.step-rejected { color:#DC2626; font-weight:700; }
.text-ar { direction: rtl; }
.form-control, .form-select {
    border-radius: 14px;
    min-height: 46px;
    border-color: #d7e3f4;
    box-shadow: none;
}
.form-control:focus, .form-select:focus {
    border-color: #9ab8ff;
    box-shadow: 0 0 0 .2rem rgba(37,99,235,.12);
}
.alert { border: 0; border-radius: 16px; }
.table-responsive { border-radius: 20px; }

.org-chart-wrap { overflow-x:auto; padding-bottom:10px; }
.org-chart-root, .org-chart-root ul { list-style:none; margin:0; padding:0; }
.org-chart-root { display:flex; justify-content:center; }
.org-chart-root li { text-align:center; position:relative; padding:18px 10px 0 10px; }
.org-chart-root li ul { display:flex; justify-content:center; flex-wrap:nowrap; }
.org-chart-root li::before, .org-chart-root li::after { content:''; position:absolute; top:0; border-top:2px solid #dbeafe; width:50%; height:18px; }
.org-chart-root li::before { right:50%; }
.org-chart-root li::after { left:50%; }
.org-chart-root li:only-child::before, .org-chart-root li:only-child::after { display:none; }
.org-chart-root li:only-child { padding-top:0; }
.org-chart-root li:first-child::before, .org-chart-root li:last-child::after { border-top:none; }
.org-chart-root ul ul::before { content:''; position:absolute; top:0; left:50%; border-left:2px solid #dbeafe; width:0; height:18px; }
.org-card { min-width:220px; max-width:220px; background:#fff; border:1px solid var(--border); border-radius:18px; padding:14px; box-shadow:0 10px 24px rgba(15,23,42,.05); }
.org-role { color:var(--blue); font-weight:700; font-size:.8rem; margin-bottom:8px; }
.org-name { font-weight:700; }
.org-name-ar { direction:rtl; color:var(--muted); margin-bottom:6px; }
.org-meta { font-size:.88rem; color:var(--muted); }
.org-meta-ar { direction:rtl; }
.bg-light-subtle { background:#f8fbff; }
.org-summary-box { border-radius:16px; border:1px solid #dbeafe; }
.gui-hierarchy-wrap { background:linear-gradient(180deg,#f8fbff 0%, #ffffff 100%); border:1px solid #e5eefc; border-radius:22px; padding:18px; }
.gui-hierarchy-root { min-width:max-content; }
.org-chart-root.gui-hierarchy-root li { padding:22px 12px 0 12px; }
.org-chart-root.gui-hierarchy-root li::before, .org-chart-root.gui-hierarchy-root li::after { border-top:2px solid #bfdbfe; }
.org-chart-root.gui-hierarchy-root ul ul::before { border-left:2px solid #bfdbfe; }
.org-node.collapsed > .org-children { display:none !important; }
.org-card { min-width:260px; max-width:260px; background:linear-gradient(180deg,#ffffff 0%, #f8fbff 100%); border:1px solid #dbeafe; border-radius:20px; padding:14px; box-shadow:0 14px 28px rgba(15,23,42,.08); }
.org-card-top { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; gap:8px; }
.org-role-chip { background:#eff6ff; }
.org-toggle { width:30px; height:30px; border-radius:50%; border:1px solid #bfdbfe; background:#fff; color:var(--blue); font-weight:700; line-height:1; }
.org-toggle:hover { background:#eff6ff; }
.org-meta.strong { color:#0f172a; font-weight:600; }
.org-code-row { display:flex; justify-content:space-between; gap:8px; margin-top:10px; font-size:.85rem; color:var(--muted); }
.org-code { background:#eff6ff; color:#1e3a8a; border-radius:999px; padding:4px 8px; font-weight:600; }
.org-sub-count { white-space:nowrap; }
.org-card-actions { display:flex; gap:8px; justify-content:center; margin-top:12px; }

@media (max-width: 991.98px) {
    .app-shell { padding-left: 0; }
    .sidebar {
        width: var(--sidebar-open);
        transform: translateX(-100%);
    }
    body.sidebar-mobile-open .sidebar { transform: translateX(0); }
    .sidebar .brand-copy,
    .sidebar .sidebar-label,
    .sidebar .user-mini-text { opacity: 1; transform: translateX(0); }
    .app-main { padding: 14px; }
    .top-header { padding: 16px 16px; }
    .mobile-menu-btn { display: inline-flex; }
    body.sidebar-mobile-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,.35);
        z-index: 1030;
    }
}

@media (max-width: 768px) {
    .top-header { border-radius: 20px; }
    .top-header-right { width: 100%; }
    .user-badge, .role-badge { width: 100%; justify-content: center; }
    .org-card { min-width:220px; max-width:220px; }
    .org-card-actions { flex-direction:column; }
}


.nav-section{
    font-size:.68rem;
    font-weight:800;
    letter-spacing:.12em;
    text-transform:uppercase;
    color:rgba(255,255,255,.56);
    padding:14px 12px 8px;
    transition:all .18s ease;
    white-space:nowrap;
    opacity:0;
    transform:translateX(-6px);
    pointer-events:none;
}
.app-shell.sidebar-pinned .nav-section,
.sidebar:hover .nav-section{
    opacity:1;
    transform:translateX(0);
}
@media (max-width: 991px){
    .nav-section{opacity:1;transform:translateX(0);}
}

.shift-card{
    border:1px solid #e5edf6;
    border-radius:22px;
    box-shadow:0 10px 30px rgba(20,55,90,.08);
}
.shift-days{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
}
.shift-day-pill{
    display:inline-flex;
    align-items:center;
    gap:8px;
    background:#fff;
    border:1px solid #d8e4f1;
    border-radius:999px;
    padding:8px 12px;
    font-size:.92rem;
}
.shift-day-pill input{margin:0;}
.shift-badge{
    display:inline-flex;
    align-items:center;
    padding:4px 10px;
    border-radius:999px;
    background:#e8f3ff;
    color:#0b5cab;
    font-size:.8rem;
    font-weight:700;
    margin:2px 6px 2px 0;
}
.shift-badge.fixed{
    background:#e8fff1;
    color:#16794a;
}
.shift-badge.missing{
    background:#fff0f0;
    color:#c0392b;
}
tr.schedule-missing td,
.missing-shift{
    background:#fff9e8 !important;
}


/* Employee attendance tab */
.employee-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 10px;
}
.employee-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 999px;
    background: #f8fafc;
    color: #0f172a;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid #e5e7eb;
}
.employee-tab:hover {
    background: #eef7ff;
    color: #0b5cab;
}
.employee-tab.active {
    background: linear-gradient(135deg, #0b5cab, #16a34a);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 18px rgba(11, 92, 171, .18);
}
.attendance-filter-card {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 180px 180px;
    gap: 14px;
    align-items: end;
    padding: 16px;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}
.attendance-debug {
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
    font-size: .92rem;
}
.attendance-table th {
    white-space: nowrap;
}
.shift-badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #bbf7d0;
    font-weight: 700;
    white-space: nowrap;
}
.badge-soft-danger {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-weight: 700;
    white-space: nowrap;
}
.attendance-row-missing-shift td {
    background: #fff7ed !important;
}
.attendance-row-warning td {
    background: #fffbeb !important;
}
.attendance-status {
    font-weight: 700;
    white-space: nowrap;
}
.small-value {
    font-size: 1.3rem !important;
}
@media (max-width: 900px) {
    .attendance-filter-card {
        grid-template-columns: 1fr;
    }
}
