:root {
  --brand:       #6264A7;
  --brand-dark:  #464775;
  --bg:          #F3F2F1;
  --surface:     #FFFFFF;
  --border:      #E1DFDD;
  --text:        #252423;
  --muted:       #605E5C;
}

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

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Password Gate ──────────────────────────────────────────────────────────── */

#pw-gate {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--brand-dark);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.pw-box {
  background: var(--surface);
  border-radius: 10px;
  padding: 40px 36px;
  width: 340px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.pw-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: .08em;
}

.pw-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.pw-box input[type=password] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
}

.pw-box input[type=password]:focus { border-color: var(--brand); }

.pw-box button {
  width: 100%;
  padding: 10px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}

.pw-box button:hover { background: var(--brand-dark); }
.pw-box button:disabled { opacity: .6; cursor: default; }

.pw-err {
  color: #C00000;
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
}

.nav-admin {
  margin-left: auto;
  font-size: 12px;
  opacity: .75;
}

/* ── Header ────────────────────────────────────────────────────────────────── */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 0;
  flex-shrink: 0;
  gap: 1px;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--brand);
  letter-spacing: .06em;
  line-height: 1.1;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 7px;
  position: relative;
}

.brand-version {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  cursor: pointer;
  line-height: 1.4;
  letter-spacing: .02em;
}

.brand-version:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.about-pop {
  position: absolute;
  top: 24px;
  left: 0;
  z-index: 50;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
  padding: 12px 14px;
}

.about-pop.hidden { display: none; }

.about-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
}

.about-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 0;
}

.about-row b { color: var(--text); font-weight: 600; }

.about-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.brand-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  font-weight: 500;
}

.header-date {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-nav { display: flex; }

.nav-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--muted);
  transition: color .12s, border-color .12s;
}
.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ── Main ──────────────────────────────────────────────────────────────────── */

main { padding: 16px 20px; }

.view { display: none; }
.view.active { display: block; }

