@import url('brand.css');

/* ==========================================================================
   Base
   ========================================================================== */

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--color-page-bg);
  color: var(--color-text);
}

[hidden] {
  display: none !important;
}

body.auth-booting #app-content {
  display: none !important;
}

html.auth-pending-restore body.auth-booting #auth-gate {
  display: none !important;
}

html.auth-pending-restore #auth-loading-overlay:not([hidden]) {
  display: flex !important;
}

body.auth-booting #auth-gate {
  visibility: visible;
}

body.auth-booting #google-signin-button {
  visibility: hidden;
}

body.auth-booting #auth-gate-verifying {
  display: block !important;
}

.auth-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--auth-loading-fade-ms, 1s) ease;
}

.auth-loading-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-loading-overlay__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.auth-loading-overlay .pass-spinner {
  background-size: 185% 185%;
}

.auth-loading-overlay__message {
  margin: 0;
  color: var(--color-muted);
  font-size: 15px;
  line-height: 1.4;
  max-width: 20rem;
}

.auth-loading-overlay--welcome .auth-loading-overlay__message {
  font-size: 18px;
  color: var(--color-text-secondary);
  white-space: pre-line;
}

.site-header {
  position: relative;
  z-index: 30;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.site-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-header__auth {
  position: relative;
  flex-shrink: 0;
}

.auth-header-logged-in {
  display: flex;
  align-items: center;
}

.google-signin-button {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.google-signin-button--gate {
  position: static;
  width: auto;
  height: auto;
  margin: 0 auto;
  padding: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.google-signin-button--gate.is-verifying {
  opacity: 0.55;
  pointer-events: none;
}

.auth-gate__verifying {
  margin: 12px 0 0;
  color: var(--color-muted);
  font-size: 14px;
}

.auth-login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-login-button:hover:not(:disabled) {
  border-color: var(--color-brand-bronze);
  box-shadow: var(--shadow-card);
  background: var(--color-surface);
  color: var(--color-text);
}

.auth-login-button--compact {
  padding: 8px 16px;
  font-size: 13px;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--color-text);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded='true'] {
  background: var(--color-page-bg);
  border-color: var(--color-border);
  color: var(--color-text);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-border);
  flex-shrink: 0;
}

.user-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-brand-slate);
  color: var(--color-on-primary);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-display-name {
  font-size: 14px;
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  z-index: 20;
}

.user-menu-email {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--color-muted);
  word-break: break-all;
}

.user-menu-signout {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.user-menu-signout:hover {
  background: var(--color-page-bg);
  color: var(--color-text);
}

.session-banner {
  background: var(--color-brand-bronze-muted);
  border-bottom: 1px solid var(--color-border);
}

.session-banner__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-left: 3px solid var(--color-brand-bronze);
  padding-left: 21px;
}

.session-banner__text {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}

.session-banner__action {
  flex-shrink: 0;
  padding: 8px 16px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.session-banner__action:hover {
  background: var(--color-brand-slate);
  border-color: var(--color-brand-slate);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-card);
}

.auth-gate {
  max-width: 1100px;
  margin: 48px auto;
  padding: 0 24px;
}

