* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0e1621; --panel: #17212b; --panel2: #1d2a36; --line: #26333f;
  --text: #e9eef2; --muted: #8696a3; --accent: #3390ec; --accent2: #2b7bd0;
  --danger: #e0524a; --ok: #4dae64; --warn: #d8a24a;
}
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin-top: 10px; min-height: 18px; font-size: 14px; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); padding: 36px 32px; border-radius: 14px; width: 320px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.login-card h1 { font-size: 26px; margin-bottom: 4px; }
.login-card p { margin-bottom: 22px; }
.login-card input { width: 100%; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 15px; }
.login-card button { width: 100%; margin-top: 14px; padding: 12px; background: var(--accent); border: none; border-radius: 8px; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: var(--accent2); }

/* App layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 0; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 20px; font-weight: 700; padding: 0 22px 18px; }
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.sidebar nav a { padding: 12px 22px; color: var(--muted); cursor: pointer; font-size: 15px; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: var(--panel2); color: var(--text); }
.sidebar nav a.active { color: var(--text); border-left-color: var(--accent); background: var(--panel2); }
.logout { margin: 0 22px; padding: 10px; background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer; }
.logout:hover { border-color: var(--danger); color: var(--danger); }
main { flex: 1; padding: 28px 32px; overflow-x: auto; }
.loader { color: var(--muted); padding: 40px; text-align: center; }

h2.title { font-size: 22px; margin-bottom: 20px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* Cards / stats */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card .n { font-size: 28px; font-weight: 700; }
.card .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }

/* Controls */
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 9px 12px; font-size: 14px; font-family: inherit; }
textarea { width: 100%; min-height: 120px; resize: vertical; }
button.btn { background: var(--accent); border: none; border-radius: 8px; color: #fff; padding: 9px 16px; font-size: 14px; cursor: pointer; font-weight: 500; }
button.btn:hover { background: var(--accent2); }
button.btn.sm { padding: 6px 10px; font-size: 13px; }
button.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.btn.ghost:hover { border-color: var(--accent); }
button.btn.danger { background: var(--danger); }
button.btn.danger:hover { background: #c63f38; }
.pill { padding: 3px 9px; border-radius: 20px; font-size: 12px; background: var(--panel2); }
.pill.chief { background: #6b3fa0; } .pill.admin { background: #2b7bd0; }
.pill.moderator { background: #2f8f5b; } .pill.editor { background: #b8862f; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border-radius: 12px; padding: 24px; width: 540px; max-width: 92vw; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; }
.modal label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.modal input, .modal select, .modal textarea { width: 100%; }
.modal .row-end { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 14px 18px; border-radius: 8px; z-index: 100; max-width: 360px; }
.toast.err { border-left-color: var(--danger); }
.log-line { font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.log-line .meta { color: var(--muted); }

.emoji-bar { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.emoji-bar span { cursor: pointer; font-size: 20px; padding: 3px 5px; border-radius: 6px; line-height: 1; }
.emoji-bar span:hover { background: var(--panel2); }
.between { display: flex; align-items: center; justify-content: space-between; }
