/* ===== index.php ===== */
:root {
    --ink: #1f1b16;
    --muted: #7b6f62;
    --paper: #fffaf1;
    --panel: rgba(255, 255, 255, 0.88);
    --line: #e7d8bd;
    --gold: #b9872d;
    --gold-dark: #79531b;
    --sage: #66785f;
    --danger: #b63c31;
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 15px;
    background:
        radial-gradient(circle at 14% 10%, rgba(185, 135, 45, 0.18), transparent 28%),
        radial-gradient(circle at 88% 14%, rgba(102, 120, 95, 0.18), transparent 30%),
        linear-gradient(135deg, #fff8e8 0%, #f4ead6 48%, #eee0c4 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(121, 83, 27, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(121, 83, 27, 0.05) 1px, transparent 1px);
    background-size: 46px 46px;
}

.app-shell {
    position: relative;
    width: min(1180px, calc(100% - 34px));
    margin: 34px auto;
}

.main-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
    border: 1px solid rgba(185, 135, 45, 0.26);
    border-radius: 999px;
    padding: 10px 12px 10px 18px;
    background: rgba(255, 255, 255, 0.68);
    box-shadow: 0 18px 42px rgba(77, 56, 24, 0.11);
    backdrop-filter: blur(16px);
}

.nav-only {
    justify-content: flex-start;
}

.menu-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: bold;
    letter-spacing: 0.04em;
}

.menu-brand::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    box-shadow: 0 0 0 5px rgba(185, 135, 45, 0.16);
}

.menu-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.menu-links a,
.menu-links button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 999px;
    padding: 0 15px;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    background: transparent;
    box-shadow: none;
}

.menu-links a:hover,
.menu-links button:hover {
    color: var(--ink);
    background: #fff7e4;
}

.menu-links .active {
    color: #fffaf1;
    background: linear-gradient(135deg, var(--ink), #5a3d17);
}

.menu-links .active {
    color: #ffffff;
    background: var(--gold);
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold-dark);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(34px, 5vw, 62px);
    line-height: 0.95;
    letter-spacing: -0.05em;
}

.hero-note {
    max-width: 310px;
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
    text-align: right;
}

.gold-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
    border: 1px solid rgba(185, 135, 45, 0.3);
    border-radius: 24px;
    padding: 18px 20px;
    background:
        linear-gradient(135deg, rgba(31, 27, 22, 0.94), rgba(98, 68, 25, 0.9)),
        radial-gradient(circle at 10% 0%, rgba(255, 229, 161, 0.22), transparent 34%);
    color: #fffaf1;
    box-shadow: 0 18px 46px rgba(77, 56, 24, 0.18);
}

.gold-card .eyebrow {
    color: rgba(255, 224, 157, 0.86);
}

.gold-title {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.03em;
}

.gold-source {
    margin: 7px 0 0;
    color: rgba(255, 248, 232, 0.7);
}

.gold-source a {
    color: #ffe09d;
    font-weight: bold;
    text-decoration: none;
}

.gold-refresh {
    margin-top: 12px;
    width: auto;
    min-height: 34px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 248, 232, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff8e8;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}

.gold-refresh:hover {
    background: rgba(255, 255, 255, 0.18);
}

.gold-refresh:disabled {
    cursor: wait;
    opacity: 0.68;
}

.gold-prices {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 10px;
}

.gold-price {
    min-width: 124px;
    border: 1px solid rgba(255, 248, 232, 0.16);
    border-radius: 18px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.08);
}