/* ── Toolbar ───────────────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.toolbar label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.toolbar select,
.toolbar input[type="search"] {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}
.toolbar select:focus,
.toolbar input[type="search"]:focus {
  outline: 1px solid var(--brand);
  border-color: var(--brand);
}
.toolbar input[type="search"] { width: 200px; }

.toolbar button {
  height: 30px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.toolbar button:hover { background: var(--brand-dark); }

.count-badge {
  font-size: 12px;
  color: var(--muted);
}

.export-btn {
  height: 30px;
  padding: 0 12px;
  background: none;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  white-space: nowrap;
  margin-left: auto;
}
.export-btn:hover { background: var(--brand); color: #fff; }

/* ── Table ─────────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFAF9; }

td {
  padding: 8px 12px;
  vertical-align: top;
}

.id-col {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 12px;
  color: var(--brand);
  white-space: nowrap;
}

.title-col { max-width: 300px; }
.notes-col { max-width: 260px; }

.clamp {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Rating */
.b-mandatory    { background: #FDE7E9; color: #A4262C; }
.b-required     { background: #FFF4CE; color: #7A5D00; }
.b-recommended  { background: #E7F3E8; color: #107C10; }

/* Status */
.b-draft        { background: #FFF4CE; color: #7A5D00; }        /* amber  – pending    */
.b-promoted     { background: #DFF6DD; color: #0E6B0E; }        /* green  – approved   */
.b-completed    { background: #DFF6DD; color: #0E6B0E; }        /* green  – done       */
.b-inprogress   { background: #FFF0E6; color: #8B3900; }        /* orange – needs work */
.b-pendingsme   { background: #EEF0F8; color: var(--brand-dark); } /* purple – waiting */
.b-notfmc       { background: #F3F2F1; color: #605E5C; }        /* grey   – n/a        */
.b-overdue      { background: #FDE7E9; color: #A4262C; }        /* red    – overdue    */
.b-fix-req      { background: #FDE7E9; color: #A4262C; font-style: italic; } /* red – fix needed */
.b-default      { background: #F3F2F1; color: #605E5C; }        /* grey   – unknown    */

/* ── States ────────────────────────────────────────────────────────────────── */

.state-msg {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

a.src-link {
  color: var(--brand);
  text-decoration: none;
  font-size: 12px;
}
a.src-link:hover { text-decoration: underline; }

.has-tip {
  border-bottom: 1px dotted var(--muted);
  cursor: help;
}

/* ── MultiSelect ────────────────────────────────────────────────────────────── */

.ms-wrap { position: relative; display: inline-block; min-width: 140px; }

.ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-family: inherit;
}
.ms-trigger:hover { border-color: var(--brand); }
.ms-caret { font-size: 10px; color: var(--muted); flex-shrink: 0; }

.ms-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  min-width: 170px;
}
.ms-menu.hidden { display: none; }

.ms-actions {
  display: flex;
  gap: 6px;
  padding: 7px 10px 5px;
  border-bottom: 1px solid var(--border);
}
.ms-btn-sm {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: none;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.ms-btn-sm:hover { background: var(--bg); }

.ms-list { max-height: 210px; overflow-y: auto; padding: 4px 0; }

.ms-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
}
.ms-item:hover { background: var(--bg); }
.ms-item input { margin: 0; cursor: pointer; }

/* ── Standards expand ────────────────────────────────────────────────────────── */

.expand-col { width: 20px; padding: 8px 4px 8px 12px !important; }

.expand-icon {
  font-size: 9px;
  color: var(--muted);
  display: inline-block;
  transition: transform .15s;
}

tr.std-row { cursor: pointer; }
tr.std-row:hover { background: #F5F4F3; }
tr.std-row.expanded { background: #EEF2FF; }
tr.std-row.expanded .expand-icon { color: var(--brand); }

tr.std-detail-row td { padding: 0 !important; border-bottom: 2px solid var(--brand); }

.detail-panel {
  padding: 16px 20px;
  background: #F8F8FC;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dp-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dp-section { display: flex; flex-direction: column; gap: 4px; }

.dp-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.dp-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.dp-text em { color: var(--muted); font-style: normal; }

.dp-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.dp-id-display {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 13px;
  color: var(--brand);
  font-weight: 600;
}

.dp-copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}
.dp-copy-btn:hover { border-color: var(--brand); color: var(--brand); }

.dp-src-btn {
  padding: 2px 10px;
  font-size: 12px;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 3px;
  text-decoration: none;
  display: inline-block;
}
.dp-src-btn:hover { background: var(--brand); color: #fff; }

.dp-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.dp-tags { display: flex; flex-direction: column; gap: 5px; }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  margin: 2px 2px 0 0;
}
.tag-product { background: #EFF6FC; color: #005B9A; }
.tag-market  { background: #E7F3E8; color: #107C10; }

/* ── Dashboard ───────────────────────────────────────────────────────────────── */

.dash-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: box-shadow .12s;
}

.metric-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }

.metric-card.alert { border-left: 4px solid #A4262C; }
.metric-card.warn  { border-left: 4px solid #C97B00; }
.metric-card.good  { border-left: 4px solid #107C10; }
.metric-card.info  { border-left: 4px solid var(--brand); }

.metric-value {
  font-size: 34px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -.01em;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-top: 2px;
}

.metric-sub {
  font-size: 11px;
  color: var(--muted);
}

.dash-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .dash-sections { grid-template-columns: 1fr; }
}

.dash-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.dash-section-head {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.dash-section table { font-size: 12px; }
.dash-section td { padding: 6px 12px; }

.fmc-signal-row { background: #FEF0F0; }

/* ── Dashboard — Changes-by-status bar chart ───────────────────────────────── */

.dash-status-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 16px;
}

.cbs-list { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 9px; }

.cbs-row { display: flex; align-items: center; gap: 10px; }

.cbs-label { min-width: 170px; flex-shrink: 0; }

.cbs-bar-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 3px;
  height: 8px;
  overflow: hidden;
}

.cbs-bar {
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width .4s ease;
  min-width: 2px;
}

.cbs-count {
  min-width: 32px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.cbs-bar.bar-mandatory   { background: #A4262C; }
.cbs-bar.bar-required    { background: #7A5D00; }
.cbs-bar.bar-recommended { background: #107C10; }

/* ── Dashboard — Portfolio Summary panel ───────────────────────────────────── */

.dash-portfolio {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .dash-portfolio { grid-template-columns: 1fr; }
}

.dash-portfolio-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.pf-cat-list { padding: 6px 14px 12px; display: flex; flex-direction: column; gap: 0; }

.pf-cat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.pf-cat-row:last-child { border-bottom: none; }

.pf-cat-name { color: var(--text); }
.pf-cat-count { font-weight: 700; color: var(--brand); font-size: 13px; }

/* ── Dashboard — Charts row ─────────────────────────────────────────────────── */

.dash-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

@media (max-width: 900px) {
  .dash-charts-row { grid-template-columns: 1fr; }
}

.dash-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.dash-chart-wrap {
  padding: 16px;
  height: 200px;
  position: relative;
}

/* ── Deadline Tracker ───────────────────────────────────────────────────────── */

.dl-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 20px;
  overflow: hidden;
}

.dl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.dl-summary { display: flex; gap: 6px; flex-wrap: wrap; }

.dl-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
.dl-chip.dl-overdue { background: #FDE7E9; color: #A4262C; }
.dl-chip.dl-week    { background: #FFF0E6; color: #8B3900; }
.dl-chip.dl-future  { background: #EEF0F8; color: var(--brand-dark); }

.dl-list { display: flex; flex-direction: column; }

.dl-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.dl-row:last-child { border-bottom: none; }
.dl-row:hover { background: #FAFAFA; }
.dl-row.dl-overdue { background: #FFF8F8; }
.dl-row.dl-week    { background: #FFFAF6; }

.dl-date-col { text-align: right; }

.dl-countdown {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}
.dl-countdown.dl-overdue { color: #A4262C; }
.dl-countdown.dl-week    { color: #8B3900; }
.dl-countdown.dl-month   { color: #7A5D00; }
.dl-countdown.dl-future  { color: var(--brand); }
.dl-countdown.dl-none    { color: var(--muted); }

.dl-date { font-size: 10px; color: var(--muted); }

.dl-info {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}

.dl-type-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 8px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.dl-type-change   { background: #EFF6FC; color: #005B9A; }
.dl-type-standard { background: #EEF0F8; color: var(--brand-dark); }

.dl-id    { font-size: 11px; font-weight: 600; color: var(--brand); flex-shrink: 0; }
.dl-title { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.dl-owner { font-size: 11px; color: var(--muted); white-space: nowrap; }
.dl-more  { padding: 8px 16px; font-size: 11px; color: var(--muted); text-align: center; border-top: 1px solid var(--border); }

/* ── Compliance Heatmap ─────────────────────────────────────────────────────── */

.hm-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 20px;
}

.hm-scroll { overflow-x: auto; }

.hm-table {
  border-collapse: collapse;
  font-size: 11px;
  min-width: 600px;
}

.hm-corner { width: 52px; }

.hm-col-head {
  padding: 0 2px 6px;
  vertical-align: bottom;
  text-align: center;
  white-space: nowrap;
}

.hm-col-label {
  display: inline-block;
  transform: rotate(-55deg) translateX(-4px);
  transform-origin: bottom left;
  color: var(--muted);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: .04em;
  width: 42px;
  text-align: left;
}

.hm-row-head {
  padding: 4px 10px 4px 0;
  text-align: right;
  color: var(--muted);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: .04em;
  white-space: nowrap;
}

.hm-cell {
  width: 36px;
  height: 28px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 3px;
  transition: opacity .15s;
  cursor: default;
}

.hm-cell:hover { outline: 2px solid var(--brand); outline-offset: -1px; }

.hm-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

.hm-legend-label { font-size: 10px; color: var(--muted); }

.hm-legend-bar {
  width: 120px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(to right, rgba(98,100,167,.08), rgba(98,100,167,.9));
  border: 1px solid var(--border);
}

/* ── Market Compare panel ───────────────────────────────────────────────────── */

.compare-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 12px;
}

.compare-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.compare-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compare-controls select {
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

.compare-controls button {
  height: 28px;
  padding: 0 14px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.compare-controls button:hover { background: var(--brand-dark); }

.cmp-summary { padding: 12px 16px; }

.cmp-table { width: auto; min-width: 260px; }
.cmp-table td { padding: 5px 10px; font-size: 13px; }
.cmp-table tr { border-bottom: 1px solid var(--border); }
.cmp-table tr:last-child { border-bottom: none; }
.cmp-num { font-weight: 700; color: var(--brand); text-align: right; padding-left: 24px; }

.cmp-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Market Brief ───────────────────────────────────────────────────────────── */

.brief-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #EEF2FF;
  border: 1px solid #C7CAE8;
  border-radius: 6px 6px 0 0;
  padding: 10px 16px;
  font-size: 13px;
  margin-bottom: 0;
}

.brief-close-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}
.brief-close-btn:hover { border-color: var(--brand); color: var(--brand); }

.brief-cat-section { margin-bottom: 16px; }

.brief-cat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-radius: 4px 4px 0 0;
}

.brief-cat-count {
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
}

/* ── Changes — Diff / Jurisdiction view ─────────────────────────────────────── */

.diff-section { margin-bottom: 14px; }

.diff-jur-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-radius: 4px 4px 0 0;
}

.active-toggle {
  background: var(--brand-dark) !important;
}

/* ── Project Cards ───────────────────────────────────────────────────────────── */

.proj-subsection {
  margin-bottom: 26px;
}

.proj-subsection-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 2px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.proj-subsection-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.proj-subsection-sub {
  font-size: 12px;
  color: var(--muted);
}

.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding-top: 4px;
}

.proj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.proj-card:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(98,100,167,.12);
}

.proj-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.proj-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.proj-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.proj-type-product  { background: #EFF6FC; color: #005B9A; }
.proj-type-baseline { background: #F0F0FF; color: var(--brand-dark); }

.proj-card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.proj-card-stats {
  display: flex;
  gap: 16px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.proj-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.proj-stat-val  { font-size: 16px; font-weight: 700; color: var(--brand); }
.proj-stat-lbl  { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.proj-card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.proj-card-markets { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.proj-rating-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rb-chip { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px; color: #fff; }
.rb-mandatory   { background: #C00000; }
.rb-required    { background: #E74C3C; }
.rb-recommended { background: #1F6BB5; }

.proj-impact-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  background: var(--brand);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  vertical-align: middle;
  cursor: default;
}
.proj-impact-badge.proj-impact-all {
  background: #C00000;
}

/* ── Project Detail ──────────────────────────────────────────────────────────── */

.proj-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.back-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}
.back-btn:hover { border-color: var(--brand); color: var(--brand); }

.proj-detail-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.proj-detail-meta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.proj-meta-item { display: flex; flex-direction: column; gap: 2px; }
.proj-meta-label { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.proj-meta-val   { font-size: 13px; color: var(--text); }

.proj-detail-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 14px;
}

.proj-section-head {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.proj-section-count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

/* ── Gap Analysis ────────────────────────────────────────────────────────────── */

.gap-cell {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.gap-ok   { color: #107C10; background: #F1FAF1; }
.gap-miss { color: #A4262C; background: #FEF0F0; }
.gap-cat  { font-size: 13px; padding: 8px 12px; }

.gap-note {
  margin-top: 10px;
  padding: 8px 14px;
  background: #E7F3E8;
  color: #107C10;
  font-size: 13px;
  border-radius: 4px;
}

.gap-clickable { cursor: pointer; }
.gap-clickable:hover { background: #F5C6C8 !important; }

/* ── Configurator ────────────────────────────────────────────────────────────── */

.cfg-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.cfg-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.cfg-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.cfg-header {
  margin-bottom: 16px;
}

.cfg-info-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.cfg-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cfg-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cfg-field input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
}

.cfg-field input:focus {
  outline: none;
  border-color: var(--brand);
}

.cfg-sections {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(180px, auto);
  gap: 16px;
  margin-bottom: 14px;
}

.cfg-section {
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.cfg-section-head {
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 6px 10px;
  text-transform: uppercase;
}

.cfg-checks {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 8px;
  max-height: 280px;
  overflow-y: auto;
}

.cfg-check-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 4px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  user-select: none;
  white-space: nowrap;
}

.cfg-check-item:hover { background: var(--bg); }

.cfg-check-item input[type=checkbox] {
  width: 14px; height: 14px;
  cursor: pointer;
  accent-color: var(--brand);
}

.cfg-ext { color: var(--muted); font-style: italic; }
.cfg-ext::after { content: ' (proxy)'; font-size: 10px; }

.cfg-context {
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 14px;
}

.cfg-context > summary {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.cfg-context > summary::before {
  content: '▶ ';
  font-size: 10px;
}

.cfg-context[open] > summary::before { content: '▼ '; }

.cfg-context-body {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.cfg-context-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.cfg-context-group {
  min-width: 140px;
}

.cfg-context-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.cfg-context-group .cfg-checks {
  max-height: 140px;
  padding: 4px 6px;
}

.cfg-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.cfg-btn-primary {
  padding: 8px 20px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.cfg-btn-primary:hover { background: var(--brand-dark); }
.cfg-btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.cfg-btn-secondary {
  padding: 7px 16px;
  background: #fff;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.cfg-btn-secondary:hover { background: #f0f0fa; }
.cfg-btn-secondary:disabled { opacity: .45; cursor: not-allowed; }

/* Admin data status panel */
.admin-status-row { display: flex; align-items: baseline; gap: 10px; padding: 3px 0; }
.admin-status-lbl { font-size: 12px; font-weight: 600; color: var(--muted); min-width: 110px; flex-shrink: 0; }
.admin-status-val { font-size: 13px; font-weight: 600; color: var(--text); font-family: monospace; }
.admin-version-input {
  font-size: 13px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
  font-family: monospace;
}
.admin-version-input:focus { outline: none; border-color: var(--brand); }

.cfg-status {
  font-size: 13px;
  color: var(--muted);
  margin-left: 4px;
}

.cfg-advisory {
  background: #FFF9E6;
  border: 1px solid #F0C83A;
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12px;
  color: #7A5D00;
}

.cfg-result-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.cfg-result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

.cfg-empty {
  padding: 16px 14px;
  color: var(--muted);
  font-size: 13px;
}

.gap-drill-head {
  padding: 10px 14px;
  background: #FEF0F0;
  border: 1px solid #F4C0C0;
  border-bottom: none;
  font-size: 13px;
  margin-top: 16px;
  border-radius: 4px 4px 0 0;
}

/* ── Upload Gap Panel ──────────────────────────────────────────────────────── */

.gap-upload-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 18px;
  margin: 10px 0 14px;
}

.gap-upload-intro {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.gap-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.gap-upload-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
  flex: 1;
}

.gap-upload-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.gap-upload-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.gap-file-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: border-color .15s;
  max-width: 300px;
}

.gap-file-pick:hover {
  border-color: var(--brand);
}

.gap-file-pick::before {
  content: "📄";
  font-size: 14px;
}

.gap-upload-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

/* ── Upload Gap Result Cards ─────────────────────────────────────────────── */

.gap-up-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.gap-up-card {
  flex: 1;
  min-width: 130px;
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.gap-up-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.gap-up-lbl {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.gap-up-sub {
  font-size: 11px;
  color: var(--muted);
}

.gap-up-miss  { border-left: 4px solid #C00000; }
.gap-up-miss  .gap-up-num { color: #C00000; }

.gap-up-match { border-left: 4px solid #107C10; }
.gap-up-match .gap-up-num { color: #107C10; }

.gap-up-extra { border-left: 4px solid #BF8F00; }
.gap-up-extra .gap-up-num { color: #BF8F00; }

.gap-up-scope { border-left: 4px solid #605E5C; }
.gap-up-scope .gap-up-num { color: #605E5C; }

/* ── Slide-in Detail Drawer ─────────────────────────────────────────────────── */

/* Backdrop — separate fixed element, sibling of .prism-drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .40);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 999;
}
.drawer-backdrop.drawer-open { opacity: 1; pointer-events: all; }

/* Drawer panel — slides in from the right */
.prism-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 520px;
  max-width: 92vw;
  background: var(--surface);
  box-shadow: -4px 0 32px rgba(0, 0, 0, .2);
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}
.prism-drawer.drawer-open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

/* ID tag chip in drawer header */
.drawer-id-tag {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  background: rgba(98,100,167,.1);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
  flex-shrink: 0;
}
.drawer-close:hover { color: var(--text); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

/* Drawer content — rendered by _DRAWER._render() */
.dr-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.dr-section {
  margin-bottom: 16px;
}

.dr-sec-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.dr-field {
  display: flex;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid #f0f0f0;
  align-items: baseline;
}
.dr-field:last-child { border-bottom: none; }

.dr-label {
  color: var(--muted);
  min-width: 130px;
  flex-shrink: 0;
  font-size: 11px;
}

.dr-val {
  color: var(--text);
  word-break: break-word;
  font-weight: 500;
}

.dr-notes {
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 4px;
}

/* Market / Product grid in drawer */
.dr-mkt-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.dr-mkt {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.dr-mkt-on  { background: rgba(98,100,167,.15); color: var(--brand); }
.dr-mkt-off { background: #f0f0f0; color: #bbb; }

.dr-proj-list { display: flex; flex-wrap: wrap; gap: 6px; }
.dr-proj {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(98,100,167,.15);
  color: var(--brand);
}
.dr-proj-baseline { background: #eef1f4; color: #5a6472; }
.dr-noproj { font-size: 12px; color: var(--muted); font-style: italic; }

/* Cursor hint on clickable ID cells */
.id-col { cursor: pointer; }
.id-col:hover { text-decoration: underline; }

/* ── PRISM Chat ──────────────────────────────────────────────────────────────── */

#view-chat { display: none; }
#view-chat.active { padding: 16px 0 0; display: block; }

.chat-container {
  display: flex;
  flex-direction: column;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 0 16px;
}

.chat-thread {
  overflow-y: auto;
  max-height: calc(100vh - 240px);
  padding: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  margin: 0;
  text-align: center;
  padding: 24px 16px 12px;
}

.chat-welcome-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 8px;
}

.chat-welcome-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.chat-skill-section {
  margin-bottom: 14px;
}

.chat-skill-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 7px;
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--brand);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.chat-chip:hover {
  background: #EDECF4;
  border-color: var(--brand);
}

.chat-skill-chip {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
  font-weight: 500;
  padding: 5px 14px;
}
.chat-skill-chip:hover { background: #EDECF4; border-color: var(--brand); }

.chat-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 0 4px;
  margin-top: 2px;
  border-top: 1px dashed var(--border);
}

.chat-followup-chip {
  background: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--brand);
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
}

.chat-followup-chip:hover {
  background: #EDECF4;
  border-color: var(--brand);
}

.chat-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-msg-user {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-msg-user p { margin: 0; }

.chat-msg-assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.chat-msg-assistant p { margin: 0 0 6px; }
.chat-msg-assistant p:last-child { margin-bottom: 0; }
.chat-msg-assistant h1,.chat-msg-assistant h2,.chat-msg-assistant h3 {
  font-size: 14px; font-weight: 700; margin: 8px 0 4px;
}
.chat-msg-assistant ul,.chat-msg-assistant ol {
  padding-left: 18px; margin: 4px 0;
}
.chat-msg-assistant li { margin: 2px 0; }
.chat-msg-assistant code {
  background: #F3F2F1; border-radius: 3px; padding: 1px 5px;
  font-size: 12px; font-family: "Cascadia Code", Consolas, monospace;
}
.chat-msg-assistant pre {
  background: #F3F2F1; border-radius: 6px; padding: 10px 12px;
  overflow-x: auto; margin: 6px 0;
}
.chat-msg-assistant pre code { background: none; padding: 0; }
.chat-msg-assistant table {
  border-collapse: collapse; width: 100%; font-size: 12px; margin: 6px 0;
}
.chat-msg-assistant th {
  background: var(--brand); color: #fff; padding: 5px 8px; text-align: left;
}
.chat-msg-assistant td {
  padding: 4px 8px; border-bottom: 1px solid var(--border);
}
.chat-msg-assistant tr:nth-child(even) td { background: #F8F8F8; }

.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.chat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  opacity: .4;
  animation: chat-bounce .9s infinite;
}
.chat-dot:nth-child(2) { animation-delay: .15s; }
.chat-dot:nth-child(3) { animation-delay: .30s; }

@keyframes chat-bounce {
  0%,80%,100% { transform: translateY(0); opacity: .4; }
  40%          { transform: translateY(-5px); opacity: 1; }
}

.chat-err { color: #C00000; font-size: 12px; }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 0 14px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}

.chat-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-input-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chat-think-ctrl {
  display: flex;
  gap: 3px;
}

.think-btn {
  font-size: 11px;
  padding: 3px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.think-btn:hover { border-color: var(--brand); color: var(--brand); }
.think-btn.think-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.chat-thinking-note {
  font-size: 11px;
  color: var(--brand);
  font-style: italic;
}

.chat-attach-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #EEF0F8;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
}
.chat-attach-badge span:nth-child(2) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-attach-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.chat-attach-remove:hover { color: #C00000; }

.chat-attach-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  padding: 3px 7px;
  color: var(--muted);
  transition: border-color .15s, color .15s;
}
.chat-attach-btn:hover { border-color: var(--brand); color: var(--brand); }

.chat-input-actions { position: relative; }

.chat-history-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  width: 280px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
}

.chat-history-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.chat-history-item:last-child { border-bottom: none; }
.chat-history-item:hover { background: #F5F5F5; }

.chat-history-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-history-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.chat-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.chat-history-search {
  width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  background: var(--bg);
  color: var(--text);
}
.chat-history-search:focus { border-color: var(--brand); }

.chat-history-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.chat-attach-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

#chat-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  line-height: 1.45;
  transition: border-color .15s;
}
#chat-input:focus { outline: none; border-color: var(--brand); }

#chat-send {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  height: 38px;
  white-space: nowrap;
}
#chat-send:hover { background: var(--brand-dark); }
#chat-send:disabled { opacity: .6; cursor: not-allowed; }

/* ── Project inline chat ─────────────────────────────────────────────────────── */

.proj-chat-wrap {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px 0;
}

.proj-chat-thread {
  max-height: 400px;
  overflow-y: auto;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.proj-chat-msg { max-width: 90%; }

.proj-chat-input-row {
  padding: 10px 0 12px;
}

#proj-chat-input,
#pm-chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  line-height: 1.45;
  transition: border-color .15s;
}
#proj-chat-input:focus,
#pm-chat-input:focus { outline: none; border-color: var(--brand); }

#proj-chat-send {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  height: 38px;
  white-space: nowrap;
}
#proj-chat-send:hover { background: var(--brand-dark); }
#proj-chat-send:disabled { opacity: .6; cursor: not-allowed; }

.proj-chat-send-btn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  height: 38px;
  white-space: nowrap;
}
.proj-chat-send-btn:hover { background: var(--brand-dark); }
.proj-chat-send-btn:disabled { opacity: .6; cursor: not-allowed; }

.chat-new-btn {
  font-size: 11px;
  padding: 3px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
}
.chat-new-btn:hover { border-color: var(--brand); color: var(--brand); }

.chat-sql-note {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ── Side Drawer ────────────────────────────────────────────────────────────── */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.drawer-backdrop.drawer-open {
  opacity: 1;
  pointer-events: auto;
}

.prism-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 500px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 32px rgba(0,0,0,.14);
  z-index: 901;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.prism-drawer.drawer-open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.drawer-id-tag {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  background: var(--brand);
  color: #fff;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.drawer-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}

.drawer-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}
.drawer-close:hover { background: var(--border); color: var(--text); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.dr-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.dr-section {
  margin-bottom: 16px;
}

.dr-sec-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.dr-field {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 2px 10px;
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
}
.dr-field:last-child { border-bottom: none; }
.dr-label { color: var(--muted); }
.dr-val   { color: var(--text); word-break: break-word; }

.dr-notes {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.dr-mkt-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.dr-mkt {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.dr-mkt-on  { background: #e2f0d9; color: #1e5c1e; }
.dr-mkt-off { background: #f0f0f0; color: #b0b0b0; }

/* Clickable ID cells in drawer-enabled rows */
[data-drawer-type] .id-col {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
[data-drawer-type] .id-col:hover { color: var(--brand-dark); }

/* Clickable dl-id spans in deadline tracker */
[data-drawer-type] .dl-id {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
[data-drawer-type] .dl-id:hover { opacity: .75; }

/* ── LATAM Regulatory Hub ─────────────────────────────────────────────────── */

.latam-hub-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #1a3a5c 0%, #2d6a9f 60%, #4a9fd4 100%);
  color: #fff;
}
.latam-hub-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .3px;
}
.latam-hub-sub {
  font-size: 12px;
  opacity: .82;
  margin-top: 3px;
}

.mw-region-pills {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  background: #122845;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-wrap: wrap;
}
.mw-region-pill {
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.3);
  background: transparent;
  color: rgba(255,255,255,.75);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  letter-spacing: .3px;
}
.mw-region-pill:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-color: rgba(255,255,255,.55);
}
.mw-region-pill.active {
  background: #fff;
  color: #122845;
  border-color: #fff;
  font-weight: 700;
}

.latam-tier1-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff0f0;
  border-left: 4px solid #d93025;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #7b1a13;
}
.latam-tier1-icon { font-size: 16px; flex-shrink: 0; }

.latam-toolbar { flex-wrap: wrap; gap: 6px 10px; }
.latam-search-box {
  min-width: 220px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.latam-table { min-width: 900px; }
.latam-table .td-tier  { white-space: nowrap; }
.latam-table .td-company { min-width: 120px; }
.latam-table .td-reg   { font-size: 12px; color: var(--muted); white-space: nowrap; }
.latam-table .td-fn    { white-space: nowrap; }
.latam-table .td-date  { white-space: nowrap; color: var(--muted); font-size: 12px; }
.latam-table .td-link  { text-align: center; }
.latam-table .td-notes { text-align: center; }

.table-scroll { overflow-x: auto; }

.filing-num {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  background: #f4f4f8;
  border: 1px solid #d0d0e0;
  border-radius: 3px;
  padding: 1px 5px;
  color: #3a3a6a;
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tier-act   { background: #fff0f0; color: #c0392b; border: 1px solid #f5c6c2; }
.tier-watch { background: #fffbe6; color: #7d6608; border: 1px solid #f0d96e; }

.row-tier1 { background: #fff8f8 !important; }
.row-tier1:hover { background: #fff0f0 !important; }

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.status-active  { background: #e2f0d9; color: #1e5c1e; }
.status-pending { background: #fff4ce; color: #7a5700; }
.status-danger  { background: #fde7e9; color: #a4262c; }
.status-default { background: #f0f0f0; color: var(--muted); }

.src-link { font-size: 14px; text-decoration: none; }
.src-link:hover { opacity: .7; }

.notes-tip {
  cursor: help;
  font-size: 14px;
  opacity: .6;
}
.notes-tip:hover { opacity: 1; }

/* ── Chat language selector ───────────────────────────────────────────────── */

.chat-lang-ctrl {
  display: flex;
  gap: 2px;
  background: #f0f0f5;
  border-radius: 6px;
  padding: 2px;
  margin-left: 4px;
}
.lang-btn {
  padding: 3px 8px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: .4px;
  transition: background .15s, color .15s;
}
.lang-btn:hover { background: #dde; color: var(--text); }
.lang-btn.lang-active {
  background: var(--brand);
  color: #fff;
}
