/*
 * Design system for the authenticated "app shell" (sidebar + topbar) pages,
 * translated from reference/homepage.html (the BuildX AI UI specification).
 *
 * Only the pieces the Dashboard page actually uses are implemented here —
 * see AGENTS.md Section 9 ("no unverified scaffolding"). Later phase
 * activities (New RFP, Bid Workspace, Bid Repository, Language Library,
 * Equipment, Intelligence, Rate Cards, Win/Loss, Settings) should extend
 * this file with their own components as those pages are actually built,
 * rather than pre-building unused CSS now.
 */

:root {
  --kb-navy: #0d2d5e;
  --kb-navy-mid: #163970;
  --kb-navy-light: #1e4a8a;
  --kb-blue: #2b7de9;
  --kb-blue-mid: #5b9cef;
  --kb-blue-light: #e8f1fd;
  --kb-blue-xlight: #f4f8fe;
  --white: #ffffff;
  --gray-50: #f8f9fb;
  --gray-100: #f0f2f6;
  --gray-200: #e2e6ed;
  --gray-300: #c8d0dc;
  --gray-400: #9aa5b4;
  --gray-500: #6b7785;
  --gray-600: #4a5568;
  --gray-700: #2d3748;
  --gray-900: #1a202c;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --amber: #e65100;
  --amber-light: #fff3e0;
  --red: #c62828;
  --red-light: #ffebee;
  --font: "DM Sans", sans-serif;
  --mono: "DM Mono", monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 220px;
  --topbar-h: 60px;
  --shadow: 0 1px 3px rgba(13, 45, 94, 0.08), 0 1px 2px rgba(13, 45, 94, 0.04);
  --shadow-md: 0 4px 12px rgba(13, 45, 94, 0.1), 0 2px 4px rgba(13, 45, 94, 0.06);
}

.app * {
  box-sizing: border-box;
}

body.app-shell {
  margin: 0;
  font-family: var(--font);
  background: #e8edf5;
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── LAYOUT ── */
.app {
  display: flex;
  min-height: 100vh;
  padding: 12px;
  gap: 12px;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--kb-navy);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
}
.logo-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--kb-blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.logo-name {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.logo-name.dark {
  color: var(--gray-900);
}
.logo-product {
  color: rgba(255, 255, 255, 0.35);
  font-size: 11px;
  margin-top: 2px;
  padding-left: 42px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}
.nav-section-label {
  padding: 14px 18px 4px;
  color: rgba(255, 255, 255, 0.22);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  user-select: none;
}
a.nav-item:hover {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.05);
}
.nav-item.active {
  color: #fff;
  background: rgba(43, 125, 233, 0.2);
  border-left: 2px solid var(--kb-blue);
  font-weight: 500;
}
.nav-item.disabled {
  cursor: default;
  color: rgba(255, 255, 255, 0.3);
}
.nav-item i {
  font-size: 16px;
  flex-shrink: 0;
}
.nav-soon {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 1px 7px;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 0.5px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--kb-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.user-name {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}
.user-role {
  color: rgba(255, 255, 255, 0.3);
  font-size: 11px;
}
.sidebar-footer .logout-form {
  margin-left: auto;
}
.sidebar-footer .link-button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 15px;
  padding: 4px;
}
.sidebar-footer .link-button:hover {
  color: #fff;
}

