:root {
  --bg: #f4f6f8; --panel: #ffffff; --panel-2: #f8fafb; --text: #14202b; --muted: #64748b; --line: #e3e8ee;
  --accent: #0e9f9a; --accent-2: #0b7f7b; --accent-soft: #e0f5f4; --danger: #dc2626; --warn: #d97706; --ok: #16a34a;
  --side: #0f1f2c; --side-text: #b9c6d2; --shadow: 0 1px 2px rgba(15,31,44,.06), 0 8px 24px rgba(15,31,44,.06);
  --radius: 12px;
}
:root[data-theme="dark"] {
  --bg: #0b141c; --panel: #121e29; --panel-2: #172633; --text: #e6edf3; --muted: #8b9bab; --line: #243545;
  --accent: #2dd4cf; --accent-2: #5eead4; --accent-soft: #103a3a; --side: #08111a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", "Noto Sans Arabic", Tahoma, system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand svg { width: 30px; height: 30px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--side-text); text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: rgba(14,159,154,.2); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.side .grow { flex: 1; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; margin: 0; flex: 1; }
.content { padding: 24px 28px 48px; max-width: 1240px; width: 100%; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; transition: .12s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.icon { padding: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
input[type=text], input[type=password], input[type=number], select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.f { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 12.5px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .5px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-2); font-size: 12px; font-weight: 600; }
.badge.gray { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9aa7b4; margin-inline-end: 8px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.toggle { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

/* hero connect */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-bottom: 20px; }
.hero .connect { padding: 26px; background: linear-gradient(135deg, var(--accent-soft), var(--panel)); }
.hero h2 { margin: 0 0 4px; font-size: 20px; }
.idbox { display: flex; gap: 10px; margin-top: 16px; }
.idbox input { font-size: 22px; padding: 12px 16px; letter-spacing: 2px; text-align: center; direction: ltr; }
.stat { padding: 16px 18px; }
.stat .n { font-size: 28px; font-weight: 700; }
.bar { height: 6px; background: var(--line); border-radius: 9px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.cc { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--side); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .5px; }

/* table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 11px 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
.tw { overflow-x: auto; border-radius: var(--radius); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* modal & toast */
.mask { position: fixed; inset: 0; background: rgba(8,17,26,.55); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.modal { width: min(520px, 100%); max-height: 92vh; overflow: auto; padding: 22px; }
.modal h3 { margin: 0 0 8px; }
.toasts { position: fixed; inset-inline-start: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.toast { background: var(--side); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { background: var(--danger); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 500px at 70% -10%, var(--accent-soft), transparent), var(--bg); }
.login .card { width: min(400px, 100%); padding: 30px; }
.login .brand { color: var(--text); padding-bottom: 8px; }

/* session */
.session { position: fixed; inset: 0; background: #05090d; z-index: 60; display: flex; flex-direction: column; }
.sbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: #0f1f2c; color: #dbe5ee; flex-wrap: wrap; }
.sbar .btn { background: #172a3a; border-color: #223a4e; color: #dbe5ee; }
.sbar .btn:hover { border-color: var(--accent); }
.sbar .btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.sbar select { width: auto; background: #172a3a; border-color: #223a4e; color: #dbe5ee; padding: 6px 8px; }
.sbar .title { font-weight: 600; margin-inline-end: 8px; }
.stage { flex: 1; min-height: 0; display: flex; position: relative; }
.view { flex: 1; overflow: auto; display: grid; place-items: center; }
.view canvas { background: #000; outline: none; max-width: 100%; max-height: 100%; }
.view.actual canvas { max-width: none; max-height: none; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; color: #dbe5ee; background: rgba(5,9,13,.8); text-align: center; }
.spin { width: 38px; height: 38px; border: 3px solid #223a4e; border-top-color: var(--accent); border-radius: 50%; animation: sp 1s linear infinite; margin: 0 auto 14px; }
@keyframes sp { to { transform: rotate(360deg); } }
.panel { width: 320px; background: #0f1f2c; color: #dbe5ee; display: flex; flex-direction: column; border-inline-start: 1px solid #223a4e; }
.panel .hd { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid #223a4e; display: flex; justify-content: space-between; }
.panel .bd { flex: 1; overflow: auto; padding: 10px 12px; }
.msg { margin: 6px 0; padding: 6px 10px; border-radius: 10px; background: #172a3a; max-width: 90%; word-break: break-word; }
.msg.me { background: var(--accent-2); margin-inline-start: auto; }
.panel input[type=text] { background: #172a3a; border-color: #223a4e; color: #dbe5ee; }
.fsrow { display: flex; justify-content: space-between; padding: 5px 4px; border-radius: 6px; cursor: pointer; gap: 8px; }
.fsrow:hover { background: #172a3a; }
.rec { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #ef4444; animation: bl 1s infinite; margin-inline-end: 6px; }
@keyframes bl { 50% { opacity: .25; } }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; }
  .brand { display: none; }
  .nav { display: flex; }
  .hero { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .panel { width: 100%; position: absolute; inset-block: 0; inset-inline-end: 0; z-index: 3; }
}
