/* =====================================================
   Mubsira Factures Québec - App design system.
   Direction C "Signature" applied. Single token source.
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* ---------- BRAND · PINE (dominant brand) ---------- */
    --pine:        #1E342A;
    --pine-deep:   #152620;
    --pine-2:      #264536;
    --pine-3:      #2F5341;
    --pine-line:   #37543F;
    --pine-tint:   #EAF0EC;
    --pine-tint-2: #DCE7DF;

    /* ---------- BRAND · CREAM (surfaces, paper) ---------- */
    --cream:   #F3EFE4;
    --cream-2: #E9E3D2;
    --cream-3: #DED8C7;
    --card:    #FBF9F2;
    --paper:   #FFFFFF;

    /* ---------- BRAND · AMBER (restrained accent) ---------- */
    --amber:        #C0863A;
    --amber-deep:   #A06E2B;
    --amber-bright: #CF9447;
    --amber-soft:   #EBDCC2;
    --amber-tint:   #F6ECD9;

    /* ---------- WARM NEUTRALS / INK ---------- */
    --ink:   #181D18;
    --ink-2: #566055;
    --ink-3: #8E9489;
    --line:   #DED8C7;
    --line-2: #CEC7B2;
    --ink-on-pine:   #F3EFE4;
    --muted-on-pine: #A9B6A9;
    --faint-on-pine: #7E8E80;

    /* ---------- APP THEME (light, calm) ---------- */
    --app-bg:       #FAF8F1;
    --app-surface:  #FFFFFF;
    --app-surface-2:#F5F2E9;
    --app-sidebar:  #FCFAF4;
    --app-ink:      #1A201B;
    --app-ink-2:    #5B6359;
    --app-ink-3:    #969C90;
    --app-line:     #E8E3D6;
    --app-line-2:   #DAD3C2;
    --app-active:   #EAF0EC;

    /* ---------- SEMANTIC STATUS ---------- */
    --st-draft:    #6B7280;  --st-draft-bg:   #F1F1EE;
    --st-sent:     #2F6F5A;  --st-sent-bg:    #E4EFE9;
    --st-paid:     #15803D;  --st-paid-bg:    #E6F2EA;
    --st-overdue:  #B91C1C;  --st-overdue-bg: #FBEAEA;
    --st-pending:  #B45309;  --st-pending-bg: #FAF0E2;

    --success:     #15803D;
    --warning:     #B45309;
    --danger:      #B91C1C;
    --danger-soft: #FBEAEA;

    /* ---------- TYPOGRAPHY ---------- */
    --font-display: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-ui:      "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
    --font-serif:   "Newsreader", Georgia, "Times New Roman", serif;

    /* ---------- SPACING (4 px base) ---------- */
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;
    --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px; --s20: 80px;

    /* ---------- RADII ---------- */
    --r-ctrl:  8px;
    --r-card:  13px;
    --r-modal: 18px;
    --r-pill:  100px;

    /* ---------- SHADOWS ---------- */
    --sh-sm: 0 1px 2px rgba(24,29,24,.06), 0 1px 3px rgba(24,29,24,.05);
    --sh-md: 0 6px 18px -8px rgba(24,29,24,.18), 0 2px 6px rgba(24,29,24,.06);
    --sh-lg: 0 24px 56px -20px rgba(24,29,24,.34), 0 8px 20px -10px rgba(24,29,24,.2);

    /* ---------- LAYOUT (app shell metrics) ---------- */
    --sidebar-w:  248px;
    --sb-w:       248px;        /* alias used by app-interface design system */
    --topbar-h:   64px;
    --tb-h:       64px;         /* alias */
    --content-max:1120px;
    --page-max:   1120px;       /* alias */
    --page-pad:   32px;

    /* ---------- INTERACTION / FOCUS ---------- */
    --ring:      0 0 0 3px rgba(192,134,58,.30);  /* amber focus ring */
    --ring-pine: 0 0 0 3px rgba(30,52,42,.16);
    --hair:      1px solid var(--app-line);

    /* ---------- APP ELEVATIONS (lighter than public site) ---------- */
    --el-row:   0 1px 0 var(--app-line);
    --el-raise: 0 1px 2px rgba(24,29,24,.05), 0 8px 22px -16px rgba(24,29,24,.22);
    --el-pop:   0 18px 48px -22px rgba(24,29,24,.40), 0 4px 14px -8px rgba(24,29,24,.16);

    /* ---------- MONEY / URGENCY ---------- */
    --money:        var(--pine);
    --money-strong: var(--pine-deep);
    --urgent:      #B91C1C;
    --urgent-bg:   #FBEAEA;
    --urgent-line: #F0CFCF;
}

/* =====================================================
   BASE
   ===================================================== */

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: var(--font-ui);
    background: var(--app-bg);
    color: var(--app-ink);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
}

a {
    color: var(--pine);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover { color: var(--pine-2); }

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

.mono   { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.serif  { font-family: var(--font-serif); }
.display{ font-family: var(--font-display); letter-spacing: -0.01em; }
.muted  { color: var(--app-ink-2); }
.small  { font-size: 12px; }

/* =====================================================
   APP SHELL — Direction C Signature, app-interface package
   ===================================================== */

.app-shell {
    display: grid;
    grid-template-columns: var(--sb-w) 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar — 3-tier hierarchy (brand → nav → footer) ---------- */

.sidebar {
    background: var(--app-sidebar);
    border-right: 1px solid var(--app-line);
    display: flex;
    flex-direction: column;
    padding: 18px 14px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

/* Brand block — strongest weight */
.sidebar-header {
    padding: 6px 8px 18px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--app-line);
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--app-ink);
    text-decoration: none;
}
.brand:hover { color: var(--app-ink); }
.brand-badge {
    width: 36px; height: 36px;
    flex: none;
    background: var(--amber);
    color: var(--pine-deep);
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 19px;
    line-height: 1;
    box-shadow: var(--sh-sm);
}
.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--app-ink);
    display: block;
    line-height: 1;
    letter-spacing: -0.01em;
}
.brand-dot { color: var(--amber); }
.brand-sub {
    display: block;
    font-size: 9px;
    color: var(--app-ink-3);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1;
    margin-top: 4px;
}

/* Nav — medium weight, the working surface */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 0 0;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 11px;
    border-radius: 9px;
    color: var(--app-ink-2);
    font-size: 14.5px;
    font-weight: 500;
    text-decoration: none;
    position: relative;
    transition: background 0.14s, color 0.14s;
}
.sidebar-link svg { flex: none; width: 19px; height: 19px; opacity: 0.85; }
.sidebar-link:hover {
    background: var(--app-surface-2);
    color: var(--app-ink);
}
.sidebar-link.active {
    background: var(--app-active);
    color: var(--pine);
    font-weight: 600;
}
.sidebar-link.active svg { opacity: 1; }
.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: -14px; top: 9px; bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--amber);
}

/* Footer — lightest weight, de-emphasized utility links */
.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--app-line);
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--app-ink-3);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.14s, color 0.14s;
}
.sidebar-footer-link:hover {
    background: var(--app-surface-2);
    color: var(--app-ink-2);
}
.sidebar-footer-link svg { width: 15px; height: 15px; opacity: 0.7; flex: none; }

.sidebar-backdrop { display: none; }

/* ---------- Main / topbar — calm light theme with backdrop blur ---------- */

.main {
    background: var(--app-bg);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: clip;
}

.topbar {
    height: var(--tb-h);
    background: rgba(250,248,241,.86);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--app-line);
    display: flex;
    align-items: center;
    padding: 0 var(--page-pad);
    gap: var(--s4);
    position: sticky;
    top: 0;
    z-index: 30;
}

.menu-toggle {
    display: none;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    background: var(--app-surface);
    border: 1px solid var(--app-line-2);
    border-radius: 9px;
    color: var(--app-ink);
    cursor: pointer;
}
.menu-toggle:hover { background: var(--app-surface-2); }
.menu-toggle svg { width: 20px; height: 20px; }

.topbar-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--app-ink);
    line-height: 1.1;
    flex: 1;
    min-width: 0;
    margin: 0;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-stub { display: none; }   /* removed — was a non-functional promise */

/* Pro / licence UI */
.topbar-pro-btn { white-space: nowrap; }
.pro-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--amber);
    color: var(--pine-deep);
    font-weight: 700;
    font-size: 12px;
    padding: 5px 11px;
    border-radius: var(--r-pill);
    letter-spacing: 0.02em;
}
.pro-pill svg { display: block; }
.tag-pro {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--amber-deep);
    background: var(--amber-tint);
    border: 1px solid var(--amber-soft);
    padding: 2px 7px;
    border-radius: var(--r-pill);
    vertical-align: middle;
}

.page-content {
    flex: 1;
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 30px var(--page-pad) 80px;
}
.page-content.page-wide { max-width: 1280px; }

/* =====================================================
   PAGE LEVEL
   ===================================================== */

