/* ═══════════════════════════════════════════════════════════════
   Invoice Agent — Apple Human Interface–inspired stylesheet
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Tint — Apple's system blue */
  --tint: #007AFF;
  --tint-hover: #0066D6;
  --tint-bg: rgba(0, 122, 255, 0.08);
  --tint-ring: rgba(0, 122, 255, 0.25);

  /* Semantic */
  --red: #FF3B30;
  --red-hover: #E0332A;
  --red-bg: rgba(255, 59, 48, 0.08);
  --orange: #FF9500;
  --orange-bg: rgba(255, 149, 0, 0.08);
  --green: #34C759;
  --green-hover: #2DB24E;
  --green-bg: rgba(52, 199, 89, 0.08);

  /* Surfaces */
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --surface-secondary: #F9F9FB;
  --surface-tertiary: #F2F2F7;
  --surface-hover: #F5F5FA;

  /* Separators */
  --separator: rgba(60, 60, 67, 0.12);
  --separator-opaque: #C6C6C8;

  /* Text — Apple's label hierarchy */
  --label: #1D1D1F;
  --label-secondary: #86868B;
  --label-tertiary: #AEAEB2;
  --label-quaternary: #C7C7CC;

  /* Metrics */
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  /* Elevation */
  --shadow-sm: 0 0.5px 1px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 2px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 2px 8px rgba(0,0,0,0.06), 0 8px 32px rgba(0,0,0,0.08);

  /* Motion — Apple spring-like curves */
  --ease: 0.28s cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

/* ── Dark Mode ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --tint: #0A84FF;
  --tint-hover: #409CFF;
  --tint-bg: rgba(10, 132, 255, 0.16);
  --tint-ring: rgba(10, 132, 255, 0.4);

  --red: #FF453A;
  --red-hover: #FF6961;
  --red-bg: rgba(255, 69, 58, 0.16);
  --orange: #FF9F0A;
  --orange-bg: rgba(255, 159, 10, 0.16);
  --green: #30D158;
  --green-hover: #4ADE80;
  --green-bg: rgba(48, 209, 88, 0.16);

  --bg: #000000;
  --surface: #1C1C1E;
  --surface-secondary: #2C2C2E;
  --surface-tertiary: #3A3A3C;
  --surface-hover: #38383A;

  --separator: rgba(84, 84, 88, 0.65);
  --separator-opaque: #38383A;

  --label: #F5F5F7;
  --label-secondary: #98989D;
  --label-tertiary: #636366;
  --label-quaternary: #48484A;

  --shadow-sm: 0 0.5px 1px rgba(0,0,0,0.3);
  --shadow: 0 1px 4px rgba(0,0,0,0.35), 0 2px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 2px 8px rgba(0,0,0,0.4), 0 8px 32px rgba(0,0,0,0.3);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Body ──────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
               'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--label);
  line-height: 1.47059;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.hidden {
  display: none !important;
}

/* ── Header ────────────────────────────────────────────────── */
header {
  margin-bottom: 32px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--label);
}

.subtitle {
  color: var(--label-secondary);
  font-size: 13px;
  font-weight: 400;
  margin-top: 2px;
  letter-spacing: -0.003em;
}

/* ── Clio Status Bar ───────────────────────────────────────── */
.clio-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease);
}

.clio-status-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--label-secondary);
}

.clio-status-right {
  display: flex;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-bg);
}

.status-dot.disconnected {
  background: var(--label-tertiary);
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-bg);
}

.status-dot.warning {
  background: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-bg);
}

/* ── Poller Status Cards ──────────────────────────────────── */
.poller-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}

.poller-status-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.poller-icon {
  color: var(--label-tertiary);
  flex-shrink: 0;
}

.poller-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.poller-folder {
  font-weight: 600;
  font-size: 13px;
  color: var(--label);
}

.poller-schedule {
  font-size: 11px;
  color: var(--label-tertiary);
}

