/* ==========================================================================
   WESMAN — AI-Based Document Management System
   Prototype stylesheet
   ========================================================================== */

:root {
  --ink-900: #0F1B2D;
  --ink-800: #15243A;
  --ink-700: #1C3049;
  --ink-600: #253C59;
  --steel-500: #5B7A9D;
  --steel-300: #A9BDD2;
  --steel-100: #E4EBF2;

  --paper-50: #F4F5F3;
  --paper-0: #FFFFFF;

  --amber-500: #E0A526;
  --amber-600: #C68E17;
  --amber-100: #FBEDCC;

  --teal-500: #1E8A85;
  --teal-600: #166B67;
  --teal-100: #DDF0EE;

  --danger: #C0392B;
  --danger-100: #FAE1DD;
  --success: #2F8F5B;
  --success-100: #E1F3E8;

  --border: #DDE3E8;
  --border-strong: #C7D0D9;

  --text-900: #131B24;
  --text-600: #4B5A68;
  --text-400: #8598A6;
  --text-on-ink: #EDF1F5;
  --text-on-ink-dim: #8FA3B8;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 14px;

  --font-display: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --sidebar-w: 248px;
  --header-h: 60px;
  --band-h: 0px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text-900);
  background: var(--paper-50);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--teal-500);
  outline-offset: 2px;
}
::selection { background: var(--amber-100); }

.mono { font-family: var(--font-mono); letter-spacing: -0.01em; }

/* ------------------------------------------------------------------------
   Blueprint grid texture — subtle nod to engineering drawings
   ------------------------------------------------------------------------ */
.blueprint-grid {
  background-image:
    linear-gradient(rgba(169,189,210,0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(169,189,210,0.14) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
@media (max-width: 880px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

.login-brand {
  background: var(--ink-900);
  color: var(--text-on-ink);
  position: relative;
  overflow: hidden;
  padding: 56px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(169,189,210,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(169,189,210,0.10) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(ellipse at 30% 20%, black 40%, transparent 85%);
}
.login-brand__top { position: relative; z-index: 1; }
.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark__glyph {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--amber-500);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-900);
  font-size: 17px;
}
.brand-mark__text {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-mark__text small {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--text-on-ink-dim);
  text-transform: uppercase;
  margin-top: 2px;
}

.login-brand__mid {
  position: relative;
  z-index: 1;
  margin-top: 64px;
  max-width: 420px;
}
.login-brand__mid h1 {
  font-size: 34px;
  line-height: 1.18;
  font-weight: 600;
}
.login-brand__mid p {
  margin-top: 14px;
  color: var(--text-on-ink-dim);
  font-size: 14.5px;
  line-height: 1.6;
}

.brand-feed {
  position: relative;
  z-index: 1;
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brand-feed__item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-on-ink-dim);
  border-left: 2px solid var(--ink-600);
  padding-left: 12px;
}
.brand-feed__item b { color: var(--text-on-ink); font-weight: 600; }

.login-brand__bottom {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-on-ink-dim);
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--ink-600);
  padding-top: 16px;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background: var(--paper-0);
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-600);
  font-weight: 700;
  margin-bottom: 8px;
}
.login-card h2 {
  font-size: 24px;
  margin-bottom: 6px;
}
.login-card__sub {
  color: var(--text-400);
  font-size: 13.5px;
  margin-bottom: 28px;
  display: block;
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-600);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--paper-0);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  border-color: var(--teal-500);
  outline: none;
  box-shadow: 0 0 0 3px var(--teal-100);
}
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-600);
}
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--teal-600); }
.link-btn {
  background: none;
  border: none;
  color: var(--teal-600);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14.5px;
  font-weight: 600;
  font-family: var(--font-body);
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink-900); color: var(--paper-0); }
.btn-primary:hover { background: var(--ink-700); }
.btn-ghost {
  background: var(--paper-0);
  color: var(--text-900);
  border: 1.5px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--paper-50); }
.btn-amber { background: var(--amber-500); color: var(--ink-900); }
.btn-amber:hover { background: var(--amber-600); }
.btn-sm { padding: 8px 12px; font-size: 13px; width: auto; }

.divider-note {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-400);
  font-family: var(--font-mono);
}

.form-error {
  display: none;
  background: var(--danger-100);
  color: #7A241A;
  border: 1px solid #EDBAAF;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 16px;
}
.form-error.show { display: block; }

/* ---- MFA step ---- */
.mfa-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  background: var(--teal-100);
  color: var(--teal-700, var(--teal-600));
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
}
.otp-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.otp-row input {
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 20px;
  padding: 10px 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.otp-row input:focus {
  border-color: var(--teal-500);
  outline: none;
  box-shadow: 0 0 0 3px var(--teal-100);
}

/* ---- Role selection step ---- */
.role-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 6px;
}
.role-opt {
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-0);
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.role-opt:hover { border-color: var(--steel-500); background: var(--paper-50); }
.role-opt.selected {
  border-color: var(--teal-500);
  background: var(--teal-100);
}
.role-opt__icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--ink-900);
  color: var(--paper-0);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.role-opt__text b { font-size: 13.5px; display: block; }
.role-opt__text span { font-size: 11.5px; color: var(--text-400); }

.dept-select {
  margin-top: 4px;
}
.dept-select select {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--paper-0);
  font-family: var(--font-body);
}

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--band-h));
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 0 1fr; }
  .sidebar { display: none; }
}

.sidebar {
  background: var(--ink-900);
  color: var(--text-on-ink);
  display: flex;
  flex-direction: column;
  padding: 20px 0 16px;
  position: sticky;
  top: var(--band-h);
  height: calc(100vh - var(--band-h));
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--ink-600);
  margin-bottom: 14px;
}
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-on-ink-dim);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-on-ink-dim);
}
.nav-item svg { flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: var(--ink-700); color: var(--text-on-ink); }
.nav-item.active {
  background: var(--ink-600);
  color: var(--paper-0);
  box-shadow: inset 3px 0 0 var(--amber-500);
}
.nav-item.locked {
  opacity: 0.4;
  cursor: not-allowed;
}
.nav-item .lock-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9px;
  background: var(--ink-700);
  padding: 2px 5px;
  border-radius: 3px;
}

