/* ============================================
   PRECIOUS METALS REGISTRY — Stylesheet
   Aesthetic: Refined luxury / editorial gold
   ============================================ */

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

:root {
    --gold:        #c9a84c;
    --gold-light:  #e8c97a;
    --gold-pale:   #f5f0e8;
    --ink:         #1a1208;
    --ink-mid:     #3d3020;
    --ink-light:   #e2dace;
    --surface:     #faf7f2;
    --surface-2:   #f0ead8;
    --border:      rgba(201,168,76,0.25);
    --border-strong: rgba(201,168,76,0.55);
    --success:     #3d7a4a;
    --error:       #8b2c2c;
    --radius:      4px;
    --font-serif:  'Cormorant Garamond', Georgia, serif;
    --font-mono:   'JetBrains Mono', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    background-color: var(--ink);
    color: var(--surface);
    font-family: var(--font-serif);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* ── Grain Texture ── */
.grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* ── Header ── */
header {
    background: linear-gradient(180deg, rgb(223, 166, 97) 0%, rgba(26,18,8,0.98) 100%);
    border-bottom: 1px solid var(--border-strong);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.65rem 0;
    min-height: 56px;
    position: relative;   /* contain the absolutely-positioned nav */
}

.logo-mark {
    width: 40px;
    height: 40px;
    color: var(--gold);
    flex-shrink: 0;
}
.logo-mark svg { width: 100%; height: 100%; }

.header-text {
    flex-shrink: 0;
    min-width: 0;
}
.header-text h1 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--gold-light);
    text-transform: uppercase;
    white-space: nowrap;
}
.header-text span {
    font-size: 0.55rem;
    letter-spacing: 0.16em;
    color: var(--ink-light);
    text-transform: uppercase;
    font-family: var(--font-mono);
    display: block;
    white-space: nowrap;
}

/* Header inner needs position:relative for centered nav */
.header-inner {
    position: relative;
}

/* Nav — absolutely centered in header */
nav {
    display: flex;
    gap: 0.2rem;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0.1rem 0;
    /* True center: */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    max-width: 60%;
}
nav::-webkit-scrollbar { display: none; }

/* Arabic nav order is handled server-side via array_reverse() in render_nav() */

.nav-link {
    font-family: var(--font-mono);
    font-size: 0.63rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-light);
    text-decoration: none;
    padding: 0.32rem 0.6rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.nav-link:hover, .nav-link.active {
    color: var(--gold-light);
    border-color: var(--border-strong);
    background: rgba(201,168,76,0.08);
}

/* Right-side controls: lang + user pill — always visible, never shrink */
.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-inline-start: auto;
}
.nav-link:hover, .nav-link.active {
    color: var(--gold-light);
    border-color: var(--border-strong);
    background: rgba(201,168,76,0.08);
}

/* ── Main ── */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
}

/* ── Page Title ── */
.page-title { margin-bottom: 2.5rem; }
.label-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--gold);
    letter-spacing: 0.2em;
    margin-bottom: 0.6rem;
}
.page-title h2 {
    font-size: 2.6rem;
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--gold-pale);
    line-height: 1.1;
}
.page-title h2 em { font-style: italic; color: var(--gold-light); }
.subtitle {
    margin-top: 0.75rem;
    font-size: 1rem;
    color: var(--ink-light);
    font-style: italic;
    max-width: 520px;
    line-height: 1.6;
}

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.75rem;
    font-size: 0.9rem;
    font-family: var(--font-mono);
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-error {
    background: rgba(139,44,44,0.15);
    border: 1px solid rgba(139,44,44,0.5);
    color: #e89090;
}

/* ── Success Panel ── */
.success-panel {
    background: linear-gradient(135deg, rgba(61,122,74,0.12) 0%, rgba(201,168,76,0.08) 100%);
    border: 1px solid rgba(61,122,74,0.4);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2.5rem;
    animation: slideIn 0.4s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.success-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(201,168,76,0.2);
}
.success-header svg { width: 28px; height: 28px; color: #6abf7a; flex-shrink: 0; }
.success-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--gold-light);
    letter-spacing: 0.04em;
}
.success-header span {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--ink-light);
    letter-spacing: 0.1em;
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: start;
}

.result-fields { display: flex; flex-direction: column; gap: 0.6rem; }
.field-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(201,168,76,0.1);
}
.field-label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.15em;
    color: var(--ink-light);
    text-transform: uppercase;
    min-width: 90px;
    flex-shrink: 0;
}
.field-value { font-size: 1rem; color: var(--gold-pale); }
.field-value.mono { font-family: var(--font-mono); font-size: 0.85rem; }

/* ── QR Container ── */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
}
#qrcode {
    background: var(--gold-pale);
    padding: 12px;
    border-radius: 6px;
    border: 2px solid var(--gold);
    box-shadow: 0 0 30px rgba(201,168,76,0.3);
}
#qrcode img, #qrcode canvas { display: block; }
.qr-caption {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--ink-light);
    text-transform: uppercase;
    text-align: center;
}
.btn-download {
    background:
        linear-gradient(
            180deg,
            #f5d96a 0%, #e8b830 8%, #d4940a 20%,
            #f0c830 35%, #f8e060 50%, #e0a810 65%,
            #c88a00 78%, #e8b830 90%, #f5d060 100%
        );
    color: #2a1a00;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-shadow: 0 1px 0 rgba(255,220,100,0.4);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(255,240,150,0.8) inset,
        0 -1px 0 rgba(100,60,0,0.5) inset,
        0 3px 8px rgba(180,120,0,0.4),
        0 1px 2px rgba(0,0,0,0.4);
}
.btn-download::before {
    content: '';
    position: absolute;
    top: 0; left: -60%; width: 45%; height: 100%;
    background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,0.3) 50%, transparent 80%);
    transform: skewX(-15deg);
    transition: left 0.4s ease;
    pointer-events: none;
}
.btn-download:hover::before { left: 110%; }
.btn-download:hover {
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255,240,150,0.9) inset,
        0 -1px 0 rgba(100,60,0,0.6) inset,
        0 6px 16px rgba(180,120,0,0.5),
        0 2px 4px rgba(0,0,0,0.4);
}
.btn-download:active { transform: translateY(0); }

/* QR action button group */
.qr-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}
.btn-pdf {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* ── Form ── */
.registry-form {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.form-section {
    padding: 2rem 2.5rem;
    border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; }

.section-title {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-light);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.section-title span {
    color: var(--gold);
    font-size: 0.8rem;
}
.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
.form-row.three-col { grid-template-columns: 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 0.45rem; }
.form-group.full-width { grid-column: 1 / -1; }

label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-light);
}

input[type="text"],
input[type="number"],
select {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--surface);
    font-family: var(--font-serif);
    font-size: 1rem;
    padding: 0.75rem 1rem;
    outline: none;
    transition: all 0.2s;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}
input::placeholder { color: rgba(201,168,76,0.6); font-style: italic; }

select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a6a50' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.8rem center; background-size: 18px; padding-right: 2.5rem; }
select option { background: var(--ink-mid); color: var(--surface); }

