:root {
  --bg: #141827;
  --panel: #111524;
  --text: #f5f7fb;
  --muted: #c9c4d5;
  --accent: #334aff;
  --accent-2: #2c6eb5;
  --border: #2a3148;
  --highlight: #eef3f7;
}

* {
  box-sizing: border-box;
  font-family: "Rubik", "Segoe UI", sans-serif;
}

/* Defensive Layout Patterns */
/* Use this utility class on any flex container that can grow beyond its parent.
   Without these properties, nested flex/grid content can overflow and cause the
   page to expand or clip. This pattern ensures the container constrains its size
   and scrolls when content exceeds available space. */
.scrollable-flex-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #2c6eb5 0%, #141827 55%);
  color: var(--text);
}

.app {
  max-width: 1280px;
  margin: 32px auto;
  padding: 0 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  background: rgba(17, 21, 36, 0.9);
  margin-bottom: 24px;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-mark img {
  height: 56px;
  width: auto;
}

.brand-divider {
  width: 1px;
  height: 32px;
  background-color: var(--border);
  opacity: 0.6;
}

.brand-product {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--muted);
  line-height: 1.2;
}

.brand-name {
  /* Alias for brand-product for backward compatibility */
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--muted);
  line-height: 1.2;
}

.brand-pill {
  display: none;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 14px;
}

.user-role-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  color: #dbe3f3;
  background: rgba(255, 255, 255, 0.05);
}

.logout-btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: var(--accent);
}

.header h1 {
  margin: 0 0 8px;
  font-size: 34px;
  letter-spacing: 0.2px;
}

.header p {
  margin: 0 0 24px;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.auth-panel {
  grid-template-columns: 1fr;
}

.auth-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.auth-form label {
  color: var(--muted);
}

.auth-form input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
}

.sso-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sso-divider {
  color: var(--muted);
  font-size: 13px;
}

.sso-row button {
  padding: 9px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1f2a4a;
  color: #f2f6ff;
  font-weight: 600;
  cursor: pointer;
}

.panel label {
  grid-column: 1 / -1;
  color: var(--muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #2a3148;
  border-radius: 999px;
  transition: 0.2s ease;
  border: 1px solid var(--border);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  top: 2px;
  background-color: #fff;
  border-radius: 50%;
  transition: 0.2s ease;
}

.toggle input:checked + .toggle-slider {
  background-color: var(--accent);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.panel input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
}

.panel input:disabled {
  background: #1b2338;
  color: #aab4c8;
  border-color: #3a4463;
  cursor: not-allowed;
  opacity: 1;
}

.panel button {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.panel button:disabled {
  background: #2b3551;
  color: #97a3bd;
  cursor: not-allowed;
  opacity: 1;
}

.start-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  grid-column: 1 / -1;
}

.start-actions .secondary-btn {
  background: #1f2a4a;
  border: 1px solid var(--border);
  color: #d7deeb;
}

.status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: #ff6b6b;
}

.status.stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats-pill {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: #d2d7e2;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
}

.stats-pill-warning {
  border-color: rgba(214, 112, 112, 0.5);
  background: rgba(132, 36, 48, 0.28);
  color: #ffe4ea;
}

.stats-pill-info {
  border-color: rgba(125, 170, 255, 0.4);
  background: rgba(51, 74, 255, 0.12);
  color: #d7e4ff;
}

.stats-docs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.stats-docs-label {
  font-size: 12px;
  color: #9ba3b3;
  margin-right: 2px;
}

.stats-doc-chip {
  border: 1px solid #364160;
  background: rgba(51, 74, 255, 0.08);
  color: #cfd6ea;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.chat {
  margin-top: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #141b30;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

.tab-calc-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  background: #1f2a4a;
  color: #d7deeb;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab-calc-btn:hover {
  border-color: #3b4f8b;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.chat-layout.calc-open {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
}

.message {
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.4;
  word-break: break-word;
}

.message.user {
  background: #1f2a4a;
  align-self: flex-end;
  white-space: pre-wrap;
}

.message.assistant {
  background: #1a1f25;
  border: 1px solid var(--border);
}

.message.thinking {
  padding: 0;
  background: transparent;
  border: none;
  color: #9ba3b3;
  font-size: 13px;
}

.message.assistant p {
  margin: 0 0 8px;
}

.message.assistant p:last-child {
  margin-bottom: 0;
}

.message.assistant ul,
.message.assistant ol {
  margin: 4px 0 8px;
  padding-left: 20px;
}

.message.assistant li {
  margin-bottom: 2px;
}

.message.assistant strong {
  color: var(--highlight);
}

.message.assistant code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.message.assistant table {
  display: block;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.9em;
  width: max-content;
  min-width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121a2a;
}

.message.assistant th,
.message.assistant td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.message.assistant th {
  background: rgba(255, 255, 255, 0.08);
  font-weight: 600;
}

