:root{
  --wine:#7a2031;
  --wine-dark:#5d1725;
  --wine-soft:#f5e9ec;
  --gold:#b58b55;
  --gold-soft:#f4eee5;

  --ink:#252525;
  --muted:#6b6762;

  --surface:#ffffff;
  --canvas:#f7f5f1;

  --line:#e4ded5;
  --line-strong:#d3cbc1;

  --success:#2f6b52;
  --success-soft:#e7f0eb;

  --warning:#a66c1d;

  --shadow:
    0 10px 30px rgba(48,35,32,.06);

  --radius:12px;
}

*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  min-height:100%;
  background:var(--canvas);
  color:var(--ink);

  font-family:
    "Segoe UI",
    "Source Sans 3",
    Arial,
    sans-serif;
}

button,
input,
select,
textarea{
  font:inherit;
}

button{
  cursor:pointer;
}

/* =========================================================
   TOP BAR
   ========================================================= */

.topbar{
  height:72px;

  display:flex;
  align-items:center;

  padding:0 26px;

  gap:32px;

  background:#fff;

  border-bottom:
    1px solid var(--line);
}

.brand{
  min-width:285px;

  display:flex;
  align-items:center;

  gap:12px;
}

.brand-mark{
  width:40px;
  height:40px;

  display:grid;
  place-items:center;

  border-radius:7px;

  background:var(--wine);
  color:#fff;

  font-weight:800;
  letter-spacing:.04em;
}

.brand-name{
  color:var(--wine);

  font-size:17px;
  font-weight:800;

  letter-spacing:.105em;
}

.brand-sub{
  margin-top:2px;

  color:var(--muted);

  font-size:11px;
}

.topnav{
  flex:1;

  height:72px;

  display:flex;
  align-items:stretch;

  gap:3px;
}

.nav-item{
  position:relative;

  border:0;

  background:transparent;

  padding:0 13px;

  color:#57524e;

  font-size:13px;
  font-weight:600;
}

.nav-item:hover{
  color:var(--wine);
}

.nav-item.active{
  color:var(--wine);
}

.nav-item.active::after{
  content:"";

  position:absolute;

  bottom:0;
  left:12px;
  right:12px;

  height:3px;

  border-radius:
    3px 3px 0 0;

  background:var(--wine);
}

.system-state{
  display:flex;
  align-items:center;

  gap:8px;

  white-space:nowrap;

  color:#555;

  font-size:12px;
}

.status-dot{
  width:8px;
  height:8px;

  border-radius:50%;

  background:var(--success);

  box-shadow:
    0 0 0 4px var(--success-soft);
}

.airgap{
  padding:5px 8px;

  border:
    1px solid var(--line);

  border-radius:99px;

  background:#faf9f7;
}

/* =========================================================
   CONTEXT BAR
   ========================================================= */

.contextbar{
  min-height:46px;

  padding:8px 26px;

  display:flex;
  align-items:center;
  justify-content:space-between;

  gap:16px;

  border-bottom:
    1px solid var(--line);

  background:#fbfaf8;

  font-size:12px;
}

.context-actions{
  display:flex;
  align-items:center;

  gap:10px;
}

.engine-badge{
  padding:6px 10px;

  border-radius:99px;

  background:var(--wine-soft);
  color:var(--wine);

  font-weight:700;
}

/* =========================================================
   LAYOUT
   ========================================================= */

.workspace{
  min-height:
    calc(100vh - 154px);

  display:grid;

  grid-template-columns:
    270px
    minmax(640px,1fr)
    290px;
}

.folder-pane,
.selection-pane{
  padding:22px 16px;

  background:#fff;
}

.folder-pane{
  border-right:
    1px solid var(--line);
}

.selection-pane{
  border-left:
    1px solid var(--line);
}

.content-pane{
  overflow:auto;

  padding:
    27px 30px 40px;
}

/* =========================================================
   TYPOGRAPHY
   ========================================================= */

h1,
h2,
h3,
p{
  margin-top:0;
}

h1{
  margin-bottom:6px;

  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size:31px;
  font-weight:600;

  letter-spacing:-.02em;
}

h2{
  margin:2px 0 0;

  font-size:18px;
}

.eyebrow{
  color:var(--wine);

  font-size:10px;
  font-weight:800;

  letter-spacing:.16em;
}

.subtitle{
  max-width:680px;

  color:var(--muted);

  font-size:13px;
  line-height:1.45;
}

/* =========================================================
   BUTTONS
   ========================================================= */

.btn{
  padding:9px 13px;

  border:
    1px solid transparent;

  border-radius:8px;

  font-size:12px;
  font-weight:700;
}

.btn.primary{
  background:var(--wine);
  color:#fff;
}

.btn.primary:hover{
  background:var(--wine-dark);
}

.btn.secondary{
  border-color:#cdaeb5;

  background:#fff;
  color:var(--wine);
}

.btn.ghost{
  border-color:var(--line);

  background:transparent;
  color:#615c57;
}

.icon-btn{
  width:32px;
  height:32px;

  border:
    1px solid var(--line);

  border-radius:8px;

  background:#fff;
  color:var(--wine);

  font-size:20px;
}

.icon-btn:hover{
  background:var(--wine-soft);

  border-color:var(--wine);
}

/* =========================================================
   FOLDERS
   ========================================================= */

.pane-title-row{
  margin-bottom:16px;

  display:flex;
  align-items:flex-start;
  justify-content:space-between;

  gap:10px;
}

.folder-search{
  margin-bottom:10px;
}

.folder-search input,
.searchbox input,
.toolbar select{
  width:100%;

  border:
    1px solid var(--line);

  border-radius:9px;

  background:#fff;
  color:var(--ink);

  outline:none;

  padding:10px 11px;
}