input:focus, select:focus {
    border-color: var(--gold);
    background: rgba(201,168,76,0.06);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.1);
}

input:valid:not(:placeholder-shown) { border-color: rgba(106,191,122,0.4); }

/* ── Form Footer ── */
.form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2.5rem;
    background: rgba(201,168,76,0.04);
    border-top: 1px solid var(--border);
}

.date-display {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--ink-light);
}
.date-display svg { width: 16px; height: 16px; color: var(--gold); flex-shrink: 0; }
.date-display strong { color: var(--gold-light); }

.btn-submit {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* ── Gold bar gradient — mimics the metallic slab ── */
    background:
        linear-gradient(
            180deg,
            #f5d96a 0%,
            #e8b830 8%,
            #d4940a 20%,
            #f0c830 35%,
            #f8e060 50%,
            #e0a810 65%,
            #c88a00 78%,
            #e8b830 90%,
            #f5d060 100%
        );
    color: #2a1a00;
    border: none;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-shadow: 0 1px 0 rgba(255,220,100,0.4);
    padding: 0.85rem 2rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(255,240,150,0.8) inset,       /* top highlight */
        0 -1px 0 rgba(100,60,0,0.5) inset,          /* bottom shadow */
        0 4px 12px rgba(180,120,0,0.45),             /* outer glow */
        0 1px 3px rgba(0,0,0,0.5);                   /* depth */
}
/* Diagonal sheen sweep — the bright reflection across the bar */
.btn-submit::before {
    content: '';
    position: absolute;
    top: 0; left: -60%;
    width: 45%; height: 100%;
    background: linear-gradient(
        105deg,
        transparent 20%,
        rgba(255,255,255,0.35) 50%,
        transparent 80%
    );
    transform: skewX(-15deg);
    transition: left 0.45s ease;
    pointer-events: none;
}
.btn-submit:hover::before { left: 110%; }
.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow:
        0 1px 0 rgba(255,240,150,0.9) inset,
        0 -1px 0 rgba(100,60,0,0.6) inset,
        0 8px 24px rgba(180,120,0,0.55),
        0 2px 6px rgba(0,0,0,0.5);
}
.btn-submit:active {
    transform: translateY(0);
    box-shadow:
        0 1px 0 rgba(255,240,150,0.6) inset,
        0 -1px 0 rgba(100,60,0,0.5) inset,
        0 2px 6px rgba(180,120,0,0.3),
        0 1px 2px rgba(0,0,0,0.4);
}
.btn-submit svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-submit.loading { opacity: 0.7; cursor: not-allowed; }

