/* ============================================================
   MaVigie - Feuille de style principale
   Charte : Marine #1B3A5C + Orange #E8651A + Blanc
   Police : Inter (Google Fonts)
   Approche : Mobile-first, responsive
   ============================================================ */

:root {
    --marine: #1B3A5C;
    --marine-dark: #0F2438;
    --marine-deeper: #091828;
    --orange: #E8651A;
    --orange-light: #F4943E;
    --orange-glow: rgba(232, 101, 26, 0.12);
    --white: #FFFFFF;
    --grey-light: #D8DEE9;
    --grey-blue: #8A9BB5;
    --blue-link: #2A5080;

    --vig-vert: #43A047;
    --vig-jaune: #FDD835;
    --vig-orange: #FB8C00;
    --vig-rouge: #E53935;

    --success: #43A047;
    --warning: #FB8C00;
    --danger: #E53935;
    --info: #2A5080;

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;
    --space-xxl: 64px;
    --space-xxxl: 64px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.35);

    --max-width: 1200px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--marine-deeper);
    color: var(--white);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--orange-light); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--orange); }
img { max-width: 100%; height: auto; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; margin-bottom: var(--space-md); color: var(--white); }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { margin-bottom: var(--space-md); color: var(--grey-light); }
small { font-size: 0.85rem; color: var(--grey-blue); }

/* Layout */
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 var(--space-lg); }
.page-content { flex: 1; padding: var(--space-xl) 0; background: var(--marine); }

/* Navbar */
.navbar {
    background: rgba(15, 36, 56, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: var(--space-md) 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-sm); }
.navbar-brand { display: flex; align-items: center; gap: 6px; font-size: 1.4rem; font-weight: 800; color: var(--white); letter-spacing: -0.3px; }
.navbar-brand img { width: 28px; height: 28px; border-radius: 6px; }
.navbar-brand:hover { color: var(--white); }
.navbar-brand .brand-accent { color: var(--orange); }
.navbar-brand .brand-text { display: inline; }
.navbar-nav { display: flex; list-style: none; gap: var(--space-sm); align-items: center; }
.navbar-nav a { color: var(--grey-blue); font-size: 0.88rem; font-weight: 500; padding: 8px 14px; border-radius: var(--radius-md); transition: all 0.2s; }
.navbar-nav a:hover, .navbar-nav a.active { color: var(--white); background: rgba(255,255,255,0.08); }
.navbar-nav a.btn-primary, .navbar-nav a.btn-primary:hover { color: var(--white); }
.navbar-nav a.btn-secondary { color: var(--white); }
.navbar-toggle { display: none; background: none; border: 1px solid rgba(255,255,255,0.15); color: var(--white); font-size: 1.3rem; cursor: pointer; padding: 6px 10px; border-radius: var(--radius-sm); }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm); padding: 11px 22px; font-family: inherit; font-size: 0.92rem; font-weight: 600; border: none; border-radius: var(--radius-md); cursor: pointer; transition: all 0.25s ease; text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--orange), #d4530f); color: var(--white); box-shadow: 0 4px 14px rgba(232,101,26,0.35); }
.btn-primary:hover { background: linear-gradient(135deg, var(--orange-light), var(--orange)); color: var(--white); box-shadow: 0 6px 20px rgba(232,101,26,0.45); transform: translateY(-1px); }
.btn-secondary { background: rgba(255,255,255,0.06); color: var(--white); border: 1px solid rgba(255,255,255,0.15); }
.btn-secondary:hover { background: rgba(255,255,255,0.12); color: var(--white); border-color: rgba(255,255,255,0.25); }
.btn-sm { padding: 7px 16px; font-size: 0.84rem; }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-block { display: flex; width: 100%; }

/* Cards */
.card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: var(--radius-lg); padding: var(--space-lg); transition: all 0.3s ease; }
.card:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); }
.card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0; }

