:root {
    --navy: #0D1B3E;
    --navy-mid: #1A2F5E;
    --gold: #C9A84C;
    --gold-light: #E8D08A;
    --gold-pale: #FDF8ED;
    --slate: #4A5568;
    --light-bg: #F7F9FC;
    --border: #E2E8F0;
    --text: #1A202C;
    --muted: #718096;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background: #EAECF2;
    color: var(--text);
    direction: rtl;
}

/* ─── SWITCHER ─── */
.switcher {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 24px;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.switcher span {
    color: var(--gold-light);
    font-size: 13px;
    letter-spacing: 0.5px;
}

.tab-btn {
    background: transparent;
    border: 1.5px solid rgba(201, 168, 76, 0.4);
    color: #adb5c8;
    padding: 7px 22px;
    border-radius: 50px;
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
    font-weight: 700;
}

.tab-btn:hover:not(.active) {
    border-color: var(--gold);
    color: var(--gold-light);
}

.print-btn {
    background: transparent;
    border: 1.5px solid rgba(201, 168, 76, 0.4);
    color: #adb5c8;
    padding: 7px 18px;
    border-radius: 50px;
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: auto;
}

.print-btn:hover {
    border-color: var(--gold);
    color: var(--gold-light);
}

/* ─── PAGE WRAPPER ─── */
.page-wrap {
    padding: 76px 24px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ─── DOCUMENT SHEET ─── */
.doc-sheet {
    width: 100%;
    max-width: 820px;
    background: #fff;
    box-shadow: 0 4px 40px rgba(13, 27, 62, 0.15);
    border-radius: 4px;
    overflow: hidden;
    display: none;
}

.doc-sheet.active {
    display: block;
}

/* ─── HEADER BAND ─── */
.doc-header {
    background: var(--navy);
    position: relative;
    overflow: hidden;
    padding: 0;
}

.header-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 36px 22px;
}

/* Logo Area */
.logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-box {
    width: 62px;
    height: 62px;
    border: 2px solid var(--gold);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(201, 168, 76, 0.08);
}

.logo-box .logo-letter {
    font-size: 22px;
    font-weight: 900;
    color: var(--gold);
    line-height: 1;
}

.logo-box .logo-sub {
    font-size: 8px;
    color: var(--gold-light);
    letter-spacing: 1px;
    margin-top: 2px;
    text-transform: uppercase;
}

.company-info h1 {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

.company-info p {
    color: #8A9BB8;
    font-size: 11px;
    margin-top: 2px;
}

.company-tagline {
    color: var(--gold-light);
    font-size: 10px;
    margin-top: 3px;
    letter-spacing: 0.5px;
}

/* Doc Title Badge */
.doc-title-badge {
    text-align: left;
}

.doc-type-ar {
    display: block;
    color: var(--gold);
    font-size: 26px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.5px;
}

.doc-type-en {
    display: block;
    color: #8A9BB8;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* ─── META BAR ─── */
.meta-bar {
    background: var(--navy-mid);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 36px;
    flex-wrap: wrap;
    gap: 8px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.meta-label {
    color: #6B7FA3;
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.meta-value {
    color: #E0E8F5;
    font-size: 12px;
    font-weight: 600;
}

.meta-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
}

/* ─── BODY ─── */
.doc-body {
    padding: 32px 36px;
}

/* Client & Info Row */
.info-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    margin-bottom: 28px;
}

.client-card {
    background: var(--light-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    position: relative;
}

.client-card::before {
    content: '';
    position: absolute;
    right: 0;
    top: 12px;
    bottom: 12px;
    width: 3px;
    background: var(--gold);
    border-radius: 0 3px 3px 0;
}

.card-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

.client-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy);
}

.client-details {
    font-size: 12px;
    color: var(--slate);
    margin-top: 6px;
    line-height: 1.8;
}

.validity-card {
    background: var(--gold-pale);
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 10px;
    padding: 16px 20px;
    text-align: center;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.validity-label {
    font-size: 10px;
    color: #9A7B2C;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.validity-value {
    font-size: 22px;
    font-weight: 900;
    color: var(--navy);
}

.validity-unit {
    font-size: 11px;
    color: var(--slate);
}

/* ─── TABLE ─── */
.items-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--navy);
    padding-bottom: 6px;
    margin-bottom: 0;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.items-table thead tr {
    background: var(--navy);
}

.items-table thead th {
    padding: 10px 14px;
    color: var(--gold-light);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-align: right;
}

.items-table thead th:last-child {
    text-align: left;
}

.items-table thead th.center {
    text-align: center;
}

.items-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.items-table tbody tr:nth-child(even) {
    background: #FAFBFD;
}

.items-table tbody tr:hover {
    background: #F0F4FB;
}

.items-table td {
    padding: 11px 14px;
    vertical-align: top;
}

.items-table td.center {
    text-align: center;
}

.items-table td.num {
    text-align: left;
    font-weight: 600;
}

.item-name {
    font-weight: 700;
    color: var(--navy);
    font-size: 13px;
}

.item-desc {
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
}

.row-num {
    width: 26px;
    height: 26px;
    background: var(--navy);
    border-radius: 50%;
    color: var(--gold-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

/* ─── TOTALS ─── */
.bottom-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    align-items: start;
}

.notes-box {
    background: var(--light-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
}

.notes-box .card-label {
    margin-bottom: 8px;
}

.notes-text {
    font-size: 12px;
    color: var(--slate);
    line-height: 1.9;
}

.totals-box {
    min-width: 240px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.total-row:last-child {
    border-bottom: none;
}

.total-row .t-label {
    color: var(--muted);
}

.total-row .t-value {
    font-weight: 600;
    color: var(--text);
}

.total-row.grand {
    background: var(--navy);
    margin: 8px -1px -1px;
    border-radius: 10px;
    padding: 12px 16px;
    border: none;
}

.total-row.grand .t-label {
    color: var(--gold-light);
    font-size: 12px;
    font-weight: 700;
}

.total-row.grand .t-value {
    color: var(--gold);
    font-size: 20px;
    font-weight: 900;
}

/* ─── BANK / PAYMENT ─── */
.bank-section {
    margin-top: 24px;
    background: var(--light-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
}

.bank-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-top: 10px;
}

.bank-item .b-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.bank-item .b-val {
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
}

/* ─── SIGNATURE ─── */
.sig-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 28px;
}

.sig-block {
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    text-align: center;
}

.sig-title {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 40px;
}

.sig-line {
    border-top: 1.5px solid var(--navy);
    margin-top: 8px;
}

.sig-name {
    font-size: 12px;
    color: var(--slate);
    margin-top: 6px;
}

/* ─── STATUS BADGE ─── */
.status-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 700;
}

.status-pending {
    background: #FEF3C7;
    color: #92400E;
}

.status-paid {
    background: #D1FAE5;
    color: #064E3B;
}

/* ─── FOOTER ─── */
.doc-footer {
    background: var(--navy-mid);
    border-top: 3px solid var(--gold);
    padding: 14px 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-text {
    color: #6B7FA3;
    font-size: 11px;
}

.footer-brand {
    color: var(--gold-light);
    font-size: 12px;
    font-weight: 700;
}

/* ─── PRINT ─── */
@media print {
    body {
        background: white;
    }

    .switcher {
        display: none !important;
    }

    .page-wrap {
        padding: 0;
    }

    .doc-sheet {
        display: block !important;
        box-shadow: none;
        max-width: 100%;
        page-break-after: always;
    }

    .doc-sheet:last-child {
        page-break-after: auto;
    }

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

@page {
    margin: 12mm;
}