/* ChannelEngine-style UI: values read from channelengine.com's stylesheet
   (Figtree 500/600, brand blue #2094F3, navy #151F39, Untitled-UI greys, 4–6px radii, pill buttons). */
[hidden] { display: none !important; }
:root {
  --blue: #2094F3;
  --blue-hover: #1E86E5;
  --blue-dark: #1A74D2;
  --navy: #151F39;
  --text: #101828;
  --muted: #667085;
  --subtle: #98A2B3;
  --border: #EAECF0;
  --border-strong: #D0D5DD;
  --bg: #F9FAFB;
  --tint: #EAF4FE;
  --white: #FFFFFF;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .10);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, .08), 0 4px 6px -2px rgba(16, 24, 40, .03);
  --font: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 400; }
h1, h2, h3 { margin: 0; font-weight: 600; }
button { font: inherit; cursor: pointer; }
a { color: var(--blue-dark); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

.btn {
  border: 1px solid var(--border-strong); background: var(--white); color: var(--text);
  border-radius: 9999px; padding: 8px 16px; font-weight: 600; font-size: 13px; box-shadow: var(--shadow);
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn:focus-visible, .nav-item:focus-visible, .demo-user:focus-visible, .cfg-btn:focus-visible {
  outline: 4px solid #B2DDFF; outline-offset: 1px;
}
.pill {
  display: inline-block; border-radius: 9999px; padding: 2px 10px; font-size: 12px; font-weight: 500;
  background: var(--tint); color: var(--blue-dark); white-space: nowrap;
}

/* ---- brand ---- */
.brand-row { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--blue);
  display: grid; place-items: center; flex: 0 0 auto;
}
.mark svg { width: 18px; height: 18px; }
.wordmark { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.wordmark small { font-weight: 500; color: var(--subtle); font-size: 12px; margin-left: 6px; }

/* ---- login ---- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.login-card {
  width: min(980px, 100%); display: grid; grid-template-columns: 1fr 1.1fr;
  background: var(--white); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-card > section { padding: 36px; }
.login-card .hero { background: var(--navy); color: var(--white); display: flex; flex-direction: column; }
.hero .wordmark small { color: #98A2B3; }
.hero h1 { font-size: 30px; line-height: 1.2; margin: 28px 0 14px; font-weight: 600; }
.hero h1 span { color: var(--blue); }
.hero p { line-height: 1.6; color: #D0D5DD; margin: 0 0 12px; }
.hero-link { color: #84CAFF; font-weight: 600; text-decoration: none; margin: 4px 0 8px; }
.hero-link:hover { color: var(--white); text-decoration: underline; }
.arch-page { height: auto; min-height: 100%; }
.arch-main { max-width: 1240px; margin: 0 auto; padding: 28px 20px 40px; }
.arch-main h1 { font-size: 26px; margin-bottom: 8px; }
.arch-main > p { max-width: 760px; line-height: 1.6; margin: 0 0 18px; }
.arch-card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 20px; }
.arch-card img { display: block; width: 100%; height: auto; }
.hero .powered { margin-top: auto; padding-top: 24px; font-size: 12px; color: #98A2B3; }
.hero .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 6px; }
.hero .stats div { border-left: 2px solid var(--blue); padding-left: 10px; }
.hero .stats b { display: block; font-size: 20px; }
.hero .stats span { font-size: 12px; color: #98A2B3; }
label { display: block; font-size: 13px; font-weight: 500; margin: 14px 0 6px; color: #344054; }
input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: 8px;
  font: inherit; background: var(--white); box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
input:focus { outline: none; border-color: #84CAFF; box-shadow: 0 0 0 4px #D1E9FF; }
form .btn.primary { width: 100%; margin-top: 18px; padding: 10px 16px; }
.error { color: #B42318; font-size: 13px; min-height: 18px; margin-top: 10px; }
.demo-users { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.demo-users .head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.demo-group { margin-top: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.demo-group-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.demo-group-head .swatch { width: 10px; height: 10px; border-radius: 9999px; background: var(--accent); }
.demo-group-head .muted { margin-left: auto; font-weight: 500; font-size: 12px; }
.demo-line { display: flex; gap: 6px; align-items: stretch; margin-top: 8px; }
.demo-user {
  flex: 1; min-width: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  text-align: left; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; border-left: 3px solid var(--accent);
}
.demo-user:hover { border-color: var(--blue); border-left-color: var(--accent); background: var(--tint); }
.demo-user b { display: block; font-weight: 600; }
.demo-user small { color: var(--muted); }
.cfg-btn {
  flex: 0 0 34px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white);
  color: var(--blue-dark); font-weight: 600; font-style: italic; font-family: Georgia, serif;
}
.cfg-btn:hover, .cfg-btn[aria-expanded="true"] { background: var(--tint); border-color: var(--blue); }
.cfg-pop {
  position: absolute; z-index: 10; width: min(400px, calc(100vw - 32px));
  background: var(--white); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 14px 16px; font-size: 12px; line-height: 1.45; border-top: 4px solid var(--accent);
}
.cfg-head { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.cfg-layer { margin: 10px 0 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.cfg-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; padding: 2px 0; }
.cfg-row .mono { word-break: break-all; }
.cfg-label { color: var(--muted); }
.cfg-sees { margin-top: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--tint); color: var(--blue-dark); }

/* ---- app shell ---- */
.shell { display: grid; grid-template-rows: auto 1fr; height: 100%; }
header.top {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--white); border-bottom: 1px solid var(--border);
}
.tenant { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; }
.tenant .swatch { width: 10px; height: 10px; border-radius: 9999px; }
.tenant small { display: block; font-size: 11px; color: var(--muted); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who .id { text-align: right; line-height: 1.3; }
.who .id b { display: block; font-weight: 600; }
.main { display: grid; grid-template-columns: 280px 1fr; min-height: 0; }
.main.chat-open { grid-template-columns: 280px 1fr 400px; }
.main:not(.chat-open) .chat { display: none; }
nav.side { border-right: 1px solid var(--border); padding: 16px; overflow: auto; background: var(--white); }
nav.side h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 6px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--white); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.nav-item .ico {
  width: 38px; height: 38px; border-radius: 8px; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--tint); color: var(--blue-dark);
}
.nav-item .body { flex: 1; min-width: 0; }
.nav-item .t { display: block; font-weight: 600; font-size: 14px; }
.nav-item .sec { display: block; margin-top: 4px; }
.nav-item .chev { color: var(--subtle); font-size: 20px; line-height: 1; }
.nav-item:hover { border-color: var(--blue); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.nav-item.active { border-color: var(--blue); background: var(--tint); box-shadow: 0 0 0 3px #D1E9FF; }
.nav-item.active .ico { background: var(--blue); color: var(--white); }
.nav-item.active .chev { color: var(--blue-dark); }
.nav-item.locked { border-style: dashed; background: var(--bg); box-shadow: none; color: var(--muted); }
.nav-item.locked .ico { background: #F2F4F7; color: var(--subtle); }
.nav-item.locked .pill { background: #F2F4F7; color: var(--muted); }
.nav-item.locked.active { border-style: solid; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9999px; border: 1px solid var(--border-strong); background: var(--white);
  color: var(--blue-dark); display: grid; place-items: center; box-shadow: var(--shadow);
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--tint); border-color: var(--blue); }
.icon-btn:focus-visible { outline: 4px solid #B2DDFF; outline-offset: 1px; }
.who { position: relative; }
.access-pop { top: calc(100% + 10px); right: 0; width: 340px; }
.access-pop .mono { font-size: 11px; word-break: break-all; }
section.stage { display: grid; grid-template-rows: auto 1fr; min-height: 0; padding: 16px 20px 20px; gap: 12px; }
.stage-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stage-head h2 { font-size: 18px; }
.stage-head .note { flex: 1 1 320px; color: var(--muted); font-size: 13px; }
.frame {
  border: 1px solid var(--border); border-radius: 8px; background: var(--white);
  box-shadow: var(--shadow); overflow: hidden; min-height: 0; position: relative;
}
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; }
.placeholder .box { max-width: 540px; }
.placeholder h2 { font-size: 18px; margin-bottom: 10px; }
.placeholder p { line-height: 1.55; }

@media (max-width: 760px) {
  .login-card { grid-template-columns: 1fr; }
  .main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  nav.side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 40vh; }
  header.top { flex-wrap: wrap; }
  .frame { min-height: 70vh; }
}

/* ---- chat with your data ---- */
.chat-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.chat {
  display: flex; flex-direction: column; min-height: 0; background: var(--white);
  border-left: 1px solid var(--border);
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--navy); display: grid; place-items: center; flex: 0 0 auto; }
.chat-title { flex: 1; min-width: 0; line-height: 1.3; }
.chat-title b { display: block; font-size: 15px; }
.chat-title .muted { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.sm { width: 30px; height: 30px; box-shadow: none; color: var(--muted); }
.chat-log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { font-size: 13.5px; line-height: 1.55; max-width: 100%; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg code { font-family: var(--mono); font-size: 12px; background: #F2F4F7; padding: 1px 4px; border-radius: 4px; }
.msg.me {
  align-self: flex-end; background: var(--blue); color: var(--white); padding: 8px 12px;
  border-radius: 12px 12px 2px 12px; max-width: 85%; white-space: pre-wrap;
}
.msg.bot { align-self: stretch; display: flex; flex-direction: column; gap: 8px; }
.msg.bot.intro { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: #344054; }
.answer { color: var(--text); }
table.md { border-collapse: collapse; font-size: 12.5px; margin: 4px 0 8px; width: 100%; }
table.md th, table.md td { border-bottom: 1px solid var(--border); padding: 4px 6px; text-align: left; }
table.md th { color: var(--muted); font-weight: 600; }
.tool { border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: 12px; }
.tool summary { cursor: pointer; padding: 7px 10px; display: flex; align-items: center; gap: 8px; color: #344054; list-style: none; }
.tool summary::-webkit-details-marker { display: none; }
.tool summary::after { content: '›'; margin-left: auto; color: var(--subtle); transition: transform .12s; }
.tool[open] summary::after { transform: rotate(90deg); }
.tool .dot { width: 8px; height: 8px; border-radius: 9999px; background: var(--subtle); animation: pulse 1s infinite alternate; }
.tool.ok .dot { background: #12B76A; animation: none; }
.tool.err .dot { background: #F04438; animation: none; }
.tool .sql { margin: 0; padding: 8px 10px; background: var(--navy); color: #E4E7EC; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; overflow-x: auto; }
.tool .res { padding: 8px 10px; }
.tool .tbl { overflow: auto; max-height: 240px; }
.tool table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
.tool th, .tool td { padding: 3px 6px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.tool th { position: sticky; top: 0; background: var(--bg); color: var(--muted); font-weight: 600; }
.tool .null { color: #B42318; font-style: italic; }
.tool .more { margin-top: 6px; }
.tool .errtxt { margin: 0; white-space: pre-wrap; color: #B42318; font-family: var(--mono); font-size: 11px; }
.chat-err { color: #B42318; margin: 0; }
.typing { display: flex; gap: 4px; padding: 6px 0; }
.typing span { width: 6px; height: 6px; border-radius: 9999px; background: var(--subtle); animation: pulse .9s infinite alternate; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { from { opacity: .25; } to { opacity: 1; } }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chip {
  border: 1px solid var(--border-strong); background: var(--white); border-radius: 9999px; padding: 6px 12px;
  font-size: 12.5px; color: #344054; text-align: left;
}
.chip:hover { border-color: var(--blue); background: var(--tint); color: var(--blue-dark); }
.followups { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: -2px 0 4px; }
.followups .chip { text-align: left; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }
.chat-form textarea {
  flex: 1; resize: none; font: inherit; font-size: 13.5px; padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: 10px; max-height: 140px; box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.chat-form textarea:focus { outline: none; border-color: #84CAFF; box-shadow: 0 0 0 4px #D1E9FF; }
.chat-form .btn, .chat-form .btn.primary { width: auto; margin-top: 0; flex: 0 0 auto; padding: 10px 14px; display: grid; place-items: center; }
.chat-form textarea { min-width: 0; }
.chat-form .btn:disabled { opacity: .5; cursor: default; }
.chat-foot { padding: 0 16px 12px; font-size: 11px; color: var(--muted); }
@media (max-width: 1200px) { .main.chat-open { grid-template-columns: 240px 1fr 340px; } }
@media (max-width: 760px) {
  .main.chat-open { grid-template-columns: 1fr; }
  .chat { border-left: 0; border-top: 1px solid var(--border); min-height: 70vh; }
}
