:root {
  color-scheme: light;
  --background: #fff;
  --sidebar: #fafafa;
  --surface: #f6f6f7;
  --text: #18181b;
  --muted: #64646e;
  --line: #e4e4e7;
  --accent: #18181b;
  --green: #0c6b4d;
  --red: #a72131;
  --sidebar-width: 248px;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--background);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button, .button { cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #52525b; outline-offset: 3px;
}
.icon { width: 17px; height: 17px; flex: none; vertical-align: middle; }
.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0,1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; background: var(--sidebar); border-right: 1px solid var(--line);
  padding: 14px 12px 12px; display: flex; flex-direction: column; gap: 17px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 7px 8px; width: fit-content; }
.brand-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; }
.brand-icon .icon { width: 21px; height: 21px; }
.brand strong, .sidebar-footer strong { display: block; font-weight: 650; line-height: 1.25; }
.brand small, .sidebar-footer small, .profile-options small { display: block; color: var(--muted); font-size: 12px; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { min-height: 36px; display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 6px; }
.sidebar nav a:hover, .sidebar nav a[aria-current] { background: #ededf0; }
.sidebar nav a[aria-current] { font-weight: 650; }
.sidebar nav a svg:last-child:not(:first-child) { margin-left: auto; width: 13px; color: var(--muted); }
.nav-label { padding: 0 9px; margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.nav-label:not(:first-child) { margin-top: 21px; }
.sidebar-footer { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 13px 7px 3px; }
.avatar { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: #ededf0; font-weight: 650; }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 3; height: 56px; display: flex; align-items: center; gap: 13px;
  border-bottom: 1px solid var(--line); background: var(--background); padding: 0 24px; }
.breadcrumb { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.breadcrumb::before { content: ""; height: 16px; width: 1px; background: var(--line); margin-right: 2px; }
.breadcrumb .icon { width: 13px; }
.breadcrumb strong { color: var(--text); font-weight: 550; }
.quick-search { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 156px;
  padding: 6px 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; color: var(--muted); }
.profile-menu { position: relative; }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.profile-options { position: absolute; top: 40px; right: 0; display: grid; gap: 4px; z-index: 4; width: 170px; padding: 9px;
  border: 1px solid var(--line); background: var(--background); box-shadow: 0 5px 18px #0001; border-radius: 8px; }
.profile-options > strong, .profile-options > small { padding: 0 5px; }
.profile-options > a, .profile-options form button { padding: 6px; border-radius: 5px; width: 100%; text-align: left; }
.profile-options > a:hover, .profile-options form button:hover { background: var(--surface); }
.profile-options form { border-top: 1px solid var(--line); padding-top: 4px; }
.profile-options form button { background: transparent; border: none; color: var(--text); }
.main { max-width: 1480px; margin: 0 auto; padding: 28px 26px 50px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -.035em; }
h2 { font-size: 17px; line-height: 1.35; letter-spacing: -.015em; }
h3 { font-size: 14px; }
p, .muted { color: var(--muted); }
.page-heading p, .section-heading p { margin-top: 5px; }
.section-heading { margin: 25px 0 13px; }
#management, #user-search { scroll-margin-top: 72px; }
.grant-card { margin-top: 16px; }
.experience-settings { max-width: 680px; }
.cards { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.product-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.card { border: 1px solid var(--line); border-radius: 9px; padding: 17px; background: var(--background); }
.stat-title, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-title .icon { color: var(--muted); }
.stat-value { display: block; font-size: 27px; line-height: 1.25; letter-spacing: -.04em; margin: 8px 0 3px; font-variant-numeric: tabular-nums; }
.stat-card p { font-size: 12px; }
.product-title { display: flex; gap: 9px; align-items: center; }
.product-symbol { display: grid; place-items: center; width: 32px; height: 32px; color: #3f3f46; background: var(--surface); border-radius: 7px; }
.product-card p { margin: 10px 0 12px; font-size: 13px; }
.product-links { display: grid; }
.product-links a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }
.product-links a:hover { text-decoration: underline; }
.product-links .icon { width: 14px; color: var(--muted); }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 6px 11px;
  background: var(--accent); color: #fff; border: 1px solid transparent; border-radius: 6px; font-weight: 550; white-space: nowrap; }
button:hover, .button:hover { opacity: .87; }
.secondary { background: var(--background); color: var(--text); border-color: var(--line); }
.outline-quiet, .text-button { background: transparent; color: var(--text); }
.outline-quiet:hover, .text-button:hover { background: var(--surface); opacity: 1; }
.danger { background: var(--background); color: var(--red); border-color: var(--line); }
.icon-button { min-height: 32px; min-width: 32px; padding: 5px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 550; }
input, select { min-height: 35px; max-width: 100%; padding: 6px 10px; background: var(--background); border: 1px solid var(--line); border-radius: 6px; }
input::placeholder { color: var(--muted); }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-field { position: relative; display: flex; align-items: center; min-width: 170px; }
.search-field .icon { position: absolute; left: 9px; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 33px; width: 250px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.table-frame { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; font-weight: 550; background: var(--sidebar); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
td.empty { text-align: center; color: var(--muted); height: 98px; }
td a:not(.button):hover { text-decoration: underline; }
.user-name { display: flex; align-items: center; gap: 9px; }
.user-name strong, .user-name small { display: block; }
.user-name small, .table-caption { color: var(--muted); font-size: 12px; }
.table-caption { padding-top: 10px; }
.badge { display: inline-flex; align-items: center; border-radius: 5px; padding: 2px 7px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; line-height: 1.35; font-weight: 550; }
.badge.success { background: #edf8f2; color: var(--green); border-color: #d5eddf; }
.badge.inactive { background: #fff3f3; color: var(--red); border-color: #f5dddd; }
.badges { display: flex; gap: 4px; }
td:last-child:has(.row-actions) { width: 1%; text-align: right; }
.row-actions { display: inline-flex; gap: 4px; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
code { font-size: 12px; overflow-wrap: anywhere; color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.stack { display: grid; gap: 13px; }
.card .stack, .card form { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: end; gap: 9px; }
.notice { background: #fff3f3; border: 1px solid #f5dddd; border-radius: 6px; padding: 9px 11px; margin-bottom: 12px; color: var(--red); }
dialog { width: min(440px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 11px; padding: 21px; color: var(--text); box-shadow: 0 12px 32px #0002; }
dialog::backdrop { background: #18181b55; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.dialog-header p { margin-top: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.auth-shell { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.auth-shell > header { padding: 15px 19px; }
.auth-main { width: min(100% - 32px, 385px); margin: auto; padding: 0 0 68px; }
.auth-main .page-heading { justify-content: center; text-align: center; margin-bottom: 20px; }
.auth-main.account-main { width: min(100% - 32px, 560px); align-self: start; margin: 38px auto; }
.auth-main .card + .card { margin-top: 14px; }
.login .stack button { margin-top: 2px; }
.sidebar-collapsed .shell { grid-template-columns: minmax(0,1fr); }
.sidebar-collapsed .sidebar { display: none; }
.skip-link { position: fixed; left: 14px; top: -50px; z-index: 10; background: var(--accent); color: white; padding: 7px 10px; border-radius: 5px; }
.skip-link:focus { top: 8px; }
@media (max-width: 1120px) { .cards { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .sidebar, .sidebar-collapsed .sidebar { display: none; position: fixed; inset: 56px auto 0 0; z-index: 2; width: min(270px,90vw); height: auto; box-shadow: 8px 0 22px #0002; }
  .sidebar-open .sidebar { display: flex; }
  .main { padding: 22px 14px 36px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .quick-search { min-width: 0; padding: 6px; }
  .quick-search span { display: none; }
  .breadcrumb { gap: 5px; }
  .product-grid, .settings-grid { grid-template-columns: 1fr; }
}

.bot-source-grid {
  display: grid;
  grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr);
  align-items: start;
  gap: 1.25rem;
}
.bot-source-list, .bot-preview { min-width: 0; }
.bot-source-list section { margin-top: 1.25rem; }
.bot-source-list h3 { display: flex; justify-content: space-between; gap: .75rem; }
.bot-source-list p, .bot-source-item small, .bot-preview p { opacity: .78; overflow-wrap: anywhere; }
.bot-source-item {
  display: grid;
  gap: .25rem;
  margin: .25rem 0;
  padding: .65rem .8rem;
  border: 1px solid transparent;
  border-radius: .6rem;
  overflow-wrap: anywhere;
  text-decoration: none;
}
.bot-source-item:hover, .bot-source-item[aria-current] {
  background: color-mix(in srgb, currentColor 6%, transparent);
  border-color: color-mix(in srgb, currentColor 24%, transparent);
}
.bot-group-picker { display: flex; align-items: end; gap: .5rem; }
.bot-group-picker label { flex: 1; min-width: 0; }
.bot-group-picker select { width: 100%; }
.bot-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.bot-intake {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}
.bot-intake button { flex: none; }
@media (max-width: 760px) {
  .bot-source-grid { grid-template-columns: minmax(0, 1fr); }
  .bot-intake { align-items: start; flex-direction: column; }
}

.bot-settings-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.bot-settings-tabs [aria-current="page"] { border-color: var(--text); font-weight: 600; }
.ops-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 12px; }
.ops-bar { display: grid; gap: 3px; min-width: 55px; }
.ops-bar meter { width: 100%; height: 10px; accent-color: #456dab; }
dialog.ops-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(700px, 100%);
  max-width: 100%; height: 100%; max-height: 100%; overflow: auto; border-radius: 0; }
.ops-drawer pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.ops-drawer { overscroll-behavior: contain; }
.ops-input-preview { display: block; width: 22ch; max-width: 22ch; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; cursor: help; }
.ops-input-unavailable, .ops-detail-error { color: var(--muted); }

.kb-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.kb-toolbar :last-child.button { margin-inline-start: auto; }
.kb-toolbar [aria-current="page"] { font-weight: 600; text-decoration: underline; }
.kb-crumb, .kb-tabs, .kb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.kb-crumb, .kb-tabs { margin-bottom: 1rem; }
.kb-crumb a { color: var(--muted); text-decoration: underline; text-underline-offset: .18em; }
.kb-crumb [aria-current="page"] { font-weight: 600; }
.kb-tabs [aria-current="page"] { background: var(--surface); border-color: var(--muted); }
.badge.warning { background: #fff7df; color: #754700; border-color: #f1d58e; }
.breadcrumb a { text-decoration: underline; text-underline-offset: .18em; }
.intake-hint { padding: .7rem .85rem; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }

.knowledge-content { color: var(--text); font-size: 15px; line-height: 1.8; overflow-wrap: anywhere; }
.bot-preview .knowledge-content p { color: var(--text); opacity: 1; margin: .75em 0; }
.knowledge-content > :first-child { margin-top: 0; }
.knowledge-content h1 { font-size: 23px; }
.knowledge-content h2 { font-size: 20px; margin: 1.3em 0 .5em; }
.knowledge-content h3 { font-size: 17px; margin: 1.2em 0 .4em; }
.knowledge-content ul, .knowledge-content ol { padding-left: 1.5em; }
.knowledge-content a { text-decoration: underline; text-underline-offset: 3px; }
.knowledge-content blockquote { margin-left: 0; padding-left: 1em; border-left: 3px solid var(--line); color: var(--muted); }
.knowledge-content pre { padding: 14px; background: var(--surface); border-radius: 6px; overflow-x: auto; }
.knowledge-content table { white-space: normal; margin: .8em 0; }
.knowledge-content th, .knowledge-content td { vertical-align: top; min-width: 6em; }
.knowledge-content td { white-space: pre-wrap; }
.knowledge-table { max-width: 100%; overflow-x: auto; }
.knowledge-source, .knowledge-aliases { margin-top: 18px; color: var(--muted); font-size: 13px; }
.knowledge-source { border-top: 1px solid var(--line); padding-top: 14px; }
.knowledge-source p { margin-bottom: 0; }

.knowledge-source > summary::after, .knowledge-aliases > summary::after { content: "+"; margin-left: .5em; }
.knowledge-source[open] > summary::after, .knowledge-aliases[open] > summary::after { content: "−"; }