.gold-price span {
    display: block;
    color: rgba(255, 248, 232, 0.64);
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.gold-price strong {
    display: block;
    margin-top: 5px;
    font-size: 20px;
}

.invoice-card {
    overflow: hidden;
    border: 1px solid rgba(185, 135, 45, 0.28);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: 0 24px 70px rgba(77, 56, 24, 0.18);
    backdrop-filter: blur(18px);
}

.contacts-panel {
    margin-top: 26px;
    border: 1px solid rgba(185, 135, 45, 0.28);
    border-radius: 28px;
    padding: 26px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 20px 56px rgba(77, 56, 24, 0.12);
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.section-heading h2 {
    margin: 0;
    font-size: 34px;
    letter-spacing: -0.04em;
}

.section-heading p {
    max-width: 360px;
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
    text-align: right;
}

.contact-list {
    display: grid;
    gap: 10px;
}

.contact-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    background: #fffdf7;
}

.contact-name {
    font-weight: bold;
}

.contact-phone {
    color: var(--muted);
}

.empty-state {
    border: 1px dashed rgba(185, 135, 45, 0.55);
    border-radius: 18px;
    padding: 20px;
    color: var(--muted);
    text-align: center;
    background: rgba(255, 250, 241, 0.72);
}

.card-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 26px;
    color: #fff8e8;
    background:
        linear-gradient(120deg, rgba(31, 27, 22, 0.95), rgba(89, 62, 24, 0.92)),
        repeating-linear-gradient(90deg, transparent 0 16px, rgba(255,255,255,0.06) 16px 17px);
}

.brand-mark {
    font-size: 26px;
    font-weight: bold;
    letter-spacing: 0.04em;
}

.band-meta {
    color: rgba(255, 248, 232, 0.72);
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.form-body {
    padding: 26px;
}

.customer-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

input {
    width: 100%;
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 13px;
    color: var(--ink);
    font: inherit;
    background: rgba(255, 255, 255, 0.72);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus {
    border-color: var(--gold);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(185, 135, 45, 0.16);
}

.items-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #fffdf7;
}

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

th {
    padding: 14px 12px;
    color: #fffaf1;
    font-size: 12px;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    background: var(--ink);
}

td {
    border-top: 1px solid var(--line);
    padding: 10px;
    text-align: center;
}

td input {
    min-width: 84px;
    margin: 0;
    border-radius: 12px;
    text-align: center;
}

td:nth-child(2) input { min-width: 210px; text-align: left; }

.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 22px;
}

.button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

button {
    border: 0;
    border-radius: 999px;
    padding: 13px 20px;
    color: #fffaf1;
    font: inherit;
    font-weight: bold;
    cursor: pointer;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    box-shadow: 0 12px 28px rgba(121, 83, 27, 0.22);
}

button.secondary {
    color: var(--ink);
    background: #fff7e4;
    border: 1px solid var(--line);
    box-shadow: none;
}

