:root {
    --bg: #f3f2ee;
    --surface: #ffffff;
    --ink: #252a2e;
    --muted: #667078;
    --line: #d9d7d0;
    --nav: #30343b;
    --nav-soft: #454b53;
    --primary: #b4533c;
    --primary-dark: #8d402f;
    --accent: #d9a441;
    --success: #16805f;
    --warning: #b26a13;
    --danger: #ba3c45;
    --info: #2769a5;
    --radius: 4px;
    --shadow: 0 1px 3px rgba(27, 31, 34, .05);
    --space-factor: 1;
    --base-font-size: 15px;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font: var(--base-font-size)/1.5 "Segoe UI", Tahoma, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; color: #dbe5ef; background: var(--nav); display: flex; flex-direction: column; }
.brand { min-width: 0; display: flex; gap: 11px; align-items: center; padding: 4px 8px 24px; }
.brand > span:last-child { min-width: 0; }
.brand strong, .brand small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: #91a0b4; font-size: 12px; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; display: inline-grid; place-items: center; border-radius: 11px; color: white; background: var(--primary); font-size: 18px; font-weight: 800; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 9px; color: #b9c5d4; font-weight: 650; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: var(--nav-soft); }
.sidebar nav a span { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid #3a4960; border-radius: 7px; font-size: 9px; letter-spacing: .05em; }
.sidebar-user { margin-top: auto; padding: 13px 8px 0; border-top: 1px solid #2b394c; display: flex; align-items: center; gap: 8px; }
.sidebar-user > div { min-width: 0; flex: 1; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user small { color: #91a0b4; font-size: 11px; }
.sidebar-user button { color: #aebacd; background: transparent; border: 0; font-size: 19px; }
.main-content { min-width: 0; padding: 30px clamp(18px, 3.2vw, 46px) 50px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 25px; margin: 0 0 24px; }
.page-head.compact { align-items: center; }
.page-head h1 { margin: 1px 0 3px; font-size: clamp(27px, 3vw, 38px); line-height: 1.12; letter-spacing: -.035em; }
.page-head p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--primary) !important; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.head-actions, .title-line { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.button { min-height: 39px; padding: 8px 14px; border: 1px solid #cfd6df; border-radius: 9px; background: white; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; }
.button:hover { border-color: #9eabb9; }
.button.primary { color: white; background: var(--primary); border-color: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: transparent; }
.button.small { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.button.wide { width: 100%; }
.panel, .action-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.panel-head h2, .action-card h2, .compact-panel h2 { margin: 0; font-size: 17px; }
.panel-head p, .action-card p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.panel-head > a { color: var(--primary); font-size: 13px; font-weight: 750; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 20px; }
.metrics.small { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 800px; }
.metric { position: relative; overflow: hidden; min-height: 104px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #8190a4; }
.metric.success::before { background: var(--success); }
.metric.warning::before { background: var(--warning); }
.metric.danger::before { background: var(--danger); }
.metric span, .metric strong { display: block; }
.metric span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric strong { margin-top: 10px; font-size: 23px; letter-spacing: -.025em; }
.split-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.client-layout { grid-template-columns: minmax(0, 1.55fr) minmax(310px, .75fr); }
.responsive-table { width: 100%; overflow-x: auto; }
.table-panel { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { color: #7b8797; background: #f9fafb; font-size: 10px; letter-spacing: .07em; text-align: left; text-transform: uppercase; }
th, td { padding: 12px 14px; border-bottom: 1px solid #e8ebef; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfd; }
td small, td strong { display: block; }
td small { color: var(--muted); font-size: 11px; }
.row-action { color: var(--primary); white-space: nowrap; font-size: 12px; font-weight: 800; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 99px; font-size: 11px; font-weight: 750; background: #eef1f4; color: #657184; white-space: nowrap; }
.status.success { color: #116549; background: #e2f5ed; }
.status.warning { color: #8a530f; background: #fff0d9; }
.status.danger { color: #95313a; background: #fde7e9; }
.status.info { color: #245b8a; background: #e5f0fb; }
.follow-list { display: grid; gap: 6px; }
.follow-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px; border-radius: 9px; background: #f6f8fa; }
.follow-list strong { font-size: 12px; color: var(--warning); }
.quiet-empty, .empty-state { padding: 32px 15px; color: var(--muted); text-align: center; }
.empty-state { max-width: 700px; margin: 50px auto; }
.empty-state h1, .empty-state h2 { color: var(--ink); }
.filter-bar { display: flex; align-items: end; gap: 10px; padding: 12px; margin-bottom: 15px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.filter-bar label { margin: 0; }
.filter-bar .search-field { flex: 1; }
.tabs { display: flex; gap: 5px; margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 700; }
.tabs a.active { color: white; background: var(--nav); }
.form-stack { display: grid; gap: 17px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 6px; color: #374457; font-size: 12px; font-weight: 750; }
label > span, label small { color: #758195; font-size: 11px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid #cfd6df; border-radius: 8px; color: var(--ink); background: white; outline: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,107,91,.11); }
fieldset { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 11px; display: grid; gap: 15px; }
legend { padding: 0 7px; font-size: 14px; font-weight: 800; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 3px; }
.line-editor { padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: #f9fafb; }
.line-head { display: flex; justify-content: space-between; margin-bottom: 9px; }
.line-head span { color: var(--muted); font-size: 12px; }
.line-row { display: grid; grid-template-columns: minmax(250px, 1fr) 100px 125px 90px 33px; gap: 9px; align-items: end; padding: 11px 0; border-top: 1px solid #e1e5ea; }
.remove-line { width: 33px; height: 40px; border: 0; border-radius: 8px; color: var(--danger); background: #fdebed; font-size: 20px; }
.document-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.totals-box { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.totals-box > div { display: flex; justify-content: space-between; gap: 15px; padding: 7px; }
.totals-box .grand-total { margin-top: 5px; padding: 12px 8px; border-top: 2px solid var(--ink); font-size: 17px; }
.document-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.document-preview { padding: 28px; }
.document-meta { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 25px; }
.document-meta > div { display: grid; gap: 3px; }
.document-meta small { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.document-meta span { color: var(--muted); }
.lines-table { margin: 10px 0 22px; }
.document-summary { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 25px; }
.document-notes { color: var(--muted); font-size: 13px; }
.totals-box.fixed { border: 0; }
.side-stack { display: grid; gap: 14px; }
.compact-panel { padding: 17px; }
.compact-panel h2 { margin-bottom: 14px; }
.inline-reminder { margin-top: 10px; }
.payment-list { display: grid; gap: 7px; margin-top: 14px; }
.payment-list div { display: flex; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; }
.type-pill { padding: 5px 9px; border-radius: 6px; color: white; background: var(--nav); font-size: 11px; font-weight: 800; }
.timeline-panel { max-height: 670px; overflow: hidden; }
.quick-note { display: grid; grid-template-columns: 1fr auto; gap: 7px; align-items: end; margin-bottom: 16px; }
.timeline { position: relative; display: grid; gap: 0; max-height: 430px; overflow-y: auto; }
.timeline-item { display: grid; grid-template-columns: 15px 1fr; gap: 10px; padding-bottom: 16px; }
.timeline-item > span { position: relative; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--primary); }
.timeline-item > span::after { content: ""; position: absolute; top: 10px; left: 3px; width: 1px; height: 45px; background: var(--line); }
.timeline-item strong, .timeline-item small { display: block; }
.timeline-item strong { font-size: 12px; }
.timeline-item small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.card-grid { display: grid; gap: 14px; margin-bottom: 18px; }
.card-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.action-card { padding: 19px; }
.action-card p { min-height: 42px; margin-bottom: 17px; }
.card-icon { width: 35px; height: 35px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 9px; color: var(--primary); background: #e7f3f0; font-size: 10px; font-weight: 850; }
.import-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.import-panel h2 { margin: 0 0 4px; }
.import-panel p { margin: 3px 0; }
.upload-form { display: flex; gap: 8px; align-items: center; min-width: 390px; }
code { padding: 2px 5px; border-radius: 4px; background: #eef1f4; font-size: 12px; }
.notice { margin: 0 0 15px; padding: 11px 14px; border: 1px solid #ced6df; border-radius: 9px; background: white; }
.notice.success { color: #116549; border-color: #b7e3d3; background: #eaf8f2; }
.notice.danger { color: #95313a; border-color: #efc4c8; background: #fff0f1; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); font-weight: 750; }
.login-page { min-height: 100vh; background: var(--nav); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: clamp(30px, 7vw, 110px); max-width: 1120px; margin: auto; padding: 40px; }
.login-copy { color: white; }
.login-copy .brand-mark { margin-bottom: 25px; }
.login-copy h1 { margin: 8px 0 15px; font-size: clamp(38px, 5vw, 63px); line-height: 1.02; letter-spacing: -.055em; }
.login-copy > p:last-child { max-width: 510px; color: #aebbc9; font-size: 17px; }
.login-card, .install-card { padding: clamp(25px, 4vw, 42px); border-radius: 18px; background: white; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.login-card h2, .install-card h1 { margin: 0; }
.install-card { width: min(760px, calc(100% - 30px)); margin: 35px auto; }
.install-card .brand-mark { margin-bottom: 18px; }
@media (max-width: 1050px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .document-layout { grid-template-columns: 1fr; }
    .side-stack { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .card-grid.three { grid-template-columns: 1fr; }
    .action-card p { min-height: 0; }
    .import-panel { align-items: stretch; flex-direction: column; }
    .upload-form { min-width: 0; }
}
@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 11px; }
    .brand { padding: 3px 4px 11px; }
    .sidebar nav { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
    .sidebar nav a { justify-content: center; padding: 8px 3px; font-size: 0; }
    .sidebar nav a span { font-size: 9px; }
    .sidebar-user { display: none; }
    .main-content { padding: 22px 13px 35px; }
    .page-head { align-items: flex-start; flex-direction: column; gap: 13px; }
    .head-actions { width: 100%; }
    .metrics, .metrics.small { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric { min-height: 90px; padding: 14px; }
    .metric strong { font-size: 19px; }
    .split-layout, .client-layout { grid-template-columns: 1fr; }
    .form-grid.two, .form-grid.three, .form-grid.four, .document-bottom, .document-summary { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .line-row { grid-template-columns: 1fr 1fr; padding: 14px 0; }
    .line-description { grid-column: 1 / -1; }
    .remove-line { align-self: end; }
    .document-preview { padding: 16px 12px; }
    .document-meta { flex-direction: column; }
    .side-stack { grid-template-columns: 1fr; }
    .filter-bar { align-items: stretch; flex-direction: column; }
    .quick-note { grid-template-columns: 1fr; }
    .upload-form { align-items: stretch; flex-direction: column; }
    .login-shell { display: block; padding: 20px; }
    .login-copy { margin: 25px 0 35px; }
    .login-copy h1 { font-size: 41px; }
}
@media (max-width: 430px) {
    .metrics, .metrics.small { grid-template-columns: 1fr; }
    .page-head .button { width: 100%; }
}

/* V0.2 — interface de gestion avec navigation horizontale */
.topbar { position: sticky; z-index: 40; top: 0; color: #fff; background: var(--nav); border-bottom: 4px solid var(--accent); }
.topbar-inner { min-height: 72px; max-width: 1500px; margin: auto; padding: 0 28px; display: flex; align-items: stretch; gap: 28px; }
.topbar .brand { flex: 0 1 260px; padding: 0; color: #fff; }
.topbar .brand-mark { background: var(--accent); border-radius: 5px 13px 5px 13px; }
.topbar .brand small { color: #c8bdd7; }
.main-nav { display: flex; align-items: stretch; gap: 2px; }
.main-nav a { position: relative; display: flex; align-items: center; padding: 0 15px; color: #cec4db; font-size: 13px; font-weight: 700; }
.main-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.main-nav a.active { color: #fff; }
.main-nav a.active::after { content: ""; position: absolute; right: 15px; bottom: 11px; left: 15px; height: 3px; border-radius: 3px; background: var(--accent); }
.user-zone { min-width: 0; margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-zone > span { min-width: 0; text-align: right; }
.user-zone strong, .user-zone small { display: block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-zone small { color: #bfb3cd; font-size: 10px; }
.logout-button { padding: 7px 9px; color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 5px; background: transparent; font-size: 11px; }
.main-content { width: min(1500px, 100%); min-height: calc(100vh - 76px); margin: auto; padding: calc(30px * var(--space-factor)) clamp(18px, 3vw, 44px) 52px; }
.panel, .action-card { border-radius: var(--radius); box-shadow: none; }
.panel { border-top: 3px solid #d8cee5; }
.page-head h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: -.025em; }
.metric { border-radius: var(--radius); box-shadow: 0 3px 12px rgba(49,31,67,.04); }
.metric::before { inset: 0 0 auto 0; width: auto; height: 4px; background: #8d829a; }
.metric.success::before { background: #2f9672; }
.metric.warning::before { background: #e39a3b; }
.metric.danger::before { background: #d65160; }
.button { border-radius: 6px; }
.button.primary { background: var(--primary); border-color: var(--primary); }
input, select, textarea { border-radius: 6px; }
fieldset { border-radius: var(--radius); }
.eyebrow { color: var(--primary) !important; }
.status, .tabs a { border-radius: 5px; }

.document-type-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.document-type-card { min-height: 205px; padding: 22px; border: 1px solid var(--line); border-top: 5px solid var(--primary); border-radius: var(--radius); background: #fff; display: flex; flex-direction: column; align-items: flex-start; transition: transform .18s, box-shadow .18s; }
.document-type-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(49,31,67,.1); }
.document-type-card > span { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 28px; border-radius: 6px; color: #fff; background: var(--primary); font-size: 12px; font-weight: 850; }
.document-type-card strong, .document-type-card small { display: block; }
.document-type-card strong { margin-bottom: 6px; font: 700 22px Georgia, serif; }
.document-type-card small { min-height: 44px; color: var(--muted); }
.document-type-card b { margin-top: auto; color: var(--primary); font-size: 12px; }
.document-type-card.type-proforma { border-top-color: #2f86a6; }
.document-type-card.type-proforma > span { background: #2f86a6; }
.document-type-card.type-invoice { border-top-color: #d46a2f; }
.document-type-card.type-invoice > span { background: #d46a2f; }
.document-type-card.type-credit { border-top-color: #a14663; }
.document-type-card.type-credit > span { background: #a14663; }

.document-create-nav { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid #d8d0e1; }
.document-create-nav a { padding: 9px 16px; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 700; }
.document-create-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.document-workbench { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(330px, .7fr); gap: 20px; align-items: start; }
.document-form { padding: 0; overflow: hidden; border-top-color: var(--primary); }
.form-section { padding: calc(21px * var(--space-factor)); border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; gap: 11px; margin-bottom: 17px; }
.section-title > span { width: 27px; height: 27px; display: grid; place-items: center; color: #fff; border-radius: 50%; background: var(--primary); font-size: 11px; font-weight: 800; }
.section-title strong, .section-title small { display: block; }
.section-title small { color: var(--muted); font-size: 11px; }
.client-picker { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.client-alert { display: none; gap: 4px; margin-top: 12px; padding: 11px 13px; color: #7e263f; border-left: 4px solid var(--accent); background: #fff0f5; }
.client-alert.visible { display: grid; }
.client-alert strong { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.client-alert span { white-space: pre-line; }
.template-picker { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin-bottom: 10px; }
.document-form .line-editor { border-radius: 7px; background: #faf9fc; }
.sticky-actions { position: sticky; bottom: 0; padding: 15px 20px; background: #fff; border-top: 1px solid var(--line); justify-content: space-between; align-items: center; }
.sticky-actions > span { color: var(--muted); font-size: 11px; }
.draft-status { display: inline-flex; padding: 6px 9px; color: #6b5e78; border: 1px solid #dcd4e5; border-radius: 5px; background: #fff; font-size: 11px; font-weight: 700; }
.draft-status[data-state="server"] { color: #176b50; border-color: #b8dfd0; background: #edf9f4; }
.draft-status[data-state="local"] { color: #8a5d16; border-color: #ead3a9; background: #fff9ed; }
.draft-status[data-state="error"] { color: #9a3441; }

.live-document-preview { position: sticky; top: 96px; border: 1px solid #d8d0e1; background: #ece8f1; }
.preview-toolbar { min-height: 43px; padding: 10px 13px; color: #fff; background: var(--nav); display: flex; justify-content: space-between; align-items: center; }
.preview-toolbar span { color: #c8bdd7; font-size: 10px; }
.preview-sheet { aspect-ratio: 1 / 1.414; margin: 17px; padding: 28px 24px; overflow: hidden; color: #25212a; background: #fff; box-shadow: 0 7px 20px rgba(40,28,50,.15); font-family: Arial, sans-serif; font-size: 9px; }
.preview-brand { padding-bottom: 17px; border-bottom: 4px solid var(--primary); display: flex; justify-content: space-between; gap: 12px; font-size: 11px; }
.preview-brand b { color: var(--primary); }
.preview-parties { display: grid; grid-template-columns: 1fr auto; gap: 18px; margin: 22px 0; }
.preview-parties small, .preview-parties strong, .preview-parties span { display: block; }
.preview-parties small { color: #8a8290; font-size: 7px; }
.preview-reference { margin-bottom: 14px; padding: 7px; background: #f4f1f7; display: flex; gap: 8px; }
.preview-sheet table { font-size: 8px; }
.preview-sheet th, .preview-sheet td { padding: 6px 4px; }
.preview-sheet th:last-child, .preview-sheet td:last-child { text-align: right; }
.preview-total { margin: 15px 0 0 auto; width: 58%; padding: 9px; color: #fff; background: var(--nav); display: flex; justify-content: space-between; }
.preview-sheet > p { margin-top: 18px; color: #6f6875; white-space: pre-line; }

.modal { position: fixed; z-index: 100; inset: 0; display: none; place-items: center; padding: 18px; }
.modal.open { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(26,14,38,.66); }
.modal-card { position: relative; width: min(540px,100%); padding: 23px; border-top: 5px solid var(--accent); background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { margin: 2px 0 0; font: 700 24px Georgia,serif; }
.modal-head > button { width: 34px; height: 34px; border: 0; background: #f0edf3; font-size: 20px; }
.modal-error { min-height: 20px; color: var(--danger); font-size: 12px; }

.settings-index { position: sticky; z-index: 5; top: 76px; margin-bottom: 15px; padding: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.96); display: flex; gap: 5px; overflow-x: auto; }
.settings-index a { padding: 7px 10px; color: var(--primary); white-space: nowrap; font-size: 12px; font-weight: 700; }
.settings-block { margin-top: 20px; }
.fieldset-help { margin: -5px 0 3px; color: var(--muted); font-size: 12px; }
.design-settings { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.design-settings input[type="color"] { height: 48px; padding: 4px; }
.document-settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.document-setting-card { align-content: start; background: #fcfbfd; }
.check-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.check-field { grid-template-columns: 18px 1fr; align-items: center; gap: 8px; }
.check-field input { width: 17px; min-height: 17px; margin: 0; }
.template-create-form { display: grid; grid-template-columns: 160px minmax(230px,1fr) 150px 80px 100px 90px auto; gap: 8px; align-items: end; }
.template-list { margin-top: 16px; border-top: 1px solid var(--line); }
.template-list > div { padding: 11px 3px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.template-list strong, .template-list small { display: block; }
.template-list small { color: var(--muted); }
.transform-form { display: flex; gap: 6px; }
.transform-form select { width: auto; min-width: 175px; }

.session-warning { position: fixed; z-index: 90; right: 20px; bottom: 20px; width: min(460px,calc(100% - 40px)); padding: 14px; color: #fff; border-left: 5px solid var(--accent); background: var(--nav); box-shadow: 0 14px 36px rgba(0,0,0,.25); display: none; align-items: center; gap: 14px; }
.session-warning.visible { display: flex; }
.session-warning > div { flex: 1; }
.session-warning strong, .session-warning span { display: block; }
.session-warning span { color: #d3cadc; font-size: 11px; }
.session-warning button { padding: 7px 10px; color: #fff; border: 1px solid rgba(255,255,255,.35); background: transparent; }

@media (max-width: 1120px) {
    .topbar-inner { gap: 12px; padding: 0 14px; }
    .topbar .brand { flex-basis: 190px; }
    .main-nav a { padding: 0 9px; }
    .user-zone > span { display: none; }
    .document-type-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .document-workbench { grid-template-columns: 1fr; }
    .live-document-preview { position: static; }
    .preview-sheet { max-width: 560px; margin: 17px auto; }
    .template-create-form { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 760px) {
    .topbar { position: static; }
    .topbar-inner { min-height: auto; padding: 10px; flex-wrap: wrap; }
    .topbar .brand { flex: 1; }
    .topbar .brand strong { max-width: 180px; }
    .user-zone { margin-left: 0; }
    .main-nav { order: 3; width: 100%; overflow-x: auto; border-top: 1px solid rgba(255,255,255,.13); }
    .main-nav a { min-height: 42px; white-space: nowrap; }
    .main-nav a.active::after { bottom: 3px; }
    .main-content { padding: 20px 12px 35px; }
    .settings-index { top: 0; }
    .document-type-grid, .document-settings-grid, .design-settings { grid-template-columns: 1fr; }
    .document-type-card { min-height: 170px; }
    .client-picker, .template-picker { grid-template-columns: 1fr; }
    .preview-sheet { margin: 10px; padding: 20px 15px; }
    .template-create-form { grid-template-columns: 1fr 1fr; }
    .template-description { grid-column: 1 / -1; }
    .transform-form { width: 100%; }
    .transform-form select { min-width: 0; }
    .session-warning { right: 10px; bottom: 10px; width: calc(100% - 20px); align-items: stretch; flex-direction: column; }
}
@media (max-width: 460px) {
    .document-type-grid, .template-create-form { grid-template-columns: 1fr; }
    .document-create-nav { overflow-x: auto; }
    .document-create-nav a { white-space: nowrap; }
}

/* V0.3 — direction professionnelle sobre */
.topbar { border-bottom-width: 2px; }
.topbar-inner { min-height: 64px; }
.topbar .brand-mark { width: 32px; height: 32px; flex-basis: 32px; border-radius: 2px; color: var(--nav); background: var(--accent); font-size: 15px; }
.topbar .brand small, .user-zone small, .preview-toolbar span { color: #b9bec3; }
.main-nav a { font-weight: 600; color: #c8ccd0; }
.main-nav a.active::after { right: 15px; bottom: 8px; left: 15px; height: 2px; border-radius: 0; }
.main-content { min-height: calc(100vh - 66px); }
.page-head { border-bottom: 1px solid var(--line); padding-bottom: 17px; }
.page-head h1, .document-type-card strong, .modal-head h2 { font-family: "Segoe UI", Tahoma, Arial, sans-serif; letter-spacing: -.025em; }
.page-head h1 { font-weight: 650; }
.eyebrow { letter-spacing: .14em; }
.panel, .action-card, .metric, fieldset, .filter-bar, .line-editor, input, select, textarea, .button { border-radius: var(--radius); }
.panel { border-top: 1px solid var(--line); }
.button { min-height: 38px; font-weight: 650; }
.button.primary { box-shadow: inset 0 -1px rgba(0,0,0,.15); }
.danger-button { color: var(--danger); border-color: #e3c2c0; background: #fff; }
.document-type-card { min-height: 180px; border-top-width: 3px; border-radius: var(--radius); }
.document-type-card:hover { transform: none; border-color: #aaa69e; box-shadow: 0 5px 14px rgba(30,34,37,.07); }
.document-type-card > span { border-radius: 2px; }
.document-type-card strong { font-size: 20px; font-weight: 650; }
.section-title > span { border-radius: 2px; background: var(--nav); }
.document-form .line-editor { background: #f7f7f4; }
.line-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.line-tools span { color: var(--muted); font-size: 12px; }
.live-document-preview { border-color: #c9c7c0; background: #e7e5df; }
.preview-toolbar { background: var(--nav); }
.preview-sheet { position: relative; margin: 14px; padding: 25px 22px 72px; box-shadow: 0 2px 8px rgba(25,28,31,.13); }
.preview-document-head { min-height: 70px; padding-bottom: 12px; border-bottom: 3px solid var(--primary); display: flex; justify-content: space-between; gap: 14px; }
.preview-issuer { min-width: 0; display: flex; align-items: flex-start; gap: 8px; }
.preview-issuer img { width: 46px; height: 34px; object-fit: contain; }
.preview-issuer span, .preview-issuer strong, .preview-issuer small, .preview-document-id strong, .preview-document-id b { display: block; }
.preview-issuer small { max-width: 175px; color: #6f7478; font-size: 6.5px; }
.preview-document-id { min-width: 98px; text-align: right; }
.preview-document-id b { color: var(--primary); font-size: 11px; }
.preview-document-id strong { margin-top: 4px; font-size: 8px; }
.barcode-sample { width: 92px; height: 13px; display: block; margin: 6px 0 0 auto; background: repeating-linear-gradient(90deg,#202326 0 1px,transparent 1px 3px,#202326 3px 5px,transparent 5px 6px,#202326 6px 7px,transparent 7px 10px); }
.preview-reference { background: #f1f0ec; }
.preview-total { background: var(--nav); }
.preview-footer { position: absolute; right: 22px; bottom: 18px; left: 22px; padding-top: 7px; border-top: 1px solid #b8b6af; display: grid; gap: 2px; color: #686c6f; font-size: 6px; line-height: 1.25; }
.preview-footer strong { color: #3e4245; }
.modal-backdrop { background: rgba(30,33,36,.7); }
.modal-card { border-top: 3px solid var(--accent); border-radius: 2px; }
.modal-head h2 { font-weight: 650; }
.template-module { width: min(980px,100%); max-height: min(760px,calc(100vh - 36px)); overflow-y: auto; }
.template-module-grid { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(300px,.8fr); gap: 24px; }
.template-module-head { min-height: 39px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.template-module-list { display: grid; max-height: 470px; overflow-y: auto; }
.template-module-list article { padding: 12px 2px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.template-module-list article > span strong, .template-module-list article > span small { display: block; }
.template-module-list article > span small { margin-top: 2px; color: var(--muted); }
.template-module-list article > div { display: flex; gap: 5px; flex-wrap: wrap; }
.template-module-form { align-content: start; padding: 16px; border: 1px solid var(--line); background: #f7f7f4; }
.template-form-title { padding-bottom: 8px; border-bottom: 1px solid var(--line); font-weight: 700; }
.identity-settings { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 22px; }
.logo-setting { padding: 15px; border: 1px solid var(--line); background: #f7f7f4; display: grid; align-content: start; gap: 12px; }
.logo-setting > img, .logo-setting > span { width: 100%; height: 100px; object-fit: contain; border: 1px dashed #bbb8b0; background: white; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.document-setting-card { background: #f9f9f7; }
.settings-index { top: 66px; }

.demo-access { margin: 16px 0; padding: 13px; border-left: 4px solid var(--accent); background: #f5f2e9; display: grid; gap: 4px; }
.demo-access strong { color: var(--nav); }
.demo-access span { font-size: 13px; }
.demo-access code { padding: 2px 5px; color: #fff; background: var(--nav); }
.demo-access small { margin-top: 4px; color: var(--muted); line-height: 1.4; }
.demo-banner { padding: 9px 20px; color: #2f291b; background: #f3d98a; display: flex; justify-content: center; gap: 10px; font-size: 13px; }
.demo-banner strong { text-transform: uppercase; letter-spacing: .08em; }

@media (max-width: 760px) {
    .line-tools { align-items: stretch; flex-direction: column; }
    .template-module-grid, .identity-settings { grid-template-columns: 1fr; }
    .template-module-list { max-height: none; }
    .preview-sheet { padding-bottom: 80px; }
}
