:root {
  --brand: #0b6b6a; --brand-2: #075251; --accent: #cfe5e3; --ink: #0d1b24; --muted: #6a7883;
  --line: #e2e7eb; --bg: #f3f5f7; --card: #fff; --bad: #c0352b; --ok: #1b7a4b; --warn: #a96300;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { -webkit-font-smoothing: antialiased; font: 15px/1.5 "Inter", "Tajawal", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
code { background: #eef2f4; padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--warn); font-weight: 600; }
.nowrap { white-space: nowrap; }

.layout { display: flex; min-height: 100vh; }
.side { width: 230px; flex: none; background: var(--ink); color: #cfd8dd; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 19px; padding: 0 8px 18px; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand.big { color: var(--ink); font-size: 26px; justify-content: center; padding-bottom: 4px; }
.brand.big img { width: 48px; height: 48px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #cfd8dd; padding: 9px 12px; border-radius: 8px; }
.side nav a:hover { background: #24343e; text-decoration: none; }
.side nav a.on { background: var(--brand); color: #fff; }
.side-foot { margin-top: auto; padding: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.side-foot .me { color: #fff; }
.side-foot .ver { color: #7d8b93; font-size: 12px; }
.link { background: none; border: 0; color: #9fd8d6; padding: 0; cursor: pointer; font: inherit; }
.langs { display: flex; gap: 6px; flex-wrap: wrap; }
.langs a { padding: 2px 8px; border-radius: 6px; border: 1px solid #3a4b55; color: #cfd8dd; font-size: 13px; }
.langs a.on { background: #fff; color: var(--ink); border-color: #fff; }
.langs.center { justify-content: center; margin-top: 16px; }
.langs.center a { border-color: var(--line); color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.count { background: #e3ecef; color: var(--muted); font-size: 14px; border-radius: 20px; padding: 1px 10px; vertical-align: middle; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.tip { background: #eaf4f3; border-color: #cfe5e3; }
.card.tip ol { margin: 6px 0 0; padding-inline-start: 22px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } .layout { flex-direction: column; } .side { width: auto; height: auto; position: static; } }

.msgs { margin-bottom: 14px; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: #e7f4ee; color: #135c34; border: 1px solid #c5e6d4; }
.msg.error { background: #fdecec; color: #8f2020; border-color: #f4c9c9; }
.msg.info { background: #eaf2fb; color: #1d4f86; border-color: #c9dcf2; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f5f7; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: #efc6c6; }
.btn.danger:hover { background: #fdf0f0; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn.pulse { box-shadow: 0 0 0 3px #cfe5e3; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(245, 178, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(245, 178, 61, 0); } }
.btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btns form { margin: 0; }
.actions { margin-top: 16px; display: flex; gap: 8px; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.danger-zone { margin-top: 18px; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.fields.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .fields.five { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .fields { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: span 1; }
.field label { font-weight: 500; font-size: 14px; }
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 500; padding-top: 22px; }
.field small { color: var(--muted); font-size: 12.5px; }
.field .err { color: var(--bad); font-size: 13px; }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--bad); }
.req { color: var(--bad); }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #cfd8dd; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd8d6; border-color: var(--brand); }
.field ul { list-style: none; padding: 0; margin: 0; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; columns: 2; }
.field ul label { font-weight: 400; display: flex; gap: 6px; }
.inline-form .fields { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; }
.search { display: flex; gap: 8px; margin-bottom: 12px; max-width: 760px; }
.search input { flex: 1; }
.search select { width: auto; }
.contact-form { border-top: 1px dashed var(--line); padding: 12px 0; }
.contact-form:first-of-type { border-top: 0; }
.del { color: var(--bad); font-size: 13px; display: inline-flex; gap: 6px; margin-top: 6px; }
.logo-preview { max-height: 80px; max-width: 200px; margin-bottom: 10px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: start; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 13px; color: var(--muted); font-weight: 500; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table td.end { text-align: end; }
.table td.end.btns { justify-content: flex-end; }
.table tr.current td { background: #f0faf9; }
.logo-cell { width: 56px; }
.logo-cell img { max-width: 48px; max-height: 32px; display: block; }
.tag { display: inline-block; background: #eef3f5; border-radius: 6px; padding: 1px 8px; font-size: 13px; margin: 1px 0; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 2px 10px; font-size: 12.5px; font-weight: 500; background: #eef2f4; color: var(--muted); }
.pill.ok, .pill.st-accepted { background: #e2f4e9; color: var(--ok); }
.pill.bad, .pill.st-declined { background: #fbe5e5; color: var(--bad); }
.pill.st-pending { background: #fff3d9; color: var(--warn); }
.pill.st-cancelled, .pill.st-expired { background: #eceff1; color: #6c7a83; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #aab5bb; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }
.row-line { padding: 6px 0; border-bottom: 1px solid var(--line); }
.row-line:last-child { border-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); display: flex; flex-direction: column; }
.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat b { font-size: 26px; }
.stat span { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs a { padding: 6px 14px; border-radius: 8px; color: var(--muted); }
.tabs a.on { background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600; }

.halls { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.hall-card { padding: 0; overflow: hidden; }
.hall-card .thumb { display: block; height: 180px; background: #e8eef1; }
.hall-card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.hall-info { padding: 14px 16px; }

.pair { text-align: center; max-width: 520px; }
.big-code { font-size: 64px; font-weight: 700; letter-spacing: 10px; color: var(--brand); margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.qr svg { width: 220px; height: 220px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0b6b6a, #17232b); padding: 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 30px 28px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card .muted { text-align: center; margin-top: 0; }
.login-card .field { margin-bottom: 12px; }

/* ---------- map editor ---------- */
.editor-page .main { padding-bottom: 16px; }
.editor { display: grid; grid-template-columns: 1fr 300px; grid-template-rows: auto 1fr; gap: 0 14px; height: calc(100vh - 110px); min-height: 480px; }
.toolbar { grid-column: 1 / 3; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; font: inherit; cursor: pointer; }
.toolbar button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.toolbar .sep { width: 10px; }
.toolbar .hint { color: var(--muted); font-size: 13px; flex: 1 1 280px; }
.canvas-wrap { background: #dfe6ea; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; }
#map { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
#map.tool-rect, #map.tool-poly, #map.tool-place { cursor: crosshair; }
#map .booth polygon { fill: rgba(11, 107, 106, .10); stroke: #0b6b6a; cursor: move; }
#map .booth.taken polygon { fill: rgba(11, 107, 106, .30); }
#map .booth.sel polygon { fill: rgba(245, 178, 61, .45); stroke: #c7861a; }
#map .booth text { fill: #10303a; font-weight: 700; pointer-events: none; font-family: inherit; }
#map .booth text.cname { font-weight: 500; }
#map .handle { fill: #fff; stroke: #c7861a; cursor: grab; }
#map .place circle { fill: #fff; stroke: #34444f; cursor: move; }
#map .place circle.dot { fill: #34444f; stroke: none; }
#map .place.sel circle { fill: #ffe9b8; }
#map .place.off { opacity: .45; }
#map .place text { pointer-events: none; }
#map .place .plabel { fill: #0d1b24; font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
#map .drawing { fill: rgba(245, 178, 61, .3); stroke: #c7861a; stroke-dasharray: 6 4; }
.panel { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
#props { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
#props label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
#props label.check { flex-direction: row; align-items: center; }
.list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
#items { overflow: auto; flex: 1; }
#items .group { font-size: 12px; color: var(--muted); padding: 8px 4px 2px; text-transform: uppercase; }
#items .item { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 5px 8px; border-radius: 6px; font: inherit; font-size: 13.5px; cursor: pointer; }
#items .item:hover { background: #f1f5f7; }
#items .item.on { background: #fff1d6; }
.toast { position: fixed; bottom: 20px; inset-inline-end: 20px; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--bad); }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; height: auto; } .canvas-wrap { height: 60vh; } }

.sound-list { display: flex; flex-wrap: wrap; gap: 8px; }
.sound-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font: inherit; cursor: pointer; }
.sound-btn .play { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; }
.sound-btn.on { border-color: var(--brand); background: #eaf4f3; }
.upload-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-row input[type=file] { width: auto; flex: 1; min-width: 240px; }