/* ── MAIN AREA ── */
.main {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  min-height: var(--topbar-h);
  padding: 12px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--white);
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-left {
  display: flex;
  flex-direction: column;
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
}
.topbar-sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 1px;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-700);
  font-family: var(--font);
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}
.btn-primary {
  background: var(--kb-blue);
  color: #fff;
  border-color: var(--kb-blue);
}
.btn-primary:hover {
  background: var(--kb-navy-light);
  border-color: var(--kb-navy-light);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn[disabled],
.btn.btn-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.btn[disabled]:hover,
.btn.btn-disabled:hover {
  background: var(--white);
  border-color: var(--gray-200);
}
.btn i {
  font-size: 15px;
}
.btn-block {
  width: 100%;
  justify-content: center;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-neutral,
.badge-draft {
  background: var(--gray-100);
  color: var(--gray-500);
}
.badge-pending-review {
  background: var(--kb-blue-light);
  color: var(--kb-navy);
}
.badge-approved {
  background: var(--green-light);
  color: var(--green);
}
.badge-submitted {
  background: #e8f5e9;
  color: #1b5e20;
}
.badge-won {
  background: #e0f7fa;
  color: #006064;
}
.badge-lost {
  background: var(--red-light);
  color: var(--red);
}

/* ── TAGS / FILTER CHIPS ── (Phase 3: Language Library, Win/Loss — ported
   from reference/homepage.html's approved UI spec, #page-language /
   #page-winloss) */
.tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-500);
}
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--gray-200);
  cursor: pointer;
  color: var(--gray-500);
  background: var(--white);
  text-decoration: none;
  transition: all 0.15s;
}
.chip:hover {
  border-color: var(--kb-blue);
  color: var(--kb-blue);
}
.chip.active {
  background: var(--kb-blue);
  color: #fff;
  border-color: var(--kb-blue);
}

/* ── WIN/LOSS SUMMARY CARDS ── */
.wl-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.wl-card {
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: center;
}
.wl-card.won {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
}
.wl-card.lost {
  background: var(--red-light);
  border: 1px solid #ffcdd2;
}
.wl-card.pending {
  background: var(--kb-blue-light);
  border: 1px solid rgba(43, 125, 233, 0.2);
}
.wl-num {
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 4px;
}
.wl-card.won .wl-num {
  color: var(--green);
}
.wl-card.lost .wl-num {
  color: var(--red);
}
.wl-card.pending .wl-num {
  color: var(--kb-navy);
}
.wl-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
}