.sidebar__foot {
  border-top: 1px solid var(--ink-600);
  margin-top: 12px;
  padding: 14px 20px 0;
}
.session-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.avatar-chip {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--amber-500);
  color: var(--ink-900);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 13px;
  flex-shrink: 0;
}
.session-card__text b { font-size: 12.5px; display: block; }
.session-card__text span {
  font-size: 11px;
  color: var(--text-on-ink-dim);
  font-family: var(--font-mono);
}
.logout-btn {
  width: 100%;
  background: var(--ink-700);
  color: var(--text-on-ink);
  border: 1px solid var(--ink-600);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.logout-btn:hover { background: var(--ink-600); }

/* ---- Main column ---- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: var(--header-h);
  background: var(--paper-0);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  position: sticky;
  top: var(--band-h);
  z-index: 20;
}
.topbar__crumb {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.topbar__title { font-size: 17px; margin-top: 1px; }
.topbar__right { display: flex; align-items: center; gap: 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.pill-admin { background: var(--amber-100); color: var(--amber-600); }
.pill-dept { background: var(--teal-100); color: var(--teal-700, var(--teal-600)); }
.pill-mgmt { background: var(--steel-100); color: var(--steel-500); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.content {
  flex: 1;
  padding: 28px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

/* ---- Cards / widgets ---- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card__label {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-card__value {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 8px 0 4px;
}
.stat-card__delta { font-size: 12px; color: var(--text-600); }
.stat-card__delta.up { color: var(--success); }
.stat-card__delta.warn { color: var(--amber-600); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 28px 0 12px;
}
.section-title h3 { font-size: 15.5px; }
.section-title span { font-size: 12px; color: var(--text-400); font-family: var(--font-mono); }

.list-card { padding: 0; overflow: hidden; }
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.list-row:last-child { border-bottom: none; }
.list-row__icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--steel-100);
  color: var(--steel-500);
}
.list-row__main { flex: 1; min-width: 0; }
.list-row__main b { font-weight: 600; display: block; }
.list-row__main span { color: var(--text-400); font-size: 12px; }
.tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.tag-amber { background: var(--amber-100); color: var(--amber-600); }
.tag-teal { background: var(--teal-100); color: var(--teal-700, var(--teal-600)); }
.tag-danger { background: var(--danger-100); color: var(--danger); }
.tag-success { background: var(--success-100); color: var(--success); }
.tag-steel { background: var(--steel-100); color: var(--steel-500); }

.confidence-bar {
  width: 60px; height: 5px; border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.confidence-bar__fill { height: 100%; background: var(--teal-500); }

.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--text-400);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.5; }
.empty-state h4 { color: var(--text-600); font-size: 14.5px; margin-bottom: 4px; }
.empty-state p { font-size: 12.5px; max-width: 320px; margin: 0 auto; }

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid;
  margin-bottom: 20px;
}
.notice-info { background: var(--steel-100); border-color: var(--border-strong); color: var(--text-600); }
.notice-amber { background: var(--amber-100); border-color: #EAD09A; color: #7A5A0E; }
.notice-teal { background: var(--teal-100); border-color: #B7DFDA; color: var(--teal-700, var(--teal-600)); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-400);
  padding: 11px 16px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--paper-50); }
.doc-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.doc-name svg { flex-shrink: 0; color: var(--steel-500); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.search-input:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-100); }
.select-filter {
  padding: 10px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--paper-0);
  font-family: var(--font-body);
}

/* ---- AI search / chat ---- */
.ai-shell { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
@media (max-width: 900px) { .ai-shell { grid-template-columns: 1fr; } }
.chat-window {
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 420px;
  display: flex;
  flex-direction: column;
}
.chat-log { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.chat-bubble { max-width: 78%; padding: 12px 15px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; }
.chat-bubble.user { align-self: flex-end; background: var(--ink-900); color: var(--paper-0); border-bottom-right-radius: 3px; }
.chat-bubble.ai { align-self: flex-start; background: var(--paper-50); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-bubble .cite {
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--teal-700, var(--teal-600));
  border-top: 1px dashed var(--border-strong);
  padding-top: 8px;
}
.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.chat-input-row input {
  flex: 1;
  padding: 11px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.chat-input-row input:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-100); }
.suggestion-chip {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper-0);
  font-size: 12.5px;
  margin-bottom: 8px;
  color: var(--text-600);
}
.suggestion-chip:hover { border-color: var(--teal-500); color: var(--text-900); }

/* ---- Access denied ---- */
.access-denied {
  max-width: 460px;
  margin: 60px auto;
  text-align: center;
}
.access-denied__icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--danger-100);
  color: var(--danger);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}

/* scrollbars */
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: var(--ink-600); border-radius: 3px; }

/* ==========================================================================
   PHASE 3 — Management / Department Dashboard widgets
   ========================================================================== */

/* ---- Breadcrumb (used on detail pages reached from KPI cards) ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-400);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--teal-600); font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 12px 14px;
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar__group {
  display: flex;
  align-items: center;
  gap: 7px;
}
.filter-bar__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-400);
}
.filter-bar select {
  padding: 8px 11px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--paper-0);
}
.filter-bar__spacer { flex: 1; }
.filter-bar__note {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-400);
}

/* ---- Clickable KPI cards ---- */
.kpi-card {
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 18px;
  display: block;
  transition: border-color 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
  position: relative;
}
.kpi-card:hover {
  border-color: var(--steel-500);
  box-shadow: 0 4px 14px rgba(15,27,45,0.06);
  transform: translateY(-1px);
}
.kpi-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.kpi-card__icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--steel-100);
  color: var(--steel-500);
  flex-shrink: 0;
}
.kpi-card__arrow {
  color: var(--text-400);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.kpi-card:hover .kpi-card__arrow { opacity: 1; transform: translateX(2px); }
.kpi-card__label {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 12px;
}
.kpi-card__value {
  font-family: var(--font-display);
  font-size: 27px;
  margin: 6px 0 3px;
}
.kpi-card__delta { font-size: 11.5px; color: var(--text-600); }
.kpi-card__delta.up { color: var(--success); }
.kpi-card__delta.warn { color: var(--amber-600); }
.kpi-card__delta.danger { color: var(--danger); }

/* ---- Bar chart (Documents by Department) ---- */
.barchart { display: flex; flex-direction: column; gap: 13px; }
.barchart-row {
  display: grid;
  grid-template-columns: 108px 1fr 56px;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background 0.12s ease;
}
.barchart-row:hover { background: var(--paper-50); }
.barchart-row__label { font-size: 12.5px; font-weight: 600; color: var(--text-600); }
.barchart-row__track { height: 9px; border-radius: 5px; background: var(--steel-100); overflow: hidden; }
.barchart-row__fill { height: 100%; background: linear-gradient(90deg, var(--teal-600), var(--teal-500)); border-radius: 5px; }
.barchart-row__value { font-size: 12px; color: var(--text-900); text-align: right; }

/* ---- Donut chart (Document Status) ---- */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 150px; }
.donut-legend__item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-legend__dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.donut-legend__label { color: var(--text-600); flex: 1; }
.donut-legend__value { color: var(--text-900); font-weight: 600; font-size: 12px; }