.auth-gate__card {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 36px;
  text-align: center;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.auth-gate__title {
  margin: 0 0 12px;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-gate__text {
  margin: 0 0 28px;
  color: var(--color-muted);
  line-height: 1.55;
}

.auth-gate__card .app-notice {
  margin-top: 16px;
}

.auth-login-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.brand-logo {
  display: block;
  height: var(--logo-height);
  width: auto;
}

.page {
  max-width: 1100px;
  margin: 32px auto 40px;
  padding: 0 24px;
  min-width: 0;
}

#analysis-sections {
  max-width: 100%;
  min-width: 0;
}

h1 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h2 {
  margin-top: 0;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.hero {
  position: relative;
  z-index: 1;
  margin-bottom: 28px;
  padding: 0;
  isolation: isolate;
}

.hero::before {
  content: '';
  position: absolute;
  top: -12px;
  right: -14px;
  bottom: -14px;
  left: -14px;
  z-index: -1;
  border-radius: var(--radius-md);
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.hero h2 {
  margin: 0 0 12px;
}

.hero form {
  margin-bottom: 0;
}

.search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 15;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(37, 37, 48, 0.24);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  cursor: default;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

body.search-overlay-active .search-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.search-overlay-active .hero {
  z-index: 20;
}

body.search-overlay-active .hero::before {
  background: var(--color-surface);
  box-shadow: 0 10px 40px rgba(37, 37, 48, 0.1);
}

body.search-overlay-active .search-help {
  color: var(--color-text-secondary);
}

@media (prefers-reduced-transparency: reduce) {
  .search-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(37, 37, 48, 0.32);
  }
}

@media (prefers-reduced-motion: reduce) {
  .search-backdrop {
    transition: none;
  }

  .hero::before {
    transition: none;
  }
}

.search-field {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

#search-form {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0;
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: outline 0.15s ease, border-color 0.15s ease;
}

.search-field:focus-within #search-form {
  border-color: var(--color-brand-bronze);
  outline: 2px solid rgba(197, 157, 95, 0.35);
  outline-offset: 1px;
}

.search-field--busy #search-form {
  opacity: 0.75;
}

#search-form input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.25;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
}

#search-form input::-webkit-search-cancel-button {
  display: none;
}

#search-form input:focus {
  outline: none;
}

.search-help {
  margin: 8px 0 0;
  color: var(--color-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.search-suggestions {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: min(52vh, 520px);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.search-suggestions__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.search-suggestions[hidden] {
  display: none;
}

.search-suggestion {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.search-suggestions__list .search-suggestion:last-child {
  border-bottom: 0;
}

.search-suggestion:hover,
.search-suggestion--active {
  background: rgba(197, 157, 95, 0.12);
}

.search-suggestion__label {
  display: block;
  font-weight: 600;
  line-height: 1.3;
}

.search-suggestion__subtitle {
  display: block;
  margin-top: 2px;
  color: var(--color-muted);
  font-size: 0.875rem;
  line-height: 1.35;
}

.search-suggestions__status {
  padding: 12px 14px;
  color: var(--color-muted);
  font-size: 0.9375rem;
}

.search-suggestions__status--footer {
  flex-shrink: 0;
  padding: 8px 14px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: 0 -4px 10px rgba(15, 23, 42, 0.06);
  font-size: 0.8125rem;
  font-style: italic;
}

.hero .app-notice {
  margin: 12px 0 0;
}

.subtitle {
  margin-bottom: 32px;
  color: var(--color-muted);
  font-weight: 300;
  line-height: 1.5;
}

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

/* ==========================================================================
   Composants
   ========================================================================== */

.card {
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  max-width: 100%;
  min-width: 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--color-muted);
  font-size: 14px;
}

.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border-input);
  flex-shrink: 0;
}

.status[hidden] {
  display: none;
}

.status--loading {
  color: var(--color-text-secondary);
  gap: 4px;
}

.status--loading::before {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 0;
  background: transparent;
  background-image: url('../assets/pass-spinner.svg');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  animation: pass-spinner-rotate 2.4s linear infinite;
}

.pass-spinner {
  display: inline-block;
  flex-shrink: 0;
  background: transparent url('../assets/pass-spinner.svg') center / contain no-repeat;
  animation: pass-spinner-rotate 2.4s linear infinite;
}

.pass-spinner--sm {
  width: 44px;
  height: 44px;
}

.pass-spinner--md {
  width: 56px;
  height: 56px;
}

.pass-spinner--lg {
  width: 72px;
  height: 72px;
}

.pass-spinner--xl {
  width: 112px;
  height: 112px;
}

@keyframes pass-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .status--loading::before,
  .pass-spinner,
  .auth-loading-overlay {
    animation-duration: 4.8s;
    transition-duration: 0.01ms;
  }
}

.status--success {
  color: var(--color-text-secondary);
}

.status--success::before {
  background: var(--color-success);
}

.app-notice {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
}

.app-notice__text {
  margin: 0;
  padding-left: 12px;
  border-left: 2px solid var(--color-brand-bronze);
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-text-secondary);
}

