/* ==============================================
   Outprime HUD Theme
   Single source of truth for all app styles.
   Load after bootstrap.
   ============================================== */

/* ── Variables ── */
:root {
  --text: #0b1220;
  --muted: #596276;
  --line: #dfe4f1;
  --accent: #2563eb;
  --accent2: #7c3aed;
  --bg: #ffffff;
  --bg2: #f4f6fb;
  --card: #ffffff;
  --shadow: 0 18px 45px rgba(11, 18, 32, .08);
  --shadow2: 0 12px 30px rgba(11, 18, 32, .10);
  --cut: 12px;
  --mono: 'IBM Plex Mono', monospace;
  --ui: 'Inter', sans-serif;
  --grid: rgba(11, 18, 32, .05);
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--ui);
  font-size: 16px;
  color: var(--text);
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, .85)),
    radial-gradient(900px 520px at 15% -10%, rgba(124, 58, 237, .14), transparent 60%),
    radial-gradient(900px 520px at 90% 0%, rgba(37, 99, 235, .14), transparent 58%),
    linear-gradient(180deg, #fff 0%, #f4f6fb 100%);
}

/* Grid overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: .6;
  z-index: 0;
}

/* ── HUD corner accents ── */
.corner {
  position: fixed;
  width: 80px;
  height: 80px;
  z-index: 2;
  pointer-events: none;
}

.corner.tl {
  top: 0;
  left: 0;
  border-top: 1.5px solid rgba(37, 99, 235, .3);
  border-left: 1.5px solid rgba(37, 99, 235, .3);
}

.corner.tr {
  top: 0;
  right: 0;
  border-top: 1.5px solid rgba(124, 58, 237, .3);
  border-right: 1.5px solid rgba(124, 58, 237, .3);
}

.corner.bl {
  bottom: 0;
  left: 0;
  border-bottom: 1.5px solid rgba(37, 99, 235, .3);
  border-left: 1.5px solid rgba(37, 99, 235, .3);
}

.corner.br {
  bottom: 0;
  right: 0;
  border-bottom: 1.5px solid rgba(124, 58, 237, .3);
  border-right: 1.5px solid rgba(124, 58, 237, .3);
}

/* ── Status bar ── */
#statusbar {
  flex: 0 0 auto;
  height: 28px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .8px;
  color: var(--muted);
  position: relative;
}

.statusbar-left,
.statusbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 5px #22c55e;
  margin-right: 3px;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .3
  }
}

/* ── Login screen ── */
#loginScreen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  transition: opacity .5s ease, transform .5s ease;
}

#loginScreen.out {
  opacity: 0;
  transform: translateY(-16px);
  pointer-events: none;
}

#loginCard {
  width: 100%;
  max-width: 400px;
  position: relative;
}

/* Card HUD corners */
#loginCard::before,
#loginCard::after,
.lc-corner-bl,
.lc-corner-tr {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 2;
}

#loginCard::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
}

#loginCard::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 2px solid var(--accent2);
  border-right: 2px solid var(--accent2);
}

.lc-corner-bl {
  bottom: -1px;
  left: -1px;
  border-bottom: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
}

.lc-corner-tr {
  top: -1px;
  right: -1px;
  border-top: 2px solid var(--accent2);
  border-right: 2px solid var(--accent2);
}

.lc-inner {
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(11, 18, 32, .1);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px rgba(11, 18, 32, .08), 0 4px 16px rgba(11, 18, 32, .04);
  padding: 36px 32px;
  clip-path: polygon(14px 0%, 100% 0%, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0% 100%, 0% 14px);
  animation: cardIn .4s ease both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

/* Scan line animation on card load */
.lc-scan {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(37, 99, 235, .5), transparent);
  animation: scanDown 1.8s ease forwards;
  z-index: 20;
  pointer-events: none;
}

@keyframes scanDown {
  0% {
    top: 0;
    opacity: 1
  }

  85% {
    opacity: 1
  }

  100% {
    top: 100%;
    opacity: 0
  }
}

