:root {
  --brand: #183650;
  --brand-strong: #102b43;
  --brand-soft: #eaf0f5;
  --background: #f4f6f8;
  --surface: #ffffff;
  --border: #dce2e8;
  --border-strong: #c9d1d9;
  --text: #1f2933;
  --muted: #65717d;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --focus: #2f6f9f;
  --radius: 8px;
}

.app-tabs { width: min(1180px, calc(100% - 32px)); margin: 18px auto 0; display: flex; gap: 8px; border-bottom: 1px solid var(--border); }
.app-tabs a { color: var(--muted); text-decoration: none; padding: 10px 18px; border-bottom: 3px solid transparent; font-weight: 600; }
.app-tabs a[aria-current="page"] { color: var(--brand); border-color: var(--brand); }
.app-tabs a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  background: var(--brand);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-logo {
  width: 105px;
  height: auto;
  display: block;
}

.header-title {
  padding-left: 20px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}

/* Sans logo, ne pas conserver son séparateur ni son espace réservé. */
.header-title:first-child {
  padding-left: 0;
  border-left: 0;
}

.header-title h1,
.header-title p,
.panel-heading h2,
.panel-heading p,
.results-heading h2,
.results-heading p {
  margin: 0;
}

.header-title h1 {
  font-size: 18px;
  font-weight: 650;
}

.header-title p {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(16, 43, 67, 0.05);
}

.configuration-panel {
  padding: 24px;
}

