:root {
  --q-primary: #0055a0;
  --q-secondary: #ffc72c;
  --q-accent: #0055a0;
  --q-positive: #1e7a4a;
  --q-negative: #c9302c;
  --q-warning: #ffc72c;
  --q-info: #0055a0;
  --ff-bleu: #0055a0;
  --ff-bleu-h: #004f9e;
  --ff-bleu-l: #ebf2fb;
  --ff-jaune: #ffc72c;
  --ff-jaune-h: #e09700;
  --ff-jaune-l: #fff8e8;
  --ff-blanc: #ffffff;
  --ff-fond: #f2f4f7;
  --ff-texte: #1c2b3a;
  --ff-texte-s: #607080;
  --ff-texte-h: #a0aebb;
  --ff-bordure: #d4dce8;
  --ff-bordure-l: #e8edf4;
  --ff-surface: #f8fafb;
  --ff-rouge: #c9302c;
  --ff-rouge-l: #fdecea;
  --ff-vert: #1e7a4a;
  --ff-vert-l: #e6f4ed;
  --ff-rayon: 5px;
  --ff-ombre: 0 2px 8px rgba(0, 30, 80, 0.08), 0 4px 16px rgba(0, 30, 80, 0.06);
  --ff-ombre-m: 0 8px 24px rgba(0, 30, 80, 0.12);
  --ff-muted: #6b7280;
  --fayat-blue: var(--ff-bleu);
  --fayat-blue-dark: #003d6b;
  --fayat-yellow: var(--ff-jaune);
  --fayat-grey: var(--ff-muted);
  --fayat-border: var(--ff-bordure);
}

body {
  margin: 0;
  padding: 0;
  position: relative;
  min-height: 100vh;
  background: var(--ff-fond);
  color: var(--ff-texte);
}

.nicegui-content {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.nicegui-column {
  gap: 0;
}

.ff-page {
  background: var(--ff-fond);
  min-height: calc(100vh - 64px);
}

.ff-panel {
  background: var(--ff-blanc);
  border: 1px solid var(--ff-bordure-l);
  border-radius: var(--ff-rayon);
}

.q-header {
  background: var(--ff-bleu) !important;
  color: var(--ff-jaune) !important;
}

.q-header a {
  color: var(--ff-blanc) !important;
}

.q-btn.bg-primary {
  background: var(--ff-bleu) !important;
}

.q-btn.bg-primary:hover {
  background: var(--ff-bleu-h) !important;
}

.q-btn.bg-secondary {
  background: var(--ff-jaune) !important;
  color: var(--ff-texte) !important;
}

.q-btn.bg-secondary:hover {
  background: var(--ff-jaune-h) !important;
}

.q-btn.q-btn--flat {
  color: var(--ff-bleu) !important;
}

.q-field--outlined .q-field__control {
  border: none !important;
  background: var(--ff-blanc);
}

.q-field--outlined .q-field__control:before {
  border: 1px solid var(--ff-bordure) !important;
}

.q-field--outlined.q-field--focused .q-field__control:after {
  border-color: var(--ff-bleu) !important;
}

.q-card {
  background: var(--ff-blanc);
  border: 1px solid var(--ff-bordure-l);
  border-radius: var(--ff-rayon);
  box-shadow: none !important;
}

.q-badge {
  border-radius: 999px;
  font-weight: 600;
}

.ag-theme-quartz,
.ag-theme-alpine {
  --ag-foreground-color: var(--ff-texte);
  --ag-background-color: var(--ff-blanc);
  --ag-header-foreground-color: var(--ff-blanc);
  --ag-header-background-color: var(--ff-bleu);
  --ag-border-color: var(--ff-bordure-l);
  --ag-odd-row-background-color: var(--ff-surface);
  --ag-row-hover-color: var(--ff-bleu-l);
}

.ag-theme-quartz .ag-header-cell-label,
.ag-theme-alpine .ag-header-cell-label {
  font-weight: 600;
}

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

.ff-btn {
  font-weight: 600;
  text-transform: none;
  border-radius: 10px !important;
}

.ff-btn:not(.q-btn--round) {
  padding: 9px 18px !important;
}

.ff-btn.q-btn--outline.text-primary {
  border-color: var(--ff-bordure) !important;
}

.ff-btn.q-btn--outline.text-primary:hover {
  background: var(--ff-bleu-l) !important;
}

.ff-btn.q-btn--outline.text-negative {
  border-color: var(--ff-rouge) !important;
}

.ff-opp-detail-page {
  background: linear-gradient(180deg, #eef2f7 0%, var(--ff-fond) 120px);
  min-height: calc(100dvh - 60px);
  height: calc(100dvh - 60px);
  max-height: calc(100dvh - 60px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.ff-opp-topbar {
  background: var(--ff-blanc);
  border-bottom: 1px solid var(--ff-bordure-l);
  padding: 12px 20px;
  width: 100%;
  flex-shrink: 0;
}

.ff-opp-back-btn {
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  border: 1px solid var(--ff-bordure) !important;
  border-radius: 10px !important;
  background: var(--ff-surface) !important;
  color: var(--ff-bleu) !important;
}

.ff-opp-title-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--ff-bleu);
}

.ff-opp-tabs--toolbar {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

.ff-opp-tabs--toolbar .q-tabs__content {
  gap: 4px;
  flex-wrap: wrap;
}

.ff-opp-tabs--toolbar .q-tab {
  font-weight: 600;
  color: var(--ff-texte-s);
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
}

.ff-opp-tabs--toolbar .q-tab--active {
  color: var(--ff-bleu);
  background: var(--ff-bleu-l);
}

.ff-opp-tabs--toolbar .q-tab__indicator {
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--ff-bleu);
}

.ff-opp-tab-panels {
  background: transparent !important;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ff-opp-tab-panels > .q-panel-parent {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ff-opp-tab-panels .q-tab-panel {
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.ff-opp-tab-panel--fill {
  overflow: hidden !important;
}

.ff-opp-content {
  width: 100%;
  padding: 16px;
  box-sizing: border-box;
}

.ff-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1.3;
}

.ff-tag--blue {
  background: #e7f3ff;
  color: #0b4d8b;
}

.ff-admin-tab-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 16px 16px 12px;
}

.ff-admin-grid-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 16px !important;
}

.ff-admin-grid-panel__toolbar {
  flex-shrink: 0;
}

.ff-admin-section-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ff-bleu);
  line-height: 1.2;
}