.lc-logo {
  text-align: center;
  margin-bottom: 28px;
}

.lc-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  clip-path: polygon(14px 0%, 100% 0%, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0% 100%, 0% 14px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lc-mark::after {
  content: "OP";
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: white;
  letter-spacing: 1px;
}

.lc-name {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text);
}

.lc-sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-top: 3px;
  text-transform: uppercase;
}

.lc-boot {
  margin-bottom: 24px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(37, 99, 235, .03);
  font-family: var(--mono);
}

.lc-boot-line {
  font-size: 10px;
  letter-spacing: .3px;
  color: var(--muted);
  line-height: 1.9;
}

.lc-boot-line .ok {
  color: #16a34a;
}

.lc-boot-line .warn {
  color: #d97706;
}

.lc-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.lc-divider::before,
.lc-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.lc-btn-sso {
  width: 100%;
  padding: 13px 18px;
  background: white;
  border: 1px solid rgba(11, 18, 32, .14);
  color: var(--text);
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  clip-path: polygon(8px 0%, 100% 0%, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0% 100%, 0% 8px);
  transition: all .18s;
  box-shadow: 0 2px 8px rgba(11, 18, 32, .06);
  margin-bottom: 8px;
}

.lc-btn-sso:hover {
  border-color: rgba(37, 99, 235, .3);
  box-shadow: 0 4px 16px rgba(37, 99, 235, .1);
}

.lc-btn-sso:active {
  transform: scale(.99);
}

.lc-btn-secondary {
  width: 100%;
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  clip-path: polygon(6px 0%, 100% 0%, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0% 100%, 0% 6px);
  transition: all .18s;
}

.lc-btn-secondary:hover {
  border-color: rgba(11, 18, 32, .25);
  color: var(--text);
}

.lc-footer {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: .4px;
  text-align: center;
  line-height: 1.8;
}

/* ── Chat shell ── */
#chatShell {
  flex: 1 1 auto;
  min-height: 0;
  /* critical — lets children scroll */
  z-index: 40;
  display: flex;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .5s ease, transform .5s ease;
  pointer-events: none;
  position: relative;
}

#chatShell.in {
  opacity: 1;
  transform: none;
  pointer-events: all;
}

/* ── Sidebar ── */
#sidebar {
  width: 220px;
  min-width: 220px;
  height: 100%;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.sb-brand {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.sb-mark {
  width: 20px;
  height: 20px;
  min-width: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  clip-path: polygon(8px 0%, 100% 0%, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0% 100%, 0% 8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sb-mark::after {
  content: "OP";
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  color: white;
}

.sb-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  font-family: var(--mono);
}

.sb-context {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sb-context-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  font-family: var(--mono);
}

.sb-breadcrumb {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.sb-crumb {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  transition: background .15s;
}

.sb-crumb:hover {
  background: rgba(37, 99, 235, .08);
  color: var(--accent);
}

.sb-crumb.active {
  color: var(--text);
  font-weight: 600;
}

.sb-crumb-sep {
  font-size: 10px;
  color: var(--muted);
  opacity: .4;
}

.sb-threads {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
}

.sb-section-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 7px 7px 2px;
  font-family: var(--mono);
}

.sb-thread-item {
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text);
  transition: background .15s;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 1px;
}

.sb-thread-item:hover {
  background: rgba(11, 18, 32, .05);
}

.sb-thread-item.active {
  background: rgba(37, 99, 235, .08);
  color: var(--accent);
  font-weight: 500;
}

.sb-thread-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sb-thread-time {
  font-size: 9px;
  color: var(--muted);
  flex-shrink: 0;
  font-family: var(--mono);
}

.sb-footer {
  padding: 9px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.sb-new-btn {
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--ui);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all .15s;
}

.sb-new-btn:hover {
  border-color: rgba(37, 99, 235, .3);
  color: var(--accent);
  background: rgba(37, 99, 235, .04);
}

/* ── Workspace ── */
#workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* was: row (default) */
  min-width: 0;
  min-height: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#workspaceRow {
  flex: 1 1 auto;
  display: flex;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* ── Document panel ── */
#docPanel {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .6);
  border-right: 1px solid var(--line);
  overflow: hidden;
  width: 0;
  min-width: 0;
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
  flex-shrink: 0;
  position: relative;
}