/* ---- Timeline (Upcoming Deadlines) ---- */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 13px 6px;
  border-left: 2px solid var(--border);
  margin-left: 5px;
  padding-left: 20px;
  position: relative;
}
.timeline-item:hover { background: var(--paper-50); }
.timeline-item:last-child { border-left-color: transparent; }
.timeline-item__marker {
  position: absolute;
  left: -7px;
  top: 16px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--steel-500);
  border: 2px solid var(--paper-0);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.timeline-item__marker.urgent { background: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.timeline-item__body { flex: 1; min-width: 0; }
.timeline-item__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timeline-item__top b { font-size: 13px; font-weight: 600; color: var(--text-900); }
.timeline-item__meta { font-size: 12px; color: var(--text-400); }

/* ---- Action summary bars ---- */
.action-summary { display: flex; flex-direction: column; gap: 12px; }
.action-summary__row { display: flex; align-items: center; gap: 12px; }
.action-summary__label { width: 92px; font-size: 12.5px; font-weight: 600; color: var(--text-600); flex-shrink: 0; }
.action-summary__track { flex: 1; height: 9px; border-radius: 5px; background: var(--steel-100); overflow: hidden; }
.action-summary__fill { height: 100%; border-radius: 5px; }
.action-summary__count { width: 26px; text-align: right; font-family: var(--font-mono); font-size: 12px; color: var(--text-900); }

/* ---- Widget panel (compliance / recommendations) ---- */
.panel-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-row:last-child { border-bottom: none; }
.panel-row__icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.panel-row__body { flex: 1; min-width: 0; }
.panel-row__body b { font-size: 13px; display: block; margin-bottom: 2px; }
.panel-row__body p { font-size: 12px; color: var(--text-400); line-height: 1.5; }
.panel-row__cta {
  flex-shrink: 0;
  align-self: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--teal-600);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ---- Section anchor offset (so sticky topbar doesn't cover scrolled-to widgets) ---- */
.anchor-target { scroll-margin-top: calc(var(--header-h) + var(--band-h) + 16px); }

@media (max-width: 640px) {
  .barchart-row { grid-template-columns: 84px 1fr 46px; }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
}

/* ==========================================================================
   PHASE 4 — Enterprise DMS Repository
   ========================================================================== */

/* ---- Folder tiles ---- */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.folder-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px;
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  transition: border-color 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
}
.folder-tile:hover { border-color: var(--steel-500); box-shadow: 0 4px 14px rgba(15,27,45,0.06); transform: translateY(-1px); }
.folder-tile__icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--amber-100);
  color: var(--amber-600);
  display: flex; align-items: center; justify-content: center;
}
.folder-tile__name { font-size: 13.5px; font-weight: 600; }
.folder-tile__count { font-size: 11.5px; color: var(--text-400); font-family: var(--font-mono); }

/* ---- Filter bar (repository) ---- */
.repo-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.repo-toolbar select, .repo-toolbar input[type="text"] {
  padding: 8px 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: var(--font-body);
  background: var(--paper-0);
}
.repo-toolbar input[type="text"] { min-width: 190px; flex: 1; }
.repo-toolbar__spacer { flex-basis: 100%; height: 0; }
.view-toggle {
  display: flex;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-toggle button {
  border: none;
  background: var(--paper-0);
  padding: 8px 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-400);
}
.view-toggle button.active { background: var(--ink-900); color: var(--paper-0); }
.view-toggle button:not(:last-child) { border-right: 1px solid var(--border-strong); }

/* ---- Document grid view ---- */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.doc-card {
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.doc-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.doc-card__icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--steel-100);
  color: var(--steel-500);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.doc-card__name { font-size: 13px; font-weight: 600; line-height: 1.35; }
.doc-card__meta { font-size: 11.5px; color: var(--text-400); font-family: var(--font-mono); }
.doc-card__tags { display: flex; flex-wrap: wrap; gap: 5px; }
.doc-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: auto;
}

/* ---- Row / card icon action buttons ---- */
.icon-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--paper-0);
  color: var(--text-600);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.icon-btn:hover { background: var(--paper-50); border-color: var(--steel-500); color: var(--text-900); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn:disabled:hover { background: var(--paper-0); border-color: var(--border-strong); color: var(--text-600); }
.row-actions { display: flex; gap: 5px; flex-wrap: nowrap; }

/* ---- Dropdown menu (More) ---- */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  background: var(--paper-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15,27,45,0.14);
  z-index: 80;
  padding: 6px;
  display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-menu button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: none;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-900);
}
.dropdown-menu button:hover { background: var(--paper-50); }
.dropdown-menu button.danger { color: var(--danger); }
.dropdown-menu button:disabled { opacity: 0.4; cursor: not-allowed; }
.dropdown-menu button:disabled:hover { background: none; }
.dropdown-menu hr { border: none; border-top: 1px solid var(--border); margin: 5px 2px; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,27,45,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-card {
  background: var(--paper-0);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15,27,45,0.3);
}
.modal-card__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-card__head h3 { font-size: 15.5px; }
.modal-card__close {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: none;
  background: var(--paper-50);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-600);
}
.modal-card__close:hover { background: var(--steel-100); }
.modal-card__body { padding: 20px; }
.modal-card__foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

/* ---- Toast ---- */
.toast-wrap {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--ink-900);
  color: var(--paper-0);
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(15,27,45,0.35);
  animation: toast-in 0.18s ease;
}
.toast button {
  background: none; border: none; color: var(--amber-500); font-weight: 700; font-size: 12px;
  font-family: var(--font-mono);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Version history list ---- */
.version-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.version-row:last-child { border-bottom: none; }
.version-row__label { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; color: var(--text-900); }
.version-row__meta { font-size: 11.5px; color: var(--text-400); margin-top: 2px; }

/* ---- Simple form field styling reused inside modals ---- */
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-600); margin-bottom: 5px; }
.modal-field input[type="text"], .modal-field select, .modal-field textarea {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--font-body);
}
.modal-field textarea { resize: vertical; min-height: 60px; }

@media (max-width: 640px) {
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .doc-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   PHASE 5 — Ingestion pipeline (upload / scan / metadata review)
   ========================================================================== */

/* ---- Stage list ---- */
.stage-list { display: flex; flex-direction: column; }
.stage-item { display: flex; gap: 14px; padding: 13px 4px; border-left: 2px solid var(--border); margin-left: 15px; padding-left: 20px; position: relative; }
.stage-item:last-child { border-left-color: transparent; }
.stage-item__dot {
  position: absolute; left: -17px; top: 10px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--paper-0); border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--text-400);
  flex-shrink: 0;
}
.stage-item.active .stage-item__dot { border-color: var(--teal-500); color: var(--teal-600); }
.stage-item.done .stage-item__dot { border-color: var(--success); background: var(--success); color: var(--paper-0); }
.stage-item__body { padding-top: 4px; }
.stage-item__label { font-size: 13.5px; font-weight: 600; color: var(--text-400); }
.stage-item.active .stage-item__label, .stage-item.done .stage-item__label { color: var(--text-900); }
.stage-item__note { font-size: 12px; color: var(--text-400); margin-top: 3px; }
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--teal-100); border-top-color: var(--teal-500);
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Upload progress rows ---- */
.upload-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.upload-row:last-child { border-bottom: none; }
.upload-row__icon { width: 30px; height: 30px; border-radius: 7px; background: var(--steel-100); color: var(--steel-500); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.upload-row__icon.error { background: var(--danger-100); color: var(--danger); }
.upload-row__main { flex: 1; min-width: 0; }
.upload-row__main b { font-size: 13px; display: block; }
.upload-row__main span { font-size: 11.5px; color: var(--text-400); font-family: var(--font-mono); }
.upload-row__error { font-size: 11.5px; color: var(--danger); margin-top: 3px; }
.upload-progress-track { width: 130px; height: 7px; border-radius: 4px; background: var(--steel-100); overflow: hidden; flex-shrink: 0; }
.upload-progress-fill { height: 100%; background: linear-gradient(90deg, var(--teal-600), var(--teal-500)); width: 0%; transition: width 0.2s ease; }
.upload-progress-pct { width: 38px; text-align: right; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-400); flex-shrink: 0; }

