/* ── Draft review + Financial period pages ──────────────────────────── */

/* Source badges on committed line items */
.source-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
  padding: 1px 5px;
}
.source-manual       { background: #ede9fe; color: #6d28d9; }
.source-extracted    { background: #d1fae5; color: #065f46; }
.source-api_import   { background: #dbeafe; color: #1d4ed8; }

/* New line item form below each table */
.new-line-item-form {
  border-top: 2px dashed #e5e7eb;
  padding: 12px 0 4px;
}

.label-input {
  flex: 2;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.9rem;
  min-width: 180px;
}
.notes-input {
  flex: 1.5;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.9rem;
  min-width: 120px;
}

/* Delete button in line item rows */
.btn-delete {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0 4px;
  text-decoration: underline;
}
.btn-delete:hover { color: #991b1b; }

.flagged-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  padding: 10px 16px;
  margin-bottom: 16px;
  color: #92400e;
  font-weight: 500;
}

/* Summary metrics */
.summary-bar {
  display: flex;
  gap: 16px;
  margin: 20px 0;
}

.metric-card {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}

.metric-value {
  font-size: 1.4rem;
  font-weight: 600;
  color: #111827;
}

.metric-positive .metric-value { color: #059669; }
.metric-negative .metric-value { color: #dc2626; }
.metric-flagged  { border-color: #f59e0b; background: #fffbeb; }
.metric-flagged .metric-value { color: #d97706; }

/* Line items table */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.line-items-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid #e5e7eb;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}

.line-items-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.line-item-row.flagged {
  background: #fffbeb;
}

.line-item-row.flagged:hover {
  background: #fef3c7;
}

/* Subtotal rows — visually separated, bold amount */
.subtotal-row td {
  border-top: 2px solid #d1d5db;
  background: #f9fafb;
  font-weight: 600;
  color: #111827;
}

/* Section header rows — muted category label */
.section-header-row td {
  padding: 20px 12px 4px;
  color: #6b7280;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  border-bottom: none;
  background: transparent;
}

.label-cell { width: 40%; }
.confidence-cell { width: 20%; }
.amount-cell { width: 25%; font-variant-numeric: tabular-nums; }
.action-cell { width: 15%; text-align: right; }

/* Confidence bar */
.confidence-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.2s ease;
}

.confidence-fill.high { background: #22c55e; }
.confidence-fill.low  { background: #f59e0b; }

/* Badges and icons */
.flag-icon   { color: #f59e0b; margin-left: 6px; font-style: normal; }
.edited-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.item-note { color: #9ca3af; margin-left: 4px; cursor: help; }

/* Inline edit form */
.line-item-editing td {
  background: #f9fafb;
  padding: 8px 12px;
}

.inline-edit-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.edit-label { font-weight: 500; color: #374151; flex: 1; min-width: 120px; }

.amount-input {
  width: 140px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.amount-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

/* Action buttons */
.draft-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.btn-primary {
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
.btn-primary:hover { background: #1e40af; }

.btn-danger {
  background: #fff;
  color: #dc2626;
  border: 1px solid #dc2626;
  border-radius: 5px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover { background: #fef2f2; }

.btn-save {
  background: #059669;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-save:hover { background: #047857; }

.edit-link  { color: #3b82f6; font-size: 0.875rem; }
.cancel-link { color: #6b7280; font-size: 0.875rem; }

/* ── Portfolio intelligence query UI ────────────────────────────────── */

.portfolio-intelligence {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 2px solid #e5e7eb;
}

.query-form-wrapper {
  margin-bottom: 24px;
}

.query-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.query-textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}

.query-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

.query-submit { min-width: 80px; white-space: nowrap; }
.query-submit.btn-loading { opacity: 0.7; cursor: not-allowed; }

/* Query entries */
.query-entry {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
}

.query-entry--failed {
  border-color: #fca5a5;
  background: #fef2f2;
}

.query-prompt {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0 0 10px;
  font-style: italic;
}

.query-response {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #111827;
}

.query-response p { margin: 0 0 8px; }
.query-response p:last-child { margin-bottom: 0; }

.query-response--error { color: #dc2626; }

.query-meta {
  margin-top: 10px;
  font-size: 0.75rem;
  color: #9ca3af;
  display: flex;
  gap: 12px;
}

.query-route {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: #6b7280;
}

.query-entry__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.query-entry__header .query-prompt {
  margin: 0;
  flex: 1;
}

.query-delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  color: #d1d5db;
  border-radius: 4px;
  line-height: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.query-entry:hover .query-delete-btn {
  opacity: 1;
}

.query-delete-btn:hover {
  color: #ef4444;
}
