/*
 * Ehfid client — professional theme
 * Uses the same visual language as the administrator dashboard while keeping
 * the client workflows and responsive behaviour intact.
 */

:root {
  --bg: #faf9f5;
  --card: #ffffff;
  --text: #162e33;
  --muted: #5b6b6a;
  --line: #dce4e1;
  --primary: #0b2228;
  --primary-dark: #162e33;
  --accent: #a67c42;
  --accent-soft: #f3ece2;
  --surface-soft: #fffefb;
  --danger: #b91c1c;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --shadow-soft: 0 1px 0 rgba(15, 23, 42, 0.02), 0 1px 3px rgba(15, 23, 42, 0.04);
}

html,
body {
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

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

input,
textarea,
select {
  min-height: 40px;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 124, 66, 0.12);
}

label {
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}

.btn {
  min-height: 38px;
  border: 1px solid var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: #1e293b;
  border-color: #1e293b;
}

.btn:active {
  transform: none;
}

.btn:focus-visible,
.link-btn:focus-visible,
.client-sidebar-link:focus-visible,
.client-user-chip:focus-visible,
.finance-range-tab:focus-visible,
.finance-toggle button:focus-visible {
  outline: 2px solid rgba(166, 124, 66, 0.46);
  outline-offset: 2px;
}

.btn.secondary,
.btn.ghost,
.btn.btn-secondary,
.btn-back {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn.secondary:hover,
.btn.ghost:hover,
.btn.btn-secondary:hover,
.btn-back:hover {
  background: var(--surface-soft);
  border-color: #cbd5e1;
  color: var(--text);
}

.btn.admin-access {
  background: var(--accent-soft);
  border-color: #e4d5c1;
  color: #7b5728;
}

.btn.admin-access:hover {
  background: #eadfce;
  border-color: #d9c3a4;
  color: #69471e;
}

.btn.danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}

.btn.danger:hover {
  background: #fef2f2;
  border-color: #fecaca;
}

.card,
.panel,
.history-filters,
.history-list-shell,
.home-document-panel,
.finance-chart-card,
.finance-vat-card,
.reconciliation-kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.card {
  padding: 18px 20px;
}

.panel {
  border-radius: var(--radius-md);
  padding: 11px 12px;
  box-shadow: none;
  color: var(--muted);
  font-size: 13px;
}

.badge,
.notice {
  border-radius: var(--radius-sm);
}