.page-section { margin-bottom: var(--s8); }
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-head .page-title { margin-bottom: 6px; }
.page-head .page-lead  { max-width: 560px; margin-bottom: 0; }
@media (max-width: 720px) {
    .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
}
.page-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--app-ink);
    margin-bottom: var(--s2);
}
.page-lead {
    color: var(--app-ink-2);
    font-size: 15.5px;
    line-height: 1.55;
    max-width: 680px;
    margin-bottom: var(--s2);
}
.section-subtitle {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--app-ink-3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: var(--s3);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 18px;
    color: var(--app-ink-2);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.back-link:hover { color: var(--pine); }
.back-link svg { width: 16px; height: 16px; flex: none; }

/* =====================================================
   BUTTONS
   ===================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    padding: 10px 18px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--r-ctrl);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background 0.16s, color 0.16s, border-color 0.16s, transform 0.12s, box-shadow 0.16s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-lg { padding: 14px 22px; font-size: 15px; border-radius: 11px; }

.btn-primary,
.btn-pine {
    background: var(--pine);
    color: var(--cream);
    border-color: var(--pine);
}
.btn-primary:hover,
.btn-pine:hover {
    background: var(--pine-2);
    border-color: var(--pine-2);
    color: var(--cream);
}

.btn-amber {
    background: var(--amber);
    color: var(--pine-deep);
    border-color: var(--amber);
}
.btn-amber:hover {
    background: var(--amber-bright);
    border-color: var(--amber-bright);
}

.btn-ghost {
    background: transparent;
    color: var(--app-ink);
    border-color: var(--app-line-2);
}
.btn-ghost:hover {
    background: var(--app-surface-2);
    border-color: var(--line);
    color: var(--app-ink);
}

.btn-line {
    background: transparent;
    border-color: var(--pine-line);
    color: var(--cream);
}
.btn-line:hover {
    background: rgba(255,255,255,.07);
    color: var(--cream);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}
.btn-danger:hover { background: #991b1b; border-color: #991b1b; color: #ffffff; }

.btn-danger-text {
    background: transparent;
    color: var(--danger);
    border-color: #FBC4C4;
}
.btn-danger-text:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* =====================================================
   FORMS
   ===================================================== */

/* .form is now a plain container — its children are .form-section cards
   that provide their own background/border/shadow. Earlier this rule
   added a nested card frame that ate 50 px of horizontal width and
   collapsed table layouts inside. */
.form {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-top: var(--s3);
    box-shadow: none;
}
.form-section {
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    padding: 24px 26px;
    margin-bottom: 18px;
    box-shadow: var(--el-raise);
}
.form-section-title {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 20px;
}
.form-section-title .n {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: var(--pine-tint);
    color: var(--pine);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono);
    font-size: 12px; font-weight: 700;
    flex: none;
}
.form-section-title h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    color: var(--app-ink);
}
.form-section-title .hint {
    margin-left: auto;
    font-size: 12px;
    color: var(--app-ink-3);
}

/* ---------- Field / input base styles (Direction C) ---------- */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--app-ink-2);
    margin-bottom: 7px;
    letter-spacing: 0.01em;
}
.field label .req { color: var(--amber-deep); }
.field .fhint {
    font-size: 11.5px;
    color: var(--app-ink-3);
    margin-top: 6px;
    line-height: 1.4;
}

.inp,
textarea.inp,
select.inp {
    width: 100%;
    font-family: var(--font-ui);
    font-size: 14.5px;
    color: var(--app-ink);
    background: var(--app-surface);
    border: 1.5px solid var(--app-line-2);
    border-radius: var(--r-ctrl);
    padding: 11px 13px;
    transition: border-color 0.14s, box-shadow 0.14s;
    line-height: 1.3;
}
.inp::placeholder { color: var(--app-ink-3); }
.inp:focus,
textarea.inp:focus,
select.inp:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: var(--ring);
}
.inp:disabled {
    background: var(--app-surface-2);
    color: var(--app-ink-2);
    cursor: not-allowed;
    border-style: dashed;
}
textarea.inp {
    resize: vertical;
    min-height: 84px;
}
.inp-mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* Multi-column field rows */
.field-row    { display: grid; gap: 14px; }
.field-row.c2 { grid-template-columns: 1fr 1fr; }
.field-row.c3 { grid-template-columns: 1fr 1fr 1fr; }
.field-row.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
    .field-row.c2,
    .field-row.c3,
    .field-row.c4 { grid-template-columns: 1fr; }
}

.form-field { margin-bottom: var(--s3); }
.form-field-inline {
    display: flex;
    align-items: center;
    gap: var(--s2);
}
.form-field-inline label { margin: 0; font-size: 14px; color: var(--app-ink); }

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s3);
    margin-bottom: var(--s3);
}
.form-row .form-field { margin-bottom: 0; }
.form-row:has(.form-field:nth-child(3)) { grid-template-columns: repeat(3, 1fr); }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--app-ink);
    margin-bottom: 5px;
}

.form-input {
    width: 100%;
    padding: 9px 12px;
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--app-ink);
    background: var(--app-surface);
    border: 1px solid var(--app-line-2);
    border-radius: var(--r-ctrl);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
    outline: none;
    border-color: var(--pine);
    box-shadow: 0 0 0 3px rgba(30,52,42,0.12);
}
.form-input[type="number"] {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.form-textarea { min-height: 88px; resize: vertical; }
.form-input[type="search"],
.search {
    background: var(--app-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16' fill='none' stroke='%238E9489' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cline x1='11' y1='11' x2='14' y2='14'/%3E%3C/svg%3E") no-repeat 12px center;
    padding-left: 36px;
}

.form-hint {
    font-size: 12px;
    color: var(--app-ink-3);
    margin-top: 5px;
    line-height: 1.5;
}
.form-hint a { color: var(--pine); font-weight: 500; }
.form-hint a:hover { color: var(--pine-2); }

.form-actions {
    display: flex;
    gap: var(--s2);
    margin-top: var(--s4);
    padding-top: var(--s4);
    border-top: 1px solid var(--app-line);
    flex-wrap: wrap;
}

/* =====================================================
   SETTINGS — Direction C two-pane layout
   ===================================================== */

.set-cols {
    display: grid;
    grid-template-columns: 208px 1fr;
    gap: 28px;
    align-items: start;
}
.set-nav {
    position: sticky;
    top: calc(var(--tb-h) + 24px);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.set-nav a {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--app-ink-2);
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.14s, color 0.14s;
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
}
.set-nav a:hover { background: var(--app-surface-2); color: var(--app-ink); }
.set-nav a.on {
    background: var(--app-active);
    color: var(--pine);
    font-weight: 600;
}
.set-nav a .num {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--app-ink-3);
    width: 14px;
}
.set-nav a.on .num { color: var(--pine); }
.set-body { min-width: 0; }

/* Tax rates (read-only display) */
.readonly-rates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.rate {
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: var(--r-ctrl);
    padding: 16px 18px;
}
.rate .k { font-size: 12px; font-weight: 600; color: var(--app-ink-2); }
.rate .v {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 600;
    color: var(--money);
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.rate .lock {
    font-size: 11px;
    color: var(--app-ink-3);
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Numbering example pill */
.numbering {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.num-example {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--app-ink-2);
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: 8px;
    padding: 11px 14px;
}
.num-example b { color: var(--pine); }

/* Logo box */
.logo-box {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.logo-prev {
    width: 240px;
    height: 96px;
    border-radius: var(--r-ctrl);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    overflow: hidden;
}
.logo-prev.empty {
    border: 2px dashed var(--app-line-2);
    background: repeating-linear-gradient(45deg, var(--app-surface-2), var(--app-surface-2) 8px, var(--app-surface) 8px, var(--app-surface) 16px);
    flex-direction: column;
    gap: 5px;
    color: var(--app-ink-3);
}
.logo-prev.empty svg { width: 26px; height: 26px; }
.logo-prev.empty .t { font-size: 12px; font-weight: 600; }
.logo-prev.full {
    background: var(--pine);
    color: var(--amber);
}
.logo-prev.full img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.set-logo-actions {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 180px;
}

/* Palette swatches with caption */
.swatches {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.swatch {
    width: 52px;
    height: 52px;
    border-radius: 13px;
    cursor: pointer;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), var(--sh-sm);
    transition: transform 0.14s;
    border: none;
    padding: 0;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.on {
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 0 0 2px var(--app-surface), 0 0 0 4px var(--amber);
}
.swatch-wrap { text-align: center; }
.swatch-cap {
    font-size: 11px;
    color: var(--app-ink-3);
    text-align: center;
    margin-top: 7px;
    font-weight: 600;
}
.palette-note {
    font-size: 12.5px;
    color: var(--app-ink-3);
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.palette-note .tag-pro {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--amber-deep);
    background: var(--amber-soft);
    padding: 3px 8px;
    border-radius: 5px;
    text-transform: uppercase;
}

/* Default-template card (replaces outdated phase-7 copy) */
.tpl-default-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    padding: 16px 18px;
    flex-wrap: wrap;
}
.tpl-default-card .mini {
    width: 70px; height: 92px;
    border-radius: 6px;
    background: #fff;
    box-shadow: var(--sh-sm);
    flex: none;
    padding: 9px;
    overflow: hidden;
}
.tpl-default-card .mini .bar { height: 4px; background: var(--pine); border-radius: 2px; width: 60%; margin-bottom: 6px; }
.tpl-default-card .mini .ln { height: 3px; background: var(--line); border-radius: 2px; margin-bottom: 4px; }
.tpl-default-card .mini .ln.a { background: var(--amber); width: 40%; }
.tpl-default-card .ti { flex: 1; min-width: 200px; }
.tpl-default-card .ti .nm {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--app-ink);
    display: flex;
    align-items: center;
    gap: 9px;
}
.tpl-default-card .ti .dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #1E342A;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--app-line-2);
}
.tpl-default-card .ti .pp { font-size: 13px; color: var(--app-ink-2); margin-top: 4px; }

@media (max-width: 880px) {
    .set-cols { grid-template-columns: 1fr; }
    .set-nav {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 8px;
    }
    .set-nav a .num { display: none; }
    .readonly-rates { grid-template-columns: 1fr; }
}

.locked-field {
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: var(--r-ctrl);
    padding: var(--s3);
    font-size: 14px;
}
.locked-field strong { display: inline; }

.tax-display {
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: var(--r-ctrl);
    padding: var(--s2) var(--s3);
}
.tax-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--s1) 0;
    font-size: 14px;
}
.tax-row + .tax-row { border-top: 1px solid var(--line); }
.tax-row strong { font-family: var(--font-display); font-weight: 700; }
.tax-row span.mono { color: var(--amber-deep); font-weight: 600; }