/* Vigilance cards */
.vigilance-card { border-left: 4px solid; padding: var(--space-md) var(--space-lg); border-radius: var(--radius-md); background: rgba(255,255,255,0.04); margin-bottom: var(--space-md); transition: all 0.2s; }
.vigilance-card:hover { background: rgba(255,255,255,0.06); }
.vigilance-card.level-1 { border-left-color: var(--vig-vert); }
.vigilance-card.level-2 { border-left-color: var(--vig-jaune); }
.vigilance-card.level-3 { border-left-color: var(--vig-orange); }
.vigilance-card.level-4 { border-left-color: var(--vig-rouge); }
.vigilance-badge { display: inline-flex; align-items: center; gap: var(--space-xs); padding: 3px 12px; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.vigilance-badge.level-1 { background: var(--vig-vert); color: #fff; }
.vigilance-badge.level-2 { background: var(--vig-jaune); color: #333; }
.vigilance-badge.level-3 { background: var(--vig-orange); color: #fff; }
.vigilance-badge.level-4 { background: var(--vig-rouge); color: #fff; }

/* Formulaires */
.form-group { margin-bottom: var(--space-md); }
.form-label { display: block; font-size: 0.88rem; font-weight: 500; color: var(--grey-light); margin-bottom: 6px; }
.form-control { width: 100%; padding: 11px 16px; font-family: inherit; font-size: 0.95rem; color: var(--white); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-md); transition: all 0.2s; }
.form-control:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(232,101,26,0.15); background: rgba(255,255,255,0.08); }
.form-control::placeholder { color: var(--grey-blue); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238A9BB5' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
select.form-control option { color: #1a1a2e; background: #fff; }
.form-check { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.form-check input[type="checkbox"], .form-check input[type="radio"] { accent-color: var(--orange); width: 18px; height: 18px; }
.form-error { color: var(--danger); font-size: 0.85rem; margin-top: var(--space-xs); }

/* Alertes */
.alert { padding: var(--space-md) var(--space-lg); border-radius: var(--radius-md); margin-bottom: var(--space-lg); font-size: 0.9rem; border-left: 4px solid; }
.alert-success { background: rgba(67,160,71,0.1); border-color: var(--success); color: #a5d6a7; }
.alert-error { background: rgba(229,57,53,0.1); border-color: var(--danger); color: #ef9a9a; }
.alert-warning { background: rgba(251,140,0,0.1); border-color: var(--warning); color: #ffcc80; }
.alert-info { background: rgba(42,80,128,0.1); border-color: var(--info); color: #90caf9; }

/* Grille */
.grid { display: grid; gap: var(--space-lg); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* Table */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px var(--space-md); text-align: left; border-bottom: 1px solid rgba(255,255,255,0.06); }
th { font-size: 0.8rem; font-weight: 600; color: var(--grey-blue); text-transform: uppercase; letter-spacing: 0.6px; }
tr:hover { background: rgba(255,255,255,0.02); }

/* Footer */
.footer { background: var(--marine-deeper); padding: var(--space-xxl) 0 var(--space-lg); margin-top: auto; border-top: 1px solid rgba(255,255,255,0.06); }
.footer-content { display: flex; flex-wrap: wrap; gap: var(--space-xl); justify-content: space-between; }
.footer-section h4 { color: var(--white); font-size: 0.95rem; margin-bottom: var(--space-md); }
.footer-section a { display: block; color: var(--grey-blue); font-size: 0.85rem; padding: 3px 0; transition: color 0.2s; }
.footer-section a:hover { color: var(--orange-light); }
.footer-bottom { margin-top: var(--space-xl); padding-top: var(--space-lg); border-top: 1px solid rgba(255,255,255,0.06); text-align: center; font-size: 0.8rem; color: var(--grey-blue); }

/* Utils */
.trend-up { color: var(--danger); }
.trend-down { color: var(--success); }
.trend-stable { color: var(--grey-blue); }
#map { width: 100%; height: 550px; border-radius: var(--radius-lg); border: 1px solid rgba(255,255,255,0.08); }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--orange); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; gap: var(--space-sm); padding: var(--space-xxl); color: var(--grey-blue); }
.source-mf { font-size: 0.75rem; color: var(--grey-blue); font-style: italic; margin-top: var(--space-xs); }
.partner-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px; background: var(--orange-glow); border: 1px solid rgba(232,101,26,0.3); border-radius: var(--radius-full); font-size: 0.82rem; font-weight: 500; color: var(--orange-light); }

/* ============================================================
   LANDING PAGE
   ============================================================ */

.hero {
    position: relative;
    text-align: center;
    padding: var(--space-xxxl) 0 var(--space-xxl);
    background: url('../img/hero-bg.jpg') center center / cover no-repeat;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(9,24,40,0.55) 0%, rgba(15,36,56,0.65) 100%);
    pointer-events: none;
    z-index: 0;
}
.hero .container { position: relative; z-index: 1; }

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    margin-bottom: var(--space-sm);
    position: relative;
}
.hero-title .accent { color: var(--orange); }

.hero .tagline { font-size: 1.3rem; color: var(--grey-blue); margin-bottom: var(--space-lg); font-weight: 400; }
.hero .hero-desc { color: var(--grey-light); max-width: 560px; margin: 0 auto var(--space-lg); font-size: 1.05rem; line-height: 1.7; }
.hero .cta-group { display: flex; gap: var(--space-md); justify-content: center; flex-wrap: wrap; margin-bottom: var(--space-lg); }

.landing-section { padding: var(--space-xxxl) 0; position: relative; }
.landing-section.alt-bg { background: var(--marine-dark); }
.section-title { text-align: center; font-size: 2rem; font-weight: 700; margin-bottom: var(--space-sm); letter-spacing: -0.5px; }
.section-subtitle { text-align: center; font-size: 1.05rem; color: var(--grey-blue); max-width: 500px; margin: 0 auto var(--space-xl); }

/* Feature cards */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.feature-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-xl);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    transition: all 0.3s ease;
}
.feature-card:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(232,101,26,0.2);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.feature-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--orange-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-lg);
    font-size: 1.5rem;
}
.feature-card h3 { font-size: 1.05rem; margin-bottom: var(--space-sm); }
.feature-card p { font-size: 0.9rem; color: var(--grey-blue); line-height: 1.6; margin-bottom: 0; }

/* Steps */
.steps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }
.step { text-align: center; }
.step-number {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange), #d4530f);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 800;
    margin: 0 auto var(--space-lg);
    box-shadow: 0 4px 20px rgba(232,101,26,0.3);
}
.step h3 { font-size: 1.05rem; margin-bottom: var(--space-sm); }
.step p { font-size: 0.92rem; color: var(--grey-blue); max-width: 280px; margin: 0 auto; }

/* Data banner */
.data-banner { display: flex; justify-content: center; gap: var(--space-lg); padding: var(--space-xl) 0; flex-wrap: wrap; max-width: 820px; margin: 0 auto; }
.data-item { text-align: center; }
.data-value { font-size: 2.2rem; font-weight: 800; color: var(--orange); line-height: 1; margin-bottom: var(--space-xs); }
.data-label { font-size: 0.85rem; color: var(--grey-blue); margin: 0; }

/* CTA bottom */
.cta-section {
    padding: var(--space-xxxl) 0;
    text-align: center;
    background: linear-gradient(180deg, var(--marine-deeper) 0%, var(--marine-dark) 100%);
    position: relative;
}
.cta-section::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(232,101,26,0.05) 0%, transparent 70%);
    pointer-events: none;
}
.cta-section h2 { font-size: 2.2rem; margin-bottom: var(--space-md); position: relative; }
.cta-section p { font-size: 1.1rem; color: var(--grey-blue); margin-bottom: var(--space-xl); position: relative; }

