:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #15181e;
  --muted: #6b7280;
  --border: #e3e6eb;
  --accent: #0f7a4a;
  --accent-soft: #e8f5ee;
  --danger: #b42318;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #eef0f3;
    --muted: #9aa1ac;
    --border: #2a2f38;
    --accent: #3ccf8e;
    --accent-soft: #15291f;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #181b21;
  --text: #eef0f3;
  --muted: #9aa1ac;
  --border: #2a2f38;
  --accent: #3ccf8e;
  --accent-soft: #15291f;
  --danger: #ff8a80;
  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: 32px 16px 40px;
}

/* En-tête */
.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.header p {
  margin: 4px 0 0;
  color: var(--muted);
}

/* Choix du service */
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--border);
  border-radius: var(--radius);
}

.modes button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.modes .icon {
  flex: none;
}

.modes button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

/* Cartes */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* Formulaire */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
}

.field {
  position: relative;
}

.field input {
  width: 100%;
  padding: 14px 48px 14px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1.375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 600;
}

.hint {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.error {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--danger);
}

.primary {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--text);
  color: var(--surface);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.primary:active {
  opacity: 0.85;
}

button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Résultat */
.result-amount {
  margin: 0 0 12px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.summary {
  margin: 0;
}

.summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.summary dt {
  color: var(--muted);
}

.summary dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.summary .savings {
  margin-top: 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent-soft);
}

.summary .savings dt,
.summary .savings dd {
  color: var(--accent);
  font-weight: 700;
}

.summary .savings.is-zero {
  background: var(--bg);
}

.summary .savings.is-zero dt,
.summary .savings.is-zero dd {
  color: var(--muted);
}

.note {
  margin: 10px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.result h2 {
  margin: 20px 0 8px;
  font-size: 1rem;
}

.operations {
  margin: 0;
  padding: 0;
  list-style: none;
}

.operations li {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.op-label {
  grid-column: 1 / -1;
  font-size: 0.8125rem;
  color: var(--muted);
}

.op-amount {
  font-weight: 600;
}

.op-fee {
  color: var(--muted);
  white-space: nowrap;
}

.op-fee::before {
  content: "→ ";
}

.total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 12px 0 0;
  font-variant-numeric: tabular-nums;
}

.total small {
  color: var(--muted);
  margin-left: 4px;
}

/* Tarifs */
.tariffs {
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.tariffs summary {
  cursor: pointer;
  color: var(--muted);
  text-align: center;
  padding: 8px;
}

.tariffs table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.tariffs caption {
  padding: 0 4px 8px;
  font-weight: 600;
  text-align: left;
}

.tariffs th,
.tariffs td {
  padding: 6px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tariffs th:last-child,
.tariffs td:last-child {
  text-align: right;
}

.tariffs th {
  color: var(--muted);
  font-weight: 500;
}

.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}