/* =====================================================
   PALETTE SWATCHES
   ===================================================== */

.palette-grid {
    display: flex;
    gap: var(--s2);
    flex-wrap: wrap;
}
.palette-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--paper);
    box-shadow: 0 0 0 1px var(--line-2), var(--sh-sm);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s, box-shadow 0.15s;
}
.palette-swatch:hover {
    transform: scale(1.08);
    box-shadow: 0 0 0 1px var(--ink-3), var(--sh-sm);
}
.palette-swatch.selected {
    box-shadow: 0 0 0 2px var(--amber), var(--sh-sm);
}

/* =====================================================
   STATUS BADGES & CHIPS
   ===================================================== */

.chip,
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 11px;
    border-radius: var(--r-pill);
    line-height: 1.3;
    letter-spacing: 0.01em;
}
.chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.chip.draft, .chip.cancelled, .status-neutral { color: var(--st-draft);   background: var(--st-draft-bg); }
.chip.sent,                    .status-info    { color: var(--st-sent);    background: var(--st-sent-bg); }
.chip.paid, .chip.accepted, .status-success    { color: var(--st-paid);    background: var(--st-paid-bg); }
.chip.overdue, .chip.declined, .status-danger  { color: var(--st-overdue); background: var(--st-overdue-bg); }
.chip.pending, .chip.partial, .chip.expired,
                               .status-warn    { color: var(--st-pending); background: var(--st-pending-bg); }
.chip.converted               { color: var(--pine); background: var(--pine-tint); }
.chip.lg                      { font-size: 13px; padding: 6px 13px; }

/* =====================================================
   DASHBOARD
   ===================================================== */

.setup-banner {
    background: linear-gradient(180deg, var(--pine), var(--pine-2));
    color: var(--cream);
    border-radius: var(--r-card);
    padding: var(--s6) var(--s8);
    margin-bottom: var(--s6);
    position: relative;
    overflow: hidden;
}
.setup-banner::after {
    content: "";
    position: absolute;
    right: -120px;
    top: -80px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(192,134,58,.12), transparent 62%);
    pointer-events: none;
}
.setup-banner h2,
.setup-banner .setup-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--cream);
    margin-bottom: var(--s2);
    letter-spacing: -0.01em;
}
.setup-banner p,
.setup-banner .setup-lead {
    color: #C7D1C7;
    margin-bottom: var(--s4);
    font-size: 15px;
}
.setup-banner .btn-primary,
.setup-banner .btn-pine {
    background: var(--amber);
    color: var(--pine-deep);
    border-color: var(--amber);
}
.setup-banner .btn-primary:hover { background: var(--amber-bright); border-color: var(--amber-bright); }

/* ---------- Dashboard greeting + section divider ---------- */
.welcome { margin-bottom: 24px; }
.welcome h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 30px;
    letter-spacing: -0.025em;
    color: var(--app-ink);
    line-height: 1.04;
}
.welcome p { font-size: 15px; color: var(--app-ink-2); margin-top: 7px; }
.sec-label {
    display: flex; align-items: center; gap: 10px;
    font-size: 11.5px; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--app-ink-3);
    margin: 6px 0 14px;
}
.sec-label .ln { flex: 1; height: 1px; background: var(--app-line); }

/* ---------- Action cards (4 across desktop) ---------- */
.ac-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}
.ac {
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    padding: 20px;
    box-shadow: var(--el-raise);
    cursor: pointer;
    transition: transform 0.14s, box-shadow 0.14s;
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: var(--app-ink);
    text-decoration: none;
    position: relative;
}
.ac:hover { transform: translateY(-3px); box-shadow: var(--el-pop); color: var(--app-ink); }
.ac .ic {
    width: 40px; height: 40px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    flex: none;
}
.ac .ic svg { width: 21px; height: 21px; }
.ac .ic.neutral { background: var(--app-surface-2); color: var(--app-ink-2); }
.ac .ic.sent    { background: var(--st-sent-bg);    color: var(--st-sent); }
.ac .ic.recv    { background: var(--pine-tint);     color: var(--pine); }
.ac .ic.over    { background: var(--urgent-bg);     color: var(--urgent); }
.ac .lbl { font-size: 13px; font-weight: 600; color: var(--app-ink-2); line-height: 1.3; }
.ac .num {
    font-family: var(--font-mono);
    font-size: 34px;
    font-weight: 600;
    color: var(--app-ink);
    line-height: 1;
    letter-spacing: -0.02em;
}
.ac .sum {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    font-weight: 600;
    color: var(--app-ink-2);
    margin-top: 5px;
}
.ac.over {
    border-color: var(--urgent-line);
    background: linear-gradient(180deg, #FEF6F6, var(--app-surface) 60%);
}
.ac.over .num,
.ac.over .sum { color: var(--urgent); }
.ac .arr {
    position: absolute;
    top: 20px; right: 18px;
    color: var(--app-ink-3);
    opacity: 0;
    transition: opacity 0.14s;
}
.ac:hover .arr { opacity: 0.6; }

.quickstart-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s3);
}
.quick-card {
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    padding: var(--s5);
    color: var(--app-ink);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    flex-direction: column;
    gap: var(--s2);
}
.quick-card:hover {
    border-color: var(--pine);
    background: var(--card);
    color: var(--app-ink);
}
.quick-card-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.quick-card-body  { font-size: 13.5px; color: var(--app-ink-2); }
.quick-card-arrow { font-size: 12px; color: var(--amber-deep); font-weight: 600; letter-spacing: 0.02em; }

/* ---------- Dashboard lower row (encaisse + panels) ---------- */
.dash-lower {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
    margin-bottom: var(--s8);
}

/* Encaisse — full-width pine card with amber accent */
.encaisse {
    grid-column: 1 / -1;
    background: var(--pine);
    border-radius: var(--r-card);
    padding: 26px 30px;
    color: var(--cream);
    display: flex;
    align-items: center;
    gap: 30px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--el-raise);
}
.encaisse::after {
    content: "";
    position: absolute;
    right: -90px; top: -90px;
    width: 320px; height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(192,134,58,.16), transparent 64%);
    pointer-events: none;
}
.encaisse .ic {
    width: 54px; height: 54px;
    border-radius: 14px;
    background: rgba(192,134,58,.16);
    color: var(--amber);
    display: flex; align-items: center; justify-content: center;
    flex: none;
    border: 1px solid rgba(192,134,58,.3);
}
.encaisse .ic svg { width: 27px; height: 27px; }
.encaisse .body { position: relative; z-index: 1; }
.encaisse .lbl {
    font-size: 12px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted-on-pine);
}
.encaisse .big {
    font-family: var(--font-display);
    font-size: 42px; font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--amber);
    line-height: 1.04;
    margin-top: 6px;
    letter-spacing: -0.02em;
}
.encaisse .meta { font-size: 13.5px; color: #C7D1C7; margin-top: 6px; }
.encaisse .mo {
    margin-left: auto;
    text-align: right;
    position: relative;
    z-index: 1;
}
.encaisse .mo .m { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--cream); }
.encaisse .mo .y { font-family: var(--font-mono); font-size: 12px; color: var(--muted-on-pine); margin-top: 2px; }

/* Side panels for expiring quotes / overdue invoices */
.panel {
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    box-shadow: var(--el-raise);
    overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; gap: 11px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--app-line);
}
.panel-head .ic {
    width: 32px; height: 32px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex: none;
}
.panel-head .ic svg { width: 17px; height: 17px; }
.panel-head .ic.warn { background: var(--st-pending-bg); color: var(--st-pending); }
.panel-head .ic.over { background: var(--urgent-bg);     color: var(--urgent); }
.panel-head h3 { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--app-ink); }
.panel-head .ct { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--app-ink-3); }
.pl-row {
    display: flex; align-items: center; gap: 13px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--app-line);
    cursor: pointer;
    transition: background 0.12s;
    color: var(--app-ink);
    text-decoration: none;
}
.pl-row:last-child { border-bottom: none; }
.pl-row:hover { background: var(--app-surface-2); color: var(--app-ink); }
.pl-row .pn {
    font-family: var(--font-mono);
    font-size: 12.5px; font-weight: 600;
    color: var(--app-ink-2);
    width: 130px; flex: none;
}
.pl-row .pc { flex: 1; min-width: 0; }
.pl-row .pc .nm { font-size: 14px; font-weight: 600; color: var(--app-ink); }
.pl-row .pc .dt { font-size: 12px; color: var(--app-ink-3); margin-top: 2px; }
.pl-row .pright { text-align: right; }
.pl-row .pright .amt {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 14px; font-weight: 600;
    color: var(--money);
}
.pl-row .pill-d {
    font-size: 11px; font-weight: 700;
    padding: 2px 8px; border-radius: var(--r-pill);
    margin-top: 4px;
    display: inline-block;
}
.pill-d.warn { color: var(--st-pending); background: var(--st-pending-bg); }
.pill-d.over { color: var(--urgent);     background: var(--urgent-bg); }

@media (max-width: 920px) {
    .ac-grid    { grid-template-columns: 1fr 1fr; }
    .dash-lower { grid-template-columns: 1fr; }
    .encaisse   { flex-direction: column; align-items: flex-start; gap: 14px; padding: 22px 24px; }
    .encaisse .mo { margin-left: 0; text-align: left; }
    .encaisse .big { font-size: 34px; }
}
@media (max-width: 480px) {
    .ac-grid { grid-template-columns: 1fr; }
}