/* ---- Confidence-scored field rows ---- */
.conf-field { padding: 13px 0; border-bottom: 1px solid var(--border); }
.conf-field:last-child { border-bottom: none; }
.conf-field__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; gap: 10px; }
.conf-field__label { font-size: 12px; font-weight: 700; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-600); }
.conf-badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 100px; white-space: nowrap; }
.conf-badge.conf-high { background: var(--success-100); color: var(--success); }
.conf-badge.conf-med { background: var(--amber-100); color: var(--amber-600); }
.conf-badge.conf-low { background: var(--danger-100); color: var(--danger); }
.conf-field input, .conf-field select {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: var(--font-body);
}
.conf-field.conf-low-border input { border-color: var(--danger); }

/* ---- Tabs (multi-file metadata review) ---- */
.intake-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.intake-tab {
  padding: 8px 13px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-strong);
  background: var(--paper-0); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px;
}
.intake-tab.active { background: var(--ink-900); color: var(--paper-0); border-color: var(--ink-900); }
.intake-tab.confirmed { border-color: var(--success); color: var(--success); }
.intake-tab .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

@media (max-width: 640px) {
  .upload-row { flex-wrap: wrap; }
  .upload-progress-track { width: 100%; order: 3; }
}

/* ==========================================================================
   PHASE 6 — Document Intelligence page (tabs, comments, sharing, diff)
   ========================================================================== */

/* ---- Tabs ---- */
.doc-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 20px;
}
.doc-tab {
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-400);
  border: none;
  background: none;
  white-space: nowrap;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  flex-shrink: 0;
}
.doc-tab:hover { color: var(--text-900); }
.doc-tab.active { color: var(--ink-900); border-bottom-color: var(--teal-500); }

/* ---- AI Summary ---- */
.summary-block { margin-bottom: 22px; }
.summary-block h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-mono); color: var(--text-400); margin-bottom: 10px; }
.summary-block p { font-size: 14px; line-height: 1.65; }
.summary-list { display: flex; flex-direction: column; gap: 8px; }
.summary-list li { font-size: 13.5px; line-height: 1.55; display: flex; gap: 8px; }
.summary-list li::before { content: '—'; color: var(--text-400); flex-shrink: 0; }
.risk-list li::before { content: '⚠'; color: var(--amber-600); }
.date-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.date-chip { background: var(--teal-100); color: var(--teal-700, var(--teal-600)); padding: 7px 12px; border-radius: 8px; font-size: 12.5px; }
.date-chip b { display: block; font-size: 10px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }
.party-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.party-chip { background: var(--steel-100); color: var(--steel-500); padding: 7px 12px; border-radius: 100px; font-size: 12.5px; font-weight: 600; }

/* ---- Metadata table (AI vs confirmed) ---- */
table.meta-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.meta-table th { text-align: left; font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-400); padding: 10px 14px; border-bottom: 1.5px solid var(--border); }
.meta-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.meta-table tr:last-child td { border-bottom: none; }
.meta-table input { width: 100%; padding: 7px 9px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 12.5px; }

/* ---- Comments ---- */
.comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment__avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink-900); color: var(--paper-0); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 12px; font-weight: 700; flex-shrink: 0; }
.comment__body { flex: 1; min-width: 0; }
.comment__head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.comment__head b { font-size: 13px; }
.comment__head span { font-size: 11px; color: var(--text-400); font-family: var(--font-mono); }
.comment__text { font-size: 13.5px; line-height: 1.5; margin-bottom: 6px; }
.comment__reply-btn { background: none; border: none; font-size: 11.5px; font-weight: 700; color: var(--teal-600); font-family: var(--font-mono); padding: 0; }
.comment__replies { margin-top: 10px; padding-left: 16px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.comment-input-row { display: flex; gap: 10px; margin-top: 6px; }
.comment-input-row textarea { flex: 1; padding: 10px 12px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font-body); min-height: 44px; resize: vertical; }

/* ---- Sharing list ---- */
.share-entry { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.share-entry:last-child { border-bottom: none; }
.share-entry__icon { width: 30px; height: 30px; border-radius: 7px; background: var(--steel-100); color: var(--steel-500); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.share-entry__main { flex: 1; min-width: 0; }
.share-entry__main b { font-size: 13px; display: block; }
.share-entry__main span { font-size: 11.5px; color: var(--text-400); font-family: var(--font-mono); }
.mode-toggle { display: flex; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 14px; width: fit-content; }
.mode-toggle button { border: none; background: var(--paper-0); padding: 8px 14px; font-size: 12.5px; font-weight: 600; color: var(--text-400); }
.mode-toggle button.active { background: var(--ink-900); color: var(--paper-0); }

/* ---- Permissions table ---- */
table.perm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-table th { text-align: left; font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-400); padding: 10px 14px; border-bottom: 1.5px solid var(--border); }
.perm-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: center; }
.perm-table td:first-child { text-align: left; font-weight: 600; }
.perm-table tr.current-role { background: var(--teal-100); }
.perm-table tr:last-child td { border-bottom: none; }
.perm-yes { color: var(--success); }
.perm-no { color: var(--text-400); }
.perm-own { color: var(--amber-600); font-size: 11px; font-family: var(--font-mono); }

/* ---- Check-out banner ---- */
.checkout-banner {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: var(--radius);
  background: var(--amber-100); color: #7A5A0E; font-size: 13px; margin-bottom: 16px; border: 1px solid #EAD09A;
}

/* ---- Diff / compare view ---- */
.diff-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.diff-section:last-child { border-bottom: none; }
.diff-section h4 { font-size: 13.5px; margin-bottom: 8px; }
.diff-line { font-size: 13.5px; line-height: 1.6; padding: 8px 12px; border-radius: 6px; }
.diff-line.unchanged { color: var(--text-600); }
.diff-line.removed { background: var(--danger-100); color: #7A241A; text-decoration: line-through; margin-bottom: 4px; }
.diff-line.added { background: var(--success-100); color: #14532d; }
.diff-badge { display: inline-block; font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; margin-bottom: 6px; }
.diff-badge.changed { background: var(--amber-100); color: var(--amber-600); }
.diff-badge.same { background: var(--steel-100); color: var(--steel-500); }
.diff-badge.new { background: var(--success-100); color: var(--success); }
.version-picker-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.version-picker-row select { padding: 9px 12px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13px; }

/* ==========================================================================
   PHASE 7 — Search (Advanced Search + AI Knowledge Search)
   ========================================================================== */

/* ---- Advanced search layout ---- */
.search-shell { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
@media (max-width: 900px) { .search-shell { grid-template-columns: 1fr; } }
.facet-card { margin-bottom: 14px; }
.facet-card h4 { font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-400); margin-bottom: 9px; }
.facet-card select, .facet-card input[type="text"] { width: 100%; padding: 9px 11px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 8px; }
.chip-toggle-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle { padding: 5px 11px; border-radius: 100px; border: 1.5px solid var(--border-strong); background: var(--paper-0); font-size: 11.5px; font-weight: 600; color: var(--text-600); }
.chip-toggle.active { background: var(--ink-900); color: var(--paper-0); border-color: var(--ink-900); }
.search-input-lg { width: 100%; padding: 13px 16px; border: 1.5px solid var(--border-strong); border-radius: var(--radius); font-size: 14.5px; margin-bottom: 8px; }
.search-input-lg:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-100); }
.boolean-hint { font-size: 11.5px; color: var(--text-400); font-family: var(--font-mono); margin-bottom: 18px; }
.boolean-hint b { color: var(--text-600); }