.message.assistant .response-timing {
  margin-top: 8px;
  color: #9ba3b3;
  font-size: 12px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 12px;
}

.composer input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
}

.composer button {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.prompt-config {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-panel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.admin-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 20, 36, 0.8);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-card h3 {
  margin: 0;
  font-size: 15px;
  color: #d8deea;
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.admin-card-header button {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1f2a4a;
  color: #fff;
  cursor: pointer;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-form label {
  color: var(--muted);
  font-size: 13px;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
  padding: 10px 12px;
}

.admin-form input:disabled,
.admin-form select:disabled,
.admin-form textarea:disabled {
  background: #1b2338;
  color: #aab4c8;
  border-color: #3a4463;
  cursor: not-allowed;
}

.admin-form button {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent-2);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d2d8e4;
  font-size: 13px;
}

.inline-check input {
  width: auto;
  margin: 0;
}

.json-view {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1120;
  color: #d5dbea;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.4;
}

.validation-output {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.validation-result-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1120;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.validation-result-title {
  font-weight: 700;
  color: #eff4ff;
}

.validation-result-summary {
  color: #ced4e2;
  font-size: 13px;
}

.contract-review-workspace.empty .contract-review-columns {
  display: none;
}

.contract-review-empty {
  color: var(--muted);
  font-size: 14px;
}

.contract-review-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  min-width: 0;
}

.contract-review-source,
.contract-review-data {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.contract-review-source-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.contract-review-source-toolbar select,
.contract-review-data textarea,
.contract-review-item textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
  padding: 10px 12px;
}

.contract-source-text {
  max-height: 640px;
  overflow: auto;
  white-space: pre-wrap;
}

.contract-review-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.contract-review-badge {
  border: 1px solid #364160;
  background: rgba(51, 74, 255, 0.12);
  color: #d7e0f3;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.contract-review-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contract-review-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1120;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contract-review-item-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.attainment-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.dashboard-panel-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dashboard-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-toolbar h3,
.dashboard-section-header h4 {
  margin: 0 0 4px;
}

.dashboard-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-toolbar-actions select,
.dashboard-filter-input {
  min-width: 180px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d1120;
  color: var(--text);
  padding: 8px 10px;
}

.dashboard-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dashboard-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.attainment-kpi {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(31, 42, 74, 0.45);
  padding: 8px 10px;
}

.attainment-kpi-emphasis {
  border-width: 2px;
}

.attainment-kpi-positive {
  border-color: #2f9d61;
  background: rgba(25, 91, 57, 0.45);
}

.attainment-kpi-negative {
  border-color: #cc5261;
  background: rgba(112, 36, 47, 0.45);
}

.formatted-negative {
  color: #f0b7bf !important;
  font-weight: 700;
}

.attainment-kpi-label {
  color: var(--muted);
  font-size: 12px;
}

.attainment-kpi-value {
  color: #eff4ff;
  font-weight: 700;
  margin-top: 2px;
  font-size: 14px;
}

.attainment-kpi-positive .attainment-kpi-label {
  color: #b8efce;
}

.attainment-kpi-positive .attainment-kpi-value {
  color: #e6fff0;
}

.attainment-kpi-negative .attainment-kpi-label {
  color: #ffd2d8;
}

.attainment-kpi-negative .attainment-kpi-value {
  color: #ffecef;
}

.attainment-notes {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.attainment-notes-title {
  color: #eff4ff;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.attainment-notes-list {
  margin: 0;
  padding-left: 18px;
  color: #ced4e2;
  font-size: 12px;
}

.attainment-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.report-table-shell {
  position: relative;
}

.report-table-wrap {
  padding-bottom: 12px;
  scrollbar-width: auto;
  scrollbar-color: #90a4c8 #0a1120;
  --report-sticky-col-0-width: 180px;
  --report-sticky-col-1-left: 180px;
  --report-sticky-col-1-width: 120px;
  --report-sticky-col-2-left: 300px;
  --report-sticky-col-2-width: 128px;
}

.report-table-wrap::-webkit-scrollbar {
  height: 14px;
}

.report-table-wrap::-webkit-scrollbar-track {
  background: #0a1120;
  border-radius: 999px;
}

.report-table-wrap::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #5f7398, #98acd0);
  border: 2px solid #0a1120;
  border-radius: 999px;
}

.report-table-wrap::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, #7085ac, #a8bcde);
}

.report-table-shell-finance::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 14px;
  width: 56px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, rgba(16, 22, 40, 0), rgba(16, 22, 40, 0.92) 60%, rgba(16, 22, 40, 1));
  transition: opacity 160ms ease;
  z-index: 9;
}

.report-table-shell-finance.show-right-fade::after {
  opacity: 1;
}