/* =====================================================
   TOOLBAR (search + segment toggle for clients / products)
   ===================================================== */

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.toolbar .search { flex: 1; min-width: 220px; max-width: 400px; }

/* Segmented control */
.seg {
    display: flex;
    background: var(--app-surface-2);
    border: 1px solid var(--app-line-2);
    border-radius: 9px;
    padding: 3px;
}
.seg button {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--app-ink-2);
    background: transparent;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.14s, color 0.14s;
    white-space: nowrap;
}
.seg button:hover { color: var(--app-ink); }
.seg button.on {
    background: var(--app-surface);
    color: var(--app-ink);
    box-shadow: var(--sh-sm);
}

/* Search input with leading icon */
.inp-icon {
    position: relative;
}
.inp-icon svg {
    position: absolute;
    left: 13px; top: 50%;
    transform: translateY(-50%);
    width: 17px; height: 17px;
    color: var(--app-ink-3);
    pointer-events: none;
}
.inp-icon .inp { padding-left: 40px; }

/* Footer toggle ("Voir les clients archivés") */
.foot-toggle {
    text-align: center;
    margin-top: 20px;
    font-size: 13.5px;
}
.foot-toggle a {
    color: var(--pine);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.foot-toggle a:hover { color: var(--pine-2); }

/* Client row layout */
.row.crow {
    grid-template-columns: 1fr 220px auto;
    align-items: center;
}
.row.crow .cv { display: flex; align-items: center; gap: 13px; }
.row.crow .av {
    width: 42px; height: 42px;
    border-radius: 11px;
    background: var(--pine-tint);
    color: var(--pine);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    flex: none;
}
.row.crow .nm { font-size: 15.5px; font-weight: 600; color: var(--app-ink); display: flex; align-items: center; gap: 9px; }
.row.crow .co { font-size: 12.5px; color: var(--app-ink-2); margin-top: 2px; }
.row.crow .tx { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.row.crow .txid {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--app-ink-3);
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    padding: 1px 7px;
    border-radius: 5px;
}
.row.crow .contact { font-size: 12.5px; color: var(--app-ink-3); line-height: 1.5; }
.row.crow .contact .em { color: var(--app-ink-2); font-weight: 500; }
.row.crow .acts { display: flex; gap: 8px; justify-self: end; }
.row.crow .acts .btn { opacity: 0.5; transition: opacity 0.14s; }
.row.crow:hover .acts .btn { opacity: 1; }
.row.crow.arch .av { background: var(--app-surface-2); color: var(--app-ink-3); }
.row.crow.arch .nm { color: var(--app-ink-2); }

/* Product row layout */
.row.prow {
    grid-template-columns: 1fr 200px;
    align-items: center;
}
.row.prow .nm {
    font-size: 15.5px;
    font-weight: 600;
    color: var(--app-ink);
    display: flex; align-items: center; gap: 9px;
    flex-wrap: wrap;
}
.row.prow .cat {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--app-ink-3);
    margin-top: 5px;
}
.row.prow .desc {
    font-size: 13px;
    color: var(--app-ink-2);
    margin-top: 5px;
    line-height: 1.45;
    max-width: 560px;
}
.row.prow .sku {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--app-ink-3);
    margin-top: 6px;
}
.row.prow .price { text-align: right; }
.row.prow .price .amt {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 19px;
    font-weight: 600;
    color: var(--money);
}
.row.prow .price .unit { font-size: 12px; color: var(--app-ink-3); margin-top: 2px; }
.row.prow.arch .nm    { color: var(--app-ink-2); }

/* "Non taxable" soft tag */
.tag-soft {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border-radius: 6px;
    text-transform: uppercase;
}
.tag-soft.nt       { color: var(--st-pending); background: var(--st-pending-bg); }
.tag-soft.archived { color: var(--app-ink-3);  background: var(--app-surface-2); border: 1px solid var(--app-line); }
.tag-soft svg      { width: 12px; height: 12px; }

@media (max-width: 760px) {
    .row.crow { grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; border: 1px solid var(--app-line); border-radius: var(--r-card); margin-bottom: 10px; background: var(--app-surface); box-shadow: var(--el-raise); }
    .row.crow .contact { display: none; }
    .row.crow .acts { justify-self: start; opacity: 1; }
    .row.crow .acts .btn { opacity: 1; }
    .row.prow { grid-template-columns: 1fr; padding: 14px 16px; border: 1px solid var(--app-line); border-radius: var(--r-card); margin-bottom: 10px; background: var(--app-surface); box-shadow: var(--el-raise); }
    .row.prow .price { text-align: left; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--app-line); display: flex; align-items: baseline; gap: 10px; }
    .row.prow .price .unit { margin-top: 0; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .search { max-width: none; }
    .seg { overflow-x: auto; }
}

/* =====================================================
   LIST + LIST ROWS (legacy structures for forms, etc.)
   ===================================================== */

.list-head-flex {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s4);
    margin-bottom: var(--s4);
}
.list-head-left { flex: 1; min-width: 0; }

.list {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    margin-bottom: var(--s4);
}

.list-row {
    display: grid;
    grid-template-columns: 1fr 220px 200px;
    align-items: center;
    gap: var(--s4);
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    padding: var(--s3) var(--s5);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.list-row:hover { border-color: var(--pine); box-shadow: var(--sh-sm); }
.list-row.is-archived {
    opacity: 0.65;
    background: var(--app-surface-2);
}

.list-row-main { min-width: 0; }
.list-row-title {
    font-weight: 600;
    color: var(--app-ink);
    margin-bottom: 2px;
    font-size: 14.5px;
}
.list-row-sub  { font-size: 13px; color: var(--app-ink-2); }
.list-row-faint{ font-size: 12px; color: var(--app-ink-3); font-family: var(--font-mono); }

.list-row-meta {
    font-size: 13px;
    color: var(--app-ink-2);
    text-align: right;
}
.list-row-meta .price {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--pine);
    font-size: 14.5px;
    font-variant-numeric: tabular-nums;
}

.list-row-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s2);
}

.list-toggle {
    margin-top: var(--s2);
    text-align: center;
}
.ghost-link {
    font-size: 13px;
    color: var(--app-ink-2);
    text-decoration: none;
}
.ghost-link:hover { color: var(--pine); }

.tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tag-warn { background: var(--amber-soft); color: var(--amber-deep); }

/* =====================================================
   EMPTY STATE
   ===================================================== */

.empty-state {
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    padding: 64px 40px;
    text-align: center;
    color: var(--app-ink-2);
    box-shadow: var(--el-raise);
    position: relative;
    overflow: hidden;
}
.empty-state::after {
    content: "";
    position: absolute;
    right: -120px; top: -80px;
    width: 360px; height: 360px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(192,134,58,.07), transparent 64%);
    pointer-events: none;
}
.empty-state .emblem {
    width: 76px; height: 76px;
    border-radius: 20px;
    margin: 0 auto 22px;
    display: flex; align-items: center; justify-content: center;
    background: var(--pine-tint);
    color: var(--pine);
    border: 1px solid var(--pine-tint-2);
}
.empty-state .emblem svg { width: 34px; height: 34px; }
.empty-state h3 {
    font-family: var(--font-display);
    color: var(--app-ink);
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
}
.empty-state p {
    font-size: 15px;
    color: var(--app-ink-2);
    max-width: 420px;
    margin: 0 auto 26px;
    line-height: 1.55;
}

/* =====================================================
   COMING NEXT (quote/invoice placeholders)
   ===================================================== */

.coming-next {
    background: var(--card);
    border: 1px dashed var(--line);
    border-radius: var(--r-card);
    padding: var(--s12) var(--s5);
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}
.coming-next h1 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; }

/* =====================================================
   ERROR STATE
   ===================================================== */

.error-state {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    border-radius: var(--r-card);
    padding: var(--s5);
    color: var(--danger);
}
.error-state strong { display: block; margin-bottom: var(--s2); font-family: var(--font-display); }

/* =====================================================
   DOCUMENT LIST (quotes, invoices) — Direction C spec
   ===================================================== */

.list {
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    overflow: hidden;
    box-shadow: var(--el-raise);
    margin-bottom: var(--s5);
}
.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--app-line);
    background: var(--app-surface-2);
}
.list-head .cnt {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--app-ink-2);
}
.list-head .cnt b {
    color: var(--app-ink);
    font-family: var(--font-mono);
}

.row {
    display: grid;
    align-items: center;
    gap: 16px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--app-line);
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
}
.row:last-child { border-bottom: none; }
.row:hover  { background: var(--app-surface-2); }
.row:focus-visible {
    outline: none;
    box-shadow: inset 3px 0 0 var(--amber);
    background: var(--app-surface-2);
}
.row:active { background: var(--cream-2); }

/* doc list grid: number | client+meta | status | total */
.row.doc { grid-template-columns: 128px 1fr auto 150px; }
.row.urgent-row { box-shadow: inset 4px 0 0 var(--urgent); }

