:root {
  --accent: #5B2E91; --accent-dark: #3F1D68; --accent-soft: #F1ECF8;
  --bg: #F6F4F9; --text: #1C1726; --muted: #6E6680; --border: #ECE8F2;
  --stage: #17131F; --danger: #D93A3A; --ok: #2E9E6A; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.35; }
h1 { font-size: 24px; font-weight: 700; } h2 { font-size: 18px; font-weight: 600; } h3 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.inline { display: inline; margin: 0; }

/* header */
.topbar { height: 64px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 20px; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.brand-text strong { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); flex: none; }
.avatar-lg { width: 96px; height: 96px; border-width: 3px; box-shadow: 0 0 0 3px var(--accent); margin-bottom: 16px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav-link { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.nav-link:hover { background: var(--accent-soft); color: var(--accent); }

/* chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); text-decoration: none; white-space: nowrap; border: 1px solid transparent; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.chip-ok { background: #E9F6EF; color: #1F7A50; }
.chip-bad { background: #FDECEC; color: #B42D2D; }
.chip-off { background: #F1EFF4; color: var(--muted); }

/* buttons + forms */
.btn { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--accent); color: #fff; } .btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--accent); border-color: #D9CCEB; } .btn-secondary:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--muted); } .btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: #fff; color: var(--danger); border-color: #F2C9C9; } .btn-danger:hover { background: #FDECEC; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 14px 18px; font-size: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
input[type=date], input[type=time] { direction: ltr; text-align: right; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; margin-bottom: 10px; }
label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
form .btn-block + .btn-block { margin-top: 10px; }
form .btn-primary.btn-block { margin-top: 6px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.alert { background: #FDECEC; color: #B42D2D; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.empty { color: var(--muted); padding: 28px; text-align: center; background: #fff; border: 1px dashed var(--border); border-radius: var(--radius); }

/* login */
.center-page { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 20px; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 36px 28px; display: flex; flex-direction: column; align-items: center; }
.login-card .btn { margin: 8px 0 14px; }

/* dashboard */
.dash { display: grid; grid-template-columns: 380px 1fr; gap: 24px; max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; align-items: start; }
/* RTL: first column (form) sits on the right; the brief puts it on the left, so swap order */
.dash-side { order: 2; position: sticky; top: 88px; }
.dash-main { order: 1; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.cards { display: grid; gap: 12px; }
.m-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: grid; grid-template-columns: 92px 1fr; gap: 16px; align-items: center; }
.m-when { background: var(--accent-soft); color: var(--accent-dark); border-radius: 12px; text-align: center; padding: 10px 6px; line-height: 1.3; }
.m-when b { display: block; font-size: 13px; font-weight: 600; } .m-when span { font-size: 16px; font-weight: 700; }
.m-body { min-width: 0; }
.m-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-meta { color: var(--muted); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; margin: 2px 0 10px; }
.m-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.m-actions .spacer { flex: 1; }
.host-tag { background: #F1EFF4; color: var(--muted); border-radius: 6px; padding: 0 8px; }
.sub-head { margin: 28px 0 10px; color: var(--muted); font-weight: 600; }
.cal-list { display: grid; gap: 6px; }
.cal-item { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text); text-decoration: none; }
.cal-item span { color: var(--muted); white-space: nowrap; }

/* permissions */
.narrow { max-width: 860px; margin: 0 auto; padding: 24px 20px 48px; }
.add-user { display: grid; grid-template-columns: 1fr 140px auto; gap: 10px; margin-bottom: 8px; }
.add-user input, .add-user select { margin: 0; }
.users { display: grid; gap: 10px; margin-top: 16px; }
.u-row { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.u-row.off { opacity: .6; }
.u-main b { display: block; font-weight: 600; } .u-main small { color: var(--muted); direction: ltr; display: inline-block; }
.u-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.u-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.u-actions select { width: auto; margin: 0; padding: 6px 8px; font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); margin: 0; }
.switch input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

/* lobby */
.lobby { max-width: 1060px; margin: 0 auto; padding: 32px 20px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: stretch; }
.preview { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.video-box { position: relative; background: var(--stage); border-radius: 12px; overflow: hidden; aspect-ratio: 16/10; }
.video-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #BDB4CC; font-size: 15px; }
.preview-controls { display: flex; gap: 12px; justify-content: center; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border); background: #fff; color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.round.off { background: var(--danger); border-color: var(--danger); color: #fff; }
.invite { display: flex; flex-direction: column; justify-content: center; padding: 32px 28px; }
.eyebrow { display: inline-block; align-self: flex-start; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px 12px; border-radius: 999px; margin-bottom: 14px; }
.invite .client { color: var(--muted); margin: -6px 0 4px; font-size: 15px; }
.invite .when { font-weight: 600; color: var(--accent-dark); margin: 0 0 22px; }
.invite form { margin-bottom: 10px; }

/* meeting */
.meeting-page, .meeting-page body { overflow: hidden; }
.meeting { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--stage); }
.meeting-bar { position: relative; flex: none; }
.meeting-tools { display: flex; align-items: center; gap: 8px; }
.chip-timer { font-variant-numeric: tabular-nums; direction: ltr; background: #F1EFF4; color: var(--text); }
.chip-timer.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
#count b { font-weight: 600; }
.stage { flex: 1; min-height: 0; width: 100%; }
.stage iframe { width: 100%; height: 100%; border: 0; display: block; }

@media (max-width: 900px) {
  .dash { grid-template-columns: 1fr; padding: 16px 14px 40px; }
  .dash-side { order: 1; position: static; } .dash-main { order: 2; }
  .lobby { grid-template-columns: 1fr; padding: 16px 14px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .chips { display: none; }
  .add-user { grid-template-columns: 1fr; }
  .u-row { grid-template-columns: 1fr; } .u-actions { justify-content: flex-start; }
}
@media (max-width: 600px) {
  .m-card { grid-template-columns: 1fr; gap: 10px; }
  .m-when { display: flex; gap: 8px; justify-content: center; align-items: baseline; }
  .meeting-bar .brand-text small { display: none; }
  .meeting-bar .avatar { width: 32px; height: 32px; }
  #copy-link { padding: 6px 8px; font-size: 12px; }
  .chip-timer { display: none; }
  .nav-link { padding: 6px; }
}