/* Ko-fi / Soutien */
.btn-kofi {
    background: #FF5E5B;
    color: var(--white);
    box-shadow: 0 4px 14px rgba(255,94,91,0.3);
    gap: var(--space-sm);
}
.btn-kofi:hover {
    background: #e54542;
    color: var(--white);
    box-shadow: 0 6px 20px rgba(255,94,91,0.45);
    transform: translateY(-1px);
}
.btn-kofi svg { width: 20px; height: 20px; fill: currentColor; }
.support-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    justify-content: center;
    margin-top: var(--space-lg);
    position: relative;
}
.support-divider span {
    font-size: 0.85rem;
    color: var(--grey-blue);
}

/* ============================================================
   TOGGLE SWITCHES & MODERN CONTROLS (Settings)
   ============================================================ */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.3s ease;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--orange);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.risk-chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.risk-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: var(--grey-blue);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    user-select: none;
}
.risk-chip:hover {
    background: rgba(255,255,255,0.09);
    border-color: rgba(255,255,255,0.18);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.risk-chip:active {
    transform: scale(0.97);
    box-shadow: none;
}
.risk-chip.active {
    background: linear-gradient(135deg, #43A047, #2E7D32);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 3px 12px rgba(67,160,71,0.35);
}
.risk-chip.active:hover {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    box-shadow: 0 5px 16px rgba(67,160,71,0.45);
    transform: translateY(-1px);
}
.risk-chip-icon {
    font-size: 1.05rem;
    line-height: 1;
    filter: grayscale(0.3);
}
.risk-chip.active .risk-chip-icon {
    filter: none;
}

.pill-group {
    display: inline-flex;
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 2px;
}
.pill-btn {
    padding: 8px 18px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    background: transparent;
    color: var(--grey-blue);
    transition: all 0.25s ease;
    white-space: nowrap;
}
.pill-btn:hover {
    color: var(--white);
    background: rgba(255,255,255,0.08);
}
.pill-btn.active {
    color: var(--white);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.pill-btn.active.lvl-jaune { background: var(--vig-jaune); color: #333; }
.pill-btn.active.lvl-orange { background: var(--vig-orange); }
.pill-btn.active.lvl-rouge { background: var(--vig-rouge); }

.settings-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--grey-blue);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: var(--space-sm);
}

.vigicrues-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--space-md);
    background: rgba(42,80,128,0.12);
    border: 1px solid rgba(42,80,128,0.2);
    border-radius: var(--radius-md);
}
.vigicrues-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--grey-light);
}

