/* Ticket Desk — Liquid Gaming staff console.
   Two themes driven by tokens on <html data-theme="light|dark">. Light is the default.
   Reading first: Inter at 15px, solid surfaces, strong text contrast, sentence-case labels. */

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --raise: #ffffff;
  --hover: #f1f5f9;
  --selected: #e8f6fa;
  --selected-line: #5bc2d8;
  --line: #e3e8ef;
  --line-2: #d2dae5;
  --text: #0f172a;
  --text-2: #2f3d52;
  --muted: #56667d;
  --faint: #7d8ba0;
  --accent: #0b7489;
  --accent-strong: #08586a;
  --accent-soft: #e2f4f8;
  --accent-line: #8fd0df;
  --focus: rgba(11, 116, 137, 0.32);
  --btn-primary: linear-gradient(135deg, #0b8aa3, #0d9a84);
  --btn-primary-text: #ffffff;
  --btn: #ffffff;
  --btn-hover: #f1f5f9;
  --topbar: #ffffff;
  --sidebar: #f5f7fb;
  --listbg: #ffffff;
  --pane: #ffffff;
  --details: #f7f9fc;
  --composer: #f7f9fc;
  --input: #ffffff;
  --menu: #ffffff;
  --scrim: rgba(15, 23, 42, 0.38);
  --scroll: rgba(15, 23, 42, 0.18);
  --scroll-hover: rgba(15, 23, 42, 0.32);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.2);

  --red: #be2a43; --red-bg: #fde8ec; --red-line: #f3b4c0; --red-dot: #e1405c;
  --amber: #9a5600; --amber-bg: #fdf0d8; --amber-line: #efcc86; --amber-dot: #e39b13;
  --green: #0a7552; --green-bg: #dcf4e9; --green-line: #9cdcc1; --green-dot: #17a673;
  --blue: #1d56cc; --blue-bg: #e2eafc; --blue-line: #a9c0f3; --blue-dot: #3d7bf0;
  --purple: #6640c4; --purple-bg: #ebe5fb; --purple-line: #c6b4f1; --purple-dot: #8a63e8;
  --gold: #835c00; --gold-bg: #fbf0d0; --gold-line: #e7d08a;
  --orange-dot: #ea7a26;
  --note-bg: #fff7dc; --note-line: #efd27c; --note-text: #4a3500; --note-strong: #7d5800; --note-input: #fffdf3;
  --code-bg: #eef2f7;
  --mention-bg: #e4e9fd; --mention-text: #2f3fa3;
  --embed-bg: #f7f9fc;
  --sys-bg: #fbf3dc; --sys-line: #ecd79c;
  --skel-a: #eef2f7; --skel-b: #e2e8f0;
  --role-mix: #0f172a;
  --role-mix-amount: 45%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #060c17;
  --surface: #0b1526;
  --surface-2: #091321;
  --surface-3: #0f1d33;
  --raise: #12223b;
  --hover: #12233b;
  --selected: #0e2a3c;
  --selected-line: #1fb6cf;
  --line: #1a2a42;
  --line-2: #26395a;
  --text: #f2f7fd;
  --text-2: #d6e2ef;
  --muted: #a3b6cb;
  --faint: #7a91aa;
  --accent: #45d7ee;
  --accent-strong: #86e9f7;
  --accent-soft: rgba(0, 229, 255, 0.12);
  --accent-line: rgba(0, 229, 255, 0.4);
  --focus: rgba(0, 229, 255, 0.32);
  --btn-primary: linear-gradient(135deg, #00cbe6, #00e09e);
  --btn-primary-text: #04121b;
  --btn: #0f1d33;
  --btn-hover: #152843;
  --topbar: #08111f;
  --sidebar: #08111f;
  --listbg: #0a1424;
  --pane: #0b1526;
  --details: #08111f;
  --composer: #091321;
  --input: #0b1729;
  --menu: #0e1b31;
  --scrim: rgba(0, 0, 0, 0.55);
  --scroll: rgba(150, 190, 235, 0.2);
  --scroll-hover: rgba(150, 190, 235, 0.34);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.6);

  --red: #ff8ea2; --red-bg: rgba(255, 77, 106, 0.14); --red-line: rgba(255, 77, 106, 0.36); --red-dot: #ff4d6a;
  --amber: #ffcb7a; --amber-bg: rgba(255, 181, 71, 0.13); --amber-line: rgba(255, 181, 71, 0.34); --amber-dot: #ffb547;
  --green: #6eebb9; --green-bg: rgba(46, 229, 157, 0.12); --green-line: rgba(46, 229, 157, 0.32); --green-dot: #2ee59d;
  --blue: #9dbfff; --blue-bg: rgba(91, 155, 255, 0.14); --blue-line: rgba(91, 155, 255, 0.34); --blue-dot: #5b9bff;
  --purple: #cdbcff; --purple-bg: rgba(177, 151, 252, 0.14); --purple-line: rgba(177, 151, 252, 0.34); --purple-dot: #b197fc;
  --gold: #ffdc85; --gold-bg: rgba(255, 200, 71, 0.12); --gold-line: rgba(255, 200, 71, 0.32);
  --orange-dot: #ff8a3d;
  --note-bg: rgba(255, 215, 106, 0.08); --note-line: rgba(255, 215, 106, 0.3); --note-text: #f6edd2; --note-strong: #ffd76a; --note-input: #15140c;
  --code-bg: rgba(150, 190, 235, 0.12);
  --mention-bg: rgba(91, 155, 255, 0.2); --mention-text: #d2e0ff;
  --embed-bg: #0e1a2e;
  --sys-bg: rgba(255, 200, 71, 0.07); --sys-line: rgba(255, 200, 71, 0.22);
  --skel-a: #0f1d33; --skel-b: #162741;
  --role-mix: #ffffff;
  --role-mix-amount: 20%;
}