.total-box {
    min-width: 300px;
    padding: 18px 20px;
    border-radius: 22px;
    color: #fffaf1;
    background: linear-gradient(135deg, var(--sage), #33402f);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}

.total-box label { color: rgba(255, 248, 232, 0.7); }
.total-box input {
    border: 0;
    padding: 0;
    color: #fff;
    font-size: 30px;
    font-weight: bold;
    background: transparent;
    box-shadow: none;
}

#arabicTotal {
    margin-top: 16px;
    padding: 16px;
    border: 1px dashed rgba(185, 135, 45, 0.55);
    border-radius: 18px;
    color: var(--gold-dark);
    text-align: center;
    font-size: 19px;
    font-weight: bold;
    direction: rtl;
    background: rgba(255, 250, 241, 0.72);
}

.success, .error {
    margin-bottom: 18px;
    border-radius: 16px;
    padding: 12px 14px;
}

.success {
    color: #285b37;
    background: #e9f5e8;
}

.error {
    color: var(--danger);
    background: #fff0ee;
}

@media (max-width: 760px) {
    .main-menu {
        align-items: stretch;
        border-radius: 24px;
        flex-direction: column;
        padding: 16px;
    }

    .menu-links {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .hero, .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .hero-note { text-align: left; }
    .gold-card,
    .gold-prices {
        grid-template-columns: 1fr;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-heading p { text-align: left; }
    .contact-row { grid-template-columns: 1fr; }
    .customer-grid { grid-template-columns: 1fr; }
    .total-box { min-width: 0; }
}

/* Business theme override */
:root {
    --ink: #172033;
    --muted: #667085;
    --paper: #ffffff;
    --panel: #ffffff;
    --line: #d8dee9;
    --gold: #2563eb;
    --gold-dark: #1d4ed8;
    --sage: #0f766e;
    --danger: #b42318;
}

body {
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: #ffffff;
}

body::before { display: none; }

.app-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 24px auto;
}

.main-menu,
.invoice-card,
.gold-card,
.contacts-panel,
.items-wrap,
.total-box,
#arabicTotal,
input,
button,
.contact-row {
    border-radius: 8px;
    box-shadow: none;
}

.main-menu {
    border-color: var(--line);
    padding: 12px 16px;
    background: #ffffff;
}

.menu-brand::before {
    border-radius: 3px;
    background: var(--gold);
    box-shadow: none;
}

.menu-links a,
.menu-links button {
    min-height: 36px;
    border-radius: 6px;
    color: #344054;
    font-size: 14px;
}

.menu-links .active,
button {
    background: var(--gold);
    color: #ffffff;
}

.hero {
    align-items: center;
    margin-bottom: 18px;
}

.eyebrow {
    color: var(--muted);
    letter-spacing: 0.08em;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -0.02em;
}

.hero-note {
    color: var(--muted);
}

.invoice-hero {
    display: flex;
    align-items: center;
    gap: 22px;
}

.hero-logo {
    display: block;
    width: 150px;
    height: 110px;
    object-fit: contain;
    object-position: center;
    mix-blend-mode: multiply;
}

.invoice-hero-title h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}

.hero-page-label {
    margin: 14px 0 0;
    color: #344054;
    font-size: 18px;
    font-weight: 700;
}

.gold-card {
    border-color: var(--line);
    background: #ffffff;
    color: var(--ink);
}

.gold-card .eyebrow,
.gold-source,
.gold-source a {
    color: var(--muted);
}

.gold-refresh {
    border-color: var(--line);
    background: #f8fafc;
    color: var(--ink);
}

.gold-refresh:hover {
    background: #eef2f7;
}

.gold-price {
    border-color: var(--line);
    background: #f8fafc;
}

.gold-price span {
    color: var(--muted);
}

.card-band {
    padding: 16px 20px;
    color: #ffffff;
    background: #172033;
}

.brand-mark {
    font-size: 20px;
}

.band-meta {
    color: #cbd5e1;
}

.form-body {
    padding: 20px;
}

label {
    color: #475467;
    letter-spacing: 0.04em;
}

input {
    border-color: var(--line);
    background: #ffffff;
}

input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

th {
    background: #eef2f7;
    color: #344054;
    letter-spacing: 0.05em;
}

td {
    border-top-color: var(--line);
}

button.secondary {
    color: #344054;
    background: #ffffff;
    border-color: var(--line);
}

.total-box {
    background: #172033;
}

#arabicTotal {
    border-style: solid;
    color: #344054;
    background: #f8fafc;
}

/* ===== contacts.php ===== */
:root {
    --ink: #1f1b16;
    --muted: #7b6f62;
    --line: #e7d8bd;
    --gold: #b9872d;
    --gold-dark: #79531b;
    --paper: #fffaf1;
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: Georgia, "Times New Roman", serif;
    background:
        radial-gradient(circle at 14% 10%, rgba(185, 135, 45, 0.18), transparent 28%),
        radial-gradient(circle at 88% 14%, rgba(102, 120, 95, 0.18), transparent 30%),
        linear-gradient(135deg, #fff8e8 0%, #f4ead6 48%, #eee0c4 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(121, 83, 27, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(121, 83, 27, 0.05) 1px, transparent 1px);
    background-size: 46px 46px;
}

.app-shell {
    position: relative;
    width: min(1100px, calc(100% - 34px));
    margin: 34px auto;
}

.main-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
    border: 1px solid rgba(185, 135, 45, 0.26);
    border-radius: 999px;
    padding: 10px 12px 10px 18px;
    background: rgba(255, 255, 255, 0.68);
    box-shadow: 0 18px 42px rgba(77, 56, 24, 0.11);
    backdrop-filter: blur(16px);
}

