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

:root {
  --accent: #1a5c3a;
  --accent-light: #e8f4ee;
  --bg: #faf9f7;
  --surface: #ffffff;
  --border: #e2e0dc;
  --text: #1c1c1a;
  --muted: #6b6860;
  --danger: #c0392b;
  --radius: 6px;
  --font-head: 'Instrument Serif', Georgia, serif;
  --font-body: 'Satoshi', -apple-system, sans-serif;
}

body.sp-body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  margin: 0;
  min-height: 100vh;
  line-height: 1.6;
}

.sp-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Header */
.sp-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.sp-wordmark {
  font-family: var(--font-head);
  font-size: 1.05rem;
  color: var(--accent);
  letter-spacing: -0.01em;
  display: block;
  margin-bottom: 0.25rem;
}
.sp-page-title {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.2;
}

/* Alert */
.sp-alert {
  background: #fdf0ef;
  border: 1px solid #f5c0bc;
  border-left: 3px solid var(--danger);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Form Sections */
.sp-form { display: flex; flex-direction: column; gap: 0; }

.sp-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.sp-section-title {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 400;
  margin: 0 0 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  letter-spacing: -0.02em;
}

/* Fields */
.sp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 540px) { .sp-row { grid-template-columns: 1fr; } }

.sp-field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.sp-field:last-child { margin-bottom: 0; }
.sp-field.sp-field-sm { margin-bottom: 0; }

.sp-field label, .sp-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sp-required { color: var(--accent); }
.sp-hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); opacity: 0.8; }
.sp-hint-block { font-size: 0.85rem; color: var(--muted); margin: -0.5rem 0 1rem; }

input[type="text"],
input[type="number"],
select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,92,58,0.1);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6860' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.sp-input-prefix, .sp-input-suffix {
  display: flex;
  align-items: center;
}
.sp-prefix, .sp-suffix {
  background: var(--border);
  border: 1px solid var(--border);
  padding: 0.55rem 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1;
}
.sp-prefix { border-right: none; border-radius: var(--radius) 0 0 var(--radius); }
.sp-suffix { border-left: none; border-radius: 0 var(--radius) var(--radius) 0; }
.sp-input-prefix input, .sp-input-suffix input {
  border-radius: 0 var(--radius) var(--radius) 0;
  flex: 1;
  min-width: 0;
}
.sp-input-suffix input { border-radius: var(--radius) 0 0 var(--radius); }

/* Fee radios */
.sp-fee-radios {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}
.sp-fee-radios .sp-label { margin-right: 0.5rem; white-space: nowrap; }
.sp-radio {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.sp-radio input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* Liens */
.sp-lien-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  transition: background 0.15s;
}
.sp-lien-row:last-child { margin-bottom: 0; }
.sp-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
}
.sp-checkbox input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.sp-lien-detail { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px dashed var(--border); }
.sp-lien-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 400px) { .sp-lien-fields { grid-template-columns: 1fr; } }

/* Actions */
.sp-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.sp-btn-primary, .sp-btn-secondary, .sp-btn-outline {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}
.sp-btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,92,58,0.2);
}
.sp-btn-primary:hover { background: #155030; box-shadow: 0 4px 14px rgba(26,92,58,0.3); transform: translateY(-1px); }
.sp-btn-secondary {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(26,92,58,0.2);
}
.sp-btn-secondary:hover { background: #d4ecde; transform: translateY(-1px); }
.sp-btn-outline {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.sp-btn-outline:hover { background: var(--surface); color: var(--text); border-color: var(--text); }

/* Result view */
.sp-meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}
.sp-badge {
  background: var(--accent);
  color: #fff;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.sp-meta-item { color: var(--muted); }
.sp-label-pill {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-style: italic;
}

.sp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}

.sp-line-table { width: 100%; border-collapse: collapse; }
.sp-line-table thead th {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.sp-line-table th.sp-num, .sp-line-table td.sp-num { text-align: right; }
.sp-line-table tbody tr { border-bottom: 1px solid var(--border); }
.sp-line-table tbody tr:last-child { border-bottom: none; }
.sp-line-table tbody tr:nth-child(even) { background: #fdfcfb; }
.sp-line-table td { padding: 0.65rem 1rem; font-size: 0.9rem; }

.sp-line-gross td { font-weight: 600; }
.sp-line-deduction .sp-line-amount, .sp-line-fee .sp-line-amount, .sp-line-lien .sp-line-amount { color: var(--danger); }
.sp-negative { color: var(--danger); }

.sp-line-net td {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  background: var(--accent-light);
  border-top: 2px solid var(--accent);
}

.sp-callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}
.sp-callout-label { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.sp-callout-value { font-weight: 700; color: var(--text); }
.sp-callout-mode { color: var(--muted); font-size: 0.82rem; }

@media print {
  body.sp-body { background: #fff; }
  .sp-actions { display: none; }
  .sp-shell { padding: 0; max-width: 100%; }
  .sp-section, .sp-card, .sp-callout { border: 1px solid #ccc; box-shadow: none; }
  .sp-page-title { font-size: 1.5rem; }
  body.sp-body { font-family: Georgia, serif; }
}
