:root {
  --bg: #f7f7f8;
  --card: #f7f7f8;
  --ink: #0f172a;
  --muted: #666666;
  --line: #cbd5e1;
  --brand: #ffffff;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.container {
  max-width: 100%;
  margin: 0 auto;
  min-height: 100vh;
}
body.app-authenticated > main > h1 {
  display: none;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #0f766e;
  text-align: left;
}

.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.note {
  margin: 16px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}

.card {
  margin-top: 10px;
  padding: 20px;
  border: 1px solid #d9dce3;
  border-radius: 12px;
  background: var(--card);
}

h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #202123;
}

label { display: block; margin: 10px 0 4px; font-weight: 600; }

input, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
}

textarea[readonly] { background: #f7f8fa; }

.row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

button {
  background: var(--brand);
  color: #334155;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

button.danger { background: var(--danger); color: #fff; border: none; }

.hidden { display: none !important; }

#loginScreen,
#appScreen {
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

#appScreen {
  background: #f7f7f8;
  border: 1px solid #d9dce3;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  margin-top: 0;
}

#googleButtonWrap {
  min-height: 46px;
  margin-top: 12px;
}

.login-primary-btn {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  padding: 14px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  color: #334155;
  font-size: 16px;
  font-weight: 600;
}

.login-primary-btn:disabled {
  opacity: 0.65;
  cursor: default;
}

.error-text {
  color: #b42318;
}

.app-topbar {
  min-height: 68px;
  background: #f7f7f8;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-brand {
  font-size: 22px;
  font-weight: 700;
  color: #202123;
}

.app-mode-switch {
  display: flex;
  gap: 10px;
}

.mode-pill {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #202123;
}

.mode-pill.active {
  background: #202123;
  border-color: #202123;
  color: #fff;
}

.logout-link {
  border: none;
  background: transparent;
  color: #202123;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
}

.app-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.tab-link {
  border: none;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  padding: 12px 20px;
  margin-right: 4px;
  font-size: 16px;
  font-weight: 500;
  color: #666;
}

.tab-link.active {
  color: #202123;
  border-bottom-color: #202123;
  font-weight: 600;
}

.upload-page {
  margin: 16px;
  padding: 16px;
  border: 1px solid #ececf1;
  border-radius: 12px;
  background: #fff;
}

.addon-page {
  margin: 16px 16px 70px;
}

.addon-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  gap: 12px;
  align-items: start;
}

.addon-card {
  margin-top: 0;
  min-height: 560px;
}

.tab-page.active {
  display: block;
}

.upload-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.upload-limit-pill {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #202123;
}

.upload-subtitle {
  font-size: 14px;
  color: #666;
  margin: 10px 0 8px;
  line-height: 20px;
}

.upload-caption {
  font-size: 12px;
  color: #666;
  margin: 0 0 4px;
}

.upload-caption.muted {
  opacity: 0.88;
  margin-top: 8px;
  margin-bottom: 8px;
}

.upload-warning {
  font-size: 13px;
  color: #c00;
  margin: 8px 0;
}

.upload-warning.inline {
  margin-top: 4px;
  margin-bottom: 2px;
}

.upload-status {
  font-size: 12px;
  margin: 8px 0 0;
  color: #666;
}

.upload-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 12px;
  align-items: start;
  margin-top: 8px;
}

.upload-main-panel {
  min-width: 0;
}

.upload-side-panel {
  min-width: 320px;
}

.upload-zone {
  margin-top: 10px;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  background: #fff;
  padding: 22px;
  text-align: center;
  min-height: 120px;
}

.upload-zone.drag-active {
  border-color: #9ca3af;
  background: #f3f4f6;
}

.upload-zone-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #202123;
}

.upload-zone-hint {
  margin: 6px 0 0;
  font-size: 14px;
  color: #666;
}

.upload-zone-drop {
  margin: 6px 0 12px;
  font-size: 12px;
  color: #9ca3af;
}

