/* ============================================================
   PR314 Invoice Hub — TradeRail Field Portal
   All classes scoped to .pr314-* prefix only.
   ============================================================ */

/* ── Page header ─────────────────────────────────────────── */
.pr314-page-header {
  margin-bottom: 16px;
}

.pr314-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1A1A2E;
  margin: 0 0 4px 0;
}

.pr314-page-subtitle {
  font-size: 0.875rem;
  color: #555;
  margin: 0 0 8px 0;
}

.pr314-tab-ribbon {
  height: 4px;
  background: #E87722;
  border-radius: 2px;
  margin-top: 8px;
  width: 100%;
}

/* ── Lily insight bar ────────────────────────────────────── */
.pr314-lily-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #F3EEFF;
  border: 1px solid #C9B8F2;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: #3B2E6E;
}

.pr314-lily-chip {
  display: inline-block;
  background: #7C5CBF;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pr314-lily-text {
  flex: 1;
}

/* ── Stats row ───────────────────────────────────────────── */
.pr314-stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pr314-stat-pill {
  background: #fff;
  border: 1px solid #E0E0E4;
  border-radius: 8px;
  padding: 12px 18px;
  min-width: 140px;
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.pr314-stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pr314-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1A1A2E;
}

/* ── Action bar ──────────────────────────────────────────── */
.pr314-action-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────── */
.pr314-btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

.pr314-btn:hover {
  opacity: 0.88;
}

.pr314-btn-primary {
  background: #E87722;
  color: #fff;
}

.pr314-btn-secondary {
  background: #F0F0F4;
  color: #1A1A2E;
  border: 1px solid #D0D0D8;
}

.pr314-btn-danger {
  background: #D9272D;
  color: #fff;
}

.pr314-btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
  border-radius: 4px;
  background: #F0F0F4;
  color: #1A1A2E;
  border: 1px solid #D0D0D8;
}