.result-card { background: var(--paper-0); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; text-decoration: none; color: inherit; display: block; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.result-card:hover { border-color: var(--steel-500); box-shadow: 0 4px 14px rgba(15,27,45,0.06); }
.result-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.result-card__title { font-size: 14.5px; font-weight: 700; color: var(--text-900); }
.result-card__meta { font-size: 11.5px; color: var(--text-400); font-family: var(--font-mono); margin-top: 3px; }
.result-card__score { flex-shrink: 0; text-align: right; }
.result-card__score b { font-family: var(--font-display); font-size: 17px; color: var(--teal-600); }
.result-card__score span { display: block; font-size: 9.5px; font-family: var(--font-mono); color: var(--text-400); text-transform: uppercase; }
.result-card__snippet { font-size: 12.5px; color: var(--text-600); line-height: 1.55; margin: 10px 0; background: var(--paper-50); padding: 9px 12px; border-radius: 6px; }
.result-card__snippet mark { background: var(--amber-100); color: var(--amber-600); padding: 0 2px; border-radius: 2px; font-weight: 700; }
.result-card__tags { display: flex; flex-wrap: wrap; gap: 5px; }

.saved-search-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.saved-search-row:last-child { border-bottom: none; }
.saved-search-row__name { flex: 1; font-size: 12.5px; font-weight: 600; }
.saved-search-row__meta { font-size: 10.5px; color: var(--text-400); font-family: var(--font-mono); }

/* ---- AI Knowledge Search ---- */
.ai-search-shell { display: grid; grid-template-columns: 220px 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .ai-search-shell { grid-template-columns: 1fr; } }
.conv-list { display: flex; flex-direction: column; gap: 4px; }
.conv-item { padding: 9px 11px; border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text-600); display: block; text-align: left; border: none; background: none; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item:hover { background: var(--paper-50); }
.conv-item.active { background: var(--ink-900); color: var(--paper-0); }

.ai-chat-window { background: var(--paper-0); border: 1px solid var(--border); border-radius: var(--radius); min-height: 480px; display: flex; flex-direction: column; overflow: hidden; }
.ai-chat-log {
  flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto; overflow-x: hidden;
  max-height: min(620px, calc(100vh - 300px));
  scrollbar-width: thin; scrollbar-color: var(--steel-300) var(--paper-50);
}
.ai-chat-log::-webkit-scrollbar { width: 9px; }
.ai-chat-log::-webkit-scrollbar-track { background: var(--paper-50); border-radius: 100px; }
.ai-chat-log::-webkit-scrollbar-thumb { background: var(--steel-300); border-radius: 100px; border: 2px solid var(--paper-50); }
.ai-chat-log::-webkit-scrollbar-thumb:hover { background: var(--steel-500); }
.ai-msg-user { align-self: flex-end; max-width: 78%; background: var(--ink-900); color: var(--paper-0); padding: 11px 15px; border-radius: 12px; border-bottom-right-radius: 3px; font-size: 13.5px; }
.ai-answer-card { border: 1px solid var(--border); border-left: 2.5px solid var(--ai-accent, #6B5FD6); border-radius: 12px; overflow: hidden; }
.ai-answer-card__head { display: flex; align-items: center; gap: 8px; padding: 10px 15px; background: var(--ai-accent-100, #ECEAFA); color: var(--ai-accent-600, #5347B8); font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.ai-answer-card__body { padding: 15px; }
.ai-answer-section { margin-bottom: 14px; }
.ai-answer-section:last-child { margin-bottom: 0; }
.ai-answer-section h5 { font-size: 10.5px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-400); margin-bottom: 6px; }
.ai-answer-section p { font-size: 13.5px; line-height: 1.6; }
.ai-answer-section ul { display: flex; flex-direction: column; gap: 6px; }
.ai-answer-section li { font-size: 13px; line-height: 1.5; display: flex; gap: 7px; }
.ai-answer-section li::before { content: '—'; color: var(--text-400); flex-shrink: 0; }
.ai-source-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-source-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 100px; background: var(--steel-100); color: var(--steel-500); font-size: 11px; font-weight: 600; text-decoration: none; transition: background-color 0.12s ease, color 0.12s ease; }
.ai-source-chip:hover { background: var(--ai-accent-600, var(--ink-900)); color: var(--paper-0); }
.ai-no-answer { color: var(--text-400); font-size: 13px; }

.sources-panel { position: sticky; top: calc(var(--header-h) + 16px); }
.source-doc-card { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; text-decoration: none; color: inherit; }
.source-doc-card:hover { border-color: var(--teal-500); background: var(--paper-50); }
.source-doc-card b { font-size: 12.5px; display: block; margin-bottom: 3px; }
.source-doc-card span { font-size: 11px; color: var(--text-400); font-family: var(--font-mono); }

@media (max-width: 640px) {
  .search-shell, .ai-search-shell { grid-template-columns: 1fr; }
}

/* ==========================================================================
   PHASE 8 — Tasks, Alerts & Workflow
   ========================================================================== */

.ai-gen-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 100px; background: var(--teal-100); color: var(--teal-700, var(--teal-600));
  white-space: nowrap;
}
.manual-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 100px; background: var(--steel-100); color: var(--steel-500);
  white-space: nowrap;
}

/* ---- Alert cards ---- */
.alert-type-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.alert-card { display: flex; gap: 14px; padding: 15px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper-0); margin-bottom: 12px; align-items: flex-start; }
.alert-card__icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.alert-card__body { flex: 1; min-width: 0; }
.alert-card__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.alert-card__title { font-size: 13.5px; font-weight: 700; }
.alert-card__detail { font-size: 12.5px; color: var(--text-600); margin-top: 4px; line-height: 1.5; }
.alert-card__meta { font-size: 11px; color: var(--text-400); font-family: var(--font-mono); margin-top: 6px; }
.alert-card__actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---- Task detail layout ---- */
.task-detail-shell { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
@media (max-width: 900px) { .task-detail-shell { grid-template-columns: 1fr; } }
.task-side-card { margin-bottom: 14px; }
.task-side-card h4 { font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-400); margin-bottom: 8px; }