.folder-search input:focus,
.searchbox input:focus,
.toolbar select:focus,
textarea:focus{
  border-color:var(--wine);

  box-shadow:
    0 0 0 3px
    rgba(122,32,49,.08);
}

.tree-all,
.folder-node{
  width:100%;

  min-height:36px;

  display:flex;
  align-items:center;

  gap:8px;

  padding:6px 8px;

  border:0;
  border-radius:8px;

  background:transparent;
  color:#494541;

  text-align:left;

  font-size:13px;
}

.tree-all:hover,
.folder-node:hover{
  background:#faf7f5;
}

.tree-all.active,
.folder-node.active{
  background:var(--wine-soft);
  color:var(--wine);

  font-weight:700;
}

.folder-icon{
  width:18px;

  color:var(--gold);
}

.tree-count{
  margin-left:auto;

  color:#85807b;

  font-size:11px;
}

.folder-branch{
  margin-left:13px;

  padding-left:8px;

  border-left:
    1px solid var(--line);
}

.folder-row{
  display:flex;
  align-items:center;
}

.folder-row .folder-node{
  flex:1;
}

.folder-menu{
  width:26px;

  opacity:0;

  border:0;

  background:transparent;
  color:#817b76;
}

.folder-row:hover .folder-menu{
  opacity:1;
}

.folder-help{
  margin-top:22px;

  padding:
    14px 5px 0;

  border-top:
    1px solid var(--line);

  color:var(--muted);

  font-size:11px;
  line-height:1.5;
}

.folder-help strong{
  color:#494541;
}

/* =========================================================
   KNOWLEDGE BASE
   ========================================================= */

.hero-row{
  margin-bottom:21px;

  display:flex;
  align-items:flex-start;
  justify-content:space-between;

  gap:24px;
}

.hero-actions{
  display:flex;

  gap:8px;
}

.toolbar{
  margin-bottom:12px;

  display:grid;

  grid-template-columns:
    minmax(240px,1fr)
    145px
    125px
    180px
    auto;

  gap:9px;
}

.searchbox{
  display:flex;
  align-items:center;

  gap:5px;

  padding-left:9px;

  border:
    1px solid var(--line);

  border-radius:9px;

  background:#fff;
}

.searchbox input{
  padding-left:3px;

  border:0;

  box-shadow:none !important;
}

.toolbar select{
  height:39px;
}

.selection-strip{
  height:42px;

  padding:0 12px;

  display:flex;
  align-items:center;

  gap:17px;

  border:
    1px solid var(--line);

  border-bottom:0;

  border-radius:
    10px 10px 0 0;

  background:#fbfaf8;

  color:var(--muted);

  font-size:12px;
}

.selection-spacer{
  flex:1;
}

.document-table-wrap{
  overflow:hidden;

  border:
    1px solid var(--line);

  border-radius:
    0 0 11px 11px;

  background:#fff;

  box-shadow:
    0 5px 18px
    rgba(50,40,35,.03);
}

.document-table{
  width:100%;

  table-layout:fixed;

  border-collapse:collapse;
}

.document-table th{
  padding:10px 12px;

  border-bottom:
    1px solid var(--line);

  background:#fff;

  color:#77716b;

  text-align:left;

  text-transform:uppercase;

  letter-spacing:.07em;

  font-size:10px;
}

.document-table td{
  padding:12px;

  vertical-align:middle;

  border-bottom:
    1px solid #eee9e3;

  font-size:12px;
}

.document-table tr:last-child td{
  border-bottom:0;
}

.document-table tbody tr:hover{
  background:#fdfbf9;
}

.check-col{
  width:38px;
}

.doc-name{
  overflow:hidden;

  margin-bottom:4px;

  white-space:nowrap;

  text-overflow:ellipsis;

  color:#34312f;

  font-size:12.5px;
  font-weight:700;
}

.doc-id{
  color:#98918b;

  font-family:
    ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;

  font-size:9px;
}

.status-chip{
  display:inline-flex;
  align-items:center;

  gap:5px;

  padding:4px 7px;

  border-radius:99px;

  background:var(--success-soft);
  color:var(--success);

  font-size:10px;
  font-weight:700;
}

.status-chip::before{
  content:"";

  width:5px;
  height:5px;

  border-radius:50%;

  background:currentColor;
}

.row-action{
  border:0;

  background:transparent;
  color:#7f7973;

  font-size:16px;
}

/* =========================================================
   SELECTED DOCUMENTS
   ========================================================= */

.selection-badge{
  min-width:27px;
  height:27px;

  display:grid;
  place-items:center;

  border-radius:50%;

  background:var(--wine);
  color:#fff;

  font-size:11px;
  font-weight:800;
}

.scope-card{
  padding:12px;

  border:
    1px solid var(--line);

  border-radius:9px;

  background:#fbfaf8;

  color:#625d58;

  font-size:11px;
  line-height:1.5;
}

.selected-list{
  overflow:auto;

  max-height:55vh;

  margin-top:12px;
}

.selected-doc{
  padding:9px 4px;

  display:flex;
  align-items:flex-start;

  gap:7px;

  border-bottom:
    1px solid #eee9e3;
}

.selected-doc-title{
  flex:1;

  min-width:0;

  font-size:11px;
  line-height:1.35;
}

.remove-selected{
  border:0;

  background:transparent;
  color:#9a555f;
}

.scope-contract{
  margin-top:18px;

  padding:12px;

  border-left:
    3px solid var(--gold);

  background:var(--gold-soft);
  color:#665b4e;

  font-size:11px;
  line-height:1.5;
}

