/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-primary:hover { background: #2565A0; border-color: #2565A0; }

.btn-outline {
  background: var(--white);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--panel-bg); border-color: var(--blue); color: var(--blue); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--panel-bg); color: var(--text-primary); }

.btn-lg { padding: 10px 22px; font-size: 0.9rem; font-weight: 600; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--panel-bg); color: var(--text-primary); }
.btn-icon svg  { width: 16px; height: 16px; }

/* ── Data Sections ──────────────────────────────────────────────────────── */
.data-section {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--white);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.data-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  user-select: none;
}
.section-header:hover { background: #E8EEF5; }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.section-title svg { width: 14px; height: 14px; color: var(--blue); }

.section-toggle svg { width: 14px; height: 14px; transition: transform 0.2s; }
.section-toggle.collapsed svg { transform: rotate(-90deg); }

.section-body { padding: 12px 14px; }
.section-body.collapsed { display: none; }

/* ── Field Rows ─────────────────────────────────────────────────────────── */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--page-bg);
  border: 1px solid transparent;
  transition: border-color var(--transition);
}
.field-row:hover { border-color: var(--border); }
.field-row.full-width { grid-column: 1 / -1; }

.field-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-value-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
}
.field-value.null-value { color: var(--text-muted); font-style: italic; font-weight: 400; }
.field-value.edited     { color: var(--blue); }

.field-original {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: line-through;
  font-family: var(--font-mono);
}

.field-edit-btn {
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.field-row:hover .field-edit-btn { opacity: 1; }
.field-edit-btn:hover { background: var(--border-light); color: var(--blue); }
.field-edit-btn svg { width: 12px; height: 12px; }

.field-input {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 8px;
  border: 1.5px solid var(--blue);
  border-radius: var(--radius-sm);
  background: #EFF6FF;
  color: var(--text-primary);
  width: 100%;
  outline: none;
}

.field-reset-btn {
  font-size: 0.68rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
}
.field-reset-btn:hover { color: var(--danger); }

/* ── Confidence Dots ────────────────────────────────────────────────────── */
.conf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conf-dot.high   { background: var(--success); }
.conf-dot.medium { background: var(--warning); }
.conf-dot.low    { background: var(--danger);  }
.conf-dot.none   { background: var(--border);  }

/* Field background tinting for medium/low confidence */
.field-row.conf-medium { background: #FFFBEB; }
.field-row.conf-low    { background: #FFF5F5; border-color: #FCA5A5; }
.field-row.conf-low .field-edit-btn { opacity: 1; color: var(--danger); }

/* ── Line Items Table ───────────────────────────────────────────────────── */
.items-table-wrap { overflow-x: auto; }

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.items-table th {
  text-align: left;
  padding: 7px 10px;
  background: var(--panel-bg);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.items-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-primary);
  vertical-align: top;
}
.items-table tr:last-child td { border-bottom: none; }
.items-table tr:hover td      { background: var(--page-bg); }
.items-table .amount { text-align: right; }
.items-table .muted  { color: var(--text-muted); font-size: 0.72rem; }

/* ── Totals Summary ─────────────────────────────────────────────────────── */
.totals-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82rem;
}
.totals-row:last-child { border-bottom: none; }
.totals-row.grand {
  padding-top: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--navy);
  border-top: 2px solid var(--navy);
  margin-top: 4px;
}
.totals-label { color: var(--text-secondary); }
.totals-value { font-family: var(--font-mono); font-weight: 500; color: var(--text-primary); }

.amount-words {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--panel-bg);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Extraction Notes ───────────────────────────────────────────────────── */
.extraction-notes {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.note-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--warning);
  padding: 5px 8px;
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
}
.note-item svg { width: 12px; height: 12px; flex-shrink: 0; margin-top: 1px; }
