:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --hover: #eef2f8;
  --select: #dbe9fb;
  --line: #e3e7ee;
  --text: #1d2330;
  --muted: #646d7c;
  --brand: #0b6bcb;
  --brand-dark: #0957a8;
  --brand-soft: #e3effc;
  --pitch: #17b26a;
  --pitch-soft: #e3f6ec;
  --danger: #d93025;
  --shadow: 0 1px 3px rgba(20, 30, 50, .12), 0 4px 14px rgba(20, 30, 50, .08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Tahoma, "Noto Sans Arabic", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--brand); text-decoration: none; }
.muted { color: var(--muted); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
svg.i { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* ---------- top bar ---------- */
.top { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.logo { display: flex; align-items: center; gap: 10px; width: 232px; flex: none; font-size: 20px; color: #3c4350; white-space: nowrap; }
.logo img { width: 40px; height: 40px; }
.logo b { font-weight: 600; color: var(--text); }
.search { flex: 1; max-width: 720px; height: 48px; background: #e9eef6; border-radius: 24px; display: flex; align-items: center; gap: 10px; padding: 0 16px; transition: background .15s, box-shadow .15s; }
.search:focus-within { background: #fff; box-shadow: var(--shadow); }
.search input { border: 0; background: transparent; outline: none; flex: 1; font-size: 16px; }
.top .grow { flex: 1; }
.ibtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; display: inline-grid; place-items: center; cursor: pointer; color: #444c5a; flex: none; }
.ibtn:hover { background: var(--hover); }
.ibtn.on { background: var(--brand-soft); color: var(--brand); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; cursor: pointer; border: 0; }
.langbtn { border: 1px solid var(--line); background: #fff; border-radius: 18px; padding: 6px 12px; cursor: pointer; }

/* ---------- layout ---------- */
.layout { display: flex; height: calc(100vh - 64px); }
.side { width: 256px; flex: none; padding: 8px 12px 16px 8px; display: flex; flex-direction: column; overflow-y: auto; }
[dir=rtl] .side { padding: 8px 8px 16px 12px; }
.newbtn { display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 22px 0 18px; border-radius: 16px; border: 0; background: #fff; box-shadow: var(--shadow); cursor: pointer; font-weight: 500; font-size: 15px; margin: 4px 0 14px 4px; align-self: flex-start; }
.newbtn:hover { background: #f4f8fd; }
.newbtn svg { width: 24px; height: 24px; }
.nav { display: flex; align-items: center; gap: 16px; height: 34px; padding: 0 16px; border-radius: 17px; cursor: pointer; color: #2d3440; border: 0; background: none; width: 100%; text-align: start; font-size: 14px; }
.nav:hover { background: #e9edf3; }
.nav.on { background: var(--select); color: #062e6f; font-weight: 600; }
.side .sep { height: 1px; background: var(--line); margin: 10px 8px; }
.side .grow { flex: 1; }
.storage { padding: 10px 16px; font-size: 13px; color: var(--muted); }
.meter { height: 4px; background: #dfe4ec; border-radius: 2px; overflow: hidden; margin: 8px 0 6px; }
.meter > div { height: 100%; background: var(--brand); }
.meter.warn > div { background: var(--danger); }
.main { flex: 1; min-width: 0; background: var(--surface); border-radius: 16px; margin: 0 16px 16px 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }
[dir=rtl] .main { margin: 0 0 16px 16px; }
.mainhead { display: flex; align-items: center; gap: 8px; padding: 14px 20px 6px; min-height: 64px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 2px; font-size: 22px; flex: 1; min-width: 0; flex-wrap: wrap; }
.crumbs button { border: 0; background: none; font-size: inherit; padding: 4px 10px; border-radius: 18px; cursor: pointer; color: var(--muted); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.crumbs button:last-child { color: var(--text); }
.crumbs button:hover { background: var(--hover); }
.crumbs .chev { color: var(--muted); font-size: 18px; }
.chips { display: flex; gap: 8px; padding: 0 20px 8px; flex-wrap: wrap; align-items: center; }
.selbar, .selbar-empty { height: 48px; margin: 0 20px 8px; padding: 0 8px; flex-wrap: nowrap; }
.selbar { background: #e9eef6; border-radius: 24px; }
.selbar-empty { font-size: 13px; padding: 0 4px; }
.chip { height: 32px; border: 1px solid #c4cbd6; border-radius: 8px; background: #fff; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
select.chip, input.chip { outline: none; cursor: pointer; }
input.chip { cursor: text; }
.chip.on { background: var(--brand-soft); border-color: var(--brand-soft); color: #062e6f; }
.content { flex: 1; overflow: auto; padding: 4px 20px 30px; position: relative; }
.content.drop { outline: 2px dashed var(--brand); outline-offset: -8px; background: #f2f8ff; }
.section-title { font-size: 14px; font-weight: 500; margin: 14px 4px 10px; color: #3c4350; }
.empty { display: grid; place-items: center; text-align: center; padding: 70px 20px; color: var(--muted); }
.empty img { width: 90px; opacity: .9; margin-bottom: 14px; }
.empty h3 { color: var(--text); font-weight: 500; margin: 0 0 6px; font-size: 20px; }

/* ---------- grid ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.fcard { height: 48px; border-radius: 12px; background: #eef2f8; display: flex; align-items: center; gap: 12px; padding: 0 6px 0 14px; cursor: pointer; user-select: none; }
[dir=rtl] .fcard { padding: 0 14px 0 6px; }
.fcard:hover { background: #e2e8f1; }
.fcard.sel { background: var(--select); }
.fcard .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.fcard.dragover, tr.dragover td { background: #cfe3fa !important; }
.card { border-radius: 12px; background: #eef2f8; padding: 0 0 10px; cursor: pointer; user-select: none; display: flex; flex-direction: column; overflow: hidden; }
.card:hover { background: #e2e8f1; }
.card.sel { background: var(--select); }
.card .ttl { display: flex; align-items: center; gap: 10px; padding: 8px 4px 8px 14px; }
[dir=rtl] .card .ttl { padding: 8px 14px 8px 4px; }
.card .ttl .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 13.5px; }
.thumb { margin: 0 10px; aspect-ratio: 16 / 9; border-radius: 8px; background: #fff; position: relative; overflow: hidden; display: grid; place-items: center; }
.thumb img.t { width: 100%; height: 100%; object-fit: cover; }
.thumb img.t.logo { object-fit: contain; padding: 14px; }
.thumb .ph { width: 54px; height: 54px; opacity: .85; }
.thumb .dur { position: absolute; bottom: 6px; inset-inline-end: 6px; background: rgba(0, 0, 0, .75); color: #fff; font-size: 11.5px; padding: 1px 6px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.thumb .play { position: absolute; width: 42px; height: 42px; border-radius: 50%; background: rgba(0, 0, 0, .45); display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.card:hover .thumb .play { opacity: 1; }
.thumb .play svg { fill: #fff; width: 22px; height: 22px; }
.card .meta { padding: 8px 14px 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.scorebar { position: absolute; top: 6px; inset-inline-start: 6px; display: flex; align-items: center; gap: 5px; background: rgba(255, 255, 255, .94); border-radius: 6px; padding: 3px 7px; font-size: 12px; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.scorebar img { width: 18px; height: 18px; object-fit: contain; }
.badge-share { color: var(--muted); }

/* ---------- list ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: start; font-weight: 500; color: #3c4350; font-size: 13px; padding: 10px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; white-space: nowrap; }
table.list td { padding: 0 8px; height: 48px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }
table.list tr.row { cursor: pointer; user-select: none; }
table.list tr.row:hover td { background: #f3f6fa; }
table.list tr.row.sel td { background: var(--select); }
table.list .nmcell { display: flex; align-items: center; gap: 14px; }
table.list .nmcell span { overflow: hidden; text-overflow: ellipsis; }
table.list .mini { width: 44px; height: 26px; border-radius: 4px; object-fit: cover; flex: none; background: #eef2f8; }
.num { text-align: end !important; font-variant-numeric: tabular-nums; }

/* ---------- matches ---------- */
.mgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.mcard { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; background: #fff; transition: box-shadow .15s, border-color .15s; }
.mcard:hover { box-shadow: var(--shadow); border-color: transparent; }
.mcard .thumb { margin: 0; border-radius: 0; background: #0f1a2b; }
.mcard .thumb .ph { opacity: .5; }
.mcard .body { padding: 12px 14px 14px; }
.mcard .comp { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.mcard .comp img { width: 18px; height: 18px; object-fit: contain; }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.team { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-weight: 600; font-size: 13.5px; min-width: 0; }
.team span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.tlogo { width: 44px; height: 44px; object-fit: contain; }
.tlogo.ph { border-radius: 50%; background: #eef2f8; display: grid; place-items: center; color: var(--muted); font-size: 15px; font-weight: 700; }
.score { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; gap: 8px; }
.score.vs { font-size: 15px; color: var(--muted); font-weight: 600; }
.mcard .foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--muted); align-items: center; }
.tag { background: #eef2f8; border-radius: 6px; padding: 2px 8px; font-size: 12px; color: #3c4350; }
.tag.q { background: var(--pitch-soft); color: #0b7a47; font-weight: 600; }

/* ---------- menus, modals ---------- */
.menu { position: fixed; z-index: 60; background: #fff; border-radius: 8px; box-shadow: 0 4px 20px rgba(20, 30, 50, .22); padding: 6px 0; min-width: 220px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 14px; border: 0; background: none; padding: 0 16px; height: 36px; cursor: pointer; text-align: start; font-size: 14px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 0; }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 22, 35, .45); display: grid; place-items: center; z-index: 70; padding: 16px; }
.modal { background: #fff; border-radius: 24px; width: min(520px, 100%); max-height: 92vh; overflow: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(760px, 100%); }
.modal h2 { margin: 0 0 18px; font-weight: 500; font-size: 22px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; align-items: center; }
.btn { height: 38px; padding: 0 20px; border-radius: 19px; border: 1px solid #c4cbd6; background: #fff; cursor: pointer; font-weight: 500; color: var(--brand); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: #f2f7fd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.text { border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea, input.inp, select.inp {
  width: 100%; height: 42px; border: 1px solid #c4cbd6; border-radius: 8px; padding: 0 12px; background: #fff; outline: none;
}
.field textarea { height: auto; min-height: 70px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, input.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.inline { display: flex; gap: 8px; align-items: flex-end; }
.inline .field { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 6px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.linkbox { display: flex; gap: 8px; align-items: center; background: #f3f6fa; border-radius: 10px; padding: 8px 8px 8px 14px; margin: 8px 0; }
.linkbox input { flex: 1; border: 0; background: transparent; outline: none; font-size: 13px; direction: ltr; }
.sharelist { margin-top: 14px; border-top: 1px solid var(--line); }
.sharelist .s { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.sharelist .s .info { flex: 1; min-width: 0; }
.scoreinp { display: grid; grid-template-columns: 1fr 70px 20px 70px 1fr; align-items: end; gap: 8px; }
.scoreinp .dash { text-align: center; padding-bottom: 12px; font-weight: 700; }
.logobox { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.logobox img, .logobox .ph { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; background: #f3f6fa; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.tree { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.tree button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: start; }
.tree button:hover { background: var(--hover); }
.tree button.on { background: var(--select); }
.tree button:disabled { opacity: .4; cursor: default; }

/* ---------- details panel ---------- */
.details { width: 340px; flex: none; background: #fff; border-radius: 16px; margin: 0 16px 16px 0; overflow-y: auto; padding: 16px 20px; }
[dir=rtl] .details { margin: 0 0 16px 16px; }
.details .dh { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.details .dh b { flex: 1; font-weight: 500; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details .prev { border-radius: 10px; overflow: hidden; background: #eef2f8; aspect-ratio: 16 / 9; display: grid; place-items: center; margin-bottom: 16px; }
.details .prev img { width: 100%; height: 100%; object-fit: cover; }
.details .prev img.logo { object-fit: contain; padding: 18px; }
.details h4 { margin: 18px 0 8px; font-weight: 500; font-size: 14px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-word; }

/* ---------- uploads panel ---------- */
.uppanel { position: fixed; bottom: 0; inset-inline-end: 24px; width: 380px; background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 4px 24px rgba(20, 30, 50, .28); z-index: 55; overflow: hidden; }
.uppanel .uh { background: #f0f4f9; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 18px; height: 54px; font-weight: 500; }
[dir=rtl] .uppanel .uh { padding: 0 18px 0 8px; }
.uppanel .uh span { flex: 1; }
.uppanel .ul { max-height: 300px; overflow-y: auto; }
.uprow { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.uprow .ui { flex: 1; min-width: 0; }
.uprow .un { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.uprow .us { font-size: 12px; color: var(--muted); margin-top: 3px; }
.uprow .bar { height: 4px; background: #e3e7ee; border-radius: 2px; overflow: hidden; margin-top: 6px; }
.uprow .bar > div { height: 100%; background: var(--brand); transition: width .2s; }
.uprow.done .bar > div { background: var(--pitch); }
.uprow.err .us { color: var(--danger); }
.ok-dot { color: var(--pitch); }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; background: rgba(10, 12, 16, .96); z-index: 65; display: flex; flex-direction: column; color: #e8eaed; }
.vbar { height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.vbar b { flex: 1; font-weight: 500; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbar .ibtn { color: #e8eaed; }
.vbar .ibtn:hover { background: rgba(255, 255, 255, .12); }
.vbody { flex: 1; display: flex; min-height: 0; }
.vstage { flex: 1; display: grid; place-items: center; padding: 10px 20px 24px; min-width: 0; }
.vstage video, .vstage img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 6px; background: #000; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.vstage img { background: #fff; }
.vstage .err { max-width: 460px; text-align: center; color: #c8ccd2; line-height: 1.6; }
.vside { width: 340px; flex: none; background: #1d2027; margin: 0 12px 16px 0; border-radius: 14px; padding: 18px; overflow-y: auto; }
[dir=rtl] .vside { margin: 0 0 16px 12px; }
.vside .teams .team { color: #fff; }
.vside .tlogo.ph { background: #2c313b; color: #9aa3b2; }
.vside .kv .k { color: #9aa3b2; }
.vside .comp { color: #9aa3b2; font-size: 12.5px; display: flex; gap: 6px; align-items: center; margin-bottom: 14px; }
.vside .comp img { width: 20px; height: 20px; object-fit: contain; }
.vside .btn { background: transparent; color: #8ab4f8; border-color: #5f6672; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login form { background: #fff; width: min(450px, 100%); border-radius: 28px; padding: 40px 36px; box-shadow: var(--shadow); }
.login img { width: 56px; }
.login h1 { font-weight: 400; font-size: 28px; margin: 14px 0 6px; }
.login .err { color: var(--danger); min-height: 22px; margin: 6px 0; font-size: 13px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 24px; inset-inline-start: 24px; background: #2f3440; color: #fff; padding: 14px 20px; border-radius: 6px; z-index: 90; box-shadow: var(--shadow); max-width: 480px; display: flex; gap: 16px; align-items: center; }
.toast.err { background: #b3261e; }
.toast button { border: 0; background: none; color: #8ab4f8; font-weight: 600; cursor: pointer; }

/* ---------- page tables (users, teams, shares) ---------- */
.ptable { width: 100%; border-collapse: collapse; }
.ptable th { text-align: start; font-weight: 500; font-size: 13px; color: #3c4350; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.ptable td { padding: 8px; border-bottom: 1px solid var(--line); height: 54px; }
.ptable img.lg { width: 34px; height: 34px; object-fit: contain; }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 12px 18px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .details { display: none; } }
@media (max-width: 860px) {
  .top { gap: 6px; padding: 0 8px; } .search { min-width: 0; padding: 0 12px; } .search input { font-size: 14px; min-width: 0; }
  .langbtn { padding: 6px 8px; font-size: 12px; } .top .grow { display: none; }
  .logo { width: auto; } .logo span { display: none; }
  .side { position: fixed; z-index: 58; background: var(--bg); height: calc(100vh - 64px); top: 64px; inset-inline-start: 0; box-shadow: var(--shadow); transform: translateX(-110%); transition: transform .2s; }
  [dir=rtl] .side { transform: translateX(110%); }
  .side.open { transform: none !important; }
  .main { margin: 0 8px 8px !important; }
  .vside { display: none; }
  .uppanel { inset-inline-end: 0; width: 100%; }
  .row3 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 861px) { .menu-toggle { display: none !important; } }
