/* ─── Reset & variables ─────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
    --primary:   #0d9488;
    --primary-d: #0f766e;
    --bg:        #f1f5f9;
    --card:      #ffffff;
    --text:      #0f172a;
    --muted:     #64748b;
    --border:    #e2e8f0;
    --radius:    12px;
    --danger:    #dc2626;
    --warning:   #d97706;
    --success:   #16a34a;
}

body {
    font-family: -apple-system, 'Inter', BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0f172a;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ─── Phone shell (desktop) ─────────────────── */
.page-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    padding: 32px 16px;
}

.phone-shell {
    width: 390px;
    height: 844px;
    background: var(--bg);
    border-radius: 54px;
    box-shadow:
        0 0 0 10px #1e293b,
        0 0 0 13px #334155,
        0 40px 100px rgba(0,0,0,0.7);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Notch */
.phone-notch {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 126px; height: 34px;
    background: #1e293b;
    border-radius: 0 0 22px 22px;
    z-index: 20;
}

/* Status bar */
.phone-status {
    background: #0f172a;
    height: 48px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 26px 7px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    z-index: 10;
}

/* Zone de contenu — ne scroll PAS elle-même, distribue header/body/footer */
.phone-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ─── App header ─────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 5;
}
.app-header-title { font-size: 16px; font-weight: 800; color: var(--text); }
.role-pill {
    font-size: 10px; font-weight: 800; color: #fff;
    padding: 3px 9px; border-radius: 10px; white-space: nowrap;
}

/* ─── Screen body — seule zone qui scroll ────── */
.screen-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg);
    padding: 14px;
    min-height: 0;
    scrollbar-width: none;
}
.screen-body::-webkit-scrollbar { display: none; }

/* ─── Bottom navigation ──────────────────────── */
.bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: #fff;
    border-top: 1px solid var(--border);
    height: 64px;
    padding-bottom: 8px;
    flex-shrink: 0;
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10px; font-weight: 600; color: var(--muted); cursor: pointer;
    padding: 4px 12px; border-radius: 8px; transition: all 0.15s;
    border: none; background: none;
}
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { transform: scale(1.15); }
.nav-icon { font-size: 22px; }