:root {
  --doc-panel-width: 55%;
}

#docPanel.open {
  width: var(--doc-panel-width);
}

.doc-scan {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(37, 99, 235, .6), transparent);
  animation: scanD 1s ease forwards;
  pointer-events: none;
  z-index: 10;
}

@keyframes scanD {
  0% {
    top: 0;
    opacity: 1
  }

  90% {
    opacity: 1
  }

  100% {
    top: 100%;
    opacity: 0
  }
}

.doc-topbar {
  height: 44px;
  min-height: 44px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
}

.doc-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-badge {
  font-size: 9px;
  font-family: var(--mono);
  letter-spacing: .8px;
  padding: 2px 7px;
  background: rgba(37, 99, 235, .08);
  border: 1px solid rgba(37, 99, 235, .2);
  color: var(--accent);
  border-radius: 3px;
}

.doc-body {
  flex: 1;
  overflow-y: auto;
}

.doc-section {
  margin-bottom: 20px;
}

.doc-section-title {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  font-family: var(--mono);
}

.doc-field {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
  align-items: baseline;
  margin-bottom: 6px;
}

.doc-label {
  font-size: 11px;
  color: var(--muted);
}

.doc-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.doc-value.editable {
  border-bottom: 1px dashed var(--line);
  cursor: text;
  padding: 1px 3px;
  border-radius: 3px 3px 0 0;
  transition: background .15s, border-color .15s;
}

.doc-value.editable:hover {
  background: rgba(37, 99, 235, .04);
  border-color: rgba(37, 99, 235, .3);
}

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

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.doc-table th {
  padding: 5px 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
}

.doc-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(223, 228, 241, .4);
  color: var(--text);
}

.doc-table tr:last-child td {
  border-bottom: none;
}

.doc-table tr:hover td {
  background: rgba(37, 99, 235, .03);
}

.doc-table .num {
  text-align: right;
  font-family: var(--mono);
}

.doc-total {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: baseline;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.doc-total-label {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
}

.doc-total-val {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text);
}

/* ── Drag divider ── */
#dragDivider {
  width: 0;
  flex-shrink: 0;
  position: relative;
  cursor: col-resize;
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

#dragDivider.visible {
  width: 6px;
}

#dragDividerLine {
  width: 1px;
  height: 100%;
  background: var(--line);
  transition: background .15s;
}

#dragDivider:hover #dragDividerLine,
#dragDivider.dragging #dragDividerLine {
  background: rgba(37, 99, 235, .4);
}

#dragDividerHandle {
  position: absolute;
  width: 18px;
  height: 36px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  opacity: 0;
  transition: opacity .2s;
}

#dragDivider:hover #dragDividerHandle,
#dragDivider.dragging #dragDividerHandle {
  opacity: 1;
}

.divider-dot {
  width: 2px;
  height: 10px;
  background: var(--muted);
  border-radius: 1px;
  opacity: .5;
}

/* ── Chat panel ── */
#chatPanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

#chatTopbar {
  height: 44px;
  min-height: 44px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
}

.chat-ctx {
  flex: 1;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-ctx-active {
  color: var(--text);
  font-weight: 600;
}

.chat-ctx-sep {
  opacity: .4;
}

.btn-open-doc {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--mono);
  background: rgba(37, 99, 235, .06);
  border: 1px solid rgba(37, 99, 235, .2);
  color: var(--accent);
  border-radius: 4px;
  cursor: pointer;
  clip-path: polygon(5px 0%, 100% 0%, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0% 100%, 0% 5px);
  transition: all .15s;
  letter-spacing: .3px;
}

.btn-open-doc:hover {
  background: rgba(37, 99, 235, .12);
  border-color: rgba(37, 99, 235, .4);
}