.upload-card {
  margin-top: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.upload-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upload-list {
  margin-top: 10px;
}

.upload-list.empty {
  font-size: 13px;
  color: #6b7280;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.upload-file {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-meta {
  font-size: 12px;
  color: #6b7280;
}

.upload-meta.review-required {
  color: #b42318;
  font-weight: 700;
}

.upload-list.recent .upload-row-recent {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: start;
}

.upload-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.upload-list.recent .upload-file {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-list.recent .upload-meta {
  white-space: normal;
  word-break: break-word;
}

.upload-remove-btn {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 10px;
}

.upload-neutral-btn,
.upload-primary-btn {
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #202123;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  min-height: 36px;
}

.upload-primary-btn {
  background: #202123;
  border-color: #202123;
  color: #fff;
}

.upload-neutral-btn.wide {
  width: 100%;
  margin-bottom: 8px;
}

.queue-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 12px;
}

.tag-chip {
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  color: #202123;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
}

.tag-chip.selected {
  background: #202123;
  border-color: #202123;
  color: #fff;
}

.lifeevents-page {
  margin: 16px;
  padding: 16px;
  border: 1px solid #ececf1;
  border-radius: 12px;
  background: #fff;
}

.lifeevents-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 12px;
}

.lifeevents-left,
.lifeevents-main {
  min-width: 0;
}

.lifeevents-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  margin-bottom: 12px;
}

.lifeevents-docs {
  max-height: 460px;
  overflow: auto;
  margin-top: 10px;
}

.lifeevents-docs.empty {
  font-size: 13px;
  color: #6b7280;
}

.lifeevents-doc-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.lifeevents-doc-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.lifeevents-doc-meta {
  grid-column: 2;
  font-size: 12px;
  color: #6b7280;
}

.lifeevents-doc-row.disabled {
  opacity: 0.6;
}

.lifeevents-confirm {
  margin: 8px 0;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  padding: 8px;
  font-size: 13px;
}

.lifeevents-confirm.warning {
  border-color: #f59e0b;
  color: #92400e;
  background: #fffbeb;
}

.lifeevents-candidates {
  margin-top: 8px;
  margin-bottom: 12px;
}

.lifeevents-candidate-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.lifeevents-candidate-event {
  font-size: 12px;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lifeevents-candidate-bar {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.lifeevents-candidate-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #202123;
}

.lifeevents-candidate-pct {
  font-size: 12px;
  color: #6b7280;
  text-align: right;
}

.lifeevents-chip {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #1f2937;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
}

.lifeevents-chip.active {
  background: #202123;
  border-color: #202123;
  color: #fff;
}

.lifeevents-action-pill {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #1f2937;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
}

.review-page {
  margin: 16px;
  padding: 16px;
  border: 1px solid #ececf1;
  border-radius: 12px;
  background: #fff;
}

.review-layout {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 12px;
}

.review-left,
.review-main {
  min-width: 0;
}

.review-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  margin-bottom: 12px;
}

.review-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.review-docs {
  max-height: 560px;
  overflow: auto;
  margin-top: 10px;
}

.review-docs.empty {
  font-size: 13px;
  color: #6b7280;
}

.review-doc-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 10px;
}

.review-doc-row.selected {
  border-color: #9ca3af;
  background: #f8fafc;
}

.review-doc-check {
  margin-top: 2px;
}

.review-doc-body {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.review-doc-name {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
}

.review-doc-meta {
  font-size: 12px;
  color: #6b7280;
}

.review-doc-meta.review-required {
  color: #b42318;
  font-weight: 700;
}

.review-doc-reason {
  font-size: 12px;
  color: #374151;
}

.askv2-page {
  margin: 0;
  padding: 0;
}

.chatv2-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - 208px);
  border-top: 1px solid #e5e7eb;
}

.chatv2-left {
  border-right: 1px solid #e5e7eb;
  padding: 18px 16px;
  background: #f7f7f8;
}

.chatv2-main {
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chatv2-nav-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: #202123;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 4px;
}

.chatv2-nav-item.active {
  background: #e5e7eb;
  font-weight: 700;
}

.chatv2-nav-search {
  margin: 8px 0 14px;
  border-radius: 14px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  padding: 10px 14px;
  background: #fff;
}

