:root { --bg:#17181a; --panel:#212326; --panel2:#2a2d31; --line:#383c42; --ink:#f1f1f2; --muted:#a2a7b0; --red:#ff2a2a; --good:#3ecf8e; --warn:#ffb020; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Tajawal, "Segoe UI", Tahoma, sans-serif; font-size: 15.5px; line-height: 1.6; }
h1, h2, h3 { font-family: Cairo, Tajawal, sans-serif; margin: 0; line-height: 1.4; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.05rem; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-height: 42px; }
input:focus, select:focus, textarea:focus { border-color: var(--red); outline: 0; }
input[type=checkbox] { width: 20px; min-height: 20px; }
textarea { min-height: 90px; resize: vertical; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--red); color: #fff; border: 0; border-radius: 8px; padding: 9px 18px; min-height: 42px; cursor: pointer; text-decoration: none; font-weight: 700; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.btn.good { background: #198a58; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .88rem; }
.btn:disabled { opacity: .5; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: 12px; padding: 28px; display: grid; gap: 14px; }
.brand { font-family: Cairo, sans-serif; font-weight: 700; font-size: 1.3rem; direction: ltr; }
.brand span { color: var(--red); }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #0f1011; border-inline-end: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { padding: 0 10px 14px; }
.side a, .side button { text-align: start; text-decoration: none; padding: 9px 12px; border-radius: 8px; background: none; border: 0; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.side a:hover, .side button:hover { background: var(--panel); }
.side a.on { background: var(--red); color: #fff; }
.side .grow { flex: 1; }
.badge { background: var(--warn); color: #000; border-radius: 99px; padding: 0 8px; font-size: .78rem; font-weight: 700; }
main { padding: 26px; min-width: 0; display: grid; gap: 18px; align-content: start; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; text-decoration: none; display: block; }
.stat span { color: var(--muted); font-size: .88rem; display: block; }
.stat b { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.form label { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); min-width: 0; }
.form .full { grid-column: 1 / -1; }
.form label.check { display: flex; gap: 8px; align-items: center; min-height: 42px; }
.muted { color: var(--muted); }
.filterbox > summary { cursor: pointer; padding: 8px 0; color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: embed; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover { background: var(--panel2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; background: var(--bg); }
.pill { display: inline-block; border-radius: 99px; padding: 1px 10px; font-size: .82rem; border: 1px solid var(--warn); color: var(--warn); white-space: nowrap; }
.s-paid, .s-shipped, .s-delivered { border-color: var(--good); color: var(--good); }
.s-cancelled, .s-expired, .s-payment_rejected, .s-dismissed { border-color: #ff7a7a; color: #ff7a7a; }
.s-awaiting_verification { background: var(--warn); color: #000; }
.low { color: var(--warn); font-weight: 700; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.time { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.time li { border-inline-start: 2px solid var(--line); padding: 4px 14px 12px; position: relative; }
.time li::before { content: ""; position: absolute; inset-inline-start: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.time small { color: var(--muted); display: block; }
.images { display: flex; flex-wrap: wrap; gap: 12px; }
.images figure { margin: 0; display: grid; gap: 6px; justify-items: center; }
.images img { width: 130px; height: 130px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.images figure.main img { border: 3px solid var(--good); }
.picker { display: grid; gap: 12px; }
.picker .images:empty { display: none; }
.shot { max-width: 100%; max-height: 520px; border-radius: 10px; border: 1px solid var(--line); }
.qr { width: 180px; background: #fff; padding: 8px; border-radius: 10px; }
.icons { display: flex; gap: 10px; flex-wrap: wrap; }
.icons svg, .ico { width: 28px; height: 28px; fill: none; stroke: var(--red); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--good); color: #000; font-weight: 700; padding: 10px 20px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 20; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); color: #fff; }

@media (max-width: 860px) {
  .shell { display: block; }
  .side { position: sticky; top: 0; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 10px; z-index: 10; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .side .brand, .side .grow { display: none; }
  .side a, .side button { white-space: nowrap; }
  main { padding: 16px; }
  .two { grid-template-columns: 1fr; }
  /* tables become stacked cards */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 10px; }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: end; }
  table.stack td::before { content: attr(data-l); color: var(--muted); text-align: start; }
}
