/* ══════════════════════════════════════════════════════════════════════
   Nutri-Import Dashboard — Style global
   ══════════════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
    --primary:       #1B2F5E;
    --primary-mid:   #243d7a;
    --primary-dark:  #142348;
    --accent:        #8CC43F;
    --accent-dark:   #6fa030;
    --bg:            #F0F2F6;
    --bg-card:       #FFFFFF;
    --text:          #0F172A;
    --text-muted:    #64748B;
    --text-light:    #94A3B8;
    --border:        #E2E8F0;
    --border-light:  #F1F5F9;
    --radius:        16px;
    --radius-sm:     10px;
    --shadow:        0 1px 3px rgba(15,23,42,0.06), 0 6px 20px rgba(15,23,42,0.04);
    --shadow-md:     0 4px 24px rgba(15,23,42,0.12);
    --success:       #10B981;
    --danger:        #EF4444;
    --header-h:      64px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
input, button, select { font-family: inherit; }

/* ══════════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════════════════ */

.login-body { background: #fff; min-height: 100vh; }

.login-wrap {
    display: flex;
    min-height: 100vh;
}

/* ── Panel gauche ─────────────────────────────────────────────────────────── */
.login-brand {
    width: 42%;
    background: linear-gradient(160deg, #1B2F5E 0%, #0d1f42 100%);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 52px 56px;
    position: relative;
    overflow: hidden;
}

.login-brand-top { margin-bottom: 64px; }

.lb-logo {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: left;
    margin-bottom: 20px;
    position: relative; z-index: 1;
}
.lb-logo-img { height: 30px; width: auto; filter: brightness(0) invert(1); object-fit: contain; }
.lb-logo-fallback {
    display: none;
    width: 100%; height: 100%;
    align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800; color: #fff; letter-spacing: 0.5px;
}

.lb-title { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -0.3px; position: relative; z-index: 1; }
.lb-tagline { font-size: 13px; color: rgba(255,255,255,0.45); margin-top: 4px; position: relative; z-index: 1; }

.lb-body { flex: 1; position: relative; z-index: 1; }

.lb-headline {
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -0.8px;
    margin-bottom: 36px;
}

.lb-channels {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.lb-channels li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255,255,255,0.65);
}
.lb-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.9;
}

.lb-footer {
    font-size: 11px;
    color: rgba(255,255,255,0.25);
    position: relative; z-index: 1;
}

/* Décorations géométriques */
.lb-deco {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.05);
    pointer-events: none;
}
.lb-deco-1 { width: 500px; height: 500px; bottom: -180px; right: -160px; }
.lb-deco-2 { width: 320px; height: 320px; bottom: -80px;  right: -80px; border-color: rgba(140,196,63,0.08); }

/* ── Panel droit ──────────────────────────────────────────────────────────── */
.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    background: #fff;
}

.login-form-inner {
    width: 100%;
    max-width: 380px;
}

.lf-logo-mobile {
    display: none;
    margin-bottom: 28px;
}

.lf-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.6px;
    margin-bottom: 8px;
}

.lf-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.6;
}

.lf-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #DC2626;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 20px;
}

.lf-form { display: flex; flex-direction: column; gap: 20px; }

.lf-field { display: flex; flex-direction: column; gap: 7px; }

.lf-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.1px;
}

.lf-field input,
.lf-input-wrap input {
    width: 100%;
    height: 48px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 16px;
    font-size: 15px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.lf-field input:focus,
.lf-input-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27,47,94,0.1);
}

.lf-input-wrap {
    position: relative;
}
.lf-input-wrap input { padding-right: 48px; }

.lf-eye {
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.15s;
    display: flex; align-items: center;
}
.lf-eye:hover { color: var(--text-muted); }

.lf-submit {
    height: 50px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(140,196,63,0.35);
    letter-spacing: -0.1px;
}
.lf-submit:hover  { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(140,196,63,0.4); }
.lf-submit:active { transform: translateY(0); }

.lf-version {
    text-align: center;
    font-size: 11px;
    color: var(--text-light);
    margin-top: 28px;
}

/* ── Login responsive ─────────────────────────────────────────────────────── */
@media (max-width: 800px) {
    .login-brand { display: none; }
    .lf-logo-mobile { display: block; }
    .login-form-panel { padding: 40px 24px; }
}

