/* gateway.dash.ps — واجهة المالك. لا أنماط داخلية: CSP يمنعها، فكل شيء هنا. */
:root {
  --bg: #0B1220; --panel: #0E1626; --card: #111A2C; --chip: #16233D;
  --line: #22304D; --line2: #1C2840; --field: #2A3A5C;
  --fg: #E6EAF2; --muted: #8C97AD; --muted2: #A3AEC4; --faint: #6F7A90;
  --accent: #3D7BF0; --link: #7FB0FF; --link2: #A9C9FF;
  --green: #2FBF71; --green-bg: #0F2A1E; --green-line: #1D4A33;
  --amber: #F5A524; --amber-bg: #221A0A; --amber-line: #4A3A16;
  --red: #F0525A; --red-bg: #2E1418; --red-line: #4A2229;
  --gray-bg: #1A2235;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.6 'IBM Plex Sans Arabic', 'Noto Sans Arabic', system-ui, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link2); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
h1 { margin: 0; font-size: 24px; font-weight: 700; text-wrap: balance; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); } .muted2 { color: var(--muted2); } .faint { color: var(--faint); }
.small { font-size: 12px; } .s13 { font-size: 13px; }
.ok { color: var(--green); } .warn { color: var(--amber); } .bad { color: var(--red); }
.hidden { display: none !important; }

/* ── الهيكل ── */
.shell { display: flex; min-height: 100vh; }
.side {
  flex: 0 0 260px; background: var(--panel); border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px; padding: 22px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 6px; }
.brand-dot { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 14px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; color: var(--faint); letter-spacing: .04em; padding: 0 10px 4px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 38px; padding: 0 10px;
  border-radius: 10px; color: var(--muted2); font-size: 14px;
}
.nav-item:hover { background: var(--chip); color: var(--fg); }
.nav-item.active { background: var(--chip); color: var(--fg); font-weight: 600; box-shadow: inset -3px 0 0 var(--accent); }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--amber); color: #1B1405; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.main { flex: 1 1 auto; min-width: 0; padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .sub { font-size: 13px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 2 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.col-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* شريط الهاتف */
.topbar { display: none; }
.tabbar { display: none; }
@media (max-width: 900px) {
  .side { display: none; }
  .main { padding: 16px 16px 96px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5;
  }
  .shell { flex-direction: column; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; inset-inline: 0; bottom: 0; z-index: 5;
    background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0; font-size: 12px; color: var(--muted2); position: relative; }
  .tabbar a.active { color: var(--fg); font-weight: 600; }
  .tabbar .badge { position: absolute; top: 4px; inset-inline-start: calc(50% + 8px); min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }
  h1 { font-size: 21px; }
}

/* ── المكوّنات ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card.panel { background: var(--panel); }
.card .line { border-top: 1px solid var(--line2); padding-top: 10px; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.fact .k { font-size: 12px; color: var(--muted); }
.fact .v { font-size: 16px; font-weight: 600; }
.notice { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted2); }
.notice.warn { border-color: var(--amber-line); background: var(--amber-bg); color: var(--amber); }
.notice.bad { border-color: var(--red-line); background: var(--red-bg); color: var(--red); }
.notice.ok { border-color: var(--green-line); background: var(--green-bg); color: var(--green); }

.btn { height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--field); background: transparent; color: var(--fg); font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--link); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #5590F5; }
.btn.danger { border-color: var(--red-line); color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn.warn { border-color: var(--amber-line); color: var(--amber); }
.btn.sm { height: 34px; padding: 0 12px; border-radius: 9px; font-size: 12px; }
.btn.block { width: 100%; height: 48px; }
.btn.link { border: 0; padding: 0; height: auto; color: var(--link); font-size: 13px; }

.chip { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 3px 9px; display: inline-block; white-space: nowrap; }
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.warn { background: var(--amber-bg); color: var(--amber); }
.chip.bad { background: var(--red-bg); color: var(--red); }
.chip.gray { background: var(--gray-bg); color: var(--muted); }
.chip.blue { background: var(--chip); color: var(--link2); font-family: 'IBM Plex Mono', monospace; font-weight: 500; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; border-radius: 999px; padding: 5px 12px; border: 1px solid var(--line); }
.pill.ok { color: var(--green); border-color: var(--green-line); background: var(--green-bg); }
.pill.bad { color: var(--red); border-color: var(--red-line); background: var(--red-bg); }
.pill.warn { color: var(--amber); border-color: var(--amber-line); background: var(--amber-bg); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted2); font-size: 13px; }
.tab.on { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 600; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.input, select.input, textarea.input { height: 42px; border-radius: 10px; border: 1px solid var(--field); background: var(--bg); color: var(--fg); font-size: 14px; padding: 0 12px; width: 100%; min-width: 0; }
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.input.code { font-family: 'IBM Plex Mono', monospace; letter-spacing: .3em; text-align: center; font-size: 22px; height: 54px; direction: ltr; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--panel); color: var(--muted); font-weight: 500; text-align: right; padding: 10px 14px; white-space: nowrap; }
td { border-top: 1px solid var(--line2); padding: 10px 14px; vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #0F1930; }
tr.sel td { background: var(--chip); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* الموافقة */
.ap-item { display: flex; flex-direction: column; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; cursor: pointer; text-align: start; width: 100%; color: var(--fg); }
.ap-item:hover { border-color: var(--field); }
.ap-item.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.side-buy { color: var(--green); font-weight: 700; }
.side-sell { color: var(--red); font-weight: 700; }
.big { font-size: 28px; font-weight: 700; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; border-top: 1px solid var(--line2); padding-top: 8px; }
.kv > :first-child { color: var(--muted); }
.timer { font-family: 'IBM Plex Mono', monospace; font-size: 13px; }