/* ── Thread ── */
#chatWrapper {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  min-height: 0;
}

#chatThread {
  width: 66%;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  padding: 20px 0 80vh;
}

#chatThread.split {
  width: 100%;
  padding: 16px 16px 80vh;
}

.msg-system {
  text-align: center;
  padding: 5px 20px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .4px;
  font-family: var(--mono);
}

.msg-row {
  padding: 3px 0;
  display: flex;
  animation: fadeUp .18s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(4px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

.msg-row.user {
  justify-content: flex-end;
}

.msg-row.ai {
  justify-content: flex-start;
  align-items: flex-start;
  gap: 7px;
}

.ai-avatar {
  width: 24px;
  height: 24px;
  min-width: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  clip-path: polygon(6px 0%, 100% 0%, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0% 100%, 0% 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  color: white;
  font-family: var(--mono);
  flex-shrink: 0;
}

/* User bubble */
.bubble-user {
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  padding: 8px 13px;
  border-radius: 14px 14px 3px 14px;
  max-width: 72%;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Collapsible long user bubble */
.bubble-long {
  max-width: 84%;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 12px 12px 3px 12px;
  overflow: hidden;
}

.bubble-long-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--line);
  background: rgba(37, 99, 235, .04);
}

.bubble-long-icon {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-size: 14px;
  color: var(--accent);
}

.bubble-long-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .4px;
  flex: 1;
  font-family: var(--mono);
}

.bubble-long-chars {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
}

.bubble-long-body {
  padding: 9px 13px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.bubble-long.collapsed .bubble-long-body {
  max-height: 80px;
  overflow: hidden;
}

.bubble-long.collapsed .bubble-long-body::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: linear-gradient(transparent, rgba(255, 255, 255, .95));
  pointer-events: none;
}

.bubble-long-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 13px;
  border-top: 1px solid var(--line);
  border-left: none;
  border-right: none;
  border-bottom: none;
  width: 100%;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--ui);
  letter-spacing: .3px;
  background: transparent;
  transition: background .15s;
}

.bubble-long-toggle:hover {
  background: rgba(37, 99, 235, .05);
}

.bubble-long-toggle-icon {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-size: 13px;
  transition: transform .2s;
}

.bubble-long.collapsed .bubble-long-toggle-icon {
  transform: rotate(0deg);
}

.bubble-long:not(.collapsed) .bubble-long-toggle-icon {
  transform: rotate(180deg);
}

/* AI bubble */
.bubble-ai {
  width: 600px;
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bubble-ai-text {
  background: rgba(255, 255, 255, .85);
  border: 1px solid var(--line);
  border-radius: 3px 14px 14px 14px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.7;
  backdrop-filter: blur(4px);
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-ai-text ul {
  margin: 6px 0 3px;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bubble-ai-text li {
  font-size: 12px;
  line-height: 1.6;
}

/* Report card in thread */
.bubble-report {
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.bubble-report-header {
  padding: 7px 11px;
  border-bottom: 1px solid var(--line);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
}

.bubble-report-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

.report-table {
  width: 100%;
  border-collapse: collapse;
}

.report-table th {
  padding: 5px 10px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 251, .6);
}

.report-table td {
  padding: 6px 10px;
  font-size: 11px;
  border-bottom: 1px solid rgba(223, 228, 241, .4);
}

.report-table tr:last-child td {
  border-bottom: none;
}

.val {
  font-weight: 600;
  text-align: right;
  font-family: var(--mono);
  font-size: 10px;
}

.report-table tr:hover td {
  background: rgba(37, 99, 235, .03);
}

.report-footer {
  padding: 5px 11px;
  font-size: 9px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: rgba(244, 246, 251, .4);
  font-family: var(--mono);
}

/* Typing indicator */
.bubble-typing {
  display: flex;
  gap: 3px;
  align-items: center;
  padding: 8px 13px;
  background: rgba(255, 255, 255, .85);
  border: 1px solid var(--line);
  border-radius: 3px 14px 14px 14px;
}

.bubble-typing span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}

.bubble-typing span:nth-child(2) {
  animation-delay: .2s;
}

.bubble-typing span:nth-child(3) {
  animation-delay: .4s;
}

@keyframes blink {

  0%,
  80%,
  100% {
    opacity: .2
  }

  40% {
    opacity: 1
  }
}

/* Context pill (AI response linking to entity) */
.ctx-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  background: rgba(37, 99, 235, .06);
  border: 1px solid rgba(37, 99, 235, .15);
  font-size: 10px;
  color: var(--accent);
  font-family: var(--mono);
  cursor: pointer;
  transition: background .15s;
  margin: 2px 0;
}

.ctx-pill:hover {
  background: rgba(37, 99, 235, .12);
}

.ctx-pill-icon {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-size: 12px;
}

/* ── Chat input ── */
#chatInputArea {
  flex-shrink: 0;
  padding: 8px 16px 12px;
  background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-input-outer {
  width: 100%;
  max-width: 620px;
}

.chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, .98);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 7px 7px 7px 12px;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 2px 10px rgba(11, 18, 32, .05);
}