.report-scroll-hint {
  position: absolute;
  right: 14px;
  top: 12px;
  transform: translateY(6px);
  padding: 7px 11px;
  border: 1px solid rgba(151, 173, 209, 0.38);
  border-radius: 999px;
  background: rgba(9, 16, 30, 0.96);
  color: #eef4ff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 10;
}

.report-table-shell-finance.show-scroll-hint .report-scroll-hint {
  opacity: 1;
  transform: translateY(0);
}

.table-scroll-x {
  width: 100%;
  overflow-x: auto;
}

.attainment-table td {
  white-space: nowrap;
}

.attainment-crossing-legend {
  color: #8de6ae;
}

.attainment-status-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.attainment-status-cell-vertical {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
}

.attainment-status-label {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(151, 173, 209, 0.26);
  background: rgba(255, 255, 255, 0.06);
  color: #eef4ff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.attainment-status-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 1px solid #8ca0c4;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1;
  color: #d7e3ff;
  background: rgba(255, 255, 255, 0.08);
  cursor: help;
}

.contract-applicability-pill.contract-applicability-normal {
  border-color: rgba(120, 170, 140, 0.34);
  background: rgba(49, 112, 71, 0.22);
  color: #dcf8e5;
}

.contract-applicability-pill.contract-applicability-info {
  border-color: rgba(125, 170, 255, 0.34);
  background: rgba(51, 74, 255, 0.14);
  color: #dce8ff;
}

.contract-applicability-pill.contract-applicability-warning {
  border-color: rgba(214, 112, 112, 0.45);
  background: rgba(132, 36, 48, 0.34);
  color: #ffe3e8;
}

.contract-applicability-pill.contract-applicability-neutral {
  border-color: rgba(151, 173, 209, 0.26);
  background: rgba(255, 255, 255, 0.06);
  color: #eef4ff;
}

.contract-applicability-reason {
  color: #b9c8e5;
  font-size: 11px;
  line-height: 1.3;
}

.attainment-crossing-bar {
  border-top: 3px solid #2fbb66;
  padding-top: 6px;
  color: #baf5ce;
  font-weight: 600;
}

.attainment-goal-crossing-row td {
  border-bottom: 3px solid #2fbb66 !important;
}

.trueup-mismatch-row td {
  background: rgba(132, 36, 48, 0.35);
  color: #ffe7eb;
}

.report-row-manual-review td {
  background: rgba(82, 28, 37, 0.38);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 20, 0.72);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-panel {
  width: min(560px, 100%);
  height: 100%;
  overflow: auto;
  background: #101628;
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.explain-row {
  color: #d9dfeb;
  font-size: 13px;
  line-height: 1.5;
}

.explain-source-item {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
  margin-top: 8px;
  color: #d9dfeb;
  font-size: 13px;
  line-height: 1.5;
}

.explain-source-note {
  margin-top: 6px;
  color: #f4d58d;
}

.explain-note-list {
  margin-top: 10px;
}

.fx-rate-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #121a2a;
}

.fx-rate-table th,
.fx-rate-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
  color: #d8deea;
}

.fx-rate-table th {
  background: rgba(255, 255, 255, 0.08);
  color: #eff4ff;
  font-weight: 700;
}

.finance-trueup-table {
  min-width: 1520px;
}

.finance-trueup-table th {
  position: sticky;
  top: 32px;
  z-index: 12;
  background: #1a2438;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.finance-trueup-table td {
  background: #121a2a;
}

.finance-trueup-table .report-table-cell {
  white-space: nowrap;
}

.finance-trueup-table .report-group-row th {
  position: sticky;
  top: 0;
  z-index: 14;
  padding: 7px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b9c8e5;
  background: #121a2a;
}

.finance-trueup-table .report-group-heading {
  border-bottom-color: rgba(255, 255, 255, 0.14);
}

.finance-trueup-table .report-group-start {
  border-left-width: 2px;
}

.finance-trueup-table .report-group-order-info {
  box-shadow: inset 0 2px 0 rgba(125, 170, 255, 0.18);
}

.finance-trueup-table .report-group-timing {
  box-shadow: inset 0 2px 0 rgba(104, 216, 195, 0.18);
}

.finance-trueup-table .report-group-commission {
  box-shadow: inset 0 2px 0 rgba(240, 199, 104, 0.2);
}

.finance-trueup-table .report-group-status {
  box-shadow: inset 0 2px 0 rgba(245, 132, 132, 0.18);
}

.finance-trueup-table .report-group-metadata {
  box-shadow: inset 0 2px 0 rgba(168, 180, 207, 0.12);
}

.finance-trueup-table th.report-group-order-info {
  background: #1a2740;
}

.finance-trueup-table th.report-group-timing {
  background: #17313d;
}

.finance-trueup-table th.report-group-commission {
  background: #372b1a;
}

.finance-trueup-table th.report-group-status {
  background: #322028;
}