.app-notice__text--critical {
  color: var(--color-error);
  border-left-color: var(--color-error);
}

.card > .app-notice {
  margin-bottom: 16px;
}

.app-notice[hidden] {
  display: none;
}

.section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-heading);
}

.section-title--sm {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-secondary);
}

.empty {
  padding: 28px 20px;
  background: var(--color-surface-muted);
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-muted);
  font-size: 14px;
  text-align: center;
  line-height: 1.5;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  margin: 2px 4px 2px 0;
  border-radius: var(--radius-pill);
  background: var(--color-accent-bg);
  color: var(--color-accent-text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
}

/* ==========================================================================
   Formulaire
   ========================================================================== */

form {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

input {
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  min-width: 240px;
  background: var(--color-surface);
  transition: border-color 0.15s ease, outline 0.15s ease;
}

input:focus {
  outline: 2px solid var(--color-brand-bronze);
  outline-offset: 2px;
  border-color: transparent;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--color-text);
  caret-color: var(--color-text);
  box-shadow: 0 0 0 1000px var(--color-surface) inset;
  transition: background-color 9999s ease-out 0s;
}

button {
  font-family: inherit;
}

/* ==========================================================================
   Tableau et filtres
   ========================================================================== */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px 0;
}

.linked-companies-warnings {
  margin: 0 0 12px;
}

.linked-companies-count {
  margin: 0 0 12px;
  color: var(--color-muted);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.35;
  opacity: 0.82;
}

.linked-companies-toggle {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.linked-companies-toggle:hover {
  background: var(--color-accent-bg);
  border-color: var(--color-brand-bronze);
}

.linked-companies-table tbody tr {
  background: transparent;
}

.linked-companies-table .app-table-row--striped {
  background: rgba(250, 249, 247, 0.8);
}

.linked-companies-table .app-table-row--external {
  background: rgba(15, 23, 42, 0.04);
}

.linked-companies-table .app-table-row--external td,
.company-missions-table .app-table-row--external td {
  color: var(--color-muted);
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.filter-pill:hover {
  background: var(--color-accent-bg);
  border-color: var(--color-brand-bronze);
}

.filter-pill.active {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-primary);
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  font-size: 14px;
}

th,
td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

th {
  background: transparent;
  color: var(--color-text-heading);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--color-brand-dark);
  padding-bottom: 10px;
}

td {
  color: var(--color-text);
  font-weight: 400;
}