.chat-input-wrap:focus-within {
  border-color: rgba(37, 99, 235, .45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

#chatInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-family: var(--ui);
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  max-height: 110px;
  overflow-y: auto;
  padding: 2px 0;
}

#chatInput::placeholder {
  color: var(--muted);
}

#sendBtn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: opacity .15s, transform .1s;
  clip-path: polygon(5px 0%, 100% 0%, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0% 100%, 0% 5px);
  flex-shrink: 0;
}

#sendBtn:hover {
  opacity: .88;
  transform: translateY(-1px);
}

#sendBtn:disabled {
  opacity: .35;
  cursor: default;
  transform: none;
}

#sendBtn svg {
  width: 13px;
  height: 13px;
}

.chat-input-hint {
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
  text-align: center;
  font-family: var(--mono);
}

/* ── Shared icon button ── */
.icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 5px;
  color: var(--muted);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Material Symbols Rounded', sans-serif;
  transition: background .15s, color .15s;
}

.icon-btn:hover {
  background: rgba(11, 18, 32, .06);
  color: var(--text);
}

/* ── Transitions ── */
.fade-out {
  opacity: 0;
  transition: opacity .45s ease;
}

.fade-in {
  opacity: 1;
  transition: opacity .6s ease;
}

/* ── HUD helpers (used by legacy domain templates) ── */
.poly {
  clip-path: polygon(var(--cut) 0%, calc(100% - var(--cut)) 0%, 100% var(--cut),
      100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%,
      var(--cut) 100%, 0% calc(100% - var(--cut)), 0% var(--cut));
}

.hudFrame {
  position: relative;
  border: 1px solid rgba(11, 18, 32, .18);
  background: rgba(255, 255, 255, .74);
  box-shadow: var(--shadow2);
}

/* ── Bootstrap table overrides (for entity views) ── */
.table {
  --bs-table-bg: rgba(255, 255, 255, .74);
  border-color: rgba(11, 18, 32, .14);
}

.table thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .35px;
  color: var(--muted);
}

.table-hover tbody tr:hover {
  background-color: rgba(37, 99, 235, .06);
}

/* ── Hub / report tables (used by domain JS) ── */
.hub-table-frame {
  background: rgb(249, 249, 249);
  position: relative;
  padding: 16px 32px;
  border: 1px solid lightgray;
}

.hub-table-frame::before,
.hub-table-frame::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid rgba(11, 18, 32, .35);
}

.hub-table-frame::before {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}

.hub-table-frame::after {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
}

.hub-row {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(11, 18, 32, .10);
  font-size: 14px;
}

.hub-row.report {
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  column-gap: .5rem;
}

.hub-row.documents {
  grid-template-columns: 1fr 2fr 1fr 1fr 1fr;
  column-gap: .5rem;
}

.hub-row.report.header {
  font-weight: bold;
}

.hub-label {
  text-align: left;
  font-weight: 600;
  letter-spacing: .4px;
}

