:root {
    --bg: #ffffff;
    --bg-soft: #f7f7f8;
    --card: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #1f2937;
    --muted: #6b7280;

    --primary: #dc2626;          /* red 600 */
    --primary-hover: #b91c1c;    /* red 700 */
    --primary-soft: #fef2f2;     /* red 50  */
    --primary-ring: rgba(220, 38, 38, 0.18);

    --success: #16a34a;
    --danger:  #b91c1c;
    --warning: #d97706;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-soft);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

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

/* ------------ Topbar ------------ */
.topbar {
    display: flex;
    align-items: center;
    background: #ffffff;
    color: var(--text);
    padding: 0 16px;
    height: 56px;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(0,0,0,.02);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar .brand {
    color: var(--text);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: .2px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.topbar .brand::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--primary);
}
.topbar .nav {
    display: flex;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.topbar .nav::-webkit-scrollbar { display: none; }
.nav-link {
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
}
.nav-link:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-link.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}
.user-block { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-name { font-weight: 600; }
.user-role {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.btn-link { color: var(--primary); }

.main { max-width: 1240px; margin: 20px auto; padding: 0 16px; }
.main-narrow { max-width: 880px; }
.footer { text-align: center; color: var(--muted); padding: 24px 0; }

/* Standalone page (used by Commande) — no main nav, focused layout */
.topbar-minimal .brand small {
    color: var(--muted);
    font-weight: 500;
    margin-left: 4px;
    font-size: 13px;
}
.topbar-minimal { justify-content: space-between; }
body.standalone { background: #ffffff; }
body.standalone .main { background: var(--bg-soft); border-radius: 14px; padding: 16px; }
@media (max-width: 640px) {
    body.standalone .main { background: transparent; padding: 0 10px; border-radius: 0; }
}

.page-title { margin: 0 0 16px; font-size: 22px; font-weight: 700; }
.page-title small { font-weight: 400; color: var(--muted); }

/* ------------ Tabs ------------ */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--muted);
    white-space: nowrap;
}
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.tab:disabled { opacity: .55; cursor: not-allowed; }

/* ------------ Card ------------ */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

/* ------------ Layout helpers ------------ */
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.col { flex: 1 1 220px; min-width: 0; }

/* ------------ Forms ------------ */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 4px;
}
.form-control,
.form-select,
input[type=text],
input[type=date],
input[type=number],
input[type=password],
input[type=email],
input[type=tel],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 15px;            /* >=16px on iOS prevents zoom; 15px is OK on most */
    background: #fff;
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
}
input[type=date] { min-height: 42px; }   /* iOS date control needs height */
select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M6 8 0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.form-control[readonly], input[readonly] {
    background: #f3f4f6;
    color: var(--muted);
    border-style: dashed;
}

.input-group { display: flex; gap: 6px; }
.input-group > :first-child { flex: 1; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}
.checkbox-row input[type=checkbox] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}
.checkbox-row:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

#map {
    height: 320px;
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    margin-bottom: 8px;
    z-index: 1;
}
@media (max-width: 640px) {
    #map { height: 260px; }
}