:root {
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-brand: 'Syne', 'Inter', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --topbar-h: 60px;
  --sidebar-w: 248px;
  --list-w: 400px;
  --details-w: 360px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
:root[data-theme="dark"] body {
  background: radial-gradient(1100px 520px at 0% -10%, rgba(0, 229, 255, 0.06), transparent 60%), var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
img { max-width: 100%; }
::selection { background: var(--focus); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tnum { font-variant-numeric: tabular-nums; }

* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }

/* ---------- gate ---------- */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 50; background: var(--bg); }
.gate-card {
  width: min(460px, 100%); text-align: center; padding: 38px 30px 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg);
}
.gate-logo { width: 78px; height: 78px; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(0, 150, 190, 0.35)); }
.gate h1 { font: 800 28px/1.1 var(--font-brand); margin: 14px 0 10px; letter-spacing: 0.3px; }
.gate-text { color: var(--text-2); margin: 0 0 20px; font-size: 15.5px; }
.gate-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.gate-spinner { width: 28px; height: 28px; margin: 18px auto 0; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons, chips, avatars ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--btn); color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { background: var(--btn-hover); border-color: var(--accent-line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--btn-primary); border-color: transparent; color: var(--btn-primary-text); box-shadow: 0 2px 8px rgba(11, 116, 137, 0.25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.btn.danger:hover { filter: brightness(0.97); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.sm { height: 31px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn .kbd { font: 600 10.5px var(--mono); opacity: 0.75; }

.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; flex: none;
  border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 16px; text-decoration: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--line); }
.icon-btn.on { color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.star-on { color: var(--gold) !important; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line);
}
.chip.red { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.chip.amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.chip.green { background: var(--green-bg); color: var(--green); border-color: var(--green-line); }
.chip.blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-line); }
.chip.purple { background: var(--purple-bg); color: var(--purple); border-color: var(--purple-line); }
.chip.gold { background: var(--gold-bg); color: var(--gold); border-color: var(--gold-line); }
.chip.cyan { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.chip.tag { background: var(--accent-soft); color: var(--accent-strong); border-style: dashed; border-color: var(--accent-line); }

.avatar {
  --size: 38px;
  width: var(--size); height: var(--size); border-radius: 50%; flex: none; overflow: hidden; position: relative;
  display: inline-grid; place-items: center; font: 700 calc(var(--size) * 0.38) var(--font); color: #fff; background: #2a4466;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xs { --size: 20px; }
.avatar.sm { --size: 28px; }
.avatar.lg { --size: 58px; }

kbd {
  font: 600 11.5px var(--mono); padding: 1px 6px; border-radius: 5px; color: var(--text-2);
  background: var(--surface-3); border: 1px solid var(--line-2); border-bottom-width: 2px;
}

/* ---------- app grid ---------- */
.app {
  display: grid; height: 100vh; height: 100dvh;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
}
.app.mode-stats { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.app.mode-stats .list-pane { display: none; }

/* ---------- topbar ---------- */
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--topbar); border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand img { width: 36px; height: 36px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font: 800 17px var(--font-brand); letter-spacing: 0.3px; }
.brand-text small { color: var(--muted); font-size: 12px; font-weight: 500; }
.live { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); flex: none; background: var(--surface-2); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-dot); box-shadow: 0 0 0 0 rgba(23, 166, 115, 0.55); animation: pulse 2.4s infinite; }
.live.stale .live-dot { background: var(--amber-dot); animation: none; }
.live.down .live-dot { background: var(--red-dot); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(23, 166, 115, 0.5); } 70% { box-shadow: 0 0 0 8px rgba(23, 166, 115, 0); } 100% { box-shadow: 0 0 0 0 rgba(23, 166, 115, 0); } }
.top-stats { display: flex; gap: 6px; flex: none; }
.top-stat {
  display: flex; align-items: baseline; gap: 6px; padding: 5px 11px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 500; color: var(--muted);
}
.top-stat:hover { border-color: var(--accent-line); color: var(--text-2); }
.top-stat b { font-size: 15.5px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.top-stat.hot b { color: var(--amber); }
.top-stat.red b { color: var(--red); }
.search {
  flex: 1; min-width: 160px; max-width: 540px; margin-left: auto; display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--input);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14.5px; }