.row .r-num {
    font-family: var(--font-mono);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--app-ink);
    letter-spacing: -0.02em;
}
.row .r-client {
    font-size: 15px;
    font-weight: 600;
    color: var(--app-ink);
    line-height: 1.2;
}
.row .r-meta {
    font-size: 12.5px;
    color: var(--app-ink-3);
    margin-top: 3px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.row .r-meta .sep { color: var(--app-line-2); }
.row .r-sub {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    margin-top: 6px;
    padding: 2px 9px;
    border-radius: var(--r-pill);
}
.r-sub.link   { color: var(--pine);     background: var(--pine-tint); }
.r-sub.paid   { color: var(--st-paid);  background: var(--st-paid-bg); }
.r-sub.urgent { color: var(--urgent);   background: var(--urgent-bg); }
.r-sub.warn   { color: var(--st-pending); background: var(--st-pending-bg); }

.row .r-status { justify-self: start; }
.row .r-total  { text-align: right; }
.row .r-total .amt {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 17px;
    font-weight: 600;
    color: var(--money);
    letter-spacing: -0.01em;
}
.row .r-total .cur {
    font-size: 11px;
    color: var(--app-ink-3);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 2px;
}
.row .chev {
    position: absolute;
    right: 14px;
    color: var(--app-ink-3);
    opacity: 0;
    transition: opacity 0.14s;
}
.row:hover .chev { opacity: 0.6; }

/* ---------- Mobile: rows reflow to cards ---------- */
@media (max-width: 720px) {
    .row.doc {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 14px 16px;
        border: 1px solid var(--app-line);
        border-radius: var(--r-card);
        margin-bottom: 10px;
        background: var(--app-surface);
        box-shadow: var(--el-raise);
    }
    .row.doc:last-child { border-bottom: 1px solid var(--app-line); }
    .row.doc .r-num   { font-size: 12.5px; color: var(--app-ink-2); }
    .row.doc .r-client{ font-size: 15.5px; }
    .row.doc .r-status{ position: absolute; top: 14px; right: 16px; }
    .row.doc .r-total {
        text-align: left;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--app-line);
    }
    .row.doc .r-total .amt { font-size: 18px; }
    .row.doc .r-total .cur { display: none; }
    .row.doc .chev         { display: none; }
    .list {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
    }
    .list-head {
        background: transparent;
        border-bottom: none;
        padding: 0 4px 12px;
    }
}

/* =====================================================
   DOCUMENT EDITOR — Direction C two-pane spec
   ===================================================== */

/* Two-column layout on desktop: form 1fr + sticky preview 320px.
   The preview only appears at >=1500px viewport so the form has enough
   width for the line table at narrower desktops. Preview kept narrow
   (320px) so the form column gets at least ~180px of Description width
   even on the smallest two-pane viewport. */
.ed-cols {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}
.ed-form {
    min-width: 0;
    /* Leave room so the sticky .action-bar never covers Totaux/Notes/Print row */
    padding-bottom: 140px;
}
.ed-prev {
    position: sticky;
    top: calc(var(--tb-h) + 24px);
    min-width: 0;
}
/* Preview width is held at 320 px at every viewport. The form column
   is already capped by --page-max (1120 px), so widening the preview
   on big screens only steals room from the line table without making
   the preview meaningfully more readable. */

/* Document header */
.doc-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.doc-kicker {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--amber-deep);
    margin-bottom: 8px;
}
.doc-header h1,
.doc-header .page-title {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 30px;
    letter-spacing: -0.02em;
    color: var(--app-ink);
    line-height: 1;
    margin-bottom: 0;
}
.doc-header .h-status {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 13px;
}
.doc-header .h-meta { font-size: 13px; color: var(--app-ink-3); }

/* Link banner (converted-from / converted-to) */
.link-banner,
.doc-link-banner {
    display: flex;
    align-items: center;
    gap: 11px;
    background: var(--pine-tint);
    border: 1px solid var(--pine-tint-2);
    border-radius: var(--r-card);
    padding: 13px 16px;
    max-width: 320px;
    color: var(--pine);
    text-decoration: none;
    transition: background 0.14s;
}
.link-banner:hover,
.doc-link-banner:hover { background: var(--pine-tint-2); color: var(--pine); }
.link-banner svg { width: 20px; height: 20px; color: var(--pine); flex: none; }
.link-banner .t {
    font-size: 11px;
    color: var(--app-ink-3);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.link-banner .v {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--pine);
    margin-top: 2px;
}

/* Client picker (avatar + info + change button) */
.picker {
    display: flex;
    align-items: center;
    gap: 13px;
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: var(--r-ctrl);
    padding: 13px 15px;
}
.picker .av {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--pine-tint);
    color: var(--pine);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    flex: none;
}
.picker .pi { min-width: 0; flex: 1; }
.picker .pi .nm { font-size: 15px; font-weight: 600; color: var(--app-ink); }
.picker .pi .ad { font-size: 12.5px; color: var(--app-ink-3); margin-top: 2px; }
.picker .chg { margin-left: auto; }

/* "Créer un nouveau client" row under the picker */
.client-picker-add {
    margin-top: 10px;
}
.client-picker-add .btn { padding: 7px 11px; }

/* Frozen-client lock hint */
.locked-hint {
    display: flex; align-items: center;
    gap: 9px;
    font-size: 12.5px;
    color: var(--app-ink-2);
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: 8px;
    padding: 10px 13px;
    margin-top: 10px;
}
.locked-hint svg { width: 15px; height: 15px; color: var(--app-ink-3); flex: none; }

/* Line table — design's .lt spec.
   table-layout: fixed locks each column to its declared width so a
   freakishly long amount can't push the entire table (and the editor
   column) past the live-preview boundary. */
.lt { width: 100%; border-collapse: collapse; table-layout: fixed; }
.lt thead th {
    text-align: left;
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--app-ink-3);
    padding: 0 10px 11px;
    border-bottom: 1px solid var(--app-line);
}
.lt th.r, .lt td.r { text-align: right; }
.lt th.c, .lt td.c { text-align: center; }
.lt tbody td, .lt td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--app-line);
    vertical-align: middle;
}
.lt .cell {
    width: 100%;
    min-width: 0;
    /* Inputs scroll their own contents horizontally when the value is
       longer than the cell — the cell itself never expands. */
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-ui);
    font-size: 14.5px;
    color: var(--app-ink);
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 7px;
    padding: 11px 13px;
    transition: border-color 0.14s, background 0.14s, box-shadow 0.14s;
    /* No browser-default number spinners — user types freely */
    appearance: textfield;
    -moz-appearance: textfield;
}
.lt .cell::-webkit-inner-spin-button,
.lt .cell::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
/* Global: never show number-input spinners anywhere in the app */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}
.lt .cell:hover  { border-color: var(--app-line-2); background: var(--app-surface); }
.lt .cell:focus  {
    outline: none;
    border-color: var(--amber);
    background: var(--app-surface);
    box-shadow: var(--ring);
}
.lt .cell.mono   { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.lt .cell.qty    { text-align: center; }
.lt td.tot {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    font-weight: 600;
    color: var(--money);
    text-align: right;
    /* Truncate very long totals with ellipsis so the cell can't push
       past the column's fixed width (table-layout: fixed handles the rest). */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.lt .rm {
    width: 32px; height: 32px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--app-ink-3);
    cursor: pointer;
    display: inline-flex;
    align-items: center; justify-content: center;
    transition: background 0.14s, color 0.14s;
}
.lt .rm:hover { background: var(--urgent-bg); color: var(--danger); }
.lt .rm svg { width: 16px; height: 16px; }
.lt-add {
    display: flex; gap: 10px; flex-wrap: wrap;
    margin-top: 14px;
}
/* Description is the only auto column → with table-layout:fixed it
   takes all space not consumed by the explicit-width columns. Sum below
   = 476 px so at the narrowest two-pane viewport (1500 vp, ed-form 712,
   form-section inner 660) Description still gets ~184 px. Adjust both
   here and the preview width together if you change either. */
.col-desc  { width: auto; }
.col-qty   { width: 60px; }
.col-unit  { width: 110px; }
.col-price { width: 100px; }
.col-tax   { width: 60px; }
.col-tot   { width: 110px; }
.col-act   { width: 36px; }
.lt tbody td, .lt td { padding: 6px 4px; vertical-align: middle; }
.lt thead th { padding: 0 4px 12px; }

/* Unit cell: select or text input; if "Autre…" is chosen, an inline
   text input is appended in place. Keep it compact. */
.lt .lt-unit-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lt .lt-unit-wrap .cell.lt-unit-custom {
    background: var(--app-surface);
    border-color: var(--app-line-2);
}

/* Taxable checkbox in line rows */
.cbx {
    appearance: none;
    width: 20px; height: 20px;
    border: 1.5px solid var(--app-line-2);
    border-radius: 6px;
    background: var(--app-surface);
    cursor: pointer;
    position: relative;
    transition: background 0.14s, border-color 0.14s;
    vertical-align: middle;
}
.cbx:checked { background: var(--pine); border-color: var(--pine); }
.cbx:checked::after {
    content: "";
    position: absolute;
    left: 6px; top: 2.5px;
    width: 5px; height: 10px;
    border: solid var(--cream);
    border-width: 0 2px 2px 0;
    transform: rotate(42deg);
}
.cbx:focus-visible { outline: none; box-shadow: var(--ring); }

/* Mobile line-row reflow — cards instead of table rows */
.mline {
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 11px;
}
.mline .ml-desc { font-size: 14.5px; font-weight: 600; color: var(--app-ink); margin-bottom: 10px; }
.mline .ml-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mline .ml-f label {
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--app-ink-3);
    display: block;
    margin-bottom: 4px;
}
.mline .ml-tot {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 12px; padding-top: 11px;
    border-top: 1px solid var(--app-line);
}
.mline .ml-tot .amt {
    font-family: var(--font-mono);
    font-size: 15px; font-weight: 600;
    color: var(--money);
}

/* Tax block — design's totals card. Items use min-width:0 so long
   amounts can wrap inside the box instead of inflating it. */