.save-status {
    font-size: 0.82rem;
    transition: all 0.3s ease;
}

/* Seuil + Vigicrues aligned row */
.seuil-vigicrues-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}
.vigicrues-toggle-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Delete icon button */
.btn-icon-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--grey-blue);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    opacity: 0.65;
}
.btn-icon-delete:hover {
    background: rgba(229,57,53,0.15);
    color: var(--danger);
    opacity: 1;
    transform: scale(1.12);
}
.btn-icon-delete:active {
    transform: scale(0.9);
    background: rgba(229,57,53,0.25);
    color: var(--danger);
}

/* River / cours d'eau chips */
.river-section {
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: rgba(42,80,128,0.08);
    border: 1px solid rgba(42,80,128,0.15);
    border-radius: var(--radius-md);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.river-chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.river-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(42,80,128,0.25);
    background: rgba(42,80,128,0.12);
    color: var(--grey-blue);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    user-select: none;
}
.river-chip:hover {
    background: rgba(42,80,128,0.22);
    border-color: rgba(42,80,128,0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.river-chip:active {
    transform: scale(0.97);
    box-shadow: none;
}
.river-chip.active {
    background: linear-gradient(135deg, #1976D2, #1565C0);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 3px 12px rgba(25,118,210,0.35);
}
.river-chip.active:hover {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    box-shadow: 0 5px 16px rgba(25,118,210,0.45);
    transform: translateY(-1px);
}
.river-chip-icon {
    font-size: 1rem;
    line-height: 1;
    filter: grayscale(0.3);
}
.river-chip.active .river-chip-icon {
    filter: none;
}
.river-loading {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    font-size: 0.85rem;
    color: var(--grey-blue);
    grid-column: 1 / -1;
}

/* ---- Dept selector chips ---- */
.dept-chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}
.dept-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 11px 10px;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1.5px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.05);
    color: var(--grey-blue);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    user-select: none;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}
.dept-chip:hover {
    background: rgba(255,255,255,0.10);
    border-color: rgba(255,255,255,0.20);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.dept-chip:active {
    transform: scale(0.96);
    box-shadow: none;
}
.dept-chip-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.08);
    color: var(--grey-light);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.dept-chip-name {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}
