:root {
  --bg: #0e1014; --panel: #161920; --panel-2: #1c2029; --line: #272c38; --text: #e7e9ef; --muted: #8d95a8;
  --accent: #ff8a3d; --accent-2: #ff5555; --good: #3ecf8e; --warn: #f5b942; --bad: #f2555a; --info: #5aa9ff; --purple: #b58cff;
  --radius: 10px; --shadow: 0 8px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f5f8; --panel: #ffffff; --panel-2: #f0f2f6; --line: #dfe3ea; --text: #1b1e26; --muted: #5f6878;
    --accent: #e8650f; --accent-2: #d93a3f; --good: #16935d; --warn: #b77a06; --bad: #cf3338; --info: #1f6fd0; --purple: #7446d6;
    --shadow: 0 8px 30px rgba(20,30,50,.12); color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--info); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 15px; margin: 0 0 10px; } h3 { font-size: 13px; margin: 0 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; } .right { text-align: right; } .grow { flex: 1; min-width: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 15px; }
.brand img { width: 28px; height: 28px; }
.brand span { background: linear-gradient(90deg, var(--accent-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.nav .count { margin-left: auto; background: var(--accent-2); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; line-height: 18px; }
.side .who { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.main { padding: 22px 26px 60px; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head .sub { color: var(--muted); }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px; }
  .brand { padding: 4px 8px; } .nav { display: flex; flex-wrap: wrap; gap: 2px; } .nav a { padding: 6px 8px; }
  .side .who { margin: 0 0 0 auto; border: 0; padding: 0 4px; }
  .main { padding: 14px 12px 50px; }
}

/* pieces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { display: block; color: var(--text); } .stat:hover { text-decoration: none; border-color: var(--accent); }
.stat b { display: block; font-size: 26px; line-height: 1.1; } .stat span { color: var(--muted); font-size: 12px; }
.cols { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sp { margin-top: 12px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 6px 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; }
.tablewrap { overflow-x: auto; margin: 0 -16px -14px; }
.empty { color: var(--muted); padding: 22px 6px; text-align: center; }
.avatar { width: 22px; height: 22px; border-radius: 4px; vertical-align: middle; image-rendering: pixelated; background: var(--panel-2); }
.avatar.big { width: 56px; height: 56px; border-radius: 8px; }
.player { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.badge.info { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.badge.purple { color: var(--purple); border-color: color-mix(in srgb, var(--purple) 45%, transparent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: var(--good); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

/* controls */
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; font-weight: 600; }
.btn.danger { color: var(--bad); } .btn.good { color: var(--good); } .btn.sm { padding: 3px 9px; font-size: 12.5px; }
input[type=text], input[type=search], select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; resize: vertical; min-height: 72px; }
label.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); } label.field > * { color: var(--text); font-size: 14px; }
label.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { background: none; border: 0; padding: 4px 11px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 10px 0 0; color: var(--muted); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 26px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login h1 { font-size: 22px; } .login code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; }
.error { color: var(--bad); }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(480px, 100%); padding: 20px; display: grid; gap: 12px; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 30; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 360px; }
.toast.bad { border-left-color: var(--bad); }

/* tickets */
.split { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 12px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
.tlist { padding: 6px; } .tlist a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.tlist a:hover { background: var(--panel-2); text-decoration: none; } .tlist a.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.tlist .t1 { display: flex; gap: 6px; align-items: center; font-weight: 600; } .tlist .t2 { color: var(--muted); font-size: 12px; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 56vh; overflow-y: auto; padding: 4px 2px 8px; }
.msg { max-width: 82%; padding: 8px 11px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.staff { align-self: flex-end; border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }

/* chat log */
.log { font-size: 13px; } .log .line { display: grid; grid-template-columns: 118px 86px 150px 1fr; gap: 8px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.log .line:last-child { border: 0; } .log .blocked { color: var(--muted); text-decoration: line-through; } .log .cmd { color: var(--info); }
.log .text { overflow-wrap: anywhere; }
@media (max-width: 700px) { .log .line { grid-template-columns: 1fr 1fr; } .log .text { grid-column: 1 / -1; } }

.profile-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.appeal .quote { background: var(--panel-2); border-left: 3px solid var(--purple); border-radius: 6px; padding: 9px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* permissions */
.row > h2 { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 11px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600; }
.chip small { font-weight: 400; color: var(--muted); }
.chip .x { background: none; border: 0; cursor: pointer; color: var(--muted); width: 22px; height: 22px; border-radius: 50%; line-height: 1; padding: 0; }
.chip .x:hover { color: var(--bad); background: var(--panel); }
.addrow { display: grid; grid-template-columns: minmax(160px, 1.6fr) auto minmax(112px, 1fr) minmax(112px, 1fr) auto; gap: 8px; align-items: center; }
@media (max-width: 760px) { .addrow { grid-template-columns: 1fr 1fr; } .addrow > :first-child { grid-column: 1 / -1; } }
button.badge.toggle { background: none; cursor: pointer; font: inherit; font-size: 11.5px; font-weight: 600; }
button.badge.toggle:hover { background: var(--panel-2); }
td.tight { width: 1%; white-space: nowrap; } td.wrap { overflow-wrap: break-word; min-width: 130px; }
.pre { white-space: pre-wrap; background: var(--panel-2); border-radius: 5px; padding: 1px 6px; }
.tlist-foot { padding: 8px 10px 4px; border-top: 1px solid var(--line); margin-top: 6px; }
