:root {
  --charcoal: #202020;
  --charcoal-deep: #0d0d0d;
  --charcoal-soft: #2d2d2d;
  --blue: #4caac9;
  --blue-light: #dff2f8;
  --blue-dark: #296f86;
  --blue-deeper: #1d4f5f;
  --surface: #ffffff;
  --canvas: #f4f6f7;
  --line: #dfe4e7;
  --line-strong: #c8d0d4;
  --text: #343a3d;
  --muted: #737373;
  --danger: #a72a22;
  --success: #18794e;
  --warning: #8a570f;
  --white: #ffffff;
  --radius: 10px;
  --shadow: 0 12px 34px rgba(13, 13, 13, 0.07);
  --shadow-hover: 0 16px 42px rgba(13, 13, 13, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(135deg, rgba(76, 170, 201, 0.055), transparent 28rem),
    var(--canvas);
  color: var(--text);
  font-family: Lato, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--blue-dark);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--blue-deeper);
}

:focus-visible {
  outline: 3px solid rgba(76, 170, 201, 0.48);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 2000;
  top: 8px;
  left: 12px;
  padding: 9px 13px;
  transform: translateY(-150%);
  border-radius: 6px;
  background: var(--white);
  color: var(--charcoal);
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  z-index: 1000;
  top: 0;
  border-bottom: 3px solid var(--blue);
  background:
    radial-gradient(circle at 12% -120%, rgba(76, 170, 201, 0.27), transparent 32%),
    linear-gradient(105deg, var(--charcoal-deep), var(--charcoal) 48%, #252b2e);
  color: var(--white);
  box-shadow: 0 5px 20px rgba(13, 13, 13, 0.22);
}

.topbar-inner {
  width: min(1380px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--white);
  text-decoration: none;
}

.brand:hover {
  color: var(--white);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--blue), #2584ad);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.25), 0 5px 16px rgba(0, 0, 0, 0.25);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: var(--white);
}