.scope-contract-title{
  margin-bottom:3px;

  font-weight:800;
}

/* =========================================================
   VIEWS
   ========================================================= */

.view{
  display:none;
}

.view.active{
  display:block;
}

.analysis-shell{
  max-width:1080px;

  margin:0 auto;
}

.analysis-header{
  margin-bottom:20px;

  display:flex;
  justify-content:space-between;

  gap:20px;
}

.prompt-card,
.progress-card,
.answer-card,
.placeholder-card{
  border:
    1px solid var(--line);

  border-radius:var(--radius);

  background:#fff;

  box-shadow:var(--shadow);
}

.prompt-card{
  padding:15px;
}

textarea{
  width:100%;

  resize:vertical;

  border:0;

  outline:0;

  color:var(--ink);

  font-size:14px;
  line-height:1.55;
}

.prompt-footer{
  padding-top:11px;

  display:flex;
  align-items:center;
  justify-content:space-between;

  border-top:
    1px solid var(--line);
}

.analysis-mode{
  display:flex;
  align-items:center;

  gap:7px;

  color:var(--muted);

  font-size:11px;
}

.analysis-mode select{
  padding:6px 8px;

  border:
    1px solid var(--line);

  border-radius:7px;
}

/* =========================================================
   PROGRESS
   ========================================================= */

.progress-card{
  margin-top:16px;

  padding:18px;
}

.progress-title{
  margin-bottom:15px;

  font-size:12px;
  font-weight:800;
}

.progress-steps{
  display:grid;

  grid-template-columns:
    repeat(6,1fr);

  gap:8px;
}

.progress-step{
  color:#9b958f;

  font-size:10px;
}

.progress-step::before{
  content:"";

  display:block;

  width:100%;
  height:3px;

  margin-bottom:8px;

  border-radius:5px;

  background:#e8e2dc;
}

.progress-step.active{
  color:var(--wine);

  font-weight:700;
}

.progress-step.active::before{
  background:var(--wine);
}

.progress-step.done{
  color:var(--success);
}

.progress-step.done::before{
  background:var(--success);
}

/* =========================================================
   ANSWER
   ========================================================= */

.answer-card{
  overflow:hidden;

  margin-top:16px;
}

.answer-tabs{
  padding:0 14px;

  display:flex;

  border-bottom:
    1px solid var(--line);
}

.answer-tab{
  position:relative;

  padding:13px 14px;

  border:0;

  background:transparent;
  color:#706a65;

  font-size:11px;
  font-weight:700;
}

.answer-tab.active{
  color:var(--wine);
}

.answer-tab.active::after{
  content:"";

  position:absolute;

  bottom:0;
  left:12px;
  right:12px;

  height:2px;

  background:var(--wine);
}

.answer-panel{
  overflow:auto;

  display:none;

  padding:20px;

  font-size:12px;
  line-height:1.65;
}

.answer-panel.active{
  display:block;
}

.answer-panel pre{
  margin:0;

  white-space:pre-wrap;

  font-family:inherit;
}

.source-card{
  margin:7px 0;

  padding:10px;

  border:
    1px solid var(--line);

  border-radius:8px;
}

.source-card strong{
  color:var(--wine);
}

.validation-ok{
  padding:11px;

  border-radius:8px;

  background:var(--success-soft);
  color:var(--success);

  font-weight:700;
}

.placeholder-card{
  padding:45px;

  text-align:center;
}

/* =========================================================
   EMPTY / UTILITIES
   ========================================================= */

.empty-state{
  padding:50px 20px;

  text-align:center;

  color:var(--muted);
}

.empty-icon{
  color:var(--gold);

  font-size:35px;
}

.hidden{
  display:none !important;
}

.toast{
  position:fixed;

  z-index:999;

  bottom:22px;
  left:50%;

  opacity:0;

  pointer-events:none;

  transform:
    translate(-50%,20px);

  transition:.2s ease;

  padding:10px 15px;

  border-radius:8px;

  background:#292624;
  color:#fff;

  font-size:12px;
}

.toast.show{
  opacity:1;

  transform:
    translate(-50%,0);
}

footer{
  height:36px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-top:
    1px solid var(--line);

  background:#fff;

  color:#847e79;

  font-size:10px;
}

@media(max-width:1180px){

  .workspace{
    grid-template-columns:
      235px
      1fr;
  }

  .selection-pane{
    display:none;
  }

  .toolbar{
    grid-template-columns:
      1fr
      130px
      120px;
  }

  .toolbar .btn{
    display:none;
  }
}


/* =========================================================
   ANSWER EXPERIENCE V2
   ========================================================= */

.answer-panel{
  padding:24px;
  font-size:13px;
  line-height:1.65;
}

.answer-document{
  color:var(--ink);
}

.answer-document p{
  margin:0 0 14px;
  max-width:920px;
}

.answer-heading{
  margin:24px 0 11px;
  color:#312d2b;
  line-height:1.3;
  letter-spacing:-.015em;
}

.answer-document h4.answer-heading{
  padding-bottom:8px;
  border-bottom:1px solid #eee8e2;
  color:var(--wine);
  font-size:15px;
  font-weight:750;
}

.answer-document h5.answer-heading{
  font-size:14px;
}

.answer-document strong{
  font-weight:750;
}

.answer-document code{
  padding:2px 5px;
  border:1px solid #e8e1da;
  border-radius:5px;
  background:#faf8f5;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  font-size:.92em;
}

.citation-ref{
  display:inline-flex;
  padding:2px 6px;
  border:1px solid #e3d7ca;
  border-radius:5px;
  background:#fbf7f2;
  color:#775d42;
  white-space:nowrap;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  font-size:10px;
  font-weight:650;
}