.menu-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: bold;
    letter-spacing: 0.04em;
}

.menu-brand::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    box-shadow: 0 0 0 5px rgba(185, 135, 45, 0.16);
}

.menu-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.menu-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 999px;
    padding: 0 15px;
    color: var(--muted);
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
}

.menu-links a:hover {
    color: var(--ink);
    background: #fff7e4;
}

.menu-links .active {
    color: #fffaf1;
    background: linear-gradient(135deg, var(--ink), #5a3d17);
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold-dark);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(36px, 5vw, 64px);
    line-height: 0.95;
    letter-spacing: -0.05em;
}

.hero-note {
    max-width: 330px;
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
    text-align: right;
}

.contacts-panel {
    border: 1px solid rgba(185, 135, 45, 0.28);
    border-radius: 28px;
    padding: 26px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 20px 56px rgba(77, 56, 24, 0.12);
}

.contacts-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.4fr);
    gap: 18px;
    align-items: start;
}

.search-box {
    width: 100%;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    color: var(--ink);
    font: inherit;
    background: #fffdf7;
    outline: none;
}

.search-box:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(185, 135, 45, 0.16);
}

.contact-list {
    display: grid;
    gap: 10px;
}

.contact-row {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    color: var(--ink);
    font: inherit;
    text-align: left;
    background: #fffdf7;
    cursor: pointer;
}

.contact-row:hover,
.contact-row.active {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(185, 135, 45, 0.12);
}

.contact-id {
    color: var(--gold-dark);
    font-weight: bold;
}

.contact-name {
    font-weight: bold;
}

.contact-phone {
    color: var(--muted);
}

.contact-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
}

.pill {
    border-radius: 999px;
    padding: 5px 9px;
    color: var(--gold-dark);
    background: #fff4da;
}

.invoice-panel {
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 18px;
    background: #fffdf7;
}

.invoice-panel[hidden] {
    display: none;
}

.invoice-panel h2 {
    margin: 0 0 4px;
    font-size: 28px;
    letter-spacing: -0.04em;
}

.invoice-panel .subtitle {
    margin: 0 0 16px;
    color: var(--muted);
}

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

.invoice-table th,
.invoice-table td {
    border-bottom: 1px solid var(--line);
    padding: 11px 9px;
    text-align: left;
}

