/* ────────────── PURCHASE ORDERS ────────────── */
.pos-view {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-8);
}

/* Toolbar */
.pos-toolbar { margin-bottom: var(--space-5); }
.pos-toolbar-top {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.pos-filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pos-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: var(--bg-surface);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) ease;
  font-family: var(--font-body);
}
.pos-pill:hover {
  border-color: rgba(var(--brand-primary-rgb),0.3);
  color: var(--text-primary);
}
.pos-pill.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
.pos-pill-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: rgba(0,0,0,0.08);
  border-radius: 9px;
  font-size: 11px;
  text-align: center;
  font-weight: 600;
}
.pos-pill.active .pos-pill-count { background: rgba(255,255,255,0.25); color: #fff; }

.pill-dot-review  { background: #f59e0b; }
.pill-dot-parsed  { background: #258acb; }
.pill-dot-manual  { background: #94a3b8; }
.pos-pill.active .pill-dot { background: rgba(255,255,255,0.7); }

.pos-toolbar-right {
  display: flex;
  gap: var(--space-3);
  margin-left: auto;
  align-items: center;
}
.pos-search-wrap { position: relative; }
.pos-search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.4;
}
.pos-search {
  padding: 7px 12px 7px 32px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: var(--radius-md);
  font-size: 13px;
  width: 220px;
  background: var(--bg-surface);
  font-family: var(--font-body);
  transition: border-color var(--dur-fast) ease;
}
.pos-search:focus { outline: none; border-color: var(--brand-primary); }
.pos-sort-select {
  padding: 7px 28px 7px 12px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color var(--dur-fast) ease;
}
.pos-sort-select:hover { border-color: rgba(var(--brand-primary-rgb), 0.30); }
/* Slightly tighter padding than the global .btn so it lines up with the
   32px-tall search/select/refresh utility row in the toolbar. */
.pos-new-btn { padding: 7px 14px; }

/* ── Toolbar utility buttons (match .quotes-search / .quotes-sort-select height + look) ── */
.pos-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--dur-fast) ease, color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.pos-icon-btn:hover {
  border-color: rgba(var(--brand-primary-rgb), 0.30);
  color: var(--brand-primary);
}
.pos-icon-btn:focus { outline: none; border-color: var(--brand-primary); }
.pos-icon-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.pos-icon-btn svg { flex-shrink: 0; }
.pos-icon-btn.working .pos-icon-btn-label::after { content: '…'; margin-left: 2px; }

/* Refresh — circular, mirrors .dash-refresh */
.pos-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 50%;
  background: var(--bg-surface);
  font-size: 16px;
  font-family: var(--font-body);
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) ease;
}
.pos-refresh-btn:hover {
  border-color: rgba(var(--brand-primary-rgb), 0.30);
  color: var(--brand-primary);
  transform: rotate(90deg);
}
.pos-refresh-btn.spinning {
  animation: pos-spin 600ms linear;
}
@keyframes pos-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@media (max-width: 720px) {
  .pos-icon-btn-label { display: none; }
  .pos-icon-btn       { padding: 7px 10px; }
}