.chatv2-recents-title {
  margin-top: 18px;
  margin-bottom: 8px;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.chatv2-recents {
  display: grid;
  gap: 8px;
  color: #6b7280;
  font-size: 12px;
}

.chatv2-thread {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #111827;
}

.chatv2-thread.selected {
  background: #202123;
  border-color: #202123;
  color: #fff;
}

.chatv2-library-header {
  margin-bottom: 10px;
}

.chatv2-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chatv2-toolbar h2 {
  margin: 0;
  font-size: 22px;
  color: #202123;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.chatv2-search-wrap {
  width: 320px;
  max-width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  padding: 0 12px;
  display: flex;
  align-items: center;
}

.chatv2-search-icon {
  font-size: 15px;
  color: #6b7280;
  margin-right: 6px;
}

.chatv2-search {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 8px 0;
  font-size: 13px;
  color: #202123;
  background: transparent;
}

.chatv2-chip-row {
  display: flex;
  gap: 14px;
}

.chatv2-chip {
  background: transparent;
  border: none;
  border-radius: 0;
  color: #9ca3af;
  padding: 2px 0;
  font-size: 13px;
  font-weight: 500;
}

.chatv2-chip.active {
  color: #202123;
  border-bottom: 2px solid #202123;
  font-weight: 600;
}

.chatv2-actions-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chatv2-start-btn {
  background: #202123;
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
}

.chatv2-selected {
  color: #202123;
  font-size: 12px;
  font-weight: 600;
}

.chatv2-clear-btn {
  background: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
}

.chatv2-table-card {
  padding-top: 4px;
}

.chatv2-meta {
  margin: 0 0 8px;
  color: #6b7280;
  font-size: 12px;
}

.chatv2-pager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.chatv2-pager-btn {
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
}

.chatv2-pager-btn:disabled {
  opacity: 0.5;
}

.chatv2-pager-text {
  font-size: 11px;
  color: #4b5563;
  font-weight: 600;
}

.chatv2-head-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 110px 90px;
  align-items: center;
  margin-bottom: 6px;
}

.chatv2-head-row span {
  font-size: 11px;
  color: #202123;
  font-weight: 600;
}

.chatv2-head-spacer {
  display: block;
}

.chatv2-doc-list {
  max-height: 520px;
  overflow: auto;
}

.chatv2-doc-list.empty {
  color: #6b7280;
  font-size: 12px;
  padding: 12px 4px;
}

.chatv2-doc-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 110px 90px;
  align-items: center;
  gap: 0;
  padding: 5px 0;
  border-bottom: 1px solid #ececf1;
}

.chatv2-doc-row.selected {
  background: #f3f4f6;
}

.chatv2-doc-row.disabled {
  opacity: 0.55;
}

.chatv2-select-col {
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatv2-select-col input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: #111;
}

.chatv2-name-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chatv2-doc-name {
  font-size: 12px;
  font-weight: 500;
  color: #202123;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatv2-doc-sub {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.2;
}

.chatv2-doc-mod,
.chatv2-doc-size {
  font-size: 12px;
  color: #6b7280;
}

.chatv2-answer {
  margin-top: 12px;
  border: 1px solid #ececf1;
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.chatv2-answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.operations-page {
  margin: 16px;
  padding: 0 0 70px;
}

.operations-hero,
.operations-card,
.operations-nav-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #fff;
  padding: 16px;
}

.operations-hero {
  margin-bottom: 12px;
}

.operations-hero h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: #202123;
}

.operations-hero p {
  margin: 0 0 8px;
  font-size: 14px;
  color: #4b5563;
}

.operations-top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.operations-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.operations-nav-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.operations-nav-list {
  display: grid;
  gap: 8px;
}

.operations-nav-btn {
  width: 100%;
  text-align: left;
  border-radius: 18px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #202123;
  font-size: 13px;
  font-weight: 700;
  min-height: 46px;
  padding: 10px 16px;
}

.operations-nav-btn.active {
  background: #202123;
  border-color: #202123;
  color: #fff;
}

.operations-main-col {
  min-width: 0;
}

.operations-card h3 {
  margin: 0 0 10px;
  font-size: 20px;
  color: #202123;
}

.operations-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.operations-list.empty {
  color: #6b7280;
  font-size: 13px;
}

.operations-row {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
}

.operations-row-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
}

.operations-row-meta {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

.settings-page {
  margin: 16px;
  padding: 0 0 70px;
}

.settings-hero-card,
.settings-card,
.settings-nav-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #fff;
  padding: 16px;
}