.invoice-table th {
    color: var(--gold-dark);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.invoice-table a {
    display: inline-flex;
    margin-right: 8px;
    color: var(--gold-dark);
    font-weight: bold;
    text-decoration: none;
}

.empty-state {
    border: 1px dashed rgba(185, 135, 45, 0.55);
    border-radius: 18px;
    padding: 20px;
    color: var(--muted);
    text-align: center;
    background: rgba(255, 250, 241, 0.72);
}

@media (max-width: 760px) {
    .main-menu,
    .hero {
        align-items: stretch;
        flex-direction: column;
    }

    .main-menu {
        border-radius: 24px;
        padding: 16px;
    }

    .menu-links {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .hero-note {
        text-align: left;
    }

    .contact-row {
        grid-template-columns: 1fr;
    }

    .contacts-layout {
        grid-template-columns: 1fr;
    }

    .invoice-table {
        display: block;
        overflow-x: auto;
    }
}

/* Business theme override */
:root {
    --ink: #172033;
    --muted: #667085;
    --line: #d8dee9;
    --gold: #2563eb;
    --gold-dark: #1d4ed8;
    --paper: #ffffff;
}

body {
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: #ffffff;
}

body::before { display: none; }

.app-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 24px auto;
}

.main-menu,
.contacts-panel,
.search-box,
.contact-row,
.invoice-panel,
.empty-state {
    border-radius: 8px;
    box-shadow: none;
}

.main-menu,
.contacts-panel {
    border-color: var(--line);
    background: #ffffff;
}

.main-menu {
    padding: 12px 16px;
}

.menu-brand::before {
    border-radius: 3px;
    background: var(--gold);
    box-shadow: none;
}

.menu-links a {
    min-height: 36px;
    border-radius: 6px;
    color: #344054;
}

.menu-links .active {
    color: #ffffff;
    background: var(--gold);
}

.eyebrow {
    color: var(--muted);
    letter-spacing: 0.08em;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -0.02em;
}

.hero-note,
.contact-phone,
.contact-meta,
.subtitle {
    color: var(--muted);
}

.search-box,
.contact-row,
.invoice-panel {
    border-color: var(--line);
    background: #ffffff;
}

.search-box:focus,
.contact-row:hover,
.contact-row.active {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.pill {
    color: #1d4ed8;
    background: #eff6ff;
}

.invoice-table th {
    color: #344054;
    background: #f8fafc;
}

.invoice-table a {
    color: var(--gold);
}

/* ===== print.php ===== */
@page {
    size: A4;
    margin: 0;
}

:root {
    --ink: #211b14;
    --muted: #756858;
    --line: #d9c59d;
    --paper: #fffaf0;
    --gold: #b9872d;
    --sage: #5f7057;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    font-family: Georgia, "Times New Roman", serif;
    background: #eee1c8;
}

.print-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: min(1000px, calc(100% - 34px));
    margin: 24px auto 18px;
    border: 1px solid rgba(185, 135, 45, 0.26);
    border-radius: 999px;
    padding: 10px 12px 10px 18px;
    background: rgba(255, 255, 255, 0.74);
    box-shadow: 0 18px 42px rgba(77, 56, 24, 0.11);
    backdrop-filter: blur(16px);
}

.menu-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: bold;
    letter-spacing: 0.04em;
}

.menu-brand::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), #79531b);
    box-shadow: 0 0 0 5px rgba(185, 135, 45, 0.16);
}

.menu-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.menu-links a,
.menu-links button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 999px;
    padding: 0 15px;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    background: transparent;
    cursor: pointer;
}

.menu-links a:hover,
.menu-links button:hover {
    color: var(--ink);
    background: #fff7e4;
}

.menu-links .active {
    color: #fffaf1;
    background: linear-gradient(135deg, var(--ink), #5a3d17);
}

.invoice-page {
    width: min(1000px, calc(100% - 34px));
    min-height: calc(297mm - 24mm);
    margin: 0 auto 24px;
    padding: 18mm;
    border: 1px solid var(--line);
    background:
        radial-gradient(circle at top left, rgba(185, 135, 45, 0.12), transparent 28%),
        linear-gradient(145deg, #fffdf7, var(--paper));
}

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--ink);
}

.brand {
    font-size: 52px;
    font-weight: bold;
    line-height: 0.9;
    letter-spacing: -0.05em;
}

.subtitle {
    margin-top: 8px;
    color: var(--gold);
    font-size: 17px;
    font-weight: bold;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.invoice-meta {
    align-self: center;
    text-align: right;
}

.invoice-title {
    margin: 0 0 14px;
    font-size: 28px;
    letter-spacing: 0.16em;
}

.meta-line {
    margin: 5px 0;
    color: var(--muted);
}

.meta-line strong {
    color: var(--ink);
}

.details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 22px 0;
}

.detail-card {
    min-height: 118px;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.62);
}