/* ---- Workflow diagram ---- */
.workflow-track { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 10px 0 20px; }
.workflow-node { display: flex; flex-direction: column; min-width: 168px; }
.workflow-node__card { background: var(--paper-0); border: 1.5px solid var(--border-strong); border-radius: var(--radius); padding: 16px 14px; text-align: center; flex: 1; }
.workflow-node__icon { width: 40px; height: 40px; border-radius: 10px; background: var(--steel-100); color: var(--steel-500); display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.workflow-node__icon.human { background: var(--amber-100); color: var(--amber-600); }
.workflow-node__icon.ai { background: var(--teal-100); color: var(--teal-700, var(--teal-600)); }
.workflow-node__icon.done { background: var(--success-100); color: var(--success); }
.workflow-node__title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.workflow-node__who { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-400); margin-bottom: 6px; }
.workflow-node__desc { font-size: 11.5px; color: var(--text-600); line-height: 1.4; }
.workflow-node__count { margin-top: 8px; font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--teal-600); }
.workflow-arrow { display: flex; align-items: center; justify-content: center; width: 34px; flex-shrink: 0; color: var(--border-strong); }

/* ---- Rules ---- */
.rule-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; background: var(--paper-0); }
.rule-card__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rule-card__flow { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 10px 0; flex-wrap: wrap; }
.rule-card__flow .step { background: var(--paper-50); border: 1px solid var(--border); padding: 6px 11px; border-radius: 6px; font-size: 12.5px; }
.rule-toggle { position: relative; width: 38px; height: 21px; border-radius: 100px; background: var(--border-strong); border: none; flex-shrink: 0; cursor: pointer; }
.rule-toggle.on { background: var(--teal-500); }
.rule-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: left 0.15s ease; }
.rule-toggle.on::after { left: 19px; }
.rule-card__meta-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-400); font-family: var(--font-mono); }

.hitl-banner {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--amber-100); border: 1px solid #EAD09A; color: #7A5A0E; margin-bottom: 18px; font-size: 13px; line-height: 1.5;
}

@media (max-width: 640px) {
  .task-detail-shell { grid-template-columns: 1fr; }
}

/* ==========================================================================
   PHASE 9 — Legal Intelligence module
   ========================================================================== */

/* ---- Journey tracker (court notice lifecycle) ---- */
.journey-item { display: flex; gap: 14px; padding: 13px 0; border-left: 2px solid var(--border); margin-left: 13px; padding-left: 20px; position: relative; }
.journey-item:last-child { border-left-color: transparent; }
.journey-item__dot {
  position: absolute; left: -13px; top: 14px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--paper-0); border: 2px solid var(--border-strong); display: flex; align-items: center; justify-content: center;
  color: var(--text-400); flex-shrink: 0;
}
.journey-item.done .journey-item__dot { border-color: var(--success); background: var(--success); color: var(--paper-0); }
.journey-item__body { flex: 1; padding-top: 2px; }
.journey-item__title { font-size: 13.5px; font-weight: 700; }
.journey-item.done .journey-item__title { color: var(--text-900); }
.journey-item:not(.done) .journey-item__title { color: var(--text-400); }
.journey-item__detail { font-size: 12.5px; color: var(--text-600); margin-top: 3px; line-height: 1.5; }
.journey-item__link { font-size: 11.5px; font-weight: 700; color: var(--teal-600); font-family: var(--font-mono); margin-top: 4px; display: inline-block; }

/* ---- Case cards ---- */
.case-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper-0); margin-bottom: 10px; text-decoration: none; color: inherit; }
.case-card:hover { border-color: var(--steel-500); box-shadow: 0 4px 14px rgba(15,27,45,0.06); }
.case-card__num { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--ink-900); background: var(--steel-100); padding: 6px 10px; border-radius: 6px; flex-shrink: 0; }
.case-card__main { flex: 1; min-width: 0; }
.case-card__main b { font-size: 13.5px; display: block; }
.case-card__main span { font-size: 11.5px; color: var(--text-400); font-family: var(--font-mono); }

/* ---- Hearing calendar (month grid) ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; color: var(--text-400); text-align: center; padding: 6px 0; }
.cal-cell { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 6px; padding: 5px; font-size: 11px; color: var(--text-400); position: relative; background: var(--paper-0); }
.cal-cell.empty { border: none; background: none; }
.cal-cell.has-hearing { background: var(--danger-100); border-color: #EDBAAF; color: var(--danger); font-weight: 700; }
.cal-cell .day-num { font-family: var(--font-mono); }
.cal-cell .dot { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--danger); }

/* ---- Contract risk row accent ---- */
.risk-High td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.risk-Medium td:first-child { box-shadow: inset 3px 0 0 var(--amber-500); }
.risk-Low td:first-child { box-shadow: inset 3px 0 0 var(--success); }

/* ==========================================================================
   PHASE 10 — Finance Intelligence module
   ========================================================================== */

.journey-item.highlight .journey-item__dot { border-color: var(--amber-500); }
.journey-item.highlight.done .journey-item__dot { border-color: var(--success); background: var(--success); }
.journey-item.highlight:not(.done) { background: var(--amber-100); border-radius: 8px; margin-left: 13px; padding-left: 20px; }
.journey-item.highlight:not(.done) .journey-item__title { color: #7A5A0E; }

.invoice-preview-mock {
  width: 100%; max-width: 260px; background: var(--paper-0); border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 18px; box-shadow: 0 8px 24px rgba(15,27,45,0.08); font-size: 10px;
}
.invoice-preview-mock .ipm-head { display: flex; justify-content: space-between; margin-bottom: 14px; }
.invoice-preview-mock .ipm-head b { font-size: 12px; }
.invoice-preview-mock .ipm-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); color: var(--text-600); }
.invoice-preview-mock .ipm-total { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 2px solid var(--ink-900); font-weight: 700; font-size: 12px; }

.approval-banner {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--teal-100); border: 1px solid #B7DFDA; color: var(--teal-700, var(--teal-600)); margin-bottom: 18px; font-size: 13px; line-height: 1.5;
}

/* ==========================================================================
   PHASE 12 — Administration: users, categories, permissions, retention, audit
   ========================================================================== */

/* ---- Admin sub-nav ---- */
.admin-subnav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1.5px solid var(--border); padding-bottom: 0; }
.admin-subnav a {
  padding: 9px 13px; font-size: 12.5px; font-weight: 600; color: var(--text-400);
  border-bottom: 2.5px solid transparent; margin-bottom: -1.5px;
}
.admin-subnav a:hover { color: var(--text-900); }
.admin-subnav a.active { color: var(--ink-900); border-bottom-color: var(--teal-500); }

/* ---- Status dot ---- */
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.status-dot.active { background: var(--success); }
.status-dot.invited { background: var(--amber-500); }
.status-dot.suspended { background: var(--danger); }