.ff-admin-grid-panel__grid-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.ff-admin-grid-panel__grid-wrap > .nicegui-aggrid {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.ff-admin-grid-panel__grid-wrap .ag-root-wrapper {
  height: 100% !important;
}

.perm-bulk-bar {
  padding: 0.5rem 0.75rem;
  background: #f1f5f9;
  border: 1px solid var(--ff-bordure);
  border-radius: 8px;
}

.perm-bulk-bar__counter {
  font-size: 0.8125rem;
  color: var(--ff-texte-s);
  min-width: 100px;
}

.perm-bulk-bar__select {
  margin-left: auto;
  min-width: 160px;
}

.perm-bulk-bar__btn {
  width: auto !important;
  min-width: 100px;
}

.perm-table {
  border: 1px solid var(--ff-bordure);
  border-radius: 8px;
  overflow: hidden;
}

.perm-table__header {
  background: #f8fafc;
  border-bottom: 1px solid var(--ff-bordure);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ff-texte-s);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.625rem 0.875rem;
  display: grid;
  grid-template-columns: 36px 1fr 160px;
  gap: 0.5rem;
  align-items: center;
}

.perm-table__row {
  border-bottom: 1px solid var(--ff-bordure-l);
  padding: 0.625rem 0.875rem;
  display: grid;
  grid-template-columns: 36px 1fr 160px;
  gap: 0.5rem;
  align-items: center;
  background: #fff;
}

.perm-table__row:last-child {
  border-bottom: none;
}

.perm-table__row:hover {
  background: #f8fafc;
}

.perm-table__row-name {
  font-size: 0.875rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.perm-table__row-sub {
  font-size: 0.75rem;
  color: var(--ff-texte-s);
}

.perm-table__col-access {
  width: 100%;
}

.perm-table__empty {
  color: var(--ff-texte-s);
  padding: 1rem;
}

/* ===== Auth — connexion & portail ===== */

.ff-version-footer {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.25rem 1rem;
  font-size: 0.75rem;
  color: var(--ff-texte-h);
  pointer-events: none;
  background: transparent;
}

.auth-version-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: transparent !important;
  pointer-events: none;
  z-index: 10;
  min-height: 0 !important;
}

.auth-shell {
  min-height: 100vh;
  width: 100%;
}

