:root{
  --portal-bg: radial-gradient(1200px 800px at 10% 0%, rgba(37,99,235,.18), transparent 60%),
               radial-gradient(900px 700px at 95% 10%, rgba(124,58,237,.18), transparent 55%),
               radial-gradient(900px 700px at 60% 90%, rgba(6,182,212,.16), transparent 55%),
               #0b1020;
  --glass: rgba(255,255,255,.08);
  --glass-2: rgba(255,255,255,.06);
  --stroke: rgba(255,255,255,.14);
  --stroke-2: rgba(255,255,255,.10);
  --text-on-dark: rgba(255,255,255,.92);
  --muted-on-dark: rgba(255,255,255,.68);
  --shadow-xl: 0 26px 80px rgba(0,0,0,.35);
  --shadow-lg: 0 18px 40px rgba(0,0,0,.28);
  --r: 22px;
  --r2: 16px;
  --t: 180ms;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Inter,Arial;
  background: var(--portal-bg);
  color: var(--text-on-dark);
}

a{color: inherit}
.wrap{max-width:1100px;margin:28px auto;padding:0 16px}
.h1{font-size: clamp(28px, 3.2vw, 40px); letter-spacing:-.02em; margin: 18px 0 6px}
.p{color:var(--muted-on-dark); margin:0 0 18px; line-height:1.55}

.nav{
  position: sticky; top:0; z-index:20;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(10,15,28,.72), rgba(10,15,28,.45));
  border-bottom: 1px solid var(--stroke-2);
}
.nav__inner{max-width:1100px;margin:0 auto; padding: 12px 16px; display:flex; align-items:center; gap:12px}
.brand{display:flex; align-items:center; gap:10px; text-decoration:none}
.brand__dot{
  width:12px;height:12px;border-radius:999px;
  background: linear-gradient(135deg, #2563eb, #7c3aed 55%, #06b6d4);
  box-shadow: 0 0 0 6px rgba(255,255,255,.06);
}
.brand__text{font-weight:800; letter-spacing:-.02em}
.nav__links{display:flex; gap:10px; margin-left:10px; flex-wrap:wrap}
.nav__links a{
  text-decoration:none; padding:8px 10px; border-radius:999px;
  color: var(--muted-on-dark);
  border: 1px solid transparent;
  transition: transform var(--t), background var(--t), border-color var(--t);
}
.nav__links a:hover{background: rgba(255,255,255,.06); border-color: var(--stroke-2); transform: translateY(-1px)}
.spacer{flex:1}

.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration:none;
  border: 1px solid var(--stroke-2);
  background: rgba(255,255,255,.06);
  color: var(--text-on-dark);
  font-weight:700;
  transition: transform var(--t), background var(--t), border-color var(--t), box-shadow var(--t);
}
.btn:hover{transform: translateY(-1px); border-color: var(--stroke); background: rgba(255,255,255,.09); box-shadow: 0 14px 30px rgba(0,0,0,.22)}
.btn.primary{
  border-color: rgba(37,99,235,.55);
  background: linear-gradient(135deg, rgba(37,99,235,.95), rgba(124,58,237,.92));
  box-shadow: 0 18px 40px rgba(37,99,235,.18);
}
.btn.primary:hover{box-shadow: 0 22px 50px rgba(37,99,235,.25)}
.badge{
  display:inline-flex; align-items:center; gap:8px;
  padding: 8px 12px; border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--stroke-2);
  color: var(--muted-on-dark);
  font-weight:700;
  font-size: 13px;
}
.badge .dot{width:8px;height:8px;border-radius:999px;background: rgba(255,255,255,.5)}
.badge.ok .dot{background: #22c55e}
.badge.warn .dot{background: #f59e0b}
.badge.err .dot{background: #ef4444}
.badge.info .dot{background: #38bdf8}

.grid{display:grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap:14px; align-items:stretch}
.card{
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
  border: 1px solid var(--stroke-2);
  box-shadow: var(--shadow-lg);
  overflow:hidden;
}
.card__inner{padding:16px}
.card h3{margin:0 0 8px; font-size:16px; letter-spacing:-.01em}
.card p{margin:0; color:var(--muted-on-dark)}
.kpi{font-size: 30px; font-weight: 900; letter-spacing:-.02em}

.form{display:grid; gap:10px}
label{font-weight:700; color:var(--muted-on-dark); font-size:13px}
input,select,textarea{
  width:100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke-2);
  background: rgba(10,15,28,.55);
  color: var(--text-on-dark);
  outline:none;
  transition: border-color var(--t), transform var(--t), background var(--t);
}
textarea{min-height:120px; resize:vertical}
input:focus,select:focus,textarea:focus{border-color: rgba(99,102,241,.65); background: rgba(10,15,28,.72)}
.help{font-size:13px;color:var(--muted-on-dark); margin-top:-4px}
.error{color:#fecaca}
.success{color:#bbf7d0}

.table{width:100%; border-collapse: collapse}
.table th,.table td{padding:12px 10px; border-bottom: 1px solid rgba(255,255,255,.08); text-align:left}
.table th{color:var(--muted-on-dark); font-size:13px; font-weight:800}
.table a{color:#93c5fd; text-decoration:none}
.table a:hover{text-decoration:underline}

.chat{
  display:flex;
  flex-direction:column;
  height: min(68vh, 680px);
}
.chat__messages{
  padding: 14px;
  display:flex;
  flex-direction:column;
  gap:10px;
  overflow:auto;
  scroll-behavior:smooth;
}
.bubble{
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.08);
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
}
.bubble.me{
  margin-left:auto;
  background: linear-gradient(135deg, rgba(37,99,235,.95), rgba(124,58,237,.92));
  border-color: rgba(255,255,255,.14);
}
.bubble.admin{
  background: rgba(255,255,255,.07);
}
.bubble .meta{margin-bottom:6px; font-size:12px; color: rgba(255,255,255,.65)}
.bubble .text{white-space:pre-wrap; line-height:1.45}
.bubble.closure{
  max-width: 100%;
  background: linear-gradient(135deg, rgba(239,68,68,.95), rgba(185,28,28,.92));
  border-color: rgba(255,255,255,.18);
}
.chat__composer{
  border-top: 1px solid rgba(255,255,255,.10);
  padding: 12px;
  display:flex;
  gap:10px;
  align-items:flex-end;
  background: rgba(10,15,28,.55);
  backdrop-filter: blur(10px);
}
.chat__composer textarea{min-height:48px; max-height:140px}
.chat__composer .btn{white-space:nowrap}

@media (max-width: 720px){
  /* Mobile: keep nav links visible (horizontal scroll) */
  .nav__links{display:flex; overflow-x:auto; -webkit-overflow-scrolling:touch; flex-wrap:nowrap; gap:8px; margin-left:0; padding:6px 0}
  .nav__links a{white-space:nowrap; padding:8px 10px}
  .nav__inner{gap:10px}

  .wrap{margin:18px auto}
  .chat{height: 70vh}
  .bubble{max-width: 92%}
}

/* System messages styling */
.bubble.system{ background: rgba(148,163,184,.14); border:1px solid rgba(148,163,184,.25); }
.bubble.waiting{ background: rgba(245,158,11,.16); border:1px solid rgba(245,158,11,.45); color:#ffedd5; }
.bubble.closure{ background: rgba(239,68,68,.16); border:1px solid rgba(239,68,68,.55); color:#fee2e2; }