.answer-table-wrap{
  width:100%;
  margin:14px 0 22px;
  overflow:auto;
  border:1px solid #ddd6cf;
  border-radius:10px;
  background:#fff;
}

.answer-table{
  width:100%;
  min-width:760px;
  border-collapse:collapse;
  font-size:12px;
  line-height:1.5;
}

.answer-table thead{
  position:sticky;
  top:0;
  z-index:1;
}

.answer-table th{
  padding:11px 12px;
  border-right:1px solid #e8e1db;
  border-bottom:1px solid #d9d0c7;
  background:#f7f3ef;
  color:#514942;
  text-align:left;
  vertical-align:bottom;
  font-size:10px;
  font-weight:800;
  letter-spacing:.04em;
  text-transform:uppercase;
}

.answer-table td{
  padding:11px 12px;
  border-right:1px solid #eee8e2;
  border-bottom:1px solid #eee8e2;
  vertical-align:top;
  color:#3f3a36;
}

.answer-table th:last-child,
.answer-table td:last-child{
  border-right:0;
}

.answer-table tbody tr:last-child td{
  border-bottom:0;
}

.answer-table tbody tr:hover{
  background:#fcfaf8;
}

.answer-list{
  margin:8px 0 16px 20px;
  padding:0;
}

.answer-list li{
  margin:5px 0;
}

.answer-observation{
  margin:7px 0;
  padding-left:12px;
  border-left:2px solid var(--gold);
}

.follow-up-section{
  margin-top:24px;
  padding-top:18px;
  border-top:1px solid #ece6e0;
}

.follow-up-label{
  margin-bottom:9px;
  color:#716a64;
  font-size:10px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.follow-up-list{
  display:flex;
  flex-direction:column;
  gap:7px;
}

.follow-up-button{
  width:100%;
  display:flex;
  align-items:flex-start;
  gap:9px;
  padding:10px 12px;
  border:1px solid #e2dbd4;
  border-radius:9px;
  background:#fff;
  color:#4b4541;
  text-align:left;
  font:inherit;
  line-height:1.45;
  cursor:pointer;
  transition:
    border-color .15s ease,
    background .15s ease,
    transform .15s ease;
}

.follow-up-button:hover{
  border-color:#cbb8a3;
  background:#fcf9f6;
  transform:translateY(-1px);
}

.follow-up-arrow{
  flex:0 0 auto;
  color:var(--wine);
  font-weight:800;
}

.answer-validation-status{
  width:max-content;
  max-width:100%;
  margin-top:18px;
  display:flex;
  align-items:center;
  gap:7px;
  padding:7px 10px;
  border-radius:7px;
  font-size:11px;
  font-weight:700;
}

.answer-validation-status.success{
  background:var(--success-soft);
  color:var(--success);
}

.answer-validation-status.warning{
  background:#fff4e5;
  color:#94601b;
}

.validation-icon{
  width:17px;
  height:17px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid currentColor;
  border-radius:50%;
  font-size:10px;
  font-weight:900;
}

.technical-details{
  margin-top:13px;
  border-top:1px solid #eee8e2;
}

.technical-details > summary{
  width:max-content;
  padding:12px 0 4px;
  color:#827a73;
  font-size:10.5px;
  font-weight:700;
  cursor:pointer;
  user-select:none;
}

.technical-details-body{
  margin-top:10px;
  padding:14px;
  border:1px solid #e8e1da;
  border-radius:9px;
  background:#faf9f7;
}

.technical-details pre{
  max-height:300px;
  overflow:auto;
  margin:6px 0 0;
  padding:10px;
  border-radius:7px;
  background:#fff;
  color:#5a544f;
  white-space:pre-wrap;
  word-break:break-word;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  font-size:10px;
  line-height:1.5;
}

.technical-section-title{
  margin-bottom:6px;
  color:#5d5650;
  font-size:10px;
  font-weight:800;
  letter-spacing:.06em;
  text-transform:uppercase;
}

.evidence-title{
  margin-top:18px;
}

.technical-evidence{
  margin-top:8px;
  padding:10px;
  border:1px solid #e9e3dc;
  border-radius:7px;
  background:#fff;
}

.technical-evidence-title{
  margin-bottom:5px;
  color:#685f58;
  font-size:10px;
  font-weight:750;
}

.technical-evidence-text{
  color:#68615b;
  font-size:10px;
  line-height:1.5;
}

.sources-intro{
  margin-bottom:14px;
  color:#716a64;
  font-size:11px;
}

.source-card{
  margin:0 0 9px;
  padding:12px 13px;
  border:1px solid #e4ddd6;
  border-radius:9px;
  background:#fff;
}

.source-card-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:15px;
}

.source-card strong{
  color:#463f3a;
  font-size:12px;
}

.source-page{
  flex:0 0 auto;
  padding:3px 7px;
  border-radius:99px;
  background:#f6f1eb;
  color:var(--wine);
  font-size:9.5px;
  font-weight:750;
}

.source-meta{
  margin-top:5px;
  color:#99918a;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  font-size:9px;
}

.source-section{
  margin-top:6px;
  color:#716a64;
  font-size:10.5px;
}

.sources-empty{
  padding:20px 0;
  color:var(--muted);
}

@media (max-width:800px){

  .answer-panel{
    padding:16px;
  }

  .answer-table{
    min-width:680px;
  }

}


/* ==========================================================
   KNOWLEDGE BASE — UPLOAD DOCUMENTS
   ========================================================== */

.upload-documents-btn {
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(28, 24, 22, 0.42);
  backdrop-filter: blur(5px);
}

.modal-backdrop.hidden {
  display: none;
}

