:root {
[hidden] { display: none !important; }
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #17221f;
  --muted: #64736f;
  --line: #e2e8e6;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-soft: #e6f5f3;
  --side: #0d2724;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 12px;
  font-family: 'IBM Plex Sans Arabic', Tahoma, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.6; }
a { color: var(--brand); }
code, pre { font-family: ui-monospace, Consolas, monospace; direction: ltr; }
pre { background: #0f1f1d; color: #d1fae5; padding: 12px 14px; border-radius: 10px; overflow: auto; font-size: 12.5px; text-align: left; white-space: pre-wrap; word-break: break-all; }
code.inline { background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; font-size: 13px; unicode-bidi: embed; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--side); color: #cfe3df; padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand b { display: block; font-size: 18px; color: #fff; }
.brand small { font-size: 12px; color: #8fb3ad; }
.brand.big b { color: var(--ink); font-size: 22px; }
.brand.big small { color: var(--muted); }
.logo { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
nav a { padding: 9px 12px; border-radius: 9px; cursor: pointer; color: #cfe3df; text-decoration: none; font-size: 14.5px; }
nav a:hover { background: rgba(255,255,255,.06); }
nav a.active { background: var(--brand); color: #fff; }

main { flex: 1; min-width: 0; padding: 0 28px 40px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 0; }
.topbar h1 { font-size: 22px; margin: 0; flex: 1; }
#menu-btn { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card h2 { font-size: 17px; margin: 0 0 4px; }
.card h3 { font-size: 15px; margin: 14px 0 6px; }
.card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }

label { display: block; font-size: 13.5px; font-weight: 500; margin-bottom: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); margin-top: 4px; }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; accent-color: var(--brand); }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: transparent; }
.ltr { direction: ltr; text-align: left; }

.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 16px; border-radius: 9px; cursor: pointer; font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: #f1f5f4; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0b5f58; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; }
.sidebar .btn.ghost { color: #8fb3ad; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; background: #eef2f1; color: var(--muted); white-space: nowrap; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.info { background: var(--brand-soft); color: var(--brand); }
.tag { display: inline-block; padding: 0 8px; border-radius: 6px; font-size: 12px; background: var(--brand-soft); color: var(--brand); margin: 1px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow: auto; }
.clip { max-width: 360px; white-space: pre-wrap; word-break: break-word; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.qr-box { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.qr-box img { width: 240px; height: 240px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #9ca3af; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px #dcfce7; }
.dot.bad { background: var(--danger); }
.dot.warn { background: var(--warn); }

.progress { height: 8px; background: #eef2f1; border-radius: 99px; overflow: hidden; min-width: 120px; }
.progress i { display: block; height: 100%; background: var(--brand-2); }

.vars { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 12px; }
.vars button { font: inherit; font-size: 12px; border: 1px dashed var(--brand-2); background: var(--brand-soft); color: var(--brand); border-radius: 6px; padding: 1px 8px; cursor: pointer; direction: ltr; }
.media-pick { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.media-pick .file-name { font-size: 13px; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { font: inherit; background: none; border: 0; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5d3; border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; right: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(-18px); }

.event-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.event-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.event-card .head b { flex: 1; }

.modal-bg { position: fixed; inset: 0; background: rgba(10, 25, 22, .45); display: none; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow: auto; z-index: 50; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 20px 22px; width: 100%; max-width: 620px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; }
#toast div { background: #17221f; color: #fff; padding: 9px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast div.err { background: var(--danger); }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 18px; }
.err { color: var(--danger); min-height: 1em; margin: 0; font-size: 14px; }
.hint { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }
.ok-box { background: #f0fdf4; border: 1px solid #bbf7d0; color: #14532d; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }

@media (max-width: 900px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .sidebar { position: fixed; right: -260px; z-index: 40; transition: right .2s; }
  .sidebar.open { right: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  #menu-btn { display: inline-flex; }
  main { padding: 0 14px 30px; }
}
