/* styles.css — Premium UI */

/* ===== Design tokens ===== */
:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #fbfcff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e5e7eb;

    --primary: #4f46e5;
    --primary-2: #7c3aed;
    --primary-soft: rgba(79, 70, 229, 0.12);

    --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.10);

    --radius: 16px;
    --radius-sm: 12px;
}

/* ===== Global reset ===== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* supprime le flash gris au tap sur iOS */
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
    background: radial-gradient(1000px 500px at 10% -10%, rgba(79, 70, 229, .12), transparent 60%),
    radial-gradient(1000px 600px at 90% -10%, rgba(124, 58, 237, .10), transparent 55%),
    var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Topbar / Nav ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(226, 232, 240, .9);
    box-shadow: 0 10px 30px rgba(15, 23, 42, .05);
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 18px 10px;
}

/* Ligne brand + hamburger */
.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand, .brand * {
    cursor: pointer;
    user-select: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

/* ===== Bouton hamburger (masqué sur desktop) ===== */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: none;
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .06);
    transition: background .15s ease, border-color .15s ease;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    transition: transform .25s ease, opacity .2s ease;
    transform-origin: center;
}

/* Croix quand ouvert */
.hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; }
.hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 950;
    letter-spacing: .5px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    box-shadow: 0 14px 30px rgba(79, 70, 229, .22);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.brand-title {
    font-size: 16px;
    font-weight: 950;
    color: var(--text);
    letter-spacing: -.01em;
}

.brand-sub {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
}

.topnav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.topnav .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(226, 232, 240, .9);
    background: rgba(255, 255, 255, .7);
    color: var(--muted);
    font-weight: 900;
    font-size: 13px;
    line-height: 1;
    text-decoration: none;
    min-height: 44px; /* touch target Apple HIG */
    touch-action: manipulation;
    box-shadow: 0 10px 22px rgba(15, 23, 42, .06);
    transition: transform .08s ease, box-shadow .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}

.topnav .nav-link:hover {
    color: var(--text);
    background: rgba(79, 70, 229, .10);
    border-color: rgba(79, 70, 229, .25);
    box-shadow: 0 14px 30px rgba(15, 23, 42, .10);
    text-decoration: none;
}

.topnav .nav-link:active {
    transform: translateY(1px);
}

.topnav .nav-link.is-active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    box-shadow: 0 14px 30px rgba(79, 70, 229, .22);
}

.topnav .nav-link.is-active:hover {
    filter: brightness(1.03);
}

/* ===== Main container ===== */
main {
    max-width: 1100px;
    margin: 18px auto 36px;
    padding: 22px 18px;
}

.page-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 24px;
}

/* ===== Typography ===== */
h2 {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 900;
    color: var(--text);
    letter-spacing: -.01em;
}

h3 {
    margin: 18px 0 10px;
    font-size: 16px;
    font-weight: 900;
    color: var(--text);
}

p {
    color: var(--muted);
    line-height: 1.5;
}

/* ===== Forms ===== */
form {
    display: block;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-weight: 700;
    outline: none;
    transition: box-shadow .15s ease, border-color .15s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="date"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

form p {
    margin: 0 0 12px;
}

form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 900;
    font-size: 12px;
    color: #64748b;
}

form input, form select, form textarea {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 800;
    color: #0f172a;
    outline: none;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

form textarea {
    resize: vertical;
    min-height: 90px;
}

.helptext {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 700;
    display: block;
    margin-top: 6px;
}

.errorlist {
    margin: 8px 0 0;
    padding-left: 18px;
    color: #b91c1c;
    font-weight: 800;
}

.errorlist li {
    margin: 4px 0;
}

.form-compact p {
    margin-bottom: 10px;
}

/* ===== Buttons ===== */
button {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: #fff;
    padding: 12px 18px;
    border-radius: 14px;
    font-weight: 900;
    font-size: 14px;
    letter-spacing: .2px;
    cursor: pointer;
    min-height: 44px; /* touch target Apple HIG */
    touch-action: manipulation; /* supprime le délai 300ms iOS */
    box-shadow: 0 14px 30px rgba(79, 70, 229, 0.22);
    transition: transform .08s ease, box-shadow .18s ease, filter .18s ease;
}

button:hover {
    filter: brightness(1.03);
    box-shadow: 0 18px 38px rgba(79, 70, 229, 0.28);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 10px 22px rgba(79, 70, 229, 0.18);
}

button:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25), 0 18px 38px rgba(79, 70, 229, 0.28);
}