.tax-block {
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    padding: 20px 22px;
    max-width: 380px;
    margin-left: auto;
    min-width: 0;
    overflow: hidden;
}
.tax-line {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--app-ink-2);
    min-width: 0;
}
.tax-line .k { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; }
.tax-line .pct {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--app-ink-3);
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    padding: 1px 7px;
    border-radius: var(--r-pill);
}
.tax-line .v {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--app-ink);
    text-align: right;
    /* Wrap absurdly long amounts inside the cell rather than overflowing */
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    max-width: 100%;
}
.tax-grand {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding: 15px 18px;
    background: var(--pine);
    border-radius: var(--r-ctrl);
    color: var(--cream);
    min-width: 0;
}
.tax-grand .k {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-weight: 600;
    color: var(--muted-on-pine);
    flex: none;
}
.tax-grand .v {
    font-family: var(--font-display);
    font-size: 24px; font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--amber);
    text-align: right;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    max-width: 100%;
    line-height: 1.15;
}

/* Print row — pine card with template summary + actions */
.print-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    background: var(--pine);
    border-radius: var(--r-card);
    padding: 18px 22px;
    margin-bottom: 18px;
    color: var(--cream);
}
.tpl-summary {
    display: flex; align-items: center;
    gap: 13px;
    min-width: 0;
}
.tpl-dot {
    width: 34px; height: 34px;
    border-radius: 9px;
    flex: none;
    border: 2px solid rgba(255,255,255,.25);
}
.tpl-summary .tn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--cream);
    line-height: 1.1;
}
.tpl-summary .tp {
    font-size: 12px;
    color: var(--muted-on-pine);
    margin-top: 3px;
}
.print-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.print-row .btn-line {
    background: transparent;
    border-color: rgba(255,255,255,.30);
    color: var(--cream);
}
.print-row .btn-line:hover { background: rgba(255,255,255,.08); }

/* Template summary chip (used in editor + settings — calm light) */
.tpl-chip {
    display: flex; align-items: center;
    gap: 13px;
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: var(--r-card);
    padding: 14px 16px;
}
.tpl-chip .dot {
    width: 30px; height: 30px;
    border-radius: 8px;
    flex: none;
    border: 2px solid var(--app-surface);
    box-shadow: 0 0 0 1px var(--app-line-2);
}
.tpl-chip .tn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--app-ink);
}
.tpl-chip .tp { font-size: 12px; color: var(--app-ink-3); margin-top: 2px; }
.tpl-chip .chg { margin-left: auto; }

/* Sticky status-action bar — raised so the next action is never lost */
.action-bar {
    position: sticky;
    bottom: 18px;
    z-index: 20;
    background: var(--app-surface);
    border: 1px solid var(--app-line-2);
    border-radius: var(--r-card);
    box-shadow: var(--el-pop);
    padding: 16px 20px;
    display: flex; align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}
.action-bar .grp {
    display: flex; align-items: center;
    gap: 9px; flex-wrap: wrap;
}
.action-bar .spacer { margin-left: auto; }
.action-bar .ab-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--app-ink-3);
    margin-right: 4px;
}

/* Payment summary panel (paid / partial invoices) */
.pay-summary {
    display: flex;
    gap: 26px;
    flex-wrap: wrap;
    background: var(--st-paid-bg);
    border: 1px solid #CDE6D4;
    border-radius: var(--r-card);
    padding: 18px 22px;
    margin-bottom: 18px;
}
.pay-summary .pi .k {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--st-paid);
    margin-bottom: 5px;
}
.pay-summary .pi .v {
    font-size: 15px;
    font-weight: 600;
    color: var(--app-ink);
}
.pay-summary .pi .v.amt {
    font-size: 18px;
    color: var(--money);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* Quiet button variant */
.btn-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--app-ink-2);
}
.btn-quiet:hover { background: var(--app-surface-2); color: var(--app-ink); }
.btn-white {
    background: var(--app-surface);
    border-color: var(--app-line-2);
    color: var(--app-ink);
}
.btn-white:hover { background: var(--app-surface-2); border-color: var(--app-ink-3); }
.btn-danger-text,
.btn-danger {
    background: transparent;
    border-color: transparent;
    color: var(--danger);
}
.btn-danger:hover,
.btn-danger-text:hover { background: var(--urgent-bg); }

/* Live preview pane (right column) — pine shell + mini paper */
.prev-shell {
    background: var(--pine);
    border-radius: var(--r-card);
    padding: 18px;
    box-shadow: var(--el-raise);
}
.prev-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.prev-head .t {
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted-on-pine);
}
.prev-head .live {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px;
    color: var(--amber);
    font-weight: 600;
}
.prev-head .live .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 0 3px rgba(192,134,58,.25);
}
.paper {
    background: #fff;
    border-radius: 6px;
    box-shadow: var(--sh-md);
    padding: 26px;
    color: var(--ink);
    position: relative;
    overflow: hidden;
    /* Live preview = real DOM div (not iframe). It needs the same
       overflow safety as the iframe templates in paper.js wrapPaper. */
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.paper *, .paper td, .paper p, .paper div, .paper span, .paper b, .paper small {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}
.paper table { width: 100%; max-width: 100%; }
.paper .amt, .paper .v, .paper .gv, .paper .tot,
.paper .pp-grand .amt, .paper .pp-tot .v {
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    max-width: 100%;
    line-height: 1.18;
}
.pp-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.pp-iss { display: flex; align-items: center; gap: 9px; }
.pp-iss .lg {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--pine);
    color: var(--amber);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 13px;
}
.pp-iss .nm { font-family: var(--font-display); font-weight: 700; font-size: 13px; line-height: 1.1; }
.pp-iss small { display: block; font-size: 8px; color: var(--ink-3); font-family: var(--font-mono); margin-top: 2px; }
.pp-title { text-align: right; }
.pp-title .lbl { font-family: var(--font-display); font-size: 21px; font-weight: 700; color: var(--pine); }
.pp-title .num { font-family: var(--font-mono); font-size: 9px; color: var(--ink-2); margin-top: 2px; }
.pp-meta {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
}
.pp-meta .k { font-size: 7.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 700; margin-bottom: 3px; }
.pp-meta .v { font-size: 10.5px; font-weight: 700; color: var(--ink); }
.pp-rows { width: 100%; border-collapse: collapse; font-size: 9.5px; }
.pp-rows th { text-align: left; font-size: 7px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 700; padding-bottom: 7px; border-bottom: 1.5px solid var(--pine); }
.pp-rows th.r, .pp-rows td.r { text-align: right; font-family: var(--font-mono); }
.pp-rows td { padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.pp-rows td b { color: var(--ink); }
.pp-tot { margin-top: 11px; margin-left: auto; width: 64%; font-size: 9.5px; min-width: 0; }
.pp-tot .ln { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: var(--ink-2); min-width: 0; }
.pp-tot .ln .v { font-family: var(--font-mono); font-weight: 500; text-align: right; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.pp-grand {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 8px;
    margin-top: 6px;
    padding: 10px 12px;
    background: var(--pine);
    color: var(--cream);
    border-radius: 6px;
    min-width: 0;
}
.pp-grand .lbl { font-size: 8px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-on-pine); font-weight: 600; flex: none; }
.pp-grand .amt {
    font-family: var(--font-display);
    font-size: 16px; font-weight: 700;
    color: var(--amber);
    text-align: right;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.18;
}

/* Stamp overlay (PAYÉE / EN RETARD) on mini-preview */
.stamp {
    position: absolute;
    top: 54px; right: 16px;
    transform: rotate(-12deg);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 0.03em;
    padding: 5px 12px;
    border: 3px solid;
    border-radius: 8px;
    opacity: 0.86;
    display: none;
}
.stamp.show { display: inline-block; }
.stamp.paid { color: var(--st-paid); border-color: var(--st-paid); }
.stamp.over { color: var(--urgent);  border-color: var(--urgent); }

/* Collapse to single column below 1500px so the form has comfortable
   room for the line table (descriptions + amounts + Taxable + Total +
   delete). Below 1500, preview pane is hidden — user can still preview
   via the "Aperçu PDF" button which opens the full-page overlay. */
@media (max-width: 1499px) {
    .ed-cols { grid-template-columns: 1fr; }
    .ed-prev { display: none; }
}

/* ---------- Mobile: stack line items as editable cards ---------- */
@media (max-width: 720px) {
    .form-section { padding: 18px 16px; }
    .doc-header { flex-direction: column; align-items: stretch; gap: var(--s2); }
    .link-banner, .doc-link-banner { max-width: 100%; }
    .field-row.c3, .field-row.c4, .form-row { grid-template-columns: 1fr !important; }
    .tax-block { max-width: none; margin-left: 0; }
    .action-bar { position: fixed; left: 18px; right: 18px; bottom: 18px; margin: 0; }
    .print-row { padding: 14px 16px; }

    /* Line table → stacked cards */
    .lt, .lt thead, .lt tbody, .lt tr, .lt td { display: block; }
    .lt thead { display: none; }
    .lt tr {
        background: var(--app-surface);
        border: 1px solid var(--app-line);
        border-radius: var(--r-card);
        padding: 14px 14px 12px;
        margin-bottom: 12px;
        box-shadow: var(--el-raise);
    }
    .lt td {
        padding: 8px 0;
        border: none;
        text-align: left;
    }
    .lt td.r, .lt td.c { text-align: left; }
    .lt td::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: var(--app-ink-3);
        margin-bottom: 4px;
    }
    .lt td.lt-no-label::before { content: ""; display: none; }
    .lt td.tot {
        font-size: 17px;
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid var(--app-line);
        text-align: right;
    }
    .lt td.tot::before { display: none; }
    /* Inline qty + unit + price as a small grid */
    .lt td[data-label="Qté"], .lt td[data-label="Unité"], .lt td[data-label="Prix"] {
        display: inline-block;
        width: calc(33% - 6px);
        vertical-align: top;
    }
    .lt td[data-label="Taxable"] { display: flex; align-items: center; gap: 8px; }
    .lt td[data-label="Taxable"]::before { display: inline-block; margin: 0; }
    .lt .cell { font-size: 15px; padding: 10px 12px; }
    .lt .rm { width: 100%; height: 36px; background: var(--app-surface-2); border-radius: 8px; }
}

