:root {
  --bg: #0f1115; --panel: #181b22; --line: #2a2f3a; --text: #e8eaf0; --muted: #8b93a7;
  --accent: #f5b301; --danger: #e5484d; --ok: #30a46c;
  font-family: system-ui, "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
a { cursor: pointer; }
button, .btn {
  background: var(--accent); color: #111; border: 0; border-radius: 8px; padding: 8px 14px;
  font-weight: 600; cursor: pointer; font-size: 14px;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--danger); color: #fff; }
button.small { padding: 4px 10px; font-size: 12px; }
input, select, textarea {
  width: 100%; background: #0c0e12; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
[dir="rtl"] { text-align: right; }
.error { color: var(--danger); min-height: 1em; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.login .card { width: min(360px, 100%); display: grid; gap: 12px; }
.login h1 { margin: 0 0 8px; } .login h1 span { color: var(--accent); }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav { background: var(--panel); border-right: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
nav .brand { font-weight: 800; font-size: 20px; color: var(--accent); margin-bottom: 16px; }
nav a { padding: 9px 12px; border-radius: 8px; color: var(--text); }
nav a:hover { background: #222632; }
nav a.active { background: var(--accent); color: #111; font-weight: 600; }
nav a.muted { color: var(--muted); margin-top: auto; }
main { padding: 24px; min-width: 0; }
main h2 { margin-top: 0; display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat b { display: block; font-size: 28px; color: var(--accent); }
.stat span { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar select, .toolbar input { width: auto; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
td img.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
td .actions { display: flex; gap: 6px; }
code.code { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: 1px; color: var(--accent); }
.pill { padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #2a2f3a; }
.pill.ok { background: rgba(48,164,108,.2); color: #4cc38a; }
.pill.bad { background: rgba(229,72,77,.2); color: #ff6369; }
.pill.wait { background: rgba(245,179,1,.15); color: var(--accent); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(720px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
#modal-form { padding: 20px; display: grid; gap: 12px; max-height: 88vh; overflow-y: auto; }
#modal-form h3 { margin: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.file-field { display: flex; gap: 8px; align-items: center; }
.file-field img, .file-field video { max-height: 60px; border-radius: 6px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
#gym-map, #pick-map { height: 520px; border-radius: 12px; border: 1px solid var(--line); }
#pick-map { height: 260px; }
.codes-out { background: #0c0e12; border: 1px dashed var(--accent); border-radius: 10px; padding: 14px; font-family: ui-monospace, Consolas, monospace; white-space: pre; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222632; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  nav .brand { display: none; } nav a { white-space: nowrap; } nav a.muted { margin-top: 0; }
  main { padding: 16px; }
  .grid3, .grid2 { grid-template-columns: 1fr; }
}