/* List */
.pos-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pos-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}
.pos-card:hover {
  border-color: rgba(var(--brand-primary-rgb),0.35);
  box-shadow: 0 2px 10px rgba(15,23,42,0.06);
  transform: translateY(-1px);
}
.pos-card.needs-review {
  border-left: 4px solid #f59e0b;
}
.pos-review-stripe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fef3c7;
  color: #b45309;
  font-weight: 700;
  font-size: 12px;
}
.pos-card-main { flex: 1; min-width: 0; }
.pos-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}
.pos-card-num { color: var(--text-secondary); font-weight: 500; }
.pos-card-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pos-ai-badge {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(37,138,203,0.10);
  color: #258acb;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.pos-card-meta {
  text-align: right;
  flex-shrink: 0;
}
.pos-card-total {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}
.pos-card-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.pos-empty, .pos-empty-inline {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.pos-empty-icon { font-size: 40px; margin-bottom: 12px; }
.pos-empty-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.pos-empty-sub { font-size: 13px; margin-bottom: 18px; }

/* Tab badge in header */
#tabPOs .tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: #f59e0b;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}

/* ────────────── PO DRAWER ────────────── */
.po-detail-drawer {
  width: 720px;
  max-width: 100%;
}
.po-detail {
  padding: 0;
}
.po-detail-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.po-meta-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,0.05);
  color: var(--text-secondary);
  text-transform: capitalize;
}
.po-meta-pill-email  { background: rgba(37,138,203,0.10); color: #258acb; }
.po-meta-pill-manual { background: rgba(148,163,184,0.18); color: #475569; }
.po-needs-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: #fef3c7;
  color: #b45309;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.po-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  margin-bottom: 14px;
}
.po-field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 3px;
}
.po-field-value {
  font-size: 14px;
  color: var(--text-primary);
  word-wrap: break-word;
}
.po-field-empty { color: rgba(0,0,0,0.25); }

.po-detail-notes {
  padding: 10px 14px;
  background: rgba(0,0,0,0.03);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 13px;
}

.po-section-h {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 18px 0 10px;
}

/* Line items table */
.po-li-wrap { overflow-x: auto; }
.po-li-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.po-li-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 8px 6px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.po-li-table th.num { text-align: right; }
.po-li-table td {
  padding: 10px 6px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  vertical-align: top;
}
.po-li-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.po-li-table tr.po-li-review td { background: rgba(245,158,11,0.05); }
.po-li-empty { text-align: center; color: rgba(0,0,0,0.4); font-style: italic; }
.po-li-product {
  margin-top: 3px;
  font-size: 11px;
  color: #258acb;
}

.po-match-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.po-match-exact    { background: rgba(34,197,94,0.12);  color: #15803d; }
.po-match-sku_only { background: rgba(37,138,203,0.12); color: #258acb; }
.po-match-fuzzy    { background: rgba(245,158,11,0.12); color: #b45309; }
.po-match-unmatched{ background: rgba(239,68,68,0.12);  color: #b91c1c; }
.po-match-manual   { background: rgba(148,163,184,0.18); color: #475569; }

/* Attachments */
.po-att-list { display: flex; flex-direction: column; gap: 6px; }
.po-att-from {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.03);
  border-radius: 6px;
}
.po-att-link {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(37,138,203,0.06);
  border: 1px solid rgba(37,138,203,0.18);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #258acb;
  text-decoration: none;
  width: fit-content;
}
.po-att-link:hover { background: rgba(37,138,203,0.12); }
.po-att-link.disabled { opacity: 0.5; cursor: not-allowed; }
.po-att-empty, .po-att-loading { font-size: 12px; color: var(--text-secondary); padding: 10px; }

/* Edit / new form */
.po-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.po-form-field { display: flex; flex-direction: column; }
.po-form-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 3px;
}
.po-form-input,
.po-form-textarea {
  padding: 7px 10px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-body);
  background: #fff;
}
.po-form-textarea-label {
  display: flex;
  flex-direction: column;
  margin: 14px 0;
}
.po-form-textarea { resize: vertical; }

.po-li-edit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.po-li-edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr 70px 90px 90px 30px;
  gap: 6px;
}
.po-li-input {
  padding: 6px 8px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-body);
  min-width: 0;
}
.po-li-input.num { text-align: right; font-variant-numeric: tabular-nums; }
.po-li-del {
  border: 1px solid rgba(0,0,0,0.10);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: rgba(0,0,0,0.4);
  font-size: 12px;
}
.po-li-del:hover { color: #ef4444; border-color: #ef4444; }
.po-add-li {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-md);
}

.po-footer-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid rgba(0,0,0,0.06);
  background: #fff;
}
.btn-secondary {
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary:hover { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.18); }
.btn-danger {
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid #ef4444;
  background: #ef4444;
  color: #fff;
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover { background: #dc2626; }

.po-detail-loading, .po-detail-error {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
}
.po-detail-error { color: #b91c1c; }
