/* Nocturn Play back-office — shared look (backend + admin) */
:root {
  --bg: #0b0a17; --bg2: #110f22; --card: #1a1733; --card2: #211d40; --line: #2c2850; --line2: #3a3566;
  --text: #ece9ff; --muted: #a7a1cf; --dim: #7a74a6;
  --violet: #9d7bff; --violet-d: #7b5cf0; --teal: #3fe0c5; --red: #ff6b8a; --amber: #ffc861; --green: #3fe0c5;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; min-height: 100vh;
  background: radial-gradient(1200px 600px at 85% -10%, rgba(157,123,255,.13), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(63,224,197,.07), transparent 60%), var(--bg); background-attachment: fixed; }
[hidden] { display: none !important; }
a { color: var(--violet); }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: .98rem; color: var(--muted); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .86em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .pos { color: var(--teal); } .neg { color: var(--red); }
.small { font-size: .84rem; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.brand b { font-weight: 800; letter-spacing: .14em; font-size: .95rem; white-space: nowrap; }
.brand small { display: block; font-size: .68rem; letter-spacing: .14em; color: var(--teal); text-transform: uppercase; font-weight: 600; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.login .brand { justify-content: center; margin-bottom: 18px; }
.login h1 { text-align: center; font-size: 1.1rem; color: var(--muted); font-weight: 500; margin-bottom: 18px; }
.login.signup, #welcome { max-width: 460px; }
.login .lead { text-align: center; margin: -8px 0 16px; }
.login .swap { text-align: center; margin: 16px 0 0; }
.login .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#welcome h1 { color: var(--text); font-weight: 650; }
#welcome ol { padding-left: 1.2em; color: var(--muted); } #welcome ol li { margin: .35em 0; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; background: rgba(11,10,23,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1320px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
.top .who { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.top .who span { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
nav.tabs { max-width: 1320px; margin: 0 auto; display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { padding: 10px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 550; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a.on { color: var(--text); border-bottom-color: var(--violet); }
main { max-width: 1320px; margin: 0 auto; padding: 20px 16px 60px; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.head h1 { margin: 0; }
.head .sp { flex: 1; }

/* cards & panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cur-block { margin-bottom: 14px; }
.cur-block .cur-tag { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .06em; margin-bottom: 8px; }
.cur-tag i { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); display: inline-block; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.stat .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.stat .v { font-size: 1.22rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.ggr { border-color: rgba(63,224,197,.35); }
.alert { border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid; }
.alert.warn { background: rgba(255,200,97,.08); border-color: rgba(255,200,97,.45); color: #ffe0a3; }
.alert.err { background: rgba(255,107,138,.08); border-color: rgba(255,107,138,.45); color: #ffc2cf; }
.alert.ok { background: rgba(63,224,197,.08); border-color: rgba(63,224,197,.4); color: #b6fff1; }
.empty { padding: 26px 12px; text-align: center; color: var(--dim); }

/* forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); min-width: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=url], select, textarea {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; padding: 8px 10px; color: var(--text); min-width: 0; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(157,123,255,.18); }
input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
textarea { min-height: 70px; resize: vertical; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters label.f { width: 150px; flex: 1 1 130px; max-width: 220px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: .9rem; }
.check input { width: 16px; height: 16px; accent-color: var(--violet); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line2); background: var(--card2); color: var(--text);
  border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--violet); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--violet), var(--violet-d)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.teal { background: rgba(63,224,197,.12); border-color: rgba(63,224,197,.5); color: var(--teal); }
.btn.danger { background: rgba(255,107,138,.12); border-color: rgba(255,107,138,.5); color: #ffb3c3; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: .82rem; border-radius: 8px; }
.btn.block { width: 100%; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 7px; color: var(--muted); cursor: pointer; font-weight: 600; font-size: .85rem; }
.seg button.on { background: var(--violet); color: #fff; }
.msg { min-height: 1.2em; font-size: .86rem; margin-top: 8px; }
.msg.err { color: var(--red); } .msg.ok { color: var(--teal); }

/* switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #2a2648; border: 1px solid var(--line2); border-radius: 24px; transition: .18s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #cfc9f5; border-radius: 50%; transition: .18s; }
.switch input:checked + span { background: rgba(63,224,197,.3); border-color: var(--teal); }
.switch input:checked + span::before { transform: translateX(18px); background: var(--teal); }
.switch input:disabled + span { opacity: .45; cursor: not-allowed; }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(157,123,255,.35); }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; background: var(--card2); white-space: nowrap; position: sticky; top: 0; }
th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(157,123,255,.05); }
tr.click { cursor: pointer; }
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 180px; }
td.nowrap { white-space: nowrap; }
.more { text-align: center; margin-top: 12px; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; }
.badge.ok, .badge.settled, .badge.active { color: var(--teal); border-color: rgba(63,224,197,.45); background: rgba(63,224,197,.08); }
.badge.warn, .badge.credit_pending, .badge.pending, .badge.debited, .badge.coming { color: var(--amber); border-color: rgba(255,200,97,.45); background: rgba(255,200,97,.08); }
.badge.err, .badge.refused, .badge.rolled_back, .badge.blocked, .badge.disabled { color: var(--red); border-color: rgba(255,107,138,.45); background: rgba(255,107,138,.08); }
.badge.vio { color: var(--violet); border-color: rgba(157,123,255,.5); background: rgba(157,123,255,.1); }

/* games grid */
.cat-title { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.cat-title h2 { margin: 0; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.game { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.game .thumb { position: relative; aspect-ratio: 440 / 590; background: linear-gradient(160deg, #2a2156, #120f26); max-height: 260px; overflow: hidden; }
.game .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game .thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; font-weight: 800; letter-spacing: .06em; color: rgba(236,233,255,.75); font-size: 1.05rem;
  background: radial-gradient(circle at 30% 20%, rgba(157,123,255,.35), transparent 60%), radial-gradient(circle at 80% 90%, rgba(63,224,197,.22), transparent 55%), #17132e; }
.game .thumb .flag { position: absolute; left: 8px; top: 8px; }
.game .body { padding: 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.game .name { font-weight: 700; font-size: 1rem; }
.game .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: .78rem; color: var(--muted); }
.game .ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.game .ctl select { width: auto; }
.game .rtp-eff { font-size: .85rem; } .game .rtp-eff b { color: var(--teal); }
.game .lock { font-size: .76rem; color: var(--amber); }
.game.off { opacity: .5; filter: grayscale(.7); }
.game.off .lockmsg { color: var(--red); font-weight: 700; font-size: .82rem; }

/* chart */
.chart-box { position: relative; }
.chart-box svg { width: 100%; height: 240px; display: block; }
.chart-box .tip { position: absolute; pointer-events: none; background: #0f0d20; border: 1px solid var(--line2); border-radius: 9px; padding: 7px 10px; font-size: .82rem; box-shadow: var(--shadow); white-space: nowrap; z-index: 5; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* docs */
.doc h2 { margin-top: 1.4em; } .doc h2:first-child { margin-top: 0; }
.doc p, .doc li { color: #d6d2f5; max-width: 860px; }
.doc ul { padding-left: 20px; }
pre.code { background: #0d0b1c; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; color: #d9d4ff; line-height: 1.5; margin: 8px 0 14px; }
code.i { background: #0d0b1c; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: #d9d4ff; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; }
.kv dt { color: var(--muted); font-size: .84rem; } .kv dd { margin: 0; overflow-wrap: anywhere; }
.secret-box { background: #0d0b1c; border: 1px dashed var(--teal); border-radius: 10px; padding: 12px; margin-top: 10px; }
.secret-box code { display: block; color: var(--teal); word-break: break-all; font-size: .92rem; margin: 6px 0 10px; }
.confirm { background: rgba(255,107,138,.06); border: 1px solid rgba(255,107,138,.4); border-radius: 10px; padding: 12px; margin-top: 10px; }

/* toast */
#toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
#toast div { background: var(--card2); border: 1px solid var(--line2); border-left: 3px solid var(--teal); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .88rem; }
#toast div.err { border-left-color: var(--red); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line2); border-top-color: var(--violet); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  main { padding: 14px 12px 50px; }
  .top-in { padding: 8px 12px; gap: 10px; }
  .top .who span { display: none; }
  .brand b { font-size: .82rem; }
  .filters label.f { max-width: none; flex-basis: 140px; }
  .stat .v { font-size: 1.05rem; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .games { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .game .ctl { flex-wrap: wrap; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; }
  th, td { padding: 8px 10px; }
}
@media (max-width: 400px) {
  .games { grid-template-columns: 1fr; }
  .game .thumb { max-height: 200px; }
}
td input[type=text] { min-width: 130px; }
