:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-2: #1f2937;
    --line: #334155;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --secondary: #64748b;
    --highlight: #22c55e;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: #020617;
    border-right: 1px solid var(--line);
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { font-size: 22px; font-weight: 800; margin-bottom: 24px; }
.user-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 18px; }
.user-name { font-weight: 700; }
.user-role { color: var(--muted); font-size: 13px; margin-top: 4px; }
.nav { display: grid; gap: 8px; }
.nav a { padding: 10px 12px; border: 1px solid transparent; border-radius: 12px; color: var(--muted); }
.nav a:hover { background: var(--panel); border-color: var(--line); color: var(--text); }
.content { flex: 1; padding: 20px; }
.page-title { font-size: 28px; margin: 0 0 8px; }
.page-subtitle { color: var(--muted); margin-bottom: 24px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 8px 30px rgba(0,0,0,.15); }
.stat-number { font-size: 32px; font-weight: 800; margin-bottom: 6px; }
.stat-label { color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 14px; font-weight: 700; }
form.inline { display: inline; }
label { display: block; margin-bottom: 8px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
    width: 100%;
    background: #0b1220;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    outline: none;
}
textarea { min-height: 120px; resize: vertical; }
button, .btn {
    border: 0;
    cursor: pointer;
    border-radius: 12px;
    padding: 11px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: #111827; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-soft { background: rgba(34,197,94,.14); border: 1px solid rgba(34,197,94,.25); color: #bbf7d0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.alert { padding: 14px 16px; border-radius: 12px; margin-bottom: 18px; border: 1px solid var(--line); }
.alert-success { background: rgba(16,185,129,.12); }
.alert-danger { background: rgba(239,68,68,.12); }
.alert-warning { background: rgba(245,158,11,.12); color: #fde68a; }
.alert-info { background: rgba(59,130,246,.12); }
.badge { display: inline-block; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-secondary { background: rgba(100,116,139,.2); color: #cbd5e1; }
.badge-warning { background: rgba(245,158,11,.2); color: #fcd34d; }
.badge-success { background: rgba(16,185,129,.2); color: #86efac; }
.badge-danger { background: rgba(239,68,68,.2); color: #fca5a5; }
.badge-info { background: rgba(59,130,246,.2); color: #93c5fd; }
.login-wrap { max-width: 460px; margin: 60px auto; }
.chat-shell { display: grid; grid-template-columns: 360px 1fr; gap: 18px; }
.chat-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.chat-stream { display: flex; flex-direction: column; gap: 14px; max-height: 62vh; overflow-y: auto; padding-right: 6px; }
.msg {
    border-radius: 18px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    max-width: 78%;
    white-space: normal;
    line-height: 1.5;
}

.msg-user {
    background: #132238;
    align-self: flex-start;
}

.msg-assistant {
    background: #12281d;
    align-self: flex-end;
}

.msg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.msg-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.msg-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-delete-form {
    margin: 0;
    flex-shrink: 0;
}

.msg-delete-btn {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}
.quick-help { color: var(--muted); font-size: 14px; line-height: 1.6; }
.sticky-compose { position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(15,23,42,0), rgba(15,23,42,1) 20%); padding-top: 14px; margin-top: 18px; }
.filter-bar { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.small { font-size: 13px; color: var(--muted); }
pre.code-block { background: #020617; border: 1px solid var(--line); border-radius: 16px; padding: 16px; overflow: auto; color: #cbd5e1; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.field-help { color: var(--muted); font-size: 12px; margin-top: 6px; }
.kv { display: grid; gap: 10px; }
.kv-item { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #0b1220; }
.kv-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.ai-box { border: 1px solid var(--line); border-radius: 16px; background: #0b1220; padding: 14px; margin-top: 14px; }
.ai-header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.right { text-align: right; }
@media (max-width: 1100px) {
    .chat-shell, .grid-2, .grid-3, .grid-4, .filter-bar { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .content { padding: 18px; }
    .msg { max-width: 92%; }
}