tbody tr:nth-child(even) {
  background: rgba(250, 249, 247, 0.8);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Graphique
   ========================================================================== */

.chart-wrap {
  border: none;
  border-radius: var(--radius-md);
  padding: 20px 16px 16px;
  background: var(--color-surface-muted);
  overflow: hidden;
}

.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.chart-subtitle {
  color: var(--color-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ==========================================================================
   Analyse de trésorerie v2
   ========================================================================== */

.treasury-v2 {
  display: grid;
  gap: 20px;
}

.treasury-v2-coverage {
  margin: 0;
  font-size: 13px;
}

.treasury-v2-perimeter {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  overflow: hidden;
}

.treasury-v2-perimeter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.treasury-v2-perimeter-count {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted);
}

.treasury-v2-perimeter-list {
  display: grid;
  gap: 0;
}

.treasury-v2-company + .treasury-v2-company {
  border-top: 1px solid var(--color-border);
}

.treasury-v2-company-row,
.treasury-v2-account-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.treasury-v2-company-row:hover,
.treasury-v2-account-row:hover {
  background: rgba(197, 157, 95, 0.08);
}

.treasury-v2-company--muted .treasury-v2-company-name,
.treasury-v2-company--muted .treasury-v2-company-row {
  color: var(--color-muted);
}

.treasury-v2-company--error .treasury-v2-company-name {
  color: var(--color-error);
}

.treasury-v2-company--loading .treasury-v2-company-name {
  color: var(--color-text-secondary);
}

.treasury-v2-company-row--disabled {
  cursor: default;
}

.treasury-v2-company-label {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.treasury-v2-company-name,
.treasury-v2-account-name {
  font-size: 14px;
  line-height: 1.35;
}

.treasury-v2-company-name {
  font-weight: 600;
}

.treasury-v2-account-hint {
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.35;
}

.treasury-v2-accounts {
  padding: 0 14px 10px 42px;
  display: grid;
  gap: 2px;
}

.treasury-v2-account-row {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}

.treasury-v2-account-name {
  font-weight: 400;
  color: var(--color-text-secondary);
}

.treasury-v2-company-row input[type='checkbox'],
.treasury-v2-account-row input[type='checkbox'] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.treasury-v2-checkmark {
  position: relative;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1.5px solid var(--color-border-input);
  border-radius: 4px;
  background: var(--color-surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.treasury-v2-checkmark::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid var(--color-on-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.12s ease;
}

.treasury-v2-company-row input:checked + .treasury-v2-checkmark,
.treasury-v2-account-row input:checked + .treasury-v2-checkmark {
  border-color: var(--color-brand-bronze);
  background: var(--color-brand-bronze);
}

.treasury-v2-company-row input:checked + .treasury-v2-checkmark::after,
.treasury-v2-account-row input:checked + .treasury-v2-checkmark::after {
  transform: rotate(45deg) scale(1);
}

.treasury-v2-company-row input:indeterminate + .treasury-v2-checkmark {
  border-color: var(--color-brand-bronze);
  background: var(--color-brand-bronze);
}

.treasury-v2-company-row input:indeterminate + .treasury-v2-checkmark::after {
  top: 7px;
  left: 3px;
  width: 10px;
  height: 0;
  border-width: 0 0 2px 0;
  transform: none;
}

.treasury-v2-company-row input:disabled + .treasury-v2-checkmark,
.treasury-v2-account-row input:disabled + .treasury-v2-checkmark {
  opacity: 0.45;
  cursor: not-allowed;
}

.treasury-v2-company-row input:disabled ~ .treasury-v2-company-label,
.treasury-v2-company-row input:disabled ~ .treasury-v2-company-name,
.treasury-v2-account-row input:disabled ~ .treasury-v2-account-name {
  opacity: 0.6;
}

.treasury-v2-status-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.treasury-v2-status-badge--loading {
  background: rgba(197, 157, 95, 0.18);
  color: var(--color-accent-text);
}

.treasury-v2-status-badge--muted {
  background: var(--color-surface-muted);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

.treasury-v2-status-badge--error {
  background: rgba(180, 48, 48, 0.1);
  color: var(--color-error);
}

.treasury-v2-company-error {
  margin: 0 14px 10px 42px;
  font-size: 12px;
}

.treasury-v2-evolution {
  display: grid;
  gap: 16px;
}

.treasury-v2-chart-shell {
  position: relative;
}

.treasury-v2-chart-shell--loading .treasury-v2-chart-host {
  opacity: 0.42;
  pointer-events: none;
}

.treasury-v2-chart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.45);
}

.treasury-v2-evolution--loading .treasury-v2-recap,
.treasury-v2-recap--loading {
  opacity: 0.72;
}

.treasury-v2-chart-host,
.treasury-v2-chart-placeholder {
  min-height: 200px;
}

.treasury-v2-chart-placeholder {
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--color-surface-muted) 0%,
    #f0eeea 50%,
    var(--color-surface-muted) 100%
  );
  background-size: 200% 100%;
  animation: treasury-v2-shimmer 1.4s ease-in-out infinite;
}

@keyframes treasury-v2-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.treasury-v2-recap {
  display: grid;
  gap: 6px;
}

.treasury-v2-recap-table {
  width: 100%;
  min-width: 520px;
  font-size: 13px;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}

.treasury-v2-recap-table th,
.treasury-v2-recap-table td {
  padding: 7px 10px;
  vertical-align: middle;
  border: none;
}

.treasury-v2-recap-table thead th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-bottom: 6px;
  white-space: nowrap;
  color: var(--color-muted);
  background: transparent;
  border: none;
}

.treasury-v2-recap-table tbody tr {
  background: transparent;
}

.treasury-v2-recap-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.treasury-v2-recap-row--total th,
.treasury-v2-recap-row--total td {
  font-weight: 700;
  color: var(--color-text-heading);
  background: var(--color-accent-bg);
}

.treasury-v2-recap-row--company th,
.treasury-v2-recap-row--company td {
  font-weight: 600;
  background: var(--color-surface-muted);
}

.treasury-v2-recap-row--account th {
  font-weight: 400;
  padding-left: 22px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
}

.treasury-v2-recap-row--account td {
  background: var(--color-surface);
}

.treasury-v2-recap-legend {
  margin: 0;
  font-size: 12px;
}

.treasury-v2-recap-placeholder {
  min-height: 72px;
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
}

.treasury-v2-chart .chart-subtitle {
  display: none;
}

.treasury-v2-aggregate-error {
  color: var(--color-error);
  font-size: 14px;
}

@media (max-width: 519px) {
  .treasury-v2 {
    gap: 16px;
  }

  .treasury-v2-perimeter-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .treasury-v2-accounts {
    padding-left: 22px;
  }

  .treasury-v2-company-error {
    margin-left: 14px;
  }

  .treasury-v2-recap-table {
    min-width: 480px;
  }

  .treasury-v2-recap-table th,
  .treasury-v2-recap-table td {
    padding: 7px 8px;
  }

  .treasury-v2-chart-host,
  .treasury-v2-chart-placeholder {
    min-height: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .treasury-v2-chart-placeholder {
    animation: none;
  }
}

/* ==========================================================================
   Détails entreprise
   ========================================================================== */

#company-profile-tabs,
#company-profile-content,
#company-missions-tabs,
#company-missions-content {
  min-width: 0;
  max-width: 100%;
}

#company-profile-tabs,
#company-missions-tabs {
  margin-bottom: 8px;
}