/* ── CARDS ── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

/* ── STAT CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--kb-blue-xlight);
  border: 1px solid rgba(43, 125, 233, 0.12);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label {
  font-size: 11px;
  color: var(--kb-navy-light);
  font-weight: 500;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-val {
  font-size: 26px;
  font-weight: 600;
  color: var(--kb-navy);
  line-height: 1;
}
.stat-change {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 6px;
}
.stat-meta {
  font-size: 12px;
  color: var(--gray-400);
  margin: 0 0 24px;
}

/* ── SECTION HEADERS ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 32px 20px;
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
}
.empty-state i {
  font-size: 28px;
  color: var(--gray-300);
  display: block;
  margin-bottom: 10px;
}
.empty-state p {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 14px;
}

/* ── FORMS ── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--white);
  transition: border-color 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--kb-blue);
  box-shadow: 0 0 0 3px rgba(43, 125, 233, 0.1);
}
.form-textarea {
  resize: vertical;
  min-height: 80px;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-errors {
  color: var(--red);
  font-size: 12px;
  margin: 4px 0 0;
  list-style: none;
  padding: 0;
}
.form-help {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  display: block;
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--gray-50);
}
.upload-zone:hover {
  border-color: var(--kb-blue);
  background: var(--kb-blue-xlight);
}
.upload-zone i {
  font-size: 32px;
  color: var(--gray-300);
  display: block;
  margin-bottom: 10px;
}
.upload-zone:hover i {
  color: var(--kb-blue);
}
.upload-zone p {
  font-size: 13px;
  color: var(--gray-500);
  margin: 0;
}
.upload-zone small {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
  display: block;
}
.upload-zone input[type="file"] {
  margin-top: 14px;
  font-size: 12px;
  color: var(--gray-600);
}

/* ── TWO-COL LAYOUT ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── TABLES ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--gray-500);
  font-weight: 500;
  font-size: 11px;
  border-bottom: 1px solid var(--gray-200);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gray-50);
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
.data-table tr:last-child td {
  border-bottom: none;
}

/* ── BID ROW (dashboard "Recent bids") ── */
.bid-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
  text-decoration: none;
}
.bid-row:hover {
  border-color: var(--kb-blue-mid);
  background: var(--kb-blue-xlight);
  box-shadow: var(--shadow);
}
.bid-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--kb-blue-light);
  border: 1px solid rgba(43, 125, 233, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bid-icon i {
  font-size: 18px;
  color: var(--kb-blue);
}
.bid-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}
.bid-meta {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bid-due {
  font-size: 11px;
  color: var(--gray-400);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── SPEC / INFO NOTES ── */
.page-note {
  background: var(--kb-blue-xlight);
  border: 1px solid rgba(43, 125, 233, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--kb-navy);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.page-note i {
  font-size: 16px;
  color: var(--kb-blue);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── CHAT ── */
.chat-container {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-header {
  padding: 12px 16px;
  background: var(--kb-navy);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.chat-header-title {
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}
.chat-header-sub {
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
}
.chat-header i {
  color: var(--kb-blue-mid);
  font-size: 18px;
}
.chat-messages {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--gray-50);
  min-height: 100px;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-height: 480px;
  overflow-y: auto;
}
.chat-messages.has-messages {
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
}
.chat-messages .empty-state {
  border: none;
  background: none;
  padding: 8px 20px;
}
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.msg.user {
  flex-direction: row-reverse;
}
.msg-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
}
.msg-av.ai {
  background: var(--kb-blue-light);
  color: var(--kb-navy);
}
.msg-av.user {
  background: var(--kb-navy);
  color: #fff;
}
.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.6;
  max-width: 82%;
}
.msg-bubble.ai {
  background: var(--white);
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
}
.msg-bubble.user {
  background: var(--kb-navy);
  color: #fff;
}
/* Chat messages are rendered from Markdown to HTML (server-side on initial
 * load via `core/templatetags/markdown_extras.py`, client-side for
 * streamed chunks via vendored `marked`+`DOMPurify` in `static/js/chat.js`)
 * — these rules give the resulting block elements sane spacing/sizing
 * inside the fairly small `.msg-bubble` instead of relying on browser
 * defaults, which are too spacious for a chat bubble. */
.msg-bubble > *:first-child {
  margin-top: 0;
}
.msg-bubble > *:last-child {
  margin-bottom: 0;
}
.msg-bubble p {
  margin: 0 0 8px;
}
.msg-bubble ul,
.msg-bubble ol {
  margin: 0 0 8px;
  padding-left: 20px;
}
.msg-bubble li + li {
  margin-top: 2px;
}
.msg-bubble h1,
.msg-bubble h2,
.msg-bubble h3,
.msg-bubble h4,
.msg-bubble h5,
.msg-bubble h6 {
  margin: 0 0 6px;
  font-size: 1em;
  font-weight: 700;
  line-height: 1.4;
}
.msg-bubble blockquote {
  margin: 0 0 8px;
  padding-left: 10px;
  border-left: 2px solid currentColor;
  opacity: 0.85;
}
.msg-bubble hr {
  margin: 8px 0;
  border: none;
  border-top: 1px solid currentColor;
  opacity: 0.2;
}
.msg-bubble code {
  font-family: var(--font-mono, monospace);
  font-size: 0.92em;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.06);
}
.msg-bubble.user code {
  background: rgba(255, 255, 255, 0.15);
}
.msg-bubble pre {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.06);
  overflow-x: auto;
}
.msg-bubble.user pre {
  background: rgba(255, 255, 255, 0.15);
}
.msg-bubble pre code {
  padding: 0;
  background: none;
}
.msg-bubble table {
  width: 100%;
  margin: 0 0 8px;
  border-collapse: collapse;
  font-size: 0.95em;
}
.msg-bubble th,
.msg-bubble td {
  padding: 4px 8px;
  border: 1px solid currentColor;
  opacity: 0.9;
  text-align: left;
}
.msg-bubble a {
  color: inherit;
  text-decoration: underline;
}
/* Typing indicator: three animated dots shown in an assistant-styled
 * bubble while a chat reply is being generated (from submit until the
 * first streamed chunk, error, or done — see static/js/chat.js). */
.msg-bubble.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}
.msg-bubble.typing .typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gray-400);
  animation: typing-dot-bounce 1.2s infinite ease-in-out;
}
.msg-bubble.typing .typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}
.msg-bubble.typing .typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes typing-dot-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}
.chat-input-row input {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  font-size: 13px;
  font-family: var(--font);
}
.chat-input-row input:focus {
  outline: none;
  border-color: var(--kb-blue);
}
.chat-input-row input[disabled] {
  background: var(--gray-50);
  color: var(--gray-400);
}

