/* Mini-MVP Styles - Based on Workship Light Editorial Theme */

:root {
  /* Light theme - Editorial Finance */
  --bg-primary: #FDFBF7;
  --bg-secondary: #F7F4EE;
  --bg-tertiary: #EFEBE4;
  --surface: #FFFFFF;
  --surface-elevated: #FFFFFF;

  --text-primary: #1A1D23;
  --text-secondary: #4A4F5C;
  --text-muted: #7D8291;
  --text-subtle: #A8ACBA;

  --accent: #B8934B;
  --accent-light: #D4B06A;
  --accent-dark: #96763A;
  --accent-subtle: rgba(184, 147, 75, 0.12);

  --navy: #1E2A3B;
  --navy-light: #2D3D52;

  --success: #2D8A5E;
  --success-bg: rgba(45, 138, 94, 0.1);
  --warning: #C17F24;
  --warning-bg: rgba(193, 127, 36, 0.1);
  --error: #C44536;
  --error-bg: rgba(196, 69, 54, 0.1);

  --border: rgba(26, 29, 35, 0.08);
  --border-strong: rgba(26, 29, 35, 0.15);
  --shadow-sm: 0 1px 3px rgba(26, 29, 35, 0.04);
  --shadow-md: 0 4px 12px rgba(26, 29, 35, 0.06);
  --shadow-lg: 0 12px 40px rgba(26, 29, 35, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.page-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Input Section */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* New grid layout for input files */
.input-section-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.file-upload-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.file-upload-col {
  display: flex;
  flex-direction: column;
}

.file-upload-col .file-box {
  flex: 1;
  min-height: 100px;
}

.input-action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.action-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.run-btn-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.btn-link-muted {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 6px 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.btn-link-muted:hover {
  color: var(--error);
  background: var(--error-bg);
}

.btn-link-muted svg {
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .file-upload-columns {
    grid-template-columns: 1fr;
  }

  .input-action-row {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .action-left {
    justify-content: center;
    flex-wrap: wrap;
  }

  .action-right {
    justify-content: center;
  }
}

.input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.input-row.run-row {
  align-items: center;
  gap: 12px;
}

.run-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-field input[type="text"] {
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  min-width: 200px;
  transition: all 0.2s ease;
}

.input-field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* File Upload Boxes */
.file-uploads {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  /* T13-D: Fixed minimum height for stable layout */
  min-height: 130px;
}

.file-box {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  /* T13-D: Fixed minimum height for stable layout */
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.file-box:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.file-box.selected {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-subtle);
}

.file-box.invalid {
  border-color: var(--error);
  background: var(--error-bg);
}

.file-box-label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.file-box-format {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.file-box-status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.file-box.selected .file-box-status {
  color: var(--accent-dark);
  font-weight: 500;
}

/* Info box for MIS Combined cost data message (replaces file-box in Daily Ops) */
.file-box-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 52px;
}

.file-box-info svg {
  flex-shrink: 0;
  color: var(--accent);
}

.file-box-info strong {
  color: var(--accent-dark);
  font-weight: 600;
}

.file-box.invalid .file-box-status {
  color: var(--error);
}

.file-box input[type="file"] {
  display: none;
}

.file-remove {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.file-remove:hover {
  border-color: var(--error);
  color: var(--error);
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--navy-light);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-loading {
  position: relative;
}

.btn-loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
}

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

/* Error Banner */
.error-banner {
  display: none;
  padding: 16px 20px;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-left: 4px solid var(--error);
  border-radius: var(--radius-md);
  color: var(--error);
  font-size: 0.9rem;
  align-items: center;
  gap: 12px;
}

.error-banner.show {
  display: flex;
}

.error-banner-icon {
  font-size: 1.2rem;
}

.error-banner-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--error);
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
}

/* Results Section */
.results-section {
  display: none;
}

.results-section.show {
  display: block;
}

/* Summary Strip */
.summary-strip {
  display: flex;
  gap: 24px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.summary-value.summary-na {
  color: var(--warning);
}

.summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

#summary-na-container.has-na .summary-value {
  color: var(--warning);
}

/* Filter Row */
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.filter-row label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-row select {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  min-width: 200px;
  cursor: pointer;
}

.filter-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.filter-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Sales Table */
.table-scroll {
  overflow-x: auto;
}

.sales-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.sales-table th {
  text-align: left;
  padding: 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
  background: var(--bg-secondary);
}

.sales-table td {
  padding: 12px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.sales-table th.text-right,
.sales-table td.text-right {
  text-align: right;
}

.sales-table th.text-center,
.sales-table td.text-center {
  text-align: center;
}

/* Sale Row */
.sale-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.sale-row:hover {
  background: var(--bg-secondary);
}

/* Expand Button */
.expand-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.expand-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.expand-btn.expanded {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-dark);
}

/* Expanded Allocations */
.allocation-row {
  display: none;
}

.allocation-row.show {
  display: table-row;
}

.allocation-row td {
  padding: 0;
  background: var(--bg-secondary);
}

.allocation-container {
  padding: 16px 24px 16px 48px;
}

.allocation-container h4 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.allocation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.allocation-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.allocation-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.allocation-table tr:last-child td {
  border-bottom: none;
}

/* ISIN cell */
.isin-cell {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.85rem;
}

/* Security name truncation */
.security-name {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-st {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.badge-lt {
  background: rgba(45, 138, 94, 0.15);
  color: var(--success);
}

.badge-opening {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.badge-unpriced {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-na {
  background: var(--warning);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-pre2018 {
  background: rgba(251, 146, 60, 0.15);
  color: #f97316;
  font-size: 0.65rem;
  padding: 2px 6px;
  margin-left: 4px;
  cursor: help;
}

/* Type badges for MIS Combined list */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-buy {
  background: var(--success-bg);
  color: var(--success);
}

.badge-sell {
  background: var(--error-bg);
  color: var(--error);
}

/* Gain Status */
.gain-computed {
  color: var(--success);
  font-weight: 600;
}

.gain-computed::before {
  content: '✓ ';
}

/* Opening Inventory Text */
.opening-inventory-text {
  color: var(--text-muted);
  font-style: italic;
}

/* Reconciliation Banner */
.reconciliation-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-top: 20px;
}

.reconciliation-banner.match {
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: var(--success);
}

.reconciliation-banner.mismatch {
  background: var(--error-bg);
  border: 1px solid var(--error);
  color: var(--error);
}

.reconciliation-icon {
  font-size: 1.2rem;
}

.reconciliation-text {
  flex: 1;
}

.reconciliation-text strong {
  display: block;
  margin-bottom: 2px;
}

/* ========================================
   NSDL Audit Trail Styles
   ======================================== */

.audit-trail-container {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.audit-trail-header {
  margin-bottom: 12px;
}

.audit-toggle-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.audit-toggle-btn:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.audit-toggle-btn.expanded {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.audit-trail-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 8px;
}

.audit-trail-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.audit-verification {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.audit-verification.audit-verified {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.audit-verification.audit-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning);
}

/* Audit Table */
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.audit-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-tertiary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.audit-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.audit-table tr:last-child td {
  border-bottom: none;
}

/* Audit Row Types */
.audit-row-sale {
  background: rgba(30, 42, 59, 0.08);
}

.audit-row-sale td {
  font-weight: 600;
  color: var(--navy);
}

.audit-row-consumed {
  background: rgba(45, 138, 94, 0.08);
}

.audit-row-muted {
  opacity: 0.6;
}

.audit-row-muted td {
  color: var(--text-muted);
}

/* Audit Badges */
.badge-audit-sale {
  background: var(--navy);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-audit-buy {
  background: rgba(45, 138, 94, 0.15);
  color: var(--success);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-audit-opening {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-audit-sell {
  background: rgba(196, 69, 54, 0.15);
  color: var(--error);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-audit-nontrade {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* Consumed quantity highlight */
.audit-consumed {
  background: var(--accent-subtle);
  color: var(--accent-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Zero remaining with checkmark */
.audit-zero {
  color: var(--success);
  font-weight: 700;
}

/* Compact/Verbose Toggle */
.audit-view-toggle {
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.audit-view-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.audit-view-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.verbose-toggle:checked + span {
  font-weight: 600;
  color: var(--accent-dark);
}

/* Verbose header showing row range */
.audit-verbose-header {
  padding: 10px 14px;
  margin-bottom: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* Truncation notice */
.audit-truncated-note {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--warning);
}

/* ========================================
   Audit Tab Navigation
   ======================================== */

.audit-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.audit-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  margin-bottom: -2px;
}

.audit-tab-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-secondary);
}

.audit-tab-btn.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.audit-tab-content {
  display: none;
}

.audit-tab-content.active {
  display: block;
}

/* ========================================
   Forward + Balance Proof Table Styles
   ======================================== */

.forward-table {
  font-size: 0.8rem;
}

.forward-table th {
  white-space: nowrap;
}

.forward-table .th-subtitle {
  font-weight: 400;
  font-size: 0.65rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.forward-row-adjusted {
  background: rgba(45, 138, 94, 0.12);
}

.forward-row-adjusted td {
  font-weight: 500;
}

.forward-row-muted {
  opacity: 0.55;
}

.forward-row-muted td {
  color: var(--text-muted);
}

.forward-adjusted {
  background: var(--accent-subtle);
  color: var(--accent-dark);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.forward-proof {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.forward-row-adjusted .forward-proof {
  color: var(--text-primary);
  font-weight: 500;
}

/* ========================================
   Reverse (CA View) Calculator-Style Table
   ======================================== */

.ca-view-table {
  font-size: 0.8rem;
}

.ca-view-table th {
  white-space: nowrap;
}

.ca-view-description {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 12px 0;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Sale row - blue/neutral tint */
.ca-view-row-sale {
  background: rgba(30, 42, 59, 0.1);
}

.ca-view-row-sale td {
  font-weight: 600;
  color: var(--navy);
}

/* Buy/adjustment rows - green tint */
.ca-view-row-buy {
  background: rgba(45, 138, 94, 0.08);
}

.ca-view-row-buy td {
  font-weight: 500;
}

/* Adjusted qty highlight */
.ca-view-adjusted {
  background: var(--accent-subtle);
  color: var(--accent-dark);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
}

/* Sale Lot Remaining column */
.ca-view-remaining {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-weight: 600;
}

/* ========================================
   Matrix View Styles (Buy Lots × Sales Grid)
   ======================================== */

.matrix-table {
  font-size: 0.8rem;
}

.matrix-table th {
  white-space: nowrap;
}

/* Matrix Summary Stats */
.matrix-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 16px;
  background: var(--navy);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.matrix-summary-item strong {
  font-size: 1.1rem;
}

.matrix-summary-sep {
  opacity: 0.6;
  font-size: 1.2rem;
}

/* Legend */
.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.8rem;
}

.matrix-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matrix-legend-box {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.matrix-legend-box.empty {
  background: #fafafa;
  border: 1px dashed #ccc;
}

.matrix-legend-box.consumed {
  background: rgba(196, 69, 54, 0.2);
  border: 1px solid var(--error);
}

.matrix-legend-box.target {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  border: 1px solid var(--accent-dark);
}

.matrix-legend-box.full {
  background: rgba(196, 69, 54, 0.2);
  border: 1px solid var(--error);
}

.matrix-legend-box.partial {
  background: rgba(193, 127, 36, 0.2);
  border: 1px solid var(--warning);
}

.matrix-description {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 12px 0;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Lot header columns (fixed left) */
.matrix-lot-header {
  background: var(--navy-light) !important;
  color: white !important;
}

/* Sale header column (target sale) */
.matrix-sale-header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%) !important;
  color: white !important;
  min-width: 140px;
}

.matrix-sale-header-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.matrix-sale-date {
  font-size: 0.75rem;
  font-weight: 600;
}

.matrix-sale-qty {
  font-size: 0.7rem;
  opacity: 0.9;
}

.matrix-sale-ref {
  font-size: 0.65rem;
  opacity: 0.8;
}

.matrix-sale-target {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 2px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* Lot cells (NSDL Row, Buy Date, Qty) */
.matrix-lot-cell {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-strong);
}

.matrix-row-ref {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-weight: 600;
  color: var(--navy);
}

.matrix-row-ref.opening {
  color: var(--text-muted);
}

/* Consumption cells */
.matrix-sale-cell {
  vertical-align: middle;
  padding: 8px 12px;
}

/* Empty cell (no consumption) */
.matrix-cell-empty {
  background: #fafafa;
  border: 1px dashed #e0e0e0;
}

/* Consumed cell (has qty consumed) */
.matrix-cell-consumed {
  background: rgba(196, 69, 54, 0.12);
  vertical-align: middle;
  padding: 8px 10px;
}

/* Target column highlight */
.matrix-cell-target-col {
  background: rgba(184, 147, 75, 0.15) !important;
  border-left: 3px solid var(--accent) !important;
  border-right: 3px solid var(--accent) !important;
}

/* Target column header */
.matrix-target-header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%) !important;
  color: white !important;
  min-width: 110px;
}

.matrix-cell-full {
  background: rgba(196, 69, 54, 0.12);
  border-left: 3px solid var(--accent) !important;
  border-right: 3px solid var(--accent) !important;
}

.matrix-cell-partial {
  background: rgba(193, 127, 36, 0.12);
  border-left: 3px solid var(--accent) !important;
  border-right: 3px solid var(--accent) !important;
}

.matrix-consume-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.matrix-consume-qty {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--error);
}

.matrix-consume-qty::before {
  content: '−';
}

.matrix-consume-qty.partial {
  color: var(--warning);
}

/* Row that contributed to target sale */
.matrix-row-target {
  background: rgba(184, 147, 75, 0.1);
}

.matrix-row-target:hover {
  background: rgba(184, 147, 75, 0.18);
}

.matrix-consume-ref {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  text-align: center;
}

.matrix-consume-ref strong {
  color: var(--navy);
}

/* Row styling */
.matrix-row-consumed {
  background: rgba(184, 147, 75, 0.08);
}

.matrix-row-consumed:hover {
  background: rgba(184, 147, 75, 0.15);
}

/* Allocation Summary Footer */
.matrix-footer {
  margin-top: 16px;
  padding: 16px 20px;
  background: linear-gradient(90deg, rgba(184, 147, 75, 0.1) 0%, rgba(184, 147, 75, 0.05) 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
}

.matrix-footer-title {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.matrix-alloc-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.matrix-alloc-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.matrix-alloc-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.matrix-alloc-label strong {
  color: var(--navy);
  font-weight: 600;
}

.matrix-alloc-value {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.matrix-alloc-equals {
  font-size: 1.3rem;
  color: var(--text-muted);
}

.matrix-alloc-total {
  padding: 10px 18px;
  background: var(--success);
  color: white;
  border-radius: var(--radius-sm);
}

.matrix-alloc-total-value {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 1.2rem;
  font-weight: 700;
}

/* Matrix Open Prompt (in-tab button to open new tab) */
.matrix-open-container {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.matrix-open-prompt {
  text-align: center;
  padding: 40px;
  max-width: 400px;
}

.matrix-open-icon {
  color: var(--accent);
  margin-bottom: 16px;
}

.matrix-open-prompt h4 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.matrix-open-prompt p {
  color: var(--text-muted);
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.matrix-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 0.95rem;
}

.matrix-open-btn svg {
  flex-shrink: 0;
}

/* Matrix button row with run ID badge */
.matrix-button-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.run-id-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
  background: var(--bg-muted);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.run-id-badge.run-id-missing {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
}

/* Matrix exhausted (remaining = 0) */
.matrix-exhausted {
  color: var(--text-muted);
  font-style: italic;
}

/* ========================================
   LOGIN PAGE STYLES
   ======================================== */

/* Login Page - Full screen 2-column layout */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: fixed;
  inset: 0;
  width: 100%;
  overflow-y: auto;
  z-index: 100;
}

.login-page.hidden {
  display: none;
}

/* Left Panel - Visual Animation */
.login-visual {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
}

.login-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(184, 147, 75, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(184, 147, 75, 0.1) 0%, transparent 40%);
}

/* Animated Ledger Canvas */
.visual-canvas {
  position: absolute;
  inset: 0;
  opacity: 0.7;
}

/* Ledger grid lines */
.ledger-line {
  fill: none;
  stroke: rgba(184, 147, 75, 0.3);
  stroke-width: 1;
}

.ledger-line.accent {
  stroke: var(--accent);
  stroke-width: 1.5;
  opacity: 0;
  animation: ledgerDraw 2s ease-out forwards;
}

.ledger-line.accent:nth-child(10) { animation-delay: 0.3s; }
.ledger-line.accent:nth-child(11) { animation-delay: 0.6s; }
.ledger-line.accent:nth-child(12) { animation-delay: 0.9s; }

@keyframes ledgerDraw {
  0% {
    opacity: 0;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
  }
  100% {
    opacity: 0.8;
    stroke-dasharray: 600;
    stroke-dashoffset: 0;
  }
}

/* Floating rupee symbols */
.rupee-float {
  position: absolute;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  opacity: 0;
  animation: rupeeRise 6s ease-in-out infinite;
}

.rupee-float:nth-child(1) { left: 12%; bottom: 20%; animation-delay: 0s; font-size: 1.2rem; }
.rupee-float:nth-child(2) { left: 72%; bottom: 15%; animation-delay: 1.5s; font-size: 1.8rem; }
.rupee-float:nth-child(3) { left: 30%; bottom: 35%; animation-delay: 3s; font-size: 1rem; }
.rupee-float:nth-child(4) { left: 85%; bottom: 45%; animation-delay: 4.5s; font-size: 1.4rem; }

@keyframes rupeeRise {
  0%, 100% {
    opacity: 0;
    transform: translateY(0);
  }
  15% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.4;
    transform: translateY(-60px);
  }
  85% {
    opacity: 0.6;
  }
}

/* Ledger entry highlights */
.ledger-entry {
  position: absolute;
  background: rgba(184, 147, 75, 0.15);
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  border-radius: 0 8px 8px 0;
  opacity: 0;
  animation: entryFade 4s ease-in-out infinite;
}

.ledger-entry span {
  display: block;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
}

.ledger-entry:nth-child(5) { top: 25%; left: 10%; animation-delay: 1s; }
.ledger-entry:nth-child(6) { top: 55%; left: 15%; animation-delay: 2.5s; }
.ledger-entry:nth-child(7) { top: 75%; left: 8%; animation-delay: 4s; }

@keyframes entryFade {
  0%, 100% {
    opacity: 0;
    transform: translateX(-10px);
  }
  20%, 80% {
    opacity: 0.7;
    transform: translateX(0);
  }
}

/* Brand content */
.visual-content {
  position: relative;
  z-index: 2;
  color: #fff;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon svg {
  width: 28px;
  height: 28px;
  stroke: #fff;
  stroke-width: 1.5;
  fill: none;
}

.brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.visual-headline {
  font-family: 'Playfair Display', serif;
  font-size: 3.2rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
  max-width: 420px;
}

.visual-headline em {
  color: var(--accent-light);
  font-style: normal;
}

/* Right Panel - Login Form */
.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  background: var(--bg-primary);
}

.login-container {
  width: 100%;
  max-width: 380px;
  animation: fadeSlideUp 0.8s ease-out;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-header {
  margin-bottom: 40px;
}

.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

/* Form Styles */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input-wrapper {
  position: relative;
}

.form-input {
  width: 100%;
  padding: 16px 20px;
  padding-left: 52px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  transition: all 0.2s ease;
  outline: none;
}

.form-input::placeholder {
  color: var(--text-subtle);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.input-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  fill: none;
  pointer-events: none;
  transition: stroke 0.2s ease;
}

.form-input:focus ~ .input-icon {
  stroke: var(--accent);
}

/* Login Error */
.login-error {
  padding: 12px 16px;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.875rem;
}

/* Submit Button */
.submit-btn {
  margin-top: 12px;
  padding: 18px 32px;
  background: var(--navy);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.submit-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.submit-btn:hover::before {
  opacity: 1;
}

.submit-btn span,
.submit-btn svg {
  position: relative;
  z-index: 1;
}

.submit-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: transform 0.3s ease;
}

.submit-btn:hover svg {
  transform: translateX(4px);
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.submit-btn:disabled::before {
  display: none;
}

/* ========================================
   APP HEADER STYLES
   ======================================== */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  height: 24px;
  width: auto;
  object-fit: contain;
}

.app-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-email {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.logout-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error);
}

/* ========================================
   VIEW TABS (Navigation Tabs)
   ======================================== */

.view-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-left: auto;
  margin-right: 16px;
}

.view-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: calc(var(--radius-md) - 2px);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.view-tab:hover {
  color: var(--text-primary);
}

.view-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ========================================
   RESPONSIVE - LOGIN
   ======================================== */

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

  .login-visual {
    display: none;
  }

  .login-form-panel {
    padding: 40px 24px;
  }
}

/* ========================================
   MULTI-NSDL FILE LIST STYLES
   ======================================== */

.file-box-multi {
  border-style: dashed;
}

.file-box-multi.has-files {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-subtle);
}

/* NSDL File List Container */
.nsdl-file-list {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 4px;
  /* T13-D: Fixed minimum height for stable layout */
  min-height: 180px;
}

.nsdl-file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.nsdl-file-list-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.nsdl-add-more-btn {
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-dark);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.nsdl-add-more-btn:hover {
  background: var(--accent-subtle);
}

/* File Items Container */
.nsdl-file-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px; /* Fits 5 compact rows (~36px each) before scrolling */
  overflow-y: auto;
  /* T13-D: Minimum height to maintain stable layout when files are removed */
  min-height: 80px;
}

/* T13-D: Empty state placeholder when all files removed */
.nsdl-file-items:empty::after {
  content: 'No files selected';
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* Individual File Item - Compact single-line rows */
.nsdl-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  min-height: 32px;
}

.nsdl-file-item:hover {
  background: var(--bg-tertiary);
}

.nsdl-file-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.nsdl-file-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
}

.nsdl-file-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nsdl-file-size {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 6px;
}

.nsdl-file-remove-btn {
  background: transparent;
  border: none;
  padding: 2px 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm);
  margin-left: 8px;
}

.nsdl-file-remove-btn:hover {
  background: var(--error-bg);
  color: var(--error);
}

/* File count badge on the file box */
.nsdl-file-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  margin-left: 6px;
}

.nsdl-warning {
  color: #b26a00;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 4px;
}

/* Detected Clients Display */
.detected-clients {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.detected-clients-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.detected-clients-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detected-client-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.detected-client-badge.found {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.detected-client-badge.unknown {
  background: var(--warning-bg);
  color: #b26a00;
  border: 1px solid #ffc107;
}

.detected-client-badge .depo-id {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.8;
  margin-left: 4px;
}

.detected-clients-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.detected-clients-loading .loading-spinner-tiny {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========================================
   UPLOAD PROGRESS SECTION
   ======================================== */

.upload-progress-section {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 4px;
  /* T13-D: Fixed minimum height for stable layout */
  min-height: 200px;
}

.upload-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.upload-progress-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.upload-progress-count {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

/* Progress Bar */
.upload-progress-bar-container {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* File Status List */
.upload-file-status-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
}

/* Individual File Status Item */
.upload-file-status-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.upload-file-status-item.uploading {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.upload-file-status-item.done {
  border-color: var(--success);
  background: var(--success-bg);
}

.upload-file-status-item.error {
  border-color: var(--error);
  background: var(--error-bg);
}

.upload-file-status-item.pending {
  opacity: 0.6;
}

/* Status Icon */
.upload-file-status-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}

.upload-file-status-icon.pending {
  color: var(--text-muted);
}

.upload-file-status-icon.uploading {
  color: var(--accent);
  animation: uploadSpin 1s linear infinite;
}

.upload-file-status-icon.done {
  color: var(--success);
}

.upload-file-status-icon.error {
  color: var(--error);
}

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

/* File Info */
.upload-file-info {
  flex: 1;
  min-width: 0;
}

.upload-file-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-file-client {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.upload-file-client strong {
  color: var(--accent-dark);
  font-weight: 600;
}

/* File Status Badge */
.upload-file-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  margin-left: 12px;
  flex-shrink: 0;
}

.upload-file-status-badge.pending {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.upload-file-status-badge.uploading {
  background: var(--accent);
  color: white;
}

.upload-file-status-badge.done {
  background: var(--success);
  color: white;
}

.upload-file-status-badge.error {
  background: var(--error);
  color: white;
}

/* Completion Message */
.upload-completion-message {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  padding: 14px 20px;
  background: var(--success-bg);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.upload-completion-icon {
  font-size: 1.2rem;
  color: var(--success);
}

.upload-completion-text {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--success);
}

.upload-completion-message.has-errors {
  background: var(--warning-bg);
  border-color: var(--warning);
}

.upload-completion-message.has-errors .upload-completion-icon,
.upload-completion-message.has-errors .upload-completion-text {
  color: var(--warning);
}

/* ========================================
   Multi-Client View (T6-B)
   ======================================== */

/* Results header with title and button */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.results-header h3 {
  margin: 0;
}

.results-header .btn-secondary {
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* Secondary button style */
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Client header row in multi-client view */
.client-header-row {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
}

.client-header-row:hover {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
}

.client-header-cell {
  padding: 12px 16px !important;
  border: none !important;
}

.client-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.client-header-code {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 4px;
}

.client-header-name {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
}

.client-header-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.1);
  padding: 3px 8px;
  border-radius: 10px;
}

/* Client filter dropdown */
#client-filter {
  margin-right: 16px;
}

/* Gain positive/negative styling */
.gain-positive {
  color: var(--success);
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.gain-negative {
  color: var(--error);
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* BF Toggle Switch (T8-C) */
.results-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bf-toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.bf-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.bf-toggle-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.bf-toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.bf-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.bf-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--text-muted);
  transition: 0.3s;
  border-radius: 24px;
}

.bf-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

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

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

.bf-toggle-switch input:focus + .bf-toggle-slider {
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.bf-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.bf-status.loading {
  color: var(--warning);
}

.bf-status.applied {
  color: var(--success);
  font-style: normal;
  font-weight: 500;
}

.bf-status.warning {
  color: var(--warning);
  font-style: normal;
  font-weight: 500;
}

.bf-status.error {
  color: var(--error);
}

/* BF Summary in Results */
.bf-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 16px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.bf-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bf-summary-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.bf-summary-value {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--text-primary);
}

.bf-summary-value.positive {
  color: var(--success);
}

.bf-summary-value.negative {
  color: var(--error);
}

/* Gain cell with BF breakdown */
.gain-cell-bf {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}

.gain-gross {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: line-through;
}

.gain-bf-applied {
  font-size: 0.7rem;
  color: var(--warning);
}

.gain-net {
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* ========================================
   CG STATEMENT STYLES (T9-B)
   ======================================== */

.cg-statement-section {
  margin-top: 24px;
}

.cg-statement-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.cg-statement-header h3 {
  margin: 0;
}

.cg-statement-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* CG Client Filter Dropdown */
.cg-client-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cg-filter-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.cg-filter-dropdown {
  position: relative;
  display: flex;
  flex-direction: column;
}

.cg-client-search {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  min-width: 220px;
  background: var(--surface);
  color: var(--text);
}

.cg-client-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.cg-client-search::placeholder {
  color: var(--text-muted);
}

.cg-client-select {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface);
  display: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cg-client-select.open {
  display: block;
}

.cg-client-select option {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}

.cg-client-select option:hover {
  background: var(--bg-secondary);
}

.cg-filter-selected {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--accent-light);
  color: var(--accent-dark);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
}

.cg-filter-selected .clear-filter {
  cursor: pointer;
  font-weight: bold;
  margin-left: 4px;
  opacity: 0.7;
}

.cg-filter-selected .clear-filter:hover {
  opacity: 1;
}

/* ========================================
   RUN HISTORY PANEL (T18-C)
   ======================================== */

.run-history-panel {
  margin-bottom: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.run-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.run-history-header:hover {
  background: var(--bg-tertiary);
}

.run-history-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.run-history-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  transition: transform 0.2s ease;
}

.run-history-toggle.collapsed svg {
  transform: rotate(-90deg);
}

.run-history-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.run-history-list.collapsed {
  display: none;
}

.run-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.run-history-item:hover {
  border-color: var(--accent-light);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.run-history-item.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.run-history-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}

.run-history-item {
  position: relative;
}

.run-history-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.run-history-item-date {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.run-history-item-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.run-history-item-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

.run-history-badge-latest {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: 10px;
}

.run-history-empty {
  padding: 24px 16px;
  text-align: center;
}

.run-history-empty-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* CG Summary Strip */
.cg-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.cg-summary-group {
  flex: 1;
  min-width: 200px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.cg-summary-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.cg-summary-items {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.cg-summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 80px;
}

.cg-summary-value {
  font-size: 1rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--text-primary);
}

.cg-summary-value.negative {
  color: var(--error);
}

.cg-summary-value.highlight {
  font-size: 1.1rem;
}

.cg-summary-value.highlight.positive {
  color: var(--success);
}

.cg-summary-value.highlight.negative {
  color: var(--error);
}

.cg-summary-value.na-count {
  color: var(--text-muted);
}

.cg-summary-value.na-count.has-na {
  color: var(--warning);
}

.cg-summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cg-summary-na {
  flex: 0 0 auto;
}

/* CG Statement Table */
.cg-table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 180px); /* Viewport minus header/summary area - increased for ~9 rows */
  min-height: min(50vh, 380px); /* Guarantees ~7 rows visible on Windows scaled displays */
  margin: 0 -24px;
  padding: 0 24px;
}

.cg-statement-table {
  width: 100%;
  min-width: 1400px;
  border-collapse: separate; /* Required for sticky to work with borders */
  border-spacing: 0;
  font-size: 0.8rem;
}

/* Sticky header - both rows */
.cg-statement-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.cg-statement-table th {
  background: var(--navy);
  color: white;
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.cg-statement-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.cg-statement-table tbody tr:hover {
  background: var(--accent-subtle);
}

/* Section header row (CA template style) */
.cg-section-headers th {
  background: var(--navy-dark, #1a2332);
  text-align: center;
  font-size: 0.7rem;
  padding: 6px 8px;
  border-bottom: 2px solid var(--navy);
}

.cg-section-headers .section-sale {
  background: #2a5a8c;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.cg-section-headers .section-purchase {
  background: #4a7a4c;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.cg-section-headers .section-gains {
  background: #8c5a2a;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.cg-section-headers .section-remittance {
  background: #6a4c8c;
  border-left: 1px solid rgba(255,255,255,0.1);
}

/* Column widths */
.cg-col-client-code { width: 40px; }
.cg-col-client-name { width: 80px; }
.cg-col-isin { width: 104px; font-family: 'SF Mono', 'Consolas', monospace; font-size: 0.75rem; }
.cg-col-scrip { width: 90px; }
.cg-col-date { width: 85px; }
.cg-col-qty { width: 60px; }
.cg-col-rate { width: 80px; }
.cg-col-value { width: 90px; }
.cg-col-stt { width: 70px; }
.cg-col-nature { width: 50px; }
.cg-col-gain { width: 100px; }
.cg-col-bf { width: 80px; }
.cg-col-net { width: 100px; }

/* =====================================================
   Sticky Columns - First 4 columns stay fixed on horizontal scroll
   Columns: Client Code, Client Name, ISIN Code, Scrip Name
   ===================================================== */

/* Sticky columns for column headers row (last row of thead) and tbody cells */
.cg-statement-table thead tr:last-child th:nth-child(-n+4),
.cg-statement-table tbody td:nth-child(-n+4) {
  position: sticky;
  z-index: 5;
}

/* Header sticky columns need higher z-index and solid background */
.cg-statement-table thead tr:last-child th:nth-child(-n+4) {
  z-index: 15;
  background: #1a2332;
}

/* Column 1: Client Code (left: 0, width: 40px) */
.cg-statement-table tbody td:nth-child(1),
.cg-statement-table thead tr:last-child th:nth-child(1) {
  left: 0;
}

/* Column 2: Client Name (left: 40px, width: 80px) */
.cg-statement-table tbody td:nth-child(2),
.cg-statement-table thead tr:last-child th:nth-child(2) {
  left: 40px;
}

/* Column 3: ISIN Code (left: 120px = 40 + 80, width: 104px) */
.cg-statement-table tbody td:nth-child(3),
.cg-statement-table thead tr:last-child th:nth-child(3) {
  left: 120px;
}

/* Column 4: Scrip Name (left: 224px = 40 + 80 + 104, width: 90px) */
.cg-statement-table tbody td:nth-child(4),
.cg-statement-table thead tr:last-child th:nth-child(4) {
  left: 224px;
}

/* Shadow on the right edge of last sticky column (Scrip Name) */
.cg-statement-table tbody td:nth-child(4),
.cg-statement-table thead tr:last-child th:nth-child(4) {
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.08);
}

/* Ensure sticky body cells have SOLID opaque backgrounds (critical for sticky to work) */
.cg-statement-table tbody tr td:nth-child(-n+4) {
  background: #ffffff !important;
}

.cg-statement-table tbody tr.cg-row-st td:nth-child(-n+4) {
  background: #fefdfb !important;
}

.cg-statement-table tbody tr.cg-row-lt td:nth-child(-n+4) {
  background: #fbfefc !important;
}

.cg-statement-table tbody tr.cg-row-na td:nth-child(-n+4) {
  background: #fffbeb !important;
}

.cg-statement-table tbody tr:hover td:nth-child(-n+4) {
  background: #f5f0e6 !important;
}

/* Row styling */
.cg-statement-row {
  transition: background-color 0.15s ease;
}

.cg-row-st {
  background: rgba(184, 147, 75, 0.03);
}

.cg-row-lt {
  background: rgba(45, 138, 94, 0.03);
}

.cg-row-na {
  background: rgba(193, 127, 36, 0.08);
}

.cg-row-opening td {
  font-style: italic;
}

/* Opening inventory text */
.cg-opening-inv {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Gain/Loss styling */
.cg-gain-positive {
  color: var(--success);
  font-weight: 600;
}

.cg-gain-negative {
  color: var(--error);
  font-weight: 600;
}

/* BF Set-off value styling - bold to stand out */
.cg-bf-value {
  font-weight: 700;
  font-size: 0.75rem;
}

.cg-bf-applied {
  color: var(--warning);
}

/* BF Preview indicator - shown when BF is calculated but not yet saved to DB */
.cg-bf-preview {
  color: #c2410c;  /* Dark orange for better visibility */
}

/* Preview badge - proper tag styling (dark amber background) */
.badge-preview {
  display: inline-block;
  background: rgba(194, 65, 12, 0.15);
  color: #c2410c;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  margin-left: 4px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Zero Balance badge - shown when client has no BF balance available */
.badge-zero-balance {
  display: inline-block;
  background: rgba(148, 163, 184, 0.2);
  color: #64748b;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: help;
}

.badge-zero-balance[data-tooltip]::after {
  max-width: 300px;
}

/* Loss badge - shown when there's a capital loss (BF doesn't apply) */
.badge-loss {
  display: inline-block;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 500;
  cursor: help;
}

.badge-loss[data-tooltip]::after {
  max-width: 300px;
}

/* Legacy preview-badge (keep for backwards compatibility) */
.preview-badge {
  display: inline-block;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 500;
  margin-left: 3px;
  vertical-align: middle;
}

/* Loading state */
.cg-statement-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Empty state */
.cg-statement-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.cg-statement-empty p {
  margin: 0;
}

/* Master Upload Progress (T12-E) */
.master-upload-progress {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.master-upload-progress-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.loading-spinner-small {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.master-upload-progress-text {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.master-upload-progress-bar-container {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.master-upload-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.master-upload-progress-stats {
  display: flex;
  gap: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.master-upload-progress-stats strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Master Upload Result (T12-E) */
.master-upload-result {
  margin-top: 16px;
  padding: 16px;
  border-radius: 8px;
  font-size: 14px;
}

.master-upload-result.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
}

.master-upload-result.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.master-upload-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 8px;
}

.master-upload-result-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.master-upload-result-stats span {
  display: flex;
  gap: 4px;
}

/* Responsive */
@media (max-width: 900px) {
  .app-header {
    flex-wrap: wrap;
    gap: 12px;
  }

  .view-tabs {
    order: 3;
    width: 100%;
    margin: 0;
  }

  .view-tab {
    flex: 1;
    text-align: center;
  }
}

/* ========================================
   MASTER DATA VIEW STYLES (T12-A)
   ======================================== */

/* Master Data Summary Cards */
.master-data-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.summary-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.summary-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.summary-card-icon {
  color: var(--text-muted);
}

.summary-card-stats {
  display: flex;
  gap: 48px;
  margin-bottom: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.summary-stat {
  display: flex;
  flex-direction: column;
}

.summary-stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
}

.summary-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.summary-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.summary-card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-danger {
  background: var(--error);
  color: white;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background 0.15s ease;
}

.btn-danger:hover {
  background: #a33a2d;
}

.btn-danger:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .master-data-summary {
    grid-template-columns: 1fr;
  }

  .summary-card-stats {
    flex-wrap: wrap;
    gap: 16px;
  }
}

/* Master Data Sub-Tabs */
.master-data-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
  width: 100%;
}

.master-tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all 0.2s ease;
  cursor: pointer;
  transition: all 0.2s ease;
}

.master-tab-btn:hover {
  color: var(--text-primary);
}

.master-tab-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.master-tab-btn svg {
  opacity: 0.7;
}

.master-tab-btn.active svg {
  opacity: 1;
}

.master-tab-panel {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.master-data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.master-data-section {
  min-width: 0;
}

.master-data-section .card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.master-data-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.master-data-section-header h3 {
  margin: 0;
}

.section-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  background: var(--accent-subtle);
  color: var(--accent-dark);
  border-radius: var(--radius-sm);
}

.section-description {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 20px 0;
  line-height: 1.5;
}

/* Upload placeholder (temporary until T12-B, T12-C) */
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: var(--bg-secondary);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
  flex: 1;
  min-height: 180px;
}

.upload-placeholder-icon {
  color: var(--text-muted);
  margin-bottom: 12px;
  opacity: 0.5;
}

.upload-placeholder-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ========================================
   MASTER DATA UPLOAD ZONE STYLES (T12-B)
   ======================================== */

.master-upload-zone {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.master-upload-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  text-align: center;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}

.master-upload-dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.master-upload-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-subtle);
  border-style: solid;
}

.master-upload-dropzone.selected {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-subtle);
}

.master-upload-dropzone input[type="file"] {
  display: none;
}

.master-upload-icon {
  color: var(--text-muted);
  margin-bottom: 12px;
  opacity: 0.6;
}

.master-upload-dropzone:hover .master-upload-icon {
  color: var(--accent);
  opacity: 1;
}

.master-upload-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.master-upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Selected file display */
.master-upload-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
}

.master-upload-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.master-upload-file-info svg {
  color: var(--accent);
  flex-shrink: 0;
}

.master-upload-filename {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.master-upload-filesize {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.master-upload-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s ease;
}

.master-upload-remove-btn:hover {
  color: var(--error);
}

/* Upload button */
.master-upload-btn {
  margin-top: auto;
}

.master-upload-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.master-upload-helper {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 8px 0 12px 0;
  text-align: center;
  font-style: italic;
}

/* Responsive for Master Data Grid */
@media (max-width: 900px) {
  .master-data-grid {
    grid-template-columns: 1fr;
  }
}

/* T13-D: Layout stability for screens 1024px and up */
@media (min-width: 1024px) {
  .file-uploads {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Ensure input section has stable minimum height */
  .input-section {
    min-height: 250px;
  }
}

@media (max-width: 1023px) and (min-width: 769px) {
  /* Tablet breakpoint - 2 columns */
  .file-uploads {
    grid-template-columns: repeat(2, 1fr);
  }

  .file-box:last-child {
    grid-column: span 2;
    max-width: 50%;
    justify-self: center;
  }
}

@media (max-width: 768px) {
  .page {
    padding: 16px;
  }

  .file-uploads {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .file-box {
    min-height: 90px;
  }

  .input-row {
    flex-direction: column;
  }

  .input-field input[type="text"] {
    min-width: 100%;
  }

  .allocation-container {
    padding: 12px;
  }

  .results-header-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .bf-toggle-container {
    width: 100%;
  }

  .cg-summary-strip {
    flex-direction: column;
  }

  .cg-summary-group {
    min-width: 100%;
  }

  .cg-statement-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cg-table-scroll {
    margin: 0 -16px;
    padding: 0 16px;
    max-height: calc(100vh - 280px); /* Smaller offset for mobile */
  }

  /* T13-D: Reduce minimum heights on mobile */
  .nsdl-file-list {
    min-height: 140px;
  }

  .upload-progress-section {
    min-height: 160px;
  }
}

/* ========================================
   BF DRILL-DOWN PANEL (T15-D)
   ======================================== */

/* Overlay behind panel */
.bf-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bf-panel-overlay.visible {
  opacity: 1;
}

/* Slide-out panel */
.bf-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.bf-panel.visible {
  transform: translateX(0);
}

/* Panel header */
.bf-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.bf-panel-title h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.bf-panel-client {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 10px;
  background: var(--accent-subtle);
  color: var(--accent-dark);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
}

.bf-panel-close {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s ease;
}

.bf-panel-close:hover {
  color: var(--text-primary);
}

/* Panel content area */
.bf-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Loading state */
.bf-panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* Error state */
.bf-panel-error {
  padding: 20px;
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  border-radius: var(--radius-md);
  color: #dc3545;
  font-size: 0.9rem;
}

/* BF Statement Data */
.bf-panel-data {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* BF Section (ST or LT) */
.bf-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.bf-section-header {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.bf-section-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* Balance rows */
.bf-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.bf-balance-row:last-child {
  border-bottom: none;
}

.bf-balance-row.bf-closing {
  background: var(--surface);
  font-weight: 600;
}

.bf-balance-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.bf-balance-row.bf-closing .bf-balance-label {
  color: var(--text-primary);
}

.bf-balance-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Setoffs list */
.bf-setoffs-list {
  padding: 8px 16px;
}

.bf-setoffs-list:empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.bf-setoffs-list:empty::after {
  content: 'No setoffs recorded';
}

/* Individual setoff entry */
.bf-setoff-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin: 4px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: default;
  transition: background 0.2s ease;
}

.bf-setoff-entry.clickable {
  cursor: pointer;
}

.bf-setoff-entry.clickable:hover {
  background: var(--accent-subtle);
}

.bf-setoff-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bf-setoff-date {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.bf-setoff-source {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.bf-setoff-source.source-ca {
  background: rgba(255, 152, 0, 0.2);
  color: #e65100;
}

.bf-setoff-source.source-platform {
  background: rgba(40, 167, 69, 0.15);
  color: #28a745;
}

.bf-setoff-amount {
  font-weight: 500;
  color: #dc3545;
  font-variant-numeric: tabular-nums;
}

/* T15-F: BF Allocation Detail Popup */
.bf-allocation-detail-popup {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  margin: 0 12px;
  animation: slideDown 0.2s ease;
  z-index: 10;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bf-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-elevated);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.bf-detail-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.bf-detail-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0 4px;
  line-height: 1;
}

.bf-detail-close:hover {
  color: var(--text-primary);
}

.bf-detail-body {
  padding: 10px 14px;
}

.bf-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 0.82rem;
}

.bf-detail-row.highlight {
  background: var(--accent-subtle);
  margin: 4px -14px;
  padding: 6px 14px;
}

.bf-detail-row.highlight:last-child {
  margin-bottom: -10px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.bf-detail-label {
  color: var(--text-secondary);
}

.bf-detail-value {
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.bf-detail-loading,
.bf-detail-error {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.bf-detail-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #dc3545;
}

/* CG Statement row clickable styling */
.cg-statement-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.cg-statement-table tbody tr:hover {
  background: var(--accent-subtle);
}

/* ========================================
   CONFIRMATION DIALOG (T18-D)
   ======================================== */

.confirm-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.confirm-dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 420px;
  max-width: 90vw;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.confirm-dialog-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.confirm-dialog-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--warning-bg);
  border-radius: 50%;
  color: var(--warning);
}

.confirm-dialog-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.confirm-dialog-body {
  padding: 20px 24px;
}

.confirm-dialog-message {
  margin: 0 0 16px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-dialog-details {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
}

.confirm-dialog-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.confirm-dialog-detail-label {
  color: var(--text-muted);
}

.confirm-dialog-detail-value {
  font-weight: 500;
  color: var(--text-primary);
}

.confirm-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--error);
  border: 1px solid var(--error);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger:hover {
  background: #b33d30;
  border-color: #b33d30;
}

.btn-danger:disabled {
  background: var(--text-muted);
  border-color: var(--text-muted);
  cursor: not-allowed;
}

/* Re-run Button in Run History */
.run-history-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.run-history-rerun-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.run-history-rerun-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.run-history-rerun-btn:active {
  background: var(--bg-tertiary);
}

.run-history-rerun-btn svg {
  width: 14px;
  height: 14px;
}

/* Progress state for re-run */
.run-history-item.rerunning {
  opacity: 0.7;
  pointer-events: none;
}

.run-history-item.rerunning .run-history-rerun-btn {
  animation: spin 1s linear infinite;
}

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

/* ========================================
   VIEW CALCULATION MODAL
   ======================================== */

.calc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 35, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calc-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.calc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.calc-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.calc-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.calc-modal-close:hover {
  color: var(--text-primary);
}

.calc-modal-body {
  padding: 20px;
  overflow-y: auto;
}

.calc-isin-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.calc-isin {
  font-family: 'Menlo', 'Monaco', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.calc-scrip {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.calc-section {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.calc-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.calc-section-gain {
  background: linear-gradient(135deg, var(--accent-subtle), transparent);
  border: 1px solid var(--accent);
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-size: 0.85rem;
}

.calc-label {
  color: var(--text-secondary);
}

.calc-value {
  font-family: 'Menlo', 'Monaco', monospace;
  font-weight: 500;
  color: var(--text-primary);
}

.calc-value.highlight {
  color: var(--accent-dark);
  font-weight: 600;
}

.calc-row.calc-formula {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.calc-row.calc-subtract .calc-label {
  color: var(--error);
}

.calc-row.calc-result {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-weight: 600;
}

.calc-row.calc-major {
  font-size: 1rem;
  padding: 8px 0;
}

.calc-row.calc-major .calc-value {
  font-size: 1.1rem;
}

.calc-row.calc-final {
  background: var(--surface);
  margin: 8px -12px -12px;
  padding: 12px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.calc-row.calc-final .calc-value {
  font-size: 1.15rem;
  color: var(--success);
}

.calc-row.calc-nature .calc-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* CG Actions column */
.cg-col-actions {
  width: 60px;
  min-width: 60px;
  padding: 4px 8px !important;
}

/* CG Row Action Buttons */
.cg-row-actions {
  display: flex;
  gap: 6px;
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

tr:hover .cg-row-actions {
  opacity: 1;
}

.cg-action-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.cg-action-btn:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.cg-action-btn.bf-apply {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.cg-action-btn.bf-apply:hover {
  background: var(--success);
  color: white;
}

.cg-action-btn.bf-clear {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error);
}

.cg-action-btn.bf-clear:hover {
  background: var(--error);
  color: white;
}

.cg-action-btn svg {
  width: 12px;
  height: 12px;
}

/* Confirmation Dialogs (BF Clear, MIS Combined Clear, etc.) */
.bf-clear-dialog-overlay,
.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 35, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-dialog-icon.danger {
  color: var(--error);
}

.confirm-dialog-warning {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--warning-bg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.confirm-dialog-stats {
  display: flex;
  gap: 24px;
  padding: 12px;
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.confirm-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.confirm-stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.confirm-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* BF Apply Result Dialog */
.bf-result-dialog {
  max-width: 400px;
}

.bf-result-dialog .confirm-dialog-icon {
  color: var(--success);
}

.bf-result-dialog .confirm-dialog-icon.warning {
  color: var(--warning);
}

.bf-result-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.bf-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
}

.bf-result-row.applied {
  border-left-color: var(--success);
  background: rgba(16, 185, 129, 0.08);
}

.bf-result-row.no-balance {
  border-left-color: var(--text-muted);
  background: var(--surface-raised);
}

.bf-result-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.bf-result-value {
  font-size: 0.95rem;
  font-weight: 600;
}

.bf-result-value.applied {
  color: var(--success);
}

.bf-result-value.no-balance {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.bf-result-row.has-balance {
  border-left-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
}

.bf-result-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.bf-available {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.bf-applied-amount {
  font-size: 0.95rem;
  color: var(--success);
  font-weight: 600;
}

.bf-not-applied {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* BF Clear Result Stats */
.bf-clear-result-stats {
  margin-top: 16px;
}

.bf-clear-stats-grid {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.bf-clear-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  min-width: 100px;
}

.bf-clear-stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
}

.bf-clear-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* BF Clear Preview Balance Breakdown */
.bf-clear-preview {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.bf-clear-preview-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
}

.bf-clear-nature-section {
  flex: 1;
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  padding: 12px;
  border-left: 3px solid var(--border);
}

.bf-clear-nature-section.has-setoff {
  border-left-color: var(--warning);
}

.bf-clear-nature-section.no-setoff {
  opacity: 0.7;
}

.bf-clear-nature-header {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.bf-clear-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.85rem;
}

.bf-clear-balance-row.highlight-clear {
  background: rgba(245, 158, 11, 0.1);
  margin: 4px -8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

.bf-clear-balance-row.result {
  font-weight: 600;
}

.bf-clear-balance-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.bf-clear-label {
  color: var(--text-secondary);
}

.bf-clear-value {
  font-weight: 500;
  color: var(--text-primary);
}

.bf-clear-value.dimmed {
  color: var(--text-muted);
}

.bf-clear-value.clearing {
  color: var(--warning);
  font-weight: 600;
}

.bf-clear-value.restored {
  color: var(--success);
}

/* Detected clients - improved styling */
.detected-client-badge.no-match {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
}

/* Per-client BF status in CG table */
.cg-client-bf-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 6px;
}

.cg-client-bf-status.applied {
  background: var(--success-bg);
  color: var(--success);
}

.cg-client-bf-status.pending {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ========================================
   INSTANT TOOLTIPS (CSS-based, no delay)
   ======================================== */

/* Base tooltip styles - applies to elements with data-tooltip attribute */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
  pointer-events: none;
  z-index: 1000;
}

/* Tooltip text box */
[data-tooltip]::after {
  content: attr(data-tooltip);
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: var(--navy);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: pre-line;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: 320px;
  text-align: left;
}

/* Tooltip arrow */
[data-tooltip]::before {
  content: '';
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--navy);
}

/* Show on hover - INSTANT (no delay) */
[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  visibility: visible;
  opacity: 1;
}

/* Tooltip positioned below for buttons in header area */
[data-tooltip-position="bottom"]::after {
  bottom: auto;
  top: calc(100% + 8px);
}

[data-tooltip-position="bottom"]::before {
  bottom: auto;
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: var(--navy);
}

/* NA badge specific tooltip styling */
.badge-na[data-tooltip] {
  cursor: help;
}

.badge-na[data-tooltip]::after {
  max-width: 400px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Button tooltip styling */
.cg-action-btn[data-tooltip]::after {
  white-space: nowrap;
  max-width: none;
}

/* Override cursor for action buttons - only Calc button should have help cursor */
.bf-apply-btn[data-tooltip],
.bf-clear-btn[data-tooltip] {
  cursor: pointer;
}

/* Responsive */
@media (max-width: 480px) {
  .bf-panel {
    width: 100vw;
    max-width: 100vw;
  }

  .confirm-dialog {
    width: 95vw;
  }

  .calc-modal {
    width: 95vw;
    max-height: 90vh;
  }

  [data-tooltip]::after {
    max-width: 280px;
    font-size: 0.7rem;
  }
}

/* ============================================
   GATED UPLOAD NOTICE (Feature 5)
   ============================================ */

.master-upload-gated {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
  gap: 12px;
}

.master-upload-gated .gated-icon {
  color: var(--text-muted);
  opacity: 0.6;
}

.master-upload-gated .gated-message {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.master-upload-gated .gated-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.summary-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.85rem;
  text-decoration: underline;
  transition: color 0.15s ease;
}

.btn-link:hover {
  color: var(--accent-dark);
}

.btn-link:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  text-decoration: none;
}

/* ============================================
   LIST MODAL STYLES (Feature 8)
   ============================================ */

.list-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 29, 35, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.list-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.list-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.list-modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s ease;
}

.list-modal-close:hover {
  color: var(--text-primary);
}

.list-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.list-modal-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

/* Wide variant for modals with more filters */
.list-modal-wide {
  max-width: 1100px;
}

/* Filter row styles */
.list-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.list-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.list-filter-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.list-filter-input {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  width: 150px;
  transition: border-color 0.15s;
}

.list-filter-input:focus {
  outline: none;
  border-color: var(--accent);
}

.list-filter-select {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--surface);
  cursor: pointer;
  min-width: 80px;
}

.list-filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Sortable table headers */
.sortable-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}

.sortable-table th.sortable:hover {
  background: var(--bg-tertiary);
}

.sortable-table th .sort-icon {
  display: inline-block;
  width: 12px;
  margin-left: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.5;
}

.sortable-table th.sorted-asc .sort-icon,
.sortable-table th.sorted-desc .sort-icon {
  opacity: 1;
  color: var(--accent);
}

.sortable-table th.sorted-asc .sort-icon::after {
  content: '▲';
}

.sortable-table th.sorted-desc .sort-icon::after {
  content: '▼';
}

/* Reset button link style */
.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 6px 8px;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--accent);
}

@media (max-width: 768px) {
  .list-filter-row {
    gap: 8px;
  }

  .list-filter-input {
    width: 120px;
  }

  .list-modal-summary {
    width: 100%;
    text-align: right;
    margin-top: 8px;
  }
}

.list-modal-table-container {
  overflow-x: auto;
  flex: 1;
  min-height: 200px;
}

.list-modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.list-modal-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.list-modal-table th.text-right {
  text-align: right;
}

.list-modal-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.list-modal-table td.text-right {
  text-align: right;
}

.list-modal-table td.text-center {
  text-align: center;
}

.list-modal-table tbody tr:hover {
  background: var(--bg-secondary);
}

.list-modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-muted);
}

.list-modal-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.pagination-info {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Badge styles for source */
.badge-platform {
  background: var(--accent-subtle);
  color: var(--accent-dark);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ca {
  background: var(--success-bg);
  color: var(--success);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

@media (max-width: 768px) {
  .list-modal {
    max-height: 90vh;
    max-width: 100%;
  }

  .list-modal-table {
    font-size: 0.85rem;
  }

  .list-modal-table th,
  .list-modal-table td {
    padding: 8px 10px;
  }
}

/* ========================================
   TDS RATES TAB STYLES
   ======================================== */

.tds-rates-form {
  margin-top: 1rem;
}

.tds-rates-form .form-group {
  margin-bottom: 1.25rem;
}

.tds-rates-form .form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.tds-rates-form .form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tds-rates-form .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.tds-rates-form .form-hint {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tds-rates-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 640px) {
  .tds-rates-form .form-row {
    grid-template-columns: 1fr;
  }
}

.tds-rates-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.tds-rates-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.tds-message-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.tds-message-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.tds-message-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* TDS Rate badges in summary card */
#master-tab-tds-rates .summary-stat-value.badge-st {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

#master-tab-tds-rates .summary-stat-value.badge-lt {
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

/* ================================================
   BATCH BF MODAL STYLES (Session 47)
   ================================================ */

/* Batch BF Buttons in CG Statement header */
.batch-bf-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  align-items: center;
}

.batch-bf-buttons .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.batch-bf-buttons .btn svg {
  flex-shrink: 0;
}

/* Batch BF Modal Overlay */
.batch-bf-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 24px;
}

/* Batch BF Modal Container */
.batch-bf-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Modal Header */
.batch-bf-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.batch-bf-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.batch-bf-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.batch-bf-modal-close:hover {
  color: var(--text-primary);
}

/* Modal Loading State */
.batch-bf-modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  gap: 16px;
  color: var(--text-secondary);
}

/* Modal Error State */
.batch-bf-modal-error {
  padding: 24px;
  color: var(--error);
  background: rgba(196, 69, 54, 0.08);
  border-radius: var(--radius-sm);
  margin: 16px 24px;
}

/* Modal Search State */
.batch-bf-modal-search {
  padding: 24px;
}

.batch-bf-modal-search p {
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.batch-bf-search-row {
  display: flex;
  gap: 12px;
}

.batch-bf-search-row input {
  flex: 1;
}

/* Modal Content */
.batch-bf-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Mode/Scope Banner */
.batch-bf-banner {
  background: rgba(184, 147, 75, 0.1);
  border: 1px solid rgba(184, 147, 75, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--accent-dark);
  line-height: 1.6;
}

/* Summary */
.batch-bf-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding: 8px 0;
}

/* Table Container */
.batch-bf-table-container {
  max-height: 350px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

/* Table */
.batch-bf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.batch-bf-table th,
.batch-bf-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.batch-bf-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.batch-bf-table tbody tr:hover {
  background: var(--bg-secondary);
}

.batch-bf-table .text-right {
  text-align: right;
}

/* Disabled row styling */
.batch-bf-client-disabled {
  opacity: 0.6;
  background: var(--bg-tertiary);
}

.batch-bf-client-disabled td {
  color: var(--text-muted);
}

/* Disclaimer */
.batch-bf-disclaimer {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.batch-bf-disclaimer label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.batch-bf-disclaimer input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}

/* Actions */
.batch-bf-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* Results */
.batch-bf-modal-results {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.batch-bf-results-summary {
  margin-bottom: 20px;
}

.batch-bf-results-summary h4 {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.batch-bf-results-summary p {
  margin: 4px 0;
  font-size: 0.9rem;
}

.batch-bf-results-summary .text-success {
  color: var(--success);
}

.batch-bf-results-summary .text-warning {
  color: var(--warning);
}

.batch-bf-results-summary .text-error {
  color: var(--error);
}

.batch-bf-results-details {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.batch-bf-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.batch-bf-results-table th,
.batch-bf-results-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.batch-bf-results-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}

.batch-bf-results-table .text-right {
  text-align: right;
}

.batch-bf-results-table .text-success {
  color: var(--success);
}

.batch-bf-results-table .text-warning {
  color: var(--warning);
}

.batch-bf-results-table .text-error {
  color: var(--error);
}

/* Badge styles for status */
.batch-bf-table .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.batch-bf-table .badge-success {
  background: rgba(45, 138, 94, 0.15);
  color: var(--success);
}

.batch-bf-table .badge-warning {
  background: rgba(193, 127, 36, 0.15);
  color: var(--warning);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Session 48: New badge styles for batch apply preview */
.batch-bf-table .badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.batch-bf-table .badge-secondary {
  background: rgba(107, 114, 128, 0.15);
  color: #6b7280;
}

.batch-bf-table .loss-credit-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ==========================================
   Session 49: BF Clear Scope Selectors
   ========================================== */

/* Row-level clear dialog scope selector */
.bf-clear-scope-selector {
  margin: 1rem 0;
  padding: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.bf-clear-scope-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.bf-clear-scope-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.bf-clear-scope-option input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.bf-clear-scope-option span {
  font-size: 0.9rem;
  color: var(--text);
}

/* Batch clear date indicator */
.batch-bf-clear-date-indicator {
  margin-bottom: 0.75rem;
}

.date-scope-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Batch clear date error */
.batch-bf-clear-date-error {
  text-align: center;
  padding: 2rem;
}

.batch-bf-clear-date-error p {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* BF Status badges for batch clear table */
.bf-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.bf-status-badge.bf-status-eligible {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.bf-status-badge.bf-status-ineligible {
  background: rgba(107, 114, 128, 0.15);
  color: #6b7280;
}