.brand-copy {
  display: grid;
  line-height: 1.08;
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.main-navigation {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.nav-links {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.nav-links a,
.link-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: #e6eaec;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.nav-links a:hover,
.nav-links a.is-active,
.link-button:hover {
  border-bottom-color: var(--blue);
  color: var(--white);
}

.nav-account {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding-left: 13px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.nav-account form {
  margin: 0;
}

.user-pill {
  max-width: 104px;
  overflow: hidden;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(76, 170, 201, 0.16);
  color: #eaf8fc;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle {
  min-width: 76px;
  min-height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-toggle-lines,
.menu-toggle-lines::before,
.menu-toggle-lines::after {
  width: 18px;
  height: 2px;
  display: block;
  border-radius: 2px;
  background: var(--blue);
  content: "";
  transition: transform 180ms ease, opacity 180ms ease;
}

.menu-toggle-lines {
  position: relative;
}

.menu-toggle-lines::before {
  position: absolute;
  top: -6px;
}

.menu-toggle-lines::after {
  position: absolute;
  top: 6px;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-lines {
  background: transparent;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-lines::before {
  top: 0;
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle-lines::after {
  top: 0;
  transform: rotate(-45deg);
}

.container {
  width: min(1180px, calc(100% - 40px));
  flex: 1 0 auto;
  margin: 34px auto 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-head h1,
.login-panel h2 {
  margin: 0;
  color: var(--charcoal);
  font-family: Lora, Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 2.4vw, 2.35rem);
  font-weight: 400;
  line-height: 1.18;
}

.page-head h1::after {
  width: 48px;
  height: 3px;
  display: block;
  margin-top: 11px;
  border-radius: 3px;
  background: var(--blue);
  content: "";
}

.page-head .muted {
  margin: 10px 0 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.actions form {
  margin: 0;
}

.button,
button.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--blue-dark);
  border-radius: 7px;
  background: var(--blue-dark);
  color: var(--white);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.015em;
  text-decoration: none;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.button:hover,
button.button:hover {
  border-color: var(--blue-deeper);
  background: var(--blue-deeper);
  color: var(--white);
  box-shadow: 0 6px 16px rgba(29, 79, 95, 0.2);
  transform: translateY(-1px);
}

.button.secondary {
  border-color: var(--blue);
  background: var(--white);
  color: var(--blue-dark);
}

.button.secondary:hover {
  background: var(--blue-light);
}

.button.neutral {
  border-color: var(--line-strong);
  background: var(--white);
  color: var(--text);
}

.button.neutral:hover {
  border-color: #aab5bb;
  background: #f6f8f9;
}

.button.danger {
  border-color: #e9b7b2;
  background: var(--white);
  color: var(--danger);
}

.button.danger:hover {
  border-color: #d88982;
  background: #fff2f1;
}

.button.small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.stats {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 30px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card:not(.table-card) {
  padding: 22px;
}

.stat {
  min-height: 118px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  overflow: hidden;
  transition: box-shadow 180ms ease, transform 180ms ease;
}

.stat::after {
  width: 72px;
  height: 72px;
  position: absolute;
  right: -30px;
  bottom: -34px;
  border: 14px solid rgba(76, 170, 201, 0.1);
  border-radius: 50%;
  content: "";
}

.stat:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #b9dfe9;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--blue-light), #f5fbfd);
  color: var(--blue-dark);
  font-size: 18px;
  font-weight: 850;
}

.stat .value {
  color: var(--charcoal);
  font-family: Lora, Georgia, serif;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
  line-height: 1;
}

.stat .label {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-transform: capitalize;
}

.table-card {
  max-width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--blue) #edf1f3;
  scrollbar-width: thin;
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  background: var(--white);
}

th {
  padding: 12px 14px;
  border-bottom: 2px solid #d4e3e8;
  background: linear-gradient(180deg, #eef6f8, #e8f0f3);
  color: #49616c;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.075em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-top: 1px solid #e8edef;
  font-size: 13px;
  vertical-align: top;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #f6fbfc;
}

td a {
  font-weight: 700;
}

td.number,
th.number {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid #d8e1e5;
  border-radius: 999px;
  background: #edf2f4;
  color: #4c5f67;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.status.accepte,
.status.payee,
.status.valide {
  border-color: #b8e5ce;
  background: #def7ec;
  color: #11643e;
}

.status.envoye,
.status.emise,
.status.en-cours {
  border-color: #b7dce9;
  background: #e1f0fa;
  color: #075a7b;
}

.status.annule,
.status.annulee,
.status.refuse {
  border-color: #f1bcb7;
  background: #fee4e2;
  color: #932017;
}

.message {
  margin-bottom: 18px;
  padding: 13px 16px;
  border: 1px solid #b9dce9;
  border-left: 4px solid var(--blue);
  border-radius: 7px;
  background: #e8f5f9;
  color: var(--blue-deeper);
}

.message.success {
  border-color: #b7e5cd;
  border-left-color: var(--success);
  background: #e7f7ef;
  color: #0e603b;
}

.message.error {
  border-color: #f0c5c1;
  border-left-color: var(--danger);
  background: #fff0ef;
  color: #8f2119;
}

.form-card {
  max-width: 900px;
}

.form-grid p {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid #edf1f3;
}

.form-grid label {
  padding-top: 9px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #b9c6cc;
  border-radius: 7px;
  background: var(--white);
  color: var(--text);
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-dark);
  outline: none;
  box-shadow: 0 0 0 3px rgba(76, 170, 201, 0.2);
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
  accent-color: var(--blue-dark);
}

.errorlist {
  margin: 4px 0;
  padding-left: 18px;
  color: var(--danger);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.meta-list {
  display: grid;
  grid-template-columns: 135px minmax(0, 1fr);
  gap: 9px 14px;
  margin: 0;
}

.meta-list dt {
  color: var(--muted);
  font-size: 12px;
}

.meta-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.totals {
  width: min(380px, 100%);
  margin-left: auto;
}

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

.totals .grand {
  margin-top: 6px;
  padding-top: 11px;
  border-top: 3px solid var(--blue);
  border-bottom: 0;
  color: var(--charcoal);
  font-family: Lora, Georgia, serif;
  font-size: 19px;
  font-weight: 700;
}

.search {
  max-width: 650px;
  display: flex;
  gap: 9px;
}

.search input {
  width: min(420px, 100%);
}

.empty {
  padding: 38px;
  color: var(--muted);
  text-align: center;
}

.inline-form {
  display: inline;
}

.cost {
  color: var(--warning);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 32px 0 12px;
}

.section-title h2 {
  margin: 0;
  color: var(--charcoal);
  font-family: Lora, Georgia, serif;
  font-size: 21px;
  font-weight: 400;
}

.app-footer {
  width: min(1180px, calc(100% - 40px));
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 20px 0 26px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-footer span:first-child {
  color: var(--blue-dark);
  font-weight: 800;
}

/* Connexion */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 5% 0, rgba(76, 170, 201, 0.34), transparent 28rem),
    linear-gradient(125deg, var(--charcoal-deep), var(--charcoal) 48%, #263238);
}

.login-shell {
  width: min(1040px, 100%);
  min-height: 610px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
}

.login-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  padding: clamp(34px, 6vw, 70px);
  background:
    linear-gradient(145deg, rgba(13, 13, 13, 0.2), rgba(13, 13, 13, 0.83)),
    radial-gradient(circle at 72% 20%, rgba(76, 170, 201, 0.74), transparent 18rem),
    #172229;
  color: var(--white);
}

.login-visual::before,
.login-visual::after {
  position: absolute;
  border: 1px solid rgba(76, 170, 201, 0.22);
  border-radius: 50%;
  content: "";
}

.login-visual::before {
  width: 430px;
  height: 430px;
  top: -180px;
  right: -170px;
  box-shadow: 0 0 0 58px rgba(76, 170, 201, 0.055), 0 0 0 116px rgba(76, 170, 201, 0.035);
}

.login-visual::after {
  width: 150px;
  height: 150px;
  right: 44px;
  bottom: 52px;
  border-width: 28px;
  opacity: 0.3;
}

.login-brand-mark {
  width: 82px;
  height: 82px;
  position: absolute;
  z-index: 1;
  top: clamp(34px, 6vw, 66px);
  left: clamp(34px, 6vw, 70px);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: linear-gradient(145deg, var(--blue), #247fa5);
  box-shadow: 0 15px 38px rgba(0, 0, 0, 0.28);
}

.login-brand-mark svg {
  width: 52px;
  fill: var(--white);
}

.login-visual > *:not(.login-brand-mark) {
  position: relative;
  z-index: 1;
}

.login-kicker {
  margin: 0 0 13px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.login-visual h1 {
  margin: 0;
  font-family: Lora, Georgia, serif;
  font-size: clamp(2.2rem, 4vw, 3.65rem);
  font-weight: 400;
  line-height: 1.08;
}

.login-visual > p:last-child {
  max-width: 460px;
  margin: 24px 0 0;
  color: #dbe2e5;
  font-size: 15px;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: clamp(32px, 6vw, 72px);
  background: var(--white);
}

.login-panel-inner {
  width: min(360px, 100%);
}

.login-panel h2 {
  margin-bottom: 10px;
}

.login-panel .muted {
  margin: 0 0 30px;
}

.login-form {
  display: grid;
  gap: 9px;
}

.login-form label {
  margin-top: 8px;
  color: #455159;
  font-size: 12px;
  font-weight: 750;
}

.login-form input {
  min-height: 48px;
  background: #fbfcfc;
}

.login-submit {
  width: 100%;
  min-height: 48px;
  justify-content: space-between;
  margin-top: 14px;
  padding-inline: 18px;
}

.login-submit span {
  font-size: 21px;
  line-height: 1;
}

.login-help {
  margin: 25px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

@media (max-width: 1180px) {
  .menu-toggle {
    display: inline-flex;
  }

  .topbar-inner {
    position: relative;
  }

  .main-navigation {
    position: absolute;
    top: calc(100% + 3px);
    right: 0;
    left: 0;
    display: none;
    align-items: stretch;
    padding: 14px 20px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 10px 10px;
    background: #202020;
    box-shadow: 0 15px 28px rgba(0, 0, 0, 0.24);
  }

  .main-navigation.is-open {
    display: block;
  }

  .nav-links {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px 8px;
  }

  .nav-links a {
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.025);
  }

  .nav-links a:hover,
  .nav-links a.is-active {
    border-color: rgba(76, 170, 201, 0.64);
    background: rgba(76, 170, 201, 0.11);
  }

  .nav-account {
    justify-content: flex-end;
    margin-top: 12px;
    padding-top: 12px;
    padding-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 0;
  }
}

@media (max-width: 860px) {
  .container {
    margin-top: 26px;
  }

  .grid.stats,
  .detail-grid,
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-shell {
    min-height: 0;
  }

  .login-visual {
    min-height: 320px;
  }

  .login-brand-mark {
    width: 64px;
    height: 64px;
  }

  .login-brand-mark svg {
    width: 40px;
  }

  .login-panel {
    min-height: 420px;
  }

  .form-grid p {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .form-grid label {
    padding-top: 0;
  }
}

@media (max-width: 620px) {
  .topbar-inner,
  .container,
  .app-footer {
    width: min(100% - 24px, 1180px);
  }

  .topbar-inner {
    min-height: 64px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-copy strong {
    font-size: 12px;
  }

  .brand-copy small {
    font-size: 10px;
  }

  .menu-toggle {
    min-width: 48px;
    padding: 0 13px;
  }

  .menu-toggle > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .main-navigation {
    padding-inline: 12px;
  }

  .nav-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-links a,
  .link-button {
    min-height: 44px;
  }

  .container {
    margin: 22px auto 46px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
  }

  .page-head > .button {
    width: 100%;
  }

  .grid.stats {
    gap: 12px;
  }

  .stat {
    min-height: 96px;
  }

  .card:not(.table-card) {
    padding: 17px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .search {
    flex-direction: column;
  }

  .search input,
  .search .button {
    width: 100%;
  }

  .meta-list {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .meta-list dd {
    margin-bottom: 8px;
  }

  .actions {
    gap: 8px;
  }

  .app-footer {
    flex-direction: column;
    gap: 5px;
  }

  .login-page {
    padding: 0;
    place-items: stretch;
  }

  .login-shell {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .login-visual {
    min-height: 260px;
    padding: 28px 24px;
  }

  .login-brand-mark {
    width: 52px;
    height: 52px;
    top: 24px;
    left: 24px;
    border-radius: 10px;
  }

  .login-brand-mark svg {
    width: 32px;
  }

  .login-visual h1 {
    font-size: 2rem;
  }

  .login-visual > p:last-child {
    display: none;
  }

  .login-panel {
    min-height: 0;
    padding: 36px 24px 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
