:root {
  --navy: #0b3159;
  --blue: #1e5f96;
  --red: #ef3e35;
  --ink: #10243d;
  --muted: #66778d;
  --line: rgba(18, 59, 102, 0.13);
  --soft: #edf4fa;
  --white: #fff;
  --shadow: 0 24px 70px rgba(14, 49, 86, 0.13);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 5%, rgba(30, 95, 150, .16), transparent 28rem),
    radial-gradient(circle at 95% 92%, rgba(239, 62, 53, .12), transparent 28rem),
    #f4f8fc;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.portal-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: .8rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(16px);
}
.portal-brand, .portal-header nav, .portal-header nav form { display: flex; align-items: center; gap: 1rem; }
.portal-brand img { width: 90px; }
.portal-brand-logo-mark,
.auth-logo-mark {
  display: block;
  overflow: hidden;
  flex: 0 0 auto;
  background-image: url("../assets/logo.png");
  background-repeat: no-repeat;
  background-position: left center;
}
.portal-brand-logo-mark {
  width: 96px;
  height: 44px;
  background-size: auto 44px;
}
.portal-brand span { color: var(--navy); font-weight: 900; }
.portal-header nav { color: var(--blue); font-size: .92rem; font-weight: 800; }
.portal-header button { border: 0; color: var(--red); background: none; cursor: pointer; font-weight: 900; }