.poller-status-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.poller-meta {
  font-size: 11px;
  color: var(--label-secondary);
}

.poller-status.polling .poller-icon {
  color: var(--tint);
  animation: spin 1s linear infinite;
}

/* ── Dashboard Stats ───────────────────────────────────────── */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease), box-shadow var(--ease);
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--label);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  color: var(--label-tertiary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* ── Mode Switcher ────────────────────────────────────────── */
.mode-switcher {
  display: flex;
  gap: 4px;
  background: var(--surface-tertiary);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 15px;
  font-weight: 500;
  color: var(--label);
  cursor: pointer;
  transition: all var(--ease);
  letter-spacing: -0.01em;
}

.mode-btn:hover {
  background: rgba(0,0,0,0.05);
}

[data-theme="dark"] .mode-btn:hover {
  background: rgba(255,255,255,0.07);
}

.mode-btn.active {
  color: #fff;
  background: var(--tint);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08);
}

.mode-btn.active:hover {
  background: var(--tint-hover);
  color: #fff;
}

.mode-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Segmented Control (Tabs) ──────────────────────────────── */
.tab-nav {
  display: flex;
  background: var(--surface-tertiary);
  border-radius: var(--radius-xs);
  padding: 2px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--label-secondary);
  cursor: pointer;
  transition: all var(--ease);
  position: relative;
  letter-spacing: -0.003em;
}

.tab-btn:hover {
  color: var(--label);
}

.tab-btn.active {
  color: var(--label);
  background: var(--surface);
  box-shadow: 0 0.5px 2px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.06);
  font-weight: 600;
}

[data-theme="dark"] .tab-btn.active {
  box-shadow: 0 0.5px 2px rgba(0,0,0,0.4);
}

.tab-content {
  min-height: 200px;
}

/* ── Badge ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* ── Buttons — Apple "Filled" + "Gray" + "Tinted" ─────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
  letter-spacing: -0.003em;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
  opacity: 0.85;
}

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

.btn-sm {
  padding: 6px 14px;
  border-radius: 7px;
}

.btn-md {
  padding: 10px 24px;
  font-size: 15px;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--tint);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--tint-hover);
}

.btn-secondary {
  background: var(--surface-tertiary);
  color: var(--label);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

[data-theme="dark"] .btn-secondary {
  background: var(--surface-secondary);
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: var(--surface-tertiary);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-hover);
}

.btn-success {
  background: var(--green);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: var(--green-hover);
}

.btn-warning {
  background: var(--orange);
  color: #fff;
}

.btn-warning:hover:not(:disabled) {
  opacity: 0.9;
}

/* ── Queue Filters ─────────────────────────────────────────── */
.queue-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-input,
.filter-select {
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--surface);
  color: var(--label);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease);
}

.filter-input {
  flex: 1;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--tint-ring), var(--shadow-sm);
}

.filter-input::placeholder {
  color: var(--label-tertiary);
}

.filter-select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2386868B' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ── Drop Zone ─────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--separator-opaque);
  border-radius: var(--radius-lg);
  padding: 64px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--ease);
  background: var(--surface);
  position: relative;
}

.drop-zone:hover {
  border-color: var(--tint);
  background: var(--tint-bg);
}

.drop-zone.drag-over {
  border-color: var(--tint);
  background: var(--tint-bg);
  transform: scale(1.005);
  box-shadow: 0 0 0 4px var(--tint-ring);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  width: 40px;
  height: 40px;
  color: var(--label-tertiary);
  margin-bottom: 16px;
  transition: color var(--ease);
}

.drop-zone:hover .upload-icon,
.drop-zone.drag-over .upload-icon {
  color: var(--tint);
}

.drop-zone p {
  color: var(--label);
  font-size: 15px;
  font-weight: 600;
}

.drop-zone-hint {
  font-size: 13px;
  color: var(--label-tertiary) !important;
  font-weight: 400 !important;
  margin-top: 2px;
}