.settings-hero-card {
  margin-bottom: 12px;
}

.settings-hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-subtitle {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.4;
  color: #4b5563;
}

.settings-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.settings-nav-title {
  margin: 0 0 12px;
  font-size: 15px;
}

.settings-nav-list {
  display: grid;
  gap: 8px;
}

.settings-nav-btn {
  width: 100%;
  text-align: left;
  border-radius: 18px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #202123;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 700;
  padding: 10px 12px;
}

.settings-nav-btn.active {
  background: #202123;
  border-color: #202123;
  color: #fff;
}

.settings-main-col {
  min-width: 0;
}

.settings-card {
  margin-bottom: 12px;
}

.settings-card > h3 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 700;
}

.settings-card > h4 {
  margin: 10px 0 4px;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 600;
  color: #202123;
}

.settings-card .upload-caption {
  font-size: 12px;
  line-height: 1.35;
  color: #6b7280;
}

.settings-card input {
  margin-top: 8px;
  font-size: 14px;
  padding: 10px 12px;
}

.settings-rows {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.settings-rows.empty {
  font-size: 13px;
  color: #6b7280;
}

.settings-row {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
}

.settings-row-title {
  margin: 0;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 700;
  color: #202123;
}

.settings-row-meta {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.3;
  color: #6b7280;
}

.settings-row-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-audit-table-wrap {
  margin-top: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.admin-audit-table-head,
.admin-audit-table-row {
  display: grid;
  grid-template-columns: 180px 240px 220px 220px 360px;
  align-items: center;
}

.admin-audit-table-head {
  border-bottom: 1px solid #e5e7eb;
  background: #f3f4f6;
  font-size: 12px;
  font-weight: 700;
  color: #4b5563;
}

.admin-audit-table-head span,
.admin-audit-table-row span {
  padding: 10px;
  font-size: 12px;
  color: #202123;
}

.admin-audit-table-body {
  max-height: 430px;
  overflow: auto;
}

.admin-audit-table-row {
  border-bottom: 1px solid #e5e7eb;
}

.admin-audit-table-row:last-child {
  border-bottom: 0;
}

@media (max-width: 1200px) {
  .admin-audit-table-wrap {
    overflow: auto;
  }
  .admin-audit-table-head,
  .admin-audit-table-row {
    min-width: 1220px;
  }
}

.settings-inline-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}

.settings-filter-btn {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #202123;
  font-size: 13px;
  font-weight: 700;
  min-height: 36px;
  padding: 8px 14px;
}

.settings-filter-btn.active {
  background: #202123;
  border-color: #202123;
  color: #fff;
}

.settings-inline-add-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 10px;
  margin-bottom: 8px;
}

.settings-inline-table {
  border-top: 1px solid #e5e7eb;
  margin-top: 4px;
}

.settings-inline-item {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}

.settings-inline-value {
  font-size: 13px;
  font-weight: 700;
  color: #202123;
  word-break: break-word;
}

.settings-inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 1200px) {
  .settings-subtitle { font-size: 14px; }
  .settings-nav-btn { font-size: 13px; padding: 10px 12px; }
  .settings-card > h3 { font-size: 16px; }
  .settings-card > h4 { font-size: 13px; }
  .settings-card .upload-caption,
  .settings-row-meta { font-size: 12px; }
  .settings-row-title { font-size: 13px; }
}

@media (max-width: 900px) {
  .operations-layout {
    grid-template-columns: 1fr;
  }
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-inline-add-row {
    grid-template-columns: 1fr;
  }
  .settings-inline-item {
    grid-template-columns: 1fr;
  }
  .settings-inline-actions {
    justify-content: flex-start;
  }
}

.chatv2-answer-head h3 {
  margin: 0;
  font-size: 16px;
}

.chatv2-sources-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  background: #f3f4f6;
}

.chatv2-answer-body {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
  color: #202123;
}

.chatv2-sources {
  margin-top: 10px;
  border-top: 1px solid #ececf1;
  padding-top: 10px;
}

.chatv2-source-row {
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 4px;
}

.chatv2-composer {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 54px 58px;
  align-items: center;
  gap: 8px;
  border: 1px solid #ececf1;
  border-radius: 999px;
  padding: 10px 12px;
  background: #fff;
}