#company-profile-status:not([hidden]),
#company-missions-status:not([hidden]) {
  margin-top: 12px;
  margin-bottom: 16px;
}

.company-details-context-label {
  margin: 0;
  color: var(--color-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

#company-profile-content,
#company-missions-content {
  margin-top: 16px;
}

.company-info-row--badges {
  align-items: center;
}

.company-info-row--badges .company-details-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.company-info-row--badges .company-details-siren-inline,
.company-info-row .company-details-siren-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
}

.company-details-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.company-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.company-badge--type {
  background: var(--color-accent-bg);
  color: var(--color-accent-text);
}

.company-badge--legal {
  background: var(--color-surface-muted);
  color: var(--color-muted-dark);
}

.company-badge--is {
  background: #e8eaf6;
  color: #3949ab;
}

.company-details-siren-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.company-details-siren__value {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  letter-spacing: 0.02em;
}

.company-copy-siren {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  padding: 2px;
  line-height: 0;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}

.company-copy-siren:hover {
  color: var(--color-brand-bronze);
  background: var(--color-surface-muted);
}

.company-copy-siren svg {
  display: block;
}

.company-details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.company-info-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.company-info-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 22px;
}

.company-info-row__icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 22px;
  color: var(--color-muted);
}

.company-info-row__value,
.company-info-row__link {
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-text);
  word-break: break-word;
}

.company-info-row__link {
  color: var(--color-brand-bronze);
  text-decoration: none;
}

.company-info-row__link:hover {
  text-decoration: underline;
}