.drop-zone-formats {
  font-size: 12px;
  color: var(--label-quaternary) !important;
  margin-top: 12px;
  font-weight: 400 !important;
}

/* ── Error Banner ──────────────────────────────────────────── */
.error-banner {
  background: var(--red-bg);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-size: 13px;
  font-weight: 500;
  animation: slideDown 0.35s var(--ease);
}

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

/* ── Duplicate Warning ─────────────────────────────────────── */
.duplicate-warning {
  background: var(--orange-bg);
  color: #CC7700;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

[data-theme="dark"] .duplicate-warning {
  color: var(--orange);
}

/* ── Sections ──────────────────────────────────────────────── */
.section {
  margin-top: 24px;
}

.section h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

/* ── Queue List ────────────────────────────────────────────── */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--separator);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Remove gap-based separator when empty */
.queue-list:empty,
.queue-list:has(.empty-state) {
  background: transparent;
  box-shadow: none;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  padding: 14px 20px;
  transition: background var(--ease);
}

.queue-item:hover {
  background: var(--surface-hover);
}

.queue-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.queue-item:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

.queue-item:only-child {
  border-radius: var(--radius);
}

.queue-item.has-duplicate {
  border-left: 3px solid var(--orange);
}

.queue-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.queue-item-filename {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.003em;
}

.queue-item-source {
  font-size: 10px;
  color: var(--label-tertiary);
  background: var(--surface-tertiary);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.queue-item-meta {
  font-size: 13px;
  color: var(--label-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Category Badge ────────────────────────────────────────── */
.category-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--tint-bg);
  color: var(--tint);
  white-space: nowrap;
  font-weight: 500;
}

/* ── Status Badges ─────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.status-pending {
  background: var(--surface-tertiary);
  color: var(--label-tertiary);
}

.status-extracting,
.status-parsing,
.status-matching {
  background: var(--tint-bg);
  color: var(--tint);
}

.status-ready {
  background: var(--green-bg);
  color: var(--green);
}

.status-submitting {
  background: var(--orange-bg);
  color: var(--orange);
}

.status-complete {
  background: var(--green-bg);
  color: var(--green);
}

.status-skipped {
  background: var(--orange-bg);
  color: var(--orange);
}

.status-error {
  background: var(--red-bg);
  color: var(--red);
}

.spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Review Panel ──────────────────────────────────────────── */
.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.review-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.review-card + .review-card {
  margin-top: 12px;
}

.review-card h3 {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Invoice Details Grid ──────────────────────────────────── */
.invoice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.field-group.full-width {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-value {
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 15px;
  background: var(--surface-tertiary);
  color: var(--label);
  width: 100%;
  transition: box-shadow var(--ease);
  font-family: inherit;
}

.field-value:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--tint-ring);
}

select.field-value {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2386868B' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ── Line Items Table ──────────────────────────────────────── */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 4px;
}

.line-items-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--separator);
  color: var(--label-tertiary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.line-items-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--separator);
  vertical-align: top;
  color: var(--label);
}

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

.line-items-table tbody tr {
  transition: background var(--ease);
}

.line-items-table tbody tr:hover {
  background: var(--surface-secondary);
}

/* ── Matter Matching ───────────────────────────────────────── */
.matter-matches {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.match-group {
  padding: 16px;
  background: var(--surface-secondary);
  border-radius: var(--radius-sm);
}

.match-group-ref {
  font-size: 12px;
  font-weight: 600;
  color: var(--label-secondary);
  margin-bottom: 8px;
}

.match-candidate {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--ease);
}

.match-candidate:hover {
  background: var(--surface-hover);
}

.match-candidate input[type="radio"] {
  flex-shrink: 0;
  accent-color: var(--tint);
  width: 16px;
  height: 16px;
}

.match-candidate-info {
  flex: 1;
  min-width: 0;
}

.match-candidate-number {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.003em;
}

