:root {
  /* Brand & action (Techmellon: indigo accent, green primary action) */
  --brand: #6366f1;
  --brand-2: #4f46e5;
  --brand-soft: #eef0ff;
  --primary: #16a34a;
  --primary-2: #15803d;
  /* Neutrals — cool slate scale */
  --ink: #18191f;
  --ink-soft: #383a42;
  --muted: #65676f;
  --line: #e4e4e8;
  --bg: #fafafa;
  --card: #ffffff;
  --soft: #f2f2f4;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-card: 0 1px 2px rgba(16, 17, 20, .04), 0 10px 30px rgba(16, 17, 20, .04);
  /* Status */
  --match: #15803d;   --match-bg: #dcfce7;
  --exceeds: #166534; --exceeds-bg: #bbf7d0;
  --partial: #b45309; --partial-bg: #fef3c7;
  --different: #4338ca; --different-bg: #e0e7ff;
  --missing: #b91c1c; --missing-bg: #fee2e2;
  --unclear: #65676f; --unclear-bg: #edeef0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(circle at 96% 3%, rgba(249, 115, 22, .10) 0%, transparent 40%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 22px; color: #fff;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  border-radius: 13px;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.topbar p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.model-pill {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--soft); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px;
}

/* App shell: sidebar + main */
.app { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  width: 264px; flex: none;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 18px 14px;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; }
.sidebar-brand .logo { width: 38px; height: 38px; font-size: 18px; border-radius: 11px; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-brand-text strong { font-size: 15px; font-weight: 800; letter-spacing: -.2px; }
.sidebar-brand-text span { font-size: 11.5px; color: var(--muted); }

.new-comp {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin: 2px 0 12px;
  background: var(--brand); color: #fff; border: none;
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .28);
  transition: background .15s, transform .05s;
}
.new-comp:hover { background: var(--brand-2); }
.new-comp:active { transform: translateY(1px); }

