
:root {
  --ink: #0f0e0d;
  --paper: #ffffff;
  --cream: #ffffff;
  --gold: #00843D;
  --gold-light: #fff;
  --rust: #0066B3;
  --avaada-gradient: linear-gradient(90deg, #0066B3 0%, #00843D 100%);
  --forest: #1a3a2a;
  --navy: #0f1f3d;
  --blue: #1e40af;
  --blue-light: #dbeafe;
  --mist: #64748b;
  --white: #ffffff;
  --border: #e2e8f0;
  --shadow: rgba(15,14,13,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

.is-hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.spinner-navy {
  width: 11px;
  height: 11px;
  border: 2px solid var(--navy);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.bot-avatar-brand { background: #0066B3; }

body {
  font-family: 'DM Sans', sans-serif;
  background: linear-gradient(180deg, #9ed0ee 0%, #d8ecfa 46%, #f2f8fd 100%);
  color: var(--ink);
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(50% 24% at 16% 24%, rgba(255, 255, 255, 0.78) 0%, rgba(255, 255, 255, 0) 100%),
    radial-gradient(48% 22% at 52% 18%, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0) 100%),
    radial-gradient(54% 25% at 86% 30%, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(68% 30% at 12% 100%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 100%),
    radial-gradient(72% 34% at 52% 108%, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0) 100%),
    radial-gradient(62% 28% at 92% 104%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
  z-index: -1;
}

/* ── VIEWS ── */
.view { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: auto; }
.view.active { display: flex; }
/* Tool views: fill height so both panels stay equal; solid white background */
#view-po,
#view-universal { overflow: hidden; background: transparent; }

/* ── HEADER ── */
header {
  background: var(--white);
  color: var(--ink);
  padding: 0 2.5rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 68px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
}
header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: #003d82;
}

.logo { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.logo-icon { width: 80px; height: 80px; background: transparent; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 17px; overflow: hidden; flex-shrink: 0; }
.logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.logo-text { font-family: 'Playfair Display', serif; font-size: 1.4rem; font-weight: 700; color: #003d82; }
.logo-sub { font-size: 0.62rem; letter-spacing: 0.15em; text-transform: uppercase; color: #4a4a4a; font-weight: 300; }

.header-right { display: flex; align-items: center; gap: 12px; }
.back-btn { display: none; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--border); color: var(--ink); border-radius: 6px; padding: 6px 14px; font-size: 0.78rem; font-family: 'DM Sans', sans-serif; cursor: pointer; transition: all 0.15s; }
.back-btn:hover { background: var(--cream); }
.back-btn.visible { display: flex; }
.back-to-upload-btn.visible { display: flex; }

/* Header History dropdown (tool-specific: only when inside PO or Universal tool) */
.header-history-wrap { position: relative; display: flex; align-items: center; }
.header-history-btn { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--border); color: var(--ink); border-radius: 6px; padding: 6px 14px; font-size: 0.78rem; font-family: 'DM Sans', sans-serif; cursor: pointer; transition: all 0.15s; }
.header-history-btn:hover { background: var(--cream); }
.header-history-dropdown { display: none; position: absolute; top: 100%; right: 0; margin-top: 6px; width: 320px; max-height: 420px; background: var(--white); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px var(--shadow); z-index: 200; overflow: hidden; flex-direction: column; }
.header-history-dropdown.open { display: flex; }
.hist-dropdown-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; color: var(--mist); padding: 10px 14px; border-bottom: 1px solid var(--border); }
.hist-dropdown-list { overflow-y: auto; padding: 8px; flex: 1; max-height: 360px; }
.hist-doc-item { border-radius: 8px; margin-bottom: 6px; border: 1px solid var(--border); overflow: hidden; }
.hist-doc-item:last-child { margin-bottom: 0; }
.hist-doc-item .hist-doc-head { border-left: 3px solid var(--forest); }
.hist-doc-item .hist-doc-head.u-doc { border-left-color: var(--navy); }
.hist-doc-item.expanded .hist-doc-toggle { transform: rotate(180deg); }
.hist-doc-item .hist-doc-chats { display: none; padding: 8px 12px 12px; background: var(--paper); border-top: 1px solid var(--border); max-height: 220px; overflow-y: auto; }
.hist-doc-item.expanded .hist-doc-chats { display: block; }
.hist-doc-chats .hist-chat-q { font-weight: 600; color: var(--forest); margin-bottom: 2px; }
.hist-doc-chats .hist-chat-q.u-doc { color: var(--navy); }
.hist-doc-chats .hist-chat-a { color: var(--mist); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Header user profile + sign out */
.header-user-wrap { position: relative; display: none; align-items: center; margin-left: 8px; }
.header-user-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff;
  padding: 0; background: var(--cream); cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.header-user-btn:hover { border-color: #0066B3; box-shadow: 0 0 0 2px rgba(0,102,179,0.2); }
.header-user-avatar {
  width: 100%; height: 100%; object-fit: cover; display: none;
}
.header-user-avatar.loaded { display: block; }
.header-user-fallback {
  font-size: 0.85rem; font-weight: 600; color: #fff;
  display: none; width: 100%; height: 100%; align-items: center; justify-content: center; background: var(--avaada-gradient); color: #fff;
}
.header-user-fallback.visible { display: flex; }
.header-user-dropdown {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 6px;
  min-width: 280px; background: var(--white); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px var(--shadow); z-index: 200;
  overflow: hidden; flex-direction: column; padding: 6px 0;
}
.header-user-dropdown.open { display: flex; }
.header-user-info {
  padding: 10px 14px; font-size: 0.78rem; color: var(--mist);
  border-bottom: 1px solid var(--border); line-height: 1.4;
}
.header-user-info .header-user-name { font-weight: 600; color: var(--ink); display: block; margin-bottom: 2px; }
.header-user-info .header-user-email { font-size: 0.72rem; color: var(--mist); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-user-signout {
  display: block; width: 100%; text-align: left; padding: 8px 14px; font-size: 0.8rem; font-weight: 500;
  color: #0066B3; background: none; border: none; cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: background 0.15s;
}
.header-user-signout:hover { background: rgba(0,102,179,0.08); color: #0066B3; }

/* Sign out confirmation modal (in-app) */
.signout-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,14,13,0.4); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px); z-index: 350; align-items: center; justify-content: center; padding: 1.5rem;
}
.signout-modal-backdrop.open { display: flex; }
.signout-modal-box {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 16px 48px var(--shadow); padding: 1.5rem 1.5rem 1.25rem;
  max-width: 360px; width: 100%;
}
.signout-modal-text {
  font-size: 0.9rem; color: var(--ink); line-height: 1.5; margin: 0 0 1.25rem;
}
.signout-modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
}
.signout-modal-cancel {
  padding: 8px 16px; font-size: 0.8rem; font-weight: 500; border: 1px solid var(--border);
  background: var(--white); color: var(--ink); border-radius: 8px; cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: background 0.15s, border-color 0.15s;
}
.signout-modal-cancel:hover { background: var(--cream); border-color: var(--mist); }
.signout-modal-confirm {
  padding: 8px 16px; font-size: 0.8rem; font-weight: 600; border: none;
  background: var(--avaada-gradient); color: var(--white); border-radius: 8px; cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: background 0.15s;
}
.signout-modal-confirm:hover { opacity: 0.92; filter: brightness(1.05); }

/* Left panel document rows (tool history) */
.hist-doc-row { padding: 0; }
.hist-doc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; cursor: pointer; transition: background 0.15s; }
.hist-doc-head:hover { background: var(--cream); }
.hist-doc-row .hist-doc-head { border-left: 3px solid var(--forest); }
.tool-history-section.blue .hist-doc-row .hist-doc-head { border-left-color: var(--navy); }
.hist-doc-name { font-size: 0.8rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.hist-doc-date { font-size: 0.65rem; color: var(--mist); flex-shrink: 0; }
.hist-doc-toggle { font-size: 0.7rem; color: var(--mist); transition: transform 0.2s; }
.hist-doc-row.expanded .hist-doc-toggle { transform: rotate(180deg); }
.hist-doc-row .hist-doc-chats { display: none; padding: 8px 12px; background: #ffffff; border-top: 1px solid var(--border); max-height: 180px; overflow-y: auto; }
.hist-doc-row.expanded .hist-doc-chats { display: block; }
.hist-chat-row { font-size: 0.72rem; padding: 6px 0; border-bottom: 1px solid var(--border); }
.hist-chat-row:last-child { border-bottom: none; }
.hist-empty { text-align: center; color: var(--mist); font-size: 0.78rem; padding: 2rem 1rem; }

/* History modal popup (documents for current tool) */
.history-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,14,13,0.4); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 300;
  align-items: center; justify-content: center; padding: 1.5rem;
}
.history-modal-backdrop.open { display: flex; }
.history-modal-box {
  background: var(--white); border-radius: 14px; box-shadow: 0 16px 48px var(--shadow);
  width: 100%; max-width: 560px; max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column; border: 1px solid var(--border);
}
.history-modal-header {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
  border-bottom: 1px solid var(--border); background: var(--cream); flex-shrink: 0;
}
.history-modal-title { font-size: 0.9rem; font-weight: 700; color: var(--ink); font-family: 'DM Sans', sans-serif; }
.history-modal-close {
  width: 32px; height: 32px; border: none; border-radius: 8px; background: rgba(0,0,0,0.06);
  cursor: pointer; font-size: 1.1rem; color: var(--mist); display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.history-modal-close:hover { background: rgba(0,0,0,0.1); color: var(--ink); }
.history-modal-list { overflow-y: auto; padding: 12px; flex: 1; max-height: 560px; min-height: 320px; }
.history-modal-list .hist-doc-item { margin-bottom: 10px; }
.history-modal-list .hist-doc-item:last-child { margin-bottom: 0; }

/* ── LANDING PAGE ── */
#view-landing {
  background: transparent;
  overflow: hidden;
  justify-content: center;
  align-items: center;
}

.landing-hero {
  text-align: center;
  padding: 5rem 2rem 3rem;
  max-width: 700px;
  margin: 0 auto;
}

.hero-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #0066B3;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  color: var(--forest);
  line-height: 1.15;
  margin-bottom: 1.2rem;
}

.hero-title em { color: #0066B3; font-style: normal; }

.hero-sub {
  font-size: 1rem;
  color: var(--mist);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto 3rem;
}

/* API Key landing input */
.api-landing-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  margin: 0 auto 3.5rem;
  box-shadow: 0 2px 12px var(--shadow);
}

.api-landing-label {
  font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--mist); font-weight: 600; margin-bottom: 8px; display: block;
}

.api-landing-row { display: flex; gap: 8px; }
.api-landing-row input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-family: monospace; font-size: 0.8rem; background: var(--paper); color: var(--ink);
  outline: none; transition: border-color 0.15s;
}
.api-landing-row input:focus { border-color: #0066B3; }
.api-hint { font-size: 0.7rem; color: var(--mist); margin-top: 6px; }

/* Tool cards */
.cards-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
}

.cards-label {
  font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--mist); font-weight: 600; text-align: center; margin-bottom: 1.5rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

.tool-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 2.2rem 2rem;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(.4,0,.2,1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px var(--shadow);
}

.card-top {
  flex: 1;
  min-height: 0;
}

.tool-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  transition: opacity 0.2s;
}