/* ─── Cards & KPIs ───────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi-card {
    background: #fff; border-radius: var(--radius); padding: 13px 12px;
    border: 1px solid var(--border);
}
.kpi-label { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 5px; }
.kpi-value { font-size: 20px; font-weight: 900; color: var(--text); line-height: 1.1; }
.kpi-sub   { font-size: 10px; color: #94a3b8; margin-top: 3px; }

.section-title { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 14px 0 8px; }

.card { background: #fff; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; margin-bottom: 10px; }
.card-row {
    padding: 11px 14px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #f8fafc;
}
.card-row:last-child { border-bottom: none; }
.card-row-label { font-size: 13px; font-weight: 600; color: var(--text); }
.card-row-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.card-row-right { text-align: right; }

/* ─── Badges ─────────────────────────────────── */
.badge { display:inline-block; font-size:10px; font-weight:800; padding:2px 7px; border-radius:8px; white-space:nowrap; }
.badge-green  { background:#dcfce7; color:#15803d; }
.badge-yellow { background:#fef9c3; color:#b45309; }
.badge-red    { background:#fee2e2; color:#dc2626; }
.badge-blue   { background:#dbeafe; color:#1d4ed8; }
.badge-teal   { background:#ccfbf1; color:#0f766e; }

/* ─── Progress bar ───────────────────────────── */
.progress-wrap { height: 5px; background: #e2e8f0; border-radius: 3px; margin-top: 5px; overflow: hidden; }
.progress-fill { height: 5px; border-radius: 3px; }

/* ─── Aging bars ─────────────────────────────── */
.aging-row { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.aging-row:last-child { margin-bottom:0; }
.aging-label { width:44px; font-size:10px; font-weight:700; color:var(--muted); }
.aging-track { flex:1; height:7px; background:#e2e8f0; border-radius:4px; overflow:hidden; }
.aging-fill  { height:7px; border-radius:4px; }
.aging-val   { font-size:10px; font-weight:700; min-width:64px; text-align:right; color:var(--text); }

/* ─── Buttons ────────────────────────────────── */
.btn { border:none; border-radius:10px; font-size:13px; font-weight:700; cursor:pointer; font-family:inherit; transition:all 0.15s; display:inline-flex; align-items:center; justify-content:center; gap:5px; }
.btn-primary   { background:var(--primary); color:#fff; padding:12px; width:100%; }
.btn-primary:hover { background:var(--primary-d); }
.btn-secondary { background:var(--bg); color:var(--text); border:1px solid var(--border); padding:12px; width:100%; }
.btn-sm-ok { flex:1; background:#dcfce7; color:#15803d; border:none; border-radius:8px; padding:9px 6px; font-size:11px; font-weight:800; cursor:pointer; }
.btn-sm-ko { flex:1; background:#fee2e2; color:#dc2626; border:none; border-radius:8px; padding:9px 6px; font-size:11px; font-weight:800; cursor:pointer; }
.btn-row   { display:flex; gap:8px; margin-top:8px; }

/* ─── CRA grid ───────────────────────────────── */
.cra-table { width:100%; border-collapse:collapse; background:#fff; border-radius:var(--radius); overflow:hidden; border:1px solid var(--border); margin-bottom:10px; font-size:11px; }
.cra-table th { background:#f8fafc; padding:7px 4px; text-align:center; font-weight:800; font-size:9px; text-transform:uppercase; letter-spacing:0.3px; color:var(--muted); border-bottom:1px solid var(--border); }
.cra-table th:first-child { text-align:left; padding-left:10px; }
.cra-table td { padding:7px 4px; text-align:center; border-top:1px solid #f8fafc; }
.cra-table td:first-child { text-align:left; padding-left:10px; font-weight:600; font-size:10px; max-width:80px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cra-table .cra-total { font-weight:800; color:var(--primary); }
.cra-table tfoot td { background:#f0fdfa; font-weight:800; color:var(--primary); border-top:1px solid #ccfbf1; }

/* ─── TVA/Finance ────────────────────────────── */
.finance-row { display:flex; justify-content:space-between; align-items:center; padding:10px 14px; border-bottom:1px solid #f8fafc; font-size:13px; }
.finance-row:last-child { border-bottom:none; font-weight:800; }
.finance-total { background:#fef2f2; border-radius:0 0 var(--radius) var(--radius); }
.finance-total-green { background:#f0fdf4; border-radius:0 0 var(--radius) var(--radius); }

/* ─── Login ──────────────────────────────────── */
.login-wrap { flex:1; background:#fff; display:flex; flex-direction:column; align-items:center; padding:36px 20px 24px; }
.login-logo { font-size:30px; font-weight:900; color:var(--text); margin-bottom:4px; letter-spacing:-0.5px; }
.login-logo b { color:var(--primary); }
.login-sub  { font-size:11px; color:var(--muted); margin-bottom:32px; text-align:center; }
.role-grid  { display:grid; grid-template-columns:1fr 1fr; gap:9px; width:100%; margin-bottom:22px; }
.role-btn   { padding:13px 8px; border-radius:12px; border:none; color:#fff; font-size:11px; font-weight:800; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:5px; transition:opacity 0.15s; }
.role-btn:hover { opacity:0.88; }
.sep { width:100%; display:flex; align-items:center; gap:8px; margin-bottom:18px; }
.sep hr { flex:1; border:none; border-top:1px solid var(--border); }
.sep span { font-size:10px; color:#94a3b8; white-space:nowrap; }
.login-select { width:100%; padding:11px 12px; border:1px solid var(--border); border-radius:10px; font-size:13px; color:var(--text); background:#f8fafc; margin-bottom:12px; appearance:none; }
.login-footer { margin-top:auto; padding-top:16px; font-size:10px; color:#94a3b8; text-align:center; }

/* ─── Util ───────────────────────────────────── */
.mt-sm { margin-top:8px; }
.mt-md { margin-top:14px; }
.text-danger  { color:var(--danger); }
.text-warning { color:var(--warning); }
.text-success { color:var(--success); }
.text-muted   { color:var(--muted); font-size:11px; }
.fw-bold { font-weight:800; }

/* ─── Media: vrai mobile ─────────────────────── */
@media (max-width: 430px) {
    body { background: var(--bg); }
    .page-bg { padding: 0; align-items: flex-start; background: var(--bg); }
    .phone-shell { width: 100vw; height: 100vh; border-radius: 0; box-shadow: none; }
    .phone-notch { display: none; }
    .phone-status { background: var(--bg); color: var(--text); height: 44px; }
}
