/* ============================================================
   CMC Inc — Customer Payment Portal
   Brand: Green #4E7A52
   ============================================================ */

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

:root {
  --primary: #4E7A52;
  --primary-dark: #3a5c3e;
  --accent: #4E7A52;
  --accent-hover: #3a5c3e;
  --bg: #f0f4f0;
  --card-bg: #fff;
  --border: #e2e5ea;
  --text: #1a2e1a;
  --muted: #6b7280;
  --success: #16a34a;
  --paid-bg: #f0fdf4;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  line-height: 1.5;
}

/* ── Header ── */
.site-header {
  background: var(--primary);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-header .brand { color: #fff; }
.site-header .brand h1 { font-size: 17px; font-weight: 800; letter-spacing: -.3px; }
.site-header .brand p { font-size: 11px; color: rgba(255,255,255,.65); margin-top: 1px; }
.header-accent { height: 3px; background: #2d4d30; }

/* ── Container ── */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Card ── */
.card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 2px 16px rgba(0,0,0,.08);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 16px; font-weight: 700; color: var(--primary); }
.card-header p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.card-body { padding: 24px; }

/* ── Lookup Form ── */
.lookup-icon { font-size: 36px; text-align: center; margin-bottom: 16px; }
.lookup-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.lookup-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 13px 16px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
  color: var(--text);
}
.lookup-input:focus { border-color: var(--primary); }
.lookup-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 15px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .3px;
  transition: background .2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Invoice Cards ── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 12px;
  padding: 0 24px;
}
.section-title:not(:first-child) { margin-top: 28px; }

.invoice-card {
  margin: 0 16px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.invoice-card:hover { border-color: var(--primary); box-shadow: 0 2px 12px rgba(78,122,82,.1); }
.invoice-card.paid {
  background: var(--paid-bg);
  border-color: #bbf7d0;
  opacity: .85;
}

.inv-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.inv-num { font-size: 13px; font-weight: 700; color: var(--primary); }
.inv-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
}
.inv-badge.open { background: #fef3c7; color: #92400e; }
.inv-badge.partial { background: #dbeafe; color: #1e40af; }
.inv-badge.paid { background: #dcfce7; color: #166534; }

.inv-desc { font-size: 14px; color: var(--text); margin-bottom: 10px; font-weight: 500; }
.inv-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.inv-meta span strong { color: var(--text); }

.inv-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.btn-pay {
  flex: 1;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}
.btn-pay:hover { background: var(--accent-hover); }
.btn-pdf {
  padding: 11px 16px;
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-pdf:hover { border-color: var(--primary); color: var(--primary); }

.paid-check { font-size: 13px; color: var(--success); font-weight: 600; }

/* ── Empty / Error States ── */
.empty-state {
  text-align: center;
  padding: 40px 24px;
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--muted); line-height: 1.6; }
.empty-state a { color: var(--accent); text-decoration: none; font-weight: 600; }
.empty-state a:hover { text-decoration: underline; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0 20px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background .2s;
  background: transparent;
  border: none;
}
.back-link:hover { background: rgba(0,0,0,.04); }

/* ── Payment Page ── */
.pay-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 2px 16px rgba(0,0,0,.08);
  overflow: hidden;
  max-width: 480px;
  margin: 0 auto;
}
.pay-header { background: var(--primary); padding: 24px 28px; }
.pay-header h1 { color: #fff; font-size: 18px; font-weight: 800; }
.pay-header p { color: rgba(255,255,255,.65); font-size: 12px; margin-top: 4px; }
.pay-divider { height: 3px; background: #2d4d30; }

.inv-summary {
  background: #f8f9fb;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}
.inv-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 5px 0;
}
.inv-summary-row .lbl { color: var(--muted); }
.inv-summary-row .val { font-weight: 600; }

.amount-display {
  font-size: 36px;
  font-weight: 900;
  color: var(--primary);
  text-align: center;
  margin: 20px 0 4px;
  letter-spacing: -1px;
}
.amount-label { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 24px; }

.method-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  margin-bottom: 12px;
}
.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.method-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  transition: all .2s;
}
.method-card:hover { border-color: var(--primary); }
.method-card.selected { border-color: var(--accent); background: #f0fdf0; }
.method-card .m-icon { font-size: 24px; margin-bottom: 6px; }
.method-card .m-name { font-size: 13px; font-weight: 700; }
.method-card .m-fee { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 3px; }
.method-card .m-fee-amt { font-size: 11px; color: var(--muted); margin-top: 2px; }

.summary-box {
  background: #f8f9fb;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}
.summary-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.summary-row.total {
  font-weight: 700;
  font-size: 15px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 10px;
}

.form-section { margin-bottom: 14px; }
.input-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; display: block; }
.field-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.field-input:focus { border-color: var(--primary); }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.secure-note {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
}

/* ── Success Screen ── */
.success-screen { text-align: center; padding: 48px 28px; }
.success-screen .s-icon { font-size: 56px; margin-bottom: 16px; }
.success-screen h2 { font-size: 22px; font-weight: 800; color: var(--primary); margin-bottom: 10px; }
.success-screen p { font-size: 14px; color: var(--muted); line-height: 1.7; }

/* ── Footer ── */
.site-footer {
  background: #f8f9fb;
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.8;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .inv-actions { flex-direction: column; }
  .btn-pdf { text-align: center; }
  .input-row { grid-template-columns: 1fr; }
}