.company-shortcuts-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.company-shortcut {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.company-shortcut:hover {
  background: var(--color-accent-bg);
  color: var(--color-accent-text);
}

.company-missions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.company-missions-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.company-missions-layout > .app-notice {
  margin-bottom: 0;
}

.company-missions .table-wrap + .company-missions-summary {
  margin-top: 4px;
}

.company-missions-col--comment {
  min-width: 10rem;
}

.company-missions-col--billing-status {
  min-width: 5.5rem;
}

.company-missions-table__comment {
  white-space: normal;
  word-break: break-word;
}

.company-missions-table tbody tr {
  background: transparent;
}

.company-missions-table .app-table-row--external {
  background: rgba(15, 23, 42, 0.04);
}

.company-missions-table {
  width: 100%;
  table-layout: auto;
}

.company-missions-table thead th {
  white-space: normal;
  line-height: 1.25;
  padding: 10px 8px;
  vertical-align: bottom;
  letter-spacing: 0.02em;
}

/* Colonnes à contenu court : largeur minimale, pas d’étirement */
.company-missions-col--company {
  min-width: 7rem;
}

.company-missions-col--mission {
  width: 1%;
  max-width: 200px;
}

.company-missions-col--amount {
  width: 1%;
}

.company-missions-col--charge {
  min-width: 9.5rem;
}

.company-missions-col--cloture {
  min-width: 5.75rem;
}

.company-missions-col--rec-tva {
  min-width: 4.75rem;
}

.company-missions-col--teis {
  min-width: 5.5rem;
}

.company-missions-table__mission {
  text-align: center;
  width: 1%;
  max-width: 200px;
}

.company-mission-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.company-mission-name {
  font-size: 11px;
  line-height: 1.3;
  font-weight: 400;
  color: var(--color-muted);
  text-align: center;
}

.company-missions-table__amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.company-missions-table__charge {
  white-space: normal;
  word-break: break-word;
}

.company-missions-year-filters {
  margin-bottom: 4px;
}

.company-missions-year-filters .filters {
  margin-bottom: 0;
}

.company-missions-table tbody .company-missions-table__amount {
  white-space: nowrap;
}

.company-missions-table tbody td:nth-child(4),
.company-missions-table tbody td:nth-child(5),
.company-missions-table tbody td:nth-child(7) {
  white-space: normal;
  word-break: break-word;
}

.company-missions-summary {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-secondary);
  text-align: right;
}


.mission-type {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  max-width: 9rem;
  text-align: center;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}

.mission-type--accounting { background: #e8f4fd; color: #1565c0; }
.mission-type--ago { background: #f3e5f5; color: #7b1fa2; }
.mission-type--pilotage { background: #e8f5e9; color: #2e7d32; }
.mission-type--support { background: #fff3e0; color: #ef6c00; }
.mission-type--creation { background: #fce4ec; color: #c2185b; }
.mission-type--social { background: #e0f2f1; color: #00695c; }
.mission-type--cac { background: #ede7f6; color: #4527a0; }
.mission-type--training { background: #f1f8e9; color: #558b2f; }
.mission-type--legal { background: #eceff1; color: #455a64; }
.mission-type--budget { background: #fff8e1; color: #f57f17; }
.mission-type--default { background: var(--color-surface-muted); color: var(--color-muted-dark); }

.company-missions-table .mission-type--closed {
  background: var(--color-surface);
  color: var(--color-muted-dark);
  border: 1px solid var(--color-border);
  text-decoration: line-through;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 800px) {
  .company-details-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 520px) {
  .site-header__inner {
    padding: 16px;
  }

  .brand-logo {
    height: 36px;
    max-width: min(160px, 52vw);
    object-fit: contain;
  }

  .site-header__auth {
    margin-left: auto;
  }

  .user-menu-trigger {
    min-width: 40px;
    min-height: 40px;
    padding: 4px;
  }

  .user-display-name {
    display: none;
  }

  .auth-gate {
    margin: 24px auto;
    padding: 0 16px;
  }

  .auth-gate__card {
    padding: 28px 20px;
  }

  .user-menu {
    min-width: min(280px, calc(100vw - 32px));
  }

  .page {
    padding: 0 16px;
  }

  .hero {
    margin-bottom: 20px;
  }

  .search-field,
  #search-form {
    max-width: none;
  }

  .search-suggestions {
    max-height: min(62vh, 520px);
  }

  .card {
    padding: 16px;
  }

  #company-missions-content .table-wrap th,
  #company-missions-content .table-wrap td {
    padding: 10px 8px;
  }

  table {
    font-size: 13px;
  }

  th,
  td {
    padding: 10px;
  }

  .badge {
    font-size: 11px;
    padding: 2px 6px;
  }
}