.upload-modal {
  width: min(760px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #E4DED5;
  border-radius: 18px;
  box-shadow:
    0 24px 70px rgba(34, 28, 24, 0.22);
}

.upload-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px 20px;
  border-bottom: 1px solid #E4DED5;
}

.upload-modal-header h2 {
  margin: 4px 0 7px;
  color: #252525;
  font-size: 24px;
  line-height: 1.2;
}

.upload-modal-header p {
  margin: 0;
  max-width: 590px;
  color: #68645F;
  font-size: 14px;
  line-height: 1.55;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid #E4DED5;
  border-radius: 9px;
  background: #fff;
  color: #68645F;
  cursor: pointer;
  font-size: 24px;
  line-height: 30px;
}

.modal-close:hover {
  border-color: #B58B55;
  color: #7A2031;
}

.upload-dropzone {
  margin: 24px 28px 16px;
  min-height: 160px;
  border: 1.5px dashed #CFC5B8;
  border-radius: 14px;
  background: #FAF9F6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  transition:
    border-color .16s ease,
    background .16s ease,
    transform .16s ease;
}

.upload-dropzone:hover,
.upload-dropzone.drag-active,
.upload-dropzone:focus {
  outline: none;
  border-color: #7A2031;
  background: #FBF6F7;
}

.upload-drop-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 3px;
  border-radius: 11px;
  background: #F1E9EA;
  color: #7A2031;
  font-size: 22px;
  font-weight: 700;
}

.upload-dropzone strong {
  color: #252525;
  font-size: 15px;
}

.upload-dropzone span {
  color: #7A2031;
  font-size: 13px;
  font-weight: 600;
}

.upload-dropzone small {
  color: #807B75;
  font-size: 12px;
}

.upload-file-list {
  margin: 0 28px 18px;
  border: 1px solid #E4DED5;
  border-radius: 12px;
  overflow: hidden;
}

.upload-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 13px;
  border-bottom: 1px solid #EEEAE4;
}

.upload-file-item:last-child {
  border-bottom: 0;
}

.upload-file-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upload-file-main strong {
  overflow: hidden;
  color: #252525;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-main span {
  color: #807B75;
  font-size: 11px;
}

.upload-file-remove {
  border: 0;
  background: transparent;
  color: #8A8580;
  cursor: pointer;
  font-size: 20px;
}

.upload-metadata {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  padding: 2px 28px 24px;
}

.upload-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-field-wide {
  grid-column: 1 / -1;
}

.upload-field label {
  color: #494541;
  font-size: 12px;
  font-weight: 650;
}

.upload-field input,
.upload-field select,
.upload-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #DDD6CC;
  border-radius: 9px;
  background: #fff;
  padding: 10px 11px;
  color: #252525;
  font: inherit;
  font-size: 13px;
}

.upload-field input:focus,
.upload-field select:focus,
.upload-field textarea:focus {
  outline: none;
  border-color: #B58B55;
  box-shadow: 0 0 0 3px rgba(181, 139, 85, .10);
}

.upload-progress {
  margin: 0 28px 22px;
  border: 1px solid #E4DED5;
  border-radius: 12px;
  overflow: hidden;
}

.upload-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 13px;
  border-bottom: 1px solid #EEEAE4;
}

.upload-progress-row:last-child {
  border-bottom: 0;
}

.upload-progress-row > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upload-progress-row strong {
  overflow: hidden;
  color: #252525;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress-row span {
  color: #807B75;
  font-size: 11px;
}

.upload-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  font-weight: 700;
}

.upload-status.working {
  background: #F6F0E8;
  color: #A66C1D;
}

.upload-status.success {
  background: #EAF3EE;
  color: #2F6B52;
}

.upload-status.error {
  background: #F7E9EB;
  color: #7A2031;
}

.upload-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 18px 28px;
  border-top: 1px solid #E4DED5;
  background: #FAF9F6;
  border-radius: 0 0 18px 18px;
}

.upload-footer-note {
  max-width: 420px;
  color: #77726D;
  font-size: 11px;
  line-height: 1.45;
}

.upload-footer-actions {
  display: flex;
  gap: 9px;
}

@media (max-width: 760px) {
  .upload-metadata {
    grid-template-columns: 1fr;
  }

  .upload-field-wide {
    grid-column: auto;
  }

  .upload-modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-footer-actions {
    justify-content: flex-end;
  }
}
/* AUDITINTEL FOLDER SIDEBAR PATCH */

/* Separate hero-level Subfolder button is no longer needed */
#newSubfolder{
  display:none !important;
}


/* ---------------------------------------------------------
   Folder row child-folder control
   --------------------------------------------------------- */

.folder-row{
  position:relative;
}

.folder-add{
  width:25px;
  height:25px;

  flex:0 0 25px;

  display:flex;
  align-items:center;
  justify-content:center;

  opacity:0;

  border:1px solid transparent;
  border-radius:6px;

  background:transparent;
  color:var(--wine);

  font-size:17px;
  line-height:1;

  cursor:pointer;

  transition:
    opacity .15s ease,
    background .15s ease,
    border-color .15s ease;
}

.folder-row:hover .folder-add,
.folder-add:focus{
  opacity:1;
}

.folder-add:hover{
  border-color:#d9c1c6;
  background:var(--wine-soft);
}

.folder-branch{
  position:relative;

  margin-left:15px;
  padding-left:10px;
}

.folder-branch::before{
  content:"";

  position:absolute;

  left:0;
  top:0;
  bottom:7px;

  width:1px;

  background:#e8e1da;
}


/* ---------------------------------------------------------
   Collapsible selected-document sidebar
   --------------------------------------------------------- */

.workspace{
  transition:
    grid-template-columns .2s ease;
}