/* ── LAYOUT UTILITIES ──
 * Small, generic spacing/color helpers used in a couple of templates in
 * place of one-off inline `style="..."` attributes. */
.mb-sm {
  margin-bottom: 14px;
}
.mb-md {
  margin-bottom: 20px;
}
.mb-lg {
  margin-bottom: 24px;
}
.mt-sm {
  margin-top: 14px;
}
.text-danger {
  color: var(--red);
}
.table-wrap {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.file-icon {
  color: var(--kb-blue);
  margin-right: 6px;
}
.p-tight {
  margin: 0 0 6px;
}

/* ── GENERATED RFP PACKAGE (version history + internal-only panels) ── */
.internal-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--amber-light);
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  margin-bottom: 14px;
}
.internal-banner i {
  font-size: 16px;
}
.generation-run {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.generation-run-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.generation-run-title {
  font-weight: 600;
  color: var(--kb-navy);
  font-size: 13px;
}
.generation-run-meta {
  font-size: 11px;
  color: var(--gray-400);
}
.generated-doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.generated-doc-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.generated-doc-row .doc-name {
  flex: 1;
  font-size: 13px;
}
.generation-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-400);
}
.generation-progress i {
  font-size: 15px;
}
.run-warnings {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--amber-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--amber);
}
.run-warnings ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

/* ── DIVIDER ── */
.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 20px 0;
}

/* ── MESSAGES ──
 * Not scoped to `.app` — shared by both the authenticated app shell and the
 * public shell (login, home, error pages) so Django's messages framework
 * renders consistently everywhere. */
.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.messages .message {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 8px;
  background: var(--kb-blue-xlight);
  color: var(--kb-navy);
}
.messages .message.error {
  background: var(--red-light);
  color: var(--red);
}
.messages .message.success {
  background: var(--green-light);
  color: var(--green);
}

/* ── SCROLLBAR ── */
.app ::-webkit-scrollbar {
  width: 4px;
}
.app ::-webkit-scrollbar-track {
  background: transparent;
}
.app ::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 4px;
}

/* ── RESPONSIVE ── */
@media (max-width: 860px) {
  .app {
    flex-direction: column;
    height: auto;
  }
  .sidebar {
    width: 100%;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ── DOCUMENTATION (in-app user manual) ── */
.docs-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
}
.docs-toc {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
}
.docs-toc-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 10px;
}
.docs-toc a {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-600);
  text-decoration: none;
  margin-bottom: 2px;
}
.docs-toc a:hover {
  background: var(--kb-blue-xlight);
  color: var(--kb-navy);
}
.docs-content {
  flex: 1;
  min-width: 0;
  max-width: 720px;
}
.docs-section {
  margin-bottom: 36px;
  scroll-margin-top: 16px;
}
.docs-section h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--kb-navy);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.docs-section h2 i {
  color: var(--kb-blue);
  font-size: 18px;
}
.docs-section p {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.7;
  margin: 0 0 12px;
}
.docs-section ul,
.docs-section ol {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.7;
  padding-left: 20px;
  margin: 0 0 12px;
}
.docs-section li {
  margin-bottom: 4px;
}
.docs-step-list {
  counter-reset: docs-step;
  list-style: none;
  padding-left: 0;
}
.docs-step-list li {
  counter-increment: docs-step;
  position: relative;
  padding-left: 34px;
  margin-bottom: 14px;
}
.docs-step-list li::before {
  content: counter(docs-step);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--kb-blue-light);
  color: var(--kb-navy);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.docs-lifecycle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0 16px;
}
.docs-lifecycle i.ti-arrow-right {
  color: var(--gray-300);
  font-size: 14px;
}
@media (max-width: 860px) {
  .docs-layout {
    flex-direction: column;
  }
  .docs-toc {
    width: 100%;
    position: static;
  }
}

