:root {
  /* Arrivau brand palette — aligned to arrivau.com.au (2026-04-29) */
  --arv-brand:       #ED6F0C;  /* primary brand orange */
  --arv-brand-ink:   #8A3F05;  /* brand dark (hover/pressed) */
  --arv-brand-soft:  #FFE8D1;  /* brand light tint (highlight bg) */
  --arv-ink:         #101114;  /* primary text */
  --arv-ink-muted:   #5F6268;  /* secondary text */
  --arv-ink-subtle:  #8D9299;  /* subtle/disabled */
  --arv-line:        #E6E3DD;  /* strong border */
  --arv-line-soft:   #F1EEE8;  /* soft separator */
  --arv-paper:       #FFFFFF;  /* white surface */
  --arv-paper-warm:  #FBF8F3;  /* warm off-white bg */
  --arv-paper-dark:  #0E1013;  /* inverted dark surface */

  /* Arrivau staff VI (2026-07-05): deep navy primary + orange accent on light-gray canvas */
  --brand-navy:      #0F6DB0;  /* arrivau primary blue — buttons, active, key figures */
  --brand-navy-deep: #0A4D7F;  /* darker blue — hover */
  --brand-ink:       #0C1C2C;  /* near-black navy — sidebar / login shell */
  --brand-ink-2:     #081521;  /* darkest shell */
  --brand-gold:      #C6923E;  /* arrivau gold (house-mark roof) */
  --brand-gold-soft: #FDEFD6;  /* soft accent tint */
  --brand-blue:      #0F6DB0;  /* alias → primary blue */

  /* aliases used by shared color vars below */
  --text-1: #1F2A37;
  --text-2: #5C6B7A;

  --bg-primary:    #FFFFFF;
  --bg-secondary:  #F4F5F7;     /* cool light-gray page canvas */
  --text-primary: #1F2A37;
  --text-secondary: #5C6B7A;
  --text-muted:    #8D9299;
  --border:        #E5E7EB;
  --border-dark:   #D3D8DF;
  --shadow:    0 1px 2px rgba(12,16,25,.06), 0 2px 6px rgba(12,16,25,.04);
  --shadow-lg: 0 4px 14px rgba(12,16,25,.08), 0 2px 4px rgba(12,16,25,.04);
  --radius:    6px;
  --transition: all 0.2s ease;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
}

/* Login page */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(140deg, var(--brand-ink), var(--brand-ink-2));
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-logo {
  margin-bottom: 32px;
}

.login-logo svg {
  margin-bottom: 12px;
}

.login-logo .brand {
  font-size: 24px;
  font-weight: 700;
  color: var(--brand-navy);
  margin-bottom: 4px;
}

.login-logo .sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.login-card h1 {
  font-size: 20px;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.login-card input:focus {
  outline: none;
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.1);
}

.login-card button {
  padding: 12px;
  background: var(--brand-navy);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.login-card button:hover {
  background: var(--brand-navy-deep);
}

.login-card button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-card .err {
  background: #fef2f2;
  color: #c00;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid #fcc;
  font-size: 13px;
  margin-bottom: 12px;
}

.lang-row {
  margin-top: 20px;
  font-size: 13px;
}

.lang-row a {
  color: var(--brand-navy);
  text-decoration: none;
  cursor: pointer;
}

.lang-row a:hover {
  text-decoration: underline;
}

/* App header */
.app-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  color: var(--brand-navy);
  font-size: 16px;
  min-width: 200px;
}

.app-header nav {
  display: flex;
  gap: 16px;
  flex: 1;
}

.app-header nav a {
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  font-size: 14px;
}

.app-header nav a:hover,
.app-header nav a.active {
  color: var(--brand-navy);
  border-bottom-color: var(--brand-gold);
}

.app-header .right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.role-pill {
  background: var(--bg-secondary);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-navy);
}

.username {
  font-size: 13px;
  font-weight: 500;
}

.lang-toggle,
.logout-btn {
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.logout-btn {
  background: #fff0f0;
  color: #c00;
  border-color: #fcc;
}

.logout-btn:hover {
  background: #ffe0e0;
}

/* Main content */
.app-main {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 13px;
}

thead {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-dark);
}

th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--bg-secondary);
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--brand-navy);
  color: white;
}

.btn-primary:hover {
  background: var(--brand-navy-deep);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #eee;
}

/* Forms */
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.1);
}

