/* SAB Gold Screen — control panel. RTL, compact, one page per task. */
:root {
  --ink: #0A2026;
  --green: #0F4F4F;
  --green-2: #1A6B6B;
  --gold: #B89A5E;
  --gold-soft: #F4EEDF;
  --pearl: #F3F4F2;
  --card: #FFFFFF;
  --line: #E1E4E0;
  --text: #16282C;
  --muted: #64737A;
  --ok: #1E7B4F;
  --ok-bg: #E5F3EC;
  --err: #A33B32;
  --err-bg: #FBEAE8;
  --warn: #8A5A00;
  --warn-bg: #FFF4DB;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--pearl);
  color: var(--text);
  font: 15px/1.5 "Tajawal", system-ui, sans-serif;
}
a { color: var(--green-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono, .num { font-family: "IBM Plex Mono", ui-monospace, monospace; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* top bar */
.topbar {
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { color: #fff; font-weight: 800; font-size: 17px; display: flex; align-items: center; }
.brand:hover { text-decoration: none; }
.brand .mark { color: var(--gold); margin-left: 8px; font-size: 20px; }
.brand small { color: #9FB3B6; font-weight: 500; font-size: 12px; margin-right: 8px; letter-spacing: .5px; }
.topbar nav { display: flex; margin-right: 28px; flex: 1; }
.topbar nav a { color: #C9D6D8; padding: 0 14px; line-height: 56px; border-bottom: 3px solid transparent; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a.on { color: #fff; border-bottom-color: var(--gold); }
.topbar form { margin: 0; }
.topbar .who { color: #9FB3B6; font-size: 13px; margin-left: 12px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 18px 20px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head h1 small { color: var(--muted); font-weight: 500; font-size: 14px; margin-right: 6px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card > h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; }
.card > h2 small { color: var(--muted); font-weight: 500; font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.hl { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat.hl .k, .stat.hl .s { color: #9FB3B6; }
.stat.hl .v { color: var(--gold); }

/* alerts */
.alert { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert form { margin: 0 12px 0 0; }
.errors { margin: 0; padding-right: 18px; }

/* badges */
.badge { display: inline-block; border-radius: 99px; padding: 1px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.gold { background: var(--gold-soft); color: #7A6232; }
.badge.grey { background: #ECEFEC; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #B8C0BC; margin-left: 6px; }
.dot.on { background: #27A35F; box-shadow: 0 0 0 3px rgba(39,163,95,.18); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 14px; font: inherit; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--green-2); text-decoration: none; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }

/* forms */
label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; border: 1px solid #CDD3CF; border-radius: 8px; padding: 7px 10px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(26,107,107,.25); border-color: var(--green-2); }
input[readonly] { background: #F6F7F5; color: var(--muted); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; font-weight: 500; font-size: 14px; margin-bottom: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 0 0 0 8px; accent-color: var(--green); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.inline { display: flex; gap: 6px; }
.inline select { width: auto; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px; border-bottom: 1px solid #EEF0ED; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: left; }
.table th.num { font-family: inherit; }
.table input[type=number] { width: 96px; text-align: left; }
.table select { width: auto; padding: 6px; }
.table .price { font-weight: 700; font-size: 16px; }
.table .price.sell { color: var(--green); }
.table .price.buy { color: #7A6232; }
.table tr.off td { opacity: .5; }
.metal { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.metal.gold { background: linear-gradient(135deg, #E9CF8C, #B89A5E); }
.metal.silver { background: linear-gradient(135deg, #F1F3F4, #A8B0B4); }

.locked .margin-cell { opacity: .55; }
.locked .margin-cell select { pointer-events: none; }

.link-box { display: flex; gap: 6px; }
.link-box input { direction: ltr; font-family: "IBM Plex Mono", monospace; font-size: 12px; }
.logo-thumb { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: var(--pearl); border: 1px solid var(--line); vertical-align: middle; }
.logo-thumb.big { width: 96px; height: 96px; }
.shop-name { display: flex; align-items: center; gap: 10px; }
.shop-name b { display: block; }

/* ads */
.ads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.ad-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ad-card .media { aspect-ratio: 16 / 9; background: var(--ink); display: flex; align-items: center; justify-content: center; }
.ad-card .media img, .ad-card .media video { width: 100%; height: 100%; object-fit: contain; }
.ad-card form { padding: 10px; margin: 0; }
.ad-card .row { display: flex; gap: 8px; margin-bottom: 8px; }
.ad-card .row > div { flex: 1; }
.ad-card.off { opacity: .55; }

details.card > summary { cursor: pointer; font-weight: 700; font-size: 16px; list-style: none; display: flex; justify-content: space-between; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; color: var(--muted); }
details.card[open] > summary { margin-bottom: 12px; }
details.card[open] > summary::after { content: "▴"; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, #133a40, var(--ink) 60%); }
.login-card { background: #fff; width: 100%; max-width: 380px; border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .brand-line { color: var(--gold); font-weight: 800; letter-spacing: .5px; margin-bottom: 18px; }
.login-card .btn { width: 100%; padding: 10px; margin-top: 6px; }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; }
  .topbar nav { order: 3; width: 100%; margin: 4px 0 0; overflow-x: auto; }
  .topbar nav a { line-height: 40px; }
  .wrap { padding: 12px; }
  .table-scroll { overflow-x: auto; }
}
