:root {
  --cfdt-orange: #E7591C;
  --cfdt-orange-light: #FBE5D8;
  --cfdt-orange-dark: #C44A0F;
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;
  --red-50: #fef2f2;
  --red-200: #fecaca;
  --red-700: #b91c1c;
  --red-900: #7f1d1d;
  --green-50: #f0fdf4;
  --green-200: #bbf7d0;
  --green-600: #16a34a;
  --green-900: #14532d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--stone-100);
  color: var(--stone-900);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  background: var(--cfdt-orange);
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.header-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  opacity: 0.9;
}
.header h1 {
  font-size: 28px;
  margin: 4px 0 4px;
}
.header-sub {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
  max-width: 480px;
}
.header-icon {
  font-size: 40px;
  opacity: 0.6;
}

.main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

.dropzone {
  cursor: pointer;
  border: 2px dashed var(--stone-300);
  border-radius: 18px;
  padding: 56px 24px;
  text-align: center;
  background: white;
  transition: all 0.15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--cfdt-orange);
  background: rgba(231, 89, 28, 0.04);
}
.dropzone.dragover {
  background: var(--cfdt-orange-light);
}
.dropzone-icon {
  font-size: 44px;
  margin-bottom: 12px;
  color: var(--cfdt-orange);
}
.dropzone-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}
.dropzone-sub {
  font-size: 13px;
  color: var(--stone-600);
}

.file-info {
  margin-top: 20px;
  background: white;
  border: 1px solid var(--stone-200);
  border-radius: 12px;
  padding: 16px 20px;
}
.file-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.file-info-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.file-info-icon {
  color: var(--cfdt-orange);
  font-size: 22px;
  flex-shrink: 0;
}
.file-info-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-info-size {
  font-size: 12px;
  color: var(--stone-500);
}
.actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--cfdt-orange);
  color: white;
}
.btn-primary:hover {
  background: var(--cfdt-orange-dark);
}
.btn-ghost {
  background: transparent;
  color: var(--stone-500);
}
.btn-ghost:hover {
  color: var(--stone-700);
}
.btn-dark {
  background: var(--stone-800);
  color: white;
}
.btn-dark:hover {
  background: var(--stone-700);
}

.password-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--stone-200);
}
.password-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--stone-700);
}
.password-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--stone-300);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.password-input:focus {
  outline: none;
  border-color: var(--cfdt-orange);
}

.alert {
  margin-top: 20px;
  padding: 14px 18px;
  border-radius: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
}
.alert-error {
  background: var(--red-50);
  border: 1px solid var(--red-200);
  color: var(--red-900);
}

.state-card {
  background: white;
  border: 1px solid var(--stone-200);
  border-radius: 18px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.state-card-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.spinner {
  display: inline-block;
  width: 44px;
  height: 44px;
  border: 4px solid var(--stone-200);
  border-top-color: var(--cfdt-orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.state-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
}
.state-msg {
  color: var(--stone-600);
  font-size: 14px;
  margin: 0;
}
.state-hint {
  color: var(--stone-400);
  font-size: 12px;
  margin-top: 20px;
}

.state-success {
  background: var(--green-50);
  border-color: var(--green-200);
}
.state-success .state-title {
  color: var(--green-900);
}
.state-success .state-msg {
  color: #166534;
}

.state-error {
  background: var(--red-50);
  border-color: var(--red-200);
}
.state-error .state-title {
  color: var(--red-900);
}
.state-error .state-msg {
  color: var(--red-700);
}

.hidden { display: none !important; }

.privacy-note {
  text-align: center;
  font-size: 12px;
  color: var(--stone-500);
  margin-top: 32px;
}

.footer {
  border-top: 1px solid var(--stone-200);
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--stone-500);
  background: white;
}

@media (max-width: 600px) {
  .header h1 { font-size: 22px; }
  .header-icon { display: none; }
  .dropzone { padding: 36px 16px; }
  .state-card { padding: 32px 20px; }
}

/* Mini référentiel IA */
.ref-panel {
  margin-top: 24px;
  background: white;
  border: 1px solid var(--stone-200);
  border-radius: 16px;
  padding: 16px;
}
.ref-toggle {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  font-weight: 700;
  color: var(--stone-800);
  cursor: pointer;
  padding: 4px 0;
}
.ref-content {
  margin-top: 14px;
  border-top: 1px solid var(--stone-200);
  padding-top: 14px;
}
.ref-intro {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--stone-600);
  line-height: 1.45;
}
.ref-form {
  display: grid;
  gap: 12px;
}
.ref-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--stone-700);
}
.ref-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--stone-300);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
  background: white;
}
.ref-input:focus {
  outline: none;
  border-color: var(--cfdt-orange);
}
.ref-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ref-status {
  font-size: 12px;
  color: var(--stone-500);
}
.ref-status-ok { color: var(--green-600); }
.ref-status-error { color: var(--red-700); }
.ref-list-head {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--stone-200);
  font-size: 12px;
  font-weight: 800;
  color: var(--stone-700);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ref-list {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.ref-empty {
  color: var(--stone-500);
  font-size: 13px;
  background: var(--stone-50);
  border: 1px solid var(--stone-200);
  border-radius: 10px;
  padding: 12px;
}
.ref-item {
  border: 1px solid var(--stone-200);
  border-radius: 12px;
  padding: 12px;
  background: var(--stone-50);
}
.ref-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.ref-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--cfdt-orange-light);
  color: var(--cfdt-orange-dark);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
}
.ref-delete {
  border: none;
  background: transparent;
  color: var(--red-700);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.ref-line {
  font-size: 13px;
  color: var(--stone-700);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.ref-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--stone-500);
  font-style: italic;
}