/* =====================================================
   MODAL + TOAST + CONFIRM — Direction C dialog system
   ===================================================== */

/* Toast host (centered bottom) */
.toast-host,
.toast-wrap {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}
.toast-host .toast,
.toast-wrap .toast { pointer-events: auto; }

.toast {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--pine);
    color: var(--cream);
    border-radius: var(--r-ctrl);
    box-shadow: var(--el-pop);
    padding: 13px 17px;
    font-size: 13.5px;
    font-weight: 500;
    max-width: 380px;
    opacity: 1;
    transition: opacity 0.22s, transform 0.22s;
}
.toast svg { width: 18px; height: 18px; color: var(--amber); flex: none; }
.toast .x {
    margin-left: 8px;
    color: var(--muted-on-pine);
    cursor: pointer;
    display: flex;
    align-items: center;
}
.toast.ok svg     { color: var(--amber); }
.toast.error,
.toast-error      { background: var(--danger); color: #ffffff; }
.toast.error svg,
.toast-error svg  { color: #ffffff; }
.toast-hide       { opacity: 0; transform: translateY(8px); }

/* Modal host + scrim */
.modal-host { position: relative; z-index: 9000; }

.modal-overlay,
.scrim {
    position: fixed;
    inset: 0;
    background: rgba(21, 38, 32, 0.46);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 9000;
    animation: scrim-in 0.18s ease;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

/* Dialog box */
.modal,
.dialog {
    background: var(--app-surface);
    border-radius: var(--r-modal);
    box-shadow: var(--el-pop);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
    animation: dialog-in 0.22s cubic-bezier(.2,.7,.3,1);
}
@keyframes dialog-in {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
.dialog.confirm,
.modal.modal-confirm { max-width: 420px; }
.modal-lg { max-width: 580px; }

/* Dialog header */
.dialog-head { padding: 22px 24px 0; }
.dialog-head .ic {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 15px;
}
.dialog-head .ic svg { width: 22px; height: 22px; }
.dialog-head .ic.warn { background: var(--urgent-bg); color: var(--danger); }
.dialog-head .ic.pine { background: var(--pine-tint); color: var(--pine); }
.dialog-head .ic.amber{ background: var(--amber-tint); color: var(--amber-deep); }
.dialog-head h3,
.modal-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.01em;
    color: var(--app-ink);
    margin: 0;
}
.dialog-head p,
.modal-message {
    font-size: 14px;
    color: var(--app-ink-2);
    margin-top: 9px;
    line-height: 1.55;
}

/* Dialog body / form area */
.dialog-body  { padding: 20px 24px; }
.dialog-body .field + .field { margin-top: 12px; }

/* Payment method picker (visual buttons) */
.meth {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.meth .m {
    font-size: 13px;
    font-weight: 600;
    color: var(--app-ink-2);
    background: var(--app-surface);
    border: 1.5px solid var(--app-line-2);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: center;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.meth .m:hover { border-color: var(--app-ink-3); }
.meth .m.on {
    border-color: var(--pine);
    background: var(--app-active);
    color: var(--pine);
}

/* Balance display in partial dialog */
.bal {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--app-surface-2);
    border: 1px solid var(--app-line);
    border-radius: 9px;
    padding: 11px 14px;
    margin-top: 12px;
}
.bal .k { font-size: 12.5px; color: var(--app-ink-2); }
.bal .v {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--money);
    font-variant-numeric: tabular-nums;
}

/* Dialog footer (action buttons) */
.dialog-foot,
.modal-actions {
    display: flex;
    gap: 11px;
    justify-content: flex-end;
    padding: 16px 24px 22px;
}
.modal-actions { padding: 0; margin-top: var(--s4); }
.dialog-foot.between,
.modal-actions.between { justify-content: space-between; }

/* =====================================================
   PRODUCT PICKER MODAL ROWS
   ===================================================== */

.picker-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 360px;
    overflow-y: auto;
    margin: var(--s3) 0;
}
.picker-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--s3);
    align-items: center;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: var(--r-ctrl);
    padding: var(--s3);
    text-align: left;
    cursor: pointer;
}
.picker-row:hover {
    border-color: var(--pine);
    background: var(--card);
}
.picker-row-title { font-weight: 600; color: var(--app-ink); }
.picker-row-sub   { font-size: 12px; color: var(--app-ink-2); }
.picker-row-meta  { font-size: 13.5px; text-align: right; font-family: var(--font-mono); color: var(--app-ink); font-variant-numeric: tabular-nums; }
.picker-empty     { padding: var(--s3); }

/* =====================================================
   PDF PREVIEW / PRINT OVERLAY
   ===================================================== */

/* PDF overlay — Direction C: deep pine with blur scrim + icon close */
.doc-viewer-overlay,
.ovl {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: rgba(13, 22, 17, 0.94);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9500;
    animation: ovl-fade 0.22s ease;
}
@keyframes ovl-fade { from { opacity: 0; } to { opacity: 1; } }

.doc-viewer-topbar,
.ovl-bar {
    height: 60px;
    flex: none;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    background: rgba(21, 38, 32, 0.7);
    border-bottom: 1px solid var(--pine-line);
}

.ovl-title {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    flex: 1;
}
.ovl-title .ic {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: rgba(192, 134, 58, 0.16);
    color: var(--amber);
    display: flex; align-items: center; justify-content: center;
    flex: none;
}
.ovl-title .ic svg { width: 18px; height: 18px; }
.ovl-title .tt { min-width: 0; }
.ovl-title .tt .l {
    font-size: 11px;
    color: var(--muted-on-pine);
    font-weight: 600;
    letter-spacing: 0.04em;
}
.ovl-title .tt .n,
.doc-viewer-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--cream);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}

.doc-viewer-actions,
.ovl-acts {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
}

/* Overlay primary action = amber, ghost = bordered pine-line */
.doc-viewer-actions .btn-primary,
.doc-viewer-actions .btn-pine,
.doc-viewer-actions .btn-amber,
.ovl-acts .btn-amber {
    background: var(--amber);
    color: var(--pine-deep);
    border-color: var(--amber);
}
.doc-viewer-actions .btn-primary:hover,
.doc-viewer-actions .btn-amber:hover { background: var(--amber-bright); border-color: var(--amber-bright); }
.doc-viewer-actions .btn-ghost,
.ovl-acts .btn-ghost {
    background: transparent;
    color: var(--cream);
    border: 1.5px solid var(--pine-line);
}
.doc-viewer-actions .btn-ghost:hover,
.ovl-acts .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--cream);
    border-color: var(--muted-on-pine);
}

/* Icon close button */
.doc-viewer-close,
.ovl-close {
    width: 40px; height: 40px;
    border-radius: 10px;
    border: 1px solid var(--pine-line);
    background: transparent;
    color: var(--cream);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.14s;
}
.doc-viewer-close:hover,
.ovl-close:hover { background: rgba(255, 255, 255, 0.08); }
.doc-viewer-close svg,
.ovl-close svg { width: 20px; height: 20px; }

.doc-viewer-iframe,
.ovl-body {
    flex: 1;
    width: 100%;
    border: 0;
    background: var(--cream-2);
    display: block;
}

@media (max-width: 700px) {
    .doc-viewer-topbar,
    .ovl-bar { padding: 0 14px; gap: 10px; }
    .ovl-title .tt .n,
    .doc-viewer-name { max-width: 140px; font-size: 14px; }
    .doc-viewer-actions .btn-label,
    .ovl-acts .btn-label { display: none; }
    .doc-viewer-actions .btn,
    .ovl-acts .btn { padding: 7px 10px; }
}

/* =====================================================
   TEMPLATE GALLERY
   ===================================================== */

.gallery-overlay {
    position: fixed;
    inset: 0;
    background: rgba(21,38,32,0.55);
    backdrop-filter: blur(2px);
    z-index: 9700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s4);
}
.gallery-modal {
    background: var(--app-bg);
    border-radius: var(--r-modal);
    width: 100%;
    max-width: 1180px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--sh-lg);
    overflow: hidden;
}
.gallery-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--s3);
    padding: var(--s5);
    border-bottom: 1px solid var(--app-line);
    background: var(--app-surface);
}
.gallery-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--app-ink);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.gallery-sub { font-size: 13.5px; color: var(--app-ink-2); }
.gallery-topbar .doc-viewer-close {
    background: transparent;
    color: var(--app-ink-2);
    border-color: var(--app-line-2);
}
.gallery-topbar .doc-viewer-close:hover {
    background: var(--app-surface-2);
    color: var(--app-ink);
}

.gallery-hint {
    padding: var(--s3) var(--s5);
    background: var(--amber-tint);
    color: var(--amber-deep);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid var(--amber-soft);
    text-align: center;
}

.gallery-palette-row {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--app-line);
    background: var(--app-surface);
    flex-wrap: wrap;
}
.gallery-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--app-ink-3);
    font-weight: 700;
    margin-right: var(--s3);
}
.gallery-swatch { width: 30px; height: 30px; }
.gallery-palette-hint {
    margin-left: auto;
    font-size: 11.5px;
    font-style: italic;
    color: var(--app-ink-3);
}