.workspace.scope-collapsed{
  grid-template-columns:
    270px
    minmax(640px,1fr)
    42px;
}

.selection-pane{
  position:relative;
}

.scope-pane-toggle{
  position:absolute;

  z-index:20;

  top:18px;
  left:-14px;

  width:28px;
  height:28px;

  display:flex;
  align-items:center;
  justify-content:center;

  border:1px solid var(--line);
  border-radius:50%;

  background:#fff;
  color:var(--wine);

  box-shadow:
    0 3px 12px
    rgba(42,31,27,.12);

  font-size:18px;
  font-weight:700;

  cursor:pointer;
}

.scope-pane-toggle:hover{
  background:var(--wine-soft);
}

.selection-pane.collapsed{
  padding:
    18px 6px;
}

.selection-pane.collapsed
  > :not(.scope-pane-toggle){
  display:none !important;
}

.content-pane{
  min-width:0;
}


/* Answer tables can use the extra width */
.answer-table-wrap{
  width:100%;
  overflow-x:auto;
}

.answer-table{
  min-width:max-content;
}


/* Responsive */
@media (max-width:1250px){

  .workspace{
    grid-template-columns:
      230px
      minmax(520px,1fr)
      255px;
  }

  .workspace.scope-collapsed{
    grid-template-columns:
      230px
      minmax(520px,1fr)
      42px;
  }
}

@media (max-width:960px){

  .workspace,
  .workspace.scope-collapsed{
    grid-template-columns:
      210px
      minmax(0,1fr);
  }

  .selection-pane{
    display:none;
  }
}
/* AUDITINTEL TOOL WORKSPACES R3 */

.tool-workspace{
  width:100%;
  max-width:none;

  padding-bottom:34px;
}

.tool-header{
  margin-bottom:17px;
}

.tool-scope-pill{
  display:inline-flex;

  margin-top:7px;

  padding:5px 9px;

  border:1px solid #ddc9ce;
  border-radius:99px;

  background:var(--wine-soft);
  color:var(--wine);

  font-size:10px;
  font-weight:800;
}

.tool-card{
  margin-bottom:15px;

  padding:18px;

  border:1px solid var(--line);
  border-radius:11px;

  background:#fff;

  box-shadow:
    0 5px 18px
    rgba(50,40,35,.03);
}

.tool-label{
  display:block;

  margin-bottom:7px;

  color:#4a4541;

  font-size:11px;
  font-weight:800;
}

.tool-label-spaced{
  margin-top:15px;
}

.tool-textarea,
.tool-input{
  width:100%;

  border:1px solid var(--line);
  border-radius:8px;

  background:#fff;

  color:inherit;
  font:inherit;

  box-sizing:border-box;
}

.tool-textarea{
  min-height:105px;

  padding:12px 13px;

  resize:vertical;

  line-height:1.5;
}

.tool-input{
  height:40px;

  padding:0 12px;
}

.tool-textarea:focus,
.tool-input:focus{
  outline:none;

  border-color:#b88b96;

  box-shadow:
    0 0 0 3px
    rgba(122,32,49,.07);
}

.tool-actions{
  margin-top:14px;

  display:flex;
  align-items:center;
  flex-wrap:wrap;

  gap:8px;
}

.suggestion-row{
  margin-top:11px;

  display:flex;
  flex-wrap:wrap;

  gap:7px;
}

.suggestion-chip{
  padding:6px 9px;

  border:1px solid var(--line);
  border-radius:99px;

  background:#faf8f5;
  color:#5e5751;

  font-size:10px;
  font-weight:700;

  cursor:pointer;
}

.suggestion-chip:hover{
  border-color:#cdaeb5;

  background:var(--wine-soft);
  color:var(--wine);
}

.tool-result{
  min-width:0;
}

.tool-result:empty{
  display:none;
}

.tool-loading,
.tool-error,
.empty-tool-result{
  padding:17px;

  border:1px solid var(--line);
  border-radius:9px;

  background:#fff;

  font-size:12px;
}

.tool-loading{
  color:var(--muted);
}

.tool-error{
  border-color:#e2bbbb;

  background:#fff7f7;
  color:#8b2c2c;
}

.tool-answer{
  margin-top:10px;

  padding:20px;

  overflow:hidden;

  border:1px solid var(--line);
  border-radius:10px;

  background:#fff;

  font-size:12px;
  line-height:1.65;
}

.tool-validation-ok{
  margin-bottom:9px;

  padding:9px 11px;

  border-radius:8px;

  background:var(--success-soft);
  color:var(--success);

  font-size:11px;
  font-weight:800;
}

.tool-validation-warning{
  margin-bottom:9px;

  padding:9px 11px;

  border:1px solid #ead8b7;
  border-radius:8px;

  background:#fffaf0;
  color:#7f5a1d;

  font-size:11px;
}

.tool-section-title{
  margin-bottom:11px;

  color:#3f3935;

  font-size:12px;
  font-weight:800;
}

.tool-muted{
  color:var(--muted);

  font-size:11px;
}

.tool-sources{
  margin-top:12px;
}

.tool-source-section{
  margin-top:3px;

  color:var(--muted);

  font-size:10px;
}


/* Wide comparison / extraction tables */

.tool-answer .answer-table-wrap,
.tool-result .answer-table-wrap{
  width:100%;

  overflow-x:auto;
}

.tool-answer .answer-table,
.tool-result .answer-table{
  width:100%;

  min-width:max-content;
}

.extraction-table td:first-child{
  min-width:220px;
}

.extraction-table th,
.extraction-table td{
  min-width:125px;
}

.extract-citation{
  margin-top:5px;

  color:var(--wine);

  font-size:9px;
  font-weight:800;
}