.auth-form-column {
  flex: 1 1 42%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-form-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-hero {
  position: relative;
  min-height: 100vh;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.auth-hero-pattern {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 45%;
  max-width: 420px;
  opacity: 0.9;
  z-index: 2;
  pointer-events: none;
}

.auth-hero-logo {
  position: absolute;
  left: 50%;
  bottom: 3rem;
  transform: translateX(-50%);
  width: min(220px, 40vw);
  z-index: 3;
}

.auth-title {
  color: var(--fayat-blue);
  font-size: 2rem;
  font-weight: 700;
}

.auth-subtitle {
  color: var(--fayat-grey);
  font-size: 0.95rem;
}

.auth-label {
  color: #374151;
  font-weight: 600;
  font-size: 0.875rem;
}

.auth-field {
  width: 100%;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--fayat-grey);
}

.auth-link,
.auth-link .q-btn__content {
  color: var(--fayat-blue) !important;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  min-height: unset;
}

.auth-link.ff-btn,
.auth-link.ff-btn:not(.q-btn--round) {
  width: auto !important;
  padding: 0 !important;
  min-height: unset !important;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-btn {
  width: 100%;
}

.auth-btn.ff-btn:not(.q-btn--round) {
  width: 100%;
}

.auth-footer-logo {
  text-align: center;
}

.auth-footer-logo img {
  max-width: 140px;
  height: auto;
}

.dashboard-header {
  background: var(--fayat-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-card {
  border: 1px solid var(--fayat-border);
  color: #fff;
  border-radius: 12px;
  transition:
    box-shadow 0.2s,
    border-color 0.2s;
  height: 100%;
}

.app-card:hover {
  border-color: var(--fayat-blue);
  box-shadow: 0 8px 24px rgba(0, 85, 150, 0.12);
}

.app-card h3 {
  color: var(--fayat-blue);
}

.app-card p {
  color: var(--fayat-grey);
  font-size: 0.9rem;
}

.hidden-panel {
  display: none !important;
}

.login-pattern {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: url("login-pattern.svg");
  background-color: var(--fayat-blue);
  opacity: 65%;
  background-repeat: no-repeat;
  background-size: contain;
}

.login-image {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: url("login-bg.png");
  background-color: var(--fayat-blue);
  background-repeat: no-repeat;
  background-size: cover;
}

.login-white-logo {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  width: 257px;
  height: auto;
}

.login-logo {
  position: absolute;
  bottom: 4rem;
  width: 108px;
  height: auto;
}

/* ===== Auth — administration ===== */

.admin-page {
  height: calc(100dvh - 60px);
  max-height: calc(100dvh - 60px);
  overflow: hidden;
  box-sizing: border-box;
}

.admin-page__content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-page__content > .q-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.admin-tab-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 1rem;
  border: 1px solid var(--fayat-border);
  border-radius: 8px;
  box-sizing: border-box;
}

.admin-tab-panel--opportunities {
  padding-top: 0.75rem;
}

.admin-tab-panel--opportunities .perm-table__row-sub {
  white-space: normal;
  line-height: 1.35;
}

.perm-panel--scrollable {
  flex: 1;
  min-height: 0;
}

.perm-table__body--scroll {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  border-top: 1px solid var(--fayat-border);
}

.admin-page__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0f172a;
}

.admin-page__tabs .q-tab {
  font-weight: 600;
  text-transform: none;
}

.admin-page__placeholder {
  color: var(--fayat-grey);
  padding: 1.125rem;
  border: 1px dashed var(--fayat-border);
  border-radius: 8px;
}

.admin-page__main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.admin-page__main-tabs .q-tab {
  font-weight: 600;
  text-transform: none;
}

.admin-page__main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-page__main-content > .q-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.admin-main-tab-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding-top: 0.5rem;
  box-sizing: border-box;
}

.admin-permissions-tab {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.admin-permissions-tab__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.admin-users-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--fayat-border);
  border-radius: 8px;
  padding: 0.75rem;
  box-sizing: border-box;
}

.admin-users-panel__grid {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-groups-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--fayat-border);
  border-radius: 8px;
  padding: 0.75rem;
  box-sizing: border-box;
}

.admin-groups-panel__grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.groups-grid {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.groups-grid .nicegui-aggrid {
  height: 100%;
  min-height: 0;
  width: 100%;
}

.users-grid {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.users-grid .nicegui-aggrid {
  height: 100%;
  min-height: 0;
  width: 100%;
}

.loading-overlay.fixed-full {
  position: fixed;
  inset: 0;
}

.loading-overlay.absolute-full {
  position: absolute;
  inset: 0;
}

.perm-all-affairs {
  padding: 0.75rem 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
}

.perm-all-affairs__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e3a8a;
  flex: 1;
  min-width: 0;
}

.perm-all-affairs__select {
  min-width: 160px;
}

.perm-all-affairs__btn {
  width: auto !important;
  min-width: 100px;
}

.perm-opp-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  margin-top: 0.25rem;
}

.perm-pagination {
  padding: 0.5rem 0;
}

.perm-bulk-bar__select-all-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a;
}

.perm-bulk-bar__hint {
  font-size: 0.75rem;
  color: var(--fayat-grey);
  line-height: 1.4;
}

.perm-opp-summary {
  font-size: 0.875rem;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  border: 1px solid var(--fayat-border);
  line-height: 1.4;
}

.perm-opp-summary--all {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.perm-opp-summary--partial {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.perm-opp-summary--none {
  background: #f8fafc;
  color: var(--fayat-grey);
}

.perm-opp-panel {
  padding: 0.75rem;
}
