:root {
    --bg: #f5f7f8;
    --panel: #ffffff;
    --line: #dde3e6;
    --text: #101820;
    --muted: #63717d;
    --sidebar: #090a0a;
    --sidebar-soft: #171818;
    --green: #00853f;
    --green-dark: #006f35;
    --danger: #b42318;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 325px 1fr; }
.sidebar { background: var(--sidebar); color: #aeb7be; padding: 20px 15px; display: flex; flex-direction: column; gap: 22px; }
.brand, .login-brand { display: flex; gap: 14px; align-items: center; color: #f7fbff; }
.brand-logo { width: 54px; height: 54px; object-fit: contain; border-radius: 8px; background: #fff; padding: 4px; }
.login-logo { width: 150px; max-width: 42%; object-fit: contain; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; background: #00a862; color: #fff; font-weight: 800; }
.brand small, .login-brand small { display: block; color: #9ca7b0; font-size: 12px; letter-spacing: .08em; margin-top: 3px; }
.nav { display: grid; gap: 7px; }
.nav a { display: grid; grid-template-columns: 24px 1fr; gap: 5px 14px; align-items: center; padding: 13px 16px; border-radius: 8px; font-weight: 700; }
.nav a.active, .nav a:hover { background: var(--sidebar-soft); color: #00c875; }
.nav span { width: 24px; text-align: center; color: #7f878d; }
.nav small { grid-column: 2; color: #7f878d; font-size: 12px; direction: rtl; text-align: left; }
.logout { margin-top: auto; }
.logout button { width: 100%; background: transparent; color: #aeb7be; border: 1px solid #242728; border-radius: 8px; padding: 12px; cursor: pointer; }
.main { min-width: 0; }
.topbar { height: 80px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: rgba(255,255,255,.78); }
.global-search, .filterbar { display: flex; align-items: center; gap: 10px; }
.global-search { border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; width: min(360px, 45vw); background: #fff; }
.global-search span { color: var(--muted); font-size: 13px; }
.global-search input, .filterbar input, .filterbar select { border: 0; outline: 0; background: transparent; min-height: 42px; width: 100%; }
.top-actions, .button-row, .form-actions { display: flex; align-items: center; gap: 12px; }
.lang-switch { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 3px; background: #fff; }
.lang-switch a { min-width: 36px; text-align: center; padding: 7px 9px; border-radius: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.lang-switch a.active { background: var(--green); color: #fff; }
.login-lang { margin-top: 22px; width: 100%; justify-content: center; }
.login-lang a { min-width: 92px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #dcefea; color: #007545; display: inline-grid; place-items: center; font-weight: 800; }
.content { padding: 28px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .12em; font-weight: 800; }
h1 { margin: 0; font-size: 30px; letter-spacing: 0; }
h1 span, h2 span { display: inline-block; margin-left: 8px; color: var(--muted); font-size: .72em; font-weight: 700; }
h2 { font-size: 18px; margin: 22px 0 12px; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: 10px 14px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.wide { width: 100%; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat strong { display: block; font-size: 32px; margin-top: 10px; }
.panel, .form-panel, .report-sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.panel { overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 0; }
.panel-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 12px; text-align: left; vertical-align: middle; }
th { color: #111827; font-size: 14px; background: #fbfcfd; }
td { color: #0f1720; }
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; }
.actions-cell a, .actions-cell button { color: var(--green); font-weight: 800; margin-right: 10px; background: transparent; border: 0; padding: 0; cursor: pointer; }
.badge { border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 800; }
.badge.ok { background: #008a12; color: #fff; }
.badge.muted { background: #e8ecef; color: #5f6b75; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.filterbar { width: min(680px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px 5px 14px; margin-bottom: 16px; }
.filterbar select { width: 145px; }
.pagination { padding: 14px; }
.alert { border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; font-weight: 700; }
.alert.success { color: #066a3b; background: #dff5e9; border: 1px solid #aee5c5; }
.form-panel { padding: 22px; display: grid; gap: 18px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
label { display: grid; gap: 7px; font-weight: 800; color: #1f2937; }
input, textarea, select { border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; background: #fff; color: var(--text); }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 15px; }
legend { font-weight: 800; padding: 0 8px; }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.check-grid.four-cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check-grid.three-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check-grid label, .check-inline { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.error { color: var(--danger); font-size: 13px; font-weight: 700; }
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #070909, #10251d 55%, #f5f7f8 55%); padding: 20px; }
.login-card { width: min(520px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: 0 24px 70px rgba(0,0,0,.18); }
.login-card form { display: grid; gap: 16px; margin-top: 28px; }
.login-brand { color: var(--text); }
.login-brand strong { color: #4a272b; font-size: 20px; }
.login-brand small[dir="rtl"] { letter-spacing: 0; font-size: 13px; color: #315c12; }
.report-sheet { padding: 28px; }
.report-brand { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.report-brand td { border: 0; padding: 0; vertical-align: middle; }
.report-logo { width: 190px; max-height: 76px; object-fit: contain; }
.report-repeat-header { display: none; }
.report-repeat-header .report-brand { margin-left: auto; width: 265px; }
.report-repeat-header .report-brand td { text-align: right; }
.report-repeat-header .report-logo { width: 170px; max-height: 72px; }
.pdf-header-code { text-align: right; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.company-ar { direction: rtl; text-align: right; font-size: 18px; font-weight: 800; color: #4a272b; }
.report-title { text-align: center; font-size: 26px; margin: 12px 0 24px; }
.report-title span { color: #4a272b; font-size: .76em; }
.report-meta { text-align: right; color: #222; font-weight: 800; }
.row { margin: 12px 0; line-height: 1.5; }
.label { font-weight: 800; }
.line { border-bottom: 1px solid #4b5563; display: inline-block; min-width: 220px; padding: 2px 6px; }
.block { border: 1px solid var(--line); border-radius: 6px; min-height: 52px; padding: 10px; margin-top: 6px; white-space: pre-wrap; }
.signatures td { height: 120px; vertical-align: top; }
.print-body { background: #fff; padding: 0; }
.print-body .report-sheet { border: 0; border-radius: 0; }
.print-body .report-repeat-header { display: block; position: fixed; top: 0; left: 0; right: 0; height: 110px; padding: 14px 34px 0; background: #fff; z-index: 5; text-align: right; }
.print-body .report-sheet { margin-top: 118px; }
[dir="rtl"] body, body[dir="rtl"] { text-align: right; }
[dir="rtl"] .brand, [dir="rtl"] .login-brand { flex-direction: row-reverse; }
[dir="rtl"] .nav a { grid-template-columns: 1fr 24px; }
[dir="rtl"] .nav span { grid-column: 2; grid-row: 1; }
[dir="rtl"] .nav a { text-align: right; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] .actions-cell { text-align: right; }
[dir="rtl"] .report-meta { text-align: left; }
[dir="rtl"] .company-ar { text-align: left; }
[dir="rtl"] .global-search { flex-direction: row-reverse; }
[dir="rtl"] .topbar, [dir="rtl"] .page-head, [dir="rtl"] .panel-head { direction: rtl; }
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .topbar, .page-head { flex-direction: column; align-items: stretch; height: auto; padding: 16px; }
    .global-search { width: 100%; }
    .stats-grid, .form-grid.two, .form-grid.four, .check-grid, .check-grid.four-cols, .check-grid.three-cols { grid-template-columns: 1fr; }
    .content { padding: 16px; }
}
@media print {
    @page { margin: 34mm 12mm 14mm; }
    .sidebar, .topbar, .page-head, .button-row { display: none !important; }
    .shell { display: block; }
    .content { padding: 0; }
    .report-sheet { border: 0; }
    .print-body .report-repeat-header { display: block; position: fixed; top: 0; left: 0; right: 0; height: 28mm; padding: 0; text-align: right; }
    .print-body .report-repeat-header .report-brand { margin-left: auto; width: 58mm; }
    .print-body .report-repeat-header .report-logo { width: 42mm; max-height: 18mm; }
    .print-body .report-sheet { margin-top: 0; }
}
