:root {
  --echo-charcoal: #1f211e;
  --echo-paper: #f3f1ec;
  --echo-white: #ffffff;
  --echo-line: #dedbd5;
  --echo-muted: #9b9993;
  --echo-green: #106b4f;
  --echo-red: #b42318;
  --font-sans: "Plus Jakarta Sans", Arial, sans-serif;
}

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

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--echo-paper);
  color: var(--echo-charcoal);
  font-family: var(--font-sans);
}

/*
 * Le shell doit rester horizontal dès le premier bundle CSS chargé.
 * Les feuilles métier complètent ensuite sa présentation, mais ne doivent pas
 * être nécessaires pour placer le contenu principal dans le viewport.
 */
#mainContent.layout {
  display: flex !important;
  flex-direction: row !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
}

#mainContent.layout > .app-main {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-height: 100vh !important;
  overflow: hidden !important;
}

#mainContent.layout > .app-main > .shell {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  width: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

#mainContent.layout > .app-main > .shell > .page.active {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* Cette modale legacy vit à la racine du shell : elle ne doit jamais prendre
   de place dans la page tant que l'utilisateur ne l'a pas ouverte. */
#timeEntryModal:not(.active) {
  display: none !important;
}

button, input, textarea { font: inherit; }

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--echo-paper);
}

.login-box {
  width: min(440px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 48px;
  border: 1px solid var(--echo-line);
  background: var(--echo-white);
  box-shadow: 0 8px 32px rgba(31, 33, 30, .08);
}

.login-box h1 {
  margin: 42px 0 8px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.03em;
}

.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--echo-green);
  color: var(--echo-white);
  font-size: 20px;
  font-weight: 700;
}
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand strong { font-size: 15px; }
.auth-brand small, .auth-intro { color: var(--echo-muted); }
.auth-brand small { margin-top: 2px; font-size: 12px; }
.auth-intro { margin: 0 0 30px; line-height: 1.5; }
.auth-label {
  display: block;
  margin: 18px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.auth-input, .request-input, .request-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--echo-line);
  border-radius: 0;
  background: var(--echo-white);
  color: var(--echo-charcoal);
}
.request-input, .request-textarea { margin-top: 10px; }
.auth-input:focus, .request-input:focus, .request-textarea:focus {
  outline: 2px solid rgba(16, 107, 79, .22);
  outline-offset: 1px;
  border-color: var(--echo-green);
}
.btn {
  min-height: 44px;
  padding: 11px 18px;
  border: 1px solid var(--echo-charcoal);
  border-radius: 0;
  cursor: pointer;
  font-weight: 700;
}
.btn-primary { background: var(--echo-charcoal); color: var(--echo-white); }
.btn-secondary { background: var(--echo-white); color: var(--echo-charcoal); }
.auth-submit-full { width: 100%; margin-top: 24px; }
.btn-auth-toggle, .btn-request-submit { width: 100%; margin-top: 10px; }
.auth-secondary-panel[hidden], #authLoginPanel[hidden] { display: none; }
.auth-link-button {
  display: block;
  margin: 10px 0 0 auto;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--echo-charcoal);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-link-back { margin: 22px auto 0; }
.auth-separator { margin: 28px 0 20px; border: 0; border-top: 1px solid var(--echo-line); }
.auth-cta-label { margin: 0; text-align: center; }
.auth-status, .auth-error, .request-message-out {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 3px solid var(--echo-green);
  background: rgba(16, 107, 79, .07);
  color: var(--echo-green);
  font-size: 13px;
  line-height: 1.45;
}
.auth-status.is-error, .auth-error {
  border-left-color: var(--echo-red);
  background: rgba(180, 35, 24, .07);
  color: var(--echo-red);
}
.auth-error.is-success { border-left-color: var(--echo-green); color: var(--echo-green); }
.gate-content-centered { width: min(420px, 100%); text-align: center; }
.gate-title { margin: 0 0 12px; font-size: 28px; font-weight: 700; }
.gate-subtitle { margin: 0; }
.gate-link { color: var(--echo-green); font-weight: 700; text-underline-offset: 3px; }

/* Les modales métier vivent hors des pages montées à la demande. Leur état
   fermé doit donc rester garanti même avec le bundle léger. */
#baseClientCreateModal.base-client-create-modal:not(.active) {
  display: none !important;
  pointer-events: none !important;
}

@media (max-width: 560px) {
  .login-box { padding: 28px 22px; }
  .login-box h1 { margin-top: 30px; font-size: 26px; }
}
