@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f5fb;
  --panel: #ffffff;
  --panel-2: #f8f9fd;
  --text: #171a2b;
  --muted: #6b7088;
  --line: #e7e9f2;
  --primary: #7c3aed;
  --primary-2: #db2777;
  --grad: linear-gradient(135deg, #7c3aed 0%, #db2777 55%, #f59e0b 100%);
  --ok: #10b981;
  --ok-bg: #e7f8f1;
  --warn: #f59e0b;
  --warn-bg: #fff6e5;
  --bad: #ef4444;
  --bad-bg: #fdecec;
  --info-bg: #efe9fe;
  --side: #12131f;
  --side-text: #a5a9c2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 22, 40, .04), 0 6px 24px rgba(20, 22, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ico { width: 18px; height: 18px; flex: none; }
pre.code, code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
pre.code { background: #0f1020; color: #e5e7ff; padding: 12px 14px; border-radius: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; background: var(--side); color: var(--side-text); padding: 20px 14px;
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 50;
  transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 20px; }
.logo-dot { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); display: inline-block; box-shadow: 0 4px 14px rgba(219, 39, 119, .4); }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--side-text); font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(124, 58, 237, .22); color: #fff; }
.nav a.active .ico { color: #c4a6ff; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, .07); margin: 12px 6px; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 12px; font-size: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }
.side-foot b { color: #fff; }

.main { flex: 1; margin-left: 248px; min-width: 0; }
.topbar {
  height: 62px; display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: rgba(244, 245, 251, .85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--text); }
.content { padding: 24px 28px 60px; max-width: 1400px; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid > .card, .grid > div > .card:last-child, .grid > form.card { margin-bottom: 0; }
.grid > div > .card { margin-bottom: 20px; }
.grid > div > .card:last-child { margin-bottom: 0; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.stat { position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat .glyph { position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--info-bg); color: var(--primary); }
.stat.pink .glyph { background: #fde7f1; color: var(--primary-2); }
.stat.green .glyph { background: var(--ok-bg); color: var(--ok); }
.stat.amber .glyph { background: var(--warn-bg); color: var(--warn); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: .15s;
}
.btn:hover { text-decoration: none; border-color: #cfd3e3; background: var(--panel-2); }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 4px 14px rgba(124, 58, 237, .28); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: #f6c4c4; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- Forms ---------- */
.form label, label.field { display: block; font-weight: 600; font-size: 13px; margin-bottom: 14px; }
.form label > input, .form label > select, .form label > textarea,
label.field > input, label.field > select, label.field > textarea { margin-top: 6px; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font: inherit; font-weight: 400; color: var(--text); transition: border .15s, box-shadow .15s;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #b9a2f5; box-shadow: 0 0 0 3px rgba(124, 58, 237, .14); }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 12px; }

/* switch */
.switch { display: flex !important; align-items: flex-start; gap: 12px; cursor: pointer; margin-bottom: 14px; font-weight: 600; }
.switch input { display: none; }
.switch .track { width: 40px; height: 22px; border-radius: 22px; background: #d6d9e6; position: relative; flex: none; transition: .2s; margin-top: 1px; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { left: 21px; }
.switch .txt small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

/* segmented radio */
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg label { margin: 0 !important; }
.seg input { display: none; }
.seg span { display: block; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg input:checked + span { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: #047857; border-color: #c4eedd; }
.badge.warn { background: var(--warn-bg); color: #b45309; border-color: #fde3b0; }
.badge.bad { background: var(--bad-bg); color: #b91c1c; border-color: #f8caca; }
.badge.info { background: var(--info-bg); color: #6d28d9; border-color: #ddd0fd; }
.badge.pink { background: #fde7f1; color: #be185d; border-color: #f9c8dd; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #c5c8d6; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 11px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.alert.success { background: var(--ok-bg); color: #065f46; border-color: #bfeedb; }
.alert.error { background: var(--bad-bg); color: #991b1b; border-color: #f6c6c6; }
.alert.warn { background: var(--warn-bg); color: #92400e; border-color: #fbe0ac; }
.alert.info { background: var(--info-bg); color: #5b21b6; border-color: #ddd0fd; }
.toast-wrap { position: fixed; right: 20px; top: 76px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast-wrap .alert { box-shadow: var(--shadow); animation: slidein .25s ease; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* ---------- Account cards ---------- */
.acc-card { display: flex; gap: 14px; align-items: center; }
.avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex: none; background: var(--grad); padding: 2px; }
.avatar.sm { width: 34px; height: 34px; }
.avatar-ph { width: 46px; height: 46px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar-ph.sm { width: 34px; height: 34px; font-size: 13px; }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.acc-grid .card { margin: 0; }
.kv { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.kv div { font-size: 12px; color: var(--muted); }
.kv b { display: block; font-size: 16px; color: var(--text); }

/* ---------- Posts grid ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.post { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.post .thumb { aspect-ratio: 1 / 1; background: #eceef6 center / cover no-repeat; position: relative; }
.post .thumb .type { position: absolute; left: 8px; top: 8px; }
.post .thumb .mon { position: absolute; right: 8px; top: 8px; }
.post .body { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post .cap { font-size: 12.5px; color: var(--muted); min-height: 36px; }
.post.off .thumb { filter: grayscale(.9) opacity(.6); }
.post-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; max-height: 360px; overflow-y: auto; padding: 4px; }
.post-pick label { position: relative; cursor: pointer; margin: 0 !important; }
.post-pick input { position: absolute; opacity: 0; }
.post-pick .pp { aspect-ratio: 1; border-radius: 10px; background: #eceef6 center / cover; border: 3px solid transparent; transition: .15s; }
.post-pick input:checked + .pp { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 58, 237, .2); }
.post-pick input:checked + .pp::after { content: '✓'; position: absolute; right: 6px; top: 6px; background: var(--primary); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; }

/* ---------- Chat ---------- */
.chat-box { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 10px 4px; }
.msg { max-width: 72%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.in { background: var(--panel-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 5px; }
.msg.out { background: var(--grad); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.msg .meta { display: block; font-size: 11px; opacity: .7; margin-top: 3px; }
.chat-send { display: flex; gap: 10px; margin-top: 14px; }
.chat-send textarea { min-height: 46px; height: 46px; }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #ede4ff 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #ffe1ef 0, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 34px; box-shadow: 0 20px 60px rgba(40, 20, 90, .12); border: 1px solid var(--line); }
.auth-card.wide { max-width: 620px; }
.brand-lg { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; margin-bottom: 22px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: #047857; }
.chip.bad { background: var(--bad-bg); color: #b91c1c; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-color: var(--primary); text-decoration: none; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 180px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 34px; background: var(--grad); border-radius: 6px 6px 3px 3px; min-height: 3px; }
.bars .b span { font-size: 10.5px; color: var(--muted); }
.progress { height: 8px; background: var(--panel-2); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); min-width: 120px; }
.progress i { display: block; height: 100%; background: var(--grad); }
.test-box { background: var(--panel-2); border: 1px dashed #cfd3e3; border-radius: 12px; padding: 14px; }
.test-result { margin-top: 8px; font-weight: 600; }
.copy { cursor: pointer; }
.wrap-text { white-space: pre-wrap; word-break: break-word; }
details summary { cursor: pointer; font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.backdrop { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 10, 20, .4); z-index: 40; }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 60px; }
  .grid.cols-2, .grid.cols-3, .grid2, .grid3 { grid-template-columns: 1fr; }
  .msg { max-width: 88%; }
  .filters select, .filters input { min-width: 0; width: 100%; }
}
@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat .value { font-size: 24px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
}
