/* Palette claire/sombre et corrections de contraste. Les composants utilisent les variables plutôt que des couleurs propres. */
/* Le thème modifie la présentation, sans recréer les éditeurs ni leur état. */
:root {
  color: var(--ink);
  background: var(--canvas);
  color-scheme: light;
  --focus: #6544bf;
}
.topbar-tools {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}
.theme-picker {
  display: grid;
  gap: 4px;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
}
.theme-picker select {
  max-width: 145px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 10px;
  font-size: 11px;
  cursor: pointer;
}
:is(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
input,
select,
textarea {
  accent-color: var(--violet);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eeeaf7;
  --muted: #b7afc7;
  --line: #494154;
  --canvas: #17141f;
  --surface: #231e2d;
  --surface-soft: #2d263a;
  --field: #1c1825;
  --violet: #c3a8ff;
  --violet-dark: #dbc8ff;
  --violet-soft: #382b51;
  --lilac: #b6a0dc;
  --green: #9adebc;
  --amber: #f2cc8a;
  --focus: #c3a8ff;
  --shadow: 0 16px 42px #00000026;
  --success-bg: #203b32;
  --success-ink: #a1e3bd;
  --success-line: #3b6854;
  --warning-bg: #3c3020;
  --warning-ink: #f2cc8a;
  --warning-line: #78603b;
  --danger-bg: #40262e;
  --danger-ink: #ffb6c1;
  --danger-line: #80505b;
}
/* Surfaces communes : connexion, formulaires, archives et confirmations. */
:root[data-theme="dark"]
  :is(
    .topbar,
    .login-layout,
    .story-card,
    .workspace-chip,
    .staff-period,
    .panel,
    .side-panel,
    .filter-card,
    .submission-card,
    .entry-card,
    .rh-date-badge,
    .empty,
    .policy-grid,
    .user-form,
    .daily-day,
    .daily-day-content,
    .daily-entry,
    dialog
  ) {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"]
  :is(
    .quiet-side,
    .period-rule,
    .day-copy-controls,
    .team-counts > div,
    th,
    .daily-empty,
    .daily-meal,
    .daily-receipt,
    .lock-mark
  ) {
  background: var(--surface-soft);
  border-color: var(--line);
}
:root[data-theme="dark"] .login-story {
  background: linear-gradient(137deg, #322047 0%, #49316d 53%, #5a3c83 100%);
}
:root[data-theme="dark"] .login-story h1 {
  color: #fff;
}
:root[data-theme="dark"]
  :is(.brand-copy b, .empty b, .daily-empty strong, .team-counts strong) {
  color: var(--ink);
}
:root[data-theme="dark"]
  :is(
    .brand-copy small,
    .story-card small,
    .workspace-chip small,
    .staff-period small,
    .rh-date-badge small,
    .login-foot,
    .side-note,
    .section-title p,
    .entry-card-head small,
    .entry-card label,
    .upload-hint,
    .submit-strip span,
    .side-panel > p,
    .workflow-step,
    .workflow small,
    .quiet-side p,
    .tab,
    .submission-main small,
    .submission-count,
    .empty,
    .audit-list p,
    .site-footer,
    .import-row > span,
    .day-copy-controls span,
    .team-counts span,
    .team-profile,
    .archive-row small,
    .excel-panel > p,
    .archive-dialog small,
    .daily-navigation p:not(.eyebrow),
    .daily-day > span,
    .daily-day > small,
    .daily-day-heading p:not(.eyebrow),
    .daily-status-label,
    .daily-totals span,
    .daily-totals small,
    .daily-duration,
    .daily-place,
    .daily-review-check,
    .daily-fields label,
    .daily-receipt small,
    .daily-missing,
    .daily-meal label,
    .daily-meal p,
    .submission-delete-area p,
    th
  ) {
  color: var(--muted);
}
:root[data-theme="dark"]
  :is(
    .stack label,
    .policy-grid label,
    .user-form label,
    .correction-box label,
    .filters label,
    .month-picker,
    .archive-filters label,
    .login-foot b
  ) {
  color: var(--ink);
}
:root[data-theme="dark"]
  :is(
    .period-heading,
    .expense-title,
    .submit-strip,
    .login-foot,
    .workflow,
    .workflow-step,
    .tabs,
    th,
    td,
    .audit-list p,
    .site-footer,
    .daily-totals,
    .daily-totals > div,
    .daily-column + .daily-column,
    .daily-editor
  ) {
  border-color: var(--line);
}
:root[data-theme="dark"]
  :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  background: var(--field);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] :is(input, textarea)::placeholder {
  color: #a59ab8;
  opacity: 1;
}
:root[data-theme="dark"] :is(input, select, textarea):disabled {
  color: var(--muted);
  opacity: 0.7;
}
:root[data-theme="dark"] input[type="file"]::file-selector-button {
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  margin-right: 9px;
}
:root[data-theme="dark"] :is(.button-primary, .workflow-step.current) {
  background: #7751ba;
  color: #fff;
  border-color: #9973dc;
}
:root[data-theme="dark"] .button-primary:hover {
  background: #8760cb;
}
:root[data-theme="dark"]
  :is(
    .button-secondary,
    .button-outline,
    .button-quiet,
    .delete-entry,
    .icon-button,
    .daily-week-control button
  ) {
  background: var(--surface-soft);
  color: var(--violet);
  border-color: var(--line);
}
:root[data-theme="dark"]
  :is(
    .button-secondary,
    .button-outline,
    .button-quiet,
    .delete-entry,
    .icon-button,
    .daily-week-control button
  ):hover {
  background: var(--violet-soft);
}
:root[data-theme="dark"]
  :is(
    .brand-mark,
    .section-number,
    .lavender,
    .version-icon,
    .daily-column-icon,
    .daily-column-heading h3 small,
    .entry-type,
    .notice,
    .status-banner,
    .daily-breakfast-budget
  ) {
  background: var(--violet-soft);
  color: var(--violet);
  border-color: #63517f;
}
:root[data-theme="dark"] .brand-mark {
  background: #f0ecfa;
  border-color: #b6a0dc;
}
:root[data-theme="dark"] .footer-brand {
  color: var(--violet);
}
:root[data-theme="dark"] .tab.active {
  color: var(--violet);
  border-color: var(--violet);
}
:root[data-theme="dark"] .daily-day.is-selected {
  background: var(--violet-soft);
  border-color: var(--violet);
  box-shadow: 0 0 0 1px var(--violet);
}
:root[data-theme="dark"]
  :is(
    .daily-day.is-selected > span,
    .daily-day.is-selected > small,
    .daily-receipt,
    .account-editor summary
  ) {
  color: var(--violet);
}
:root[data-theme="dark"] .travel-type {
  background: #26344b;
  color: #b9cffa;
}
:root[data-theme="dark"] :is(.status) {
  background: var(--surface-soft);
  color: var(--muted);
}
:root[data-theme="dark"] :is(.status-submitted, .daily-warning, .preflight) {
  background: var(--warning-bg);
  color: var(--warning-ink);
  border-color: var(--warning-line);
}
:root[data-theme="dark"] :is(.preflight button, .matrix-missing) {
  color: var(--warning-ink);
}
:root[data-theme="dark"]
  :is(
    .status-approved,
    .shield,
    .quiet-check,
    .entry-type.expense-type,
    .expenses-icon
  ) {
  background: var(--success-bg);
  color: var(--success-ink);
  border-color: var(--success-line);
}
:root[data-theme="dark"] :is(.archive-mark, .draft-status) {
  color: var(--success-ink);
}
:root[data-theme="dark"]
  :is(
    .status-changes_requested,
    .submission-delete-area .button-danger,
    .submission-delete-dialog .button-danger
  ) {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-color: var(--danger-line);
}
:root[data-theme="dark"]
  :is(
    .error,
    #user-action-error,
    .daily-delete,
    .user-delete,
    .submission-delete-dialog .submission-delete-error
  ) {
  color: var(--danger-ink);
}
:root[data-theme="dark"]
  :is(
    .submission-delete-area .button-danger,
    .submission-delete-dialog .button-danger
  ):hover {
  background: #56303b;
}
:root[data-theme="dark"] dialog::backdrop {
  background: #09070fb3;
}
:root[data-theme="dark"] .toast {
  background: #e6def6;
  color: #231b32;
}
:root[data-theme="dark"] .archive-dialog progress::-webkit-progress-bar {
  background: var(--surface-soft);
}
:root[data-theme="dark"] .archive-dialog progress::-webkit-progress-value {
  background: #b394ed;
}
:root[data-theme="dark"] .archive-dialog progress:not([value]) {
  background: linear-gradient(90deg, #382b51 25%, #b394ed 50%, #382b51 75%);
  background-size: 200% 100%;
}
:root[data-theme="dark"] .period-rule {
  color: var(--muted);
}
:root[data-theme="dark"] .team-counts > button {
  background: var(--surface-soft);
  border-color: var(--line);
}
:root[data-theme="dark"]
  .team-counts
  > button:is(:hover, [aria-pressed="true"]) {
  background: var(--violet-soft);
  border-color: var(--violet);
}
@media (max-width: 700px) {
  .topbar {
    height: auto;
    min-height: 78px;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 15px;
  }
  .topbar-tools {
    gap: 12px;
    margin-left: auto;
  }
  .theme-picker {
    font-size: 8px;
  }
  .theme-picker select {
    font-size: 10px;
    max-width: 125px;
    padding: 7px;
  }
  .account-meta {
    max-width: 85px;
  }
}
@media (max-width: 500px) {
  .topbar-tools:has(.account:not(.hidden)) {
    width: 100%;
    justify-content: space-between;
  }
  .topbar-tools:has(.account:not(.hidden)) .account-meta {
    max-width: 130px;
  }
}