/* Utility */
.err {
  background: #fef2f2;
  color: #c00;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid #fcc;
  font-size: 13px;
}

.muted {
  color: var(--text-muted);
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card h3 {
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text-primary);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.badge.status-settled {
  background: #d4edda;
  color: #155724;
}

.badge.status-current {
  background: #d1ecf1;
  color: #0c5460;
}

.badge.status-opportunity {
  background: #fff3cd;
  color: #856404;
}

.badge.status-done {
  background: #e2e3e5;
  color: #383d41;
}

/* Responsive */
@media (max-width: 768px) {
  .app-header {
    flex-wrap: wrap;
  }

  .app-header nav {
    width: 100%;
    order: 3;
    gap: 8px;
    margin-top: 8px;
  }

  .app-header .right {
    margin-left: 0;
    order: 4;
    width: 100%;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 8px;
  }

  .login-card {
    padding: 32px 24px;
  }
}

/* ============== AI 助手 floating chat widget ============== */
.chat-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-gold, #ED6F0C) 0%, var(--brand-navy, #101114) 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 24px;
  box-shadow: 0 6px 20px rgba(31, 78, 121, 0.4);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.chat-fab:hover { transform: scale(1.08); }
.chat-fab.open { background: var(--brand-navy, #101114); }

.chat-panel {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: min(640px, calc(100vh - 120px));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(31, 78, 121, 0.25);
  display: none;
  flex-direction: column;
  z-index: 998;
  overflow: hidden;
  border: 1px solid var(--border, #e1e5ea);
}
.chat-panel.open { display: flex; }

.chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand-navy, #101114) 0%, #0E1013 100%);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-header .title {
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-header .clear-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.chat-header .clear-btn:hover { background: rgba(255, 255, 255, 0.28); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fafbfd;
  font-size: 13px;
}
.chat-msg { margin-bottom: 12px; display: flex; flex-direction: column; }
.chat-msg.user { align-items: flex-end; }
.chat-msg.bot { align-items: flex-start; }

.chat-bubble {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 12px;
  line-height: 1.55;
  word-wrap: break-word;
}
.chat-msg.user .chat-bubble {
  background: var(--brand-navy, #101114);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot .chat-bubble {
  background: #fff;
  color: var(--text, #222);
  border: 1px solid var(--border, #e1e5ea);
  border-bottom-left-radius: 4px;
}
.chat-bubble.thinking {
  background: var(--brand-gold, #ED6F0C);
  color: #4a3a00;
  font-weight: 600;
  font-style: italic;
}
.chat-bubble code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}
.chat-bubble strong { color: var(--brand-navy, #101114); }
.chat-msg.user .chat-bubble strong { color: var(--brand-gold, #ED6F0C); }
.chat-bubble ul, .chat-bubble ol { margin: 4px 0 4px 18px; padding: 0; }
.chat-bubble li { margin: 2px 0; }
.chat-bubble a { color: var(--brand-navy, #101114); cursor: pointer; }
.chat-bubble.error { background: #fff3f3; color: #c0392b; border-color: #e8a3a3; }

.chat-msg .meta {
  font-size: 10px;
  color: var(--text-3, #97a3b3);
  margin-top: 3px;
}

.chat-input-row {
  padding: 10px 12px;
  border-top: 1px solid var(--border, #e1e5ea);
  background: #fff;
  display: flex;
  gap: 6px;
}
.chat-input-row textarea {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border, #e1e5ea);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  min-height: 36px;
  max-height: 80px;
}
.chat-input-row textarea:focus {
  outline: 2px solid var(--brand-gold, #ED6F0C);
  outline-offset: -1px;
  border-color: var(--brand-navy, #101114);
}
.chat-input-row button {
  padding: 8px 16px;
  background: var(--brand-navy, #101114);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
.chat-input-row button:hover { background: #0E1013; }
.chat-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-empty-hints {
  color: var(--text-3, #97a3b3);
  text-align: center;
  padding: 16px;
  font-size: 12px;
}

@media (max-width: 600px) {
  .chat-fab { width: 48px; height: 48px; bottom: 14px; right: 14px; }
  .chat-panel { bottom: 0; right: 0; left: 0; width: 100%; max-width: 100%; height: 80vh; border-radius: 14px 14px 0 0; }
  .chat-bubble { font-size: 13px; }
}

/* ============================================================
   Staff portal additions (Mail / Files / Contracts) — Arrivau VI
   ============================================================ */

/* utilities */
.page-title { font-size: 22px; font-weight: 700; color: var(--brand-navy); letter-spacing: -0.3px; }
.page-subtitle { color: var(--text-secondary); font-size: 13.5px; margin: 4px 0 16px; }
.muted { color: var(--text-secondary); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.mt-12 { margin-top: 12px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.empty { padding: 32px 20px; text-align: center; color: var(--text-muted); font-size: 14px; }
.ok-msg { background: #e9f7ee; color: #1c7a44; border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.err { background: #fdecec; color: #b3261e; border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.loading { padding: 24px; color: var(--text-muted); font-size: 14px; }
.btn-primary:hover { background: var(--brand-navy-deep); }
.btn-gold { background: var(--brand-gold); color: #fff; }
.btn-gold:hover { background: #cf7813; }

/* form fields */
.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.fld > span { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.fld input, .fld select, .fld textarea { width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-navy); box-shadow: 0 0 0 3px rgba(31,63,102,.12); }
.mail-form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.mail-form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(23,50,79,.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: #fff; border-radius: 14px; padding: 24px; width: 560px; max-width: 94vw; max-height: 90vh; overflow: auto; box-shadow: 0 24px 70px rgba(0,0,0,.32); }
.compose-card { width: 640px; }
.icon-x { background: none; border: none; font-size: 18px; color: var(--text-muted); cursor: pointer; line-height: 1; }
.icon-x:hover { color: var(--text-primary); }
.compose-body { width: 100%; resize: vertical; line-height: 1.6; }
.ai-box { background: var(--brand-gold-soft); border: 1px solid #f0dcbc; border-radius: 10px; padding: 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.ai-box textarea { width: 100%; resize: vertical; border-color: #ecd7b4; background: #fff; }
.ai-box .btn { align-self: flex-end; }
.link-copy { display: flex; gap: 8px; margin: 8px 0; }
.link-copy input { flex: 1; background: #f7f9fb; color: var(--brand-navy); font-size: 13px; }

/* mailbox */
.mail-tabs { display: flex; gap: 4px; margin: 12px 0; align-items: center; }
.mail-tab { background: none; border: none; padding: 8px 14px; border-radius: 8px; font-size: 14px; color: var(--text-secondary); cursor: pointer; font-weight: 500; }
.mail-tab.active { background: var(--brand-navy); color: #fff; }
.mail-tab:hover:not(.active) { background: #eef1f5; }
.mail-row { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.mail-row:last-child { border-bottom: none; }
.mail-row:hover { background: #f7f9fb; }
.mail-row.unread { background: #fbfcfe; }
.mail-row-from { width: 168px; flex-shrink: 0; font-size: 13.5px; color: var(--text-primary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row.unread .mail-row-from { font-weight: 700; }
.mail-row-main { flex: 1; min-width: 0; }
.mail-row-subj { font-size: 14px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row.unread .mail-row-subj { font-weight: 600; }
.mail-row-subj .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-gold); margin-right: 7px; vertical-align: middle; }
.mail-row-date { width: 56px; flex-shrink: 0; text-align: right; font-size: 12px; color: var(--text-muted); }
.mail-meta { margin: 14px 0; padding: 12px 14px; background: #f7f9fb; border-radius: 8px; font-size: 13px; line-height: 1.7; }
.mail-body { margin-top: 6px; font-size: 14.5px; line-height: 1.7; }
.mail-html img { max-width: 100%; height: auto; }
.mail-plain { white-space: pre-wrap; font-family: inherit; font-size: 14.5px; line-height: 1.65; margin: 0; }
.summary-text { font-size: 14px; line-height: 1.7; }
.summary-text ul { margin: 6px 0 6px 18px; } .summary-text strong { color: var(--brand-navy); }
.bind-guide { background: #f7f9fb; border: 1px solid var(--border); border-left: 3px solid var(--brand-gold); border-radius: 8px; padding: 14px 16px; margin: 14px 0; font-size: 13px; }
.bind-guide-title { font-weight: 700; color: var(--brand-navy); margin-bottom: 8px; }
.bind-guide ol { margin: 0 0 8px 18px; line-height: 1.75; color: var(--text-secondary); }
.bind-guide-note { color: var(--text-muted); font-size: 12px; }

/* files */
.files-crumb { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; }
.files-uplink { font-size: 13px; color: var(--brand-navy); font-weight: 600; text-decoration: none; }
.files-table { width: 100%; border-collapse: collapse; }
.files-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); padding: 10px 18px; border-bottom: 1px solid var(--border); }
.files-table td { padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 14px; }
.files-table tr:last-child td { border-bottom: none; }
.files-table tr.is-folder { cursor: pointer; }
.files-table tr.is-folder:hover { background: #f7f9fb; }
.files-table .dl-link { color: var(--brand-navy); font-weight: 600; text-decoration: none; font-size: 13px; }

/* contracts */
.ct-table { width: 100%; border-collapse: collapse; }
.ct-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); padding: 10px 18px; border-bottom: 1px solid var(--border); }
.ct-table td { padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 14px; }
.ct-table tr:last-child td { border-bottom: none; }
.ct-table tr:hover { background: #f7f9fb; }
.ct-table .ct-view { color: var(--brand-navy); font-weight: 600; text-decoration: none; }
.ct-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.ct-sent { background: var(--brand-gold-soft); color: #a4650f; }
.ct-signed { background: #e4f6ec; color: #1c7a44; }
.ct-void { background: #f0f1f3; color: #7a828c; }
.ct-draft { background: #eef1f5; color: #4a5867; }
.doc-view { white-space: pre-wrap; font-size: 14.5px; line-height: 1.7; background: #fafbfc; border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-top: 14px; max-height: 46vh; overflow: auto; }
.signed-box { margin-top: 14px; padding: 14px 16px; background: #f3faf5; border: 1px solid #cdead8; border-radius: 10px; font-size: 13.5px; line-height: 1.8; }
.sig-preview { margin-top: 8px; }
.sig-preview img { max-width: 280px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }

/* brand wordmark */
.logo .brandmark { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.logo .brandmark .bm1 { color: var(--brand-navy); }
.logo .brandmark .bm2 { color: var(--brand-gold); }
.logo .brand-divider { display: inline-block; width: 1px; height: 18px; background: var(--border-dark); margin: 0 10px; vertical-align: middle; }
.logo .brand-sub { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

/* login wordmark */
.login-wordmark { font-size: 30px; font-weight: 800; letter-spacing: -0.6px; margin-bottom: 6px; }
.login-wordmark .bm1 { color: var(--brand-navy); }
.login-wordmark .bm2 { color: var(--brand-gold); }

/* ============================================================
   Knowledge Q&A tab (embedded chat + bot conversation logs)
   ============================================================ */
.kqa-page-head { margin-bottom: 14px; }
.kqa-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.kqa-tab { background: none; border: none; padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.kqa-tab.active { background: var(--brand-navy); color: #fff; }
.kqa-tab:hover:not(.active) { background: #eef1f5; }

/* embedded assistant */
.kqa-chat-panel { display: flex; flex-direction: column; height: calc(100vh - 260px); min-height: 420px; padding: 0; overflow: hidden; }
.kqa-chat-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--brand-navy); color: #fff; }
.kqa-chat-header-left { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.kqa-chat-clear { background: rgba(255,255,255,.16); border: none; color: #fff; font-size: 12px; padding: 5px 11px; border-radius: 7px; cursor: pointer; }
.kqa-chat-clear:hover { background: rgba(255,255,255,.28); }
.kqa-chat-messages { flex: 1; overflow-y: auto; padding: 18px; background: #f7f9fb; }
.kqa-chat-input-row { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); background: #fff; }
.kqa-chat-input-row textarea { flex: 1; resize: none; max-height: 120px; border-radius: 9px; }
.kqa-chat-messages .chat-msg { display: flex; margin-bottom: 12px; }
.kqa-chat-messages .chat-msg.user { justify-content: flex-end; }
.kqa-chat-messages .chat-bubble { max-width: 78%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.6; }
.kqa-chat-messages .chat-msg.user .chat-bubble { background: var(--brand-navy); color: #fff; border-bottom-right-radius: 4px; }
.kqa-chat-messages .chat-msg.bot .chat-bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.kqa-chat-messages .chat-bubble.error { background: #fdecec; color: #b3261e; border-color: #f3c0bd; }
.kqa-chat-messages .chat-bubble.thinking { color: var(--text-muted); font-style: italic; }
.kqa-chat-messages .chat-bubble strong { color: inherit; }
.kqa-chat-messages .chat-bubble a { color: var(--brand-gold); }
.kqa-chat-messages .chat-msg.user .chat-bubble a { color: #ffe0bf; }
.hint-item:hover { border-color: var(--brand-navy) !important; background: #f5f8fc !important; }

/* bot conversation logs */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filter-bar input { padding: 8px 12px; }
.table-wrap { overflow-x: auto; }
#chat-logs-table { width: 100%; border-collapse: collapse; }
#chat-logs-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); padding: 10px 14px; border-bottom: 1px solid var(--border); }
#chat-logs-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: top; }
.chat-log-row { cursor: pointer; }
.chat-log-row:hover { background: #f7f9fb; }
.chat-log-row.expanded { background: #eef3f8; }
.td-time { white-space: nowrap; color: var(--text-secondary); font-size: 12.5px; }
.td-expand { text-align: center; }
.btn-expand { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 12px; }
.muted.small { font-size: 11.5px; }
.detail-panel { background: #fbfcfd; border-radius: 10px; padding: 16px; }
.detail-section { margin-bottom: 16px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-navy); margin-bottom: 8px; }
.bot-detail-grid { display: grid; grid-template-columns: 140px 1fr; gap: 4px 14px; font-size: 13px; }
.bot-detail-k { color: var(--text-muted); }
.bot-detail-v { color: var(--text-primary); word-break: break-word; }
.bot-transcript { display: flex; flex-direction: column; gap: 10px; }
.bot-turn { max-width: 82%; padding: 9px 13px; border-radius: 10px; font-size: 13.5px; line-height: 1.6; }
.bot-turn.user { align-self: flex-end; background: var(--brand-navy); color: #fff; }
.bot-turn.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--border); }
.bot-turn.system { align-self: center; background: #f0f1f3; color: var(--text-muted); font-size: 12px; }
.bot-turn-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; opacity: .7; margin-bottom: 3px; }
.bot-turn-content { white-space: pre-wrap; }
.pagination-bar { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; }
.page-info { color: var(--text-secondary); margin-right: auto; }
.btn-page { padding: 6px 14px; border: 1px solid var(--border); background: #fff; border-radius: 7px; cursor: pointer; font-size: 13px; }
.btn-page:disabled { opacity: .45; cursor: not-allowed; }

/* ============================================================
   Sidebar shell (staff.unilink.co-style, left menu) — 2026-07-05
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 238px; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  display: flex; flex-direction: column; padding: 18px 14px;
  background: linear-gradient(165deg, var(--brand-ink), var(--brand-ink-2));
  color: #fff;
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 2px 6px; }
.sidebar-brand .brand-mark { display: block; border-radius: 7px; }
.sidebar-brand .brand-word { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.sidebar-brand .brand-word .bm1 { color: #fff; }
.sidebar-brand .brand-word .bm2 { color: var(--brand-gold); }
.sidebar-sub {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  color: rgba(255,255,255,.5); padding: 6px 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 10px;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-nav a {
  display: flex; align-items: center; padding: 10px 13px; border-radius: 9px;
  color: rgba(255,255,255,.78); text-decoration: none; font-size: 14px; font-weight: 500;
  border-bottom: none; transition: background .12s, color .12s;
}
.side-nav a:hover { background: rgba(255,255,255,.09); color: #fff; }
.side-nav a.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--brand-gold); }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; margin-top: 8px; }
.sidebar-foot .user-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; margin-bottom: 10px; }
.sidebar-foot .username { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .role-pill { background: rgba(255,255,255,.16); color: #fff; }
.sidebar-foot .foot-actions { display: flex; gap: 8px; }
.sidebar-foot .lang-toggle, .sidebar-foot .logout-btn {
  flex: 1; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.16);
  padding: 8px 6px; border-radius: 8px; font-size: 12.5px;
}
.sidebar-foot .lang-toggle:hover { background: rgba(255,255,255,.16); }
.sidebar-foot .logout-btn { background: rgba(224,80,80,.18); border-color: rgba(224,80,80,.3); color: #ffd7d7; }
.sidebar-foot .logout-btn:hover { background: rgba(224,80,80,.3); }

.app-body { margin-left: 238px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-main { padding: 26px 30px; max-width: 1280px; width: 100%; margin: 0; }

.sidebar-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 60;
  width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--border);
  background: #fff; color: var(--brand-navy); font-size: 18px; cursor: pointer; box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .app-sidebar.open { transform: translateX(0); }
  .app-body { margin-left: 0; }
  .app-main { padding: 64px 18px 24px; }
  .sidebar-toggle { display: block; }
}

/* ===== Pipeline funnel + Rules ===== */
.funnel-row { display: grid; grid-template-columns: 150px 1fr 54px 44px; align-items: center; gap: 12px; padding: 7px 0; }
.funnel-label { font-size: 13.5px; color: var(--text-primary); font-weight: 500; }
.funnel-bar-track { background: #eef1f5; border-radius: 6px; height: 22px; overflow: hidden; }
.funnel-bar-fill { height: 100%; background: var(--brand-navy); border-radius: 6px; transition: width .4s ease; min-width: 2px; }
.funnel-bar-fill.gold { background: var(--brand-gold); }
.funnel-count { text-align: right; font-weight: 700; color: var(--brand-navy); font-size: 14px; }
.funnel-pct { text-align: right; font-size: 12px; color: var(--text-muted); }
.rules-badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.rules-badge.scope-all { background: #e7eefc; color: #2a4d8f; }
.rules-badge.scope-bot { background: var(--brand-gold-soft); color: #a4650f; }
.rules-badge.on { background: #e4f6ec; color: #1c7a44; }
.rules-badge.off { background: #f0f1f3; color: #7a828c; }
.rule-edit, .rule-del { text-decoration: none; font-weight: 600; font-size: 13px; }
.rule-edit { color: var(--brand-navy); }

/* ===== grouped tab pages (top tab → subtabs) ===== */
.grouptabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.grouptab { background: none; border: none; padding: 10px 16px; font-size: 14.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.grouptab:hover { color: var(--brand-navy); }
.grouptab.active { color: var(--brand-navy); border-bottom-color: var(--brand-gold); }
.kb-sources { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border); font-size: 11px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 8px; }
.kb-sources span { white-space: nowrap; }

/* ===== KB upload (cards + dropzone + url) ===== */
.fld-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.kb-scope-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.kb-scope-card { text-align: left; background: #fff; border: 1.5px solid var(--border); border-radius: 12px; padding: 16px 18px; cursor: pointer; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; transition: border-color .12s, background .12s; }
.kb-scope-card:hover { border-color: var(--brand-navy); }
.kb-scope-card.active { border-color: var(--brand-navy); background: #f5f8fc; box-shadow: 0 0 0 3px rgba(31,63,102,.1); }
.kb-scope-card .ksc-ic { grid-row: 1 / 3; align-self: center; width: 40px; height: 40px; border-radius: 9px; background: var(--brand-gold-soft); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.kb-scope-card .ksc-t { font-size: 15px; font-weight: 700; color: var(--brand-navy); }
.kb-scope-card .ksc-d { font-size: 12px; color: var(--text-muted); }
.kb-drop { border: 2px dashed #b9c3cf; border-radius: 12px; padding: 30px 20px; text-align: center; cursor: pointer; transition: border-color .12s, background .12s; background: #fafbfc; }
.kb-drop:hover, .kb-drop.over { border-color: var(--brand-navy); background: #f5f8fc; }
.kb-drop.busy { opacity: .7; pointer-events: none; }
.kb-drop-ic { width: 46px; height: 46px; border-radius: 11px; background: var(--brand-gold-soft); color: var(--brand-gold); font-size: 22px; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.kb-drop-main { font-size: 15px; color: var(--text-primary); }
.kb-drop-pick { color: var(--brand-navy); font-weight: 700; }
.kb-drop-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.kb-url-row { display: flex; gap: 8px; margin-top: 12px; }
.kb-url-row input { flex: 1; }
.opt-badge { display: inline-block; background: #eef1f5; color: var(--text-secondary); border-radius: 5px; padding: 1px 7px; font-size: 10.5px; font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ===== KB email-ingest addresses ===== */
.kb-mail-box { background: #f7f9fb; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.kb-mail-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13.5px; flex-wrap: wrap; }
.kb-mail-n { color: var(--text-muted); }
.kb-mail-row code { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px; font-size: 13px; color: var(--brand-navy); }
.kb-mail-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 12px; }
.kb-mail-tag.out { background: var(--brand-gold-soft); color: #a4650f; }
.kb-mail-tag.in { background: #e7eefc; color: #2a4d8f; }
.kb-mail-copy { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 2px 10px; font-size: 12px; cursor: pointer; color: var(--brand-navy); }
.kb-mail-copy:hover { background: #eef3f8; }