.detail-label {
    margin-bottom: 10px;
    color: var(--gold);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.detail-line {
    margin: 7px 0;
}

.items {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
}

.items th {
    padding: 12px 10px;
    color: #fffaf0;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--ink);
}

.items td {
    border-top: 1px solid var(--line);
    padding: 12px 10px;
    text-align: center;
    background: rgba(255, 255, 255, 0.54);
}

.items td.description {
    text-align: left;
}

.total-row td {
    color: #fffaf0;
    font-weight: bold;
    background: var(--sage);
}

.total-row td:first-child {
    text-align: right;
    letter-spacing: 0.08em;
}

.arabic-total {
    margin-top: 22px;
    padding: 17px;
    border: 1px dashed rgba(185, 135, 45, 0.78);
    border-radius: 18px;
    color: #6d4915;
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    direction: rtl;
    background: rgba(255, 248, 232, 0.8);
}

.notes {
    margin-top: 16px;
    color: var(--muted);
    text-align: right;
    line-height: 1.8;
    direction: rtl;
}

@media print {
    html,
    body {
        width: 210mm;
        min-height: 297mm;
        background: #fff;
    }

    .print-menu { display: none; }
    .invoice-page {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 14mm;
        border: 0;
        box-shadow: none;
    }
}

@media (max-width: 760px) {
    .print-menu {
        align-items: stretch;
        border-radius: 24px;
        flex-direction: column;
        padding: 16px;
    }

    .menu-links {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .details,
    .topbar {
        grid-template-columns: 1fr;
    }

    .invoice-meta {
        text-align: left;
    }
}

/* Business print theme override */
:root {
    --ink: #172033;
    --muted: #667085;
    --line: #d8dee9;
    --paper: #ffffff;
    --gold: #2563eb;
    --sage: #172033;
}

body {
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: #ffffff;
}

.print-menu,
.invoice-page,
.detail-card,
.items,
.arabic-total {
    border-radius: 8px;
    box-shadow: none;
}

.print-menu {
    border-color: var(--line);
    background: #ffffff;
}

.menu-brand::before {
    border-radius: 3px;
    background: var(--gold);
    box-shadow: none;
}

.menu-links a,
.menu-links button {
    border-radius: 6px;
    color: #344054;
}

.menu-links .active {
    color: #ffffff;
    background: var(--gold);
}

.invoice-page {
    border-color: var(--line);
    background: #ffffff;
}

.topbar {
    border-bottom-color: var(--line);
}

.brand {
    font-size: 42px;
    letter-spacing: -0.02em;
}

.subtitle,
.detail-label {
    color: var(--muted);
    letter-spacing: 0.08em;
}

.invoice-title {
    font-size: 24px;
    letter-spacing: 0.08em;
}

.print-logo {
    display: block;
    width: 320px;
    max-width: 100%;
    height: 120px;
    object-fit: contain;
    object-position: left center;
    mix-blend-mode: multiply;
}

.detail-card,
.items,
.arabic-total {
    border-color: var(--line);
    background: #ffffff;
}

.items th {
    color: #344054;
    background: #eef2f7;
}

.items td {
    border-top-color: var(--line);
}

.total-row td {
    background: #172033;
}

.arabic-total {
    color: #344054;
    border-style: solid;
    background: #f8fafc;
}

@media print {
    body,
    .invoice-page {
        background: #ffffff;
    }
}

/* Keep the printed invoice visually aligned with print.php. */
body.print-page {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body.print-page {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        background: #ffffff;
    }

    body.print-page .print-menu {
        display: none !important;
    }

    body.print-page .invoice-page {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 18mm;
        border: 0;
        border-radius: 0;
        background: #ffffff;
        box-shadow: none;
    }

body.print-page .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

body.print-page .invoice-meta {
    align-self: center;
    text-align: right;
}

    body.print-page .details {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        margin: 22px 0;
    }

    body.print-page .detail-card,
    body.print-page .items,
    body.print-page .arabic-total {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #ffffff;
    }

    body.print-page .items th {
        color: #344054;
        background: #eef2f7;
    }

    body.print-page .items td {
        background: #ffffff;
    }

    body.print-page .total-row td {
        color: #ffffff;
        background: #172033;
    }
}

