:root {
  color-scheme: light;
  font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  --ink: #0a2348;
  --muted: #536985;
  --line: rgba(25, 99, 215, 0.16);
  --line-strong: rgba(0, 109, 255, 0.32);
  --surface: #f8fbff;
  --surface-soft: #eef6ff;
  --panel: #ffffff;
  --accent: #006dff;
  --accent-strong: #0054e9;
  --accent-soft: #dff2ff;
  --cyan: #19d8ff;
  --navy: #071b46;
  --navy-deep: #031c42;
  --warn: #9a5b00;
  --error: #8a1f2d;
  --shadow-soft: 0 16px 34px rgba(29, 82, 145, 0.1);
  --shadow-tight: 0 10px 22px rgba(13, 63, 128, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
textarea:disabled,
input:disabled,
select:disabled {
  cursor: wait;
  opacity: 0.68;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-width: 0;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  max-width: 100vw;
  padding: 24px;
  background:
    linear-gradient(180deg, #05255d 0%, #031c42 100%);
  color: #f4f9ff;
  border-right: 1px solid rgba(25, 216, 255, 0.12);
  box-shadow: 18px 0 42px rgba(4, 22, 56, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  padding: 4px;
  border: 1px solid rgba(225, 237, 252, 0.92);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 26px rgba(2, 20, 50, 0.22);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong {
  color: #ffffff;
}

.brand span:not(.brand-mark),
.session span {
  display: block;
  color: rgba(237, 246, 255, 0.72);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.nav-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.nav-group-label {
  margin: 0;
  color: rgba(237, 246, 255, 0.52);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-item,
.ghost {
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(237, 246, 255, 0.76);
  text-align: left;
}

.nav-item.active,
.nav-item:hover,
.ghost:hover {
  border-color: rgba(25, 216, 255, 0.2);
  background: rgba(25, 216, 255, 0.12);
  color: #fff;
}

.nav-item-with-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.security-alert-badge {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  padding: 0 6px;
  border: 1px solid rgba(255, 194, 194, 0.72);
  border-radius: 999px;
  background: #c62828;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.session {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.language-control {
  display: grid;
  gap: 5px;
  width: 100%;
}

.language-control > span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  font-weight: 700;
}

.language-control select {
  width: 100%;
  min-height: 38px;
  padding: 7px 30px 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #fff;
  background-color: rgba(255, 255, 255, 0.08);
  color-scheme: dark;
}

.language-control select:focus-visible {
  outline: 2px solid #77a8ff;
  outline-offset: 2px;
}

.language-control select:focus,
.language-control select:focus-visible {
  border-color: rgba(119, 168, 255, 0.82);
  color: #ffffff;
  background: #173462;
  box-shadow: 0 0 0 3px rgba(36, 104, 237, 0.22);
}

.language-control select option {
  color: #0a2348;
  background: #ffffff;
}

.panel,
.workspace {
  min-width: 0;
  max-width: 100vw;
  padding: 28px;
}

.workspace {
  height: 100vh;
  overflow: auto;
}

.auth-panel {
  display: grid;
  place-items: center;
  min-width: 0;
}

.auth-box {
  width: 100%;
  max-width: 420px;
  min-width: 0;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  margin-bottom: 18px;
  font-size: 34px;
}

h2 {
  font-size: 24px;
}

h3 {
  margin-bottom: 14px;
  font-size: 17px;
}

.stack {
  display: grid;
  gap: 14px;
}

.stack.compact {
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--line-strong);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 109, 255, 0.12);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.autofill-decoy {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.input-with-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

.page-filter {
  margin-bottom: 14px;
}

.pagination-row {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.pagination-row span {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.compact-pagination {
  margin-top: 10px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary,
.secondary {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 700;
}

.primary {
  border: 1px solid rgba(73, 143, 255, 0.42);
  background: linear-gradient(135deg, #0054e9 0%, #087bff 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(0, 109, 255, 0.18);
}

.primary:hover {
  background: linear-gradient(135deg, #0049cc 0%, #006dff 100%);
}

.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  color: #0f4f99;
}

.secondary:hover {
  border-color: var(--line-strong);
  background: #eef6ff;
}

.secondary.danger {
  border-color: rgba(211, 47, 47, 0.34);
  background: #fff5f5;
  color: #b42318;
}

.secondary.danger:hover {
  border-color: rgba(211, 47, 47, 0.58);
  background: #fee7e7;
  color: #8f1f16;
}

.message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--error);
}

.inline-alert,
.form-status {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.inline-alert:empty,
.form-status:empty {
  display: none;
}

.inline-alert.warning,
.form-status.warning,
.form-status.error {
  border-color: rgba(154, 91, 0, 0.24);
  background: #fff8e8;
  color: var(--warn);
}

.inline-alert.success,
.form-status.success {
  border-color: rgba(22, 101, 52, 0.24);
  background: #ecfdf3;
  color: #166534;
}

.security-alert-panel {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid rgba(198, 40, 40, 0.32);
  border-left: 4px solid #c62828;
  border-radius: 8px;
  background: #fff6f6;
  color: #671515;
}

.security-alert-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.security-alert-heading h3 {
  margin: 2px 0 0;
}

.security-alert-label {
  margin: 0;
  color: #a51f1f;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.security-alert-counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.security-alert-counts span {
  min-width: 112px;
  padding: 8px 10px;
  border: 1px solid rgba(198, 40, 40, 0.2);
  border-radius: 8px;
  background: #ffffff;
  color: #7a2020;
  font-size: 12px;
  text-align: center;
}

.security-alert-counts strong {
  display: block;
  color: #a51f1f;
  font-size: 20px;
}

.security-alert-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.security-alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(198, 40, 40, 0.14);
  font-size: 13px;
}

.security-alert-item span {
  color: #8a3a3a;
  text-align: right;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.view[hidden],
.admin-only[hidden],
[hidden] {
  display: none !important;
}

#chatView {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.history-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  height: calc(100vh - 112px);
}

.history-list-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}

.conversation-list,
.conversation,
.admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-tight);
}

.conversation-list {
  overflow: auto;
  min-height: 0;
  padding: 8px;
}

.conversation-item {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.conversation-item.active,
.conversation-item:hover {
  background: var(--surface-soft);
  color: #075ecf;
}

.conversation-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.conversation {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
}

.chat-layout .conversation {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto auto;
}

.history-title {
  max-height: 112px;
  overflow: auto;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

.history-conversation {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.chat-layout .messages {
  min-height: 0;
}

.history-conversation .messages {
  overflow: auto;
}

.bubble {
  display: grid;
  gap: 8px;
  max-width: min(920px, 96%);
  padding: 12px 14px;
  border-radius: 8px;
  background: #f2f7fc;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.bubble-text {
  display: grid;
  gap: 10px;
  white-space: normal;
}

.message-section {
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border-left: 3px solid #2f6ce5;
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, 0.68);
}

.message-section + .message-section {
  margin-top: 2px;
}

.bubble.user .message-section {
  border-left-color: rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.1);
}

.bubble-text p,
.bubble-text ul,
.bubble-text ol {
  margin: 0;
}

.bubble-text ul,
.bubble-text ol {
  display: grid;
  gap: 6px;
  padding-left: 22px;
}

.bubble-text li {
  padding-left: 2px;
}

.bubble-text li::marker {
  color: #2563eb;
  font-weight: 850;
}

.bubble.user .bubble-text li::marker {
  color: #ffffff;
}

.bubble-text code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(4, 33, 74, 0.08);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.94em;
}

.message-heading {
  margin: 0;
  color: #075ecf;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.25;
  text-transform: none;
}

.bubble.user .message-heading {
  color: #ffffff;
}

.bubble-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}

.message-copy-btn {
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.84);
  color: #0f4f99;
  font-size: 12px;
  font-weight: 800;
}

.message-copy-btn:hover,
.message-copy-btn:focus-visible {
  border-color: var(--line-strong);
  background: #ffffff;
}

.bubble.user .message-copy-btn {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.message-images {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.message-documents,
.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.message-documents span,
.message-files span,
.message-files a {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  max-width: 260px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-files a {
  text-decoration: none;
}

.message-files a:hover,
.message-files a:focus-visible {
  border-color: var(--line-strong);
  background: #ffffff;
  color: #075ecf;
}

.message-files small {
  overflow: hidden;
  color: inherit;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.86;
  text-overflow: ellipsis;
}

.bubble.assistant .message-documents span,
.bubble.assistant .message-files span,
.bubble.assistant .message-files a {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.message-image-link {
  display: block;
  width: fit-content;
  max-width: 100%;
  border-radius: 8px;
}

.message-image-link:focus-visible {
  outline: 3px solid rgba(0, 101, 255, 0.25);
  outline-offset: 2px;
}

.message-image {
  max-width: min(360px, 100%);
  max-height: 320px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
}

.bubble.assistant .message-image {
  border-color: var(--line);
}

.bubble.assistant {
  align-self: flex-start;
  background: #f3f9ff;
  border: 1px solid rgba(0, 109, 255, 0.14);
  box-shadow: 0 8px 24px rgba(11, 68, 133, 0.05);
}

.bubble.thinking {
  color: #075ecf;
}

.bubble.thinking::after {
  content: "";
  display: inline-block;
  width: 1.4em;
  text-align: left;
  animation: thinkingDots 1.1s steps(4, end) infinite;
}

.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0054e9 0%, #087bff 100%);
  color: #fff;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  min-height: 52px;
  max-height: 220px;
  resize: none;
  line-height: 1.45;
  overflow-y: hidden;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  justify-content: flex-end;
}

.composer-actions > button,
.composer-actions > label {
  min-height: 44px;
}

.image-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

.image-upload-button.disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.image-preview,
.file-preview {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0 14px 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 13px;
}

.image-preview img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: #ffffff;
}

.image-preview strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.file-preview {
  grid-template-columns: minmax(0, 1fr);
}

.file-preview strong,
.file-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-metrics {
  min-height: 28px;
  padding: 0 14px 12px;
  color: var(--muted);
  font-size: 12px;
}

.starter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px;
}

.starter {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #0f4f99;
  font-size: 13px;
  font-weight: 700;
}

.starter:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.context-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.user-list-panel,
.user-detail-panel {
  min-width: 0;
}

.admin-section {
  padding: 18px;
}

.document-file-field {
  position: relative;
  min-width: 0;
}

.document-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.document-file-drop {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.document-file-input:focus + .document-file-drop,
.document-file-drop:hover {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(0, 109, 255, 0.08);
}

.document-file-action {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.document-file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-file-name.is-empty {
  color: var(--muted);
  font-weight: 600;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.user-filter-row {
  margin-top: 16px;
}

.user-directory-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.user-directory-tab {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.user-directory-tab:hover,
.user-directory-tab:focus-visible {
  background: var(--surface-soft);
  color: var(--ink);
}

.user-directory-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.user-directory-tab span {
  display: inline-flex;
  min-width: 24px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 6px;
  background: #edf2f9;
  color: var(--ink);
  font-size: 11px;
}

.list-info {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.list-item,
.metric {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.user-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.summary-card.active,
.user-card.active {
  border-color: var(--line-strong);
  background: #f8fbff;
}

.user-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.summary-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.document-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.document-item small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.document-context {
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.document-context strong {
  color: var(--accent-strong);
}

.document-terms {
  color: var(--muted);
}

.document-error {
  color: var(--error);
}

.document-note {
  color: #35506f;
  line-height: 1.45;
}

.document-note strong {
  margin-right: 4px;
  color: #075ecf;
}

.admin-list-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  align-items: center;
}

.status-pill {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.success {
  border-color: rgba(22, 101, 52, 0.24);
  background: #ecfdf3;
  color: #166534;
}

.status-pill.muted {
  background: var(--surface-soft);
}

.user-detail-empty {
  margin-top: 14px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
}

.user-panel {
  margin-top: 14px;
}

.account-state-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.account-state-panel > div {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.account-state-panel strong {
  color: var(--ink);
}

.account-state-panel span:not(.status-pill),
.account-state-panel p {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.account-state-panel p {
  margin: 0;
}

.section-divider {
  height: 1px;
  margin: 8px 0;
  background: var(--line);
}

.rag-library-heading {
  margin-top: 2px;
}

.compact-file-drop {
  min-height: 88px;
}

.rag-library-actions {
  align-items: center;
}

.rag-library-actions .form-note {
  margin: 0;
}

.rag-library-list {
  max-height: 520px;
  overflow-y: auto;
}

.rag-document-item > div:first-child {
  min-width: 0;
}

.rag-global-intro {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: #f2f7ff;
}

.rag-global-intro p {
  max-width: 820px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.rag-global-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.rag-global-summary .metric {
  min-width: 0;
  box-shadow: var(--shadow-tight);
}

.rag-global-summary .metric strong {
  overflow-wrap: anywhere;
}

.rag-inspector {
  margin-bottom: 18px;
}

.rag-inspector-heading {
  align-items: flex-start;
}

.rag-inspector-controls {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(190px, 1fr) minmax(140px, 0.55fr) minmax(140px, 0.55fr);
  gap: 12px;
}

.rag-inspector-controls label,
.rag-inspector form > label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rag-inspector-query {
  min-height: 96px;
  resize: vertical;
}

.rag-inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rag-inspector-actions .form-note {
  flex: 1 1 260px;
  margin: 0 0 0 4px;
}

.rag-map-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 0.34fr);
  min-height: 440px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.rag-map-visual {
  min-width: 0;
  padding: 16px 18px 14px 0;
  border-right: 1px solid var(--line);
}

.rag-map-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.rag-map-toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.rag-map-toolbar-actions .compact-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.rag-map-toolbar-actions .compact-button.is-playing .button-icon {
  animation: ragMapReplayPulse 720ms ease-in-out infinite alternate;
}

.rag-map-toolbar h4,
.rag-map-details h4 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.rag-map-toolbar p,
.rag-map-details > p:not(.eyebrow) {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.rag-map-canvas-wrap {
  position: relative;
  width: 100%;
  height: 350px;
  overflow: hidden;
  border: 1px solid #d8e2f1;
  border-radius: 7px;
  background: #07142d;
  box-shadow: inset 0 0 0 1px rgba(120, 158, 222, 0.06), 0 10px 26px rgba(12, 31, 65, 0.08);
}

.rag-map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
}

.rag-map-canvas:focus-visible {
  outline: 3px solid rgba(87, 239, 207, 0.58);
  outline-offset: -3px;
}

.rag-map-flow {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 1;
  display: flex;
  gap: 18px;
  align-items: center;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border: 1px solid rgba(125, 159, 219, 0.2);
  border-radius: 6px;
  background: rgba(6, 17, 40, 0.84);
  color: #8093b5;
  font-size: 10px;
  font-weight: 800;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.rag-map-flow span {
  position: relative;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  transition: color 180ms ease, opacity 180ms ease;
}

.rag-map-flow span:not(:last-child)::after {
  position: absolute;
  top: 50%;
  left: calc(100% + 6px);
  width: 6px;
  height: 1px;
  background: rgba(127, 154, 202, 0.3);
  content: "";
}

.rag-map-flow i {
  width: 7px;
  height: 7px;
  border: 1px solid rgba(148, 172, 215, 0.65);
  border-radius: 50%;
  background: #243556;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.rag-map-flow .is-active {
  color: #f4f8ff;
}

.rag-map-flow .is-active i {
  border-color: #6ff0d1;
  background: #3bd0b3;
  box-shadow: 0 0 11px rgba(70, 232, 199, 0.9);
  animation: ragMapStagePulse 620ms ease-in-out infinite alternate;
}

.rag-map-flow .is-complete {
  color: #a9bedf;
}

.rag-map-flow .is-complete i {
  border-color: #72a3ff;
  background: #4f86ff;
  box-shadow: 0 0 7px rgba(79, 134, 255, 0.65);
}

.rag-map-flow .is-waiting {
  opacity: 0.45;
}

@keyframes ragMapStagePulse {
  from { transform: scale(0.82); }
  to { transform: scale(1.18); }
}

@keyframes ragMapReplayPulse {
  from { opacity: 0.55; transform: scale(0.88); }
  to { opacity: 1; transform: scale(1.05); }
}

.rag-map-tooltip {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 3px;
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid #cad7ea;
  border-radius: 6px;
  background: #10244f;
  box-shadow: var(--shadow-tight);
  color: #ffffff;
  font-size: 11px;
  pointer-events: none;
}

.rag-map-tooltip[hidden] {
  display: none;
}

.rag-map-tooltip strong {
  overflow-wrap: anywhere;
}

.rag-map-tooltip span {
  color: #d9e5fb;
}

.rag-map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

.rag-map-empty[hidden] {
  display: none;
}

.rag-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.rag-map-legend span,
.rag-map-scope-breakdown span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.rag-map-legend i,
.rag-map-scope-breakdown i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9da9bb;
}

.rag-map-legend .is-global,
.rag-map-scope-breakdown .is-global { background: #2468e8; }
.rag-map-legend .is-team,
.rag-map-scope-breakdown .is-team { background: #0b9187; }
.rag-map-legend .is-profile,
.rag-map-scope-breakdown .is-profile { background: #d14d62; }
.rag-map-legend .is-selected { background: #159466; }
.rag-map-legend .is-candidate { background: #cc8b1f; }

.rag-map-details {
  min-width: 0;
  padding: 18px 0 18px 18px;
}

.rag-map-details h4 {
  overflow-wrap: anywhere;
  font-size: 16px;
}

.rag-map-details .eyebrow {
  margin-bottom: 5px;
}

.rag-map-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 18px 0 14px;
  border-top: 1px solid var(--line);
}

.rag-map-facts > div {
  min-width: 0;
  padding: 10px 8px 8px 0;
  border-bottom: 1px solid var(--line);
}

.rag-map-facts dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.rag-map-facts dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.rag-map-scope-breakdown,
.rag-map-modalities {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.rag-map-scope-breakdown span,
.rag-map-modalities span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.rag-map-scope-breakdown span {
  justify-content: flex-start;
}

.rag-map-scope-breakdown strong {
  margin-left: auto;
  color: var(--ink);
}

.rag-map-modalities {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rag-map-modalities span {
  display: grid;
  gap: 2px;
  padding-left: 8px;
  border-left: 2px solid var(--line-strong);
}

.rag-map-modalities strong {
  color: var(--ink);
  font-size: 15px;
}

.rag-map-retrieval-note {
  display: grid;
  gap: 3px;
  margin-top: 16px;
  padding: 11px 12px;
  border-left: 4px solid #cc8b1f;
  background: #fff8e9;
}

.rag-map-retrieval-note.is-selected {
  border-left-color: #159466;
  background: #effaf4;
}

.rag-map-retrieval-note span,
.rag-map-retrieval-note small {
  color: var(--muted);
  font-size: 11px;
}

.rag-inspector-summary {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.rag-inspector-summary[hidden] {
  display: none;
}

.rag-inspector-decision {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border-left: 4px solid #8ca0bd;
  background: var(--surface-soft);
}

.rag-inspector-decision.is-rag {
  border-left-color: #16824b;
  background: #effaf4;
}

.rag-inspector-decision span,
.rag-inspector-summary > p {
  color: var(--muted);
  font-size: 12px;
}

.rag-inspector-summary > p {
  margin: 0;
}

.rag-inspector-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.rag-inspector-metrics > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 10px;
  border-left: 2px solid var(--line-strong);
}

.rag-inspector-metrics strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 18px;
}

.rag-inspector-metrics span {
  color: var(--muted);
  font-size: 11px;
}

.rag-inspector-results {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.rag-inspector-result {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid #aab7ca;
  border-radius: 7px;
  background: #ffffff;
}

.rag-inspector-result.is-selected {
  border-left-color: #16824b;
}

.rag-inspector-result.is-discarded {
  background: #fafbfd;
}

.rag-inspector-result-head,
.rag-inspector-result-head > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rag-inspector-result-head {
  justify-content: space-between;
}

.rag-inspector-result-head > div {
  min-width: 0;
}

.rag-inspector-result-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rag-rank {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.rag-scope-label {
  color: var(--muted);
  font-size: 12px;
}

.rag-score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.rag-score {
  display: grid;
  gap: 5px;
}

.rag-score > span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.rag-score > span strong {
  color: var(--ink);
}

.rag-score > span b {
  font-variant-numeric: tabular-nums;
}

.rag-score > i {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #e8eef7;
}

.rag-score > i > u {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  text-decoration: none;
}

.rag-chunk-preview {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.rag-chunk-details {
  color: var(--accent-strong);
  font-size: 12px;
}

.rag-chunk-details summary {
  cursor: pointer;
  font-weight: 800;
}

.rag-chunk-details pre {
  max-height: 360px;
  margin: 10px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.rag-global-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.6fr);
  gap: 18px;
  align-items: start;
}

.rag-global-upload {
  position: sticky;
  top: 0;
}

.rag-global-file-drop {
  display: grid;
  gap: 8px;
  min-height: 150px;
  align-content: center;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
  text-align: center;
}

.rag-global-file-drop:hover,
.rag-global-file-drop:focus-within {
  border-color: var(--accent);
  background: #f2f7ff;
  box-shadow: 0 0 0 3px rgba(0, 109, 255, 0.08);
}

.rag-global-file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
}

.rag-global-file-drop > span {
  overflow-wrap: anywhere;
  color: var(--accent-strong);
  font-weight: 800;
}

.rag-global-file-drop > span.is-empty {
  color: var(--ink);
}

.rag-global-file-drop small,
.rag-upload-progress {
  color: var(--muted);
  font-size: 12px;
}

.rag-upload-progress {
  min-height: 20px;
  margin: 0;
}

.rag-processing-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(780px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(9, 30, 66, 0.24);
}

.rag-processing-dialog::backdrop {
  background: rgba(9, 25, 55, 0.56);
  backdrop-filter: blur(2px);
}

.rag-processing-shell {
  display: grid;
  max-height: min(780px, calc(100vh - 32px));
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.rag-processing-header {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.rag-processing-heading {
  display: flex;
  min-width: 0;
  gap: 14px;
  align-items: center;
}

.rag-processing-heading h2,
.rag-processing-heading p {
  margin: 0;
}

.rag-processing-heading h2 {
  margin-top: 2px;
  font-size: 20px;
}

.rag-processing-heading p:not(.eyebrow) {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.rag-processing-mark {
  display: inline-flex;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid #c9dcff;
  border-radius: 8px;
  background: #edf5ff;
  color: var(--accent);
}

.rag-processing-mark svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  animation: rag-processing-spin 1.2s linear infinite;
}

.rag-processing-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.rag-processing-summary > div {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.rag-processing-summary > div:last-child {
  border-right: 0;
}

.rag-processing-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.rag-processing-summary strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.rag-processing-jobs {
  min-height: 170px;
  padding: 0 24px;
  overflow-y: auto;
}

.rag-processing-job {
  display: grid;
  gap: 10px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.rag-processing-job:last-child {
  border-bottom: 0;
}

.rag-processing-job-heading,
.rag-processing-job-facts {
  display: flex;
  min-width: 0;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.rag-processing-job-heading > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.rag-processing-job-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rag-processing-job-heading span,
.rag-processing-job-facts {
  color: var(--muted);
  font-size: 12px;
}

.rag-processing-job-heading b {
  color: var(--accent-strong);
  font-size: 14px;
}

.rag-processing-track {
  height: 9px;
  overflow: hidden;
  border-radius: 5px;
  background: #e3eaf5;
}

.rag-processing-track > i {
  position: relative;
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 350ms ease;
}

.rag-processing-track > i::after {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.28);
  content: "";
  transform: translateX(-100%);
  animation: rag-processing-sweep 1.5s ease-in-out infinite;
}

.rag-processing-job.has-error .rag-processing-track > i {
  background: var(--danger);
}

.rag-processing-job .document-error {
  margin: 0;
}

.rag-processing-footer {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.rag-processing-footer p {
  max-width: 500px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rag-processing-footer button {
  flex: 0 0 auto;
}

@keyframes rag-processing-spin {
  to { transform: rotate(360deg); }
}

@keyframes rag-processing-sweep {
  50%, 100% { transform: translateX(100%); }
}

.rag-global-catalog {
  min-width: 0;
}

.rag-global-filters {
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px);
}

.rag-global-document-list {
  gap: 10px;
}

.rag-global-document {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.rag-document-main {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.rag-file-type {
  display: inline-flex;
  width: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 1px solid #cfe0fb;
  border-radius: 7px;
  background: #edf5ff;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-align: center;
}

.rag-document-copy,
.rag-document-title-row {
  min-width: 0;
}

.rag-document-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rag-document-title-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rag-document-copy > span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.rag-document-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 8px;
  color: var(--ink);
  font-size: 12px;
}

.rag-document-facts span:not(:last-child)::after {
  margin-left: 12px;
  color: var(--line-strong);
  content: "·";
}

.prompt-info {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: #075ecf;
  font-size: 13px;
}

.editor-meta {
  display: grid;
  gap: 4px;
  margin-top: -4px;
  color: var(--muted);
  font-size: 12px;
}

.editor-meta strong,
.editor-meta .warning {
  color: var(--warn);
}

.prompt-version {
  width: 100%;
  color: var(--ink);
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.inline-action {
  margin-top: 8px;
  margin-right: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #0f4f99;
  font-size: 13px;
}

.inline-action.danger {
  color: var(--error);
}

.reset-form {
  margin-top: 12px;
}

.form-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.permissions-list {
  display: grid;
  gap: 8px;
}

.template-selection-fieldset {
  min-width: 0;
  margin: 6px 0 0;
  padding: 16px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.template-selection-fieldset legend {
  padding: 0;
  color: var(--ink);
  font-weight: 800;
}

.template-selection-list {
  display: grid;
  max-height: 340px;
  margin-top: 10px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.template-selection-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.template-selection-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.template-selection-row strong,
.template-selection-row small {
  display: block;
}

.template-selection-row small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

#profileTemplateFormTitle:focus {
  outline: none;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.permission-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.permission-state {
  font-weight: 700;
}

.readonly-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.list-item span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  color: var(--muted);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #031c42;
  color: #fff;
  box-shadow: 0 16px 40px rgba(3, 28, 66, 0.24);
}

@keyframes thinkingDots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

@media (max-width: 1180px) {
  .rag-global-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .rag-global-grid {
    grid-template-columns: 1fr;
  }

  .rag-global-upload {
    position: static;
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: start;
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
  }

  .workspace {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  #chatView {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .sidebar {
    align-self: start;
    height: auto;
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 14px;
    padding: 14px 18px;
  }

  .brand .brand-mark {
    width: 48px;
    height: 48px;
    padding: 4px;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  }

  .session {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-top: 0;
    align-items: center;
  }

  .chat-layout,
  .history-layout,
  .admin-grid,
  .summary-card,
  .user-card {
    grid-template-columns: 1fr;
    height: auto;
  }

  .section-heading {
    display: grid;
  }

  .admin-list-actions {
    justify-content: flex-start;
  }

  .conversation {
    min-height: 460px;
  }

  .conversation-list {
    max-height: 300px;
  }

  .chat-layout .conversation {
    order: -1;
  }

  .chat-layout .conversation-list {
    max-height: 240px;
  }
}

@media (max-width: 640px) {
  .rag-global-intro,
  .rag-global-document {
    display: grid;
  }

  .rag-global-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rag-global-filters,
  .rag-document-main {
    grid-template-columns: 1fr;
  }

  .rag-global-document .admin-list-actions {
    justify-content: stretch;
  }

  .rag-global-document .admin-list-actions button {
    flex: 1 1 auto;
  }

  .panel,
  .workspace {
    padding: 18px;
  }

  .auth-box {
    width: min(100%, 340px);
    max-width: 100%;
    padding: 24px;
    margin-inline: 0;
  }

  .auth-panel {
    place-items: start;
    justify-items: start;
  }

  .sidebar {
    padding: 12px;
  }

  .user-directory-tab {
    flex-direction: column;
    gap: 2px;
    padding-inline: 3px;
    font-size: 11px;
  }

  .user-directory-tab span {
    min-width: 20px;
    min-height: 20px;
    padding: 1px 4px;
    font-size: 10px;
  }

  .user-card > div:first-child,
  .user-card > div:first-child span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .brand {
    gap: 10px;
  }

  .nav {
    display: flex;
    gap: 8px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-group {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
  }

  .nav-group-label {
    display: none;
  }

  .nav-item,
  .ghost {
    flex: 0 0 auto;
    min-width: 108px;
    min-height: 38px;
    padding: 8px 10px;
  }

  .toolbar,
  .composer {
    grid-template-columns: 1fr;
  }

  .security-alert-heading,
  .security-alert-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .security-alert-counts {
    width: 100%;
    justify-content: stretch;
  }

  .security-alert-counts span {
    flex: 1 1 120px;
  }

  .security-alert-item span {
    text-align: left;
  }

  .composer-actions {
    justify-content: stretch;
  }

  .composer-actions > button,
  .composer-actions > label {
    flex: 1 1 140px;
  }

  .chat-layout .conversation {
    grid-template-rows: minmax(160px, 1fr) auto auto auto auto;
    height: 520px;
    min-height: 0;
  }

  .toolbar {
    display: grid;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .permission-row {
    grid-template-columns: 1fr;
  }

  .prompt-version,
  .pagination-row {
    grid-template-columns: 1fr;
  }

  .prompt-actions {
    justify-content: flex-start;
  }
}

/* FlexoAI product interface */
:root {
  font-family: "Inter", "Aptos", "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  --ink: #12203a;
  --muted: #657189;
  --line: #dfe5ef;
  --line-strong: #aebfda;
  --surface: #f5f7fb;
  --surface-soft: #f0f4f9;
  --panel: #ffffff;
  --accent: #2468ed;
  --accent-strong: #1956c8;
  --accent-soft: #eaf1ff;
  --cyan: #1ca6b4;
  --coral: #dc5c5c;
  --navy: #0d2557;
  --navy-deep: #091b42;
  --warn: #8a5807;
  --error: #a72d37;
  --shadow-soft: 0 20px 46px rgba(28, 46, 82, 0.09);
  --shadow-tight: 0 7px 20px rgba(28, 46, 82, 0.07);
  --ease-out: cubic-bezier(0.2, 0.75, 0.25, 1);
}

html {
  background: var(--surface);
}

body {
  background: var(--surface);
}

::selection {
  background: #cfe0ff;
  color: var(--ink);
}

.sr-only {
  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;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 9px 12px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--navy-deep);
  font-weight: 800;
  transform: translateY(-150%);
  transition: transform 160ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  grid-template-columns: 244px minmax(0, 1fr);
  background: var(--surface);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  gap: 22px;
  padding: 20px 14px 16px;
  overflow: hidden;
  background: var(--navy-deep);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.brand {
  flex: 0 0 auto;
  gap: 10px;
  padding: 0 6px;
}

.brand .brand-mark {
  width: 44px;
  height: 44px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: none;
}

.brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.brand span:not(.brand-mark) {
  margin-top: 3px;
  color: rgba(239, 245, 255, 0.62);
  font-size: 11px;
}

.nav {
  flex: 1 1 auto;
  min-height: 0;
  gap: 13px;
  align-content: start;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.nav-group {
  gap: 3px;
  align-content: start;
  align-self: start;
}

.nav-group-label {
  padding: 0 10px;
  color: rgba(239, 245, 255, 0.43);
  font-size: 10px;
}

.nav-item,
.ghost {
  position: relative;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: rgba(244, 248, 255, 0.76);
  font-size: 13px;
  font-weight: 650;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

.nav-item::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 9px;
  border-radius: 2px;
  background: rgba(239, 245, 255, 0.34);
  vertical-align: 2px;
}

.nav-item.active,
.nav-item:hover,
.ghost:hover {
  border-color: rgba(100, 163, 255, 0.24);
  background: rgba(53, 116, 224, 0.2);
  color: #ffffff;
}

.nav-item.active::before {
  background: #69c3d0;
}

.nav-item-with-badge {
  justify-content: flex-start;
}

.nav-item-with-badge .security-alert-badge {
  margin-left: auto;
}

.session {
  display: grid;
  gap: 10px;
  padding: 14px 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  margin-top: 0;
  flex: 0 0 auto;
}

.session-profile {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: 0;
}

.session .session-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: #2468ed;
  color: #ffffff;
  font-size: 11px;
  font-weight: 850;
}

.session .session-copy {
  display: block;
  min-width: 0;
}

.session-copy strong,
.session-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-copy strong {
  color: #ffffff;
  font-size: 12px;
}

.session-copy small {
  margin-top: 2px;
  color: rgba(239, 245, 255, 0.54);
  font-size: 10px;
}

.session .ghost {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
  font-size: 12px;
  text-align: center;
}

.session .ghost:hover {
  border-color: rgba(119, 168, 255, 0.74);
  background: rgba(53, 116, 224, 0.28);
}

.panel,
.workspace {
  padding: 28px 32px;
}

.workspace {
  height: 100vh;
  overflow: auto;
  background: var(--surface);
}

.view.active {
  animation: viewEnter 180ms var(--ease-out) both;
}

.auth-box {
  max-width: 430px;
  padding: 30px;
  border-color: var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

.page-lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

input,
textarea,
select {
  border-color: var(--line);
  border-radius: 7px;
  background: #ffffff;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background 160ms var(--ease-out);
}

input:hover,
textarea:hover,
select:hover {
  border-color: #c6d0df;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #7da4ef;
  box-shadow: 0 0 0 3px rgba(36, 104, 237, 0.11);
}

button:focus-visible,
.image-upload-button:focus-visible,
.document-file-drop:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid rgba(36, 104, 237, 0.24);
  outline-offset: 2px;
}

button:disabled,
textarea:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.primary,
.secondary {
  min-height: 40px;
  border-radius: 7px;
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), transform 160ms var(--ease-out), opacity 160ms var(--ease-out);
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 7px 16px rgba(36, 104, 237, 0.18);
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: #31527f;
}

.secondary:hover {
  border-color: #b8c5d8;
  background: var(--surface-soft);
}

button:active:not(:disabled),
.image-upload-button:active:not(.disabled) {
  transform: translateY(1px);
}

.toolbar {
  min-height: 58px;
  margin-bottom: 16px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#chatView .toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

#chatView .toolbar > div:first-child {
  min-width: 0;
}

#chatView .toolbar-actions {
  flex-wrap: nowrap;
}

.home-view {
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
}

.home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.home-query-band {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(380px, 1.25fr);
  gap: 34px;
  align-items: end;
  min-height: 210px;
  padding: 30px;
  border: 1px solid #183d78;
  border-radius: 8px;
  background: #0f2e63;
  color: #ffffff;
  box-shadow: 0 16px 32px rgba(15, 46, 99, 0.14);
}

.home-query-band .eyebrow {
  color: #7fd1da;
}

.home-query-band h2 {
  max-width: 540px;
  color: #ffffff;
  font-size: 26px;
}

.home-query-copy > p:last-child {
  max-width: 480px;
  margin: 10px 0 0;
  color: rgba(244, 248, 255, 0.72);
  font-size: 14px;
  line-height: 1.55;
}

.home-query-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.home-query-form textarea {
  min-height: 64px;
  max-height: 160px;
  resize: vertical;
  border-color: rgba(255, 255, 255, 0.24);
  background: #ffffff;
  color: var(--ink);
}

.home-query-form .primary {
  min-height: 64px;
  padding-inline: 22px;
  border-color: #ffffff;
  background: #ffffff;
  color: #174fae;
  box-shadow: none;
}

.home-query-form .primary:hover {
  border-color: #e8eef8;
  background: #edf3fd;
}

.home-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 34px;
  margin-top: 32px;
}

.home-section {
  min-width: 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.compact-heading {
  margin-bottom: 8px;
}

.compact-heading h2 {
  font-size: 18px;
}

.text-action {
  min-height: 34px;
  padding: 0 4px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.text-action:hover {
  color: var(--accent-strong);
}

.home-activity-list,
.quick-action-list {
  display: grid;
}

.home-activity-item,
.quick-action {
  width: 100%;
  min-width: 0;
  min-height: 68px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background 160ms var(--ease-out), padding 160ms var(--ease-out), transform 160ms var(--ease-out);
}

.home-activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.home-activity-item:hover,
.quick-action:hover {
  padding-inline: 10px;
  background: #ffffff;
}

.home-activity-item strong,
.home-activity-item small,
.quick-action strong,
.quick-action span {
  display: block;
}

.home-activity-item strong,
.quick-action strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-activity-item small,
.quick-action span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.home-activity-action {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.quick-action {
  position: relative;
  padding-left: 16px;
}

.quick-action::before {
  content: "";
  position: absolute;
  top: 17px;
  bottom: 17px;
  left: 2px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.quick-action:nth-child(2)::before {
  background: var(--cyan);
}

.quick-action:nth-child(3)::before {
  background: var(--coral);
}

.home-empty-state {
  margin: 0;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

#chatView {
  grid-template-rows: auto minmax(0, 1fr);
}

.chat-layout {
  grid-template-columns: 258px minmax(0, 1fr);
  gap: 12px;
}

.conversation-panel,
.conversation,
.admin-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-tight);
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.conversation-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 9px;
  color: var(--ink);
  font-size: 12px;
}

.conversation-panel-heading > span {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.conversation-search {
  padding: 0 10px 9px;
}

.conversation-search input {
  min-height: 36px;
  padding: 8px 10px;
  background: var(--surface);
  font-size: 12px;
}

.conversation-list {
  min-height: 0;
  padding: 4px 7px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.conversation-item {
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: color 150ms var(--ease-out), background 150ms var(--ease-out), border-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}

.conversation-item strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.conversation-item.active,
.conversation-item:hover {
  border-color: #d8e3f5;
  background: var(--accent-soft);
  color: #194fba;
}

.conversation {
  box-shadow: none;
}

.chat-layout .conversation {
  grid-template-rows: minmax(0, 1fr) auto auto auto auto;
}

.messages {
  gap: 16px;
  padding: 22px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.bubble {
  max-width: min(860px, 88%);
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.58;
  animation: messageEnter 190ms var(--ease-out) both;
}

.bubble.assistant {
  border-color: var(--line);
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(25, 47, 86, 0.05);
}

.bubble.user {
  max-width: min(760px, 76%);
  border: 1px solid #2468ed;
  background: #2468ed;
  box-shadow: none;
}

.bubble-text {
  gap: 12px;
}

.message-section {
  gap: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.message-section + .message-section {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid #e7ebf2;
}

.bubble.user .message-section {
  border-left: 0;
  background: transparent;
}

.message-heading {
  color: #194fba;
  font-size: 13px;
  line-height: 1.35;
}

.bubble-text ul,
.bubble-text ol {
  gap: 7px;
}

.bubble-text li::marker {
  color: var(--accent);
}

.bubble-text,
.message-section {
  min-width: 0;
}

.message-table-scroll {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid #d8e3f2;
  border-radius: 7px;
  background: #ffffff;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.message-table-scroll:focus-visible {
  outline: 3px solid rgba(36, 104, 237, 0.22);
  outline-offset: 2px;
}

.message-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.message-table th,
.message-table td {
  min-width: 128px;
  max-width: 360px;
  padding: 9px 11px;
  border-right: 1px solid #dfe7f2;
  border-bottom: 1px solid #dfe7f2;
  overflow-wrap: anywhere;
  text-align: left;
  vertical-align: top;
}

.message-table th {
  background: #edf5ff;
  color: #174a8b;
  font-size: 12px;
  font-weight: 850;
}

.message-table tbody tr:nth-child(even) td {
  background: #f8fbff;
}

.message-table th:last-child,
.message-table td:last-child {
  border-right: 0;
}

.message-table tbody tr:last-child td {
  border-bottom: 0;
}

.message-table .align-center {
  text-align: center;
}

.message-table .align-right {
  text-align: right;
}

.bubble.user .message-table-scroll {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.08);
}

.bubble.user .message-table {
  color: #ffffff;
}

.bubble.user .message-table th,
.bubble.user .message-table td {
  border-color: rgba(255, 255, 255, 0.3);
}

.bubble.user .message-table th {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.bubble.user .message-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.08);
}

.message-formula {
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  overflow-x: auto;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: #f2f6fd;
  color: #102a57;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.bubble.user .message-formula {
  border-left-color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.message-divider {
  width: 100%;
  margin: 2px 0;
  border: 0;
  border-top: 1px solid #e2e8f1;
}

.bubble.user .message-divider {
  border-top-color: rgba(255, 255, 255, 0.36);
}

.bubble.streaming .bubble-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 4px;
  background: var(--accent);
  vertical-align: -2px;
  animation: responseCaret 780ms steps(2, end) infinite;
}

.bubble-actions {
  animation: actionEnter 170ms var(--ease-out) both;
}

.message-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface);
  color: #31527f;
  font-size: 11px;
}

.button-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.chat-header-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.chat-action-label-short {
  display: none;
}

.composer {
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  padding: 11px 13px 13px;
  border-top-color: var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -8px 22px rgba(30, 48, 82, 0.04);
}

.composer textarea {
  width: 100%;
  min-height: 50px;
  max-height: 180px;
  padding: 12px 14px;
  border-radius: 8px;
  border-color: #d6deea;
  background: #ffffff;
}

.composer-generation-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.composer-action-selector {
  flex: 1 1 auto;
}

.composer-action-selector,
.composer-format-selector,
.illustrated-presentation-options {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  padding: 3px;
  border: 1px solid #d9e1ec;
  border-radius: 7px;
  background: #f3f6fa;
}

.composer-format-selector {
  flex: 0 0 auto;
  margin-left: auto;
}

.composer-format-selector[hidden] {
  display: none;
}

.illustrated-presentation-options {
  flex: 1 1 100%;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-left: 0;
  padding: 6px 8px;
}

.illustrated-presentation-options[hidden] {
  display: none;
}

.illustrated-presentation-options > small {
  flex: 1 1 260px;
  align-self: center;
  color: #66758c;
  font-size: 10px;
}

.composer-option-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.composer-option-group > span {
  margin-right: 3px;
  color: #4d5e78;
  font-size: 10px;
  font-weight: 750;
}

.composer-option-group button {
  min-height: 28px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #4d5e78;
  font-size: 10px;
  font-weight: 750;
}

.composer-option-group button.active {
  border-color: #b7ccec;
  background: #ffffff;
  color: #1956c8;
}

.composer-action,
.composer-format {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #4d5e78;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.composer-action:hover:not(:disabled),
.composer-format:hover:not(:disabled) {
  border-color: #c8d6ea;
  background: #ffffff;
  color: #183e78;
}

.composer-action.active,
.composer-format.active {
  border-color: #b7ccec;
  background: #ffffff;
  color: #1956c8;
  box-shadow: 0 2px 7px rgba(27, 75, 143, 0.08);
}

.composer-action.unavailable {
  border-color: transparent;
  background: transparent;
  color: #8a94a6;
}

.composer-action:disabled,
.composer-format:disabled {
  cursor: not-allowed;
}

.composer-action-requirement {
  padding: 2px 4px;
  border-radius: 4px;
  background: #e4e8ef;
  color: #68758b;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.2;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.composer-tools,
.composer-submit {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.composer-submit {
  flex: 0 0 auto;
  margin-left: auto;
}

.composer-tool,
.composer-send,
.composer-stop,
.attachment-remove-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.composer-tool {
  min-height: 36px;
  padding: 0 10px;
  border-color: #d9e1ec;
  background: var(--surface);
  color: #31527f;
  font-size: 12px;
}

.composer-tool:hover {
  border-color: #b8c8df;
  background: var(--surface-soft);
}

.composer-send,
.composer-stop {
  min-height: 38px;
  padding: 0 13px;
  font-size: 12px;
}

.composer-send {
  min-width: 102px;
}

.composer-stop {
  min-width: 96px;
  border-color: rgba(198, 40, 40, 0.24);
  background: #fff7f6;
  color: #a12727;
}

.composer[aria-busy="true"] .composer-send-icon {
  animation: skeletonPulse 900ms ease-in-out infinite;
}

.chat-restriction-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 13px;
  padding: 10px 12px;
  border: 1px solid #e7b64f;
  border-radius: 7px;
  background: #fff9e8;
  color: #704d08;
  font-size: 12px;
  line-height: 1.45;
}

.chat-restriction-notice[data-kind="admin"] {
  border-color: #e1a4a4;
  background: #fff4f4;
  color: #852c2c;
}

.chat-restriction-notice > .button-icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.chat-restriction-notice > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.chat-restriction-notice strong,
.chat-restriction-notice span {
  display: block;
}

.attachment-tray {
  display: grid;
  gap: 8px;
  padding: 0 13px 8px;
  background: #ffffff;
}

.attachment-preview {
  position: relative;
  min-width: 0;
  padding: 9px 44px 9px 10px;
  border: 1px solid #dce5f1;
  border-radius: 7px;
  background: var(--surface);
}

.image-preview,
.file-preview {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.image-preview {
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
}

.image-preview img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
}

.file-preview {
  grid-template-columns: minmax(0, 1fr);
}

.attachment-remove-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(198, 40, 40, 0.2);
  border-radius: 6px;
  background: #ffffff;
  color: #a12727;
}

.attachment-remove-button:hover {
  border-color: rgba(198, 40, 40, 0.38);
  background: #fff0ef;
}

.starter-row {
  padding: 0 13px 11px;
  background: #ffffff;
}

.starter {
  border-radius: 6px;
  color: #31527f;
  font-size: 12px;
}

.entity-detail-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(220px, auto);
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px 0 18px;
  border-bottom: 1px solid var(--line);
}

.entity-detail-header > .secondary {
  align-self: center;
}

.entity-detail-heading {
  min-width: 0;
}

.entity-detail-heading .eyebrow {
  margin-bottom: 5px;
}

.entity-detail-heading h3 {
  overflow-wrap: anywhere;
  font-size: 20px;
}

.entity-detail-heading h3:focus {
  outline: none;
}

.entity-detail-heading .page-lead {
  overflow-wrap: anywhere;
}

.entity-detail-header .context-summary {
  justify-content: flex-end;
}

.entity-overview {
  width: 100%;
  max-width: 900px;
}

.management-list {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.management-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 13px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background 150ms var(--ease-out), color 150ms var(--ease-out);
}

.management-link:last-child {
  border-bottom: 0;
}

.management-link:hover,
.management-link:focus-visible {
  background: var(--surface-soft);
}

.management-link > span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.management-link strong,
.management-link small {
  display: block;
}

.management-link strong {
  color: var(--ink);
  font-size: 14px;
}

.management-link small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.management-link > span:last-child {
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.management-link:disabled {
  background: var(--surface-soft);
}

.subpage-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.subpage-heading > div {
  min-width: 0;
}

.subpage-heading h3 {
  overflow-wrap: anywhere;
}

.subpage-heading .form-note {
  max-width: 760px;
}

.admin-section {
  padding: 18px;
  box-shadow: none;
}

.list-item,
.metric,
.permission-row {
  border-color: var(--line);
  border-radius: 7px;
  transition: background 150ms var(--ease-out), border-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}

.user-card-side {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.user-card-side .inline-action {
  margin: 0;
  min-width: 64px;
}

.list-item:hover,
.permission-row:hover {
  border-color: #cbd5e3;
  background: #fbfcfe;
}

.status-pill,
.readonly-pill {
  border-radius: 6px;
}

.document-file-drop,
.document-file-action,
.inline-alert,
.form-status,
.security-alert-panel {
  border-radius: 7px;
}

.toast {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: #12203a;
  box-shadow: 0 18px 40px rgba(18, 32, 58, 0.24);
  animation: toastEnter 180ms var(--ease-out) both;
}

.skeleton-line {
  display: block;
  width: 100%;
  height: 9px;
  border-radius: 4px;
  background: #e6eaf1;
  animation: skeletonPulse 1.2s ease-in-out infinite;
}

.skeleton-line-title {
  width: 78%;
  height: 11px;
}

.skeleton-line-medium {
  width: 62%;
}

.skeleton-line-short {
  width: 38%;
}

.skeleton-conversation,
.skeleton-home-row {
  display: grid;
  gap: 9px;
  padding: 13px 10px;
  border-bottom: 1px solid #edf0f5;
}

.skeleton-list-row {
  display: grid;
  min-height: 72px;
  gap: 10px;
  align-content: center;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.skeleton-home-row {
  min-height: 68px;
  align-content: center;
  padding-inline: 4px;
}

.skeleton-message {
  display: grid;
  align-self: flex-start;
  width: min(660px, 76%);
  gap: 11px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.skeleton-message-user {
  align-self: flex-end;
  width: min(420px, 58%);
  background: var(--accent-soft);
}

@keyframes viewEnter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes messageEnter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes actionEnter {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes responseCaret {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

@keyframes toastEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 0.54; }
  50% { opacity: 1; }
}

@media (hover: hover) {
  .bubble-actions {
    opacity: 0.62;
    transition: opacity 150ms var(--ease-out);
  }

  .bubble:hover .bubble-actions,
  .bubble:focus-within .bubble-actions {
    opacity: 1;
  }
}

@media (max-width: 1120px) {
  .home-query-band {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .home-content-grid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
    gap: 24px;
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    width: 100%;
    height: auto;
    min-height: 70px;
    padding: 10px 14px;
    overflow: visible;
  }

  .brand {
    padding: 0;
  }

  .brand .brand-mark {
    width: 40px;
    height: 40px;
  }

  .nav {
    display: flex;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
  }

  .nav-group {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
  }

  .nav-group-label {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 7px 9px;
  }

  .session {
    grid-template-columns: auto auto;
    gap: 6px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .session-copy {
    display: none !important;
  }

  .session .ghost {
    width: auto;
    min-width: 54px;
  }

  .workspace {
    height: calc(100dvh - 70px);
    padding: 20px;
  }

  #chatView {
    height: 100%;
    overflow: hidden;
  }

  .chat-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    height: auto;
  }

  .conversation {
    min-height: 0;
  }

  .conversation-list {
    max-height: none;
  }

  .chat-layout .conversation {
    order: initial;
  }

  .chat-layout .conversation-list {
    max-height: none;
  }

  .admin-grid,
  .history-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .home-content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace {
    height: auto;
    min-height: calc(100dvh - 70px);
    overflow: visible;
  }

  #chatView {
    height: auto;
    overflow: visible;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-layout .conversation {
    order: -1;
    height: calc(100dvh - 190px);
    min-height: 520px;
  }

  .conversation-panel {
    min-height: 250px;
    max-height: 320px;
  }

  .home-header {
    display: grid;
  }

  .home-header .primary {
    width: fit-content;
  }

  .home-query-band {
    gap: 24px;
    padding: 24px;
  }

  .bubble {
    max-width: 96%;
  }

  .bubble.user {
    max-width: 88%;
  }

  .entity-detail-header {
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
  }

  .entity-detail-header > .secondary {
    justify-self: start;
  }

  .entity-detail-header .context-summary {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .sidebar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 9px 12px;
  }

  .brand span:not(.brand-mark) {
    display: none;
  }

  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    padding-bottom: 1px;
  }

  .session {
    grid-column: 2;
    grid-row: 1;
  }

  .session-avatar {
    display: none !important;
  }

  .panel,
  .workspace {
    padding: 14px;
  }

  .home-header {
    gap: 16px;
    margin-bottom: 18px;
  }

  .home-query-band {
    padding: 20px;
  }

  .home-query-band h2 {
    font-size: 22px;
  }

  .home-query-form {
    grid-template-columns: 1fr;
  }

  .home-query-form .primary {
    min-height: 44px;
  }

  .home-content-grid {
    margin-top: 24px;
  }

  .toolbar {
    display: grid;
    gap: 12px;
  }

  #chatView .toolbar {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }

  #chatView .toolbar-actions {
    flex-wrap: wrap;
  }

  #chatView .toolbar h2 {
    font-size: 19px;
    line-height: 1.25;
  }

  .chat-action-label-full {
    display: none;
  }

  .chat-action-label-short {
    display: inline;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions > button {
    flex: 1 1 145px;
  }

  .chat-layout .conversation {
    height: clamp(430px, calc(100dvh - 284px), 560px);
    min-height: 430px;
  }

  .messages {
    padding: 14px;
  }

  .composer {
    gap: 7px;
    padding: 10px;
  }

  .composer-footer {
    gap: 8px;
  }

  .composer-generation-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-action-selector,
  .composer-format-selector,
  .illustrated-presentation-options {
    width: 100%;
    overflow-x: auto;
  }

  .composer-format-selector {
    margin-left: 0;
  }

  .illustrated-presentation-options {
    overflow: visible;
    margin-left: 0;
  }

  .composer-action,
  .composer-format {
    flex: 1 0 auto;
  }

  .composer-tool {
    width: 38px;
    min-width: 38px;
    padding: 0;
  }

  .composer-tool .button-label {
    display: none;
  }

  .composer-send {
    min-width: 92px;
  }

  .composer-stop {
    min-width: 88px;
  }

  .attachment-tray {
    padding: 0 10px 8px;
  }

  .chat-restriction-notice {
    margin: 0 10px;
  }

  .bubble,
  .bubble.user {
    max-width: 98%;
  }

  .subpage-heading {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .subpage-heading > .secondary {
    width: 100%;
  }

  .management-link {
    gap: 10px;
    min-height: 72px;
    padding: 12px 4px;
  }
}

.security-notice-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(198, 40, 40, 0.32);
  border-left: 4px solid #c62828;
  border-radius: 7px;
  background: #fff4f3;
  color: #671515;
}

.security-notice-banner p {
  max-width: 900px;
  margin: 4px 0 0;
  line-height: 1.5;
}

.security-summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.security-summary-metric {
  display: grid;
  gap: 3px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}

.security-summary-metric strong {
  color: #a51f1f;
  font-size: 24px;
}

.security-summary-metric span {
  color: var(--muted);
  font-size: 13px;
}

.security-management-layout {
  display: grid;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
  gap: 16px;
  min-height: 640px;
}

.security-incident-panel,
.security-incident-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.security-incident-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.security-incident-list {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 10px;
  overflow-y: auto;
}

.security-incident-item {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 92px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.security-incident-item:hover,
.security-incident-item.active {
  border-color: #bfd2f3;
  background: var(--accent-soft);
}

.security-incident-item strong,
.security-incident-item span {
  overflow-wrap: anywhere;
}

.security-incident-item span,
.security-incident-item small {
  color: var(--muted);
}

.security-incident-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-pill.danger {
  border-color: rgba(198, 40, 40, 0.24);
  background: #fff1f0;
  color: #a51f1f;
}

.status-pill.warning {
  border-color: rgba(154, 91, 0, 0.24);
  background: #fff8e6;
  color: #8a5200;
}

.security-incident-detail {
  padding: 18px;
}

#securityIncidentContent {
  display: grid;
  grid-template-rows: auto minmax(260px, 48vh) auto;
  gap: 16px;
  height: 100%;
}

.security-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.security-detail-header h3,
.security-actions-band h4,
.security-resolution-actions h4 {
  margin: 0;
}

.security-incident-messages {
  min-height: 260px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  overflow-y: auto;
}

.security-actions-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.security-resolution-actions {
  display: grid;
  align-content: start;
  gap: 12px;
}

.security-action-buttons {
  justify-content: flex-start;
}

.security-filter-row select {
  min-width: 210px;
}

@media (max-width: 1080px) {
  .rag-inspector-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rag-inspector-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .rag-map-shell {
    grid-template-columns: 1fr;
  }

  .rag-map-visual {
    padding-right: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rag-map-details {
    padding-left: 0;
  }

  .security-management-layout {
    grid-template-columns: 1fr;
  }

  .security-incident-panel {
    min-height: 280px;
    max-height: 380px;
  }

  .security-actions-band {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .rag-inspector-controls,
  .rag-inspector-metrics,
  .rag-score-grid {
    grid-template-columns: 1fr;
  }

  .rag-inspector-actions button {
    width: 100%;
  }

  .rag-inspector-actions .form-note {
    margin-left: 0;
  }

  .rag-inspector-result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .rag-map-shell {
    min-height: 0;
  }

  .rag-map-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .rag-map-toolbar-actions {
    justify-content: space-between;
  }

  .rag-map-toolbar .status-pill {
    align-self: flex-start;
  }

  .rag-map-canvas-wrap {
    height: 330px;
  }

  .rag-map-flow {
    gap: 10px;
    width: calc(100% - 24px);
    justify-content: center;
    overflow: hidden;
  }

  .rag-map-flow span {
    min-width: 0;
  }

  .rag-map-flow span:not(:last-child)::after {
    display: none;
  }

  .rag-map-facts,
  .rag-map-modalities {
    grid-template-columns: 1fr 1fr;
  }

  .security-notice-banner,
  .security-detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .security-summary-row {
    grid-template-columns: 1fr;
  }

  .security-filter-row select,
  .security-filter-row button {
    width: 100%;
  }

  .security-incident-detail {
    padding: 12px;
  }

  #securityIncidentContent {
    grid-template-rows: auto minmax(320px, 56vh) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rag-map-flow .is-active i,
  .rag-map-toolbar-actions .compact-button.is-playing .button-icon {
    animation: none;
  }
}

/* Mobile application shell and chat drawers */
.sidebar-drawer {
  display: contents;
}

.mobile-menu-button,
.mobile-only,
.mobile-backdrop,
.conversation-panel-close {
  display: none;
}

.conversation-panel-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.generation-action-label-short {
  display: none;
}

@media (max-width: 980px) {
  body {
    min-height: var(--app-height, 100dvh);
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  .shell {
    grid-template-rows: 64px minmax(0, 1fr);
    width: 100%;
    height: var(--app-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    position: relative;
    top: auto;
    z-index: 60;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
    height: 64px;
    min-height: 64px;
    padding: 9px 12px;
    overflow: visible;
  }

  .brand {
    min-width: 0;
  }

  .brand .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand > div {
    min-width: 0;
  }

  .mobile-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 88px;
    min-height: 42px;
    padding: 0 11px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-menu-button:hover,
  .mobile-menu-button:focus-visible {
    border-color: rgba(119, 168, 255, 0.8);
    background: rgba(53, 116, 224, 0.28);
  }

  .mobile-menu-close-icon {
    display: none;
  }

  body.mobile-nav-open .mobile-menu-open-icon {
    display: none;
  }

  body.mobile-nav-open .mobile-menu-close-icon {
    display: block;
  }

  .sidebar-drawer {
    position: fixed;
    z-index: 55;
    top: 64px;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    width: min(330px, calc(100vw - 44px));
    min-height: 0;
    padding: 14px;
    background: var(--navy-deep);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 18px 0 36px rgba(3, 18, 45, 0.28);
    transform: translateX(-105%);
    transition: transform 180ms var(--ease-out);
  }

  body.mobile-nav-open .sidebar-drawer {
    transform: translateX(0);
  }

  .sidebar .nav {
    display: grid;
    grid-column: auto;
    grid-row: auto;
    align-content: start;
    gap: 18px;
    padding: 0 2px 14px 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .sidebar .nav-group {
    display: grid;
    gap: 5px;
  }

  .sidebar .nav-group-label {
    display: block;
  }

  .sidebar .nav-item {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
  }

  .sidebar .session {
    display: grid;
    grid-column: auto;
    grid-row: auto;
    grid-template-columns: 1fr;
    gap: 9px;
    width: 100%;
    padding: 12px 2px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .sidebar .session-copy,
  .sidebar .session-avatar {
    display: block !important;
  }

  .sidebar .session-avatar {
    display: grid !important;
  }

  .sidebar .session-profile {
    display: grid;
  }

  .sidebar .session .ghost {
    width: 100%;
  }

  body:not(.authenticated) .mobile-menu-button,
  body:not(.authenticated) .sidebar-drawer {
    display: none;
  }

  .mobile-backdrop {
    position: fixed;
    inset: 64px 0 0;
    width: 100%;
    height: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(8, 20, 42, 0.42);
    backdrop-filter: blur(1px);
  }

  .navigation-backdrop {
    z-index: 50;
    display: block;
  }

  .workspace,
  .panel {
    height: calc(var(--app-height, 100dvh) - 64px);
    min-height: 0;
  }

  .workspace {
    padding: 18px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 820px) {
  body.chat-view-active {
    overflow: hidden;
  }

  body.chat-view-active .workspace {
    height: calc(var(--app-height, 100dvh) - 64px);
    padding: 10px;
    overflow: hidden;
  }

  body.chat-view-active #chatView {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  #chatView.view.active {
    animation: none;
  }

  #chatView .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    min-height: 0;
    margin-bottom: 8px;
  }

  #chatView .toolbar .eyebrow {
    display: none;
  }

  #chatView .toolbar h2 {
    display: -webkit-box;
    overflow: hidden;
    font-size: 17px;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #chatView .toolbar-actions {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  #chatView .toolbar-actions::-webkit-scrollbar {
    display: none;
  }

  #chatView .toolbar-actions > button {
    flex: 0 0 auto;
    min-height: 36px;
  }

  .mobile-only {
    display: inline-flex;
  }

  .mobile-conversation-count {
    display: inline-grid;
    min-width: 20px;
    height: 20px;
    place-items: center;
    padding: 0 5px;
    border-radius: 5px;
    background: var(--surface-soft);
    color: var(--accent-strong);
    font-size: 10px;
    font-weight: 850;
  }

  .chat-layout {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .chat-layout .conversation {
    width: 100%;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden;
  }

  .conversation-panel {
    position: fixed;
    z-index: 45;
    top: 64px;
    bottom: 0;
    left: 0;
    width: min(340px, calc(100vw - 36px));
    max-height: none;
    min-height: 0;
    border-width: 0 1px 0 0;
    border-radius: 0;
    box-shadow: 18px 0 38px rgba(12, 34, 69, 0.2);
    transform: translateX(-105%);
    transition: transform 180ms var(--ease-out);
  }

  body.mobile-conversations-open .conversation-panel {
    transform: translateX(0);
  }

  .conversation-backdrop {
    z-index: 40;
    display: block;
  }

  .conversation-panel-heading {
    min-height: 56px;
    padding: 13px 14px 10px;
  }

  .conversation-panel-close {
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
  }

  .conversation-search {
    padding: 0 12px 10px;
  }

  .conversation-list {
    max-height: none !important;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .messages {
    min-height: 0;
    padding: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-bottom: 12px;
    scrollbar-gutter: auto;
    touch-action: pan-y;
  }

  .bubble,
  .bubble.user {
    max-width: 100%;
  }

  .bubble.assistant {
    width: min(100%, 860px);
  }

  .bubble.user {
    max-width: 92%;
  }

  .composer {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    gap: 7px;
    padding: 9px;
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }

  .composer textarea {
    min-height: 46px;
    max-height: min(132px, 24vh);
    padding: 10px 12px;
  }

  .composer-generation-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-action-selector,
  .composer-format-selector,
  .illustrated-presentation-options {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .composer-action-selector::-webkit-scrollbar,
  .composer-format-selector::-webkit-scrollbar {
    display: none;
  }

  .composer-format-selector {
    margin-left: 0;
  }

  .illustrated-presentation-options {
    overflow: visible;
    margin-left: 0;
  }

  .composer-action,
  .composer-format {
    flex: 1 0 auto;
    min-height: 34px;
  }

  .starter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .starter-row::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 480px) {
  .brand span:not(.brand-mark) {
    display: block;
  }

  .mobile-menu-button {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .mobile-menu-button > span {
    display: none;
  }

  body.chat-view-active .workspace {
    padding: 8px;
  }

  #chatView .toolbar-actions > button {
    flex: 1 1 auto;
    justify-content: center;
    padding-inline: 9px;
  }

  .chat-action-label-full {
    display: none;
  }

  .chat-action-label-short {
    display: inline;
  }

  .messages {
    gap: 10px;
    padding: 9px;
  }

  .bubble {
    padding: 11px 12px;
    font-size: 14px;
    line-height: 1.5;
  }

  .message-section {
    padding: 8px 9px;
  }

  .composer-action,
  .composer-format {
    padding-inline: 7px;
    font-size: 10px;
  }

  .composer-footer {
    gap: 6px;
  }

  .composer-send,
  .composer-stop {
    min-width: 84px;
  }

  .attachment-tray,
  .chat-restriction-notice {
    margin-inline: 8px;
  }

  .admin-section {
    padding: 14px;
  }

  .rag-processing-dialog {
    width: calc(100vw - 16px);
    max-height: calc(var(--app-height, 100vh) - 16px);
  }

  .rag-processing-shell {
    max-height: calc(var(--app-height, 100vh) - 16px);
  }

  .rag-processing-header {
    padding: 16px;
  }

  .rag-processing-mark {
    display: none;
  }

  .rag-processing-summary {
    grid-template-columns: 1fr;
  }

  .rag-processing-summary > div {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 9px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rag-processing-summary > div:last-child {
    border-bottom: 0;
  }

  .rag-processing-jobs {
    padding: 0 16px;
  }

  .rag-processing-job-facts,
  .rag-processing-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .rag-processing-footer {
    padding: 14px 16px;
  }

  .rag-processing-footer button {
    width: 100%;
  }

  .section-heading > button,
  .admin-list-actions > button {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .composer-generation-controls {
    flex-wrap: nowrap;
  }

  .composer-action-selector {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .composer-action {
    min-width: 0;
  }

  .generation-action-label-full {
    display: none;
  }

  .generation-action-label-short {
    display: inline;
  }
}

@media (max-width: 360px) {
  .generation-action-label-full {
    display: none;
  }

  .generation-action-label-short {
    display: inline;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