.match-candidate-desc {
  font-size: 13px;
  color: var(--label-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-candidate-score {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.score-high  { background: var(--green-bg);  color: var(--green); }
.score-medium { background: var(--orange-bg); color: var(--orange); }
.score-low   { background: var(--red-bg);    color: var(--red); }

/* ── Manual Matter Search ──────────────────────────────────── */
.matter-search {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.matter-search input {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 15px;
  background: var(--surface-tertiary);
  color: var(--label);
  transition: box-shadow var(--ease);
  font-family: inherit;
}

.matter-search input::placeholder {
  color: var(--label-tertiary);
}

.matter-search input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--tint-ring);
}

.search-results {
  margin-top: 8px;
}

/* ── Split Invoice ─────────────────────────────────────────── */
.split-section {
  margin-top: 16px;
  padding: 20px;
  background: var(--surface-secondary);
  border-radius: var(--radius);
}

.split-row {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.split-row .field-group {
  margin-bottom: 0;
}

.split-total {
  font-size: 13px;
  color: var(--label-secondary);
  margin-top: 10px;
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.split-total.over-budget {
  color: var(--red);
  font-weight: 700;
}

/* ── Submit Section ────────────────────────────────────────── */
.submit-section {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--separator);
}

/* ── Auto-Submit Banner ────────────────────────────────────── */
.auto-submit-banner {
  background: var(--green-bg);
  color: #1A8438;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 500;
}

[data-theme="dark"] .auto-submit-banner {
  color: var(--green);
}

/* ── Success Message ───────────────────────────────────────── */
.success-msg {
  background: var(--green-bg);
  color: var(--green);
  padding: 20px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  text-align: center;
  font-weight: 600;
  animation: slideDown 0.35s var(--ease);
}

/* ── History List ──────────────────────────────────────────── */
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  padding: 14px 20px;
  transition: background var(--ease);
}

.history-item:hover {
  background: var(--surface-hover);
}

.history-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.history-item-vendor {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.003em;
}

.history-item-details {
  font-size: 12px;
  color: var(--label-secondary);
}

.history-item-right {
  text-align: right;
  flex-shrink: 0;
}

.history-item-amount {
  font-weight: 700;
  font-size: 17px;
  color: var(--label);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.history-item-date {
  font-size: 12px;
  color: var(--label-tertiary);
  margin-top: 1px;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  color: var(--label-tertiary);
  text-align: center;
  padding: 48px 16px;
  font-size: 15px;
  font-weight: 400;
}

/* ── Review Layout (Side-by-Side Preview) ─────────────────── */
.container.review-active {
  max-width: 1400px;
  transition: max-width var(--ease);
}

.review-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ── Preview Card ─────────────────────────────────────────── */
.preview-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 24px;
}

.preview-card h3 {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.preview-iframe {
  width: 100%;
  height: 70vh;
  min-height: 500px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-xs);
  background: var(--surface-tertiary);
}

/* ── Non-PDF Fallback ─────────────────────────────────────── */
.preview-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}

.preview-fallback-icon {
  color: var(--label-tertiary);
  margin-bottom: 4px;
}

.preview-fallback-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--label);
  word-break: break-all;
}

.preview-fallback-type {
  font-size: 13px;
  color: var(--label-secondary);
}

/* ── Responsive: Preview stacks at narrow viewports ───────── */
@media (max-width: 1100px) {
  .container.review-active {
    max-width: 920px;
  }

  .review-layout {
    grid-template-columns: 1fr;
  }

  .preview-card {
    position: static;
  }

  .preview-iframe {
    height: 50vh;
    min-height: 400px;
  }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .container {
    padding: 20px 16px 48px;
  }

  header h1 {
    font-size: 24px;
  }

  .dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .invoice-grid {
    grid-template-columns: 1fr;
  }

  .clio-status {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .queue-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .queue-item-right {
    width: 100%;
    justify-content: flex-end;
  }

  .split-row {
    grid-template-columns: 1fr;
  }

  .tab-btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .stat-value {
    font-size: 22px;
  }
}