.sidebar-section {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); padding: 8px 8px 6px;
}
.history { display: flex; flex-direction: column; gap: 2px; overflow: auto; flex: 1; min-height: 40px; }
.history-empty { color: var(--muted); font-size: 13px; padding: 8px; }
.history-item {
  display: block; text-decoration: none; color: var(--ink);
  padding: 8px 10px; border-radius: 10px;
  border-left: 3px solid transparent;
  transition: background .12s;
}
.history-item:hover { background: var(--soft); }
.history-item.active { background: var(--brand-soft); border-left-color: var(--brand); }
.hi-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sidebar-foot { padding: 12px 8px 2px; border-top: 1px solid var(--line); margin-top: 8px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav-item {
  display: block; text-decoration: none; color: var(--ink);
  padding: 9px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  transition: background .12s;
}
.side-nav-item:hover { background: var(--soft); }
.side-nav-item.active { background: var(--brand-soft); color: var(--brand-2); }

/* Past comparisons table */
.hist-row { cursor: pointer; transition: background .12s; }
.hist-row:hover { background: var(--brand-soft); }
.hist-title { font-weight: 600; }
.hist-date { color: var(--muted); white-space: nowrap; }
.hist-empty { padding: 28px; color: var(--muted); text-align: center; }

main { flex: 1; min-width: 0; padding: 28px 32px; }

.setup {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-card);
}
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.drop {
  border: 1.5px dashed #d0d1d6;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.drop.dragover { border-color: var(--brand); background: var(--brand-soft); }
.drop.filled { border-style: solid; border-color: #bbf7d0; background: #f4fbf6; }
.drop-icon {
  width: 30px; height: 30px; margin: 0 auto 10px;
  background: var(--brand); color: #fff; border-radius: 9px;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  box-shadow: 0 4px 10px rgba(99, 102, 241, .3);
}
.drop h3 { margin: 4px 0; font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0; }

.filebtn {
  display: inline-block; margin-top: 12px;
  background: var(--brand); color: #fff;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s;
}
.filebtn input { display: none; }
.filebtn:hover { background: var(--brand-2); }
.filebtn:active { transform: translateY(1px); }

.filelist { margin-top: 12px; text-align: left; }
.filechip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 13px; font-weight: 500;
  background: var(--soft); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 11px; margin-top: 7px;
}
.filechip button {
  border: none; background: none; color: var(--missing);
  cursor: pointer; font-size: 16px; line-height: 1;
}

.actions {
  margin-top: 22px;
  display: flex; align-items: center; gap: 16px;
}
.hint { color: var(--muted); font-size: 13px; }

button.primary {
  background: var(--primary); color: #fff; border: none;
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(22, 163, 74, .25);
  transition: background .15s, transform .05s, box-shadow .15s;
}
button.primary:disabled { background: #c4cbd4; box-shadow: none; cursor: not-allowed; }
button.primary:not(:disabled):hover { background: var(--primary-2); }
button.primary:not(:disabled):active { transform: translateY(1px); }

button.ghost {
  background: #fff; color: var(--ink);
  border: 1px solid #d0d1d6; border-radius: var(--radius-sm);
  padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
button.ghost:hover { background: var(--soft); border-color: #b9bbc2; }

.status {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-top: 22px;
  box-shadow: var(--shadow-card);
}
.spinner {
  width: 34px; height: 34px;
  border: 4px solid #e4e4e8; border-top-color: var(--brand);
  border-radius: 50%; animation: spin .9s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  background: var(--missing-bg); color: var(--missing);
  border: 1px solid #f6c6c0; border-radius: 12px;
  padding: 16px 18px; margin-top: 22px; font-size: 14px; font-weight: 500;
}

.results { margin-top: 8px; }
.results-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin: 8px 0 16px;
}
.results-head h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.results-actions { display: flex; gap: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px;
  border-radius: 999px;
}
.badge.match { background: var(--match-bg); color: var(--match); }
.badge.exceeds { background: var(--exceeds-bg); color: var(--exceeds); }
.badge.partial { background: var(--partial-bg); color: var(--partial); }
.badge.different { background: var(--different-bg); color: var(--different); }
.badge.missing { background: var(--missing-bg); color: var(--missing); }
.badge.unclear { background: var(--unclear-bg); color: var(--unclear); }

.summary-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.scard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.scard h4 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.scard .sub { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.scard.err { border-color: #f6c6c0; background: var(--missing-bg); }
.bar { display: flex; height: 9px; border-radius: 999px; overflow: hidden; background: var(--soft); }
.bar span { display: block; height: 100%; }
.bar .s-match { background: var(--match); }
.bar .s-exceeds { background: var(--exceeds); }
.bar .s-partial { background: var(--partial); }
.bar .s-different { background: var(--different); }
.bar .s-missing { background: var(--missing); }
.bar .s-unclear { background: #c4cad6; }
.counts { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; font-size: 12px; }
.counts span b { font-variant-numeric: tabular-nums; }

.table-wrap {
  overflow: auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card);
  max-height: 72vh;
  box-shadow: var(--shadow-card);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--soft); color: var(--ink);
  text-align: left; padding: 12px 13px; font-weight: 700;
  vertical-align: bottom; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th small { color: var(--muted); font-weight: 500; }
thead th.sticky-l, tbody td.sticky-l {
  position: sticky; left: 0; z-index: 1;
}
thead th.sticky-l { z-index: 3; }
tbody td.sticky-l { background: var(--card); }
.cat-row td {
  background: var(--brand-soft); font-weight: 700; color: var(--brand-2);
  padding: 9px 13px; position: sticky; left: 0;
  letter-spacing: .2px;
}
tbody td {
  border-top: 1px solid var(--line);
  padding: 11px 13px; vertical-align: top;
}
.benefit { font-weight: 600; min-width: 220px; }
.benefit .note { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 3px; }
.req { min-width: 180px; color: var(--ink-soft); }
.cell { min-width: 220px; }
.cell .val { font-weight: 600; }
.cell .cmt { color: var(--muted); font-size: 12px; margin-top: 4px; }
.cell .ev { color: #9498a1; font-size: 11px; margin-top: 4px; font-style: italic; }
.cell .badge { margin-top: 5px; display: inline-block; }
td.c-match { background: var(--match-bg); }
td.c-exceeds { background: var(--exceeds-bg); }
td.c-partial { background: var(--partial-bg); }
td.c-different { background: var(--different-bg); }
td.c-missing { background: var(--missing-bg); }
td.c-unclear { background: var(--unclear-bg); }

/* Cost comparison (separate algorithm, after the benefits table) */
.cost-section { margin-top: 34px; }
.cost-head { margin-bottom: 14px; }
.section-title {
  margin: 0 0 4px; font-size: 19px; font-weight: 800; letter-spacing: -.3px;
  display: flex; align-items: center; gap: 8px;
}

.cost-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.ccard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow-card);
  position: relative;
}
.ccard.cheapest { border-color: #86efac; box-shadow: 0 0 0 2px #bbf7d0, var(--shadow-card); background: #f4fbf6; }
.ccard.err { border-color: #f6c6c0; background: var(--missing-bg); }
.ccard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ccard h4 { margin: 0; font-size: 15px; font-weight: 700; }
.rank-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--soft); color: var(--muted); white-space: nowrap;
}
.rank-badge.best { background: var(--match-bg); color: var(--match); }
.cgross { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin-top: 10px; color: var(--ink); font-variant-numeric: tabular-nums; }
.cgross-lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 1px; }
.cdelta { font-size: 12.5px; font-weight: 700; color: var(--missing); margin-top: 8px; }
.ccard.cheapest .cgross { color: var(--match); }
.cmeta { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
.cmeta b { font-variant-numeric: tabular-nums; }
.cnotes { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.45; border-top: 1px solid var(--line); padding-top: 8px; }
.ccard .sub.err-text { font-size: 12px; color: var(--missing); margin-top: 8px; }

/* Cost table */
#costTable .cost-label { font-weight: 600; min-width: 220px; color: var(--ink); }
#costTable td.cost-cell {
  font-variant-numeric: tabular-nums; min-width: 150px; white-space: nowrap;
}
#costTable .cval { font-weight: 600; }
#costTable tr.headline-row td { background: #f8fafc; font-size: 14px; }
#costTable tr.headline-row .cost-label,
#costTable tr.headline-row .cval { font-weight: 800; }
#costTable td.best-cost { background: var(--match-bg); }
#costTable td.best-cost .cval { color: var(--match); font-weight: 800; }
.best-tag { color: var(--match); font-weight: 800; }
.derived-tag, .th-best {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); background: var(--soft); padding: 1px 6px; border-radius: 6px;
  vertical-align: middle;
}
.th-best { color: var(--match); background: var(--match-bg); }
#costTable td.cost-cell.clickable { cursor: pointer; transition: box-shadow .12s, filter .12s; }
#costTable td.cost-cell.clickable:hover { box-shadow: inset 0 0 0 2px var(--brand); filter: brightness(.99); }
#costTable .src-cue { margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--brand); opacity: .8; }

/* Single-document mode for the source viewer (cost cells) */
.modal-panes.solo { grid-template-columns: 1fr; }
.modal-panes.solo .pane:last-child { display: none; }

/* Banners */
.banner {
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
  font-size: 13px; line-height: 1.45; font-weight: 500;
}
.banner.warn { background: #fff7ed; border: 1px solid #fed7aa; color: #b45309; }

.table-hint { margin: 0 0 12px; }

/* Clickable comparison cells */
td.cell.clickable { cursor: pointer; transition: filter .12s, box-shadow .12s; }
td.cell.clickable:hover { filter: brightness(0.98); box-shadow: inset 0 0 0 2px var(--brand); }
.cell .src-cue {
  display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 600;
  color: var(--brand); opacity: .85;
}
td.cell.noloc { cursor: default; }

/* Source viewer modal */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 17, 20, .5);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-box {
  background: #fff; border-radius: 18px;
  width: min(1280px, 96vw); height: min(88vh, 900px);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 30px 70px rgba(16, 17, 20, .45);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.modal-title strong { font-size: 16px; font-weight: 700; }
.modal-sub { color: var(--muted); font-size: 13px; margin-left: 10px; }
.modal-panes { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0; min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.pane:last-child { border-right: none; }
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--soft); border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 13px;
}
.pane-page { color: var(--muted); font-weight: 500; }
.pane-body {
  flex: 1; overflow: auto; background: #8e9099;
  padding: 16px; display: flex; justify-content: center;
}
.pdfpage { position: relative; box-shadow: 0 2px 12px rgba(0, 0, 0, .3); background: #fff; height: max-content; }
.pdf-hl {
  position: absolute; background: rgba(255, 214, 0, .38);
  outline: 2px solid rgba(214, 158, 0, .9); border-radius: 2px;
  pointer-events: none; mix-blend-mode: multiply;
}
.pane-notice {
  margin: auto; max-width: 280px; text-align: center;
  color: #fff; font-size: 13px; line-height: 1.5;
}
.pane-spinner {
  margin: auto; width: 28px; height: 28px;
  border: 4px solid rgba(255, 255, 255, .3); border-top-color: #fff;
  border-radius: 50%; animation: spin .9s linear infinite;
}
.loc-fuzzy { font-size: 11px; color: #ffe7b3; }

/* Home hero (empty state) */
.hero { display: grid; place-items: center; padding: 44px 24px; }
.hero-card { text-align: center; max-width: 460px; }
.hero-icon {
  width: 60px; height: 60px; margin: 0 auto 18px; border-radius: 17px;
  display: grid; place-items: center; font-size: 26px; color: #fff;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  box-shadow: 0 10px 24px rgba(99, 102, 241, .35);
}
.hero-card h2 { margin: 0 0 8px; font-size: 24px; font-weight: 800; letter-spacing: -.4px; }
.hero-card p { margin: 0 0 22px; }
button.primary.lg {
  padding: 14px 28px; font-size: 16px;
  background: var(--brand); box-shadow: 0 6px 16px rgba(99, 102, 241, .3);
}
button.primary.lg:hover { background: var(--brand-2); }

/* New-comparison wizard */
.wiz-box {
  background: #fff; border-radius: 20px; width: min(620px, 94vw);
  box-shadow: 0 30px 70px rgba(16, 17, 20, .45);
  padding: 20px 24px 24px; max-height: 92vh; overflow: auto;
}
.wiz-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.wiz-steps { display: flex; align-items: center; gap: 10px; }
.wiz-dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--muted);
  background: var(--soft); border: 1px solid var(--line);
  transition: background .15s, color .15s, border-color .15s;
}
.wiz-dot.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.wiz-bar { width: 44px; height: 3px; border-radius: 2px; background: var(--line); }
.iconbtn {
  border: none; background: none; font-size: 16px; color: var(--muted);
  cursor: pointer; line-height: 1; padding: 6px 9px; border-radius: 8px;
}
.iconbtn:hover { background: var(--soft); color: var(--ink); }
.wiz-title { margin: 4px 0 4px; font-size: 18px; font-weight: 800; }
.wiz-sub { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.wiz-drop { padding: 34px 22px; }
.drop-emoji { font-size: 32px; margin-bottom: 6px; }
.drop-main { font-weight: 700; font-size: 15px; margin: 4px 0 2px; }
.wiz-foot { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.wiz-foot .hint { flex: 1; }

/* Utility: must win over any component that sets its own display (e.g. .chat-panel,
   .chat-fab, .extra-status are defined later and set display:flex). */
.hidden { display: none !important; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .history { max-height: 200px; }
  main { padding: 20px; }
}

@media (max-width: 720px) {
  .upload-grid { grid-template-columns: 1fr; }
  .results-head { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* Extra benefits section (offered but not in the broker slip) */
.extra-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.extra-actions { display: flex; gap: 8px; flex: none; }
.extra-status {
  display: flex; align-items: center; gap: 10px; color: var(--muted);
  font-size: 13.5px; font-weight: 600; margin: 6px 0 14px;
}
.spinner.sm { width: 20px; height: 20px; border-width: 3px; }
.extra-empty {
  background: var(--soft); border: 1px dashed var(--line); border-radius: 12px;
  padding: 16px; color: var(--muted); font-size: 13.5px; margin-bottom: 12px;
}
#extraTable td.extra-cell { min-width: 150px; vertical-align: top; }
#extraTable td.extra-cell.offered { background: #f1f9f0; }
#extraTable td.extra-cell.offered .cval { color: var(--match); font-weight: 700; }
#extraTable td.extra-cell.absent { color: #b8bcc4; }
#extraTable td.extra-cell .cmt { color: var(--muted); font-size: 12px; margin-top: 4px; }
#extraTable td.extra-cell.clickable { cursor: pointer; transition: box-shadow .12s; }
#extraTable td.extra-cell.clickable:hover { box-shadow: inset 0 0 0 2px var(--brand); }

/* Broker assistant: floating button */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 45;
  display: flex; align-items: center; gap: 9px;
  padding: 13px 20px 13px 16px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff;
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 26px rgba(99, 102, 241, .45);
  transition: transform .12s, box-shadow .12s;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(99, 102, 241, .5); }
.chat-fab-icon { font-size: 18px; line-height: 1; }

/* Broker assistant: non-blocking side drawer (no page backdrop) */
.chat-panel {
  position: fixed; top: 16px; right: 16px; bottom: 16px; z-index: 46;
  width: min(420px, calc(100vw - 32px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(16, 17, 20, .3);
  animation: chatIn .18s ease-out;
}
@keyframes chatIn { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }
.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(139,92,246,.05));
}
.chat-head-text strong { font-size: 15px; font-weight: 800; display: block; }
.chat-sub { font-size: 11.5px; color: var(--muted); }

.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-welcome { text-align: center; margin: auto 0; color: var(--ink-soft); }
.chat-welcome-icon { font-size: 30px; margin-bottom: 10px; }
.chat-welcome p { font-size: 13.5px; line-height: 1.5; margin: 6px 12px; }
.chat-welcome code, .chat-sub code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

.chat-msg {
  max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5;
  word-wrap: break-word; white-space: normal;
}
.chat-msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: var(--soft); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-msg.note { align-self: flex-start; background: var(--brand-soft); color: var(--brand-2); font-weight: 600; }
.chat-msg p { margin: 0 0 8px; } .chat-msg p:last-child { margin-bottom: 0; }
.chat-msg ul, .chat-msg ol { margin: 6px 0; padding-left: 20px; }
.chat-msg code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.chat-msg.user code { background: rgba(255,255,255,.2); }
.chat-msg table { border-collapse: collapse; width: 100%; font-size: 12px; margin: 6px 0; }
.chat-msg th, .chat-msg td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.chat-msg th { background: rgba(0,0,0,.04); font-weight: 700; }
.chat-link { color: var(--brand-2); font-weight: 700; text-decoration: none; }
.chat-link:hover { text-decoration: underline; }
.chat-err { color: var(--missing); }
.chat-spin {
  display: inline-block; width: 12px; height: 12px; vertical-align: -1px;
  border: 2px solid rgba(99,102,241,.3); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
}

.chat-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 6px; }
.chat-chip {
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  background: var(--card); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px;
  transition: background .12s, border-color .12s;
}
.chat-chip:hover { background: var(--soft); border-color: #c7c9d0; }
.chat-chip.cmd { color: var(--brand-2); border-color: #c7d2fe; background: var(--brand-soft); font-family: ui-monospace, Menlo, monospace; }

.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-family: inherit; font-size: 13.5px; line-height: 1.4;
  max-height: 140px; outline: none; transition: border-color .12s;
}
.chat-input textarea:focus { border-color: var(--brand); }
.chat-send {
  flex: none; width: 40px; height: 40px; border: none; border-radius: 11px;
  background: var(--brand); color: #fff; font-size: 16px; cursor: pointer;
  transition: background .12s;
}
.chat-send:hover { background: var(--brand-2); }
.chat-send:disabled { background: #c4cbd4; cursor: default; }

@media (max-width: 560px) {
  .chat-panel { top: 0; right: 0; bottom: 0; left: 0; width: 100vw; border-radius: 0; }
  .chat-fab-label { display: none; }
}

/* Presentation generator modal */
button.ghost.accent { border-color: #c7d2fe; color: var(--brand-2); background: var(--brand-soft); }
button.ghost.accent:hover { background: #e0e7ff; border-color: var(--brand); }
.pres-box { width: min(560px, 94vw); }
.pres-drop { padding: 26px 22px; margin-top: 8px; }
.pres-status { display: flex; align-items: center; gap: 16px; padding: 28px 8px; }
.pres-done { text-align: center; padding: 8px 4px 4px; }
.pres-done-head { font-size: 17px; font-weight: 800; color: var(--match); margin-bottom: 14px; }
.pres-done .primary.lg { background: var(--brand); }
.pres-done .primary.lg:hover { background: var(--brand-2); }
.pres-edit { text-align: left; margin-top: 6px; }
.pres-edit .wiz-sub { text-align: left; }
.pres-edit-log { display: flex; flex-direction: column; gap: 10px; max-height: 220px; overflow-y: auto; margin-bottom: 10px; }
.pres-edit-item { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.pe-user { font-weight: 600; font-size: 13.5px; }
.pe-status { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.pres-edit .chat-input { padding: 0; border: none; }

/* Auth gate */
.auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 20% 10%, rgba(99,102,241,.18), transparent 45%),
              radial-gradient(circle at 90% 90%, rgba(139,92,246,.16), transparent 45%), var(--bg);
}
.auth-card {
  width: min(400px, 94vw); background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 30px 28px; box-shadow: 0 30px 70px rgba(16,17,20,.18);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand .logo { width: 36px; height: 36px; font-size: 17px; border-radius: 10px; }
.auth-brand strong { font-size: 16px; font-weight: 800; }
.auth-view h2 { margin: 0 0 16px; font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.auth-view input {
  width: 100%; margin-bottom: 11px; padding: 12px 14px; font-family: inherit; font-size: 14.5px;
  border: 1px solid var(--line); border-radius: 11px; outline: none; transition: border-color .12s;
}
.auth-view input:focus { border-color: var(--brand); }
button.primary.full { width: 100%; margin-top: 4px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.auth-links a { color: var(--brand-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.auth-links a:hover { text-decoration: underline; }
.auth-err { background: var(--missing-bg); color: var(--missing); border-radius: 10px;
  padding: 10px 12px; font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.auth-msg { background: var(--brand-soft); color: var(--brand-2); border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px; word-break: break-all; }
.auth-msg a { color: var(--brand-2); }

/* Sidebar account block */
.sidebar-account { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--line); }
.acct-id { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; }
.acct-avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff; font-weight: 800; font-size: 15px;
}
.acct-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.acct-meta strong { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-meta span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-actions { display: flex; gap: 6px; }
.acct-link {
  flex: 1; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  background: var(--soft); border: 1px solid var(--line); color: var(--ink); border-radius: 9px; padding: 8px 6px;
  transition: background .12s;
}
.acct-link:hover { background: var(--brand-soft); border-color: #c7d2fe; }

/* 2FA modal */
#twofaModal input { width: 100%; margin: 6px 0 10px; padding: 11px 13px; font-family: inherit;
  font-size: 14px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
#twofaModal input:focus { border-color: var(--brand); }
.twofa-qr { display: flex; justify-content: center; padding: 6px 0 12px; }
.twofa-qr img, .twofa-qr canvas { border: 1px solid var(--line); border-radius: 8px; }
.twofa-secret { font-family: ui-monospace, Menlo, monospace; font-size: 13px; text-align: center;
  background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 9px;
  margin-bottom: 12px; word-break: break-all; letter-spacing: 1px; }

/* Document diff tool */
.diff-step { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.diff-step .ghost { padding: 7px 11px; }
.diff-step #diffPos { font-size: 13px; font-weight: 700; min-width: 54px; text-align: center;
  font-variant-numeric: tabular-nums; }
.diff-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.dstat { font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: var(--soft); }
.dstat.total { background: var(--brand-soft); color: var(--brand-2); }
.dstat.changed { background: var(--partial-bg); color: var(--partial); }
.dstat.added { background: var(--match-bg); color: var(--match); }
.dstat.removed { background: var(--missing-bg); color: var(--missing); }

.diff-layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
.diff-list {
  max-height: 78vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow-card);
}
.diff-empty { color: var(--match); font-weight: 600; font-size: 13.5px; padding: 14px; text-align: center; }
.diff-item { border: 1px solid var(--line); border-radius: 11px; padding: 9px 11px; cursor: pointer;
  transition: box-shadow .12s, border-color .12s; border-left-width: 4px; }
.diff-item:hover { box-shadow: inset 0 0 0 1px var(--brand); }
.diff-item.active { box-shadow: 0 0 0 2px var(--brand); border-color: var(--brand); }
.diff-item.dt-added { border-left-color: var(--match); }
.diff-item.dt-removed { border-left-color: var(--missing); }
.diff-item.dt-changed { border-left-color: var(--partial); }
.di-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.di-chip { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.di-chip.added { background: var(--match-bg); color: var(--match); }
.di-chip.removed { background: var(--missing-bg); color: var(--missing); }
.di-chip.changed { background: var(--partial-bg); color: var(--partial); }
.di-loc { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.di-line { font-size: 12px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.di-a { color: var(--missing); } .di-b { color: var(--match); }

.diff-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff-pane { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--card); box-shadow: var(--shadow-card); }
.diff-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; background: var(--soft); border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.dp-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diff-pagenav { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.diff-pagenav button { border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer;
  width: 26px; height: 26px; font-size: 14px; line-height: 1; }
.diff-pagenav button:hover { background: var(--brand-soft); }
.diff-pagenav span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 52px; text-align: center; }
.diff-pane-body { height: 76vh; overflow: auto; background: #8e9099; padding: 14px; display: flex; justify-content: center; }
.diff-hl { position: absolute; border-radius: 2px; pointer-events: none; mix-blend-mode: multiply; }
.diff-hl.dh-changed { background: rgba(245, 200, 66, .40); outline: 2px solid rgba(214, 158, 0, .85); }
.diff-hl.dh-added { background: rgba(34, 197, 94, .32); outline: 2px solid rgba(21, 128, 61, .85); }
.diff-hl.dh-removed { background: rgba(239, 68, 68, .30); outline: 2px solid rgba(185, 28, 28, .85); }

@media (max-width: 1100px) {
  .diff-layout { grid-template-columns: 1fr; }
  .diff-list { max-height: 240px; }
}

/* Document diff — full-page (maximized) mode */
body.diff-maxed { overflow: hidden; }
#diffResults.maximized {
  position: fixed; inset: 0; z-index: 80; margin: 0;
  background: var(--bg); padding: 14px 20px; overflow: auto;
}
#diffResults.maximized .diff-stats { margin-bottom: 10px; }
#diffResults.maximized .diff-pane-body { height: calc(100vh - 150px); }
#diffResults.maximized .diff-list { max-height: calc(100vh - 150px); }
@media (max-width: 1100px) {
  #diffResults.maximized .diff-list { max-height: 200px; }
  #diffResults.maximized .diff-pane-body { height: calc(100vh - 360px); }
}

/* Document-diff history table on the diff setup page */
.diff-history { margin-top: 30px; }
.diff-history .section-title { font-size: 16px; }
.diff-history .muted { margin-bottom: 12px; }

/* Collapsible sidebar */
.app { overflow-x: clip; }
.sidebar { transition: margin-left .24s ease; }
main { transition: padding-left .24s ease; }
.sb-toggle {
  margin-left: auto; flex: none; border: none; background: var(--soft); color: var(--muted);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 20px; line-height: 1;
  display: grid; place-items: center; transition: background .12s, color .12s;
}
.sb-toggle:hover { background: var(--brand-soft); color: var(--brand-2); }
.sb-open {
  position: fixed; top: 14px; left: 14px; z-index: 60;
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 10px; cursor: pointer; font-size: 18px;
  box-shadow: var(--shadow-card); transition: background .12s;
}
.sb-open:hover { background: var(--soft); }

body.sb-collapsed .sidebar { margin-left: -264px; }
body.sb-collapsed .sb-open { display: flex; }
body.sb-collapsed main { padding-left: 64px; }

@media (max-width: 860px) {
  /* On narrow screens the sidebar stacks on top; collapsing just hides it. */
  body.sb-collapsed .sidebar { display: none; margin-left: 0; }
  body.sb-collapsed main { padding-left: 20px; }
}

/* === Sidebar refresh (2026) ============================================== */
.sidebar {
  padding: 16px 12px 14px;
  background: linear-gradient(180deg, rgba(99,102,241,.05), rgba(255,255,255,.72) 22%);
}
.sidebar-brand { position: relative; align-items: center; gap: 12px; padding: 6px 6px 16px; }
.sidebar-brand .logo {
  width: 40px; height: 40px; font-size: 18px; border-radius: 12px;
  box-shadow: 0 6px 16px rgba(99,102,241,.34);
}
.sidebar-brand-text { flex: 1; min-width: 0; }
.sidebar-brand-text strong { font-size: 15px; font-weight: 800; letter-spacing: -.3px; white-space: nowrap; }
.sidebar-brand-text span { font-size: 11px; }
.sb-toggle {
  position: absolute; top: 2px; right: 2px; margin: 0;
  width: 26px; height: 26px; background: transparent; color: var(--muted); font-size: 18px;
}
.sb-toggle:hover { background: var(--soft); }

.new-comp {
  gap: 8px; padding: 12px 14px; border-radius: 13px; font-size: 14px; letter-spacing: -.1px;
  background: linear-gradient(135deg, var(--brand), #7c6cf3);
  box-shadow: 0 6px 18px rgba(99,102,241,.32);
}
.new-comp:hover { background: linear-gradient(135deg, var(--brand-2), #6d5cf0); }
.new-comp .nav-ic { width: 17px; height: 17px; }

.side-section-label {
  font-size: 10.5px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  color: #9aa0ad; padding: 16px 10px 7px;
}
.side-nav { gap: 3px; }
.side-nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: 11px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-soft); position: relative; transition: background .14s, color .14s;
}
.side-nav-item .nav-ic { width: 18px; height: 18px; flex: none; color: #8b90a0; transition: color .14s; }
.side-nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav-item:hover { background: var(--soft); }
.side-nav-item.active { background: var(--brand-soft); color: var(--brand-2); }
.side-nav-item.active .nav-ic { color: var(--brand); }
.side-nav-item.active::before {
  content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 2px; background: var(--brand);
}

/* Account card */
.sidebar-account {
  margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); box-shadow: 0 1px 2px rgba(16,17,20,.03);
}
.acct-id { padding: 0 2px 11px; }
.acct-avatar { box-shadow: 0 4px 10px rgba(99,102,241,.3); }
.acct-actions { gap: 7px; }
.acct-link {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--soft); border: 1px solid transparent; border-radius: 10px; padding: 8px 6px;
}
.acct-link svg { width: 15px; height: 15px; flex: none; }
.acct-link:hover { background: var(--brand-soft); border-color: #d6dbfb; color: var(--brand-2); }
#logoutBtn:hover { background: var(--missing-bg); border-color: #f4c9c4; color: var(--missing); }

/* === Clickable status capsules → filter the benefits table ============== */
.legend .lbadge, .scard .cbadge { cursor: pointer; transition: filter .12s, box-shadow .12s, transform .05s; user-select: none; }
.legend .lbadge:hover, .scard .cbadge:not(.zero):hover { filter: brightness(.96); }
.legend .lbadge:active, .scard .cbadge:not(.zero):active { transform: translateY(1px); }
.scard .cbadge.zero { cursor: default; opacity: .5; }
.legend .lbadge.active, .scard .cbadge.active {
  outline: 2px solid currentColor; outline-offset: 1px; box-shadow: 0 2px 8px rgba(16,17,20,.12);
}
/* Dim the cells that don't match the active filter, in the visible rows */
#comparisonTable td.cell.flt-dim { opacity: .32; }
#comparisonTable td.cell.flt-dim:hover { opacity: .55; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--brand-2);
  background: var(--brand-soft); border: 1px solid #d6dbfb;
  padding: 4px 11px; border-radius: 999px; margin-left: 4px;
}
.filter-chip .fx { color: var(--muted); font-weight: 700; }
.filter-chip:hover { background: #e0e7ff; }
.filter-chip:hover .fx { color: var(--missing); }

/* === Results header toolbar: keep buttons on one line, wrap as a group ==== */
.results-head { flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.results-head > div:first-child { flex: 1 1 300px; min-width: 0; }
.results-actions { flex-wrap: wrap; gap: 8px; align-items: center; }
.results-actions button { white-space: nowrap; flex: none; }
/* Uniform, compact toolbar buttons */
.results-actions button.ghost {
  padding: 9px 14px; font-size: 13.5px; line-height: 1.15; border-radius: 10px;
  display: inline-flex; align-items: center; gap: 6px;
}

/* === Benefits table search ============================================== */
.table-toolbar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.search-box {
  position: relative; display: flex; align-items: center;
  width: min(360px, 100%);
}
.search-box .search-ic {
  position: absolute; left: 12px; width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}
.search-box input {
  width: 100%; padding: 10px 14px 10px 36px; font-family: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--card); color: var(--ink);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.search-box input::placeholder { color: #9aa0ad; }
.table-empty {
  background: var(--soft); border: 1px dashed var(--line); border-radius: 12px;
  padding: 16px; text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 14px;
}

/* ── Cost analysis tab ───────────────────────────────────────────────────── */
.cost-hero .hero-icon { background: linear-gradient(135deg, #16a34a, #0d9488); box-shadow: 0 10px 24px rgba(13, 148, 136, .32); }

/* Cards: primary / dependents breakdown under the headline gross total */
.ccard .cbreak { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.ccard .cbreak > div { font-size: 12.5px; color: var(--ink-soft); }
.ccard .cbreak b { font-variant-numeric: tabular-nums; }
.resolution-tag {
  display: inline-block; margin-top: 10px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; padding: 2px 8px; border-radius: 6px;
  background: var(--soft); color: var(--muted);
}
.resolution-tag.calc { background: var(--partial-bg); color: var(--partial); }
.resolution-tag.direct { background: var(--match-bg); color: var(--match); }
.calc-notes { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.5;
  border-top: 1px solid var(--line); padding-top: 8px; }
.calc-notes .warn { color: var(--partial); display: block; }
.cplanb { font-size: 12px; color: var(--brand-2); margin-top: 8px; font-weight: 600; }
.cplanb b { font-variant-numeric: tabular-nums; }

/* Cost analysis comparison table (Σύνολα) — reuse #costTable styling */
#costAnalysisTable .cost-label { font-weight: 600; min-width: 240px; color: var(--ink); }
#costAnalysisTable td.cost-cell { font-variant-numeric: tabular-nums; min-width: 150px; white-space: nowrap; }
#costAnalysisTable .cval { font-weight: 600; }
#costAnalysisTable tr.headline-row td { background: #f8fafc; font-size: 14px; }
#costAnalysisTable tr.headline-row .cost-label, #costAnalysisTable tr.headline-row .cval { font-weight: 800; }
#costAnalysisTable td.best-cost { background: var(--match-bg); }
#costAnalysisTable td.best-cost .cval { color: var(--match); font-weight: 800; }
#costAnalysisTable td.cost-cell.clickable { cursor: pointer; transition: box-shadow .12s; }
#costAnalysisTable td.cost-cell.clickable:hover { box-shadow: inset 0 0 0 2px var(--brand); }
#costAnalysisTable .src-cue { margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--brand); opacity: .8; }

/* Per-category detail (one block per insurer, below the totals table) */
#costCategoryDetail { margin-top: 26px; }
.catdet-title { font-size: 16px; font-weight: 800; letter-spacing: -.2px; margin: 0 0 12px; }
.catdet-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-card); padding: 14px 16px; margin-bottom: 14px; }
.catdet-card h4 { margin: 0 0 10px; font-size: 14.5px; font-weight: 700; }
.catdet-card table { font-size: 12.5px; }
.catdet-card thead th { background: var(--soft); position: static; }
.catdet-card td, .catdet-card th { padding: 8px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
.catdet-card td.num { font-variant-numeric: tabular-nums; text-align: right; }
.catdet-card td.cat-name { font-weight: 600; }
.catdet-card td.clickable { cursor: pointer; }
.catdet-card td.clickable:hover { box-shadow: inset 0 0 0 2px var(--brand); }

/* Calculation derivation popup + cue */
.calc-box {
  background: #fff; border-radius: 18px; width: min(620px, 94vw); max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 30px 70px rgba(16, 17, 20, .45);
}
.calc-body { padding: 18px 20px; overflow-y: auto; }
.calc-resolution {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: 3px 10px; border-radius: 7px;
  background: var(--partial-bg); color: var(--partial); margin-bottom: 14px;
}
.calc-formula {
  background: var(--soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin: 0 0 10px; font-size: 13.5px; line-height: 1.6;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.calc-formula b { color: var(--match); }
.calc-warning {
  background: #fff7ed; border: 1px solid #fed7aa; color: #b45309;
  border-radius: 10px; padding: 10px 14px; margin: 0 0 10px; font-size: 13px; line-height: 1.5;
}
.calc-foot { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 12px 0 0;
  border-top: 1px solid var(--line); padding-top: 10px; }

/* "ƒ" derivation cue on calculated cells */
.calc-cue { margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--partial); opacity: .9; }
#costAnalysisTable td.cost-cell.calc-clickable { cursor: pointer; transition: box-shadow .12s; }
#costAnalysisTable td.cost-cell.calc-clickable:hover { box-shadow: inset 0 0 0 2px var(--partial); }

/* Dual-plan (proposed plan) comparison row */
#costAnalysisTable tr.planb-row td { background: #faf5ff; }
#costAnalysisTable tr.planb-row .cost-label { color: var(--different); font-weight: 700; }

/* Dual-plan card line */
.cplanb { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.cplanb .cplanb-delta { color: var(--muted); font-weight: 600; font-size: 11.5px; }

/* Plan switcher (dual-plan documents) */
.plan-toggle { display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 18px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 12px; }
.plan-tab {
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  border: none; background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 9px; transition: background .12s, color .12s;
}
.plan-tab:hover { color: var(--ink); }
.plan-tab.active { background: var(--card); color: var(--brand-2);
  box-shadow: 0 1px 3px rgba(16,17,20,.12); }

/* Card for an insurer that has no equivalent of the selected plan */
.ccard.absent { background: var(--soft); border-style: dashed; }
.ccard.absent h4 { color: var(--muted); }

/* ── Results tab bar (Παροχές | Κόστος) ──────────────────────────────────── */
.result-tabs { display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 18px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 12px; }
.rtab { font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  border: none; background: transparent; color: var(--muted);
  padding: 9px 20px; border-radius: 9px; transition: background .12s, color .12s; }
.rtab:hover { color: var(--ink); }
.rtab.active { background: var(--card); color: var(--brand-2); box-shadow: 0 1px 3px rgba(16,17,20,.12); }

/* ── Cost reference table (structure from CostTable.html, this app's styling) ─ */
.cost-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 14px; }

#costRefTable { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
#costRefTable thead th { position: sticky; top: 0; z-index: 2; background: var(--soft);
  text-align: right; padding: 13px 14px; font-weight: 700; border-bottom: 1px solid var(--line);
  white-space: nowrap; vertical-align: bottom; }
#costRefTable th.row-h { text-align: left; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; }
#costRefTable th.row-h, #costRefTable td.rowlabel { position: sticky; left: 0; z-index: 1; background: var(--card); }
#costRefTable thead th.row-h { z-index: 3; }
#costRefTable th.win, #costRefTable td.win { background: var(--match-bg); }
#costRefTable thead th.win { color: var(--match); }
.th-best { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--match); background: #fff; padding: 1px 6px; border-radius: 6px; }
.muted-mini { font-size: 10px; color: var(--muted); font-weight: 600; }

#costRefTable td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
#costRefTable td.rowlabel { text-align: left; color: var(--ink); font-weight: 600; border-right: 1px solid var(--line); }
#costRefTable td.rowlabel.indent { padding-left: 28px; color: var(--ink-soft); font-weight: 400; }
#costRefTable tr:hover td { background: #fbfcfb; }
#costRefTable tr:hover td.win { background: #d6f3df; }

#costRefTable tr.band td { background: var(--brand-soft); color: var(--brand-2); font-weight: 700;
  font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; padding: 9px 14px;
  position: sticky; left: 0; text-align: left; }
#costRefTable tr.band.alt td { background: #eef2f6; color: var(--ink-soft); }

#costRefTable tr.subtotal td { font-weight: 800; border-top: 1px solid var(--line-strong, #cdd6d2); }
#costRefTable tr.subtotal td.win { color: var(--match); }
#costRefTable tr.grandtotal td { font-weight: 800; font-size: 14px; background: #f8fafc;
  border-top: 2px solid var(--ink); border-bottom: 2px solid var(--line); }
#costRefTable tr.grandtotal td.win { background: var(--match-bg); color: var(--match); }

#costRefTable tr.diff td { font-size: 12.5px; color: var(--muted); padding: 9px 14px; }
#costRefTable tr.diff td.rowlabel { font-style: italic; color: var(--muted); font-weight: 500; }
#costRefTable tr.diff .up { color: var(--partial); font-weight: 700; }
#costRefTable tr.diff .pct { font-weight: 700; color: var(--ink); }
#costRefTable tr.diff .tag { font-weight: 700; color: var(--match); }

#costRefTable td.clickable { cursor: pointer; transition: box-shadow .12s; }
#costRefTable td.clickable:hover { box-shadow: inset 0 0 0 2px var(--brand); }
#costRefTable td.calc-clickable { cursor: pointer; transition: box-shadow .12s; }
#costRefTable td.calc-clickable:hover { box-shadow: inset 0 0 0 2px var(--partial); }
#costRefTable .src-cue { font-size: 12px; font-weight: 700; color: var(--brand); opacity: .8; }