.hub-value {
  text-align: left;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.report-container {
  padding: 2rem;
  height: 100%;
  flex: 67;
}

.report-insight {
  padding: 2rem;
  flex: 33;
}

.chart-wrapper {
  width: 100%;
  height: calc(100vh - 340px);
  position: relative;
}

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

.panel-title {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}

.panel-body {
  font-size: 14px;
  color: #111827;
}

/* ── MDI (multi-document interface tabs) ── */
#mdi {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#mdiTabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .9);
}

#mdiViews {
  flex: 1;
  overflow: hidden;
}

/* Collection view inside doc panel */
.doc-collection-body {
  padding: 0;
}

.doc-row-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.doc-row-table thead {
  position: sticky;
  top: 0;
  background: #fafafa;
  z-index: 1;
}

.doc-row-th {
  text-align: left;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 500;
  white-space: nowrap;
}

.doc-row {
  cursor: pointer;
  transition: background-color .12s;
}

.doc-row:hover {
  background: #f9fafb;
}

.doc-row>td {
  padding: 10px 16px;
  border-bottom: 1px dashed var(--line);
  vertical-align: middle;
}

.doc-row-key {
  white-space: nowrap;
}

.doc-row-key-value {
  font-weight: 600;
  color: #111;
  margin-right: 8px;
}

.doc-row-badge {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .5px;
  color: #6b7280;
  background: #fff;
  vertical-align: middle;
}

.doc-row-cell {
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.doc-row-cell-status {
  color: #d97706;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .5px;
  text-transform: uppercase;
}




/* Collection footer / pagination */
.doc-collection-footer {
  flex-shrink: 0;
  height: 40px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .5px;
}

.doc-page-info {
  text-transform: uppercase;
}

.doc-per-page {
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc-per-page select {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 6px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 3px;
  cursor: pointer;
  outline: none;
}

.doc-pager {
  display: flex;
  align-items: center;
  gap: 2px;
}

.doc-pager button {
  min-width: 26px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  border-radius: 3px;
  transition: all .12s;
}

.doc-pager button:hover:not(:disabled) {
  background: rgba(37, 99, 235, .06);
  color: var(--accent);
  border-color: rgba(37, 99, 235, .2);
}

.doc-pager button.active {
  background: rgba(37, 99, 235, .1);
  color: var(--accent);
  border-color: rgba(37, 99, 235, .3);
  font-weight: 600;
}

.doc-pager button:disabled {
  opacity: .3;
  cursor: default;
}

.doc-pager-ellipsis {
  color: var(--muted);
  padding: 0 4px;
  opacity: .5;
}

/* Search in topbar */
.tbl-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  width: 220px;
  transition: border-color .15s, box-shadow .15s;
}

.tbl-search:focus-within {
  border-color: rgba(37, 99, 235, .4);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

.tbl-search-icon {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-size: 13px;
  color: var(--muted);
}

.tbl-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--ui);
  font-size: 12px;
  color: var(--text);
  min-width: 0;
}

.tbl-search input::placeholder {
  color: var(--muted);
}

.tbl-search-clear {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-family: 'Material Symbols Rounded', sans-serif;
  font-size: 13px;
  display: none;
}

.tbl-search.has-value .tbl-search-clear {
  display: block;
}

.tbl-search-clear:hover {
  color: var(--text);
}

/* Empty state */
.doc-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 12px;
}

.doc-empty-icon {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-size: 28px;
  opacity: .4;
  display: block;
  margin-bottom: 6px;
}

.single-value-card {
  padding: 16px 0;
}

.single-value-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.single-value-number {
  font-size: 28px;
  font-weight: 600;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}

.report-list-row {
  cursor: pointer;
}

.report-list-row:hover td {
  background: #f9fafb;
}

.bubble-report-count {
  margin-left: 10px;
  font-size: 11px;
  color: #6b7280;
  font-weight: normal;
}

.report-empty {
  padding: 16px;
  color: #6b7280;
  font-style: italic;
  text-align: center;
}