.chatv2-plus {
  border: none;
  background: transparent;
  font-size: 22px;
  font-weight: 700;
  color: #202123;
  padding: 0;
}

.chatv2-prompt {
  border: none;
  background: transparent;
  border-radius: 0;
  resize: none;
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.3;
  min-height: 24px;
  max-height: 74px;
}

.chatv2-prompt:focus {
  outline: none;
}

.chatv2-mic {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chatv2-mic.active {
  background: #f3f4f6;
}

.chatv2-mic-icon {
  width: 22px;
  height: 22px;
  fill: #111827;
}

.chatv2-send {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #202123;
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chatv2-send-icon {
  width: 24px;
  height: 24px;
  fill: #fff;
}

.help-page {
  margin: 16px;
  padding: 0;
}

.help-card {
  margin: 0 0 12px;
  padding: 16px;
  border: 1px solid #ececf1;
  border-radius: 12px;
  background: #fff;
}

.help-card h3 {
  margin-bottom: 8px;
}

.help-card p {
  margin: 0 0 6px;
  color: #374151;
  font-size: 14px;
  line-height: 1.45;
}

.help-subtitle {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
}

.documents-page {
  margin: 16px;
  padding: 0;
}

.documents-top-row {
  margin-bottom: 8px;
}

.documents-library-title {
  margin: 10px 2px 6px;
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #4b5563;
  text-transform: uppercase;
}

.documents-bulk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.documents-table-card {
  overflow-x: auto;
}

.documents-table-wrap {
  width: 100%;
  overflow: auto;
}

.documents-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

.documents-table thead th {
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
}

.documents-table tbody td {
  vertical-align: top;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
}

.documents-file {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
  color: #111827;
  word-break: break-word;
}

.documents-status {
  font-size: 15px;
  color: #374151;
  line-height: 1.25;
}

.documents-sub {
  margin-top: 3px;
  font-size: 13px;
  color: #6b7280;
}

.documents-sub.review-required {
  color: #b42318;
  font-weight: 700;
}

.documents-cell-wrap {
  font-size: 14px;
  line-height: 1.35;
  color: #374151;
  white-space: normal;
  word-break: break-word;
}

.documents-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 270px;
}

.documents-action-btn {
  min-height: 34px;
  font-size: 13px;
  padding: 7px 10px;
}

.documents-scan-preview {
  margin-top: 12px;
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
}

.documents-scan-text {
  margin: 8px 0 0;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.4;
  color: #111827;
}

.documents-inspector-title {
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 700;
  color: #202123;
}

.documents-inspector-layout {
  display: grid;
  grid-template-columns: 460px minmax(0, 1fr);
  gap: 12px;
}

.documents-inspector-left,
.documents-inspector-right {
  min-width: 0;
}

.documents-inspector-left {
  min-height: 760px;
}

.documents-inspector-right {
  max-height: 980px;
  overflow: auto;
}

.documents-doc-row {
  width: 100%;
  text-align: left;
  border: 1px solid #d1d5db;
  border-radius: 16px;
  background: #f7f7f8;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.documents-doc-row.selected {
  border-color: #202123;
  box-shadow: inset 0 0 0 1px #202123;
}

.documents-doc-name {
  display: block;
  font-size: 13px;
  line-height: 1.15;
  font-weight: 700;
  color: #111827;
}

.documents-doc-meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.2;
  color: #6b7280;
}

.documents-inspector-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  margin-top: 12px;
}

.documents-fields p {
  margin: 6px 0;
  font-size: 12px;
  line-height: 1.18;
  color: #374151;
}

.documents-fields strong {
  color: #111827;
}

.documents-preview-empty {
  font-size: 12px;
  line-height: 1.2;
  color: #6b7280;
}

.documents-image-wrap {
  width: 100%;
}

.documents-preview-image {
  width: 100%;
  max-height: 700px;
  object-fit: contain;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
}

.documents-text-preview {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  font-size: 12px;
  line-height: 1.25;
  color: #111827;
  white-space: pre-wrap;
}

.documents-chunks-list {
  display: grid;
  gap: 10px;
}

.documents-chunk-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fafafa;
  padding: 10px;
}

.documents-chunk-title {
  font-size: 12px;
  font-weight: 700;
  color: #111827;
}