.dept-chip-badge {
    font-size: 0.7rem;
    color: var(--success);
    flex-shrink: 0;
}
/* Selected state (orange highlight) */
.dept-chip.selected {
    background: linear-gradient(135deg, var(--orange), #D4580F);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 3px 12px rgba(232,101,26,0.4);
}
.dept-chip.selected:hover {
    background: linear-gradient(135deg, var(--orange-light), var(--orange));
    box-shadow: 0 5px 16px rgba(232,101,26,0.5);
    transform: translateY(-1px);
}
.dept-chip.selected .dept-chip-code {
    background: rgba(255,255,255,0.25);
    color: #fff;
}
/* Already added (disabled) */
.dept-chip.already-added {
    opacity: 0.45;
    cursor: default;
    border-style: dashed;
}
.dept-chip.already-added:hover {
    transform: none;
    box-shadow: none;
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.10);
}
/* Just-added animation */
.dept-chip.just-added {
    animation: chipAdded 0.5s ease;
}
@keyframes chipAdded {
    0% { transform: scale(1); }
    50% { transform: scale(0.92); background: rgba(67,160,71,0.25); }
    100% { transform: scale(1); }
}
/* ===== Dashboard KPI & Cards ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: var(--space-lg);
}
.kpi-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
}
.kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(42,80,128,0.2);
    color: var(--grey-blue);
    flex-shrink: 0;
}
.kpi-icon-ok { background: rgba(67,160,71,0.15); color: var(--success); }
.kpi-icon-alert { background: rgba(229,57,53,0.15); color: var(--danger); }
.kpi-content { display: flex; flex-direction: column; min-width: 0; }
.kpi-value { font-size: 1.3rem; font-weight: 700; color: var(--white); line-height: 1.2; }
.kpi-label { font-size: 0.72rem; color: var(--grey-blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dash-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: var(--space-lg) 0 var(--space-sm);
    color: var(--white);
}
.dash-loading {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    font-size: 0.85rem;
    color: var(--grey-blue);
}
.dash-empty {
    padding: var(--space-md);
    font-size: 0.88rem;
    color: var(--grey-blue);
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.06);
}
.dash-calm {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    font-size: 0.88rem;
    color: var(--success);
    background: rgba(67,160,71,0.06);
    border-radius: var(--radius-md);
    border: 1px solid rgba(67,160,71,0.15);
}

/* Dept status cards */
.dept-grid { display: flex; flex-direction: column; gap: 10px; }
.dept-status-card {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.06);
}
.dept-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: 4px;
}
.dept-status-header strong { font-size: 0.92rem; color: var(--white); }
.dept-status-risks {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.mini-risk-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(255,255,255,0.08);
    color: var(--grey-light);
}
.mini-risk-chip.level-2 { background: rgba(253,216,53,0.15); color: #FDD835; }
.mini-risk-chip.level-3 { background: rgba(251,140,0,0.15); color: #FB8C00; }
.mini-risk-chip.level-4 { background: rgba(229,57,53,0.15); color: #E53935; }
.dept-status-calm {
    font-size: 0.82rem;
    color: var(--success);
    margin-top: 2px;
}
.dept-status-bulletin {
    font-size: 0.78rem;
    color: var(--grey-blue);
    margin-top: 6px;
    line-height: 1.4;
}

/* Vigicrues alert cards */
.vigicrues-alert-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}
.vigicrues-alert-info { display: flex; flex-direction: column; gap: 2px; }
.vigicrues-alert-info strong { font-size: 0.88rem; color: var(--white); }
.vigicrues-alert-info small { font-size: 0.72rem; color: var(--grey-blue); }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}
.timeline-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.timeline-text { font-size: 0.82rem; color: var(--grey-light); }
.timeline-date { font-size: 0.7rem; color: var(--grey-blue); }

/* Vigilance badges */
.vigilance-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.vigilance-badge.level-1 { background: rgba(67,160,71,0.15); color: #43A047; }
.vigilance-badge.level-2 { background: rgba(253,216,53,0.2); color: #F9A825; }
.vigilance-badge.level-3 { background: rgba(251,140,0,0.2); color: #FB8C00; }
.vigilance-badge.level-4 { background: rgba(229,57,53,0.2); color: #E53935; }

.source-mf {
    font-size: 0.7rem;
    color: var(--grey-blue);
    opacity: 0.6;
    margin-top: var(--space-lg);
    text-align: center;
}

.dept-counter {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--grey-blue);
    white-space: nowrap;
}

/* ===== Accordion départements ===== */
.sub-header {
    display: flex;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--light-grey);
    transition: background 0.2s;
    gap: var(--space-sm);
}
.sub-header:hover {
    background: rgba(42,80,128,0.04);
}
.sub-header-top {
    flex: 1;
    min-width: 0;
}
.sub-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
}
.sub-header-left .card-title {
    margin: 0;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sub-chevron {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--grey-blue);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}
.is-collapsed .sub-chevron {
    transform: rotate(-90deg);
}
.sub-summary {
    font-size: 0.78rem;
    color: var(--grey-blue);
    padding-left: 22px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sub-body {
    padding: var(--space-lg);
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, padding 0.3s ease;
    overflow: hidden;
    opacity: 1;
}
.sub-body.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

/* ===== Autosave bar ===== */
.autosave-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: var(--space-sm) var(--space-lg);
    border-top: 1px solid var(--light-grey);
    min-height: 36px;
}
.autosave-bar .save-status {
    font-size: 0.82rem;
    color: var(--grey-blue);
    transition: color 0.3s;
}
.autosave-bar .save-status.unsaved {
    color: var(--orange);
    animation: pulse-unsaved 1.5s ease-in-out infinite;
}
@keyframes pulse-unsaved {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== River controls (tout/aucun + compteur) ===== */
.river-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}
.river-controls-btns {
    display: flex;
    gap: var(--space-xs);
}
.river-controls-btns button {
    background: transparent;
    border: 1px solid var(--light-grey);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.78rem;
    cursor: pointer;
    color: var(--dark-blue);
    transition: all 0.2s;
}
.river-controls-btns button:hover {
    background: var(--dark-blue);
    color: #fff;
    border-color: var(--dark-blue);
}
.river-counter {
    font-size: 0.8rem;
    color: var(--grey-blue);
    font-weight: 500;
}

/* ===== Notification test card ===== */
.notif-test-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
}
.notif-test-info {
    font-size: 0.9rem;
    color: var(--grey-blue);
}
.notif-test-result {
    font-size: 0.85rem;
    margin-top: var(--space-xs);
}

/* ===== App-like behavior ===== */
html, body {
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}
body {
    touch-action: manipulation;
}
/* Safe area padding for notched devices */
.page-content {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ===== Bottom Navigation Bar (mobile) ===== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(15, 32, 52, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0));
}
.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    text-decoration: none;
    color: var(--grey-blue);
    font-size: 0.65rem;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
    min-width: 56px;
}
.bottom-nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.2s;
}
.bottom-nav-item.active {
    color: var(--orange);
}
.bottom-nav-item.active svg {
    stroke-width: 2.2;
}
.bottom-nav-item:active {
    transform: scale(0.92);
}