.panel-heading,
.results-heading {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2,
.results-heading h2 {
  color: var(--brand-strong);
  font-size: 20px;
  font-weight: 650;
}

.panel-heading p,
.results-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.form-stack {
  display: grid;
  gap: 20px;
  padding-top: 20px;
}

.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field label,
.field legend {
  display: block;
  margin-bottom: 7px;
  color: #3b4650;
  font-size: 13px;
  font-weight: 600;
}

select,
.detail-fields .field > input[type="text"],
.amount-input-wrap,
.compact-amount-wrap {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
}

select {
  padding: 0 38px 0 12px;
  color: var(--text);
}

.detail-fields .field > input[type="text"] {
  min-width: 0;
  padding: 9px 10px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

select:focus,
.detail-fields .field > input[type="text"]:focus,
.amount-input-wrap:focus-within,
.compact-amount-wrap:focus-within,
.mode-button:focus-visible,
.primary-button:focus-visible,
.secondary-link:focus-visible,
.country-button:focus-visible {
  outline: 3px solid rgba(47, 111, 159, 0.2);
  outline-offset: 1px;
  border-color: var(--focus);
}

.mode-switch {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.4fr;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f1f3f5;
}

.mode-button {
  min-height: 36px;
  padding: 6px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.mode-button:hover {
  color: var(--text);
}

.mode-button.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(16, 43, 67, 0.12);
}

.amount-input-wrap {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.compact-amount-wrap {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.compact-amount-wrap input {
  min-width: 0;
  flex: 1;
  padding: 9px 10px;
  border: 0;
  outline: 0;
  color: var(--text);
}

.compact-amount-wrap span {
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.payroll-details {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
}

.payroll-details summary {
  color: var(--brand);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.detail-fields {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.amount-input-wrap input {
  min-width: 0;
  flex: 1;
  padding: 10px 12px;
  border: 0;
  outline: 0;
  color: var(--brand-strong);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.amount-input-wrap span {
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field-error {
  margin: 7px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.range-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-heading output {
  min-width: 32px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand);
  text-align: center;
  font-weight: 700;
}

input[type="month"] {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  min-width: 0;
  max-width: 100%;
}
.field > input[type="month"] { width: 100%; }
#period-note[hidden] { display: none; }
input[type="month"]:focus-visible { outline: 2px solid #2b6388; outline-offset: 2px; }

input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

.field-help,
.simulation-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.primary-button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

.primary-button:hover {
  background: var(--brand-strong);
}

.secondary-link {
  width: fit-content;
  color: var(--brand);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.results-panel {
  overflow: visible;
}

.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
}

.currency-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
}

.summary-item {
  min-width: 0;
  padding: 18px 24px;
  border-right: 1px solid var(--border);
}

.summary-item:last-child {
  border-right: 0;
}

.summary-item span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  color: var(--text);
  font-size: clamp(16px, 2vw, 22px);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.primary-summary strong {
  color: var(--brand);
}

.summary-value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }
.summary-ratio { color: var(--brand); font-size: 12px; font-weight: 600; white-space: nowrap; }
.ratio-legend { color: var(--muted); font-size: 11px; margin: 8px 24px; }
.leave-summary { padding: 18px 24px; border-top: 1px solid var(--border); }
.leave-summary h3 { font-size: 14px; margin: 0 0 8px; }
.leave-summary p { margin: 6px 0; }
.leave-summary > p:first-of-type { font-size: 14px; font-weight: 600; }
.payroll-table .rate-cell { padding-left: 6px; padding-right: 6px; font-size: 11px; white-space: nowrap; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.charges-summary { padding: 20px 24px; border-top: 1px solid var(--border); }
.charges-summary h3 { font-size: 15px; margin: 0 0 4px; }
.charges-table { width: 100%; min-width: 400px; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.charges-table th, .charges-table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.charges-table thead th { color: var(--muted); font-size: 12px; font-weight: 600; background: #f7f8fa; }
.charges-table tbody th { font-weight: 500; }
.charges-table tfoot { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.info-heading { position: relative; display: flex; align-items: center; gap: 6px; }
.info-heading h3, .summary-item .info-heading span { margin: 0; }
.info-heading-cost { margin-bottom: 5px; }
.info-button { flex: 0 0 auto; padding: 2px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.info-button:hover, .info-button[aria-expanded="true"] { background: #e8eff5; color: #17384e; }
.info-button:focus-visible { outline: 2px solid #2b6388; outline-offset: 2px; }
.info-panel { position: absolute; top: 100%; left: 0; z-index: 10; width: min(390px, calc(100vw - 84px)); max-height: 50vh; overflow: auto; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 6px 24px #17384e26; color: var(--text); font-size: 12px; line-height: 1.5; font-weight: normal; }
.info-heading-cost .info-panel { left: auto; right: 0; }
.info-panel p { margin: 0 0 10px; }
.info-panel p:last-child { margin-bottom: 0; }
.info-panel[hidden] { display: none !important; }
.charges-summary [hidden] { display: none !important; }

.payroll-table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.payroll-table {
  min-width: 780px;
}

.payroll-row-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.payroll-table th,
.payroll-table td,
.admin-table th,
.admin-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #edf0f2;
  text-align: left;
  vertical-align: top;
}

.payroll-table thead th,
.admin-table thead th {
  background: #f7f8fa;
  color: #53606c;
  font-size: 12px;
  font-weight: 650;
}

.number-cell {
  text-align: right !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.payroll-table tbody tr:hover,
.admin-table tbody tr:hover {
  background: #fafbfc;
}

.payroll-table tfoot th,
.payroll-table tfoot td {
  padding-top: 15px;
  padding-bottom: 15px;
  border-bottom: 0;
  background: #f7f8fa;
  font-weight: 700;
}

.employee-value,
.employee-total,
.tax-value {
  color: var(--brand);
  font-weight: 700;
}

.simulation-note {
  margin: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}

.admin-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 24px auto;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.admin-nav {
  padding: 12px;
}

.admin-nav-title {
  margin: 10px 10px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.country-button {
  width: 100%;
  margin: 1px 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #3d4852;
  cursor: pointer;
  text-align: left;
}

.country-button:hover {
  background: #f2f5f7;
}

.country-button.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 650;
}

.admin-content {
  display: grid;
  gap: 18px;
}

.content-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.content-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.content-card-heading h2,
.content-card-heading h3,
.content-card-heading p {
  margin: 0;
}

.content-card-heading h2 {
  color: var(--brand-strong);
  font-size: 22px;
}

.content-card-heading h3 {
  font-size: 17px;
}

.content-card-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 18px 20px;
}

.metadata-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metadata-item strong {
  display: block;
  margin-top: 3px;
}

.source-list,
.note-list {
  margin: 0;
  padding: 16px 20px 16px 38px;
  color: #4c5863;
  font-size: 13px;
}

.source-list li,
.note-list li {
  margin: 5px 0;
}

.detail-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.warning-card {
  border-color: #f2c94c;
  background: #fffcf2;
}

.warning-card .content-card-heading {
  border-bottom-color: #f4df9b;
}

.empty-state,
.loading-state,
.error-state {
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}

.error-state {
  color: var(--danger);
  background: var(--danger-soft);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-link {
  color: #fff;
  font-size: 13px;
  text-underline-offset: 3px;
}

.readonly-badge {
  display: inline-flex;
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
}

@media (max-width: 900px) {
  .page-shell,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
  }

  .admin-nav-title {
    display: none;
  }

  .country-button {
    width: auto;
    flex: 0 0 auto;
  }
}

@media (max-width: 620px) {
  .header-inner,
  .page-shell,
  .admin-shell {
    width: min(100% - 20px, 1180px);
  }

  .header-title p,
  .readonly-badge {
    display: none;
  }

  .summary-grid,
  .metadata-grid {
    grid-template-columns: 1fr;
  }

  .summary-item {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .summary-item:last-child {
    border-bottom: 0;
  }

  .configuration-panel {
    padding: 20px;
  }
}