.auth-shell {
  display: grid;
  grid-template-columns: minmax(300px, 520px) minmax(340px, 620px);
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: calc(100vh - 78px);
  width: min(1180px, calc(100% - 2rem));
  margin: auto;
  padding: 2rem 0;
}
.auth-card, .panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}
.auth-card { min-width: 0; padding: clamp(1.5rem, 4vw, 3.2rem); }
.auth-card > img { width: 130px; margin-bottom: 1.5rem; }
.auth-logo-mark {
  width: 170px;
  height: 74px;
  margin-bottom: 1.5rem;
  background-size: auto 74px;
}
.auth-logo-client {
  display: block;
  width: 150px !important;
  height: auto;
  object-fit: contain;
  image-rendering: auto;
  filter: none;
}
.auth-card h1, .auth-card h2, .page-heading h1, .panel h2 { margin: 0; color: var(--navy); }
.auth-card h1 { font-size: clamp(2rem, 4.4vw, 4rem); line-height: 1; }
.auth-card h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.auth-card p, .auth-card li { color: var(--muted); line-height: 1.7; }
.auth-card--intro {
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(11, 49, 89, .97), rgba(30, 95, 150, .93)),
    #0b3159;
}
.auth-card--intro h1, .auth-card--intro li { color: #fff; }
.auth-card--intro .eyebrow { color: #ffb3ae; }
.auth-card--intro ul { display: grid; gap: .8rem; margin: 2rem 0 0; padding: 0; list-style: none; }
.auth-card--intro li::before { content: "✓"; margin-right: .7rem; color: #ff746b; font-weight: 900; }
.auth-card h1,
.auth-card h2,
.auth-card li,
.auth-card .eyebrow {
  overflow-wrap: anywhere;
}
.eyebrow { margin: 0 0 .6rem; color: var(--red); font-size: .78rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }

.portal-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.portal-form--wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.portal-form label { display: grid; gap: .45rem; color: var(--navy); font-weight: 800; }
.portal-form small { color: var(--muted); font-weight: 500; }
.portal-form input, .portal-form textarea, .portal-form select {
  width: 100%;
  min-height: 51px;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: 0;
  color: var(--ink);
  background: #f9fbfd;
}
.portal-form textarea { min-height: 110px; resize: vertical; }
.portal-form input:focus, .portal-form textarea:focus, .portal-form select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(30, 95, 150, .1); }
.portal-form .full { grid-column: 1 / -1; }
.honeypot { position: absolute !important; left: -9999px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: fit-content;
  padding: .85rem 1.25rem;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), #ff665c);
  box-shadow: 0 12px 28px rgba(239, 62, 53, .2);
  cursor: pointer;
  font-weight: 900;
}
.button--ghost { color: var(--navy); background: var(--soft); box-shadow: none; }
.switch-link { margin: 1.2rem 0 0; text-align: center; }
.switch-link a, .empty-state a { color: var(--blue); font-weight: 900; }
.form-actions, .heading-actions { display: flex; flex-wrap: wrap; gap: .7rem; }

.portal-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.portal-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem 1.25rem;
  color: #fff;
  background:
    radial-gradient(circle at bottom left, rgba(239, 62, 53, .3), transparent 17rem),
    linear-gradient(180deg, #0b3159, #174f7e);
}
.client-chip { display: flex; align-items: center; gap: .8rem; padding: 1rem; border: 1px solid rgba(255,255,255,.15); border-radius: 20px; background: rgba(255,255,255,.08); }
.client-chip > span { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; background: var(--red); font-size: 1.2rem; font-weight: 900; }
.client-chip strong, .client-chip small { display: block; }
.client-chip small { overflow: hidden; margin-top: .2rem; max-width: 160px; color: rgba(255,255,255,.7); text-overflow: ellipsis; white-space: nowrap; }
.portal-sidebar nav { display: grid; gap: .45rem; }
.portal-sidebar nav a { padding: .9rem 1rem; border-radius: 14px; color: rgba(255,255,255,.78); font-weight: 800; }
.portal-sidebar nav a:hover, .portal-sidebar nav a.is-active { color: #fff; background: rgba(255,255,255,.14); }
.sidebar-help { margin-top: auto; padding: 1rem; border-radius: 18px; color: rgba(255,255,255,.76); background: rgba(0,0,0,.12); }
.sidebar-help strong { display: block; margin-top: .35rem; color: #fff; }

.portal-main { min-width: 0; padding: clamp(1.2rem, 3vw, 3rem); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.2rem; }
.page-heading h1 { font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1.02; }
.page-heading p:not(.eyebrow) { max-width: 720px; margin: .7rem 0 0; color: var(--muted); line-height: 1.65; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stats-grid article { padding: 1.4rem; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: 0 15px 40px rgba(14,49,86,.08); }
.stats-grid span, .stats-grid strong, .stats-grid small { display: block; }
.stats-grid span { color: var(--red); font-size: 2.2rem; font-weight: 900; }
.stats-grid strong { margin-top: .25rem; color: var(--navy); font-size: 1.05rem; }
.stats-grid small { margin-top: .45rem; color: var(--muted); }
.stats-grid__contact { background: linear-gradient(135deg, #0b3159, #1e5f96) !important; }
.stats-grid__contact strong, .stats-grid__contact small { color: #fff; }
.content-grid, .detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.panel { padding: clamp(1rem, 2.4vw, 1.7rem); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.panel-heading a { color: var(--blue); font-weight: 900; }
.form-panel { max-width: 960px; }
.data-list { display: grid; }
.data-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; align-items: center; gap: .8rem; padding: 1rem .3rem; border-bottom: 1px solid var(--line); }
.data-row:last-child { border-bottom: 0; }
.data-row strong, .data-row small { display: block; }
.data-row strong { color: var(--navy); }
.data-row small { margin-top: .3rem; color: var(--muted); }
.row-arrow { color: var(--red); font-size: 1.7rem; }
.status { display: inline-flex; align-items: center; width: fit-content; padding: .42rem .7rem; border-radius: 999px; color: #174f7e; background: #e5f1fb; font-size: .75rem; font-weight: 900; white-space: nowrap; }
.status--terminee, .status--resolue, .status--fermee { color: #0b6b43; background: #dff7eb; }
.status--annulee { color: #8f2330; background: #fde8eb; }
.status--en_cours, .status--haute, .status--urgente { color: #8a4b00; background: #fff0d8; }
.empty-state { padding: 1.5rem; color: var(--muted); text-align: center; }
.alert { margin-bottom: 1rem; padding: 1rem 1.2rem; border-radius: 17px; font-weight: 800; }
.alert--success { color: #0b6340; background: #dff7eb; }
.alert--error { color: #8f2330; background: #fde8eb; }
dl { display: grid; grid-template-columns: minmax(110px, .35fr) 1fr; gap: .8rem 1rem; margin: 1.2rem 0 0; }
dt { color: var(--muted); font-weight: 800; }
dd { margin: 0; line-height: 1.6; }
.timeline { display: grid; margin-top: 1rem; }
.timeline article { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: .7rem; }
.timeline article > span { position: relative; width: 11px; height: 11px; margin-top: .35rem; border-radius: 50%; background: var(--red); }
.timeline article > span::after { content: ""; position: absolute; top: 11px; left: 5px; width: 1px; height: calc(100% + 3.2rem); background: var(--line); }
.timeline article:last-child > span::after { display: none; }
.timeline article > div { padding-bottom: 1.3rem; }
.timeline__top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.timeline p { margin: .6rem 0; color: var(--ink); line-height: 1.6; }
.timeline small, .muted { color: var(--muted); }
.message-form { margin-top: .8rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.document-link { color: var(--blue); font-weight: 900; }
.company-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid rgba(28, 91, 143, .16);
  border-radius: 22px;
  background: radial-gradient(circle at 100% 0, rgba(239, 62, 53, .12), transparent 12rem), linear-gradient(135deg, #f8fbfe, #eef5fb);
}
.company-profile-card h2 {
  margin: .2rem 0 .35rem;
  color: var(--navy);
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}
.company-profile-card p:not(.eyebrow) {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  line-height: 1.6;
}
.company-profile-card img {
  width: 112px;
  max-height: 76px;
  object-fit: contain;
  padding: .35rem;
  border-radius: 16px;
  background: #fff;
}
.company-logo-preview {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbfe;
  color: var(--muted);
  font-weight: 800;
}
.company-logo-preview img {
  width: 86px;
  max-height: 58px;
  object-fit: contain;
}
.portal-sidebar__app { color: #fff !important; background: linear-gradient(135deg, var(--red), #ff6b60) !important; }
.portal-sidebar__app--payroll { background: linear-gradient(135deg, #0b3159, #1e5f96) !important; }
.commercial-launch { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-bottom: 1rem; padding: clamp(1.2rem, 3vw, 2rem); border-radius: 26px; color: #fff; background: radial-gradient(circle at 85% 20%, rgba(239,62,53,.45), transparent 18rem), linear-gradient(135deg, #0b3159, #1e5f96); box-shadow: var(--shadow); }
.commercial-launch h2 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.4rem); }
.commercial-launch p:not(.eyebrow) { max-width: 720px; margin: .5rem 0 0; color: rgba(255,255,255,.8); line-height: 1.6; }
.commercial-launch--payroll { background: radial-gradient(circle at 88% 22%, rgba(239,62,53,.32), transparent 17rem), linear-gradient(135deg, #082747, #1e5f96); }
.commercial-launch--locked { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.commercial-launch--locked p:not(.eyebrow) { color: var(--muted); }
.gc-body { background: #edf3f8; }
.gc-layout { grid-template-columns: 250px minmax(0, 1fr); }
.gc-main { width: 100%; max-width: 1600px; }
.gc-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gc-stats span { font-size: clamp(1.2rem, 2vw, 1.75rem); }
.gc-form-grid { grid-template-columns: minmax(310px, .65fr) minmax(0, 1.35fr); margin-bottom: 1rem; }
.gc-wide-panel { min-width: 0; }
.gc-table-wrap { overflow-x: auto; }
.gc-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.gc-table th, .gc-table td { padding: .85rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.gc-table th { color: var(--navy); font-size: .76rem; text-transform: uppercase; }
.gc-table small { display: block; margin-top: .25rem; color: var(--muted); }
.gc-alert { color: #b4232d; background: #fff1f2; font-weight: 900; }
.gc-document-form { margin-bottom: 1rem; }
.gc-article-panel { min-width: 0; }
.gc-price-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: .2rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, #f8fbfe, #eef5fb);
}
.gc-price-fields legend {
  padding: 0 .45rem;
  color: var(--navy);
  font-weight: 900;
}
.gc-calculated input {
  background: #eef5fb;
}
.gc-form-note {
  grid-column: 1 / -1;
  margin: -.2rem 0 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.55;
}
.gc-actions-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  align-items: center;
}
.gc-lines { display: grid; gap: .55rem; padding: .9rem; border: 1px solid var(--line); border-radius: 18px; background: #f7fafc; }
.gc-line { display: grid; grid-template-columns: minmax(220px, 1.45fr) minmax(90px, .42fr) minmax(115px, .55fr) minmax(95px, .42fr) minmax(95px, .42fr) minmax(110px, .5fr); gap: .55rem; }
.gc-line select, .gc-line input { min-width: 0; }
.gc-line output {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 51px;
  padding: .85rem .8rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  color: var(--navy);
  font-weight: 900;
}
.gc-line--heading { padding: 0 .45rem; color: var(--navy); font-size: .76rem; text-transform: uppercase; }
.invoice-sheet { width: min(940px, 100%); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem); background: #fff; box-shadow: var(--shadow); }
.invoice-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-bottom: 1.5rem; }
.invoice-sheet > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; padding-bottom: 1.5rem; border-bottom: 2px solid var(--navy); }
.invoice-sheet > header img { width: 130px; }
.invoice-company-logo { max-height: 88px; object-fit: contain; }
.invoice-sheet > header p { margin: 0 0 .4rem; color: var(--navy); font-size: 1.15rem; font-weight: 900; }
.invoice-sheet > header small { color: var(--muted); line-height: 1.6; }
.invoice-title { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin: 2rem 0; }
.invoice-title p { margin: 0 0 .4rem; color: var(--red); font-size: .75rem; font-weight: 900; text-transform: uppercase; }
.invoice-title h1 { margin: 0 0 .5rem; color: var(--navy); }
.invoice-title strong, .invoice-title span { display: block; line-height: 1.6; }
.invoice-table { width: 100%; margin-top: 1.5rem; border-collapse: collapse; }
.invoice-table th { color: #fff; background: var(--navy); }
.invoice-table th, .invoice-table td { padding: .9rem; border: 1px solid var(--line); text-align: left; }
.invoice-total { display: grid; grid-template-columns: 1fr auto; gap: .6rem 1.5rem; width: min(360px, 100%); margin: 1.5rem 0 0 auto; padding: 1.2rem; background: var(--soft); }
.invoice-total strong { color: var(--navy); text-align: right; }
.invoice-notes { margin-top: 2rem; padding: 1rem; border-left: 4px solid var(--red); background: #fff7f6; }

@media (max-width: 980px) {
  .portal-layout { grid-template-columns: 1fr; }
  .portal-sidebar { position: static; padding: 1rem; }
  .portal-sidebar nav { grid-template-columns: repeat(4, minmax(130px, 1fr)); overflow-x: auto; }
  .sidebar-help { display: none; }
  .gc-layout { grid-template-columns: 1fr; }
  .gc-stats { grid-template-columns: repeat(2, 1fr); }
  .gc-form-grid { grid-template-columns: 1fr; }
  .gc-price-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gc-line { grid-template-columns: minmax(180px, 1.4fr) repeat(5, minmax(90px, .55fr)); }
}
@media (max-width: 760px) {
  .portal-header { align-items: flex-start; flex-direction: column; }
  .portal-header nav { width: 100%; flex-wrap: wrap; }
  .auth-shell, .content-grid, .detail-grid, .stats-grid, .portal-form--wide { grid-template-columns: 1fr; }
  .auth-shell { min-height: auto; width: 100%; padding: 1rem; }
  .auth-card { width: 100%; padding: 1.5rem; }
  .auth-card--intro .eyebrow { font-size: .68rem; letter-spacing: .06em; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .portal-form .full { grid-column: auto; }
  .gc-price-fields { grid-template-columns: 1fr; }
  .portal-sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .commercial-launch { align-items: flex-start; flex-direction: column; }
  .company-profile-card { align-items: flex-start; flex-direction: column; }
  .gc-main { width: 100%; max-width: 100vw; overflow: hidden; }
  .gc-main .page-heading h1 { font-size: 2rem; }
  .gc-main .page-heading p { overflow-wrap: anywhere; }
  .gc-line { grid-template-columns: 1fr; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
  .gc-line--heading { display: none; }
  .invoice-title { grid-template-columns: 1fr; }
  .data-row { grid-template-columns: 1fr auto; }
  .data-row .row-arrow { display: none; }
  dl { grid-template-columns: 1fr; gap: .25rem; }
  dd { margin-bottom: .7rem; }
}

@media print {
  .no-print { display: none !important; }
  .gc-body { background: #fff; }
  .portal-layout, .gc-layout { display: block; }
  .portal-main, .gc-main { padding: 0; }
  .invoice-sheet { width: 100%; box-shadow: none; }
}