/* ===== Pull-to-refresh indicator ===== */
.ptr-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    z-index: 999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--dark-blue);
    border: 2px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.ptr-indicator.visible {
    transform: translateX(-50%) translateY(70px);
}
.ptr-indicator.refreshing {
    transform: translateX(-50%) translateY(70px);
}
.ptr-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: var(--orange);
    border-radius: 50%;
}
.ptr-indicator.refreshing .ptr-spinner {
    animation: spin 0.8s linear infinite;
}
.ptr-arrow {
    color: var(--orange);
    font-size: 1.1rem;
    transition: transform 0.2s;
}

/* Responsive */
@media (max-width: 768px) {
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.3rem; }
    .hero-title { font-size: 2.5rem; }
    .hero .tagline { font-size: 1.1rem; }
    .hero { padding: var(--space-xxl) 0 var(--space-xl); }
    .section-title { font-size: 1.6rem; }
    .landing-section { padding: var(--space-xxl) 0; }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
    .steps-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
    /* Bottom nav visible on mobile */
    .bottom-nav { display: block; }
    body.has-bottom-nav { padding-bottom: 68px; }
    body.has-bottom-nav .footer { display: none; }
    /* Hide top navbar links, keep only brand */
    .navbar-toggle { display: none; }
    .navbar-nav { display: none !important; }
    .navbar { padding: 8px 0; }
    #map { height: 380px; }
    .footer-content { flex-direction: column; gap: var(--space-lg); }
    .data-banner { gap: var(--space-xl); }
    .sub-summary { font-size: 0.75rem; }
    .sub-header { padding: var(--space-sm) var(--space-md); }
    .sub-body { padding: var(--space-md); }
    .autosave-bar { padding: var(--space-xs) var(--space-md); }
}

@media (max-width: 480px) {
    .container { padding: 0 var(--space-md); }
    .card { padding: var(--space-md); }
    .hero-title { font-size: 2rem; }
    .hero .hero-desc { font-size: 0.95rem; }
    .cta-section h2 { font-size: 1.6rem; }
    .feature-grid { grid-template-columns: 1fr; }
    .pill-btn { padding: 7px 12px; font-size: 0.78rem; }
    .risk-chip { padding: 8px 10px; font-size: 0.78rem; }
    .risk-chip-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .river-chip { padding: 8px 10px; font-size: 0.78rem; }
    .river-chip-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .dept-chip { padding: 10px 8px; font-size: 0.78rem; gap: 6px; }
    .dept-chip-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 6px; }
    .dept-chip-code { min-width: 24px; height: 20px; padding: 0 4px; font-size: 0.68rem; }
    .seuil-vigicrues-row { flex-direction: column; align-items: flex-start; }
    .vigicrues-toggle-wrapper { align-items: flex-start; }
    .sub-header { padding: var(--space-sm) var(--space-md); }
    .sub-summary { white-space: normal; padding-left: 20px; font-size: 0.72rem; }
    .notif-test-card { flex-direction: column; align-items: flex-start; }
    .kpi-grid { grid-template-columns: 1fr; gap: 8px; }
    .kpi-card { padding: 10px 14px; }
    .kpi-value { font-size: 1.1rem; }
    .dept-status-header { flex-direction: column; align-items: flex-start; gap: 4px; }
}