/* الدخول */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.login-card .brand { justify-content: center; font-size: 20px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }

/* نافذة */
.modal-back { position: fixed; inset: 0; background: rgba(5, 9, 18, .72); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow-y: auto; }
.modal.wide { max-width: 720px; }
.toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%); z-index: 30; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-size: 13px; max-width: calc(100vw - 32px); }
.toast.bad { border-color: var(--red-line); color: var(--red); }
.toast.ok { border-color: var(--green-line); color: var(--green); }
@media (max-width: 900px) { .toast { bottom: 88px; } }
.secret { background: var(--bg); border: 1px dashed var(--amber-line); border-radius: 10px; padding: 12px; word-break: break-all; font-family: 'IBM Plex Mono', monospace; font-size: 13px; direction: ltr; }
.grant-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 10px; align-items: end; border-top: 1px solid var(--line2); padding-top: 10px; }
@media (max-width: 700px) { .grant-row { grid-template-columns: 1fr 1fr; } }
.doc-method { font-weight: 600; }
.m-get { color: var(--green); } .m-post, .m-put, .m-patch { color: var(--amber); } .m-delete { color: var(--red); }
.grant-row [data-span] { grid-column: 1 / -1; }
.kv select.input { width: auto; min-width: 180px; height: 36px; font-size: 13px; }
.subnav { display: none; }
a.tab { display: inline-flex; align-items: center; }
@media (max-width: 900px) {
  .subnav { display: flex; flex-wrap: nowrap; overflow-x: auto; padding: 12px 16px 0; }
  .subnav .tab { flex: none; }
}

/* ── الوسطاء: اختيار الوسيط، الأدوات، Binance ── */
.broker-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.broker-card { color: var(--fg); border-radius: 16px; transition: border-color .15s; }
.broker-card:hover { border-color: var(--accent); color: var(--fg); }
.broker-card.off { opacity: .55; pointer-events: none; }
.broker-mark { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff; flex: none; }
.broker-mark.m-metaapi { background: #3D7BF0; }
.broker-mark.m-ibkr { background: #C8102E; }
.broker-mark.m-binance { background: #F0B90B; color: #1E2026; }
.s16 { font-size: 16px; }
.grow { flex: 1 1 auto; min-width: 0; }
.row.nowrap { flex-wrap: nowrap; }
.inst-list { gap: 0; max-height: 360px; overflow-y: auto; }
.inst-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line2); min-width: 0; }
.inst-row:first-child { border-top: 0; }
.inst-sym { flex: 0 0 auto; font-weight: 600; }
.inst-desc { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.res-box { gap: 0; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--bg); max-height: 260px; overflow-y: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; background: var(--bg); }
.seg-b { height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted2); font-size: 13px; }
.seg-b.on { background: var(--chip); color: var(--fg); font-weight: 600; }
.ip-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px dashed var(--amber-line); background: var(--amber-bg); border-radius: 10px; padding: 10px 12px; }
.acct-pick.off { opacity: .5; }
.sym-list { gap: 2px; max-height: 320px; overflow-y: auto; }
.check.maybe { color: var(--muted); }
.broker-q { border: 1px solid var(--amber-line); background: var(--bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 560px) { .row.nowrap { flex-wrap: wrap; } .inst-desc { white-space: normal; } }
.sec-h { margin-top: 18px; margin-bottom: 8px; }
