:root {
  --navy: #7c0032; --gold: #b8860b; --bg: #e1bbba; --card: #fbf4f3;
  --text: #2a1a1f; --muted: #7d5a63; --line: #ecd2d2; --danger: #b42318;
  --ok: #17613f; --warn: #b54708;
  --rose: #f2cfd6; --rose-light: #f8ebe9;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Cairo", "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Naskh Arabic", Arial, sans-serif;
       background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; color: var(--navy); }
small, .muted, .hint { color: var(--muted); font-size: .85rem; }
code { font-size: .8rem; direction: ltr; display: inline-block; max-width: 340px; overflow-wrap: anywhere; }

.topbar { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
          background: var(--navy); color: #fff; padding: .75rem 1.5rem; }
.topbar a { color: #fff; }
.topbar nav { display: flex; gap: 1rem; flex-wrap: wrap; flex: 1; }
.brand { font-weight: 700; letter-spacing: .08em; color: #f3d27a; }
.userbox { display: flex; align-items: center; gap: .75rem; }
.userbox small { opacity: .75; }

.container { max-width: 1200px; margin: 1.5rem auto; padding: 0 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
        padding: 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.kpi span { display: block; color: var(--muted); font-size: .85rem; }
.kpi strong { font-size: 1.3rem; color: var(--navy); direction: ltr; display: inline-block; }

.grid-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.status-tile { background: var(--card); border: 1px solid var(--line); border-right: 4px solid var(--navy);
               border-radius: 8px; padding: .75rem 1rem; display: flex; justify-content: space-between; color: var(--text); }
.status-tile strong { font-size: 1.2rem; }
.status-tile:hover { text-decoration: none; background: #fafbfd; }

.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem;
         background: #eef2f7; color: var(--navy); white-space: nowrap; }
.badge.s-received { background: #eef4ff; color: #1d4ed8; }
.badge.s-at_workshop { background: #fff4e5; color: var(--warn); }
.badge.s-ready { background: #ecfdf3; color: var(--ok); }
.badge.s-delivered { background: #e7f5ee; color: #05603a; }
.badge.s-cancelled { background: #fef3f2; color: var(--danger); }
.status-tile.s-ready { border-right-color: var(--ok); }
.status-tile.s-at_workshop { border-right-color: var(--warn); }
.status-tile.s-cancelled { border-right-color: var(--danger); }
.status-tile.s-delivered { border-right-color: #05603a; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td small { text-decoration: none; display: inline-block; }
td.due, dd.due { color: var(--danger); }

input, select, textarea { font: inherit; padding: .5rem .65rem; border: 1px solid #cfd5de; border-radius: 7px;
                          background: #fff; color: var(--text); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d7f0; border-color: var(--navy); }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
label input, label select, label textarea { color: var(--text); }
textarea { resize: vertical; }

.btn, .btn-secondary, .btn-small { display: inline-block; border-radius: 7px; padding: .5rem 1rem; cursor: pointer;
                                   font: inherit; border: 1px solid var(--navy); }
.btn { background: var(--navy); color: #fff; }
.btn-secondary { background: #fff; color: var(--navy); }
.btn-small { background: #f3d27a; color: var(--navy); border-color: #f3d27a; padding: .3rem .8rem; }
.btn:hover, .btn-secondary:hover { text-decoration: none; opacity: .9; }
button.link { background: none; border: none; color: var(--navy); cursor: pointer; padding: 0; font: inherit; }
.topbar button.link { color: #f3d27a; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem 1.1rem; }
.form-grid.compact { grid-template-columns: 1fr 1fr 2fr auto; align-items: end; margin-top: .75rem; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .9rem; margin: 0; display: grid; gap: .8rem; }
fieldset.wide { grid-column: 1 / -1; }
legend { color: var(--navy); font-weight: 700; padding: 0 .4rem; }
.actions { display: flex; gap: 1rem; align-items: center; }
.inline { display: inline; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters input[name=q] { flex: 1; min-width: 260px; }
.filters label { min-width: 150px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0 0 .75rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.timeline { padding-right: 1.2rem; margin: 0; }
.timeline li { margin-bottom: .6rem; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #ecfdf3; color: var(--ok); }
.flash.error { background: #fef3f2; color: var(--danger); }

.login-card { max-width: 380px; margin: 6rem auto; background: #fff; border: 1px solid var(--line);
              border-radius: 12px; padding: 2rem; }
.login-card h1 { color: var(--navy); margin-top: 0; }
.stack { display: grid; gap: 1rem; }
.stack .btn { justify-self: start; }

/* receipts */
.receipt-page { background: #fff; }
.receipt { max-width: 780px; margin: 1.5rem auto; padding: 2rem; border: 1px solid #ccc; }
.receipt-head { text-align: center; border-bottom: 2px solid var(--navy); margin-bottom: 1rem; padding-bottom: .5rem; }
.receipt-head h1 { color: var(--navy); margin: 0; letter-spacing: .1em; }
.receipt-table th { width: 18%; background: none; border: 1px solid #ddd; }
.receipt-table td { border: 1px solid #ddd; }
.receipt-note { margin-top: 1.25rem; font-size: .9rem; }
.sign-row { display: flex; justify-content: space-between; margin-top: 2.5rem; text-align: center; }
.center { text-align: center; }



@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .container { max-width: none; margin: 0; padding: 0; }
  .card { border: none; padding: 0; }
  a { color: #000; }
}

/* ---------------- v2 additions ---------------- */
.topbar { gap: 1rem; padding: .6rem 1.25rem; position: sticky; top: 0; z-index: 10; }
.brand:hover { text-decoration: none; }
.topsearch input { width: 280px; max-width: 60vw; border: none; background: rgba(255,255,255,.14); color: #fff; }
.topsearch input::placeholder { color: rgba(255,255,255,.7); }
.topsearch input:focus { background: #fff; color: var(--text); outline: none; }
.menu-btn { display: none; background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 6px; font-size: 1.2rem; padding: .1rem .6rem; }
.ratebar { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; padding: .35rem 1.25rem; background: #fff7e0;
           border-bottom: 1px solid #f0e0b0; font-size: .85rem; }
.ratebar b { direction: ltr; display: inline-block; }
.container.narrow, .card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.btn-big { font-size: 1.05rem; padding: .7rem 1.6rem; }
.btn-danger { background: var(--danger); color: #fff; border: 1px solid var(--danger); border-radius: 7px; padding: .5rem 1rem; cursor: pointer; font: inherit; }
.actions.wrap { flex-wrap: wrap; }
.ok { color: var(--ok); }
.due { color: var(--danger); }
.nowrap { white-space: nowrap; }
h3.sub { font-size: .95rem; color: var(--muted); margin: .75rem 0 .4rem; }
.line { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.line:last-of-type { border-bottom: none; }
.line strong { direction: ltr; }
details > summary { cursor: pointer; color: var(--navy); font-weight: 600; margin: .5rem 0; }
details[open] > summary { margin-bottom: .75rem; }
label.check { flex-direction: row; align-items: center; gap: .4rem; min-width: 0 !important; }
.req { color: var(--danger); font-weight: 600; font-size: .8rem; }
.hint.ok { color: var(--ok); }

.money-group { display: contents; }
.with-btn { display: flex; gap: .4rem; }
.with-btn input { flex: 1; min-width: 0; }
.gold-helper { grid-column: 1 / -1; background: #fffaf0; border: 1px dashed #e6c76a; border-radius: 8px; padding: .5rem .75rem; display: none; }
.pay-preview { grid-column: 1 / -1; font-weight: 600; color: var(--navy); min-height: 0; }

.photo-input .previews { display: flex; gap: .4rem; flex-wrap: wrap; }
.photo-input .previews img { width: 74px; height: 74px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.photo-input input[type=file] { padding: .9rem; border: 2px dashed #c8cfda; background: #fafbfd; }
.gallery { display: flex; gap: .75rem; flex-wrap: wrap; }
.gallery a { display: flex; flex-direction: column; gap: .2rem; width: 150px; }
.gallery img { width: 150px; height: 150px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
td.thumb { width: 52px; padding: .3rem; }
td.thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fafbfd; }

.next-step { border-right: 4px solid var(--gold); }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .9rem; }
.tabs a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.tracking { list-style: none; padding: 0; margin: 0 0 1rem; position: relative; }
.tracking li { display: flex; gap: .85rem; padding: 0 0 1rem; position: relative; }
.tracking li::before { content: ""; position: absolute; right: 6px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.tracking li:last-child::before { display: none; }
.tracking .dot { width: 14px; height: 14px; border-radius: 50%; background: #cbd3df; flex: 0 0 14px; margin-top: 5px; z-index: 1; }
.tracking .ev-received .dot { background: #1d4ed8; }
.tracking .ev-sent_to_workshop .dot { background: var(--warn); }
.tracking .ev-returned_from_workshop .dot, .tracking .ev-ready .dot { background: var(--ok); }
.tracking .ev-delivered .dot { background: #05603a; box-shadow: 0 0 0 4px #d1fadf; }
.tracking .ev-cancelled .dot, .tracking .ev-payment_voided .dot, .tracking .ev-cost_voided .dot { background: var(--danger); }
.tracking .ev-payment .dot { background: var(--gold); }

.table-scroll { overflow-x: auto; }
table.pick td { padding: .4rem; }
table.pick tr.picked td { background: #f3f8ff; }
table.pick input:disabled, table.pick select:disabled { opacity: .4; }
.mini-money { white-space: nowrap; }
.mini-money .rate-wrap { display: inline; }
.small-file { max-width: 160px; font-size: .8rem; padding: .25rem; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: .75rem 0; justify-content: space-between; border-top: 1px solid var(--line); margin-top: .75rem; }
.danger-zone summary { color: var(--danger); }
table.ledger td:nth-child(n+3), table.ledger th:nth-child(n+3) { direction: ltr; text-align: left; white-space: nowrap; }
.report .num { direction: ltr; text-align: left; white-space: nowrap; }
.report .summary b { display: block; }
.report h3 { color: var(--navy); margin-top: 1.25rem; }
.report table.pnl { max-width: 560px; }
.report tr.tot td { font-weight: 700; background: #f3f5f8; }

.track-page { background: #f5f2ea; }
.brand-dark { font-weight: 800; letter-spacing: .1em; color: var(--gold); font-size: 1.1rem; }
.track-status { display: inline-block; padding: .45rem 1.2rem; border-radius: 999px; font-weight: 700; background: #eef4ff; color: #1d4ed8; }
.track-status.s-at_workshop { background: #fff4e5; color: var(--warn); }
.track-status.s-ready { background: #ecfdf3; color: var(--ok); }
.track-status.s-delivered { background: #e7f5ee; color: #05603a; }
.track-status.s-cancelled { background: #fef3f2; color: var(--danger); }

@media (max-width: 900px) {
  .menu-btn { display: inline-block; }
  .topbar nav, .topbar .userbox { display: none; width: 100%; }
  body.nav-open .topbar nav, body.nav-open .topbar .userbox { display: flex; flex-direction: column; gap: .6rem; }
  .topsearch { flex: 1; }
  .topsearch input { width: 100%; max-width: none; }
}
@media (max-width: 640px) {
  .container { margin: 1rem auto; }
  .card { padding: 1rem; }
  .filters label { min-width: 0; flex: 1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  th, td { padding: .45rem .35rem; font-size: .9rem; }
  .gallery a, .gallery img { width: 46vw; height: auto; }
}
@media print { .ratebar, .topbar { display: none !important; } }
fieldset { min-width: 0; }
.form-grid > *, .two-col > * { min-width: 0; }
.photo-input input[type=file] { max-width: 100%; }
fieldset > * { min-width: 0; }
input, select, textarea { max-width: 100%; }
fieldset { grid-template-columns: minmax(0, 1fr); }
.form-grid label, .money-group > * { min-width: 0; }

/* ---------------- Goldora theme (matches goldora.co) ---------------- */
.brand { display: flex; align-items: center; }
.brand img { height: 34px; width: auto; display: block; }
.topbar { box-shadow: 0 2px 8px rgba(80,0,30,.25); }
.topbar nav a { opacity: .92; }
.topbar nav a:hover { opacity: 1; }
.btn-small { background: var(--rose); color: var(--navy); border-color: var(--rose); font-weight: 700; }
.topbar button.link { color: var(--rose); }
.ratebar { background: var(--rose-light); border-bottom: 1px solid var(--line); color: var(--navy); }
h1 { color: var(--navy); }
th { background: var(--navy); color: #fff; font-weight: 600; }
th:first-child { border-top-right-radius: 8px; }
th:last-child { border-top-left-radius: 8px; }
tbody tr:nth-child(even) td { background: var(--rose-light); }
tr.clickable:hover td { background: var(--rose); }
table.pick tr.picked td { background: var(--rose); }
.report tr.tot td { background: var(--rose); }
.status-tile:hover { background: var(--rose-light); }
.card, .kpi, .status-tile { box-shadow: 0 1px 3px rgba(124,0,50,.06); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rose); }
.tabs a { background: var(--card); }
.gold-helper { background: var(--rose-light); border-color: #d9a3b0; }
.login-card { background: var(--card); text-align: center; }
.login-card form { text-align: right; }
.login-logo { width: 240px; max-width: 80%; height: auto; display: block; margin: 0 auto .25rem; }
.track-page { background: var(--bg); }
.track-logo { width: 220px; max-width: 75%; height: auto; display: block; margin: 0 auto .75rem; }
.receipt-table th, .kv th { background: none; color: var(--muted); }
.sticky-actions { background: var(--card); }
.photo-input input[type=file] { background: var(--rose-light); border-color: #d9a3b0; }
@media (max-width: 900px) { .brand img { height: 28px; } }
@media print { th { background: #eee !important; color: #000 !important; } tbody tr:nth-child(even) td { background: none !important; } }
.topbar a.btn-small { color: var(--navy); }
.topbar nav { gap: .25rem .85rem; font-size: .93rem; align-items: center; }
.topsearch input { width: 220px; }
[hidden] { display: none !important; }
.badge.shop-badge { background: var(--rose); color: var(--navy); font-weight: 700; vertical-align: middle; }
.shop-cover-check { background: var(--rose-light); border: 1px dashed #d9a3b0; border-radius: 8px; padding: .6rem .8rem; margin-bottom: .6rem; }
.otp-box { background: var(--rose-light); border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; }
.otp-box p { margin: 0 0 .5rem; }
.otp-input { font-size: 1.5rem; letter-spacing: .5rem; text-align: center; font-weight: 700; max-width: 220px; }