.search input::placeholder { color: var(--faint); }
.search-icon { color: var(--muted); font-size: 18px; }
.me {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 11px 0 6px; flex: none;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
}
.me:hover { border-color: var(--accent-line); }
.me-name { font-weight: 600; font-size: 14px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: 10px; }
.only-narrow { display: none; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line); overflow-y: auto;
  padding: 14px 10px 18px; display: flex; flex-direction: column; gap: 16px;
}
.side-section { display: flex; flex-direction: column; gap: 2px; }
.side-title { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 2px 10px 6px; }
.side-hint { font-weight: 500; color: var(--faint); }
.side-item {
  width: 100%; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent; color: var(--text-2); text-align: left; font-size: 14.5px; font-weight: 500; position: relative;
}
.side-item:hover { background: var(--hover); color: var(--text); }
.side-item.active { background: var(--selected); color: var(--text); font-weight: 600; }
.side-item.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.side-item.empty { color: var(--faint); }
.si-icon { width: 20px; text-align: center; flex: none; font-size: 15px; }
.si-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-count { font-size: 12.5px; font-weight: 700; color: var(--muted); min-width: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.si-count.hot { color: #3a2200; background: var(--amber-dot); padding: 1px 8px; border-radius: 999px; }
.si-count.unread { color: #fff; background: var(--accent); padding: 1px 8px; border-radius: 999px; }
:root[data-theme="dark"] .si-count.unread { color: #04121b; }
.side-foot { margin-top: auto; font-size: 12.5px; color: var(--muted); padding: 8px 10px 0; line-height: 1.55; }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 29; }

/* ---------- list pane ---------- */
.list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--listbg); border-right: 1px solid var(--line); }
.list-head { padding: 16px 14px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 11px; }
.list-title { display: flex; align-items: center; gap: 10px; }
.list-title h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.2px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-pill { font-size: 13px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); padding: 2px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.list-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.select {
  height: 32px; padding: 0 28px 0 11px; border-radius: 8px; border: 1px solid var(--line-2); max-width: 100%;
  background: var(--btn) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2378879c'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none; font-size: 13.5px; font-weight: 600; color: var(--text-2);
}
.select:hover { border-color: var(--accent-line); }
.toggle-chip {
  height: 32px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--btn);
  font-size: 13.5px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px;
}
.toggle-chip.on { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.list-banner { margin: 10px 12px 0; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; background: var(--amber-bg); border: 1px solid var(--amber-line); color: var(--amber); }
.list { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.list-empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14.5px; }
.list-empty .big { font-size: 36px; display: block; margin-bottom: 10px; }

.tk {
  width: 100%; display: block; text-align: left; border: 1px solid transparent; border-radius: 12px;
  background: transparent; padding: 11px 12px 11px 15px; margin-bottom: 4px; position: relative; color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.tk:hover { background: var(--hover); }
.tk.active { background: var(--selected); border-color: var(--selected-line); }
.tk::before { content: ''; position: absolute; left: 5px; top: 13px; bottom: 13px; width: 3px; border-radius: 3px; background: transparent; }
.tk.pri-high::before { background: var(--red-dot); }
.tk.pri-low::before { background: var(--line-2); }
.tk-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tk-name { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.tk.unread .tk-name { font-weight: 800; }
.tk-time { font-size: 12.5px; color: var(--faint); flex: none; font-variant-numeric: tabular-nums; }
.tk.unread .tk-time { color: var(--accent); font-weight: 700; }
.tk-unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.tk-star { color: var(--gold); font-size: 13px; }
.tk-mid { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-chan { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.tk-preview { font-size: 14px; color: var(--muted); margin-top: 5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.45; }
.tk.unread .tk-preview { color: var(--text-2); }
.tk-preview .who { font-weight: 700; color: var(--text-2); }
.tk-preview .who.player { color: var(--green); }
.tk-preview .who.staff { color: var(--accent); }
.tk-bottom { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.tk-bottom .grow { flex: 1; }
.tk-claimer { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }

.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--faint); display: inline-block; }
.s-open, .s-waiting_staff { background: var(--amber-dot); }
.s-open.unclaimed { background: var(--red-dot); }
.s-in_progress { background: var(--blue-dot); }
.s-waiting_player { background: var(--purple-dot); }
.s-on_hold { background: var(--orange-dot); }
.s-resolved { background: var(--green-dot); }

/* ---------- ticket pane ---------- */
.ticket-pane { min-width: 0; min-height: 0; display: flex; position: relative; background: var(--pane); }
.tv { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.tv-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; font-size: 15px; }
.tv-empty .art { font-size: 56px; margin-bottom: 10px; }
.tv-empty h3 { margin: 0 0 8px; font-size: 21px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.tv-empty .tips { margin-top: 18px; display: grid; gap: 6px; font-size: 13.5px; color: var(--faint); }

.tv-head { padding: 13px 18px 12px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 11px; }
.tv-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tv-title { flex: 1; min-width: 0; }
.tv-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tv-name .emoji { font-size: 21px; }
.tv-name h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-name input { font: 600 16px var(--mono); background: var(--input); color: var(--text); border: 1px solid var(--accent); border-radius: 8px; padding: 4px 9px; outline: 0; width: min(380px, 100%); box-shadow: 0 0 0 3px var(--focus); }
.tv-sub { font-size: 13.5px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-sub b { color: var(--text-2); font-weight: 600; }
.tv-actions { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.tv-actions .spacer { flex: 1; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 33px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--btn); font-size: 13.5px; font-weight: 600; color: var(--text);
}
.pill-btn:hover { border-color: var(--accent-line); background: var(--btn-hover); }
.pill-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.pill-btn .lbl { color: var(--faint); font-weight: 500; }
.pill-btn.p-high { border-color: var(--red-line); color: var(--red); background: var(--red-bg); }
.pill-btn.p-low { color: var(--muted); }
.claim-note { font-size: 13.5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 7px; }

.tv-body { flex: 1; min-height: 0; display: flex; position: relative; }
.convo-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; position: relative; background: var(--pane); }
.convo { flex: 1; overflow-y: auto; padding: 16px 22px 10px; min-height: 0; }
.convo-top { text-align: center; padding: 6px 0 14px; font-size: 13px; }
.day { display: flex; align-items: center; gap: 12px; margin: 18px 0 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.day::before, .day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.only-mobile { display: none; }

.msg { display: flex; gap: 13px; padding: 6px 10px; margin: 0 -10px; border-radius: 10px; position: relative; max-width: 940px; }
.msg:hover { background: var(--hover); }
.msg.cont { padding-top: 2px; padding-bottom: 2px; }
.msg .gut { width: 40px; flex: none; display: flex; justify-content: center; }
.msg.cont .gut-time { opacity: 0; font-size: 11px; color: var(--faint); padding-top: 4px; font-variant-numeric: tabular-nums; }
.msg.cont:hover .gut-time { opacity: 1; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.author { font-weight: 700; font-size: 15px; color: var(--text); }
.role-player .author { color: var(--green); }
.role-staff .author { color: var(--accent); }
.role-bot .author { color: var(--purple); }
.badge { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 6px; line-height: 1.5; }
.badge.player { background: var(--green-bg); color: var(--green); }
.badge.staff { background: var(--accent-soft); color: var(--accent-strong); }
.badge.bot { background: var(--purple-bg); color: var(--purple); }
.badge.web { background: var(--blue-bg); color: var(--blue); }
.badge.game { background: var(--gold-bg); color: var(--gold); }
.msg-head time { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.msg-text { color: var(--text); font-size: 15px; line-height: 1.6; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.role-bot .msg-text { color: var(--text-2); }
.msg-text p { margin: 0; }
.msg-text strong { font-weight: 700; }
.msg-text code { font: 13.5px var(--mono); background: var(--code-bg); padding: 1px 6px; border-radius: 5px; }
.msg-text pre { font: 13.5px/1.55 var(--mono); background: var(--code-bg); border: 1px solid var(--line); padding: 10px 13px; border-radius: 9px; overflow-x: auto; margin: 7px 0; white-space: pre; }
.msg-text blockquote { margin: 5px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--line-2); color: var(--text-2); }
.msg-text h1, .msg-text h2, .msg-text h3 { margin: 7px 0 3px; line-height: 1.3; font-weight: 700; }
.msg-text h1 { font-size: 21px; } .msg-text h2 { font-size: 18px; } .msg-text h3 { font-size: 16px; }
.msg-text a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
.msg-text a:hover { text-decoration-color: var(--accent); }
.msg-text .spoiler { background: var(--line-2); color: transparent; border-radius: 4px; padding: 0 3px; cursor: pointer; }
.msg-text .spoiler.shown { color: inherit; background: var(--surface-3); }
.mention { background: var(--mention-bg); color: var(--mention-text); padding: 0 4px; border-radius: 4px; font-weight: 600; }
.mention.role {
  color: color-mix(in srgb, var(--role) calc(100% - var(--role-mix-amount)), var(--role-mix));
  background: color-mix(in srgb, var(--role) 16%, transparent);
}
.emoji-img { width: 21px; height: 21px; vertical-align: -5px; object-fit: contain; }
.edited { font-size: 11.5px; color: var(--faint); margin-left: 5px; }
.msg.system { justify-content: center; }
.sys-line { display: inline-flex; align-items: center; gap: 8px; max-width: 90%; font-size: 13.5px; color: var(--text-2); background: var(--sys-bg); border: 1px solid var(--sys-line); padding: 6px 13px; border-radius: 999px; }

.attachments { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.att-img { max-width: 380px; max-height: 300px; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; display: block; background: var(--surface-3); }
.att-video { max-width: 440px; max-height: 320px; border-radius: 10px; border: 1px solid var(--line); background: #000; }
.att-file { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); text-decoration: none; color: var(--text); font-size: 13.5px; max-width: 340px; }
.att-file:hover { border-color: var(--accent-line); }
.att-file .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.att-file .fsize { color: var(--faint); font-size: 12px; flex: none; }

.embed { margin-top: 7px; max-width: 580px; border-radius: 10px; background: var(--embed-bg); border: 1px solid var(--line); border-left: 4px solid var(--emb, var(--accent)); padding: 11px 13px; display: grid; gap: 7px; }
.embed-author { font-size: 13px; font-weight: 700; color: var(--text-2); }
.embed-title { font-weight: 700; font-size: 15px; color: var(--text); }
.embed-title a { color: var(--accent); }
.embed-desc { font-size: 14px; color: var(--text-2); line-height: 1.55; }
.embed-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 9px 14px; }
.embed-field { min-width: 0; }
.embed-field.full { grid-column: 1 / -1; }
.embed-field .fn { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 1px; }
.embed-field .fv { font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.embed-thumb { float: right; width: 66px; height: 66px; border-radius: 8px; object-fit: cover; margin-left: 10px; }
.embed-image { max-width: 100%; border-radius: 8px; cursor: zoom-in; }
.embed-footer { font-size: 12px; color: var(--faint); }
.reactions { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.reaction { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 7px; background: var(--surface-3); border: 1px solid var(--line); font-size: 13px; }
.reaction img { width: 16px; height: 16px; }
.msg-note { font-size: 12.5px; color: var(--faint); margin-top: 3px; }

.jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 160px; z-index: 3; box-shadow: var(--shadow); }

/* composer */
.composer { border-top: 1px solid var(--line); padding: 11px 18px 15px; background: var(--composer); }
.composer-tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 9px; }
.ctab { height: 31px; padding: 0 13px; border-radius: 8px; border: 1px solid transparent; background: transparent; font-weight: 600; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.ctab:hover { color: var(--text); background: var(--hover); }
.ctab.active { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.ctab.ctab-note.active { background: var(--note-bg); border-color: var(--note-line); color: var(--note-strong); }
.composer-hint { margin-left: auto; font-size: 13px; color: var(--muted); text-align: right; }
.composer-hint.warn { color: var(--amber); font-weight: 600; }
.composer-box { border: 1px solid var(--line-2); border-radius: 12px; background: var(--input); transition: border-color 0.15s, box-shadow 0.15s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.composer.mode-note .composer-box { background: var(--note-input); border-color: var(--note-line); }
.composer.mode-note .composer-box:focus-within { border-color: var(--note-strong); box-shadow: 0 0 0 3px rgba(200, 150, 20, 0.18); }
.composer textarea { width: 100%; min-height: 80px; max-height: 280px; resize: none; border: 0; outline: 0; background: transparent; padding: 12px 14px 4px; font-size: 15px; line-height: 1.55; display: block; color: var(--text); }
.composer textarea::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; flex-wrap: wrap; }
.composer-bar .grow { flex: 1; }
.char-count { font: 12px var(--mono); color: var(--faint); }
.char-count.over { color: var(--red); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--text-2); user-select: none; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* details panel */
.details { width: var(--details-w); flex: none; border-left: 1px solid var(--line); overflow-y: auto; background: var(--details); padding: 14px 13px 30px; }
.details.closed-panel { display: none; }
.d-sec { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 11px; overflow: hidden; }
.d-head { display: flex; align-items: center; gap: 8px; padding: 10px 13px; font-size: 14px; font-weight: 700; color: var(--text); width: 100%; border: 0; background: transparent; text-align: left; }
.d-head:hover { background: var(--hover); }
.d-head .grow { flex: 1; }
.d-head .cnt { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-3); padding: 0 8px; border-radius: 999px; }
.d-sec.collapsed .d-content { display: none; }
.d-sec.collapsed .d-head .chev { transform: rotate(-90deg); }
.chev { transition: transform 0.15s; font-size: 10px; color: var(--muted); }
.d-content { padding: 2px 13px 13px; display: grid; gap: 9px; }
.kv { display: grid; grid-template-columns: 98px minmax(0, 1fr); gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.player-card { display: flex; gap: 13px; align-items: center; }
.player-card .pn { font-weight: 700; font-size: 16.5px; }
.player-card .pu { color: var(--muted); font-size: 13px; font-family: var(--mono); }
.roles { display: flex; gap: 5px; flex-wrap: wrap; }
.role-chip { font-size: 12.5px; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); }
.role-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.qa { display: grid; gap: 9px; }
.qa .q { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.qa .a { font-size: 14px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.notes { display: grid; gap: 8px; }
.notes .note { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 10px; padding: 9px 11px; position: relative; }
.note-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.note-head b { color: var(--note-strong); font-weight: 700; }
.note-text { font-size: 14px; color: var(--note-text); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.notes .note .del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; font-size: 12px; opacity: 0; }
.notes .note:hover .del { opacity: 1; }
.note-add { display: flex; gap: 6px; }
.note-add input { flex: 1; min-width: 0; height: 34px; border-radius: 8px; border: 1px solid var(--note-line); background: var(--note-input); padding: 0 11px; outline: 0; font-size: 14px; }
.note-add input:focus { border-color: var(--note-strong); }
.tags { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.tags .chip button { border: 0; background: transparent; color: inherit; padding: 0 0 0 2px; font-size: 13px; line-height: 1; opacity: 0.7; }
.tags .chip button:hover { opacity: 1; }
.tag-input { height: 26px; width: 120px; border-radius: 999px; border: 1px dashed var(--line-2); background: var(--input); padding: 0 11px; font-size: 13px; outline: 0; }
.tag-input:focus { border-color: var(--accent); border-style: solid; }
.people { display: grid; gap: 7px; }
.person { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.person .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .icon-btn { width: 28px; height: 28px; font-size: 13px; }
.prev-list { display: grid; gap: 6px; }
.prev { display: grid; gap: 2px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px; text-align: left; width: 100%; color: var(--text-2); }
.prev:hover { border-color: var(--accent-line); }
.prev .pt { font-weight: 600; color: var(--text); }
.prev .pm { color: var(--muted); font-size: 12.5px; }
.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 9px; font-size: 13.5px; position: relative; padding-bottom: 11px; }
.tl::before { content: ''; position: absolute; left: 6px; top: 13px; bottom: 0; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; margin-left: 2px; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tl-dot.web { background: var(--blue-dot); box-shadow: 0 0 0 3px var(--blue-bg); }
.tl-text { color: var(--text-2); line-height: 1.45; }
.tl-text b { color: var(--text); font-weight: 600; }
.tl-time { color: var(--faint); font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.link-btn { border: 0; background: none; color: var(--accent); padding: 0; font-size: 13.5px; font-weight: 600; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* ---------- menus, modals, toasts ---------- */
.menu {
  position: fixed; z-index: 60; min-width: 230px; max-width: 360px; max-height: min(480px, 72vh); overflow-y: auto;
  background: var(--menu); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
  animation: pop 0.12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu-title { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 6px 10px 5px; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 0; background: transparent; text-align: left; color: var(--text); font-size: 14px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item.active { color: var(--accent-strong); font-weight: 600; }
.menu-item.danger { color: var(--red); }
.menu-item:disabled { opacity: 0.45; cursor: not-allowed; }
.mi-icon { width: 20px; text-align: center; flex: none; }
.mi-text { flex: 1; min-width: 0; }
.mi-desc { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-check { color: var(--accent); font-weight: 700; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-search { width: 100%; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--input); padding: 0 10px; outline: 0; margin-bottom: 4px; font-size: 14px; }
.menu-search:focus { border-color: var(--accent); }

.modal-back { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(3px); z-index: 70; display: grid; place-items: center; padding: 18px; animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(540px, 100%); max-height: calc(100vh - 36px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop 0.15s ease-out; }
.modal.wide { width: min(780px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 19px; font-weight: 700; flex: 1; letter-spacing: -0.2px; }
.modal-body { padding: 8px 20px 6px; display: grid; gap: 13px; font-size: 14.5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 20px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.input, .textarea { width: 100%; border-radius: 10px; border: 1px solid var(--line-2); background: var(--input); padding: 10px 12px; outline: 0; font-size: 14.5px; color: var(--text); }
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { height: 31px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--btn); font-size: 13.5px; color: var(--text-2); }
.quick button:hover { border-color: var(--accent-line); color: var(--text); }
.canned-row { display: flex; gap: 10px; align-items: flex-start; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.canned-row .ct { font-weight: 700; }
.canned-row .cx { font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; margin-top: 2px; }
.canned-row .grow { flex: 1; min-width: 0; }
.shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 20px; font-size: 14px; }
.shortcuts div { display: flex; justify-content: space-between; gap: 10px; color: var(--text-2); }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.86); display: grid; place-items: center; padding: 30px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-lg); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 8px; width: min(400px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 15px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); border-left-width: 4px; box-shadow: var(--shadow-lg); font-size: 14px; animation: slide 0.18s ease-out; }
.toast.ok { border-left-color: var(--green-dot); }
.toast.err { border-left-color: var(--red-dot); }
.toast.info { border-left-color: var(--accent); }
.toast .t-icon { flex: none; }
.toast .t-text { flex: 1; color: var(--text-2); }
.toast .t-text b { color: var(--text); }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

/* ---------- stats ---------- */
.stats { flex: 1; overflow-y: auto; padding: 24px 26px 44px; background: var(--bg); }
.stats h2 { font-size: 23px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.3px; }
.stats .sub { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; background: var(--surface); box-shadow: var(--shadow); }
.kpi .k { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 800; margin-top: 4px; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 13px; color: var(--muted); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 13px; font-size: 16px; font-weight: 700; }
.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 160px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar .bl { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .bt { display: block; height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar .bf { display: block; height: 100%; min-width: 4px; border-radius: 999px; background: linear-gradient(90deg, #0aa5c0, #10b48f); }
.bar .bv { text-align: right; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 7px 9px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 9px; border-bottom: 1px solid var(--line); color: var(--text); }
.table tr:last-child td { border-bottom: 0; }

/* closed history */
.closed-row .tk-preview { -webkit-line-clamp: 3; }
.readonly-banner { margin: 12px 18px 0; padding: 10px 13px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 13.5px; color: var(--text-2); display: flex; gap: 8px; align-items: center; }

/* skeletons */
.skel { border-radius: 10px; background: linear-gradient(90deg, var(--skel-a), var(--skel-b), var(--skel-a)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- game tools: players, logs, refunds ---------- */
.player-head { gap: 12px; }
.player-head .avatar.lg { --size: 52px; }
.money-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.money-chip { display: inline-flex; flex-direction: column; padding: 6px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); line-height: 1.25; }
.money-chip small { font-size: 12px; color: var(--muted); font-weight: 600; }
.money-chip b { font-size: 16.5px; font-variant-numeric: tabular-nums; }
.money-chip.green b { color: var(--green); }
.money-chip.blue b { color: var(--blue); }
.money-chip.amber b { color: var(--amber); }
.money-chip.purple b { color: var(--purple); }
.money-note { font-size: 12.5px; }
.ptabs { display: flex; gap: 2px; overflow-x: auto; margin: 0 -6px -12px; }
.ptab { height: 38px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.ptab:hover { color: var(--text); }
.ptab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.pcount { font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-2); padding: 0 7px; border-radius: 999px; line-height: 1.6; }
.ppane { flex: 1; overflow-y: auto; padding: 16px 20px 44px; min-height: 0; background: var(--bg); }
:root[data-theme="dark"] .ppane { background: var(--pane); }
.psec { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.psec-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; }
.psec-head h3 { margin: 0; font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; flex: 1 1 200px; min-width: 0; }
.sub-head { font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 7px; }
.empty-note { padding: 18px 4px; font-size: 14px; }
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.overview-grid .psec { margin-bottom: 0; }
.kpis.mini { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 10px; gap: 8px; }
.kpis.mini .kpi { padding: 10px 12px; box-shadow: none; background: var(--surface-2); }
.kpis.mini .kpi .v { font-size: 22px; }
.stat-bar { display: grid; grid-template-columns: 72px minmax(0, 1fr) 46px; gap: 10px; align-items: center; font-size: 13.5px; margin-bottom: 7px; }
.sb-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: block; }
.sb-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #0aa5c0, #10b48f); }
.stat-bar.warn .sb-fill { background: linear-gradient(90deg, #e39b13, #e1405c); }
.stat-bar b { text-align: right; font-variant-numeric: tabular-nums; }
.row-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 6px; border: 0; border-bottom: 1px solid var(--line); font-size: 14px; width: 100%; background: none; text-align: left; color: var(--text); }
.row-line:last-child { border-bottom: 0; }
.link-row:hover { background: var(--hover); border-radius: 8px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.kv.small { font-size: 13px; grid-template-columns: 90px minmax(0, 1fr); }
button.chip { cursor: pointer; }
button.chip:hover { filter: brightness(0.96); }

/* items */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.item-card { position: relative; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); padding: 10px 8px 9px; text-align: center; display: grid; justify-items: center; align-content: start; gap: 4px; }
.item-card.weapon { border-color: var(--amber-line); }
.item-img { --s: 56px; width: var(--s); height: var(--s); position: relative; display: inline-grid; place-items: center; flex: none; }
.item-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.item-img .item-fallback { font-size: calc(var(--s) * 0.48); opacity: 0.4; }
.item-img.loaded .item-fallback { visibility: hidden; }
.item-img.sm { --s: 30px; }
.item-img.money { --s: 44px; font-size: 26px; }
.item-count { position: absolute; top: 5px; right: 6px; z-index: 1; padding: 0 5px; border-radius: 6px; background: var(--surface-2); line-height: 18px; font-size: 12.5px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.item-label { font-size: 13px; font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-meta { font-size: 11.5px; color: var(--muted); line-height: 1.3; }

/* vehicles */
.vehicle-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 22px; align-items: start; margin-bottom: 4px; }

/* logs */
.log-tools { position: sticky; top: -16px; z-index: 2; background: var(--bg); padding: 4px 0 10px; margin-bottom: 4px; }
:root[data-theme="dark"] .log-tools { background: var(--pane); }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.log-filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.log-filter-row .input { flex: 1; min-width: 200px; height: 34px; padding: 0 12px; }
.log-row { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; margin-bottom: 7px; }
.log-main { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; padding: 0; text-align: left; color: var(--text); flex-wrap: wrap; }
.log-time { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 122px; }
.log-label { font-weight: 700; font-size: 14.5px; flex: 1; min-width: 160px; }
.log-row.open .chev { transform: rotate(180deg); }
.log-msg { font-size: 14px; color: var(--text-2); margin-top: 4px; overflow-wrap: anywhere; }
.log-extra { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 4px; }
.log-meta { font: 12.5px/1.5 var(--mono); background: var(--code-bg); border-radius: 8px; padding: 9px 11px; margin: 8px 0 0; overflow: auto; max-height: 320px; }

/* money history */
.money-list { display: grid; gap: 6px; }
.money-line { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 9px 13px; }
.ml-amt { font-weight: 800; font-size: 15px; min-width: 112px; font-variant-numeric: tabular-nums; }
.ml-amt.in { color: var(--green); }
.ml-amt.out { color: var(--red); }
.ml-main { flex: 1; min-width: 0; font-size: 14px; }

/* characters linked to a ticket */
.char-row { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.char-row:last-child { border-bottom: 0; }
.cr-main { flex: 1; min-width: 0; font-size: 14px; }
.cr-actions { display: flex; gap: 5px; flex: none; }

/* refund builder */
.refund-mini { display: grid; }
.builder { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 14px; align-items: start; }
.b-catalog, .b-cart { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.b-catalog { display: grid; gap: 10px; }
.b-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
.b-tabs .ptab { padding: 0 10px; }
.b-catalog { container-type: inline-size; }
@container (max-width: 520px) { .b-tabs .pcount { display: none; } }
.b-cat-list { max-height: min(62vh, 640px); overflow-y: auto; margin: 0 -4px; padding: 2px 4px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.cat-card { border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); padding: 9px 7px 8px; display: grid; justify-items: center; align-content: start; gap: 3px; text-align: center; color: var(--text); }
.cat-card:hover { border-color: var(--accent); background: var(--selected); }
.cat-card:active { transform: scale(0.98); }
.cat-label { font-size: 13px; font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cat-name { font-size: 10.5px; color: var(--faint); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-form { display: grid; gap: 12px; padding-top: 4px; }
.money-add { display: flex; gap: 10px; align-items: flex-end; }
.money-add label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.money-add .grow { flex: 1; }
.b-cart { display: grid; gap: 11px; position: sticky; top: 0; }
.cart-head { display: flex; align-items: center; justify-content: space-between; }
.cart-head h3 { margin: 0; font-size: 16px; }
.b-target { font-size: 13.5px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.cart-lines { display: grid; gap: 7px; max-height: 44vh; overflow-y: auto; }
.cart-lines.readonly { max-height: none; }
.b-line { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 11px; padding: 7px 9px; background: var(--surface-2); flex-wrap: wrap; }
.b-line .item-img { --s: 40px; }
.b-main { flex: 1; min-width: 120px; }
.b-label { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-sub { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-field { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.b-field input { width: 86px; height: 30px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--input); padding: 0 8px; font-size: 14px; color: var(--text); }
.b-field input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.b-cart .field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.refund-done { text-align: center; display: grid; gap: 8px; justify-items: center; padding: 10px 4px; }
.rd-icon { font-size: 44px; }
.rd-title { font-size: 18px; font-weight: 800; }
.rd-code { font-size: 26px; font-weight: 700; letter-spacing: 1px; padding: 8px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-strong); border: 1px dashed var(--accent-line); user-select: all; }
.rd-sum { font-size: 14px; color: var(--text-2); }
.rd-help { font-size: 13.5px; color: var(--muted); }
.rd-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.modal.builder-modal { width: min(1140px, 100%); }
.modal.builder-modal .modal-body { padding-bottom: 18px; }
/* Fixed list height so the window does not jump while searching. */
.modal.builder-modal .b-cat-list { height: min(58vh, 600px); }
@media (max-width: 1000px) {
  .builder { grid-template-columns: minmax(0, 1fr); }
  .b-cart { position: static; }
}

/* ---------- responsive ---------- */
@media (max-width: 1500px) {
  .details { position: absolute; right: 0; top: 0; bottom: 0; z-index: 8; box-shadow: -14px 0 40px rgba(15, 23, 42, 0.18); }
  .details.closed-panel { display: none; }
  .top-stats .top-stat:nth-child(n+4) { display: none; }
}
@media (max-width: 1180px) {
  :root { --list-w: 350px; }
  .app { grid-template-columns: var(--list-w) minmax(0, 1fr); }
  .app.mode-stats { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: 280px; z-index: 30; transform: translateX(-102%); transition: transform 0.2s ease; }
  .sidebar.open { transform: none; box-shadow: 18px 0 40px rgba(15, 23, 42, 0.25); }
  .only-narrow { display: inline-grid; }
  .top-stats { display: none; }
  .brand-text small { display: none; }
}
@media (max-width: 760px) {
  :root { --topbar-h: 56px; }
  body { font-size: 15.5px; }
  .app, .app.mode-stats { grid-template-columns: minmax(0, 1fr); }
  .list-pane { border-right: 0; }
  .app.show-ticket .list-pane { display: none; }
  .app:not(.show-ticket):not(.mode-stats) .ticket-pane { display: none; }
  .brand-text, .live-text, .me-name, .caret, #shortcutsBtn, .search-kbd { display: none; }
  .search { margin-left: 0; }
  .details { width: 100%; }
  .tv-head { padding: 10px 12px; }
  .convo { padding: 12px 12px 6px; }
  .msg { margin: 0 -6px; padding: 6px; }
  .composer { padding: 9px 10px 12px; }
  .att-img, .att-video { max-width: 100%; }
  .bar { grid-template-columns: 120px minmax(0, 1fr) 34px; }
  .kv { grid-template-columns: 88px minmax(0, 1fr); }
  .only-mobile { display: inline-grid; }
  .composer-tabs { flex-wrap: wrap; }
  .composer-hint { flex-basis: 100%; order: 3; text-align: left; margin: 4px 0 0; }
  .btn .kbd, .hide-mobile, .tv-name .icon-btn { display: none; }
  .player-head .avatar.lg { display: none; }
  .player-head .tv-name { flex-wrap: wrap; row-gap: 3px; }
  .ppane { padding: 12px 12px 40px; }
  /* Small phones: the search box shrinks instead of pushing the account button off screen. */
  .topbar { gap: 8px; padding: 0 10px; }
  .search { min-width: 0; }
  .modal.builder-modal .b-cat-list { height: 44vh; }
}
@media (max-width: 420px) {
  .brand { display: none; }
}

/* Open a ticket with someone */
.side-new { padding: 0 2px; }
.side-new-btn { width: 100%; justify-content: center; }
.nt-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.nt-cat, .nt-hint { font-size: 12.5px; }
.nt-results { max-height: 220px; overflow-y: auto; margin-top: 6px; }
.nt-results:empty { display: none; }
.nt-person { padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface-2); }
.nt-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.nt-warn { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 14px; }
.nt-warn-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
select.input { height: 42px; padding: 0 10px; }
@media (max-width: 520px) { .nt-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .player-head .tv-row { flex-wrap: wrap; row-gap: 8px; } .player-head .tv-title { flex: 1 1 200px; } .player-head .ph-actions { width: 100%; justify-content: flex-start; } }