.tool-card.po::before { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); }
.tool-card.universal::before { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); }

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px var(--shadow);
  border-color: transparent;
}

.tool-card.po:hover { border-color: #00843D; }
.tool-card.universal:hover { border-color: #0066B3; }

.card-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 1.2rem;
}

.po .card-icon { background: rgba(0,132,61,0.12); }
.universal .card-icon { background: rgba(0,102,179,0.12); }

.card-tag {
  font-size: 0.62rem; letter-spacing: 0.15em; text-transform: uppercase;
  font-weight: 700; margin-bottom: 0.5rem; display: block;
}

.po .card-tag { color: #0066B3; }
.universal .card-tag { color: #0066B3; }

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem; font-weight: 700;
  color: var(--ink); line-height: 1.2; margin-bottom: 0.8rem;
}
.po .card-title { color: #0066B3; }
.universal .card-title { color: #0066B3; }

.card-desc {
  font-size: 0.83rem; color: var(--mist); line-height: 1.65; margin-bottom: 1.4rem;
}

.card-features {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 1.6rem;
}

.card-feature {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 0.78rem; color: var(--ink); line-height: 1.4;
}

.feature-dot {
  width: 5px; height: 5px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
}

.po .feature-dot { background: #00843D; }
.universal .feature-dot { background: #0066B3; }

.card-cta {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 600; padding: 10px 20px;
  border-radius: 8px; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: all 0.15s;
}

.po .card-cta,
.universal .card-cta {
  background: linear-gradient(90deg, #0066B3 0%, #00843D 100%);
  color: #fff;
}
.po .card-cta:hover,
.universal .card-cta:hover {
  opacity: 0.92;
}

/* ── SHARED TOOL LAYOUT ── */
.tool-layout {
  flex: 1;
  min-height: 0;
  height: 100%;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 4rem 2rem 4.5rem;
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  grid-template-rows: 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

/* Both panels same height: stretch to full grid row */
.tool-layout > .panel {
  height: 100%;
  min-height: 0;
}

/* When viewing a document from History: hide upload panel, show only summary */
.tool-layout.summary-only > .panel:first-child { display: none; }
.tool-layout.summary-only { grid-template-columns: 1fr; padding: 2rem 4rem; }

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  padding: 1rem 1.4rem; border-bottom: 1px solid var(--border);
  background: var(--cream); display: flex; align-items: center; gap: 10px;
}

.panel-header h2 { font-family: 'Playfair Display', serif; font-size: 0.95rem; font-weight: 600; color: var(--navy); flex: 1; }
#view-po .panel-header h2 { color: #0A427D; }
#view-po .panel-header .panel-icon { background: #0A427D; color: #fff; }
#view-universal .panel-header h2 { color: #0A427D; }
#view-universal .panel-header .panel-icon.blue { background: #0A427D; color: #fff; }
.panel-icon { width: 26px; height: 26px; background: var(--navy); border-radius: 5px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; }
.panel-icon.blue { background: var(--navy); color: #fff; }

.panel-body { padding: 1.4rem; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1rem; overflow-y: auto; }

/* Forms */
label.field-label { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: #0066B3; font-weight: 600; display: block; margin-bottom: 5px; }

input[type="text"], textarea {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--border); border-radius: 7px;
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem;
  background: var(--paper); color: var(--ink); outline: none; transition: border-color 0.15s;
  resize: none;
}
input[type="text"]:focus, textarea:focus { border-color: #0066B3; background: var(--white); }
input[type="text"].blue-focus:focus { border-color: var(--blue); }

.upload-zone {
  border: 2px dashed #0066B3; border-radius: 10px; padding: 2rem 1rem;
  text-align: center; cursor: pointer; transition: all 0.2s; background: #fff;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: #00843D; background: rgba(0,102,179,0.04); }
.upload-zone.blue:hover, .upload-zone.blue.drag-over { border-color: var(--blue); background: rgba(30,64,175,0.03); }
.upload-zone input { display: none; }
.upload-icon {
  font-size: 0;
  line-height: 0;
  display: block;
  margin-bottom: 0.6rem;
  color: transparent;
  overflow: hidden;
}
.upload-icon::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%230066B3' d='M30 6h-4V4c0-1.1-.9-2-2-2h-8c-1.1 0-2 .9-2 2v2h-4c-1.1 0-2 .9-2 2v32c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-12-2h8v2h-8V4zm10 34H14V12h14v26z'/%3E%3Crect x='18' y='18' width='12' height='2' rx='0.5' fill='%230066B3' opacity='0.7'/%3E%3Crect x='18' y='23' width='12' height='2' rx='0.5' fill='%230066B3' opacity='0.7'/%3E%3Crect x='18' y='28' width='8' height='2' rx='0.5' fill='%230066B3' opacity='0.7'/%3E%3C/svg%3E") no-repeat center / contain;
}
.upload-zone.blue .upload-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%230066B3' d='M30 6h-4V4c0-1.1-.9-2-2-2h-8c-1.1 0-2 .9-2 2v2h-4c-1.1 0-2 .9-2 2v32c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-12-2h8v2h-8V4zm10 34H14V12h14v26z'/%3E%3Crect x='18' y='18' width='12' height='2' rx='0.5' fill='%230066B3' opacity='0.7'/%3E%3Crect x='18' y='23' width='12' height='2' rx='0.5' fill='%230066B3' opacity='0.7'/%3E%3Crect x='18' y='28' width='8' height='2' rx='0.5' fill='%230066B3' opacity='0.7'/%3E%3C/svg%3E");
}
.upload-title { font-family: 'Playfair Display', serif; font-size: 0.9rem; color: #0f1f3d; margin-bottom: 0.25rem; }
.upload-sub { font-size: 0.72rem; color: #0066B3; line-height: 1.5; }

.file-chip { display: flex; align-items: center; gap: 10px; background: var(--cream); border: 1px solid var(--border); border-radius: 7px; padding: 8px 12px; font-size: 0.8rem; }
.file-chip .name { flex: 1; font-weight: 500; color: var(--forest); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .sz { color: var(--mist); font-size: 0.7rem; }
.file-chip .rm { cursor: pointer; color: var(--mist); padding: 0 4px; }
.file-chip .rm:hover { color: #0066B3; }

.status-bar { display: flex; align-items: center; gap: 10px; padding: 9px 13px; border-radius: 7px; font-size: 0.78rem; font-weight: 500; }
.status-bar.processing { background: rgba(0,102,179,0.08); color: #0066B3; border: 1px solid rgba(0,102,179,0.2); }
.status-bar.success { background: rgba(0,132,61,0.08); color: #00843D; border: 1px solid rgba(0,132,61,0.2); }
.status-bar.error { background: rgba(0,102,179,0.08); color: #0066B3; border: 1px solid rgba(0,102,179,0.2); }
.status-bar.blue-proc { background: rgba(30,64,175,0.06); color: var(--navy); border: 1px solid rgba(30,64,175,0.2); }

.spinner { width: 13px; height: 13px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

button { font-family: 'DM Sans', sans-serif; cursor: pointer; border: none; border-radius: 7px; font-weight: 500; transition: all 0.15s; }

.btn-primary { background: var(--forest); color: #fff; padding: 11px 20px; font-size: 0.85rem; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary:hover { background: #0d2d1f; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
/* Generate Executive Summary: Avaada gradient (blue → green) */
#view-po .btn-primary#po-generateBtn { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); color: #fff; }
#view-po .btn-primary#po-generateBtn:hover:not(:disabled) { opacity: 0.92; filter: brightness(1.05); }
#view-po .btn-primary#po-generateBtn:disabled { opacity: 0.45; filter: none; }
.btn-primary.blue { background: var(--navy); color: #bfdbfe; }
.btn-primary.blue:hover { background: #0a1628; }
#view-universal .btn-primary.blue#u-generateBtn { background: #0A427D; color: #fff; }
#view-universal .btn-primary.blue#u-generateBtn:hover:not(:disabled) { background: #083a6b; }

.btn-secondary { background: transparent; color: var(--forest); padding: 8px 14px; font-size: 0.78rem; border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--forest); background: var(--cream); }

.btn-gold { background: var(--avaada-gradient); color: #fff; padding: 9px 18px; font-size: 0.8rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.btn-gold:hover { opacity: 0.92; filter: brightness(1.05); }

.btn-blue-export { background: var(--navy); color: #bfdbfe; padding: 9px 18px; font-size: 0.8rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.btn-blue-export:hover { background: #0a1628; }

.divider { height: 1px; background: var(--border); }

.action-row { display: flex; gap: 8px; padding: 0.9rem 1.4rem; border-top: 1px solid var(--border); background: var(--cream); }

/* Q&A */
.qa-section { border-top: 1px solid var(--border); padding-top: 1rem; }
.qa-input-row { display: flex; gap: 8px; }
.qa-input-row input { flex: 1; }
.btn-ask { background: var(--forest); color: #fff; padding: 9px 16px; font-size: 0.8rem; white-space: nowrap; }
.btn-ask:hover { background: #0d2d1f; }
.btn-ask:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ask.blue { background: var(--navy); color: #bfdbfe; }
.btn-ask.blue:hover { background: #0a1628; }

.qa-history { margin-top: 0.9rem; display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.qa-q { font-size: 0.78rem; font-weight: 600; color: var(--forest); margin-bottom: 4px; display: flex; gap: 6px; align-items: flex-start; }
.qa-q::before { content: 'Q'; background: var(--forest); color: #fff; border-radius: 3px; padding: 0 5px; font-size: 0.62rem; margin-top: 2px; flex-shrink: 0; }
.qa-q.blue-q { color: var(--navy); }
.qa-q.blue-q::before { background: var(--navy); color: #93c5fd; }
.qa-a { font-size: 0.8rem; color: var(--ink); line-height: 1.6; border-left: 2px solid #0066B3; margin-left: 12px; padding-left: 10px; }
.qa-a.blue-a { border-left-color: var(--blue); }

/* Summary output panel */
.summary-output { flex: 1; min-height: 0; overflow-y: auto; }
.empty-state { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--mist); text-align: center; padding: 3rem 2rem; }
.empty-icon { font-size: 2.8rem; margin-bottom: 1rem; opacity: 0.35; }
.empty-text { font-family: 'Playfair Display', serif; font-size: 0.9rem; color: var(--ink); opacity: 0.45; margin-bottom: 0.4rem; }
.empty-sub { font-size: 0.72rem; line-height: 1.6; }

/* PO Summary styles */
.summary-block { margin-bottom: 0.4rem; }
.summary-section { display: flex; align-items: center; gap: 4px; margin-bottom: 0.2rem; }
.section-tag { font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: #0066B3; font-weight: 600; white-space: nowrap; }
.section-line { flex: 1; height: 1px; background: var(--border); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.kv-item { background: var(--paper); border: 1px solid var(--border); border-radius: 5px; padding: 5px 7px; }
.kv-key { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: #0066B3; margin-bottom: 1px; }
.kv-value { font-size: 0.82rem; font-weight: 500; color: var(--ink); line-height: 1.3; }
.kv-item.highlight { border-color: #0066B3; background: rgba(0,102,179,0.06); }
.kv-item.highlight .kv-value { color: var(--forest); font-weight: 600; }
.scope-text { background: var(--paper); border: 1px solid var(--border); border-left: 3px solid #0066B3; border-radius: 0 5px 5px 0; padding: 6px 8px; font-size: 0.83rem; line-height: 1.35; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.contact-card { background: var(--paper); border: 1px solid var(--border); border-radius: 5px; padding: 6px 8px; }
.contact-role { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mist); margin-bottom: 2px; font-weight: 600; }
.contact-name { font-size: 0.87rem; font-weight: 600; color: var(--forest); margin-bottom: 1px; }
.contact-detail { font-size: 0.77rem; color: var(--ink); line-height: 1.35; }
.terms-table { border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.terms-row { display: grid; grid-template-columns: 150px 1fr; border-bottom: 1px solid var(--border); }
.terms-label { padding: 5px 8px; background: var(--cream); font-size: 0.75rem; font-weight: 600; color: var(--forest); border-right: 1px solid var(--border); display: flex; flex-direction: column; justify-content: flex-start; line-height: 1.3; }
.terms-value { padding: 5px 8px; font-size: 0.82rem; color: var(--ink); line-height: 1.35; }
.stage-item { display: flex; gap: 5px; align-items: flex-start; margin-bottom: 2px; font-size: 0.8rem; line-height: 1.35; }
.stage-num { background: var(--forest); color: #fff; border-radius: 50%; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-size: 0.6rem; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.badge-yes { display: inline-block; background: rgba(26,58,42,0.12); color: var(--forest); border: 1px solid rgba(26,58,42,0.25); border-radius: 4px; padding: 1px 9px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; }
.badge-no { display: inline-block; background: rgba(138,130,120,0.1); color: var(--mist); border: 1px solid var(--border); border-radius: 4px; padding: 1px 9px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; }
.badge-na { display: inline-block; color: var(--mist); font-size: 0.75rem; }
.obligations-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.obligation-col { border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.obligation-header { padding: 5px 9px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
.owner-header { background: rgba(26,58,42,0.08); color: var(--forest); border-bottom: 1px solid rgba(26,58,42,0.15); }
.contractor-header { background: rgba(0,102,179,0.08); color: #0066B3; border-bottom: 1px solid rgba(0,102,179,0.2); }
.obligation-item { display: flex; gap: 5px; align-items: flex-start; padding: 4px 8px; font-size: 0.78rem; line-height: 1.35; border-bottom: 1px solid var(--border); }
.obligation-item:last-child { border-bottom: none; }
.obs-dot { width: 5px; height: 5px; background: var(--forest); border-radius: 50%; margin-top: 3px; flex-shrink: 0; }
.contractor-dot { background: #00843D; }
.risk-item { display: flex; align-items: flex-start; gap: 5px; padding: 4px 7px; background: rgba(0,102,179,0.04); border: 1px solid rgba(0,102,179,0.14); border-radius: 5px; margin-bottom: 2px; font-size: 0.8rem; line-height: 1.35; }
.risk-dot { width: 5px; height: 5px; background: #0066B3; border-radius: 50%; margin-top: 3px; flex-shrink: 0; }

/* Universal summary styles */
.u-section { margin-bottom: 0.4rem; }
.u-section-header { display: flex; align-items: center; gap: 4px; margin-bottom: 0.2rem; }
.u-section-tag { font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: #6b8cc9; font-weight: 600; white-space: nowrap; }
.u-section-line { flex: 1; height: 1px; background: #dbeafe; }
.u-prose { background: #f0f5ff; border: 1px solid #dbeafe; border-left: 3px solid var(--blue); border-radius: 0 5px 5px 0; padding: 6px 8px; font-size: 0.83rem; line-height: 1.35; color: var(--ink); }
.u-kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.u-kv-item { background: #f8faff; border: 1px solid #dbeafe; border-radius: 5px; padding: 5px 7px; }
.u-kv-key { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: #6b8cc9; margin-bottom: 1px; }
.u-kv-value { font-size: 0.82rem; font-weight: 500; color: var(--ink); line-height: 1.3; }
.u-kv-item.hl { border-color: var(--blue); background: #eff6ff; }
.u-kv-item.hl .u-kv-value { color: var(--navy); font-weight: 600; }
.u-bullet { display: flex; gap: 5px; align-items: flex-start; padding: 2px 0; font-size: 0.8rem; line-height: 1.35; border-bottom: 1px solid #e8f0fe; }
.u-bullet:last-child { border-bottom: none; }
.u-bdot { width: 5px; height: 5px; background: var(--blue); border-radius: 50%; margin-top: 3px; flex-shrink: 0; }
.u-bullets-wrap { background: #f8faff; border: 1px solid #dbeafe; border-radius: 5px; padding: 3px 8px; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.text-xs { font-size: 0.7rem; color: var(--mist); }

/* ═══════════════ FULL-PAGE CHAT INTERFACE ═══════════════ */
#view-chat {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  background: transparent;
  overflow: hidden;
}
#view-chat.active {
  display: flex;
}
.chat-page-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
/* Chat app header (PO Summaries style) */
.chat-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-app-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.chat-app-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  flex-shrink: 0;
}
.chat-page-wrap.po-theme .chat-app-logo { color: var(--forest); }
.chat-app-brand { min-width: 0; }
.chat-app-brand-name {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 2px;
}
.chat-app-brand-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--mist);
  line-height: 1.3;
}
.chat-app-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-app-icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.chat-app-icon-btn:hover:not(:disabled) { background: #f1f5f9; color: var(--ink); }
.chat-app-icon-btn:disabled { opacity: 0.5; cursor: default; }
.chat-page-messages-slot {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--white);
  padding: 0 1.5rem 0 1rem;
  overflow: hidden;
}
.chat-page-messages-slot .chatbot-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem 1.5rem 1.5rem 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: transparent;
  max-height: none;
  scroll-behavior: smooth;
}
.chat-page-messages-slot .chatbot-messages::-webkit-scrollbar { width: 6px; }
.chat-page-messages-slot .chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chat-page-messages-slot .chatbot-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
.chat-page-messages-slot .chatbot-messages::-webkit-scrollbar-thumb:hover { background: var(--mist); }

/* Chat page: message bubbles (light grey bot, timestamp inside) */
.chat-page-messages-slot .chat-msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 85%;
}
.chat-page-messages-slot .user-msg {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-page-messages-slot .bot-msg { align-self: flex-start; }
.chat-page-messages-slot .bot-msg .bot-avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #e5e7eb !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-page-messages-slot .bot-msg .bot-avatar-sm svg { opacity: 0.7; }
.chat-page-messages-slot .chat-bubble {
  padding: 10px 14px 8px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: flex-start;
}
.chat-page-messages-slot .chat-bubble-text { flex: 0 1 auto; min-width: 0; }
/* Timestamp under each message (e.g. 12:01) - small & grey, tight to content */
.chat-page-messages-slot .chat-bubble-time {
  font-size: 0.5rem;
  color: #9ca3af;
  margin-top: 2px;
  flex-shrink: 0;
}
/* Same for chatbot popup (Executive PO Summarizer, etc.) */
.chatbot-popup .chat-bubble-time {
  font-size: 0.5rem;
  color: #9ca3af;
  margin-top: 2px;
}
.chat-page-messages-slot .bot-bubble {
  border-bottom-left-radius: 6px;
  border-top-right-radius: 18px;
  border-top-left-radius: 18px;
  border-bottom-right-radius: 18px;
  background: #f1f5f9;
  color: var(--ink);
  border: none;
}
.chat-page-messages-slot .po-bot-bubble { background: #f1f5f9; color: var(--ink); }
.chat-page-messages-slot .u-bot-bubble { background: #f1f5f9; color: var(--ink); }
.chat-page-messages-slot .user-bubble {
  border-bottom-right-radius: 6px;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-bottom-left-radius: 18px;
  background: #fff;
  color: #0f172a;
  border: 1px solid var(--border);
}
.chat-page-messages-slot .user-bubble.u-user {
  background: #fff;
  color: #0f172a;
  border: 1px solid var(--border);
}

/* Chat page: input bar (upload, mic, input, send) + gradient strip */
.chat-page-input-slot {
  flex-shrink: 0;
  background: var(--white);
  display: flex;
  flex-direction: column;
  padding: 0;
}
.chat-input-bar-gradient {
  height: 4px;
  background: linear-gradient(90deg, #0066B3 0%, #00843D 100%);
  flex-shrink: 0;
  order: 2;
}
.chat-page-input-slot .chatbot-input-area {
  padding: 1rem 1.5rem 1.25rem;
  border: none;
  background: transparent;
  width: 100%;
  order: 1;
}
.chat-page-input-slot .chatbot-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px 10px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-page-input-slot .chatbot-input-row:focus-within {
  border-color: #0066B3;
  box-shadow: 0 0 0 2px rgba(0,102,179,0.15);
}
.chat-page-input-slot .chat-ib-mic {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(90deg, #0066B3 0%, #00843D 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}
.chat-page-input-slot .chat-ib-mic:hover { opacity: 0.92; filter: brightness(1.08); transform: scale(1.05); }
.chat-ib-mic.recording { background: #dc2626 !important; animation: mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 50% { opacity: 0.85; transform: scale(1.05); } }
.chat-page-input-slot .chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 0;
  font-size: 0.9rem;
  background: transparent;
  outline: none;
  min-width: 0;
}
.chat-page-input-slot .chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
  background: linear-gradient(90deg, #0066B3 0%, #00843D 100%);
  color: #fff;
  border: none;
}
.chat-page-input-slot .chatbot-send:hover { transform: scale(1.08); }
.chat-page-input-slot .chatbot-send:active { transform: scale(0.98); }
.chat-page-input-slot .chatbot-send.po-send { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); }
.chat-page-input-slot .chatbot-send.u-send { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); }
.tool-history-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.tool-history-section h3 {
  font-family: 'Playfair Display', serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--forest);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tool-history-section.blue h3 { color: var(--navy); }
.tool-history-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 900px) {
  .cards-grid { grid-template-columns: 1fr; }
  .tool-layout { grid-template-columns: 1fr; }
  .chat-page-header { padding: 0.875rem 1rem 1rem; }
  .chat-page-messages-slot { padding: 0 1rem; }
  .chat-page-messages-slot .chatbot-messages { padding: 1rem 0; gap: 1rem; max-width: 100%; }
  .chat-page-messages-slot .chat-bubble { padding: 12px 16px; font-size: 0.85rem; }
  .chat-page-input-slot { padding: 0.75rem 1rem 1rem; }
  .chat-page-header-right { gap: 10px; }
  .chat-page-avatar { width: 42px; height: 42px; font-size: 20px; }
  .chat-page-title { font-size: 1.05rem; }
}

/* ═══════════════ CHATBOT WIDGET (SolMate-style UI) ═══════════════ */
.chat-banner-wrap { position: fixed; bottom: 28px; right: 28px; z-index: 500; display: none; }
.chat-bubble-banner { display: flex; align-items: center; gap: 12px; padding: 12px 20px 12px 24px; border-radius: 50px; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 0.88rem; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,0.18); transition: transform 0.18s, box-shadow 0.18s; animation: bannerPop 0.4s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes bannerPop { from { opacity:0; transform: scale(0.7) translateY(20px); } to { opacity:1; transform: scale(1) translateY(0); } }
.chat-bubble-banner:hover { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(0,0,0,0.22); }
.po-banner, .u-banner { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); color: #fff; }
.banner-bot { font-size: 1.5rem; width: 40px; height: 40px; background: rgba(255,255,255,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; }

.po-fab, .u-fab { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); color: #fff; box-shadow: 0 8px 24px rgba(0,102,179,0.35); }
.po-fab:hover, .u-fab:hover { opacity: 0.92; filter: brightness(1.08); color: #fff; }

/* Blurred backdrop when chatbot is expanded */
.chatbot-expand-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 599;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}
.chatbot-expand-backdrop.visible { display: block; }

/* Popup: clean modern card */
.chatbot-popup {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 460px;
  max-height: 680px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
  z-index: 600;
  display: none; flex-direction: column;
  animation: chatPop 0.35s cubic-bezier(.34,1.56,.64,1) both;
  background: #fff;
}
.chatbot-popup.expanded {
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: min(92vw, 900px);
  height: 85vh;
  max-height: 85vh;
  transform: translate(-50%, -50%);
  animation: none;
}
.chatbot-popup.expanded .chatbot-messages { max-height: none; flex: 1; min-height: 200px; }
@keyframes chatPop { from { opacity:0; transform: scale(0.9) translateY(20px); } to { opacity:1; transform: scale(1) translateY(0); } }

/* Header: Avaada gradient */
.chatbot-header {
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  background: linear-gradient(90deg, #0066B3 0%, #00843D 100%);
}
.po-chat-header, .u-chat-header { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); }

.chatbot-header-left { display: flex; align-items: center; gap: 12px; }
.chatbot-logo-sol {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Sans', sans-serif; font-size: 1.25rem; font-weight: 800;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}
.chatbot-brand { min-width: 0; }
.chatbot-title { font-size: 0.95rem; font-weight: 700; color: #fff; line-height: 1.25; letter-spacing: 0.02em; }
.chatbot-subtitle { font-size: 0.7rem; color: rgba(255,255,255,0.85); margin-top: 2px; }
.chatbot-header-right { display: flex; align-items: center; gap: 8px; }
.chatbot-header-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.chatbot-header-icon:hover { background: rgba(255,255,255,0.22); }
.chatbot-header-icon svg { width: 18px; height: 18px; }
.chatbot-close { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.chatbot-close:hover { background: rgba(255,255,255,0.3); }

/* Messages: white area, clean bubbles (same as app) */
.chatbot-messages {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  background: #fff;
  min-height: 280px; max-height: 480px;
}
.chatbot-messages::-webkit-scrollbar { width: 6px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-start; }
.bot-msg { flex-direction: row; }
.user-msg { flex-direction: row-reverse; }
.chatbot-popup .bot-msg .bot-avatar-sm { background: #0066B3 !important; }
.chatbot-popup .bot-msg .bot-avatar-sm svg { opacity: 1; }
.chat-bubble { padding: 10px 14px; border-radius: 12px; font-size: 0.875rem; line-height: 1.5; max-width: 88%; word-break: break-word; }
.bot-bubble { border-bottom-left-radius: 6px; background: #fff; color: #0f172a; border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.po-bot-bubble, .u-bot-bubble { background: #fff; color: #0f172a; border: 1px solid var(--border); }
.chat-bubble-time { font-size: 0.5rem; color: #9ca3af; margin-top: 4px; }
.chat-bubble-text { display: block; line-height: 1.45; white-space: pre-wrap; white-space: break-spaces; }
.chat-bubble-text .chat-p { margin: 0 0 0.3em; line-height: 1.45; }
.chat-bubble-text .chat-p:last-child { margin-bottom: 0; }
.chat-bubble-text > *:last-child { margin-bottom: 0 !important; }
.chat-bubble-text strong { font-weight: 700; color: #0f172a; }
.chat-bubble-text em { font-style: italic; }
.chat-bubble-text ul.chat-ul, .chat-bubble-text ol.chat-ol { margin: 0.2em 0 0.35em; padding-left: 1.25em; }
.chat-bubble-text ul:not(.chat-ul), .chat-bubble-text ol:not(.chat-ol) { margin: 0.2em 0 0.35em; padding-left: 1.25em; }
.chat-bubble-text li { margin: 0.08em 0; line-height: 1.4; padding: 0; }
.chat-bubble-text li + li { margin-top: 0.08em; }
.chat-bubble-text .chat-inline-code { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace; font-size: 0.85em; padding: 0.12em 0.35em; background: rgba(0,102,179,0.08); border-radius: 4px; border: 1px solid rgba(0,102,179,0.15); color: #0f172a; }
.chat-bubble-text .chat-pre { margin: 0.3em 0 0.4em; padding: 8px 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; overflow-x: auto; font-size: 0.8rem; line-height: 1.4; }
.chat-bubble-text .chat-code-block { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace; display: block; white-space: pre; margin: 0; color: #334155; }
.chat-table-wrap { margin: 0.3em 0 0.4em; overflow-x: auto; border-radius: 8px; border: 1px solid #e2e8f0; }
.chat-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.chat-table th, .chat-table td { padding: 5px 8px; text-align: left; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.chat-table th { background: rgba(0,102,179,0.06); font-weight: 600; color: #0066B3; }
.chat-table tr:last-child td { border-bottom: none; }
.chat-table tbody tr:hover { background: rgba(0,102,179,0.03); }
.chat-heading { font-weight: 600; color: #0f172a; margin: 0.35em 0 0.2em; line-height: 1.25; }
.chat-heading.chat-h1 { font-size: 1.1rem; margin-top: 0.15em; }
.chat-heading.chat-h2 { font-size: 1.02rem; }
.chat-heading.chat-h3 { font-size: 0.97rem; }
.chat-heading.chat-h4 { font-size: 0.92rem; }
.chat-heading:first-child { margin-top: 0; }
.chat-bubble-text .chat-table-wrap { margin: 0.3em 0; }
.user-bubble { border-bottom-right-radius: 6px; background: #fff; color: #0f172a; border: 1px solid var(--border); }
.user-bubble.u-user { background: #fff; color: #0f172a; border: 1px solid var(--border); }

.typing-bubble { display: flex; gap: 5px; align-items: center; padding: 12px 16px; }
.typing-dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; animation: typingBounce 1.2s infinite ease-in-out; }
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%,60%,100% { transform: translateY(0); opacity:0.5; } 30% { transform: translateY(-5px); opacity:1; } }
.po-typing .typing-dot, .u-typing .typing-dot { background: #0066B3; }

/* Streaming answer: cursor blinks while text is arriving */
.streaming-content { display: inline; }
.streaming-cursor {
  display: inline-block;
  margin-left: 1px;
  color: #0066B3;
  animation: streamCursor 0.9s ease-in-out infinite;
}
@keyframes streamCursor {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.2; }
}

/* Input bar: white background, Avaada mic/send */
.chatbot-input-area {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chatbot-input-row { display: flex; gap: 10px; align-items: center; }
.chat-ib-mic {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(0,102,179,0.1);
  color: #0066B3;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}
.chat-ib-mic:hover { background: rgba(0,102,179,0.2); color: #0066B3; }
.chat-ib-mic.recording { background: #dc2626 !important; color: #fff; animation: mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 50% { opacity: 0.9; } }
.chatbot-input {
  flex: 1; padding: 11px 16px; border: 1px solid var(--border); border-radius: 24px;
  font-family: 'DM Sans', sans-serif; font-size: 0.84rem; background: #fff;
  outline: none; color: #0f172a; transition: border-color 0.15s;
}
.chatbot-input::placeholder { color: #64748b; }
.chatbot-input:focus { border-color: #0066B3; box-shadow: 0 0 0 2px rgba(0,102,179,0.15); }
.chatbot-send {
  width: 42px; height: 42px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: transform 0.15s, box-shadow 0.15s;
  background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); color: #fff;
}
.chatbot-send:hover { transform: scale(1.06); box-shadow: 0 4px 12px rgba(0,102,179,0.35); }
.chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.po-send, .u-send { background: linear-gradient(90deg, #0066B3 0%, #00843D 100%); }



/* FAB always visible, full color. Tooltip shown on disabled click */
/* ── FLOATING CHAT FAB ── */
.chat-fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 500;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  cursor: pointer;
  animation: fabFloat 3s ease-in-out infinite;
  will-change: transform;
  overflow: hidden;
}
.chat-fab-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes fabFloat {
  0%   { transform: translateY(0px);   box-shadow: 0 8px 24px rgba(0,0,0,0.22); }
  50%  { transform: translateY(-10px); box-shadow: 0 18px 36px rgba(0,0,0,0.28); }
  100% { transform: translateY(0px);   box-shadow: 0 8px 24px rgba(0,0,0,0.22); }
}

.chat-fab:hover {
  animation-play-state: paused;
  transform: scale(1.12) translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.3);
}

.chat-fab.fab-shake {
  animation: fabShake 0.45s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes fabShake {
  0%,100% { transform: translateX(0); }
  15%     { transform: translateX(-7px) rotate(-3deg); }
  35%     { transform: translateX(7px)  rotate(3deg); }
  55%     { transform: translateX(-5px) rotate(-2deg); }
  75%     { transform: translateX(5px)  rotate(2deg); }
}

/* Floating tooltip above FAB */
.fab-tooltip {
  position: fixed;
  bottom: 100px; right: 20px;
  background: #1a1a2e;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 700;
  pointer-events: none;
  animation: tooltipFade 2.2s ease forwards;
}
.fab-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px; right: 22px;
  width: 12px; height: 12px;
  background: #1a1a2e;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
@keyframes tooltipFade {
  0% { opacity: 0; transform: translateY(6px); }
  15% { opacity: 1; transform: translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-4px); }
}


.chat-tab-btn { background:rgba(255,255,255,0.12);border:1px solid rgba(255,255,255,0.2);color:rgba(255,255,255,0.7);font-family:'DM Sans',sans-serif;font-size:0.68rem;font-weight:600;padding:4px 10px;border-radius:20px;cursor:pointer;transition:all 0.15s; }
.chat-tab-btn.active { background:rgba(255,255,255,0.3);color:#fff;border-color:rgba(255,255,255,0.5); }
.chat-tab-btn:hover:not(.active) { background:rgba(255,255,255,0.2);color:#fff; }
.bot-avatar-sm { width: 32px; height: 32px; min-width: 32px; border-radius: 50%; background: #0066B3; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; position: relative; }
.bot-avatar-sm svg { width: 18px; height: 18px; opacity: 0.95; }
.bot-avatar-sm .bot-avatar-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.chat-page-messages-slot .bot-msg .bot-avatar-sm { width: 40px; height: 40px; min-width: 40px; }
.chat-page-messages-slot .bot-msg .bot-avatar-sm .bot-avatar-video { width: 100%; height: 100%; }
.history-panel { flex:1;display:none;flex-direction:column;background:#ffffff;overflow:hidden; }
.history-panel.active { display:flex; }
.history-header { display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:#fff;border-bottom:1px solid #e8eaf0;flex-shrink:0; }
.history-title { font-size:0.78rem;font-weight:700;color:#1a1a2e; }
.history-refresh-btn { display:flex;align-items:center;gap:5px;font-family:'DM Sans',sans-serif;font-size:0.72rem;font-weight:600;padding:5px 12px;border-radius:20px;border:none;cursor:pointer;transition:all 0.15s; }
.po-refresh { background:rgba(26,58,42,0.1);color:#1a3a2a; } .po-refresh:hover { background:rgba(26,58,42,0.22); }
.u-refresh { background:rgba(30,64,175,0.1);color:#1e40af; } .u-refresh:hover { background:rgba(30,64,175,0.22); }
.history-list { flex:1;overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:6px;max-height:290px; }
.history-empty { text-align:center;color:#9ca3af;font-size:0.78rem;line-height:1.6;padding:2rem 1rem; }
.history-item { background:#fff;border:1px solid #e8eaf0;border-radius:10px;padding:10px 12px;cursor:pointer;transition:all 0.15s; }
.history-item.po-hist:hover { border-color:#4a7c59;background:#f0f7f2;transform:translateX(2px); }
.history-item.u-hist:hover { border-color:#60a5fa;background:#eff6ff;transform:translateX(2px); }
.history-q { font-size:0.78rem;font-weight:600;color:#1a1a2e;margin-bottom:3px;display:flex;gap:5px;align-items:flex-start; }
.history-q::before { content:"Q";background:#e8eaf0;border-radius:3px;padding:0 5px;font-size:0.6rem;color:#6b7280;margin-top:1px;flex-shrink:0; }
.history-a { font-size:0.72rem;color:#6b7280;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.history-time { font-size:0.63rem;color:#9ca3af;margin-top:4px;text-align:right; }


/* ── Generation Progress Bar ── */
.progress-wrap {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.progress-wrap.blue-prog { background: #eff6ff; border-color: #bfdbfe; }
.progress-label {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 7px; color: #0066B3;
}
.progress-wrap.blue-prog .progress-label { color: var(--navy); }
.po-progress-spinner { width: 11px; height: 11px; border: 2px solid #0066B3; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
.progress-step-text { flex: 1; }
.progress-pct { font-size: 0.68rem; color: var(--mist); font-weight: 500; }
.progress-track {
  height: 5px; background: var(--border); border-radius: 10px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, #0066B3 0%, #00843D 100%);
  width: 0%; transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.progress-wrap.blue-prog .progress-fill {
  background: linear-gradient(90deg, var(--navy), #60a5fa);
}
.progress-steps {
  display: flex; gap: 4px;
}
.progress-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border); transition: background 0.3s;
}
.progress-dot.done { background: #00843D; }
.progress-dot.active { background: #0066B3; animation: dotPulse 0.8s ease-in-out infinite; }
.progress-wrap.blue-prog .progress-dot.done { background: #60a5fa; }
.progress-wrap.blue-prog .progress-dot.active { background: var(--navy); }
@keyframes dotPulse { 0%,100% { transform: scale(1); opacity:1; } 50% { transform: scale(1.4); opacity:0.7; } }

