/* MIA Factu — styles applicatifs (sur la charte EasyIDEL, module=factu / violet) */

.app-header { position: sticky; top: 0; z-index: 50; background: var(--header-bg); color: var(--header-text); box-shadow: var(--shadow-md); }
.app-header-inner { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: baseline; gap: 8px; cursor: pointer; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); align-self: center; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; opacity: .7; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.badge-status { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: var(--r-pill); background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); }
.badge-status.ok { background: color-mix(in srgb, var(--success) 30%, transparent); }
.badge-status.demo { background: color-mix(in srgb, var(--amber-500) 35%, transparent); }
.btn-theme { color: var(--header-text); border-color: rgba(255,255,255,.3); }

.disclaimer-strip { max-width: 1040px; margin: 12px auto 0; padding: 9px 14px; background: var(--accent-soft); color: var(--accent-hover); border-radius: var(--r-sm); font-size: 11.5px; line-height: 1.5; }
[data-theme="dark"] .disclaimer-strip { color: var(--text); }

.crumbs { max-width: 1040px; margin: 10px auto 0; padding: 0 16px; font-size: 12.5px; color: var(--text-muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crumbs a { color: var(--accent); text-decoration: none; font-weight: 500; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { opacity: .5; }

.app-main { max-width: 1040px; margin: 14px auto 60px; padding: 0 16px; }
.loading { text-align: center; color: var(--text-muted); padding: 40px; }

/* ── Cards / sections ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.card h2 { font-size: 14px; color: var(--accent); display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card h2 .n { width: 22px; height: 22px; background: var(--accent); color: var(--accent-text); border-radius: 50%; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--text-muted); font-size: 12.5px; }
.section-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }

/* ── Buttons ── */
button { font-family: var(--font-ui); cursor: pointer; }
.btn { background: var(--accent); color: var(--accent-text); border: none; padding: 10px 16px; border-radius: var(--r-sm); font-weight: 600; font-size: 13.5px; }
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); padding: 8px 14px; border-radius: var(--r-sm); font-weight: 600; font-size: 13px; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); border-radius: var(--r-xs); padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Forms ── */
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm); font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--text); }
.field textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 620px){ .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.toggles { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0; }
.toggles label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }

/* ── Lists ── */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; transition: border-color .15s, transform .05s; }
.list-item:hover { border-color: var(--accent); }
.list-item:active { transform: scale(.998); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-hover); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; font-size: 14px; }
.li-sub { font-size: 12px; color: var(--text-muted); }
.li-meta { font-size: 11.5px; color: var(--text-muted); text-align: right; white-space: nowrap; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 9px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-hover); }
.pill.green { background: var(--green-100); color: var(--green-700); }
.pill.amber { background: var(--amber-100); color: var(--amber-700); }
.pill.red { background: var(--red-100); color: var(--red-700); }
.pill.gray { background: var(--gray-100); color: var(--gray-600); }
.empty { text-align: center; color: var(--text-muted); padding: 30px 12px; }
.empty .ico { font-size: 34px; opacity: .5; }

/* ── Capture ── */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: var(--r-sm); border: 1.5px solid var(--accent); color: var(--accent); background: transparent; font-size: 12.5px; font-weight: 600; }
.tab.active, .tab:hover { background: var(--accent); color: var(--accent-text); }
.dropzone { border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--r-md); padding: 26px 18px; text-align: center; cursor: pointer; background: var(--accent-soft); }
.dropzone:hover, .dropzone.drag { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.dropzone .ico { font-size: 32px; }
.dropzone small { color: var(--text-muted); }
#cam-video-host { width: 100%; max-height: 340px; border-radius: var(--r-md); background: #000; object-fit: contain; display:none; }
.preview { margin-top: 12px; }
.preview img { width: 100%; max-height: 420px; object-fit: contain; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); }
.preview-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.link-x { color: var(--danger); cursor: pointer; font-weight: 600; }