.documents-chunk-text {
  margin: 6px 0 0;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.25;
  color: #374151;
}

.integrity-page {
  margin: 16px;
  padding: 16px;
  border: 1px solid #ececf1;
  border-radius: 12px;
  background: #fff;
}

.integrity-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 12px;
}

.integrity-left,
.integrity-main {
  min-width: 0;
}

.integrity-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  margin-bottom: 12px;
}

.integrity-docs {
  max-height: 460px;
  overflow: auto;
  margin-top: 10px;
}

.integrity-docs.empty {
  font-size: 13px;
  color: #6b7280;
}

.integrity-doc-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.integrity-doc-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.integrity-doc-meta {
  grid-column: 2;
  font-size: 12px;
  color: #6b7280;
}

.rule-warning {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b42318;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.integrity-doc-row.disabled {
  opacity: 0.6;
}

.integrity-results {
  display: grid;
  gap: 8px;
}

.integrity-results.empty {
  font-size: 13px;
  color: #6b7280;
}

.integrity-result-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px;
}

.integrity-result-title {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
}

.integrity-result-metric {
  font-size: 12px;
  color: #334155;
  margin-bottom: 4px;
}

.integrity-result-warn {
  font-size: 12px;
  color: #92400e;
}

@media (max-width: 1024px) {
  .app-brand {
    font-size: 22px;
  }
  .tab-link {
    font-size: 16px;
  }
  h2 {
    font-size: 15px;
  }
  .upload-panels {
    grid-template-columns: 1fr;
  }
  .upload-side-panel {
    min-width: 0;
  }
  .lifeevents-layout {
    grid-template-columns: 1fr;
  }
  .review-layout {
    grid-template-columns: 1fr;
  }
  .integrity-layout {
    grid-template-columns: 1fr;
  }
  .chatv2-shell {
    grid-template-columns: 1fr;
  }
  .chatv2-left,
  .chatv2-main {
    min-height: 0;
  }
  .chatv2-left {
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }
  .chatv2-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .chatv2-search-wrap {
    width: 100%;
  }
  .chatv2-head-row,
  .chatv2-doc-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }
  .chatv2-select-col {
    width: 34px;
  }
  .chatv2-doc-mod,
  .chatv2-doc-size,
  .chatv2-head-row span:nth-child(3),
  .chatv2-head-row span:nth-child(4) {
    display: none;
  }
  .chatv2-composer {
    grid-template-columns: 36px minmax(0, 1fr) 44px 48px;
    padding: 8px 10px;
    gap: 6px;
  }
  .addon-layout {
    grid-template-columns: 1fr;
  }
  .addon-card {
    min-height: 0;
  }
  #askv2Prompt {
    min-height: 24px;
  }
  .documents-inspector-layout {
    grid-template-columns: 1fr;
  }
  .documents-inspector-left {
    min-height: 0;
  }
  .documents-inspector-right {
    max-height: none;
  }
  .documents-inspector-title {
    font-size: 28px;
  }
  .documents-doc-name {
    font-size: 18px;
  }
  .documents-doc-meta {
    font-size: 14px;
  }
  .documents-fields p {
    font-size: 16px;
  }
  .documents-preview-empty,
  .documents-text-preview {
    font-size: 14px;
  }
  .documents-chunk-title {
    font-size: 15px;
  }
  .documents-chunk-text {
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  body {
    padding: 0;
  }

  .app-topbar {
    padding: 0 12px;
    height: 58px;
  }

  .app-brand {
    font-size: 18px;
  }

  .mode-pill {
    padding: 6px 10px;
    font-size: 13px;
  }

  .logout-link {
    font-size: 15px;
  }

  .app-tabs {
    padding: 8px 12px 0;
    gap: 10px;
    overflow-x: auto;
  }

  .tab-link {
    font-size: 16px;
    padding: 10px 12px;
    white-space: nowrap;
  }

  .upload-page {
    padding: 12px;
    margin: 12px;
  }

  .addon-page {
    margin: 12px 12px 70px;
  }

  .integrity-page {
    margin: 12px;
    padding: 12px;
  }

  h2 {
    font-size: 15px;
  }

  .upload-subtitle,
  .upload-caption,
  .upload-warning {
    font-size: 13px;
  }
}