.pr314-btn-approve { background: #1E88E5; color: #fff; border: none; }
.pr314-btn-send    { background: #00897B; color: #fff; border: none; }
.pr314-btn-dispute { background: #F57C00; color: #fff; border: none; }
.pr314-btn-paid    { background: #2E7D32; color: #fff; border: none; }
.pr314-btn-void    { background: #757575; color: #fff; border: none; }

/* Two-tap confirm pulse */
.pr314-confirm-pending {
  border: 2px solid #E87722;
  animation: pr314-pulse 0.6s ease-in-out 2;
}

@keyframes pr314-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(232,119,34,0.5); }
  50%  { box-shadow: 0 0 0 6px rgba(232,119,34,0); }
  100% { box-shadow: 0 0 0 0 rgba(232,119,34,0); }
}

/* ── Invoice table ───────────────────────────────────────── */
.pr314-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #E0E0E4;
  margin-bottom: 24px;
}

.pr314-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.pr314-table thead tr {
  background: #1A1A2E;
  color: #fff;
}

.pr314-table thead th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.pr314-table tbody tr.pr314-inv-row {
  cursor: pointer;
  transition: background 0.1s;
}

.pr314-table tbody tr.pr314-inv-row:nth-child(4n+1) {
  background: #fff;
}

.pr314-table tbody tr.pr314-inv-row:nth-child(4n+3) {
  background: #F7F7FA;
}

.pr314-table tbody tr.pr314-inv-row:hover {
  background: #FFF3E8;
}

.pr314-table tbody td {
  padding: 10px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #EBEBEF;
  color: #222;
}

.pr314-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ── Status badges ───────────────────────────────────────── */
.pr314-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.pr314-badge-draft           { background: #EBEBEB; color: #555; }
.pr314-badge-pending_approval { background: #FFF3CD; color: #856404; }
.pr314-badge-approved        { background: #D0E8FF; color: #0D47A1; }
.pr314-badge-sent            { background: #C8F5F0; color: #00695C; }
.pr314-badge-paid            { background: #C8E6C9; color: #1B5E20; }
.pr314-badge-void            { background: #F0F0F0; color: #999; text-decoration: line-through; }
.pr314-badge-disputed        { background: #FFCDD2; color: #B71C1C; }

/* ── Row detail expand ───────────────────────────────────── */
.pr314-detail-row {
  background: #FAFAFA;
  transition: none;
}

.pr314-detail-cell {
  padding: 0 !important;
}

/* ── Detail panel ────────────────────────────────────────── */
.pr314-detail-panel {
  background: #fff;
  border-left: 4px solid #E87722;
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  animation: pr314-slide-in 0.18s ease;
}

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

.pr314-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.pr314-detail-num {
  font-size: 1.05rem;
  color: #1A1A2E;
}

.pr314-detail-source {
  font-size: 0.8rem;
  background: #EEF0F6;
  color: #444;
  padding: 2px 8px;
  border-radius: 10px;
}

.pr314-detail-link {
  font-size: 0.8rem;
  color: #E87722;
  text-decoration: underline;
}

.pr314-detail-co {
  font-size: 0.8rem;
  color: #666;
}

.pr314-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.pr314-detail-grid > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pr314-detail-lbl {
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 2px;
}

.pr314-detail-timestamps {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.82rem;
  color: #555;
  margin-bottom: 14px;
  padding: 8px 10px;
  background: #F7F7FA;
  border-radius: 6px;
}

/* ── Approval section ────────────────────────────────────── */
.pr314-approval-section {
  background: #FFF8E1;
  border: 1px solid #FFE082;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ── Send panel ──────────────────────────────────────────── */
.pr314-send-panel {
  background: #F4FBF9;
  border: 1px solid #B2DFDB;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pr314-send-mode {
  display: flex;
  gap: 18px;
  font-size: 0.875rem;
}

.pr314-send-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.pr314-lily-disclaimer {
  font-size: 0.78rem;
  color: #6A4BAA;
  background: #F3EEFF;
  border-radius: 4px;
  padding: 6px 10px;
  margin: 0;
}

/* ── Dispute section ─────────────────────────────────────── */
.pr314-dispute-section {
  background: #FFF3E0;
  border: 1px solid #FFCC80;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Dispute resolution ──────────────────────────────────── */
.pr314-dispute-resolution {
  background: #FFEBEE;
  border: 1px solid #EF9A9A;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pr314-dispute-reason {
  font-size: 0.875rem;
  color: #B71C1C;
  margin: 0;
}

/* ── Audit log ───────────────────────────────────────────── */
.pr314-audit-log {
  border-top: 1px solid #EBEBEF;
  padding-top: 10px;
  margin-top: 12px;
}

.pr314-audit-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  color: #666;
}

.pr314-audit-list li::before {
  content: ">";
  margin-right: 4px;
  color: #E87722;
}

/* ── New invoice panel ───────────────────────────────────── */
.pr314-new-invoice-panel {
  background: #fff;
  border: 1px solid #E0E0E4;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.pr314-panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1A1A2E;
  margin: 0 0 16px 0;
}

.pr314-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.pr314-form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pr314-input,
.pr314-select,
.pr314-textarea {
  border: 1px solid #D0D0D8;
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 0.875rem;
  color: #1A1A2E;
  background: #FAFAFA;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.pr314-input:focus,
.pr314-select:focus,
.pr314-textarea:focus {
  border-color: #E87722;
  background: #fff;
}

.pr314-textarea {
  resize: vertical;
  font-family: inherit;
}

.pr314-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ── Row actions ─────────────────────────────────────────── */
.pr314-row-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* ── Queue panel ─────────────────────────────────────────── */
.pr314-queue-panel {
  background: #fff;
  border: 1px solid #E0E0E4;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}

.pr314-queue-item {
  padding: 8px 0;
  border-bottom: 1px solid #EBEBEF;
  font-size: 0.875rem;
  color: #333;
}

/* ── Invoices root wrapper ───────────────────────────────── */
.pr314-invoices-root {
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1A1A2E;
  box-sizing: border-box;
}

/* ── Responsive: mobile < 768px ──────────────────────────── */
@media (max-width: 767px) {
  .pr314-col-period {
    display: none;
  }

  .pr314-stats-row {
    gap: 8px;
  }

  .pr314-stat-pill {
    min-width: 120px;
    padding: 10px 12px;
  }

  .pr314-stat-value {
    font-size: 1.05rem;
  }

  .pr314-table thead th:nth-child(3) {
    display: none;
  }

  .pr314-table tbody td:nth-child(3) {
    display: none;
  }

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

  .pr314-table thead th,
  .pr314-table tbody td {
    padding: 8px 8px;
  }

  .pr314-row-actions {
    flex-direction: column;
    gap: 4px;
  }

  .pr314-btn-sm {
    width: 100%;
    text-align: center;
  }

  .pr314-detail-panel {
    padding: 12px;
  }

  .pr314-detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pr314-send-actions {
    justify-content: flex-start;
  }

  .pr314-action-bar {
    flex-direction: column;
  }

  .pr314-btn-primary,
  .pr314-btn-secondary {
    width: 100%;
  }

  /* Card-style table rows on mobile */
  .pr314-table-wrap {
    border: none;
    border-radius: 0;
  }

  .pr314-table,
  .pr314-table thead,
  .pr314-table tbody,
  .pr314-table th,
  .pr314-table td,
  .pr314-table tr {
    display: block;
  }

  .pr314-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .pr314-table tbody tr.pr314-inv-row {
    border: 1px solid #E0E0E4;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #fff;
    padding: 4px 0;
  }

  .pr314-table tbody td {
    border: none;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .pr314-table tbody td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    min-width: 80px;
    flex-shrink: 0;
  }
}