/* ---- Toggle switch (reuses rule-toggle look) ---- */
.admin-toggle { position: relative; width: 38px; height: 21px; border-radius: 100px; background: var(--border-strong); border: none; flex-shrink: 0; cursor: pointer; }
.admin-toggle.on { background: var(--teal-500); }
.admin-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: left 0.15s ease; }
.admin-toggle.on::after { left: 19px; }

/* ---- Category cards ---- */
.category-card { background: var(--paper-0); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.category-card__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.category-card__count { font-family: var(--font-mono); font-size: 11px; color: var(--text-400); }

/* ---- Metadata field rows ---- */
.field-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: none; }
.field-row__label { flex: 1; font-size: 13px; font-weight: 600; }
.field-row input[type="text"] { flex: 1; padding: 7px 10px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 12.5px; }

/* ---- Audit table ---- */
table.audit-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.audit-table th { text-align: left; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-400); padding: 10px 12px; border-bottom: 1.5px solid var(--border); white-space: nowrap; }
.audit-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.audit-table tr:hover td { background: var(--paper-50); }
.audit-hash { font-family: var(--font-mono); font-size: 10px; color: var(--steel-500); background: var(--steel-100); padding: 2px 6px; border-radius: 3px; letter-spacing: 0.02em; }
.audit-result-success { color: var(--success); font-weight: 700; }
.audit-result-blocked { color: var(--danger); font-weight: 700; }
.audit-ip { font-family: var(--font-mono); font-size: 11px; color: var(--text-400); }
.audit-chain-note {
  display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--text-400);
  padding: 10px 14px; background: var(--paper-50); border-top: 1px solid var(--border);
}

/* ---- Permission matrix ---- */
table.perm-matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.perm-matrix th { text-align: center; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; color: var(--text-400); padding: 10px; border-bottom: 1.5px solid var(--border); }
.perm-matrix th:first-child { text-align: left; }
.perm-matrix td { text-align: center; padding: 10px; border-bottom: 1px solid var(--border); }
.perm-matrix td:first-child { text-align: left; font-weight: 600; }

@media (max-width: 640px) {
  .admin-subnav { overflow-x: auto; flex-wrap: nowrap; }
}

/* ==========================================================================
   PHASE 13 — Reports & MIS
   ========================================================================== */

.report-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1.5px solid var(--border); }
.report-nav a { padding: 9px 13px; font-size: 12.5px; font-weight: 600; color: var(--text-400); border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; }
.report-nav a:hover { color: var(--text-900); }
.report-nav a.active { color: var(--ink-900); border-bottom-color: var(--teal-500); }

.report-card {
  background: var(--paper-0); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  text-decoration: none; color: inherit; display: block; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.report-card:hover { border-color: var(--steel-500); box-shadow: 0 4px 14px rgba(15,27,45,0.06); }
.report-card__label { font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-400); }
.report-card__value { font-family: var(--font-display); font-size: 25px; margin: 7px 0 3px; }
.report-card__meta { font-size: 11.5px; color: var(--text-600); }

.compliance-status-toggle { padding: 5px 11px; border-radius: 100px; border: 1.5px solid var(--border-strong); background: var(--paper-0); font-size: 11px; font-weight: 700; cursor: pointer; }
.compliance-status-toggle.open { color: var(--danger); border-color: #EDBAAF; background: var(--danger-100); }
.compliance-status-toggle.resolved { color: var(--success); border-color: #B7E4C7; background: var(--success-100); }

/* ---- Print styles: used by Export PDF (window.print → Save as PDF) and Print ---- */
@media print {
  .no-print, .sidebar, .topbar, .proto-band, .corner-stamp, .doc-tabs, .toolbar, .repo-toolbar, .filter-bar, .breadcrumb { display: none !important; }
  .app-shell { display: block !important; }
  .main, .content { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
  body { background: #fff !important; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; }
  a { text-decoration: none !important; color: inherit !important; }
}

/* ==========================================================================
   PHASE 14 — QA polish: mobile navigation
   The sidebar is hidden below 900px (app-shell collapses to a single
   column); this restores access to it via a topbar hamburger button that
   slides the sidebar in as an overlay, with a tap-to-close scrim.
   ========================================================================== */
.mobile-menu-btn {
  display: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  background: var(--paper-0);
  color: var(--text-600);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--paper-50); }

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 27, 45, 0.45);
  z-index: 90;
}
.sidebar-scrim.show { display: block; }

@media (max-width: 900px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    display: flex !important;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    max-width: 82vw;
    z-index: 100;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.3);
  }
  .sidebar.mobile-open { transform: translateX(0); }
}

/* ---- Activity timeline item ("audit-item") — used by document-details.html,
   task-details.html, finance/invoice-details.html and
   procurement/procurement-details.html for their Activity sections.
   Modelled on the existing .stage-item pipeline pattern for visual
   consistency. Centralised here since it's a shared component. ---- */
.audit-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.audit-item:last-child { border-bottom: none; }
.audit-item__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--steel-400); flex-shrink: 0; margin-top: 6px; }
.audit-item__body { flex: 1; min-width: 0; }
.audit-item__body b { display: block; font-size: 13px; font-weight: 600; line-height: 1.45; }
.audit-item__body span { display: block; font-size: 11.5px; color: var(--text-400); margin-top: 2px; font-family: var(--font-mono); }

/* ---- Metadata grid ("meta-grid"/"meta-item") — used by document-details.html,
   legal/legal-document.html and procurement/procurement-details.html for
   key/value fact panels. Centralised here (previously only defined locally
   on document-details.html) so every page using it renders consistently. ---- */
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 24px; }
@media (max-width: 760px) { .meta-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .meta-grid { grid-template-columns: 1fr; } }
.meta-item b { display: block; font-size: 10.5px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-400); margin-bottom: 4px; }
.meta-item span { font-size: 13.5px; font-weight: 600; }

/* ---- Step progress indicator ("stepper") — used by documents/upload.html
   and documents/scan.html for their pipeline step trackers. Centralised
   here (previously only defined locally on upload.html, so scan.html's
   stepper rendered unstyled) so both pages get it consistently. ---- */
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.stepper__step { display: flex; align-items: center; gap: 8px; font-size: 12px; font-family: var(--font-mono); color: var(--text-400); }
.stepper__dot { width: 22px; height: 22px; border-radius: 50%; background: var(--steel-100); color: var(--text-400); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; flex-shrink: 0; }
.stepper__step.active .stepper__dot { background: var(--ink-900); color: var(--paper-0); }
.stepper__step.done .stepper__dot { background: var(--success); color: var(--paper-0); }
.stepper__step.active span.lbl { color: var(--text-900); font-weight: 700; }
.stepper__line { width: 24px; height: 1.5px; background: var(--border-strong); }

/* ==========================================================================
   PHASE 15 — Enterprise visual design pass
   Design-token refinement, AI/Human distinction system, tooltips, refined
   states (empty/loading/processing/success/warning/error), and consistency
   polish across cards, tables and timelines. Purely additive — no existing
   class is renamed or removed, so every prior page keeps working unchanged.
   ========================================================================== */

