:root {
  --primary: #696cff;
  --sidebar-bg: #233446;
  --sidebar-text: #cbd5e1;
  --body-bg: #f5f5f9;
  --card-bg: #fff;
  --border: #e7e7ef;
  --text: #566a7f;
  --danger: #ff3e1d;
  --success: #71dd37;
  --warning: #ffab00;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--text); background: var(--body-bg); }
a { color: var(--primary); text-decoration: none; }
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; padding: 1rem; }
.sidebar-brand { color: #fff; font-weight: 700; font-size: 1.1rem; margin-bottom: 1.5rem; display: flex; gap: .5rem; align-items: center; }
.brand-icon { color: var(--primary); }
.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar-nav .nav-section {
    margin-top: 1rem;
    margin-bottom: 0.15rem;
    padding: 0 0.75rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(203, 213, 225, 0.55);
}
.sidebar-nav .nav-section:first-child { margin-top: 0; }
.nav-item { padding: .6rem .75rem; border-radius: .5rem; color: var(--sidebar-text); }
.nav-item.nav-item-sub { padding-left: 1.35rem; font-size: 0.88rem; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-footer { font-size: .75rem; opacity: .7; }
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: .75rem 1.25rem; display: flex; justify-content: space-between; align-items: center; }
.topbar-title { font-weight: 600; color: #384551; }
.app-content { padding: 1.25rem; }
.container-fluid { width: 100%; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: .75rem; box-shadow: 0 2px 6px rgba(67,89,113,.08); margin-bottom: 1rem; }
.card-header { padding: .9rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; background: #fff; border-radius: .75rem .75rem 0 0; }
.card-body { padding: 1rem; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .65rem .75rem; border-bottom: 1px solid var(--border); text-align: left; }
.table thead th { background: #f8f9fc; font-weight: 600; }
.badge { display: inline-block; padding: .2rem .5rem; border-radius: .35rem; font-size: .75rem; background: #eceef1; }
.badge-role { background: rgba(105,108,255,.12); color: var(--primary); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: .5rem; padding: .5rem 1rem; cursor: pointer; font-size: .875rem; font-weight: 500; line-height: 1.4; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease; box-shadow: 0 1px 2px rgba(67,89,113,.08); white-space: nowrap; }
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 6px rgba(105,108,255,.35); }
.btn-primary:hover { background: #5f61e6; color: #fff; box-shadow: 0 4px 12px rgba(105,108,255,.4); }
.btn-outline, .btn-outline-primary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline-primary { border-color: rgba(105,108,255,.5); color: var(--primary); background: rgba(105,108,255,.04); }
.btn-outline-primary:hover { background: rgba(105,108,255,.1); color: var(--primary); border-color: var(--primary); }
.btn-outline-secondary { background: #fff; border-color: var(--border); color: #697a8d; }
.btn-outline-secondary:hover { background: #f8f9fc; color: #384551; border-color: #c9cdd8; }
.btn-outline-warning { background: #fff; border-color: rgba(255,171,0,.45); color: #b78103; }
.btn-outline-warning:hover { background: rgba(255,171,0,.08); }
.btn-outline-danger { background: #fff; border-color: rgba(255,62,29,.35); color: var(--danger); }
.btn-outline-danger:hover { background: rgba(255,62,29,.06); }
.btn-outline-info { background: #fff; border-color: rgba(3,195,236,.4); color: #03c3ec; }
.btn-outline-info:hover { background: rgba(3,195,236,.08); }
.btn-secondary { background: #8592a3; color: #fff; border-color: #8592a3; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); box-shadow: 0 2px 6px rgba(255,171,0,.3); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; border-radius: .4rem; }
.btn-lg { padding: .7rem 1.35rem; font-size: .95rem; border-radius: .55rem; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); box-shadow: 0 2px 6px rgba(113,221,55,.35); }
.btn-success:hover { background: #67c932; color: #fff; }
.btn-label-primary { background: rgba(105,108,255,.12); color: var(--primary); border-color: transparent; box-shadow: none; }
.btn-label-primary:hover { background: rgba(105,108,255,.2); color: var(--primary); box-shadow: none; }
.btn-label-success { background: rgba(113,221,55,.14); color: #4e9f22; border-color: transparent; box-shadow: none; }
.btn-label-success:hover { background: rgba(113,221,55,.22); color: #3d7d1a; box-shadow: none; }
.btn-label-secondary { background: rgba(133,146,163,.12); color: #697a8d; border-color: transparent; box-shadow: none; }
.btn-label-secondary:hover { background: rgba(133,146,163,.2); color: #566a7f; box-shadow: none; }
.btn-icon { width: 2.375rem; height: 2.375rem; padding: 0; border-radius: .5rem; }
.btn-icon.btn-sm { width: 2rem; height: 2rem; }
.w-100 { width: 100%; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.form-control, .form-select { width: 100%; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: .5rem; font-size: .9rem; }
.form-label { display: block; margin-bottom: .35rem; font-size: .85rem; font-weight: 500; }
.form-stack { display: flex; flex-direction: column; gap: .75rem; }
.form-stack > * { margin-bottom: 0; }
.alert { padding: .75rem 1rem; border-radius: .5rem; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.alert-danger { background: #ffe7e3; color: #ff3e1d; }
.alert-success { background: #e8fadf; color: #2f6b1c; }
.alert-info { background: #e7f3ff; color: #0d6efd; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.kpi-card { padding: 1rem; }
.kpi-label { font-size: .8rem; opacity: .8; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: #384551; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.mt-3 { margin-top: 1rem; }

/* ─── Guest / Login (Sneat-style) ─── */
.guest-body {
  min-height: 100vh;
  margin: 0;
  background: var(--body-bg);
}

.guest-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(320px, 1fr);
}

.guest-hero {
  background: linear-gradient(145deg, #233446 0%, #1a2533 55%, #151d28 100%);
  color: #e8ebf5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}

.guest-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(105,108,255,.25), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(3,195,236,.15), transparent 40%);
  pointer-events: none;
}

.guest-hero-inner {
  position: relative;
  max-width: 420px;
}

.guest-hero-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(105,108,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #a5a8ff;
  margin-bottom: 1.25rem;
}

.guest-hero h1 {
  margin: 0 0 .75rem;
  font-size: 2rem;
  color: #fff;
  font-weight: 800;
}

.guest-hero p.guest-slogan {
  margin: 0 0 1.5rem;
  line-height: 1.5;
  color: #c5cee0;
  font-size: 1.05rem;
  font-weight: 500;
  font-style: italic;
}

.guest-hero p:not(.guest-slogan) {
  margin: 0 0 1.5rem;
  line-height: 1.55;
  color: #b8c2d9;
  font-size: .95rem;
}

.guest-hero-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .65rem;
}

.guest-hero-features li {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .9rem;
  color: #d5dcea;
}

.guest-hero-features i {
  color: var(--primary);
}

.guest-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  min-height: 100vh;
}

.guest-card {
  background: #fff;
  padding: 2rem 2rem 1.75rem;
  border-radius: 1rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(43, 47, 66, .1);
  border: 1px solid var(--border);
}

.guest-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 1.25rem;
}

.guest-brand i { font-size: 1.35rem; }

.guest-title {
  margin: 0 0 .35rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: #384551;
}

.guest-subtitle {
  margin: 0 0 1.25rem;
  font-size: .9rem;
  color: #8a94a6;
}

.guest-form .form-label { margin-bottom: .25rem; }

.input-icon-wrap {
  position: relative;
}

.input-icon-wrap i {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa3b2;
  font-size: .95rem;
  pointer-events: none;
}

.input-icon-wrap .form-control {
  padding-left: 2.35rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(105,108,255,.15);
}

.guest-submit {
  margin-top: .25rem;
  padding: .65rem 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}

.guest-footer {
  margin-top: 1.25rem;
  font-size: .75rem;
  color: #9aa3b2;
  text-align: center;
}

.btn-primary:hover { filter: brightness(1.05); }

.guest-lab-hint {
  margin-top: 1.25rem;
  padding: .85rem 1rem;
  border-radius: .65rem;
  background: #f8f9fc;
  border: 1px dashed var(--border);
  font-size: .8rem;
  color: #566a7f;
}

.guest-lab-hint p {
  margin: 0 0 .5rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: #384551;
}

.guest-lab-hint dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .25rem .75rem;
  align-items: baseline;
}

.guest-lab-hint dt {
  font-weight: 600;
  color: #697a8d;
}

.guest-lab-hint dd { margin: 0; }
.guest-lab-hint code {
  font-size: .78rem;
  background: #fff;
  padding: .1rem .35rem;
  border-radius: .25rem;
  border: 1px solid var(--border);
}

.sidebar-brand .brand-icon {
  color: var(--primary);
  font-size: 1.1rem;
}
.code-block, pre.json-box { background: #1e1e1e; color: #d4d4d4; padding: .75rem; border-radius: .5rem; overflow: auto; font-size: .8rem; }
.node-card { border-left: 4px solid var(--primary); }
.intent-quick { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }
.intent-quick button { font-size: .75rem; padding: .25rem .5rem; }
.chat-box { max-height: 320px; overflow-y: auto; background: #f8f9fc; border-radius: .5rem; padding: .75rem; }
.chat-bubble { max-width: 85%; padding: .5rem .75rem; border-radius: .75rem; margin-bottom: .5rem; font-size: .9rem; }
.chat-assistant { background: #fff; border: 1px solid var(--border); }
.chat-user { background: rgba(105,108,255,.12); margin-left: auto; }
@media (max-width: 992px) { .sidebar { width: 200px; } .row-2 { grid-template-columns: 1fr; } }
@media (max-width: 768px) { .app-wrapper { flex-direction: column; } .sidebar { width: 100%; } }
@media (max-width: 900px) {
  .guest-shell { grid-template-columns: 1fr; }
  .guest-hero { padding: 2rem 1.5rem; min-height: auto; }
  .guest-hero h1 { font-size: 1.5rem; }
  .guest-panel { min-height: auto; padding-top: 0; }
}