/* ══════════════════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════════════════ */

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    height: var(--header-h);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 20px rgba(0,0,0,0.2);
}

.header-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.header-logo-wrap {
    height: 38px;
    display: flex; align-items: center;
}
.header-logo-img {
    height: 36px;
    width: 150px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}
.header-logo-fallback {
    display: none;
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.13);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 10px;
    align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; color: #fff;
}

.header-brand-text { display: flex; flex-direction: column; gap: 1px; }
.header-name    { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.header-tagline { font-size: 11px; color: rgba(255,255,255,0.45); line-height: 1; }

.header-period { flex: 1; display: flex; justify-content: center; }

.period-group {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
}
.period-group select {
    background: transparent; border: none; color: #fff;
    font-size: 13px; font-weight: 500; cursor: pointer; outline: none;
    padding: 0 18px 0 2px; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.55)'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 2px center;
}
.period-group select option { background: #1e3570; }

.btn-apply {
    background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.22);
    color: #fff; border-radius: 6px; padding: 6px 14px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: background 0.15s; white-space: nowrap;
}
.btn-apply:hover { background: rgba(255,255,255,0.24); }

.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.conn-status { display: flex; gap: 6px; }
.conn-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 500; padding: 3px 9px;
    border-radius: 20px; border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.45); white-space: nowrap;
}
.conn-pill.ok  { color: #6ee7b7; border-color: rgba(110,231,183,0.25); }
.conn-pill.err { color: #fca5a5; border-color: rgba(252,165,165,0.25); }
.conn-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.btn-logout {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.btn-logout:hover { background: rgba(255,255,255,0.18); color: #fff; }

.btn-export {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius-sm); padding: 8px 16px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(140,196,63,0.3);
}
.btn-export:hover  { background: var(--accent-dark); transform: translateY(-1px); }
.btn-export:active { transform: translateY(0); }

/* ── Container ───────────────────────────────────────────────────────────── */
.container { max-width: 1440px; margin: 0 auto; padding: 28px 28px 8px; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }

/* ── KPI Grid ────────────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 22px 24px 20px;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-card.kpi-pos::before     { background: linear-gradient(90deg, var(--success), #34d399); }
.kpi-card.kpi-neg::before     { background: linear-gradient(90deg, var(--danger), #f87171); }
.kpi-card.kpi-channel::before { background: var(--chan, var(--primary)); }
.kpi-card.kpi-wide            { grid-column: span 3; }
.kpi-card.kpi-channel         { grid-column: span 2; }

.kpi-label {
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.6px;
    margin-bottom: 10px;
}

.kpi-value {
    font-size: 22px; font-weight: 800;
    color: var(--text); letter-spacing: -0.5px;
    line-height: 1.1; margin-bottom: 12px;
    font-variant-numeric: tabular-nums;
}
.kpi-card.kpi-wide .kpi-value { font-size: 30px; }

.kpi-footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-compare { font-size: 11px; color: var(--text-light); }

.trend-up, .trend-down, .trend-neutral {
    display: inline-flex; align-items: center; gap: 2px;
    font-size: 12px; font-weight: 600;
    padding: 2px 8px; border-radius: 20px; flex-shrink: 0;
}
.trend-up      { background: #ECFDF5; color: #059669; }
.trend-down    { background: #FEF2F2; color: #DC2626; }
.trend-neutral { background: var(--border-light); color: var(--text-muted); }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center;
    justify-content: space-between; gap: 12px;
}
.card-header h2 { font-size: 14px; font-weight: 700; color: var(--text); }

.badge {
    background: var(--primary); color: #fff;
    border-radius: 20px; padding: 3px 11px;
    font-size: 11px; font-weight: 600;
}
.badge-year {
    background: var(--bg); color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 20px; padding: 3px 11px;
    font-size: 11px; font-weight: 600;
}

.card-body { padding: 20px 22px; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }

.metrics-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.metrics-table .th-label {
    background: var(--primary);
    color: rgba(255,255,255,0.55);
    padding: 12px 22px; text-align: left;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    width: 210px; white-space: nowrap;
}
.metrics-table .th-channel {
    background: var(--primary); color: #fff;
    padding: 12px 22px; text-align: right;
    font-size: 12px; font-weight: 600;
    white-space: nowrap;
    border-bottom: 3px solid var(--ch, var(--accent));
}
.metrics-table .th-total {
    background: var(--primary-dark); color: #fff;
    padding: 12px 22px; text-align: right;
    font-size: 12px; font-weight: 700; white-space: nowrap;
}

.metrics-table td {
    padding: 11px 22px; text-align: right;
    border-bottom: 1px solid var(--border-light);
    color: var(--text); white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transition: background 0.1s;
}
.metrics-table .td-label {
    text-align: left; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
}
.metrics-table .td-total {
    font-weight: 700; color: var(--primary); background: #F5F8FF;
}
.metrics-table tr:last-child td { border-bottom: none; }
.metrics-table tr:nth-child(even) td { background: #FAFBFC; }
.metrics-table tr:nth-child(even) .td-total { background: #EDF1FC; }
.metrics-table tr:hover td { background: #EEF2FA; }
.metrics-table tr:hover .td-total { background: #E3EAF7; }

.cell-zero { color: var(--text-light); }
.cell-na   { color: var(--text-light); font-style: italic; }

.source-badge {
    display: inline-block; background: #F0F9E4; color: #4a7a1c;
    border-radius: 4px; padding: 1px 6px;
    font-size: 10px; font-weight: 700; letter-spacing: 0.3px; flex-shrink: 0;
}

/* ── Charts ──────────────────────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.chart-container { position: relative; height: 300px; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
    text-align: center; color: var(--text-light); font-size: 11px;
    padding: 20px 0 28px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.footer-sep { opacity: 0.35; }

/* ── Modale Export ───────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 500;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
    padding: 16px;
}
.modal-box {
    background: #fff; border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(15,23,42,0.25);
    width: 100%; max-width: 440px; overflow: hidden;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
}
.modal-header h3 {
    font-size: 15px; font-weight: 700; color: var(--text);
    display: flex; align-items: center;
}
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-light); padding: 6px; border-radius: 6px;
    display: flex; align-items: center; transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px 24px 18px; }
.modal-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

.modal-year-row {
    display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
}
.modal-year-row label,
.modal-range-col label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); display: block; margin-bottom: 6px;
}
.modal-year-row select,
.modal-range-col select {
    height: 42px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); padding: 0 14px;
    font-size: 14px; color: var(--text); background: #fff;
    outline: none; cursor: pointer; font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-year-row select:focus,
.modal-range-col select:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,47,94,0.1);
}

.modal-range {
    display: flex; align-items: flex-end; gap: 10px;
}
.modal-range-col { flex: 1; }
.modal-range-col select { width: 100%; }
.modal-range-arrow {
    font-size: 22px; color: var(--text-light);
    padding-bottom: 10px; flex-shrink: 0;
}

.modal-summary {
    margin-top: 14px; font-size: 13px; font-weight: 500;
    min-height: 18px; transition: color 0.15s;
}
.modal-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 14px 24px; background: var(--bg);
    border-top: 1px solid var(--border-light);
}
.modal-cancel {
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 9px 18px;
    font-size: 13px; font-weight: 500; color: var(--text-muted);
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.modal-cancel:hover { background: var(--border-light); color: var(--text); }
.modal-confirm {
    display: flex; align-items: center; gap: 8px;
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius-sm); padding: 9px 20px;
    font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
    box-shadow: 0 2px 8px rgba(140,196,63,0.35);
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.modal-confirm:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(140,196,63,0.4); }
.modal-confirm:active { transform: translateY(0); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1200px) { .conn-status { display: none; } }

@media (max-width: 960px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-card.kpi-wide    { grid-column: span 1; }
    .kpi-card.kpi-channel { grid-column: span 1; }
    .kpi-card.kpi-wide .kpi-value { font-size: 24px; }
    .charts-grid { grid-template-columns: 1fr; }
    .header-period { display: none; }
}

@media (max-width: 600px) {
    .container { padding: 14px; }
    .kpi-grid { gap: 10px; }
    .kpi-value { font-size: 18px; }
    .kpi-card { padding: 16px; }
}