/* Toolbar: family filter pills + facture/soumission toggle. */
.gallery-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s4);
    padding: var(--s3) var(--s5);
    border-bottom: 1px solid var(--app-line);
    background: var(--app-surface);
    flex-wrap: wrap;
}
.gallery-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.gallery-filter-pill {
    appearance: none;
    border: 1px solid var(--app-line-2);
    background: var(--app-surface);
    color: var(--app-ink-2);
    border-radius: 999px;
    padding: 5px 12px;
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.gallery-filter-pill:hover {
    background: var(--app-surface-2);
    color: var(--app-ink);
}
.gallery-filter-pill.active {
    background: var(--pine);
    color: var(--cream);
    border-color: var(--pine);
}
.gallery-doctype {
    display: flex;
    align-items: center;
    gap: 4px;
}
.gallery-toggle-btn {
    appearance: none;
    border: 1px solid var(--app-line-2);
    background: var(--app-surface);
    color: var(--app-ink-2);
    padding: 5px 12px;
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.gallery-toggle-btn:first-of-type { border-radius: 6px 0 0 6px; }
.gallery-toggle-btn:last-of-type  { border-radius: 0 6px 6px 0; margin-left: -1px; }
.gallery-toggle-btn:hover {
    background: var(--app-surface-2);
    color: var(--app-ink);
}
.gallery-toggle-btn.active {
    background: var(--app-ink);
    color: var(--paper);
    border-color: var(--app-ink);
    z-index: 1;
    position: relative;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--s8) var(--s5);
    font-size: 13.5px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    align-items: start;
    gap: 22px;
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    background: var(--app-bg);
}

.tpl-card {
    border: 2px solid var(--app-line);
    border-radius: var(--r-card);
    overflow: hidden;
    background: var(--app-surface);
    cursor: pointer;
    transition: border-color 0.16s, box-shadow 0.16s, transform 0.16s;
    display: flex;
    flex-direction: column;
}
.tpl-card:hover {
    border-color: var(--line-2);
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
}
.tpl-card.selected {
    border-color: var(--pine);
    box-shadow: 0 0 0 3px var(--pine-tint), var(--sh-md);
}

/* Preview frame: tight crop to typical template content height.
   iframe layout box 800x1040 → at scale 0.36, visual 288x374.
   Preview at 300px tall crops the bottom whitespace of the iframe
   so cards don't have huge empty cream space below the template. */
.tpl-preview {
    background: var(--cream-2);
    height: 300px;
    flex: 0 0 auto;
    overflow: hidden;
    position: relative;
    pointer-events: none;
    padding: 12px 0 0 12px;
}
.tpl-preview::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 24px;
    background: linear-gradient(180deg, rgba(233,227,210,0) 0%, var(--cream-2) 100%);
    pointer-events: none;
    z-index: 1;
}
.tpl-preview-iframe {
    width: 800px;
    height: 1040px;
    border: 0;
    transform: scale(0.36);
    transform-origin: top left;
    background: var(--paper);
    pointer-events: none;
    box-shadow: 0 8px 22px -10px rgba(0,0,0,.35);
    border-radius: 4px;
}
.tpl-family-tag {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    font-family: var(--font-ui);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.92);
    color: var(--app-ink-2);
    border: 1px solid var(--app-line-2);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.tpl-family-tag[data-family="signature"] { background: var(--pine); color: var(--amber); border-color: var(--pine); }
.tpl-family-tag[data-family="modern"]    { background: #1f2937; color: #fff; border-color: #1f2937; }
.tpl-family-tag[data-family="premium"]   { background: #5b3a2c; color: #f7efe2; border-color: #5b3a2c; }
.tpl-family-tag[data-family="trade"]     { background: #b45309; color: #fff; border-color: #b45309; }
.tpl-family-tag[data-family="classic"]   { background: #f4f1ea; color: #3a3328; border-color: #d8d1bf; }
.tpl-family-tag[data-family="compact"]   { background: #161616; color: #fff; border-color: #161616; }
.tpl-meta {
    padding: var(--s3) var(--s4) var(--s4);
    border-top: 1px solid var(--app-line);
    background: var(--app-surface);
}
.tpl-name {
    display: flex;
    align-items: center;
    gap: var(--s2);
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--app-ink);
    font-size: 15.5px;
    letter-spacing: -0.01em;
}
.tpl-tagline { font-size: 12.5px; margin-top: 3px; color: var(--app-ink-2); }
.tpl-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.tpl-badge-pro { background: var(--amber-soft); color: var(--amber-deep); }
.tpl-badge-free{ background: var(--st-sent-bg); color: var(--st-sent); }

.gallery-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s3);
    padding: var(--s4) var(--s5);
    border-top: 1px solid var(--app-line);
    background: var(--app-surface);
    flex-wrap: wrap;
}
.gallery-selection { font-size: 13.5px; color: var(--app-ink-2); }
.gallery-selection strong { color: var(--app-ink); font-weight: 600; }
.gallery-actions { display: flex; gap: var(--s2); }

/* =====================================================
   BRANDING / LOGO UPLOAD (Settings)
   ===================================================== */

.logo-field { }
.logo-field .logo-file-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
    width: 0;
    height: 0;
}
.logo-preview {
    background:
        linear-gradient(45deg, var(--cream) 25%, transparent 25%) 0 0 / 14px 14px,
        linear-gradient(-45deg, var(--cream) 25%, transparent 25%) 0 7px / 14px 14px,
        linear-gradient(45deg, transparent 75%, var(--cream) 75%) 7px -7px / 14px 14px,
        linear-gradient(-45deg, transparent 75%, var(--cream) 75%) -7px 0 / 14px 14px,
        var(--paper);
    border: 1px dashed var(--line-2);
    border-radius: var(--r-ctrl);
    padding: var(--s4);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--s3);
}
.logo-preview-img {
    max-width: 280px;
    max-height: 100px;
    object-fit: contain;
    display: block;
    background: transparent;
    padding: 0;
}
.logo-preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--app-ink-3);
}
.logo-preview-empty-label {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--app-ink-2);
    letter-spacing: -0.01em;
}
.logo-actions {
    display: flex;
    gap: var(--s2);
    flex-wrap: wrap;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 880px) {
    .ac-grid       { grid-template-columns: repeat(2, 1fr); }
    .quickstart-grid { grid-template-columns: 1fr; }
    .list-row      { grid-template-columns: 1fr; gap: var(--s2); }
    .list-row-meta { text-align: left; }
    .list-row-actions { justify-content: flex-start; }

    .doc-row {
        grid-template-columns: 100px 1fr auto;
    }
    .doc-row-status {
        grid-column: 1 / -1;
        flex-direction: row;
        gap: var(--s2);
        align-items: center;
    }
    .doc-row-total { grid-row: 1; grid-column: 3; }

    .line-table-head { display: none; }
    .line-row {
        grid-template-columns: 1fr;
        gap: var(--s1);
    }
    .line-row .lt-col { width: 100%; justify-content: stretch; }
    .line-row .lt-col-tax { justify-content: flex-start; }
    .line-row .lt-col-total {
        justify-content: flex-end;
        padding-top: var(--s1);
        border-top: 1px solid var(--app-line);
    }
    .line-row .lt-col-act { justify-content: flex-end; }
    .totals-block { justify-content: stretch; }
    .totals-card  { min-width: 100%; }

    .doc-header { flex-direction: column; align-items: stretch; gap: var(--s2); }
    .doc-link-banner { display: block; text-align: center; }
}

@media (max-width: 920px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 282px;
        height: 100vh;
        z-index: 80;
        transform: translateX(-100%);
        transition: transform 0.26s cubic-bezier(.3,.8,.3,1);
        box-shadow: var(--el-pop);
    }
    .mobile-menu-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(21,38,32,.42);
        backdrop-filter: blur(1px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.26s;
        z-index: 70;
    }
    .mobile-menu-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    .menu-toggle { display: inline-flex; }

    :root { --page-pad: 18px; }

    .form-row { grid-template-columns: 1fr !important; }
    .list-head { flex-direction: column; align-items: flex-start; }
    .page-content { padding: 22px 18px 96px; }
    .topbar { padding: 0 18px; }

    .gallery-overlay { padding: 0; }
    .gallery-modal { border-radius: 0; max-height: 100vh; height: 100vh; max-width: 100vw; }
    .gallery-topbar { padding: var(--s4); }
    .gallery-grid {
        grid-template-columns: 1fr 1fr;
        padding: var(--s4);
        gap: var(--s3);
    }
    .tpl-preview { height: 280px; }
    .tpl-preview-iframe { transform: scale(0.28); }
    .gallery-toolbar { flex-direction: column; align-items: flex-start; gap: var(--s2); }
    .gallery-footer { flex-direction: column; align-items: stretch; }
    .gallery-actions { justify-content: stretch; }
    .gallery-actions .btn { flex: 1; }
}

@media (max-width: 600px) {
    .doc-viewer-topbar {
        height: auto;
        padding: var(--s3);
        flex-wrap: wrap;
    }
    .doc-viewer-name { width: 100%; flex-basis: 100%; font-size: 14px; padding-bottom: var(--s1); }
    .doc-viewer-actions { width: 100%; }
    .doc-viewer-actions .btn { flex: 1; }
    .doc-viewer-close { padding: 7px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
    .gallery-grid { grid-template-columns: 1fr; }
    .tpl-preview { height: 360px; }
    .tpl-preview-iframe { transform: scale(0.42); }
    .ac-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 24px; }
    .setup-banner { padding: var(--s5); }
}
