:root {
  --bg: #101318; --panel: #181d24; --panel2: #1f252e; --line: #2a313b; --text: #f5f7fa;
  --muted: #9aa4b2; --accent: #ffd21f; --teal: #42d8c4; --good: #63e6b0; --bad: #ff8a92;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 "Segoe UI", Tahoma, Arial, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.4em; }
h1, h2, h3 { margin: 0 0 12px; }
h2 { font-size: 22px; }
a { color: var(--accent); }

input, textarea, select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #ffd21f55; border-color: var(--accent); }
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
label > input, label > textarea, label > select { margin-top: 4px; color: var(--text); font-size: 15px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.check input { width: auto; }

.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 8px 14px;
  border-radius: 10px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.login-card img { max-width: 180px; display: block; margin: 0 auto 12px; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 16px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; overflow-y: auto; }
.brand { font-size: 22px; font-weight: 900; color: var(--accent); margin-bottom: 16px; }
.brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: 2px; }
nav .group { color: var(--muted); font-size: 12px; margin: 14px 8px 4px; }
nav a { display: block; padding: 7px 10px; border-radius: 9px; color: var(--text); text-decoration: none; }
nav a:hover { background: var(--panel2); }
nav a.active { background: #ffd21f22; color: var(--accent); }
nav a .badge { float: left; }
.me { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center;
  font-size: 12px; color: var(--muted); overflow: hidden; }
.me span { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.main { padding: 24px; max-width: 1200px; width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 28px; color: var(--accent); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #111;
  font-size: 12px; text-align: center; font-weight: 700; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--panel2); color: var(--muted); }
.pill.good { color: var(--good); } .pill.bad { color: var(--bad); } .pill.accent { color: var(--accent); }

.list .item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item .title { flex: 1; min-width: 0; }
.list .item .title small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--panel2); flex: none; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }

/* editor */
.field-list { border: 1px dashed var(--line); border-radius: 12px; padding: 10px; margin: 4px 0 14px; }
.field-list > .entry { background: var(--panel2); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.field-list > .entry > .entry-head { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.strings .entry { display: flex; gap: 6px; padding: 6px; }
.img-field { display: flex; gap: 10px; align-items: center; }
.img-field img { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: #0005; }
.images { display: flex; flex-wrap: wrap; gap: 8px; }
.images .im { position: relative; }
.images .im img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.images .im .x { position: absolute; top: 2px; left: 2px; }

.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; padding: 20px; z-index: 10; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; width: min(820px, 100%);
  max-height: calc(100vh - 40px); overflow-y: auto; padding: 22px; }
.modal-actions { position: sticky; bottom: -22px; background: var(--panel); padding: 12px 0; display: flex; gap: 8px;
  border-top: 1px solid var(--line); margin-top: 8px; }

.toast { position: fixed; bottom: 20px; left: 20px; background: var(--panel2); border: 1px solid var(--accent);
  padding: 10px 16px; border-radius: 12px; z-index: 20; }
.toast.bad { border-color: var(--bad); }

/* chat */
.chat { display: grid; grid-template-columns: 280px 1fr; gap: 14px; height: calc(100vh - 140px); }
.chat .threads { overflow-y: auto; }
.chat .threads .item { cursor: pointer; }
.chat .threads .item.active { background: #ffd21f15; }
.chat .conv { display: flex; flex-direction: column; min-height: 0; padding: 0; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: var(--panel2); align-self: flex-start; }
.msg.admin { align-self: flex-end; background: #ffd21f26; }
.msg small { display: block; color: var(--muted); font-size: 11px; }
.msg .who { color: var(--teal); font-weight: 700; font-size: 12px; }
.chat form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat .conv { height: 70vh; }
}
