:root {
    --navy: #003a66;
    --navy-deep: #07131f;
    --gold: #c4a574;
    --ink: #1c2430;
    --muted: #6b7380;
    --line: rgba(15, 31, 48, 0.08);
    --paper: #f4f1eb;
    --white: #ffffff;
    --sidebar-width: 268px;
    --radius: 22px;
    --shadow: 0 18px 40px rgba(16, 32, 50, 0.08);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { direction: rtl; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Tahoma, sans-serif;
    font-size: 15px;
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(0, 69, 122, 0.08), transparent 50%),
        linear-gradient(180deg, #f7f4ee 0%, #eef1f6 100%);
    min-height: 100vh;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: #002b4d; }
img { max-width: 100%; }

.container-fluid { width: 100%; }
.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
.row > [class*="col-"] { padding: 0 10px; }
.col-6 { width: 50%; }
.col-md-2 { width: 16.666%; }
.col-md-3 { width: 25%; }
.col-md-4 { width: 33.333%; }
.col-md-6 { width: 50%; }
.col-md-8 { width: 66.666%; }
.col-md-12 { width: 100%; }
.col-lg-3 { width: 25%; }

@media (max-width: 980px) {
    .col-md-2, .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-lg-3, .col-6 { width: 100%; }
}

.d-inline { display: inline; }
.d-none { display: none; }
.d-flex { display: flex; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.p-0 { padding: 0 !important; }
.table-responsive { overflow-x: auto; }

.app {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    top: 14px;
    right: 14px;
    width: var(--sidebar-width);
    height: calc(100vh - 28px);
    background: linear-gradient(180deg, #0b1826 0%, #071018 100%);
    color: #fff;
    overflow-y: auto;
    z-index: 30;
    border-radius: 28px;
    box-shadow: 0 20px 50px rgba(7, 16, 24, 0.28);
}

.brand-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 16px 18px;
}

.brand-link .brand-image {
    height: 58px;
    width: auto;
}

.brand-kicker {
    margin-top: 10px;
    font-size: 11px;
    letter-spacing: 0.28em;
    color: var(--gold);
}

.sidebar { padding: 8px 14px 28px; }

.nav-sidebar {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-sidebar .nav-link {
    color: rgba(255,255,255,0.72);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    margin: 3px 0;
    border-radius: 14px;
    font-size: 14px;
    transition: 0.18s ease;
}

.nav-sidebar .nav-link p { margin: 0; }

.nav-sidebar .nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.nav-sidebar .nav-link.active {
    background: linear-gradient(90deg, #00457a, #0a5e9c);
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 69, 122, 0.35);
}

.nav-icon {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.06);
    font-size: 13px;
}

.nav-header {
    color: rgba(196, 165, 116, 0.7);
    font-size: 11px;
    padding: 18px 14px 6px;
    letter-spacing: 0.18em;
}

.app-main {
    margin-right: calc(var(--sidebar-width) + 28px);
    min-height: 100vh;
    padding: 18px 28px 32px;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 4px 22px;
}

.topbar-title h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 650;
    letter-spacing: -0.03em;
    color: var(--navy-deep);
}

.topbar-title span {
    color: var(--muted);
    font-size: 13px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.72);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 6px 6px 14px;
    backdrop-filter: blur(12px);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.btn-ghost {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
}

.menu-toggle {
    display: none;
    border: 0;
    background: #fff;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
}

.card {
    background: rgba(255,255,255,0.86);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    backdrop-filter: blur(10px);
}

.card-header {
    padding: 18px 22px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border: 0;
}

.card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

.report-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.report-links a {
    display: inline-flex;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-size: 13px;
}

.card-body { padding: 18px 22px 22px; }
.card-footer {
    padding: 14px 22px 18px;
    border-top: 1px solid var(--line);
}

.table { width: 100%; border-collapse: collapse; }

.table th,
.table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    text-align: right;
}

.table thead th {
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.table-striped tbody tr:hover { background: rgba(0, 69, 122, 0.03); }

.table tfoot td {
    border-top: 1px solid var(--line);
    background: #fbfaf7;
    font-weight: 600;
}
.table tfoot .table-subtotal td {
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
}
.table tfoot .table-total td {
    background: #07131f;
    color: #fff;
    border-bottom: 0;
    font-size: 15px;
}
.table tfoot .table-total td:nth-child(2) { color: var(--gold); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.3;
    background: #ece8e1;
    color: var(--ink);
    transition: 0.15s ease;
}

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn-block { display: flex; width: 100%; }

.btn-amair,
.btn-primary {
    background: var(--navy);
    color: #fff;
}

.btn-amair:hover,
.btn-primary:hover { background: #002b4d; color: #fff; }

.btn-secondary { background: #e8edf3; color: var(--navy); }
.btn-danger { background: #c4453c; color: #fff; }
.btn-outline-primary { background: #fff; border-color: #d5deea; color: var(--navy); }
.btn-outline-danger { background: #fff; border-color: #f0c9c6; color: #c4453c; }
.btn-link { background: transparent; border: 0; color: var(--navy); padding: 0; }

.form-group { margin-bottom: 1rem; }
.form-row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.form-row > .form-group { padding: 0 8px; }

.form-control,
select.form-control,
textarea.form-control,
input.form-control {
    display: block;
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #e1ddd6;
    border-radius: 12px;
    font-size: 14px;
    background: #fff;
    color: var(--ink);
}

.form-control:focus {
    outline: none;
    border-color: #8fb3d1;
    box-shadow: 0 0 0 4px rgba(0, 69, 122, 0.08);
}

.form-inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: rgba(255,255,255,0.8);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 12px 14px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.form-inline .form-control { width: auto; min-width: 140px; }
.form-check { display: flex; align-items: center; gap: 8px; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #e7f6ee; color: #0f7b4a; }
.badge-danger { background: #fdecea; color: #b42318; }
.badge-warning { background: #fff6e0; color: #8a5b00; }
.badge-info { background: #e8f4fb; color: #0b6e99; }
.badge-primary { background: #e7eef6; color: var(--navy); }
.badge-secondary { background: #eef0f3; color: #4b5563; }

.alert {
    padding: 13px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success { background: #eef8f2; color: #146c43; }
.alert-info { background: #eef6fb; color: #0b5f86; }
.alert-danger { background: #fdeeee; color: #9b1c1c; }
.alert-secondary { background: #f3f1ec; color: #4a4a4a; }

.small-box {
    background: rgba(255,255,255,0.9);
    color: var(--ink);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
    position: relative;
    min-height: 118px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.small-box .inner h3 {
    margin: 8px 0 4px;
    font-size: 30px;
    letter-spacing: -0.04em;
}

.small-box .inner p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.small-box .icon {
    position: absolute;
    left: 16px;
    top: 16px;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    opacity: 1;
}

.small-box.bg-success { background: #fff; }
.small-box.bg-success .icon { background: #e7f6ee; }
.small-box.bg-success .inner h3 { color: #0f7b4a; }

.small-box.bg-danger { background: #fff; }
.small-box.bg-danger .icon { background: #fdecea; }
.small-box.bg-danger .inner h3 { color: #b42318; }

.small-box.bg-warning { background: #fff; color: var(--ink); }
.small-box.bg-warning .icon { background: #fff6e0; }
.small-box.bg-warning .inner h3 { color: #8a5b00; }

.small-box.bg-info { background: #fff; }
.small-box.bg-info .icon { background: #e8f4fb; }
.small-box.bg-info .inner h3 { color: #0b6e99; }

.chart-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.chart-wrap canvas {
    display: block;
    margin: 0 auto;
    max-width: 280px;
}

.chart-legend { list-style: none; margin: 18px 0 0; padding: 0; }
.chart-legend li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.chart-legend li:last-child { border-bottom: 0; }
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
}

.unit-card {
    border-radius: 18px;
    padding: 14px;
    color: #fff;
    min-height: 120px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}

.unit-card select,
.unit-card input {
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 7px 8px;
    font-size: 12px;
}

.login-page-amair {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(800px 400px at 80% 0%, rgba(196,165,116,0.18), transparent 50%),
        linear-gradient(160deg, #05090e 0%, #0c1c2c 55%, #061018 100%);
}

.login-box-amair {
    width: 100%;
    max-width: 420px;
    background: rgba(10, 18, 28, 0.78);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 28px;
    padding: 36px 32px 32px;
    color: #fff;
    box-shadow: 0 30px 80px rgba(0,0,0,0.35);
    backdrop-filter: blur(16px);
}

.login-box-amair img {
    max-width: 180px;
    display: block;
    margin: 0 auto 14px;
}

.login-box-amair h5 {
    font-weight: 400;
    letter-spacing: 0.18em;
    font-size: 12px;
    color: var(--gold);
}

.login-box-amair .form-control {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
}

.login-box-amair label { color: rgba(255,255,255,0.7); display: block; margin-bottom: 6px; }

[x-cloak] { display: none !important; }

.pagination { display: flex; list-style: none; padding: 0; margin: 0; gap: 6px; }
.pagination .page-link {
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--navy);
    background: #fff;
}
.pagination .active .page-link { background: var(--navy); color: #fff; }

.main-footer { display: none; }
.page-title { display: none; }
.content-header { display: none; }
.navbar-nav { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
.nav-link { color: inherit; }

.wrapper { min-height: 100vh; }
.main-header { display: none; }
.main-sidebar { /* mapped via app-sidebar */ }
.content-wrapper { }
.content { }

.sidebar-collapse .app-sidebar { right: calc((var(--sidebar-width) + 14px) * -1); }
.sidebar-collapse .app-main { margin-right: 18px; }

@media (max-width: 980px) {
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .app-sidebar { right: calc((var(--sidebar-width) + 14px) * -1); }
    .app-main { margin-right: 0; padding: 14px; }
    .sidebar-open .app-sidebar { right: 14px; }
}

.pdf-wrap { font-family: dejavusans, sans-serif; direction: rtl; text-align: right; font-size: 12px; }
.pdf-header { background: #000; color: #fff; padding: 12px; text-align: center; margin-bottom: 16px; }
.pdf-header img { height: 55px; }
.pdf-table { width: 100%; border-collapse: collapse; }
.pdf-table th, .pdf-table td { border: 1px solid #ccc; padding: 6px; font-size: 11px; }
.pdf-table th { background: #00457a; color: #fff; }

.status-select {
    min-width: 148px;
    width: auto;
    padding: 7px 10px;
    font-size: 13px;
    border-radius: 10px;
    background: #fff;
}
.inline-status { margin: 0; display: inline-block; }

.contracts-box {
    margin: 8px 0 22px;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    background: #fbfaf7;
}
.contracts-box-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.contracts-box h4 { margin: 0 0 4px; }
.contracts-nested th { background: #f4efe6; }
.contracts-detail-row td { background: #fbfaf7; padding-top: 6px; padding-bottom: 14px; }