/* .btn = lien/bouton action (blanc/bordure) */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #0f172a;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 13px;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    cursor: pointer;
    min-height: 44px; /* touch target Apple HIG */
    touch-action: manipulation; /* supprime le délai 300ms iOS */
}

.btn:hover {
    filter: brightness(1.03);
    box-shadow: 0 18px 38px rgba(79, 70, 229, 0.28);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 10px 22px rgba(79, 70, 229, 0.18);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25), 0 18px 38px rgba(79, 70, 229, 0.28);
}

/* Variantes .btn */
.btn.primary {
    border-color: #6366f1;
    background: #eef2ff;
    color: #3730a3;
}

.btn.primary:hover {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(79, 70, 229, .25);
    filter: none;
}

.btn.primary:active {
    transform: translateY(0);
    box-shadow: 0 10px 24px rgba(79, 70, 229, .20);
}

.btn.danger {
    border-color: #fee2e2;
    background: #fef2f2;
    color: #991b1b;
}

.btn.edit {
    border-color: #dbeafe;
    background: #eff6ff;
    color: #1d4ed8;
}

.btn.ghost {
    background: #fff;
}

/* .btn-primary = bouton CTA violet plein */
.btn-primary,
a.btn.btn-primary,
button.btn.btn-primary {
    background: #5b4bff !important;
    border-color: #5b4bff !important;
    color: #fff !important;
    text-decoration: none !important;
}

a.btn.btn-primary:hover,
button.btn.btn-primary:hover {
    background: #4f46e5 !important;
    border-color: #4f46e5 !important;
    color: #fff !important;
    text-decoration: none !important;
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(79, 70, 229, .25);
}

/* .btn-secondary = bouton neutre */
.btn-secondary {
    background: #fff;
    border-color: #e5e7eb;
    color: #0f172a;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: rgba(15, 23, 42, 0.04);
    filter: none;
}

a.btn,
a.btn:hover {
    text-decoration: none;
}

a.btn-open,
a.btn-open:link,
a.btn-open:visited,
a.btn-open:hover,
a.btn-open:active,
a.btn-open:focus {
    color: #0b0505 !important;
    text-decoration: none !important;
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
    margin: 18px 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    white-space: nowrap;
}

th {
    background: linear-gradient(180deg, #fbfcff 0%, #f6f7fb 100%);
    color: #334155;
    font-weight: 900;
    font-size: 12px;
    letter-spacing: .2px;
    border-bottom: 1px solid var(--border);
}

td {
    color: var(--text);
    font-weight: 700;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}

tr:last-child td {
    border-bottom: 0;
}

tr:hover td {
    background: rgba(79, 70, 229, 0.05);
}

/* ===== Cards ===== */
.card {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.card-h {
    padding: 14px 16px;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-h h2,
.card-h h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 900;
    color: #0f172a;
}

.card-b {
    padding: 14px 16px;
}

.card-b p {
    margin: 0 0 14px;
}

.card-b label {
    display: block;
    font-weight: 900;
    color: #0f172a;
    margin-bottom: 7px;
    font-size: 13px;
}

.card-b input,
.card-b select,
.card-b textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    background: #fff;
    outline: none;
    font-weight: 800;
    color: #0f172a;
}

.card-b input:focus,
.card-b select:focus,
.card-b textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.card-b input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.card-b input[type="number"]::-webkit-outer-spin-button,
.card-b input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ===== Small UI helpers ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 900;
    font-size: 12px;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    background: #f1f5f9;
    color: #334155;
    white-space: nowrap;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.pill.gen {
    background: #f8fafc;
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.08);
}

.pill.vl,
.pill.eco {
    background: #ecfdf5;
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.15);
}

.pill.pl,
.pill.ecoplus {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: rgba(59, 130, 246, 0.18);
}

.pill.h,
.pill.trad {
    background: #fff7ed;
    color: #9a3412;
    border-color: rgba(234, 88, 12, 0.18);
}

.pill.m3,
.pill.pres {
    background: #f5f3ff;
    color: #5b21b6;
    border-color: rgba(124, 58, 237, 0.18);
}

.pill.ok {
    background: #ecfdf5;
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.15);
}

.pill.no {
    background: #fef2f2;
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.18);
}