/* ─────────────────────────────────────────────────────────────────────
 * PUBLIC SHELL — unauthenticated pages (home, login, password reset,
 * error pages). Shares the same brand tokens/fonts/icons as the
 * authenticated app shell above (`.app`/`.sidebar`/etc.) but with a plain
 * top-nav layout instead of a sidebar, since these pages don't have a
 * signed-in user's workspace to navigate.
 * ───────────────────────────────────────────────────────────────────── */

body.public-shell {
  margin: 0;
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.public-header {
  background: var(--kb-navy);
  padding: 14px 24px;
}
.public-header .public-nav {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.public-header .logo-lockup {
  text-decoration: none;
}
.public-header .nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}
.public-header .nav-links a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}
.public-header .nav-links a:hover {
  color: #fff;
}
.public-header .nav-user {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}
.public-header .link-button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  padding: 0;
}
.public-header .link-button:hover {
  color: #fff;
}

.public-main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px;
  box-sizing: border-box;
}

/* ── HERO (home page) ── */
.hero {
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
}
.hero-eyebrow {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--kb-blue);
  margin-bottom: 8px;
}
.hero h1 {
  font-size: 28px;
  font-weight: 600;
  color: var(--kb-navy);
  margin-bottom: 12px;
}
.hero p {
  font-size: 14px;
  color: var(--gray-600);
  line-height: 1.7;
  margin-bottom: 24px;
}

/* ── LOGIN / AUTH CARDS ── */
.auth-card {
  max-width: 380px;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}
.auth-card .logo-lockup {
  justify-content: center;
  margin-bottom: 20px;
}
.auth-card h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  text-align: center;
  margin: 0 0 20px;
}
.auth-card .form-help {
  text-align: center;
  margin-top: 16px;
}
.auth-card .form-help a {
  color: var(--kb-blue);
  text-decoration: none;
}
.auth-card .form-help a:hover {
  text-decoration: underline;
}

/* ── ERROR PAGES ── */
.error-page {
  text-align: center;
  max-width: 480px;
  margin: 40px auto 0;
}
.error-page .error-code {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--kb-blue);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.error-page h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 12px;
}
.error-page p {
  font-size: 14px;
  color: var(--gray-600);
  line-height: 1.7;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .public-main {
    padding: 32px 16px;
  }
  .auth-card {
    padding: 24px 20px;
  }
}

/* ── NOTIFICATIONS (bell + dropdown) ── */
.notif-bell-wrap {
  position: relative;
}
.notif-bell {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--gray-500);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
}
.notif-bell:hover {
  background: var(--gray-50);
  color: var(--gray-700);
}
.notif-badge-count {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--red);
  color: #fff;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 5px;
  min-width: 16px;
  text-align: center;
}
.notif-badge-count.is-empty {
  display: none;
}
.notif-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 40;
}
.notif-dropdown.is-open {
  display: block;
}
.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}
.notif-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  text-decoration: none;
  color: inherit;
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item:hover {
  background: var(--gray-50);
}
.notif-item.unread {
  background: var(--kb-blue-xlight);
}
.notif-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}
.notif-item-message {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}
.notif-item-time {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}
.notif-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
}
