:root {
  --bg: #f6f5fb; --card: #ffffff; --text: #17142b; --muted: #6b6780; --line: #e7e4f0;
  --primary: #7c3aed; --primary-soft: #efe9ff; --blue: #2563eb; --green: #16a34a; --red: #dc2626; --amber: #d97706;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1em; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; align-self: center; }
.login-card h1 { text-align: center; margin: 0; }
.login-card p { text-align: center; margin: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); }
textarea { min-height: 70px; resize: vertical; }
.captcha { min-height: 65px; display: flex; justify-content: center; }

.btn { font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; background: #ecebf3; color: var(--text); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--blue)); color: #fff; }
.btn.danger { background: #fde8e8; color: var(--red); }
.btn.good { background: #e3f6e8; color: var(--green); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.shell { display: flex; min-height: 100vh; }
.side { width: 250px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; padding: 18px 16px; font-size: 18px; font-weight: 800; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { color: var(--blue); }
.brand small { color: var(--muted); font-weight: 600; font-size: 12px; margin-left: 2px; }
nav { display: flex; flex-direction: column; padding: 6px; gap: 2px; flex: 1; overflow: auto; }
nav a { text-decoration: none; color: var(--text); padding: 9px 12px; border-radius: 10px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
nav a:hover { background: #f3f1fa; }
nav a.on { background: var(--primary-soft); color: var(--primary); }
nav a i { margin-left: auto; font-style: normal; background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; }
nav a i:empty { display: none; }
.me { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; }
.main { flex: 1; padding: 24px; min-width: 0; max-width: 1200px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .v { font-size: 26px; font-weight: 800; }
.stat .l { color: var(--muted); font-weight: 600; font-size: 12px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.warn .v { color: var(--red); }

.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.chart h3 { margin: 0 0 8px; font-size: 13px; }
.chart svg { width: 100%; height: auto; display: block; margin-top: 4px; }
.chart .sum { color: var(--muted); font-size: 12px; margin-top: 4px; }
.chart .sum b { color: var(--text); }
.tip { position: fixed; display: none; z-index: 20; background: #17142b; color: #fff; padding: 8px 11px; border-radius: 10px; font-size: 13px; line-height: 1.5; pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 260px; }
.chart details { margin-top: 8px; }
.chart summary { cursor: pointer; color: var(--primary); font-weight: 700; font-size: 13px; }
table.mini { margin-top: 6px; font-size: 12px; }
table.mini td, table.mini th { padding: 4px 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.charts { grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); }
.chart h3 { font-size: 15px; }
@media (max-width: 520px) { .charts { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #faf9fd; font-size: 12px; color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.scroll { overflow-x: auto; }

.bar { height: 10px; background: #eee; border-radius: 6px; overflow: hidden; min-width: 120px; }
.bar > span { display: block; height: 100%; background: var(--green); }
.bar.mid > span { background: var(--amber); }
.bar.high > span { background: var(--red); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; background: #eee; }
.pill.red { background: #fde8e8; color: var(--red); }
.pill.green { background: #e3f6e8; color: var(--green); }
.pill.amber { background: #fdf0dc; color: var(--amber); }
.pill.purple { background: var(--primary-soft); color: var(--primary); }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.item .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.item .preview { white-space: pre-wrap; word-break: break-word; background: #faf9fd; border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.split { display: grid; grid-template-columns: 340px 1fr; gap: 14px; }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; padding: 8px; background: #faf9fd; border-radius: 10px; }
.msg { max-width: 75%; padding: 7px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--primary-soft); }
.clickable { cursor: pointer; }
.clickable:hover { background: #faf9fd; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #17142b; color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10; }
.toast.on { opacity: 1; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { flex-direction: row; overflow-x: auto; }
  nav a { white-space: nowrap; }
  .main { padding: 16px; }
  .split { grid-template-columns: 1fr; }
}