.finance-trueup-table th.report-group-metadata {
  background: #1f2738;
}

.finance-trueup-table .report-sticky-col {
  position: sticky;
  background: #121a2a;
  z-index: 8;
  overflow: hidden;
  text-overflow: ellipsis;
}

.finance-trueup-table th.report-sticky-col {
  z-index: 18;
}

.finance-trueup-table .report-group-row .report-group-order-info {
  z-index: 20;
}

.finance-trueup-table .report-sticky-col-0 {
  left: 0;
  width: var(--report-sticky-col-0-width);
  min-width: var(--report-sticky-col-0-width);
  max-width: var(--report-sticky-col-0-width);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.08), 12px 0 16px rgba(6, 10, 18, 0.16);
}

.finance-trueup-table .report-sticky-col-1 {
  left: var(--report-sticky-col-1-left);
  width: var(--report-sticky-col-1-width);
  min-width: var(--report-sticky-col-1-width);
  max-width: var(--report-sticky-col-1-width);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.08), 12px 0 16px rgba(6, 10, 18, 0.12);
}

.finance-trueup-table .report-sticky-col-2 {
  left: var(--report-sticky-col-2-left);
  width: var(--report-sticky-col-2-width);
  min-width: var(--report-sticky-col-2-width);
  max-width: var(--report-sticky-col-2-width);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.1), 16px 0 18px rgba(6, 10, 18, 0.18);
}

.finance-trueup-table td.report-sticky-col {
  background: #152036;
}

.finance-trueup-table th.report-sticky-col.report-group-order-info {
  background: #223252;
}

.finance-trueup-table .report-value-muted-zero {
  color: #8b99b6;
}

.finance-trueup-table .report-value-accrued {
  color: #eff4ff;
  font-weight: 600;
}

.fx-rate-input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
  padding: 6px 8px;
}

.fx-note-input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
  padding: 6px 8px;
}

.fx-rate-row-dirty {
  background: rgba(51, 74, 255, 0.08);
}

.fx-rate-error {
  margin-top: 4px;
  font-size: 11px;
}

.prompt-config label {
  color: var(--muted);
  font-size: 14px;
}

.prompt-config textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
  padding: 10px 12px;
  resize: vertical;
  min-height: 140px;
}

.prompt-actions {
  display: flex;
  gap: 8px;
}

.prompt-actions button {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent-2);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.prompt-status {
  color: var(--muted);
  font-size: 13px;
}

.prompt-status.error {
  color: #ff6b6b;
}

.calc-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 20, 36, 0.8);
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.calc-panel[hidden] {
  display: none !important;
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  margin-bottom: 10px;
}

.calc-header h3 {
  margin: 0;
  font-size: 14px;
  color: #d8deea;
  letter-spacing: 0.2px;
  min-width: 0;
}

.calc-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  min-width: 0;
  flex: 0 0 auto;
}

.calc-form label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.optional-label {
  color: rgba(201, 196, 213, 0.72);
}

.calc-form input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
}

.calc-form input:disabled,
.calc-form select:disabled {
  background: #1b2338;
  color: #aab4c8;
  border-color: #3a4463;
  cursor: not-allowed;
}

.calc-form select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1424;
  color: var(--text);
}

.calc-form button {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent-2);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.calc-panel .prompt-status {
  margin-top: 8px;
  margin-bottom: 8px;
}

.calc-preset {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
}

.calc-preset div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.calc-preset span {
  color: #9ba3b3;
  font-size: 12px;
}

.calc-preset strong {
  color: #e7ebf5;
  font-size: 12px;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.calc-result {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1120;
  color: #d5dbea;
  padding: 10px;
  min-height: 80px;
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 4px;
  line-height: 1.4;
  white-space: normal;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.calc-result.empty {
  min-height: 0;
  max-height: none;
  border: none;
  background: transparent;
  padding: 0;
  overflow: visible;
}

.calc-result-title {
  font-size: 13px;
  color: #9ba3b3;
  margin-bottom: 4px;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.calc-result-value {
  font-size: 20px;
  font-weight: 700;
  color: #f5f7fb;
  margin-bottom: 8px;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.calc-result-detail,
.calc-result-explainer,
.calc-result-line,
.calc-result > * {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.calc-result-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
  color: #9ba3b3;
  font-size: 13px;
}

.calc-result-line,
.calc-result-explainer {
  display: block;
}

@media (max-width: 640px) {
  .panel {
    grid-template-columns: 1fr;
  }
  .start-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .composer {
    grid-template-columns: 1fr;
  }
  .prompt-actions {
    flex-direction: column;
  }
  .admin-card-header {
    flex-direction: column;
    align-items: stretch;
  }
  .chat-layout.calc-open {
    grid-template-columns: 1fr;
  }
  .contract-review-columns {
    grid-template-columns: 1fr;
  }
}