.pill.sel {
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

hr {
    border: 0;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    margin: 18px 0;
}

/* ===== Page layout helpers ===== */
.page {
    max-width: 900px;
    margin: 0 auto;
    padding: 10px 8px 90px;
}

.form-narrow {
    max-width: 520px;
    margin: 0 auto;
}

.form-narrow form {
    display: grid;
}

.form-narrow input,
.form-narrow select,
.form-narrow textarea {
    width: 100%;
}

.form-narrow button,
.form-narrow .btn {
    width: fit-content;
}

.header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.title-wrap h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.title-wrap h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.subtitle {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.actions form {
    margin: 0;
}

.section {
    margin-top: 16px;
}

.hint {
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
}

.muted {
    color: #94a3b8;
}

/* ===== Rows (label / value) ===== */
.rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border-bottom: 1px dashed #eef2f7;
    align-items: baseline;
}

.row:last-child {
    border-bottom: none;
}

.row > * {
    min-width: 0;
}

.label {
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
}

.row .label {
    flex: 0 0 180px;
    font-weight: 900;
    color: #64748b;
}

.value {
    color: #0f172a;
    font-weight: 900;
    text-align: right;
}

.value a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 900;
}

.value a:hover {
    text-decoration: underline;
}

.row .value {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: right;
}

.row .value a {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rows.wrap .row {
    align-items: flex-start;
}

.rows.wrap .label {
    font-size: 12.5px;
}

.rows.wrap .value {
    font-size: 12.5px;
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 62%;
    text-align: right;
}

/* ===== Grids ===== */
.grid-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}

.grid-2 > .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.grid-2 > .card .card-b {
    flex: 1 1 auto;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

/* ===== KPI blocks ===== */
.kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.kpi {
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 14px;
    padding: 12px;
}

.kpi .k {
    display: block;
    font-size: 12px;
    color: #64748b;
    font-weight: 800;
    margin-bottom: 4px;
}

.kpi .v {
    font-weight: 900;
    color: #0f172a;
    font-size: 16px;
}

/* ===== Pricing cards ===== */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.pricing-card {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.pricing-card.selected {
    border-color: #6366f1;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.18);
}

.pricing-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.pricing-title {
    margin: 0;
    font-size: 16px;
    font-weight: 900;
    color: #0f172a;
}

.pricing-amount {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 6px 0 4px;
}

.pricing-amount .value {
    font-size: 28px;
    font-weight: 1000;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.pricing-amount .unit {
    font-size: 13px;
    color: #64748b;
    font-weight: 900;
}

.pricing-sub {
    margin: 0 0 10px;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}

/* ===== Company card ===== */
.company-card {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    margin-top: 14px;
}

.company-card-h {
    padding: 14px 16px;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.company-card-h h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.company-card-b {
    padding: 14px 16px;
}

.company-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    align-items: start;
}

.logo-box {
    border: 1px solid #eef2f7;
    background: #f8fafc;
    border-radius: 14px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 92px;
}

.logo-box img {
    max-width: 150px;
    max-height: 80px;
    width: auto;
    height: auto;
    display: block;
}

.logo-placeholder {
    color: #94a3b8;
    font-weight: 900;
    font-size: 12px;
}

/* ===== Sélecteur de période ===== */
.periode-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.periode-btn {
    padding: 7px 18px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
    box-shadow: var(--shadow-sm);
}

.periode-btn:hover {
    color: var(--primary);
    border-color: rgba(79, 70, 229, 0.3);
    background: rgba(79, 70, 229, 0.05);
}

.periode-btn.is-active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.25);
}

/* ===== Stats dashboard ===== */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 0;
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.stat-card--wide {
    grid-column: span 2;
}

.stat-card--full {
    grid-column: 1 / -1;
}

.stat-card-h {
    padding: 14px 16px;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stat-card-h h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
}

.stat-card-b {
    padding: 16px;
}

.chart-container-pie {
    height: 240px;
    position: relative;
}

.chart-container-bar {
    height: 200px;
    position: relative;
}

/* Carte montant centré */
.stat-card--center .stat-card-b {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    gap: 10px;
}

/* Fond dégradé subtil sur la carte montant */
.stat-card--amount {
    background: linear-gradient(145deg, #ffffff 0%, #f5f3ff 100%);
    border-color: rgba(79, 70, 229, 0.2);
}

.stat-card--amount .stat-card-h {
    border-bottom-color: rgba(79, 70, 229, 0.12);
}

/* Icône ronde */
.amount-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 22px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.amount-value {
    font-size: 40px;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: -0.04em;
    line-height: 1;
}

.amount-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: center;
}

/* Badge */
.stat-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    letter-spacing: 0.03em;
}