/* ---- Extended tokens ---- */
:root {
  --ai-accent: #6B5FD6;       /* distinct, restrained "intelligence" hue — used ONLY for AI-origin labels, never for actions */
  --ai-accent-100: #ECEAFA;
  --ai-accent-600: #5347B8;
  --human-accent: #166B67;    /* reuses teal — human/verified actions stay in the product's primary action colour */
  --human-accent-100: #DDF0EE;
  --ease-standard: cubic-bezier(0.2, 0.7, 0.3, 1);
  --shadow-sm: 0 1px 2px rgba(15,27,45,0.05), 0 1px 1px rgba(15,27,45,0.04);
  --shadow-md: 0 4px 14px rgba(15,27,45,0.07);
  --shadow-lg: 0 20px 60px rgba(15,27,45,0.28);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---- Notice: error/danger variant (Warning/Error states) ---- */
.notice-danger { background: var(--danger-100); border-color: #EDBAAF; color: #8A2E20; }
.notice-success { background: var(--success-100); border-color: #B7E4C7; color: #1E6B41; }

/* ---- Refined empty state (bigger icon container, calmer weight) ---- */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
}
.empty-state__icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--paper-50); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--steel-500); margin-bottom: 14px;
}

/* ---- Skeleton / loading state ---- */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--paper-50);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
  transform: translateX(-100%);
  animation: skeleton-sweep 1.3s var(--ease-standard) infinite;
}
@keyframes skeleton-sweep { to { transform: translateX(100%); } }
.skeleton-line { height: 11px; margin-bottom: 8px; }
.skeleton-line:last-child { margin-bottom: 0; width: 65%; }

/* ---- Slim top loading bar (page-transition micro-interaction) ---- */
#wesmanTopLoader {
  position: fixed; top: 0; left: 0; height: 2.5px; width: 0%;
  background: linear-gradient(90deg, var(--teal-500), var(--amber-500));
  z-index: 400; border-radius: 0 2px 2px 0;
  transition: width 0.28s var(--ease-standard), opacity 0.25s ease 0.15s;
}
#wesmanTopLoader.done { width: 100%; opacity: 0; }

/* ---- Tooltip (pure CSS, no JS wiring needed — add data-tip="..." to any element) ---- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%) translateY(2px);
  background: var(--ink-900); color: var(--paper-0);
  font-size: 11px; font-weight: 500; line-height: 1.4; font-family: var(--font-body);
  padding: 6px 10px; border-radius: 6px; white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity 0.14s ease, transform 0.14s ease;
}
[data-tip]::before {
  content: ''; position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--ink-900);
  opacity: 0; pointer-events: none; transition: opacity 0.14s ease; z-index: 60;
}
[data-tip]:hover::after, [data-tip]:hover::before,
[data-tip]:focus-visible::after, [data-tip]:focus-visible::before { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tip-wide]::after { white-space: normal; width: 220px; }

/* ---- AI / Human distinction chips ----
   A dedicated visual language that is deliberately NOT chatbot-styled:
   no gradients-on-bubbles, no purple glow. Just a small violet accent dot
   for machine-origin content and the product's own teal for human action —
   consistent with the existing ledger-and-stamp aesthetic. */
.ai-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px 3px 6px; border-radius: 100px;
  white-space: nowrap; line-height: 1.5;
}
.ai-chip__dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.ai-chip--suggested { background: var(--ai-accent-100); color: var(--ai-accent-600); }
.ai-chip--suggested .ai-chip__dot { background: var(--ai-accent); }
.ai-chip--extracted { background: var(--ai-accent-100); color: var(--ai-accent-600); }
.ai-chip--extracted .ai-chip__dot { background: var(--ai-accent); animation: ai-pulse 2s ease-in-out infinite; }
.ai-chip--confidence { background: var(--paper-0); color: var(--text-600); border: 1px solid var(--border-strong); }
.ai-chip--confidence .ai-chip__dot { background: var(--steel-500); }
.ai-chip--verified { background: var(--human-accent-100); color: var(--human-accent); }
.ai-chip--verified .ai-chip__dot { background: var(--human-accent); }
.ai-chip--confirmed { background: var(--success-100); color: var(--success); }
.ai-chip--confirmed .ai-chip__dot { background: var(--success); }
@keyframes ai-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(107,95,214,0.35); } 50% { opacity: 0.75; box-shadow: 0 0 0 3px rgba(107,95,214,0); } }

/* ---- AI panel framing — wraps AI-generated content blocks (summaries,
   extraction results, chat answers) with a subtle left rail instead of a
   chat-bubble, keeping the "ledger" document feel rather than a messaging UI. */
.ai-panel {
  position: relative;
  border-left: 2.5px solid var(--ai-accent);
  padding-left: 14px;
  background: linear-gradient(90deg, var(--ai-accent-100) 0%, transparent 130px);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding-top: 2px; padding-bottom: 2px;
}
.ai-panel__label {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ai-accent-600); margin-bottom: 6px;
}

/* ---- Human-in-the-loop banner refinement (used by approval-banner already;
   this adds a matching "human required" variant for un-actioned states) ---- */
.human-required-banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--paper-50); border: 1px dashed var(--border-strong);
  font-size: 12.5px; color: var(--text-600); line-height: 1.55;
}
.human-required-banner svg { color: var(--steel-500); flex-shrink: 0; margin-top: 1px; }

/* ---- Card & KPI micro-interaction refinement ---- */
.card { transition: box-shadow 0.15s var(--ease-standard); }
.report-card, a.card, .list-row, .panel-row { transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.08s ease; }

/* ---- Data table refinement: clearer header, subtle zebra option ---- */
.data-table th { background: var(--paper-50); }
.data-table.zebra tbody tr:nth-child(even) td { background: rgba(228,235,242,0.28); }
.data-table tr { transition: background-color 0.1s ease; }

/* ---- Timeline dot unification (stage-item / journey-item / audit-item all
   share the same resting/active/done colour language without renaming) ---- */
.stage-item__dot, .journey-item__dot, .audit-item__dot { transition: background-color 0.15s ease, border-color 0.15s ease; }

/* ---- Modal polish: slightly stronger entrance + consistent max-width tiers ---- */
.modal-card { animation: modal-in 0.16s var(--ease-standard); }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-card.modal-wide { max-width: 640px; }

/* ---- Breadcrumb refinement ---- */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-400); margin-bottom: 14px; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-600); font-weight: 600; }
.breadcrumb a:hover { color: var(--teal-600); text-decoration: underline; }

/* ---- Accessibility: visible focus for interactive custom controls ---- */
.role-opt:focus-visible, .kpi-card:focus-visible, .list-row:focus-visible, .report-card:focus-visible,
.compliance-status-toggle:focus-visible, .admin-toggle:focus-visible {
  outline: 2px solid var(--teal-500); outline-offset: 2px;
}
.tag, .ai-chip { outline-offset: 1px; }

@media (max-width: 640px) {
  .ai-panel { background: var(--ai-accent-100); padding: 10px 12px; border-radius: var(--radius-sm); }
}