/* ── Records Table ── */
.records-wrapper { overflow-x: auto; margin-top: 2rem; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
thead tr {
    border-bottom: 2px solid var(--border-strong);
}
th {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    padding: 0.75rem 1rem;
    text-align: left;
}
tbody tr {
    border-bottom: 1px solid rgba(201,168,76,0.08);
    transition: background 0.15s;
}
tbody tr:hover { background: rgba(201,168,76,0.04); }
td {
    padding: 0.85rem 1rem;
    color: var(--gold-pale);
    vertical-align: middle;
}
td.mono { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-light); }
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.badge-gold     { background: rgba(201,168,76,0.15); color: var(--gold-light); border: 1px solid rgba(201,168,76,0.3); }
.badge-silver   { background: rgba(192,192,192,0.1); color: #d4d4d4; border: 1px solid rgba(192,192,192,0.3); }
.badge-platinum { background: rgba(200,220,240,0.1); color: #b8d4e8; border: 1px solid rgba(200,220,240,0.25); }
.badge-other    { background: rgba(255,255,255,0.06); color: #aaa; border: 1px solid rgba(255,255,255,0.15); }

.qr-thumb { cursor: pointer; transition: transform 0.2s; }
.qr-thumb:hover { transform: scale(1.1); }

/* QR Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal-hidden { display: none !important; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.modal-box {
    background: var(--ink-mid);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    max-width: 320px;
    width: 90%;
}
.modal-box h4 { font-size: 1.1rem; color: var(--gold-light); margin-bottom: 0.5rem; }
.modal-box p { font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-light); margin-bottom: 1.25rem; }
.modal-qr { background: var(--gold-pale); padding: 12px; border-radius: 6px; display: inline-block; margin-bottom: 1rem; }
.modal-close {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--ink-light);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.45rem 1.2rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}
.modal-close:hover { border-color: var(--gold); color: var(--gold-light); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--ink-light);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; color: var(--border-strong); }
.empty-state p { font-size: 1rem; font-style: italic; }

/* ── Footer ── */
footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--ink-light);
    letter-spacing: 0.1em;
}

/* ── Responsive ── */

/* Tablets (≤ 1024px) — shrink nav text */
@media (max-width: 1024px) {
    header { padding: 0 1.25rem; }
    .nav-link { font-size: 0.62rem; padding: 0.35rem 0.55rem; letter-spacing: 0.06em; }
    .header-text h1 { font-size: 1rem; }
    .user-name { max-width: 80px; }
}

/* Small tablets / large phones (≤ 768px) — hide tagline, shrink logo */
/* ── Desktop header layout ── */
@media (min-width: 769px) {
    .nav-hamburger       { display: none; }
    .header-mobile-row2  { display: none; }
    .header-brand        { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
    /* On desktop the user-pill logout label is hidden; show icon only */
    .logout-label        { display: none; }
}

/* ── Mobile (≤ 768px) ── */
@media (max-width: 768px) {
    /* Header wraps into two rows */
    .header-inner {
        flex-wrap: wrap;
        padding: 0.5rem 0.75rem 0;
        gap: 0;
        align-items: center;
        position: relative;   /* needed for absolute-positioned brand to centre correctly */
        min-height: 42px;
    }

    /* ── Row 1: [☰ LEFT]  [logo CENTRE - absolute]  [controls RIGHT] ── */
    .nav-hamburger {
        display: flex;
        order: 1;
        flex-shrink: 0;
    }
    .header-brand {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        order: 2;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        flex-shrink: 0;
    }
    .logo-mark { width: 33px; height: 33px; }
    .header-text h1   { font-size: 0.82rem; }
    .header-text span { display: none; }

    /* Hide desktop nav and lang switcher; hide user pill on mobile row 1 */
    header nav                      { display: none !important; }
    .header-controls                { display: flex !important; align-items: center; order: 3; flex-shrink: 0; margin-inline-start: auto; }
    .header-controls .lang-switcher { display: none; }   /* lang goes to row 2 */
    .header-controls .user-pill     { display: none; }   /* user goes to row 2 */

    /* ── Row 2: [🇬🇧🇸🇦 lang LEFT] ......... [Sign Out RIGHT] ── */
    .header-mobile-row2 {
        display: flex;
        align-items: center;
        order: 10;
        width: 100%;
        padding: 0.4rem 0 0.45rem;
        border-top: 1px solid rgba(201,168,76,0.12);
        margin-top: 0.35rem;
    }
    .header-mobile-row2 .lang-switcher {
        display: flex;
        gap: 0.25rem;
        /* sits at the left */
    }
    .header-mobile-row2 .lang-btn {
        font-size: 0.7rem;
        padding: 0.28rem 0.6rem;
        opacity: 1;
    }
    .mobile-logout {
        margin-inline-start: auto;
    }
    .mobile-logout-link {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        color: var(--ink-light);
        text-decoration: none;
        font-family: var(--font-mono);
        font-size: 0.68rem;
        letter-spacing: 0.06em;
        padding: 0.25rem 0.5rem;
        border: 1px solid var(--border);
        border-radius: 20px;
        transition: all 0.18s;
    }
    .mobile-logout-link:hover {
        color: #e87878;
        border-color: rgba(220,100,100,0.4);
        background: rgba(220,100,100,0.08);
    }
    .mobile-logout-link svg { width: 14px; height: 14px; flex-shrink: 0; }
    .mobile-logout-name {
        color: var(--gold-pale);
        font-size: 0.65rem;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Dropdown top accounts for two-row header */
    .nav-dropdown-backdrop { top: 78px; }
    .nav-dropdown-panel    { top: 78px; }

    /* Page layout */
    .user-role-badge { display: none; }
    main { padding: 2rem 1rem 4rem; }
    .form-section { padding: 1.5rem 1.25rem; }
    .form-row, .form-row.three-col { grid-template-columns: 1fr; }
    .form-footer { flex-direction: column; gap: 1.25rem; align-items: stretch; }
    .btn-submit { justify-content: center; }
    .result-grid { grid-template-columns: 1fr; }
    .qr-container { margin-top: 1rem; }
    .page-title h2 { font-size: 1.9rem; }
}

@media (max-width: 540px) {
    .header-text h1 { font-size: 0.74rem; }
    .nav-dropdown-backdrop { top: 74px; }
    .nav-dropdown-panel    { top: 74px; }
}

/* ── Mobile scan nav link ── */
.nav-mobile {
    background: rgba(201,168,76,0.08);
    border: 1px solid rgba(201,168,76,0.3) !important;
    color: var(--gold-light) !important;
    font-size: 0.68rem !important;
}
.nav-mobile:hover {
    background: rgba(201,168,76,0.18) !important;
    box-shadow: 0 0 12px rgba(201,168,76,0.2);
}

/* ── Status badges ── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.22rem 0.7rem;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
}
.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
/* manufactured — light grey */
.status-available, .status-manufactured {
    background: rgba(180,180,180,0.12);
    color: #c8c8c8;
    border: 1px solid rgba(200,200,200,0.3);
}
.status-available::before, .status-manufactured::before { background: #aaaaaa; box-shadow: 0 0 5px rgba(200,200,200,0.4); }

/* distributor — blue */
.status-distributor {
    background: rgba(40,120,220,0.15);
    color: #6ab0f5;
    border: 1px solid rgba(80,160,240,0.35);
}
.status-distributor::before { background: #4090e0; box-shadow: 0 0 5px rgba(80,160,240,0.6); }

/* sold — green */
.status-market, .status-sold {
    background: rgba(46,160,100,0.15);
    color: #5cd490;
    border: 1px solid rgba(60,180,110,0.35);
}
.status-market::before, .status-sold::before { background: #3cb878; box-shadow: 0 0 5px rgba(60,180,110,0.6); }

/* registered — bright gold */
.status-registered {
    background: rgba(201,168,76,0.18);
    color: #f5d060;
    border: 1px solid rgba(230,190,80,0.5);
}
.status-registered::before { background: #e8c040; box-shadow: 0 0 8px rgba(230,190,80,0.7); }

/* melted — amber (unchanged) */
.status-melted {
    background: rgba(184,100,18,0.18);
    color: #f0a84e;
    border: 1px solid rgba(220,145,60,0.35);
}
.status-melted::before { background: #dc913c; box-shadow: 0 0 5px rgba(220,145,60,0.7); }

/* destroyed — red (unchanged) */
.status-destroyed {
    background: rgba(139,44,44,0.18);
    color: #e87878;
    border: 1px solid rgba(220,100,100,0.35);
}
.status-destroyed::before { background: #dc6464; box-shadow: 0 0 5px rgba(220,100,100,0.7); }

/* Status legend in form */
.status-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    padding-top: 1.6rem;
}

/* ════════════════════════════════════════════════════════════
   MULTILINGUAL — Arabic font & RTL layout overrides
   ════════════════════════════════════════════════════════════ */

/* ── Arabic font import ── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@300;400;600;700&display=swap');

/* ── Language switcher ── */
.lang-switcher {
    display: flex;
    gap: 0.2rem;
    align-items: center;
    flex-shrink: 0;
}
.lang-btn {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--ink-light);
    text-decoration: none;
    padding: 0.28rem 0.55rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    transition: all 0.18s;
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0.7;
}
.lang-btn:hover { border-color: var(--border); color: var(--gold-light); opacity: 1; }
.lang-btn.active {
    border-color: var(--border-strong);
    color: var(--gold-light);
    background: rgba(201,168,76,0.1);
    opacity: 1;
}

/* ── RTL base ── */
[dir="rtl"] {
    font-family: 'Noto Sans Arabic', var(--font-serif);
}
[dir="rtl"] body {
    font-family: 'Noto Sans Arabic', Georgia, sans-serif;
}
/* Mono in RTL falls back to Noto Sans Arabic since JetBrains has no Arabic glyphs */
[dir="rtl"] .mono,
[dir="rtl"] [class*="mono"],
[dir="rtl"] .font-mono,
[dir="rtl"] .label-text,
[dir="rtl"] .section-title,
[dir="rtl"] .field-label,
[dir="rtl"] .field-value.mono,
[dir="rtl"] .nav-link,
[dir="rtl"] .btn-submit,
[dir="rtl"] .btn-download,
[dir="rtl"] .lang-btn,
[dir="rtl"] footer p,
[dir="rtl"] header span {
    font-family: 'Noto Sans Arabic', monospace;
    letter-spacing: 0;
}

/* ── Arabic 25% font-size boost for key UI elements ── */
[dir="rtl"] .nav-link        { font-size: calc(0.72rem * 1.25); }   /* 0.9rem  */
[dir="rtl"] .label-text      { font-size: calc(0.62rem * 1.25); }   /* 0.775rem */
[dir="rtl"] .section-title span,
[dir="rtl"] .section-title   { font-size: calc(0.8rem  * 1.25); }   /* 1rem    */
[dir="rtl"] label,
[dir="rtl"] .field-label     { font-size: calc(0.72rem * 1.25); }   /* 0.9rem  */
[dir="rtl"] .btn-submit      { font-size: calc(0.78rem * 1.25); letter-spacing: 0.04em; }  /* 0.975rem */
[dir="rtl"] .btn-download    { font-size: calc(0.7rem  * 1.25); letter-spacing: 0.04em; }  /* 0.875rem */
[dir="rtl"] .btn-update      { font-size: calc(0.78rem * 1.25); letter-spacing: 0.04em; }
[dir="rtl"] .btn-filter      { font-size: calc(0.78rem * 1.25); letter-spacing: 0.04em; }
[dir="rtl"] .btn-search      { font-size: calc(0.78rem * 1.25); letter-spacing: 0.04em; }

/* ── Header RTL ── */
/* ── Page title RTL ── */
[dir="rtl"] .page-title { text-align: right; }
[dir="rtl"] .label-text::before { content: none; }

/* ── Form RTL ── */
[dir="rtl"] .section-title { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .section-title::after { display: none; }
[dir="rtl"] .section-title::before {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
[dir="rtl"] label { text-align: right; }
[dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] textarea {
    text-align: right;
    direction: rtl;
}
[dir="rtl"] select {
    background-position: left 0.8rem center;
    padding-right: 1rem;
    padding-left: 2.5rem;
}
[dir="rtl"] .form-footer { flex-direction: row-reverse; }
[dir="rtl"] .date-display { flex-direction: row-reverse; }
[dir="rtl"] .btn-submit { flex-direction: row-reverse; }
[dir="rtl"] .btn-submit svg { transform: scaleX(-1); }

/* ── Success panel RTL ── */
[dir="rtl"] .success-header { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .result-grid { direction: rtl; }
[dir="rtl"] .result-fields { text-align: right; }
[dir="rtl"] .field-row { flex-direction: row-reverse; }
[dir="rtl"] .qr-actions { flex-direction: row-reverse; }
[dir="rtl"] .btn-download { flex-direction: row-reverse; }

/* ── Alert RTL ── */
[dir="rtl"] .alert { flex-direction: row-reverse; text-align: right; }

/* ── Records table RTL ── */
[dir="rtl"] .records-toolbar { flex-direction: row-reverse; }
[dir="rtl"] .status-filter-bar { flex-direction: row-reverse; justify-content: flex-end; }
[dir="rtl"] th a { flex-direction: row-reverse; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] .records-meta { flex-direction: row-reverse; }
[dir="rtl"] .per-page-group { flex-direction: row-reverse; }
[dir="rtl"] .per-btn { border-left: none; border-right: 1px solid var(--border); }
[dir="rtl"] .per-btn:first-of-type { border-right: none; }
[dir="rtl"] .pagination { flex-direction: row-reverse; }
[dir="rtl"] .badge { direction: ltr; } /* keep metal badges LTR */
[dir="rtl"] .status-badge { direction: rtl; }
[dir="rtl"] .qr-thumb { margin-right: auto; margin-left: 0; }

/* ── Modal RTL ── */
[dir="rtl"] .modal-box { text-align: center; direction: rtl; }
[dir="rtl"] .modal-box > div { flex-direction: row-reverse; }

/* ── Verify page RTL ── */
[dir="rtl"] .verify-layout { direction: rtl; }
[dir="rtl"] .mode-tabs { flex-direction: row-reverse; }
[dir="rtl"] .mode-tab { flex-direction: row-reverse; }
[dir="rtl"] .mode-tab:not(:last-child) { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .mode-tab.active { border-right: none; }
[dir="rtl"] .manual-row { flex-direction: row-reverse; }
[dir="rtl"] .result-idle { direction: rtl; }
[dir="rtl"] .result-card { direction: rtl; }
[dir="rtl"] .status-banner { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .record-detail h4 { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .record-detail h4::after { display: none; }
[dir="rtl"] .record-detail h4::before { content: ''; flex: 1; height: 1px; background: var(--border); }
[dir="rtl"] .detail-row { flex-direction: row-reverse; }
[dir="rtl"] .detail-val { text-align: right; }
[dir="rtl"] .mismatch-compare { flex-direction: row-reverse; }
[dir="rtl"] .cert-badge { flex-direction: row-reverse; }
[dir="rtl"] .btn-scan-again { flex-direction: row-reverse; }
[dir="rtl"] .btn-scan-again svg { transform: scaleX(-1); }
[dir="rtl"] .scan-history h4 { flex-direction: row-reverse; }
[dir="rtl"] .scan-history h4::after { display: none; }
[dir="rtl"] .scan-history h4::before { content: ''; flex: 1; height: 1px; background: var(--border); }
[dir="rtl"] .history-item { flex-direction: row-reverse; }

/* ── Status page RTL ── */
[dir="rtl"] .status-layout { direction: rtl; }
[dir="rtl"] .search-panel { direction: rtl; }
[dir="rtl"] .panel-header { flex-direction: row-reverse; }
[dir="rtl"] .search-form { flex-direction: row-reverse; }
[dir="rtl"] .result-item { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .record-card-header { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .record-meta-grid { direction: rtl; }
[dir="rtl"] .meta-item { flex-direction: row-reverse; }
[dir="rtl"] .meta-item:nth-child(odd) { border-right: none; border-left: 1px solid rgba(201,168,76,0.06); }
[dir="rtl"] .status-grid { direction: rtl; }
[dir="rtl"] .status-option label { direction: rtl; }
[dir="rtl"] .update-footer { flex-direction: row-reverse; }
[dir="rtl"] .current-status-display { flex-direction: row-reverse; }
[dir="rtl"] .btn-update { flex-direction: row-reverse; }
[dir="rtl"] .history-row { flex-direction: row-reverse; }
[dir="rtl"] .history-arrow { flex-direction: row-reverse; }
[dir="rtl"] .history-arrow svg { transform: scaleX(-1); }

/* ── Empty state RTL ── */
[dir="rtl"] .empty-state { direction: rtl; }

/* ── Footer RTL ── */
[dir="rtl"] footer { direction: rtl; }

/* ── Keep QR codes and serial numbers LTR always ── */
[dir="rtl"] #qrcode,
[dir="rtl"] #modalQR,
[dir="rtl"] .qr-container,
[dir="rtl"] .field-value.mono,
[dir="rtl"] td.mono { direction: ltr; text-align: left; }

/* ── User pill in header ── */
.user-pill {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.45rem 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: rgba(255,255,255,0.03);
    flex-shrink: 0;
}
.user-pill svg { color: var(--ink-light); flex-shrink: 0; }
.user-name {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    color: var(--gold-pale);
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role-badge {
    font-family: var(--font-mono);
    font-size: 0.52rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(201,168,76,0.15);
    color: var(--gold);
    border: 1px solid rgba(201,168,76,0.3);
    border-radius: 20px;
    padding: 0.08rem 0.4rem;
}
.user-logout {
    display: flex;
    align-items: center;
    color: var(--ink-light);
    padding: 0.18rem;
    border-radius: 50%;
    transition: all 0.2s;
    text-decoration: none;
    flex-shrink: 0;
}
.user-logout:hover { color: var(--red-light, #e87878); background: rgba(220,100,100,0.1); }

/* Alert success */
.alert-success {
    background: rgba(61,122,74,0.15);
    border: 1px solid rgba(106,191,122,0.4);
    color: #7fd492;
}



/* ════════════════════════════════════════════════
   EXTENSION: lang switcher, user pill, hamburger
   nav dropdown, RTL, status extras, mobile fixes
   ════════════════════════════════════════════════ */

/* Noto Sans Arabic font */

/* ── Header layout overrides ── */
.header-inner {
    display: flex; align-items: center; gap: 0.75rem;
    max-width: 1400px; margin: 0 auto;
    padding: 0.65rem 0; min-height: 56px;
}
.header-text { flex-shrink: 0; min-width: 0; }
.header-text h1 {
    font-size: 0.95rem; font-weight: 600;
    letter-spacing: 0.08em; color: var(--gold-light);
    text-transform: uppercase; white-space: nowrap;
}
.header-text span {
    font-size: 0.55rem; letter-spacing: 0.16em;
    color: var(--ink-light); text-transform: uppercase;
    font-family: var(--font-mono); display: block; white-space: nowrap;
}
nav {
    display: flex; gap: 0.2rem;
    align-items: center; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; padding: 0.1rem 0;
    position: absolute; left: 50%; transform: translateX(-50%);
    max-width: 60%;
}
nav::-webkit-scrollbar { display: none; }
.header-controls {
    display: flex; align-items: center;
    gap: 0.5rem; flex-shrink: 0; margin-inline-start: auto;
}

/* ── Language switcher ── */
.lang-switcher { display: flex; gap: 0.2rem; align-items: center; flex-shrink: 0; }
.lang-btn {
    font-family: var(--font-mono); font-size: 0.6rem;
    letter-spacing: 0.04em; color: var(--ink-light);
    text-decoration: none; padding: 0.28rem 0.5rem;
    border: 1px solid transparent; border-radius: var(--radius);
    transition: all 0.18s; white-space: nowrap; flex-shrink: 0;
}
.lang-btn:hover { border-color: var(--border); color: var(--gold-light); }
.lang-btn.active { border-color: var(--border-strong); color: var(--gold-light); background: rgba(201,168,76,0.1); }

/* ── User pill ── */
.user-pill {
    display: flex; align-items: center; gap: 0.35rem;
    padding: 0.25rem 0.45rem 0.25rem 0.6rem;
    border: 1px solid var(--border); border-radius: 100px;
    background: rgba(255,255,255,0.03); flex-shrink: 0;
}
.user-pill svg { color: var(--ink-light); flex-shrink: 0; }
.user-name {
    font-family: var(--font-mono); font-size: 0.62rem;
    letter-spacing: 0.04em; color: var(--gold-pale);
    white-space: nowrap; max-width: 100px;
    overflow: hidden; text-overflow: ellipsis;
}
.user-role-badge {
    font-family: var(--font-mono); font-size: 0.52rem;
    letter-spacing: 0.08em; text-transform: uppercase;
    background: rgba(201,168,76,0.15); color: var(--gold);
    border: 1px solid rgba(201,168,76,0.3); border-radius: 20px;
    padding: 0.08rem 0.4rem;
}
.user-logout {
    display: flex; align-items: center; color: var(--ink-light);
    padding: 0.18rem; border-radius: 50%;
    transition: all 0.2s; text-decoration: none; flex-shrink: 0;
}
.user-logout:hover { color: #e87878; background: rgba(220,100,100,0.1); }

/* ── Alert success ── */
.alert-success {
    background: rgba(61,122,74,0.15);
    border: 1px solid rgba(106,191,122,0.4);
    color: #7fd492;
}

/* ── All status badges (complete set) ── */
.status-manufactured { background: rgba(180,180,180,0.12); color: #c8c8c8; border: 1px solid rgba(200,200,200,0.3); }
.status-manufactured::before { background: #aaaaaa; box-shadow: 0 0 5px rgba(200,200,200,0.45); }

.status-distributor { background: rgba(40,120,220,0.15); color: #6ab0f5; border: 1px solid rgba(80,160,240,0.35); }
.status-distributor::before { background: #4090e0; box-shadow: 0 0 5px rgba(80,160,240,0.6); }

.status-sold { background: rgba(46,160,100,0.15); color: #5cd490; border: 1px solid rgba(60,180,110,0.35); }
.status-sold::before { background: #3cb878; box-shadow: 0 0 5px rgba(60,180,110,0.6); }

.status-registered { background: rgba(201,168,76,0.18); color: #f5d060; border: 1px solid rgba(230,190,80,0.5); }
.status-registered::before { background: #e8c040; box-shadow: 0 0 8px rgba(230,190,80,0.7); }

.status-melted { background: rgba(184,100,18,0.18); color: #f0a84e; border: 1px solid rgba(220,145,60,0.35); }
.status-melted::before { background: #dc913c; box-shadow: 0 0 5px rgba(220,145,60,0.7); }

.status-destroyed { background: rgba(139,44,44,0.18); color: #e87878; border: 1px solid rgba(220,100,100,0.35); }
.status-destroyed::before { background: #dc6464; box-shadow: 0 0 5px rgba(220,100,100,0.7); }

/* ── Hamburger button ── */
.nav-hamburger {
    display: none; align-items: center; justify-content: center;
    flex-direction: column; gap: 5px;
    width: 38px; height: 38px; background: transparent;
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--gold-light); cursor: pointer; transition: all 0.2s;
    flex-shrink: 0; padding: 0;
}
.nav-hamburger:hover { border-color: var(--gold); background: rgba(201,168,76,0.1); }
.nav-hamburger .bar {
    display: block;
    width: 20px; height: 2.5px;
    background: currentColor;
    border-radius: 2px;
    transition: width 0.2s ease;
}
/* Middle bar slightly shorter for classic stacked-line look */
.nav-hamburger .bar:nth-child(2) { width: 14px; }
/* On open: middle bar returns to full width to show all 3 equal */
.nav-hamburger.open .bar { width: 20px; }

/* ── Dropdown panel ── */
.nav-dropdown { display: none; position: fixed; inset: 0; z-index: 51; }
.nav-dropdown.open { display: block; }
.nav-dropdown-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
.nav-dropdown-panel {
    position: absolute; top: 56px; left: 0; right: 0;
    background: rgba(26,18,8,0.98);
    border-bottom: 1px solid var(--border-strong);
    backdrop-filter: blur(12px); padding: 0.5rem 0 0.75rem;
    transform: translateY(-8px); opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.nav-dropdown.open .nav-dropdown-panel { transform: translateY(0); opacity: 1; }
.nav-dropdown-links {
    display: flex; flex-direction: column;
    padding: 0 1rem; gap: 0.15rem;
    max-width: 480px; margin: 0;   /* left-justified, not centred */
}
.nav-dropdown-links .nav-link {
    display: flex; align-items: center;
    padding: 0.75rem 1rem; font-size: 0.78rem;
    letter-spacing: 0.08em; border-radius: 6px;
    border: 1px solid transparent;
}
.nav-dropdown-links .nav-link:hover,
.nav-dropdown-links .nav-link.active {
    background: rgba(201,168,76,0.1);
    border-color: rgba(201,168,76,0.25); color: var(--gold-light);
}
.nav-dropdown-links .nav-link.active::before {
    content: ''; display: inline-block;
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--gold); margin-right: 0.6rem; flex-shrink: 0;
}

/* ── Mobile: show hamburger, hide inline nav ── */
@media (max-width: 768px) {
    .nav-hamburger { display: flex; }
}

/* ════ RTL ════ */
[dir="rtl"] { font-family: 'Noto Sans Arabic', var(--font-serif); }
[dir="rtl"] body { font-family: 'Noto Sans Arabic', Georgia, sans-serif; }
[dir="rtl"] .nav-link,
[dir="rtl"] .lang-btn,
[dir="rtl"] .btn-submit,
[dir="rtl"] .btn-download,
[dir="rtl"] footer p,
[dir="rtl"] header span { font-family: 'Noto Sans Arabic', monospace; letter-spacing: 0; }

/* ════ RTL page content ════ */

/* ════ RTL HEADER — full mirror ════ */

/* Desktop: entire header-inner row reversed */
[dir="rtl"] .header-inner    { flex-direction: row-reverse; }
[dir="rtl"] .header-brand    { flex-direction: row-reverse; } /* logo right of text */
[dir="rtl"] .header-text     { text-align: right; }
[dir="rtl"] nav              { flex-direction: row-reverse; } /* nav links RTL order */
[dir="rtl"] .header-controls { flex-direction: row-reverse; margin-inline-start: 0; margin-inline-end: auto; }
[dir="rtl"] .lang-switcher   { flex-direction: row-reverse; margin-inline-start: 0; }
[dir="rtl"] .user-pill       { flex-direction: row-reverse; }
[dir="rtl"] .user-logout     { margin-inline-start: 0; margin-inline-end: 0; }

/* Mobile (≤768px): hamburger LEFT (same as LTR), brand centre */
@media (max-width: 768px) {
    [dir="rtl"] .header-inner  { flex-direction: row; }  /* keep LTR flow so order works same as English */
    [dir="rtl"] .header-brand  { flex-direction: row-reverse; }  /* logo to right of text inside brand */
    [dir="rtl"] .nav-hamburger { order: 1; margin-inline-start: 0; margin-inline-end: auto; }
    [dir="rtl"] .header-controls { order: 3; margin-inline-start: auto; margin-inline-end: 0; }

    /* Row 2: sign-out LEFT, lang RIGHT (mirror of LTR) */
    [dir="rtl"] .header-mobile-row2             { flex-direction: row-reverse; }
    [dir="rtl"] .header-mobile-row2 .mobile-logout { margin-inline-start: 0; margin-inline-end: auto; }
}

/* Dropdown: links and panel right-aligned, RTL flow */
[dir="rtl"] .nav-dropdown-panel   { text-align: right; }
[dir="rtl"] .nav-dropdown-links   { direction: rtl; align-items: flex-start; }
[dir="rtl"] .nav-dropdown-links .nav-link          { direction: rtl; }
[dir="rtl"] .nav-dropdown-links .nav-link.active::before { margin-right: 0; margin-left: 0.6rem; }
[dir="rtl"] .page-title      { text-align: right; }
[dir="rtl"] .label-text::before { content: none; }
[dir="rtl"] .section-title   { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .section-title::after  { display: none; }
[dir="rtl"] .section-title::before { content:''; flex:1; height:1px; background:var(--border); }
[dir="rtl"] label            { text-align: right; }
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea         { text-align: right; direction: rtl; }
[dir="rtl"] select           { background-position: left 0.8rem center; padding-right: 1rem; padding-left: 2.5rem; }
[dir="rtl"] .form-footer     { flex-direction: row-reverse; }
[dir="rtl"] .date-display    { flex-direction: row-reverse; }
[dir="rtl"] .btn-submit      { flex-direction: row-reverse; }
[dir="rtl"] .btn-submit svg  { transform: scaleX(-1); }
[dir="rtl"] .success-header  { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .result-grid     { direction: rtl; }
[dir="rtl"] .field-row       { flex-direction: row-reverse; }
[dir="rtl"] .qr-actions      { flex-direction: row-reverse; }
[dir="rtl"] .alert           { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] .pagination      { flex-direction: row-reverse; }
[dir="rtl"] .status-badge    { direction: rtl; }
[dir="rtl"] #qrcode,
[dir="rtl"] .qr-container,
[dir="rtl"] td.mono          { direction: ltr; text-align: left; }
[dir="rtl"] footer           { direction: rtl; }

/* ════════════════════════════════════════════════════════════
   GOLD BAR BUTTON — Shared metallic slab style
   Applies to all primary action buttons sitewide
   ════════════════════════════════════════════════════════════ */

/* Shared gold-bar gradient mixin applied globally */
.btn-gold,
.btn-auth,
.btn-allow,
.btn-scan-again,
.btn-verify-manual,
.btn-update,
.btn-start-camera,
.btn-browse,
.perm-save-btn {
    background:
        linear-gradient(
            180deg,
            #f5d96a 0%,
            #e8b830 8%,
            #d4940a 20%,
            #f0c830 35%,
            #f8e060 50%,
            #e0a810 65%,
            #c88a00 78%,
            #e8b830 90%,
            #f5d060 100%
        ) !important;
    color: #2a1a00 !important;
    border: none !important;
    border-radius: 8px;
    font-weight: 700 !important;
    text-shadow: 0 1px 0 rgba(255,220,100,0.4);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(255,240,150,0.8) inset,
        0 -1px 0 rgba(100,60,0,0.5) inset,
        0 4px 12px rgba(180,120,0,0.4),
        0 1px 3px rgba(0,0,0,0.5) !important;
}

.btn-gold::before,
.btn-auth::before,
.btn-allow::before,
.btn-scan-again::before,
.btn-verify-manual::before,
.btn-update::before {
    content: '';
    position: absolute;
    top: 0; left: -60%; width: 45%; height: 100%;
    background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,0.3) 50%, transparent 80%);
    transform: skewX(-15deg);
    transition: left 0.42s ease;
    pointer-events: none;
}
.btn-gold:hover::before,
.btn-auth:hover::before,
.btn-allow:hover::before,
.btn-scan-again:hover::before,
.btn-verify-manual:hover::before,
.btn-update:hover::before { left: 110%; }

.btn-gold:hover,
.btn-auth:hover,
.btn-allow:hover,
.btn-scan-again:hover,
.btn-verify-manual:hover,
.btn-update:hover,
.btn-start-camera:hover,
.btn-browse:hover,
.perm-save-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow:
        0 1px 0 rgba(255,240,150,0.9) inset,
        0 -1px 0 rgba(100,60,0,0.6) inset,
        0 8px 24px rgba(180,120,0,0.55),
        0 2px 6px rgba(0,0,0,0.5) !important;
}
.btn-gold:active,
.btn-auth:active,
.btn-allow:active,
.btn-scan-again:active,
.btn-verify-manual:active,
.btn-update:active { transform: translateY(0) !important; }

/* ── Must Register checkbox ── */
.checkbox-field { display: flex; flex-direction: column; gap: 0.4rem; }
.checkbox-label {
    display: flex; align-items: center; gap: 0.6rem;
    cursor: pointer; user-select: none;
}
.checkbox-label input[type="checkbox"] { display: none; }
.checkbox-custom {
    width: 20px; height: 20px; flex-shrink: 0;
    border: 2px solid rgba(201,168,76,0.5); border-radius: 4px;
    background: rgba(26,18,8,0.8); transition: all 0.18s;
    position: relative;
}
.checkbox-custom::after {
    content: '';
    position: absolute; top: 2px; left: 5px;
    width: 6px; height: 10px;
    border: 2px solid #2a1a00;
    border-top: none; border-left: none;
    transform: rotate(45deg) scale(0);
    transition: transform 0.15s ease;
}
.checkbox-label input[type="checkbox"]:checked ~ .checkbox-custom {
    background: linear-gradient(180deg,#f5d96a 0%,#e8b830 8%,#d4940a 20%,#f0c830 35%,#f8e060 50%,#e0a810 65%,#c88a00 78%,#e8b830 90%,#f5d060 100%);
    border-color: #c9a84c;
    box-shadow: 0 0 8px rgba(201,168,76,0.4);
}
.checkbox-label input[type="checkbox"]:checked ~ .checkbox-custom::after {
    transform: rotate(45deg) scale(1);
}
.checkbox-text {
    font-family: var(--font-mono); font-size: 0.75rem;
    color: var(--gold-pale); letter-spacing: 0.06em;
}
.field-hint {
    font-family: var(--font-mono); font-size: 0.62rem;
    color: var(--ink-light); letter-spacing: 0.04em; line-height: 1.5;
    margin: 0;
}


/* ════════════════════════════════════════════════════════════
   LIGHT THEME
   Applied via: <html data-theme="light">
   Toggled by the ☀/🌙 button in the header (theme.js cookie).
   Every colour-bearing variable is overridden here; layout,
   spacing, and typography rules are inherited unchanged.
   ════════════════════════════════════════════════════════════ */

[data-theme="light"] {
    /* ── Core palette ── */
    --gold:           #9a6e1a;
    --gold-light:     #7a520e;
    --gold-pale:      #3d2800;
    --ink:            #faf7f0;        /* was the dark body bg — now lightest surface */
    --ink-mid:        #f0e8d8;
    --ink-light:      #6b5a3e;
    --surface:        #2d1f08;        /* was light text — now dark text on light bg */
    --surface-2:      #e8dcc8;
    --border:         rgba(154,110,26,0.2);
    --border-strong:  rgba(154,110,26,0.45);
    --success:        #2a6636;
    --error:          #7a1f1f;
}

/* ── Body & layout ── */
[data-theme="light"] body {
    background-color: #faf7f0;
    color: #2d1f08;
}

/* ── Grain: slightly more visible on light bg ── */
[data-theme="light"] .grain { opacity: 0.02; }

/* ── Header ── */
[data-theme="light"] header {
    background: linear-gradient(180deg, #c9a84c 0%, rgba(240,230,210,0.98) 100%);
    border-bottom: 1px solid rgba(154,110,26,0.35);
}
[data-theme="light"] .header-text h1 { color: #3d2800; }
[data-theme="light"] .header-text span { color: #6b5a3e; }

/* ── Nav links ── */
[data-theme="light"] .nav-link { color: #6b5a3e; }
[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active {
    color: #3d2800;
    border-color: rgba(154,110,26,0.45);
    background: rgba(154,110,26,0.1);
}

/* ── Lang switcher ── */
[data-theme="light"] .lang-btn { color: #6b5a3e; }
[data-theme="light"] .lang-btn:hover { color: #3d2800; border-color: rgba(154,110,26,0.35); }
[data-theme="light"] .lang-btn.active {
    color: #3d2800;
    border-color: rgba(154,110,26,0.5);
    background: rgba(154,110,26,0.12);
}

/* ── User pill ── */
[data-theme="light"] .user-pill {
    border-color: rgba(154,110,26,0.3);
    background: rgba(154,110,26,0.06);
}
[data-theme="light"] .user-pill svg { color: #6b5a3e; }
[data-theme="light"] .user-name { color: #3d2800; }
[data-theme="light"] .user-role-badge {
    background: rgba(154,110,26,0.12);
    color: #7a520e;
    border-color: rgba(154,110,26,0.3);
}
[data-theme="light"] .user-logout { color: #6b5a3e; }
[data-theme="light"] .user-logout:hover { color: #8b1f1f; background: rgba(180,50,50,0.08); }

/* ── Page title ── */
[data-theme="light"] .label-text { color: #9a6e1a; }
[data-theme="light"] .page-title h2 { color: #2d1f08; }
[data-theme="light"] .page-title h2 em { color: #7a520e; }
[data-theme="light"] .subtitle { color: #6b5a3e; }

/* ── Form ── */
[data-theme="light"] .registry-form {
    background: #fff;
    border-color: rgba(154,110,26,0.2);
    box-shadow: 0 2px 16px rgba(61,40,0,0.07);
}
[data-theme="light"] .form-section { border-bottom-color: rgba(154,110,26,0.12); }
[data-theme="light"] .section-title { color: #6b5a3e; }
[data-theme="light"] .section-title span { color: #9a6e1a; }
[data-theme="light"] .section-title::after,
[data-theme="light"] .section-title::before { background: rgba(154,110,26,0.15); }
[data-theme="light"] label { color: #6b5a3e; }

[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="number"],
[data-theme="light"] select,
[data-theme="light"] textarea {
    background: #fff;
    border-color: rgba(154,110,26,0.25);
    color: #2d1f08;
}
[data-theme="light"] input::placeholder { color: rgba(154,110,26,0.5); }
[data-theme="light"] select option { background: #f5efe0; color: #2d1f08; }
[data-theme="light"] input:focus,
[data-theme="light"] select:focus {
    border-color: #9a6e1a;
    background: rgba(154,110,26,0.04);
    box-shadow: 0 0 0 3px rgba(154,110,26,0.1);
}
[data-theme="light"] .form-footer {
    background: rgba(154,110,26,0.04);
    border-top-color: rgba(154,110,26,0.12);
}
[data-theme="light"] .date-display { color: #6b5a3e; }
[data-theme="light"] .date-display svg { color: #9a6e1a; }
[data-theme="light"] .date-display strong { color: #7a520e; }

/* ── Success panel ── */
[data-theme="light"] .success-panel {
    background: linear-gradient(135deg, rgba(42,102,54,0.07) 0%, rgba(154,110,26,0.05) 100%);
    border-color: rgba(42,102,54,0.35);
}
[data-theme="light"] .success-header { border-bottom-color: rgba(154,110,26,0.15); }
[data-theme="light"] .success-header h3 { color: #3d2800; }
[data-theme="light"] .success-header span { color: #6b5a3e; }
[data-theme="light"] .field-label { color: #6b5a3e; }
[data-theme="light"] .field-value { color: #2d1f08; }

/* ── QR ── */
[data-theme="light"] #qrcode {
    background: #fff;
    border-color: #9a6e1a;
    box-shadow: 0 0 20px rgba(154,110,26,0.2);
}
[data-theme="light"] .qr-caption { color: #6b5a3e; }

/* ── Records table ── */
[data-theme="light"] thead tr { border-bottom-color: rgba(154,110,26,0.4); }
[data-theme="light"] th { color: #9a6e1a; }
[data-theme="light"] tbody tr { border-bottom-color: rgba(154,110,26,0.08); }
[data-theme="light"] tbody tr:hover { background: rgba(154,110,26,0.04); }
[data-theme="light"] td { color: #2d1f08; }
[data-theme="light"] td.mono { color: #6b5a3e; }

/* ── Badges ── */
[data-theme="light"] .badge-gold     { background: rgba(154,110,26,0.1); color: #7a520e; border-color: rgba(154,110,26,0.3); }
[data-theme="light"] .badge-silver   { background: rgba(120,120,120,0.1); color: #555; border-color: rgba(120,120,120,0.3); }
[data-theme="light"] .badge-platinum { background: rgba(60,100,140,0.1); color: #2d5a8a; border-color: rgba(60,100,140,0.25); }
[data-theme="light"] .badge-other    { background: rgba(0,0,0,0.05); color: #666; border-color: rgba(0,0,0,0.12); }

/* ── Status badges (keep vivid — same across themes) ── */
/* Status badge colors are chromatic / semantic — keep them bright in light mode too */
[data-theme="light"] .status-manufactured { background: rgba(100,100,100,0.1); color: #555; border-color: rgba(100,100,100,0.3); }
[data-theme="light"] .status-manufactured::before { background: #888; }
[data-theme="light"] .status-distributor { background: rgba(40,100,200,0.1); color: #1a5cc8; border-color: rgba(40,100,200,0.3); }
[data-theme="light"] .status-distributor::before { background: #2060c0; }
[data-theme="light"] .status-sold { background: rgba(30,140,80,0.1); color: #1a7840; border-color: rgba(30,140,80,0.3); }
[data-theme="light"] .status-sold::before { background: #1a8a48; }
[data-theme="light"] .status-registered { background: rgba(154,110,26,0.12); color: #7a5210; border-color: rgba(154,110,26,0.35); }
[data-theme="light"] .status-registered::before { background: #9a6e1a; }
[data-theme="light"] .status-melted { background: rgba(180,90,10,0.1); color: #b05a08; border-color: rgba(180,90,10,0.3); }
[data-theme="light"] .status-melted::before { background: #c06410; }
[data-theme="light"] .status-destroyed { background: rgba(180,40,40,0.1); color: #a82020; border-color: rgba(180,40,40,0.3); }
[data-theme="light"] .status-destroyed::before { background: #c02828; }

/* ── Modal ── */
[data-theme="light"] .modal-overlay { background: rgba(61,40,0,0.6); }
[data-theme="light"] .modal-box {
    background: #faf7f0;
    border-color: rgba(154,110,26,0.4);
    box-shadow: 0 8px 32px rgba(61,40,0,0.15);
}
[data-theme="light"] .modal-box h4 { color: #3d2800; }
[data-theme="light"] .modal-box p { color: #6b5a3e; }
[data-theme="light"] .modal-qr { background: #fff; }
[data-theme="light"] .modal-close {
    border-color: rgba(154,110,26,0.25);
    color: #6b5a3e;
}
[data-theme="light"] .modal-close:hover { border-color: #9a6e1a; color: #3d2800; }

/* ── Alerts ── */
[data-theme="light"] .alert-error { background: rgba(160,40,40,0.07); border-color: rgba(160,40,40,0.3); color: #8b1f1f; }
[data-theme="light"] .alert-success { background: rgba(30,120,60,0.07); border-color: rgba(30,120,60,0.3); color: #1a6635; }

/* ── Empty state ── */
[data-theme="light"] .empty-state { color: #6b5a3e; }
[data-theme="light"] .empty-state svg { color: rgba(154,110,26,0.3); }

/* ── Footer ── */
[data-theme="light"] footer {
    border-top-color: rgba(154,110,26,0.15);
    color: #8a7060;
}

/* ── Hamburger / dropdown ── */
[data-theme="light"] .nav-hamburger {
    border-color: rgba(154,110,26,0.3);
    color: #3d2800;
}
[data-theme="light"] .nav-hamburger:hover {
    border-color: #9a6e1a;
    background: rgba(154,110,26,0.1);
}
[data-theme="light"] .nav-dropdown-panel {
    background: rgba(250,247,240,0.98);
    border-bottom-color: rgba(154,110,26,0.3);
    box-shadow: 0 8px 24px rgba(61,40,0,0.12);
}
[data-theme="light"] .nav-dropdown-links .nav-link { color: #6b5a3e; }
[data-theme="light"] .nav-dropdown-links .nav-link:hover,
[data-theme="light"] .nav-dropdown-links .nav-link.active {
    background: rgba(154,110,26,0.08);
    border-color: rgba(154,110,26,0.2);
    color: #3d2800;
}

/* ── Mobile row 2 ── */
[data-theme="light"] .header-mobile-row2 { border-top-color: rgba(154,110,26,0.15); }
[data-theme="light"] .mobile-logout-link { color: #6b5a3e; border-color: rgba(154,110,26,0.25); }
[data-theme="light"] .mobile-logout-link:hover { color: #8b1f1f; border-color: rgba(180,50,50,0.35); background: rgba(180,50,50,0.06); }
[data-theme="light"] .mobile-logout-name { color: #2d1f08; }

/* ── Checkbox ── */
[data-theme="light"] .checkbox-custom {
    border-color: rgba(154,110,26,0.5);
    background: #fff;
}

/* ── Theme toggle button ── */
.theme-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink-light);
    cursor: pointer;
    transition: all 0.18s;
    flex-shrink: 0;
    padding: 0;
}
.theme-toggle:hover {
    border-color: var(--border-strong);
    color: var(--gold-light);
    background: rgba(201,168,76,0.08);
}
.theme-toggle svg { width: 15px; height: 15px; pointer-events: none; }
[data-theme="light"] .theme-toggle { color: #6b5a3e; border-color: rgba(154,110,26,0.3); }
[data-theme="light"] .theme-toggle:hover { color: #3d2800; border-color: rgba(154,110,26,0.5); background: rgba(154,110,26,0.08); }

/* ── Filter bars ── */
[data-theme="light"] .filter-label { color: #6b5a3e; }
[data-theme="light"] .filter-pill { border-color: rgba(154,110,26,0.25); color: #6b5a3e; background: rgba(154,110,26,0.04); }
[data-theme="light"] .filter-pill:hover { background: rgba(154,110,26,0.1); color: #3d2800; }
[data-theme="light"] .filter-pill.active.pill-all { background: rgba(154,110,26,0.15); color: #3d2800; border-color: rgba(154,110,26,0.45); }

/* ── License page ── */
[data-theme="light"] .lic-card { background: #fff; border-color: rgba(154,110,26,0.18); box-shadow: 0 2px 12px rgba(61,40,0,0.06); }
[data-theme="light"] .lic-table th { color: #9a6e1a; }
[data-theme="light"] .lic-table td { color: #2d1f08; }
[data-theme="light"] .lic-table th, [data-theme="light"] .lic-table td { border-bottom-color: rgba(154,110,26,0.08); }
[data-theme="light"] .lic-section-title { color: #9a6e1a; border-bottom-color: rgba(154,110,26,0.15); }