.stat-badge--blue {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

/* Carte montant de la période */
.stat-card--month {
    background: linear-gradient(145deg, #ffffff 0%, #eff6ff 100%);
    border-color: rgba(59, 130, 246, 0.2);
}

.stat-card--month .stat-card-h {
    border-bottom-color: rgba(59, 130, 246, 0.12);
}

.amount-icon--blue {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    font-size: 20px;
}

.amount-value--blue {
    color: #2563eb;
}

/* Carte montant facturé */
.stat-card--facture {
    background: linear-gradient(145deg, #ffffff 0%, #f5f3ff 100%);
    border-color: rgba(79, 70, 229, 0.2);
}

.stat-card--facture .stat-card-h {
    border-bottom-color: rgba(79, 70, 229, 0.12);
}

.amount-icon--facture {
    background: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
    font-size: 22px;
    font-weight: 900;
}

.amount-value--facture {
    color: #4338ca;
}

.stat-badge--facture {
    background: rgba(79, 70, 229, 0.1);
    color: #4338ca;
}

/* Carte nb devis */
.stat-card--count {
    background: linear-gradient(145deg, #ffffff 0%, #f0fdf4 100%);
    border-color: rgba(16, 185, 129, 0.2);
}

.stat-card--count .stat-card-h {
    border-bottom-color: rgba(16, 185, 129, 0.12);
}

.amount-icon--green {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    font-size: 22px;
    font-weight: 900;
}

.amount-value--green {
    color: #059669;
}

.stat-badge--green {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.stat-badge--muted {
    background: rgba(100, 116, 139, 0.1);
    color: var(--muted);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    gap: 12px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

.pagination-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.page-btn:hover {
    color: var(--primary);
    border-color: rgba(79, 70, 229, 0.3);
    background: rgba(79, 70, 229, 0.05);
}

.page-btn.is-active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

.page-btn.is-disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
}

/* ===== Sticky save bar ===== */
.savebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    padding: 10px 12px;
    /* respecte le Home Indicator / Dynamic Island sur iPhone */
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 50;
}

.savebar-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 8px;
}

.savebar-inner-create {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 8px;
}

/* ===== Toggle pills (radio) ===== */
.toggle-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.toggle-pill {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-pill span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #0f172a;
    font-weight: 900;
    font-size: 13px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
    transition: .15s ease;
}

.toggle-pill:hover span {
    border-color: #c7d2fe;
    background: #eef2ff;
}

.toggle-pill input:checked + span {
    border-color: #6366f1;
    background: #eef2ff;
    color: #3730a3;
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.18);
}

/* ===== Devis table — style compact desktop ===== */
/* Réduit le padding pour que les 9 colonnes tiennent dans 1100px */
.devis-table th,
.devis-table td {
    padding: 10px 10px;
    font-size: 13px;
}

.devis-table td {
    white-space: normal; /* autorise le retour ligne */
}

/* ===== Filter form (devis list) ===== */
.filter-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.filter-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 140px 140px 1fr;
    gap: 10px;
    align-items: end;
}

.filter-field label {
    display: block;
    font-weight: 900;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===== Footer actions ===== */
.footer-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    main {
        padding: 18px 14px;
    }

    nav {
        padding: 0 10px;
    }

    nav a {
        margin: 6px 4px;
    }
}

@media (max-width: 900px) {
    .grid-2,
    .grid-3,
    .grid,
    .pricing-grid,
    .kpis {
        grid-template-columns: 1fr;
    }

    .row {
        flex-direction: column;
        align-items: flex-start;
    }

    .row .label {
        flex: 0 0 auto;
    }

    .row .value {
        width: 100%;
        text-align: left;
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* ===== Mobile (iPhone & co) ===== */
@media (max-width: 768px) {

    /* — Topbar — */
    .topbar-inner {
        padding: 10px 16px 10px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .brand {
        margin-bottom: 0;
    }

    /* Affiche le hamburger sur mobile */
    .hamburger {
        display: flex;
    }

    /* Menu déroulant mobile */
    .topnav {
        display: flex;
        flex-direction: column;
        gap: 6px;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        padding: 0;
        transition: max-height .3s ease, opacity .25s ease, padding .3s ease;
    }

    .topnav.is-open {
        max-height: 400px;
        opacity: 1;
        padding-top: 10px;
        padding-bottom: 6px;
    }

    .topnav .nav-link {
        width: 100%;
        justify-content: flex-start;
        border-radius: 12px;
        padding: 13px 16px;
        font-size: 14px;
        white-space: normal;
    }

    /* Nav pillbar */
    .nav-pillbar {
        flex-wrap: wrap !important;
        overflow-x: hidden !important;
        justify-content: flex-start;
        border-radius: 18px;
        gap: 8px;
    }

    .nav-pillbar .nav-link {
        padding: 9px 12px;
        font-size: 13px;
    }

    /* — Titres — */
    .title-wrap h1 {
        font-size: 20px;
    }

    .title-wrap h2 {
        font-size: 18px;
    }

    h2 {
        font-size: 17px;
    }

    /* — Header / actions — */
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    .actions .btn,
    .actions button {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 0;
    }

    /* — Container — */
    main {
        padding: 14px 16px;
        /* safe area latérale (paysage iPhone) */
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    /* — Cards — */
    .card-h {
        padding: 12px 14px;
    }

    .card-b {
        padding: 12px 14px;
    }

    /* — Rows — */
    .rows {
        gap: 6px;
    }

    .row {
        flex-direction: column;
        align-items: flex-start;
        padding: 6px 0;
        gap: 2px;
        border-bottom: 1px solid #eef2f7;
    }

    .label {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: #94a3b8;
    }

    .value {
        font-size: 14px;
        text-align: left;
        width: 100%;
    }

    /* — Inputs : CRITIQUE — font-size 16px minimum sinon Safari zoome — */
    input, select, textarea,
    form input, form select, form textarea,
    .card-b input, .card-b select, .card-b textarea {
        font-size: 16px !important;
    }

    /* — KPI — */
    .kpis {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .kpi {
        padding: 10px 12px;
        border-radius: 12px;
    }

    .kpi .k {
        font-size: 11px;
        margin-bottom: 3px;
    }

    .kpi .v {
        font-size: 18px;
    }

    /* — Pricing — */
    .pricing-amount .value {
        font-size: 22px;
    }

    /* — Table — */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }

    /* — Tarification globale : grille 5 cases → 2 rangées — */
    .table-pricing {
        overflow: visible;
        border: none;
        background: transparent;
        box-shadow: none;
        margin: 18px 0;
    }

    .table-pricing table {
        display: block;
        background: transparent;
    }

    .table-pricing thead {
        display: none;
    }

    .table-pricing tbody {
        display: block;
    }

    .table-pricing tbody tr {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
        border-bottom: none;
    }

    .table-pricing tbody tr:hover td {
        background: var(--surface);
    }

    .table-pricing td {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        white-space: normal;
        border: 1px solid rgba(79, 70, 229, 0.12);
        border-radius: var(--radius-sm);
        padding: 12px 6px 10px;
        background: linear-gradient(160deg, #ffffff 0%, #f8f7ff 100%);
        box-shadow: 0 4px 14px rgba(79, 70, 229, 0.07);
        gap: 6px;
        transition: box-shadow .18s ease, transform .12s ease;
    }

    .table-pricing td:active {
        transform: scale(0.97);
    }

    .table-pricing td::before {
        content: attr(data-label);
        font-size: 8.5px;
        font-weight: 800;
        color: var(--primary);
        text-transform: uppercase;
        letter-spacing: 0.07em;
        line-height: 1.3;
        word-break: break-word;
        opacity: 0.75;
    }

    .table-pricing td:last-child::before {
        font-size: 7.5px;
    }

    table {
        width: 100%;
        min-width: 0 !important;
    }

    th {
        white-space: normal;
        font-size: 11px;
    }

    th, td {
        padding: 10px 12px;
    }

    /* — Page (avec savebar) — */
    .page {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }

    /* — Savebar — */
    .savebar-inner,
    .savebar-inner-create {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .savebar-inner .btn,
    .savebar-inner button,
    .savebar-inner-create .btn,
    .savebar-inner-create button {
        width: 100%;
        justify-content: center;
    }

    /* — Toggle pills — */
    .toggle-row {
        gap: 8px;
    }

    .toggle-pill span {
        padding: 9px 12px;
        font-size: 13px;
    }

    /* — Footer actions — */
    .footer-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .footer-actions .btn,
    .footer-actions button {
        width: 100%;
        justify-content: center;
    }

    /* — Devis list : masquer Volume, Adresses, Date sur mobile — */
    .devis-table .col-hide-mobile {
        display: none;
    }

    /* — Header tags natifs — */
    header {
        padding: 8px 0;
    }

    header h1 {
        font-size: 16px;
    }

    nav {
        padding: 0 10px;
    }
}

@media (max-width: 700px) {
    .company-grid {
        grid-template-columns: 1fr;
    }

    .company-card-h {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .periode-selector {
        flex-wrap: wrap;
    }

    .stats-dashboard {
        grid-template-columns: 1fr 1fr;
    }

    .stat-card--wide,
    .stat-card--full {
        grid-column: 1 / -1;
    }

    .amount-value {
        font-size: 26px;
    }

    .chart-container-pie {
        height: 200px;
    }
}

/* ===== Devis table → cartes sur iPad et mobile (≤1024px) ===== */
@media (max-width: 1024px) {
    /* wrapper : retire le style "table-container" */
    .devis-table-wrap {
        border: none;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
        margin: 0;
    }

    /* table → block */
    .devis-table,
    .devis-table tbody {
        display: block;
    }

    /* masque les en-têtes */
    .devis-table thead {
        display: none;
    }

    /* chaque ligne → carte */
    .devis-table tbody tr {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
        overflow: hidden;
        margin-bottom: 10px;
    }

    .devis-table tbody tr:hover {
        box-shadow: 0 6px 20px rgba(79, 70, 229, 0.10);
    }

    /* chaque cellule → ligne label / valeur */
    .devis-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 9px 14px;
        border-bottom: 1px solid #f1f5f9;
        white-space: normal;
        font-size: 14px;
        font-weight: 700;
        color: #0f172a;
        min-height: 0;
    }

    .devis-table td:last-child {
        border-bottom: none;
    }

    /* label généré via data-label */
    .devis-table td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 800;
        color: #94a3b8;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex: 0 0 auto;
        text-align: left;
        margin-right: 12px;
        white-space: nowrap;
    }

    /* première cellule (ID) → entête de carte */
    .devis-table td:first-child {
        background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
        font-size: 12px;
        color: #64748b;
        font-weight: 800;
        padding: 8px 14px;
    }

    /* cellule Actions : boutons côte à côte */
    .devis-table td[data-label="Actions"] {
        background: #f8fafc;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }

    .devis-table td[data-label="Actions"]::before {
        display: none;
    }

    .devis-table td[data-label="Actions"] .btn,
    .devis-table td[data-label="Actions"] button {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
        font-size: 13px;
    }

    /* filtre : 2 colonnes sur iPad */
    .filter-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
}

/* filtre : 1 colonne sur mobile */
@media (max-width: 580px) {
    .filter-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .filter-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-actions button,
    .filter-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== Badge navbar (calcul en attente) ===== */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    margin-left: 5px;
    vertical-align: middle;
}

/* ===== Stat cards cliquables ===== */
a.stat-card,
a.stat-card:link,
a.stat-card:visited {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

a.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(79, 70, 229, 0.15);
}

/* ===== Sort links dans les en-têtes de tableau ===== */
.sort-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.sort-link:hover {
    color: var(--primary);
}

/* ===== Statut badges ===== */
.statut-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.statut-en_cours {
    background: rgba(100, 116, 139, 0.12);
    color: #475569;
}

.statut-envoye {
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
}

.statut-accepte {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.statut-refuse {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.statut-facture {
    background: rgba(79, 70, 229, 0.1);
    color: #4338ca;
}

/* ===== Calcul en attente badge ===== */
.badge--warning {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
    white-space: nowrap;
}

/* Bouton Recalculer urgent (quand prix null) */
.btn-recalc-urgent {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-recalc-urgent:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* ===== iPhone SE / petit mobile (375px et moins) ===== */
@media (max-width: 390px) {
    .topbar-inner {
        padding: 6px 12px 4px;
    }

    main {
        padding: 10px 12px;
    }

    .card-h,
    .card-b {
        padding: 10px 12px;
    }

    .kpis {
        grid-template-columns: 1fr;
    }

    .kpi .v {
        font-size: 16px;
    }

    .title-wrap h1 {
        font-size: 18px;
    }

    .btn, button {
        font-size: 13px;
        padding: 10px 14px;
    }

    nav a {
        font-size: 12px;
        padding: 8px 10px;
    }
}