@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@100;200;300;400;500;600;700&display=swap');

:root {
  --bg: #0b0d13;
  --bg2: #11141d;
  --panel: #161a26;
  --panel2: #1c2130;
  --line: #262c3d;
  --text: #e7ecf5;
  --muted: #8e98ad;
  --acc: #7aa2ff;
  --acc2: #b18cff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

a { color: var(--acc); text-decoration: none; }

/* ---------- Header ---------- */
header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: rgba(11,13,19,.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .2px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--acc), var(--acc2));
  display: grid; place-items: center; color: #0b0d13; font-weight: 700;
}
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }

.game-switch { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.game-switch button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 13px; padding: 7px 14px; border-radius: 9px; transition: .18s;
}
.game-switch button.on { background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #0b0d13; font-weight: 600; }

header .spacer { flex: 1; }

.btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  font-family: inherit; font-size: 13px; padding: 9px 16px; border-radius: 10px;
  cursor: pointer; transition: .18s; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--acc); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #0b0d13; border: 0; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ---------- Layout ---------- */
.wrap { flex: 1; display: flex; min-height: 0; }
nav.side {
  width: 232px; flex: 0 0 232px; border-left: 1px solid var(--line);
  background: var(--bg2); padding: 14px 10px; overflow-y: auto;
}
nav.side .grp { font-size: 11px; color: var(--muted); padding: 12px 10px 6px; letter-spacing: .5px; }
nav.side button {
  width: 100%; text-align: right; border: 0; background: transparent; color: var(--muted);
  font-family: inherit; font-size: 14px; padding: 10px 12px; border-radius: 10px;
  cursor: pointer; display: flex; align-items: center; gap: 10px; transition: .15s;
}
nav.side button:hover { background: var(--panel); color: var(--text); }
nav.side button.on { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--acc); }
nav.side button .ic { width: 20px; text-align: center; opacity: .9; }
nav.side button .cnt { margin-inline-start: auto; font-size: 11px; color: var(--muted); background: var(--panel); padding: 2px 7px; border-radius: 20px; }

main { flex: 1; overflow-y: auto; padding: 22px 26px 80px; }

/* ---------- Drop zone ---------- */
.drop {
  border: 2px dashed var(--line); border-radius: 20px; padding: 60px 30px; text-align: center;
  background: radial-gradient(1200px 300px at 50% 0%, rgba(122,162,255,.07), transparent);
  transition: .2s;
}
.drop.hot { border-color: var(--acc); background: rgba(122,162,255,.06); }
.drop h2 { font-weight: 600; font-size: 22px; margin-bottom: 8px; }
.drop p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.drop .paths { margin-top: 22px; font-size: 12px; color: var(--muted); line-height: 2; direction: ltr; }
.drop code { background: var(--panel); padding: 3px 8px; border-radius: 6px; font-size: 11.5px; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 9px; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }

.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }

.stat {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.stat label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.stat .row { display: flex; align-items: center; gap: 8px; }
.stat input[type=number], .stat input[type=text] {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font-family: inherit; font-size: 15px; padding: 8px 10px; border-radius: 9px; direction: ltr; text-align: left;
}
.stat input:focus { outline: 0; border-color: var(--acc); }
.stat .max { font-size: 11px; color: var(--muted); cursor: pointer; padding: 6px 8px; border-radius: 7px; background: var(--panel); border: 1px solid var(--line); }
.stat .max:hover { color: var(--acc); }

/* ---------- Toggle tiles ---------- */
.tile {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  cursor: pointer; transition: .15s; position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px; min-height: 74px;
}
.tile:hover { border-color: var(--acc); transform: translateY(-2px); }
.tile.on { border-color: var(--ok); background: linear-gradient(180deg, rgba(74,222,128,.1), var(--panel2)); }
.tile .t { font-size: 13.5px; font-weight: 500; line-height: 1.35; }
.tile .d { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.tile .dot { position: absolute; inset-inline-end: 10px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.tile.on .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.tile .cost { font-size: 11px; color: var(--acc); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.search {
  flex: 1; min-width: 180px; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-family: inherit; font-size: 13px; padding: 9px 13px; border-radius: 10px;
}
.search:focus { outline: 0; border-color: var(--acc); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  font-size: 12px; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); cursor: pointer; transition: .15s;
}
.chip.on { background: var(--acc); color: #0b0d13; border-color: var(--acc); font-weight: 600; }

/* ---------- Progress ---------- */
.bar { height: 8px; background: var(--panel2); border-radius: 20px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc2)); border-radius: 20px; transition: .4s; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.kpi b { display: block; font-size: 24px; font-weight: 600; }
.kpi span { font-size: 12px; color: var(--muted); }

/* ---------- Story slider ---------- */
.story { display: flex; flex-direction: column; gap: 8px; }
.story .step {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 11px;
  background: var(--panel2); border: 1px solid var(--line); cursor: pointer; transition: .15s;
}
.story .step:hover { border-color: var(--acc); }
.story .step.done { border-color: rgba(74,222,128,.5); background: linear-gradient(90deg, rgba(74,222,128,.08), var(--panel2)); }
.story .step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); font-size: 12px; color: var(--muted); }
.story .step.done .n { background: var(--ok); color: #0b0d13; font-weight: 700; }
.story .step .nm { flex: 1; }
.story .step .nm b { display: block; font-size: 14px; font-weight: 500; }
.story .step .nm span { font-size: 11.5px; color: var(--muted); }

/* ---------- Raw json ---------- */
textarea.raw {
  width: 100%; height: 60vh; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; padding: 14px;
  border-radius: 12px; direction: ltr; text-align: left; line-height: 1.6; resize: vertical;
}
textarea.raw:focus { outline: 0; border-color: var(--acc); }

table.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
table.kv th, table.kv td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.kv th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.kv td.k { direction: ltr; text-align: left; font-family: ui-monospace, monospace; font-size: 12px; color: var(--acc); }
table.kv input, table.kv select {
  background: var(--bg); border: 1px solid var(--line); color: var(--text); font-family: inherit;
  padding: 5px 8px; border-radius: 7px; font-size: 12.5px; direction: ltr; width: 100%;
}

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel2); border: 1px solid var(--line); border-inline-start: 3px solid var(--acc);
  padding: 12px 16px; border-radius: 11px; font-size: 13px; box-shadow: var(--shadow);
  animation: pop .25s ease; max-width: 340px;
}
.toast.ok { border-inline-start-color: var(--ok); }
.toast.bad { border-inline-start-color: var(--bad); }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 150; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; max-width: 560px; width: 100%; box-shadow: var(--shadow); max-height: 85vh; overflow-y: auto; }
.modal h3 { font-size: 18px; margin-bottom: 6px; }
.modal p { color: var(--muted); font-size: 13px; line-height: 1.7; margin-bottom: 16px; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; }

.hint { font-size: 12px; color: var(--muted); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; line-height: 1.8; }

.warnbox { border-inline-start: 3px solid var(--warn); background: rgba(251,191,36,.07); }

footer { padding: 16px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

@media (max-width: 860px) {
  nav.side { position: fixed; inset-inline-end: 0; top: 58px; bottom: 0; transform: translateX(100%); transition: .25s; z-index: 60; }
  nav.side.open { transform: none; }
  main { padding: 16px; }
  .brand small { display: none; }
}