/* ── Résultat / cotation ── */
.resume-head { background: linear-gradient(135deg, var(--accent-hover), var(--accent)); color: #fff; border-radius: var(--r-md); padding: 16px 18px; }
.resume-type { font-size: 20px; font-weight: 700; }
.resume-sub { opacity: .92; font-size: 13px; margin-top: 2px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.chip { background: rgba(255,255,255,.2); border-radius: var(--r-pill); padding: 3px 11px; font-size: 11px; font-weight: 600; }

.msg { display: flex; gap: 8px; align-items: flex-start; padding: 9px 12px; border-radius: var(--r-sm); margin-bottom: 7px; font-size: 13px; line-height: 1.5; }
.msg.ok { background: var(--green-100); color: var(--green-700); }
.msg.warn { background: var(--amber-100); color: var(--amber-700); }
.msg.info { background: var(--blue-100); color: var(--blue-700); }
.msg.bloc { background: var(--red-100); color: var(--red-700); }

/* acte */
.acte { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 10px; }
.acte-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.acte-title { font-weight: 700; font-size: 14px; }
.ngap-code { font-family: var(--font-mono); font-weight: 700; font-size: 16px; color: var(--accent-hover); background: var(--accent-soft); padding: 3px 10px; border-radius: var(--r-sm); }
.conf { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); text-transform: uppercase; letter-spacing: .03em; }
.conf.haute { background: var(--green-100); color: var(--green-700); }
.conf.moyenne { background: var(--amber-100); color: var(--amber-700); }
.conf.basse, .conf.non_securisable { background: var(--red-100); color: var(--red-700); }
.acte .justif { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { background: var(--accent-soft); color: var(--accent-hover); border-radius: var(--r-xs); padding: 3px 9px; font-size: 11.5px; font-weight: 600; }
.tag.warn { background: var(--amber-100); color: var(--amber-700); }
.tag.bloc { background: var(--red-100); color: var(--red-700); }

/* chiffrage table */
.cot-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cot-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); padding: 6px 8px; border-bottom: 2px solid var(--border); }
.cot-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cot-table .code { font-family: var(--font-mono); font-weight: 600; }
.cot-table .mt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cot-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding: 12px 14px; background: var(--accent-soft); border-radius: var(--r-md); }
.cot-total .lbl { font-weight: 600; color: var(--accent-hover); }
.cot-total .val { font-size: 26px; font-weight: 800; font-family: var(--font-mono); color: var(--accent-hover); }

.export-block { background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 8px; }
.export-block .k { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.export-text { font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; font-family: var(--font-ui); }

/* prescripteur / annuaire */
.presc-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; }
.annu-res { display:flex; align-items:center; gap:10px; padding:8px 10px; border:1px solid var(--border); border-radius:var(--r-sm); margin-bottom:6px; cursor:pointer; }
.annu-res:hover { border-color: var(--accent); background: var(--accent-soft); }
.annu-res .n { font-weight:600; font-size:13px; }
.annu-res .s { font-size:11.5px; color:var(--text-muted); }

/* mail */
.mail-box { border: 1.5px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: var(--r-md); padding: 14px 16px; background: var(--accent-soft); }
.mail-box .export-text { background: var(--surface); border-radius: var(--r-sm); padding: 12px; border: 1px solid var(--border); }

/* statut */
.statut-bar { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Toast / spinner ── */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--navy-900); color: #fff; padding: 10px 18px; border-radius: var(--r-pill); font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.source-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: var(--r-pill); margin-bottom: 10px; }
.source-tag.llm { background: var(--green-100); color: var(--green-700); }
.source-tag.demo { background: var(--amber-100); color: var(--amber-700); }
.thumb { width: 46px; height: 46px; border-radius: var(--r-sm); object-fit: cover; border: 1px solid var(--border); background: var(--surface-2); flex-shrink: 0; }

/* ── Authentification ── */
.auth-wrap { display: flex; justify-content: center; align-items: flex-start; padding-top: 4vh; }
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; color: var(--text); }
.auth-logo .brand-dot { width: 12px; height: 12px; }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
#auth-actions { display: inline-flex; gap: 6px; align-items: center; }
.btn-danger.btn-sm { padding: 5px 10px; font-size: 12px; }