.extract-note{
  margin-top:3px;

  max-width:220px;

  color:var(--muted);

  font-size:9px;
}


/* Insights */

.insight-grid{
  display:grid;

  grid-template-columns:
    repeat(4,minmax(0,1fr));

  gap:10px;

  margin-bottom:15px;
}

.insight-kpi{
  padding:15px;

  border:1px solid var(--line);
  border-radius:10px;

  background:#fff;
}

.insight-kpi span{
  display:block;

  margin-bottom:6px;

  color:var(--muted);

  font-size:10px;
  font-weight:700;
}

.insight-kpi strong{
  color:var(--wine-dark);

  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size:25px;
}

.scope-type-list{
  display:grid;

  gap:7px;
}

.scope-type-row{
  padding:8px 10px;

  display:flex;
  align-items:center;
  justify-content:space-between;

  border:1px solid var(--line);
  border-radius:7px;

  background:#fbfaf8;

  font-size:11px;
}


@media (max-width:1250px){

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

@media (max-width:720px){

  .insight-grid{
    grid-template-columns:
      1fr;
  }
}

/* =========================================================
   AUTHENTICATED USER AREA
   ========================================================= */

.topbar-right{
  display:flex;
  align-items:center;
  gap:14px;
  margin-left:auto;
}

.user-account{
  display:flex;
  align-items:center;
  gap:9px;

  padding-left:14px;

  border-left:
    1px solid var(--line);
}

.user-avatar{
  width:30px;
  height:30px;

  display:grid;
  place-items:center;

  border-radius:50%;

  background:#14283f;
  color:#fff;

  font-size:11px;
  font-weight:700;
}

.user-meta{
  min-width:0;
  max-width:165px;
}

.user-name{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;

  color:#2f3337;

  font-size:11px;
  font-weight:700;
}

.user-office{
  margin-top:2px;

  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;

  color:#85817d;

  font-size:9px;
}

.user-logout{
  min-height:30px;

  padding:0 9px;

  border:
    1px solid var(--line);

  border-radius:6px;

  background:#fff;
  color:#5f5a56;

  font-size:10px;
  font-weight:600;

  cursor:pointer;
}

.user-logout:hover{
  border-color:#c9c5c1;
  background:#faf9f7;
}

@media(max-width:1180px){

  .user-meta{
    display:none;
  }

  .user-account{
    padding-left:10px;
  }
}

@media(max-width:900px){

  .system-state{
    display:none;
  }
}

.user-admin-link{
  min-height:30px;

  display:inline-flex;
  align-items:center;

  padding:0 10px;

  border:1px solid #d8d0c6;
  border-radius:6px;

  background:#faf8f5;
  color:#745a3e;

  font-size:10px;
  font-weight:650;

  text-decoration:none;
  white-space:nowrap;
}

.user-admin-link:hover{
  background:#f5f0ea;
  border-color:#cbbda9;
}


/* =========================================================
   AUDITINTEL WORKSPACE REFINEMENT
   ========================================================= */

/* ---------- Global scrollbar ---------- */

html{
  scrollbar-width:thin;
  scrollbar-color:
    rgba(89,78,70,.28)
    transparent;
}

*{
  scrollbar-width:thin;
  scrollbar-color:
    rgba(89,78,70,.22)
    transparent;
}

*::-webkit-scrollbar{
  width:6px;
  height:6px;
}

*::-webkit-scrollbar-track{
  background:transparent;
}

*::-webkit-scrollbar-thumb{
  background:
    rgba(89,78,70,.18);

  border-radius:999px;
}

*::-webkit-scrollbar-thumb:hover{
  background:
    rgba(89,78,70,.38);
}

*::-webkit-scrollbar-corner{
  background:transparent;
}


/* ---------- Top bar ---------- */

.topbar{
  min-height:68px;
  height:auto;

  padding:
    0 20px;

  gap:20px;
}

.brand{
  min-width:230px;
}

.topbar-right{
  gap:9px;
}

.system-state{
  white-space:nowrap;
}

.user-account{
  gap:7px;
  padding-left:10px;
}

.user-meta{
  max-width:135px;
}

.user-admin-link,
.user-logout{
  min-height:28px;

  padding:
    0 8px;
}


/* ---------- Main 3-column workspace ---------- */

.workspace{
  min-height:
    calc(100vh - 150px);

  grid-template-columns:
    220px
    minmax(0,1fr)
    245px;

  align-items:stretch;
}


/* ---------- Left folder sidebar ---------- */

.folder-pane{
  position:sticky;

  top:0;

  align-self:start;

  height:
    calc(100vh - 150px);

  overflow-y:auto;
  overflow-x:hidden;

  padding:
    18px 13px;

  overscroll-behavior:contain;
}


/* ---------- Right active scope ---------- */

.selection-pane{
  position:sticky;

  top:0;

  align-self:start;

  height:
    calc(100vh - 150px);

  overflow-y:auto;
  overflow-x:hidden;

  padding:
    18px 13px;

  overscroll-behavior:contain;
}


/* ---------- Main content ---------- */

.content-pane{
  min-width:0;

  overflow-x:hidden;
  overflow-y:auto;

  padding:
    24px 24px 38px;
}


/* ---------- Document header ---------- */

.content-pane h1{
  font-size:28px;
}

.content-pane h2{
  font-size:17px;
}


/* ---------- Toolbar / filters ---------- */

.toolbar{
  gap:9px;
}

.toolbar input,
.toolbar select{
  min-width:0;
}


/* ---------- Document table ---------- */

.document-table-wrap{
  max-width:100%;

  overflow-x:auto;
  overflow-y:hidden;
}

.document-table{
  min-width:760px;
}


/* ---------- Active scope ---------- */

.selected-list{
  max-height:
    calc(100vh - 370px);

  overflow-y:auto;
}


/* ---------- Keep cards breathable ---------- */

.scope-contract{
  padding:12px;
}

.folder-pane,
.selection-pane,
.content-pane{
  box-sizing:border-box;
}


/* =========================================================
   RESPONSIVE WORKSPACE
   ========================================================= */

@media(max-width:1380px){

  .workspace{
    grid-template-columns:
      205px
      minmax(0,1fr)
      225px;
  }

  .brand{
    min-width:205px;
  }

  .topbar{
    gap:14px;
    padding:
      0 16px;
  }

  .content-pane{
    padding:
      22px 20px 34px;
  }

  .user-meta{
    display:none;
  }
}


@media(max-width:1180px){

  .workspace{
    grid-template-columns:
      205px
      minmax(0,1fr);
  }

  .selection-pane{
    display:none;
  }

  .folder-pane{
    height:
      calc(100vh - 150px);
  }

  .content-pane{
    padding:
      20px 18px 32px;
  }

  .system-state{
    display:none;
  }
}


@media(max-width:900px){

  .workspace{
    grid-template-columns:
      180px
      minmax(0,1fr);
  }

  .brand{
    min-width:auto;
  }

  .brand-subtitle{
    display:none;
  }

  .content-pane{
    padding:
      18px 15px 30px;
  }

  .user-avatar{
    display:none;
  }
}


@media(max-width:720px){

  .workspace{
    display:block;
  }

  .folder-pane{
    position:relative;

    height:auto;
    max-height:260px;

    border-right:0;
    border-bottom:
      1px solid var(--line);
  }

  .content-pane{
    overflow:visible;
  }
}


/* =========================================================
   DATASET DOCUMENT INDICATORS
   ========================================================= */

.dataset-meta{
  display:flex;
  align-items:center;
  gap:6px;
  margin-top:5px;
  color:#827b74;
  font-size:9px;
}

.dataset-badge{
  display:inline-flex;
  align-items:center;
  min-height:18px;
  padding:0 6px;
  border:1px solid #d8d0c6;
  border-radius:999px;
  background:#faf7f2;
  color:#745a3e;
  font-size:8px;
  font-weight:750;
  letter-spacing:.06em;
}



/* =========================================================
   ANALYSIS HISTORY + SAVED ANSWERS
   ========================================================= */

.answer-tab-spacer{
  flex:1;
}

.answer-action-btn{
  border:1px solid #d9d3cb;
  background:#fff;
  border-radius:8px;
  min-height:32px;
  padding:0 10px;
  font:inherit;
  font-size:12px;
  font-weight:650;
  cursor:pointer;
}

.answer-action-btn:hover:not(:disabled){
  background:#f7f5f2;
}

.answer-action-btn:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.history-drawer{
  position:fixed;
  z-index:1200;
  top:0;
  right:0;
  width:min(430px,94vw);
  height:100vh;
  background:#fff;
  border-left:1px solid #ddd7cf;
  box-shadow:-16px 0 40px rgba(21,26,35,.12);
  display:flex;
  flex-direction:column;
}

.history-drawer.hidden{
  display:none;
}

.history-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
  padding:22px 20px 16px;
  border-bottom:1px solid #ebe7e2;
}