.article-row {
    display: grid;
    grid-template-columns: 1fr 130px 42px;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
.article-row .btn-rm {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 8px;
    height: 42px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.article-row .btn-rm:hover { background: #fca5a5; color: #fff; }
@media (max-width: 640px) {
    .article-row { grid-template-columns: 1fr 110px 42px; gap: 4px; }
}

/* Two adjacent fields rendered as a single connected control (no gap, merged borders). */
.field-pair {
    display: flex;
    gap: 0;
    align-items: stretch;
    flex: 2 1 380px;
    min-width: 0;
}
.field-pair .form-group { margin-bottom: 0; }
.field-pair .form-group:first-child  { flex: 1; min-width: 0; }
.field-pair .form-group:first-child  select,
.field-pair .form-group:first-child  input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.field-pair .form-group:last-child   { flex: 0 0 130px; }
.field-pair .form-group:last-child   input {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 0;
}
@media (max-width: 640px) {
    /* On phone, the pair stays side by side but prix shrinks */
    .field-pair { flex: 1 1 100%; }
    .field-pair .form-group:last-child { flex: 0 0 110px; }
}

/* ------------ Buttons ------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: #f3f4f6;
    color: var(--text);
    min-height: 42px;
    line-height: 1.1;
    transition: background-color .12s ease, color .12s ease;
}
.btn:hover { background: #e5e7eb; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-outline {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary-soft); }
.btn-sm   { padding: 6px 10px; font-size: 12px; min-height: 32px; }
.btn-icon { padding: 6px 12px; font-size: 18px; line-height: 1; min-height: 42px; }

/* ------------ Section title ------------ */
.section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text);
    margin: 22px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

/* ------------ Lines table ------------ */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 8px;
}
.line-table { width: 100%; border-collapse: collapse; }
.line-table th, .line-table td {
    padding: 10px 12px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.line-table th {
    background: var(--bg-soft);
    font-weight: 700;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.line-table tbody tr:last-child td { border-bottom: none; }
.line-table tfoot td {
    background: var(--bg-soft);
    font-weight: 700;
    border-top: 1px solid var(--border-strong);
    border-bottom: none;
}
.line-empty {
    color: var(--muted);
    text-align: center;
    font-style: italic;
    padding: 22px;
}

/* ------------ Alerts ------------ */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-success { background: #dcfce7; color: #166534; border-color: #86efac; }
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.alert-info    { background: var(--primary-soft); color: var(--primary-hover); border-color: #fecaca; }

/* ------------ Login ------------ */
.login-wrap {
    max-width: 400px;
    margin: 60px auto;
    padding: 0 16px;
}
.login-wrap .card { padding: 28px; }
.login-wrap h1 {
    margin: 0 0 18px;
    font-size: 22px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.login-wrap h1::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--primary);
}
.login-wrap .btn { width: 100%; }

/* ============================================================
   Mobile (≤ 640px)  — Commande and other forms must work on phone.
   ============================================================ */
@media (max-width: 640px) {
    body { font-size: 14px; }

    .topbar { padding: 0 10px; gap: 10px; height: 52px; }
    .topbar .brand { font-size: 14px; }
    .topbar .user-block .user-name,
    .topbar .user-block .user-role { display: none; }
    .topbar .user-block .btn-link { font-size: 12px; }

    .main { margin: 12px auto; padding: 0 10px; }
    .page-title { font-size: 18px; margin-bottom: 12px; }

    .card { padding: 14px; border-radius: 10px; }

    /* Stack everything vertically on phone */
    .row { gap: 10px; flex-direction: column; }
    .col { flex: 1 1 100%; }

    .form-group { margin-bottom: 10px; }
    .form-group label { font-size: 11px; }

    /* Bigger tap targets — also avoid iOS zoom on focus */
    input[type=text],
    input[type=date],
    input[type=number],
    input[type=password],
    input[type=email],
    input[type=tel],
    select,
    textarea {
        font-size: 16px;
        padding: 12px;
        min-height: 46px;
    }
    .btn { width: 100%; min-height: 46px; font-size: 15px; }
    .btn-sm { width: auto; min-height: 32px; font-size: 12px; }
    .btn-icon { width: auto; flex: 0 0 auto; }

    /* The "+" client button stays inline next to the client selector */
    .input-group > .btn-icon { width: 46px; flex: 0 0 46px; }

    /* Submit/reset row stacks vertically */
    .form-actions { flex-direction: column; }

    /* Tabs are scrollable; tab itself bigger */
    .tab { padding: 12px 16px; font-size: 14px; }

    /* Lines table: scroll horizontally if content wider than screen */
    .table-wrap { border-radius: 8px; }
    .line-table th, .line-table td { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
    .line-table th { font-size: 11px; }

    .section-title { font-size: 11px; margin: 18px 0 8px; }
}

/* very small phones */
@media (max-width: 380px) {
    .topbar { padding: 0 8px; }
    .topbar .nav { gap: 0; }
    .nav-link { padding: 6px 8px; font-size: 12px; }
    .main { padding: 0 8px; }
}

/* ============================================================
   App shell — bottom tabs, FAB, card list
   ============================================================ */

/* Pages using the app shell push their main content up so it
   doesn't sit under the fixed bottom tab bar. */
body.app-shell { padding-bottom: 76px; background: var(--bg-soft); }
body.app-shell .main { max-width: 880px; }

/* Bottom tab bar (fixed) — red background, white icons */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    background: var(--primary);
    padding: 4px 0 max(4px, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(0,0,0,.12);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    color: rgba(255, 255, 255, .72);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    border-top: 3px solid transparent;
    margin-top: -1px;
    transition: color .12s ease;
}
.bottom-nav-item:hover { text-decoration: none; color: #fff; }
.bottom-nav-item .icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.bottom-nav-item .icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.bottom-nav-item.active {
    color: #ffffff;
    border-top-color: #ffffff;
    font-weight: 700;
}

/* Floating Action Button */
.fab {
    position: fixed;
    right: 16px;
    bottom: 88px;        /* above the tab bar */
    z-index: 49;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(220, 38, 38, .35);
    transition: transform .12s ease, background-color .12s ease;
}
.fab:hover { background: var(--primary-hover); transform: translateY(-1px); }
.fab:focus { outline: none; box-shadow: 0 6px 16px rgba(220, 38, 38, .35), 0 0 0 4px var(--primary-ring); }

/* Search bar at top of each tab */
.search-bar { margin: 4px 0 12px; }
.search-bar input[type="search"] {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat 12px center;
    font-size: 14px;
    -webkit-appearance: none;
    appearance: none;
}
.search-bar input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-bar input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

/* Grouped lists (e.g. affaires by client) */
.group { margin-bottom: 16px; }
.group-header {
    margin: 4px 0 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text);
    padding: 6px 0;
    border-bottom: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.group-header .count-badge {
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-soft);
    color: var(--muted);
    border-radius: 999px;
    padding: 2px 8px;
    text-transform: none;
    letter-spacing: 0;
}

/* Read-only detail rows on view pages */
.detail-row {
    display: flex;
    gap: 14px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    align-items: baseline;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
    flex: 0 0 200px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.detail-value {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    font-size: 14px;
}
.detail-value.empty { color: var(--muted); font-style: italic; }
@media (max-width: 640px) {
    .detail-row { flex-direction: column; gap: 2px; padding: 8px 0; }
    .detail-label { flex: none; font-size: 11px; }
}

/* Action row at the bottom of a list card */
.list-card .lc-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

/* Bottom-sheet modal (mobile-first) */
.modal-backdrop {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100%; height: 100%;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 100;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff;
    width: 100%;
    max-width: 520px;
    border-radius: 16px 16px 0 0;
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-slide-up .2s ease;
}
.modal h2 { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* Click-to-copy chips inside list cards (data-copy attribute) */
[data-copy], [data-copy-all] {
    cursor: copy;
    border-radius: 4px;
    padding: 0 4px;
    margin: 0 -4px;
    transition: background-color .12s ease;
    -webkit-user-select: text; user-select: text;
}
[data-copy]:hover, [data-copy-all]:hover { background: var(--primary-soft); }
[data-copy].copied, [data-copy-all].copied {
    background: #dcfce7 !important;
    color: #166534;
}
[data-copy-all] { cursor: pointer; }

/* Per-line copyable rows in the ADV detail modal */
.adv-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-soft);
}
.adv-line:last-child { margin-bottom: 0; }
.adv-line-text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    word-break: break-word;
}
.adv-line .btn { flex: 0 0 auto; }
@keyframes modal-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@media (min-width: 640px) {
    .modal-backdrop { align-items: center; padding: 16px; }
    .modal { border-radius: 16px; }
    @keyframes modal-slide-up {
        from { transform: translateY(20px); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }
}

/* List header inside a tab page */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4px 0 12px;
}
.list-header h1 { margin: 0; font-size: 20px; font-weight: 700; }
.list-header .count {
    background: var(--bg-soft);
    color: var(--muted);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
}

/* Cards: responsive grid — squarish cards that flow into multiple columns
   on wider viewports, single column on phones. */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 12px;
    align-items: stretch;
}
.list-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
    color: inherit;
    text-decoration: none;
    transition: border-color .12s ease, box-shadow .12s ease;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
/* Push the action row to the bottom so all cards in a grid row line up. */
.list-card .lc-actions { margin-top: auto; }
.list-card:hover {
    text-decoration: none;
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(220, 38, 38, .08);
}
.list-card .lc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.list-card .lc-id {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: .3px;
    color: var(--text);
}
.list-card .lc-sub {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.4;
}
.list-card .lc-meta {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 12px;
    color: var(--muted);
}
.list-card .lc-meta strong { color: var(--text); font-weight: 600; }
.list-card .lc-amount {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}
.list-card .lc-audit {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
    color: var(--muted);
    font-size: 11px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}
.list-card .lc-audit strong { color: var(--text); font-weight: 600; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

/* Per-agent colored bubble (deterministic palette via .agent-c1 … .agent-c8). */
.agent-bubble {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.3;
}
.agent-c1 { background: #dc2626; }   /* red */
.agent-c2 { background: #ea580c; }   /* orange */
.agent-c3 { background: #d97706; }   /* amber */
.agent-c4 { background: #16a34a; }   /* green */
.agent-c5 { background: #0891b2; }   /* cyan */
.agent-c6 { background: #2563eb; }   /* blue */
.agent-c7 { background: #7c3aed; }   /* violet */
.agent-c8 { background: #db2777; }   /* pink */

/* Status badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    background: #e5e7eb;
    color: var(--text);
    white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-primary { background: var(--primary-soft); color: var(--primary-hover); }
.badge-muted   { background: #f3f4f6; color: var(--muted); }

/* Balance âgée table */
.balance-table { width: 100%; border-collapse: collapse; }
.balance-table th, .balance-table td {
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.balance-table th {
    background: var(--bg-soft);
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .3px;
}
.balance-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.balance-table tfoot td {
    background: var(--bg-soft);
    font-weight: 700;
    border-top: 2px solid var(--primary);
}
.balance-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.balance-summary .stat {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}
.balance-summary .stat .lbl {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .3px;
}
.balance-summary .stat .val {
    font-size: 18px;
    font-weight: 700;
    margin-top: 4px;
}
.balance-summary .stat .val.danger { color: var(--primary); }

@media (max-width: 640px) {
    .bottom-nav-item { font-size: 10px; }
    .bottom-nav-item .icon { font-size: 20px; }
    .list-header h1 { font-size: 18px; }
    .list-card { padding: 12px; }
    .balance-table th, .balance-table td { padding: 8px 8px; font-size: 12px; }
}