/* Authentication */
.auth-split {
  width: min(100% - 40px, 980px);
  min-height: 610px;
  margin: max(24px, calc((100dvh - 610px) / 2)) auto;
  grid-template-columns: minmax(320px, 0.82fr) minmax(420px, 1.18fr);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-aside {
  min-height: 100%;
  background: var(--primary);
  color: #fff;
}

.auth-aside-inner {
  padding: 34px;
  gap: 42px;
}

.auth-aside-brand {
  gap: 10px;
  font-size: 13px;
}

.auth-aside-brand img {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  box-shadow: none;
}

.auth-aside-brand > div {
  display: grid;
  gap: 1px;
}

.auth-aside-brand strong {
  font-size: 14px;
  font-weight: 650;
}

.auth-aside-kicker {
  color: rgba(255, 255, 255, 0.62);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.auth-aside-label {
  margin-bottom: 14px;
  color: #d9c29e;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.auth-aside-pitch h2 {
  max-width: 340px;
  margin: 0;
  font-size: clamp(27px, 3vw, 38px);
  line-height: 1.14;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.auth-aside-pitch p {
  max-width: 330px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  line-height: 1.65;
}

.auth-aside-foot {
  color: rgba(255, 255, 255, 0.52);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.auth-main {
  padding: clamp(34px, 5vw, 64px);
  background: #fff;
}

.auth-main-inner {
  max-width: 390px;
  animation: none;
}

.auth-main-inner > h2 {
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-welcome-actions {
  gap: 9px;
  margin-top: 22px;
}

.auth-legal-links {
  justify-content: flex-start;
  margin-top: 22px;
  padding-top: 14px;
  border-top-color: var(--line);
  font-size: 11px;
}

.link-btn {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.link-btn:hover {
  color: var(--accent);
}

/* Client application shell */
.client-shell {
  grid-template-columns: 232px minmax(0, 1fr);
  background: var(--bg);
}

.client-sidebar {
  padding: 18px 14px;
  gap: 14px;
  background: #fff;
  border-right: 1px solid var(--line);
  color: var(--text);
}

.client-brand-block {
  padding: 6px 6px 4px;
}

.client-brand-row {
  gap: 10px;
}

.client-brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  box-shadow: none;
}

.client-brand-kicker {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.client-brand-block h1 {
  margin-top: 1px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.client-sidebar-nav {
  width: 100%;
  align-self: stretch;
  gap: 2px;
  margin-top: 6px;
  min-height: 0;
  overflow-y: auto;
}

.client-sidebar-link {
  min-width: 0;
  min-height: 36px;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.client-sidebar-link:hover {
  background: #f1f5f9;
  border-color: transparent;
  color: var(--text);
}

.client-sidebar-link.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
  font-weight: 600;
}

.client-nav-icon {
  width: 18px;
  height: 18px;
  border-radius: 0;
  background: transparent;
  color: currentColor;
  font-size: 14px;
  font-weight: 600;
}

.client-nav-badge {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  box-shadow: none;
}

.client-sidebar-link.active .client-nav-badge {
  background: #fff;
  color: #0f172a;
}

.client-user-chip {
  padding: 8px;
  border-radius: var(--radius-md);
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.client-user-chip:hover,
.client-user-chip.active {
  background: var(--surface-soft);
  border-color: #cbd5e1;
}

.client-account-menu {
  border-color: var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
}

.client-account-option.active {
  background: var(--accent-soft);
}

.client-account-option:hover:not(:disabled),
.client-account-action:hover,
.client-account-menu-close:hover {
  background: var(--surface-soft);
}

.client-account-avatar {
  background: var(--primary);
}

.client-account-copy span,
.client-account-status,
.client-account-menu-close,
.client-account-chevron {
  color: var(--muted);
}

.client-account-menu-actions {
  border-top-color: var(--line);
}

.client-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
}

.client-user-copy strong {
  font-size: 12px;
  font-weight: 650;
}

.client-user-copy span {
  color: var(--muted);
  font-size: 10px;
}

.client-legal-links {
  gap: 5px 11px;
  padding: 9px 8px 0;
  font-size: 10px;
}

.client-legal-links a {
  color: var(--muted);
}

.client-legal-links a:hover,
.client-legal-links a:focus-visible {
  color: var(--text);
}

.client-main {
  height: 100dvh;
  padding: 22px 28px 28px;
  overflow-y: auto;
}

.client-topbar {
  align-items: center;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.topbar-subtitle {
  margin-top: 2px;
  font-size: 12px;
}

.client-menu-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
}

.client-shell .topbar-actions .btn {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 12px;
}

.shell,
.finance-dashboard,
.history-page,
.invoice-builder-page {
  gap: 14px;
}

.finance-dashboard-head,
.finance-summary-head,
.section-head {
  padding: 0;
}

.finance-dashboard-head {
  align-items: center;
}

.finance-dashboard-head h2,
.finance-summary-head h3,
.section-head h2 {
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.section-head p,
.section-lead {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Overview and financial content */
.finance-head-action {
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.finance-kpis {
  gap: 12px;
}

.finance-kpi-card {
  min-height: 132px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
  color: var(--text);
  grid-template-columns: auto 1fr;
  grid-template-rows: 1fr;
  align-items: flex-start;
  gap: 13px;
}

.finance-kpi-card.light,
.finance-kpi-card.dark {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.finance-kpi-icon,
.finance-kpi-card.dark .finance-kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
}

.finance-kpi-body {
  min-width: 0;
  gap: 5px;
}

.finance-kpi-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.finance-kpi-value {
  color: var(--text);
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 700;
}

.finance-kpi-subtitle {
  color: var(--muted);
  font-size: 11px;
}

.finance-net-pill {
  gap: 11px;
  padding: 13px 15px;
  border-color: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.finance-net-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 16px;
}

.finance-range-tabs {
  gap: 5px;
}

.finance-range-tab {
  border-color: var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}

.finance-range-tab:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.finance-range-tab.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.finance-chart-card {
  padding: 14px;
}

.finance-chart-grid {
  stroke: var(--line);
}

.finance-chart-line-primary {
  stroke: var(--primary);
}

.finance-chart-line-secondary {
  stroke: rgba(166, 124, 66, 0.62);
}

.finance-chart-bubble,
.finance-chart-dot {
  fill: var(--primary);
  filter: none;
}

.finance-chart-hit-area:hover::after,
.finance-chart-hit-area.active::after {
  background: rgba(11, 34, 40, 0.16);
}

.finance-chart-detail {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.finance-toggle {
  width: fit-content;
  min-width: 280px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}

.finance-toggle button {
  border-radius: 7px;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.finance-toggle button.active {
  background: var(--text);
  color: #fff;
  box-shadow: none;
}

.finance-insight {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.finance-ring {
  width: 46px;
  height: 46px;
  background: conic-gradient(var(--accent) calc(var(--progress) * 1turn), var(--accent-soft) 0);
}

.finance-ring::after {
  inset: 6px;
  background: #fff;
}

.finance-insight-copy {
  font-size: 13px;
  font-weight: 600;
}

.finance-insight-arrow {
  color: var(--muted);
}

.finance-vat-card {
  padding: 16px;
}

.finance-vat-head h3 {
  font-size: 15px;
  font-weight: 650;
}

.finance-vat-cell {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

/* Document lists and utility panels */
.home-document-grid {
  gap: 14px;
}

.home-document-panel,
.history-list-shell {
  padding: 16px;
}

.history-filters {
  padding: 14px;
}

.invoice-item {
  border-radius: var(--radius-md);
  padding: 11px 12px;
}

.invoice-item:hover {
  border-color: #cbd5e1;
  background: var(--surface-soft);
}

.invoice-item .title,
.invoice-item .amount {
  font-weight: 650;
}

.install-banner {
  border-color: var(--line);
  background: var(--accent-soft);
  box-shadow: none;
}

.install-banner-copy strong {
  font-weight: 650;
}

.upload-cta {
  border: 1px dashed #b7c5c1;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.upload-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
}

.message-row.me .message-bubble {
  background: var(--primary);
}

.message-bubble,
.message-attachment,
.modal-card,
.invoice-email-editor,
.install-qr-wrap,
.autocomplete-list,
.reconciliation-kpi {
  border-color: var(--line);
  border-radius: var(--radius);
}

.modal-backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
}

.toast {
  background: #fff;
  border-color: var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.toast-icon {
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}

.invoice-email-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 124, 66, 0.12);
}

.invoice-email-editor-chip,
.invoice-email-inline-chip,
.invoice-email-token {
  border-color: #e4d5c1;
  background: var(--accent-soft);
  color: #7b5728;
}

.invoice-email-token:hover {
  background: #eadfce;
}

.autocomplete-item:hover,
.autocomplete-item:focus {
  background: var(--accent-soft);
}

.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary);
  box-shadow: var(--shadow-soft);
}

.profile-logo-preview,
.profile-logo-placeholder {
  border-radius: var(--radius-md);
}

.invoice-builder-headline h2 {
  font-size: 22px;
  font-weight: 700;
}

.reconciliation-kpi-value {
  font-size: 22px;
  font-weight: 700;
}

/* Agenda : calendrier dense et lisible, cohérent avec l'espace client. */
.agenda-page-head h2 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.agenda-calendar-card,
.agenda-day-panel {
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.agenda-day {
  border-color: #e4e9e7;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.agenda-day:hover {
  border-color: #c9d3cf;
  background: var(--surface-soft);
}

.agenda-day.is-outside {
  background: #fbfbfa;
  color: #94a09d;
}

.agenda-day.is-today .agenda-day-number {
  background: var(--accent-soft);
  color: #765322;
}

.agenda-day.is-selected {
  border-color: var(--primary);
  background: #f6f8f7;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.agenda-day.is-selected .agenda-day-number {
  background: var(--primary);
  color: #fff;
}

.agenda-day-count {
  background: #eef2f0;
  color: var(--primary);
}

.agenda-day-preview {
  border-left: 2px solid var(--accent);
  color: #42514f;
}

.agenda-day-preview.has-unread {
  border-left-color: var(--danger);
  color: var(--text);
  font-weight: 700;
}

.agenda-nearest-reminder {
  border-color: #e4d5c1;
  background: var(--accent-soft);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.agenda-nearest-reminder:hover:not(:disabled) {
  border-color: #d4bc9c;
  background: #eee3d5;
}

.agenda-event-row {
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.agenda-event-row:hover {
  border-color: #cbd5e1;
  background: var(--surface-soft);
}

.agenda-event-row.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.agenda-event-time {
  color: #765322;
}

.agenda-reminder-status {
  padding: 5px 8px;
  border: 1px solid #e4d5c1;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #765322;
}

.agenda-settings-switch:hover {
  border-color: #cbd5e1;
  background: var(--surface-soft);
}

.agenda-settings-switch input:checked + .agenda-settings-track {
  background: var(--primary);
}

.agenda-settings-switch:has(input:disabled) {
  cursor: wait;
  opacity: 0.68;
}

.agenda-day:focus-visible,
.agenda-event-row:focus-visible,
.agenda-nearest-reminder:focus-visible,
.agenda-settings-switch:has(input:focus-visible) {
  outline: 2px solid rgba(166, 124, 66, 0.52);
  outline-offset: 2px;
}

.btn-back {
  border-radius: var(--radius-sm);
}

@media (max-width: 980px) {
  .client-shell {
    grid-template-columns: 1fr;
  }

  .auth-split {
    width: min(100% - 28px, 620px);
    min-height: auto;
    margin: 14px auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .auth-aside {
    min-height: auto;
  }

  .auth-aside-inner {
    justify-content: center;
    padding: 20px 22px;
  }

  .auth-aside-pitch,
  .auth-aside-foot {
    display: none;
  }

  .auth-main {
    padding: 28px 22px 32px;
  }

  .client-sidebar {
    width: min(86vw, 264px);
    box-shadow: 18px 0 42px rgba(15, 23, 42, 0.12);
  }

  .client-overlay {
    background: rgba(15, 23, 42, 0.42);
  }

  .client-main {
    height: auto;
    min-height: 100dvh;
    padding: 14px 14px calc(22px + env(safe-area-inset-bottom));
  }

  .client-topbar {
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 13px;
  }

  .client-shell .topbar-actions {
    width: auto;
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .auth-split {
    width: 100%;
    margin: 0;
    min-height: 100dvh;
    grid-template-rows: 112px minmax(0, 1fr);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-main {
    align-items: start;
    padding: 28px 18px calc(30px + env(safe-area-inset-bottom));
  }

  .client-topbar {
    flex-direction: row;
    align-items: flex-start;
  }

  .client-shell .topbar-actions {
    width: auto;
  }

  .client-shell .topbar-actions-main {
    justify-content: flex-end;
  }

  .client-shell .topbar-actions .btn {
    width: auto;
  }

  .client-shell .topbar-actions .btn span {
    display: none;
  }

  .topbar-title {
    font-size: 19px;
  }

  .finance-dashboard-head,
  .finance-summary-head,
  .section-head {
    gap: 10px;
  }

  .finance-kpis {
    grid-template-columns: 1fr;
  }

  .finance-kpi-card {
    min-height: 112px;
  }

  .finance-net-pill {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .finance-net-meta {
    width: 100%;
    padding-left: 45px;
  }

  .finance-range-tabs {
    flex-wrap: nowrap;
    margin-inline: -14px;
    padding: 0 14px 5px;
    overflow-x: auto;
  }

  .finance-range-tab {
    flex: 0 0 auto;
  }

  .finance-toggle {
    width: 100%;
    min-width: 0;
  }

  .finance-vat-grid {
    grid-template-columns: 1fr;
  }

  .home-document-panel,
  .history-list-shell,
  .card {
    border-radius: var(--radius-md);
    padding: 14px;
  }

  .agenda-day-preview {
    display: none;
  }
}

@media (max-width: 390px) {
  .client-main {
    padding-inline: 10px;
  }

  .client-topbar {
    gap: 9px;
  }

  .client-shell .topbar-actions-main {
    gap: 5px;
  }

  .finance-dashboard-head .inline-actions {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
  }

  .finance-dashboard-head .btn {
    width: 100%;
  }
}

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