.history-header h2{
  margin:4px 0 0;
}

.history-tabs{
  display:flex;
  align-items:center;
  gap:8px;
  padding:12px 16px;
  border-bottom:1px solid #ebe7e2;
}

.history-tab{
  border:0;
  background:transparent;
  padding:7px 9px;
  border-radius:7px;
  font:inherit;
  font-size:12px;
  font-weight:650;
  cursor:pointer;
}

.history-tab.active{
  background:#f0eee9;
}

.history-tab-spacer{
  flex:1;
}

.history-clear{
  border:0;
  background:transparent;
  font:inherit;
  font-size:11px;
  color:#766e65;
  cursor:pointer;
}

.history-list{
  flex:1;
  overflow-y:auto;
  padding:10px;
}

.history-item{
  position:relative;
  border:1px solid #e6e1da;
  border-radius:10px;
  margin-bottom:9px;
  background:#fff;
}

.history-open{
  width:100%;
  border:0;
  background:transparent;
  text-align:left;
  padding:13px 13px 38px;
  cursor:pointer;
  font:inherit;
}

.history-open:hover{
  background:#faf9f7;
}

.history-item-top{
  display:flex;
  align-items:center;
  gap:7px;
  margin-bottom:7px;
}

.history-mode{
  font-size:9px;
  font-weight:800;
  letter-spacing:.08em;
  color:#65594b;
}

.history-saved{
  font-size:10px;
  color:#725a37;
}

.history-title{
  display:block;
  font-size:13px;
  line-height:1.4;
  margin-bottom:5px;
}

.history-time{
  display:block;
  font-size:10px;
  color:#8a8178;
}

.history-preview{
  display:block;
  margin-top:8px;
  font-size:11px;
  line-height:1.45;
  color:#625d57;
}

.history-delete{
  position:absolute;
  right:10px;
  bottom:8px;
  border:0;
  background:transparent;
  color:#8a4c4c;
  font:inherit;
  font-size:10px;
  cursor:pointer;
}

.history-empty{
  padding:30px 18px;
  text-align:center;
  color:#827a72;
  font-size:12px;
}

@media (max-width:720px){
  .answer-tabs{
    flex-wrap:wrap;
  }

  .answer-tab-spacer{
    display:none;
  }

  .answer-action-btn{
    margin-left:4px;
  }
}

