:root {
  --brand: #4F46E5;
  --accent: #22C55E;

  --bg: #0B1220;
  --layer: #0E172A;
  --card: rgba(255,255,255,0.06);
  --stroke: rgba(255,255,255,0.08);

  --text: #E6EAF2;
  --text-muted: #A8B3CF;

  --danger: #EF4444;
  --warn: #F59E0B;
  --info: #3B82F6;

  --radius: 16px;
  --shadow: 0 6px 24px rgba(0,0,0,.25);
}

/* Light theme via [data-theme="light"] on <html> */
html[data-theme="light"] {
  --bg: #F6F8FC;
  --layer: #FFFFFF;
  --card: #FFFFFF;
  --stroke: rgba(3,7,18,.08);
  --text: #0B1220;
  --text-muted: #51607A;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 80% -10%, rgba(79,70,229,.25), transparent 60%),
              radial-gradient(800px 600px at -10% 50%, rgba(34,197,94,.18), transparent 60%),
              var(--bg);
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "aside header"
    "aside main";
  min-height: 100dvh;
}
.header { grid-area: header; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: var(--layer); border-bottom: 1px solid var(--stroke); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; letter-spacing: .2px; }
.header .actions { display: flex; gap: 8px; align-items: center; }

.aside { grid-area: aside; background: var(--layer); border-right: 1px solid var(--stroke); padding: 16px; position: sticky; top: 0; height: 100dvh; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; color: var(--text-muted); text-decoration: none;
}
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: linear-gradient(180deg, rgba(79,70,229,.18), rgba(79,70,229,.08)); color: var(--text); border: 1px solid rgba(79,70,229,.35); }

.main { grid-area: main; padding: 24px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 64px auto 1fr; grid-template-areas:
    "header" "aside" "main"; }
  .aside { height: auto; position: static; border-right: none; border-bottom: 1px solid var(--stroke); }
}

/* Cards */
.cards { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.card { grid-column: span 4; background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.half { grid-column: span 6; }
.card.full { grid-column: 1 / -1; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card .muted { color: var(--text-muted); font-size: 13px; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--stroke);
  background: var(--layer); color: var(--text); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--card); }
.btn.primary { background: linear-gradient(180deg, #5B54F0, #4338CA); border-color: rgba(255,255,255,.12); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { background: linear-gradient(180deg, #EF4444, #B91C1C); border-color: rgba(255,255,255,.12); }

/* Forms */
.form { max-width: 420px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--text-muted); }
.input, .select {
  width: 100%; padding: 12px 12px; border-radius: 12px; border: 1px solid var(--stroke); background: var(--layer); color: var(--text);
}
.input:focus, .select:focus { outline: 2px solid rgba(79,70,229,.5); border-color: rgba(79,70,229,.35); }

/* Tables */
.table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.table thead th {
  text-align: left; font-weight: 600; font-size: 13px; padding: 12px; color: var(--text-muted); background: var(--layer); position: sticky; top: 0; z-index: 1;
}
.table tbody td { padding: 12px; border-top: 1px solid var(--stroke); }
.table tbody tr:nth-child(odd) td { background: rgba(255,255,255,.02); }

/* Badges & Alerts */
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--stroke); background: var(--card); }
.badge.success { color: #22C55E; border-color: rgba(34,197,94,.35); }
.badge.warn { color: #F59E0B; border-color: rgba(245,158,11,.35); }
.badge.danger { color: #EF4444; border-color: rgba(239,68,68,.35); }

.alert { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--stroke); background: var(--card); margin: 12px 0; }
.alert.success { border-color: rgba(34,197,94,.35); }
.alert.danger { border-color: rgba(239,68,68,.35); }
.alert.info { border-color: rgba(59,130,246,.35); }

/* Misc */
hr { border: none; height: 1px; background: var(--stroke); margin: 16px 0; }
.separator { height: 1px; background: var(--stroke); margin: 8px 0; }

/* Utility */
.row { display: flex; gap: 10px; align-items: center; }
.space { flex: 1; }
.small { font-size: 12px; color: var(--text-muted); }

/* Chat */
.chat {
  display: grid; grid-template-rows: 1fr auto; gap: 12px; height: calc(100dvh - 64px - 48px);
}
.chat .messages {
  overflow: auto; padding: 12px; border: 1px solid var(--stroke);
  border-radius: var(--radius); background: var(--card);
}
.msg {
  max-width: 68%; padding: 10px 12px; border-radius: 14px; margin: 8px 0;
  border: 1px solid var(--stroke); background: var(--layer);
}
.msg .meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.msg.me { margin-left: auto; background: linear-gradient(180deg, #5B54F0, #4338CA); border-color: rgba(255,255,255,.12); }
.msg.bot { background: rgba(255,255,255,.04); }
.msg.system { background: transparent; border-style: dashed; color: var(--text-muted); }
.chat .composer {
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
}
.chat .composer .input { height: 44px; }
.typing { font-size: 12px; color: var(--text-muted); padding-left: 6px; }

