:root {
  --green: #2d6a4f;
  --green-dark: #1b4332;
  --green-light: #40916c;
  --green-pale: #d8f3dc;
  --blue: #1d3557;
  --blue-light: #457b9d;
  --gray: #6c757d;
  --gray-light: #f1f3f5;
  --gray-border: #dee2e6;
  --bg: #f8faf9;
  --white: #ffffff;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 12px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: #212529;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; }

/* ============ BOUTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: 8px; font-size: 15px; font-weight: 600;
  transition: all .2s; white-space: nowrap;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--green); border: 2px solid var(--green); }
.btn-outline:hover { background: var(--green-pale); }
.btn-ghost { background: var(--gray-light); color: #333; }
.btn-ghost:hover { background: #e2e6ea; }
.btn-danger { background: #d73027; color: #fff; }
.btn-danger:hover { background: #b02418; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ============ LANDING ============ */
.landing-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 6%; background: #fff; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100;
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; color: var(--green); }
.logo i { font-size: 26px; }
.nav-links { display: flex; gap: 14px; align-items: center; }

.hero {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 50%, var(--blue-light) 100%);
  color: #fff; padding: 90px 6% 100px; text-align: center;
}
.hero h1 { font-size: clamp(32px, 5vw, 52px); font-weight: 800; margin-bottom: 18px; line-height: 1.15; }
.hero p { font-size: clamp(16px, 2.2vw, 20px); max-width: 680px; margin: 0 auto 32px; opacity: .95; }
.hero-cta { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.hero .btn-primary { background: #fff; color: var(--green-dark); }
.hero .btn-primary:hover { background: var(--green-pale); }
.hero .btn-outline { color: #fff; border-color: #fff; }
.hero .btn-outline:hover { background: rgba(255,255,255,.15); }

.features { padding: 70px 6%; max-width: 1100px; margin: 0 auto; }
.features h2 { text-align: center; font-size: 32px; color: var(--green-dark); margin-bottom: 12px; }
.features .subtitle { text-align: center; color: var(--gray); margin-bottom: 48px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 28px; }
.feature-card {
  background: #fff; padding: 34px 28px; border-radius: var(--radius); box-shadow: var(--shadow);
  text-align: center; transition: transform .2s;
}
.feature-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.feature-icon {
  width: 64px; height: 64px; border-radius: 16px; background: var(--green-pale); color: var(--green);
  display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 18px;
}
.feature-card h3 { font-size: 19px; margin-bottom: 10px; color: var(--blue); }
.feature-card p { color: var(--gray); font-size: 15px; }

.dpe-scale-section { background: #fff; padding: 60px 6%; }
.dpe-scale-section h2 { text-align:center; font-size: 28px; color: var(--green-dark); margin-bottom: 36px; }
.dpe-scale { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.dpe-row { display: flex; align-items: center; gap: 14px; }
.dpe-letter { width: 50px; height: 38px; border-radius: 6px; color: #fff; font-weight: 800; display:flex; align-items:center; justify-content:center; }
.dpe-range { color: var(--gray); font-size: 14px; }

.landing-footer { background: var(--green-dark); color: #fff; text-align: center; padding: 36px 6%; margin-top: 40px; }

/* ============ AUTH ============ */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--green-dark), var(--blue-light)); padding: 20px;
}
.auth-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 420px; }
.auth-card .logo { justify-content: center; margin-bottom: 8px; }
.auth-card h2 { text-align: center; margin-bottom: 6px; color: var(--blue); }
.auth-card .sub { text-align: center; color: var(--gray); margin-bottom: 26px; font-size: 14px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; color: #333; }
.form-group input, .form-group select {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--gray-border); border-radius: 8px; font-size: 15px; transition: border .2s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--green); }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--gray); }
.auth-switch a { color: var(--green); font-weight: 600; }

/* ============ DASHBOARD ============ */
.dash { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: var(--green-dark); color: #fff; display: flex; flex-direction: column;
  position: fixed; height: 100vh; top: 0; left: 0; z-index: 50; transition: transform .3s;
}
.sidebar .logo { color: #fff; padding: 24px 22px; border-bottom: 1px solid rgba(255,255,255,.12); font-size: 19px; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 8px;
  color: rgba(255,255,255,.85); font-weight: 500; transition: all .2s;
}
.sidebar-nav a i { width: 20px; text-align: center; }
.sidebar-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav a.active { background: var(--green-light); color: #fff; }
.sidebar-user { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.sidebar-user strong { display: block; font-size: 14px; }
.sidebar-user span { opacity: .75; }

.main { flex: 1; margin-left: 250px; padding: 28px 36px; max-width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.topbar h1 { font-size: 26px; color: var(--green-dark); }
.menu-toggle { display: none; background: var(--green); color: #fff; width: 42px; height: 42px; border-radius: 8px; font-size: 18px; }

.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; margin-bottom: 24px; }
.card h2 { font-size: 19px; color: var(--blue); margin-bottom: 18px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* Stats cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 8px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display:flex; align-items:center; justify-content:center; font-size: 22px; color:#fff; }
.stat-info .value { font-size: 26px; font-weight: 800; color: var(--blue); }
.stat-info .label { color: var(--gray); font-size: 13px; }

/* ============ RÉSULTAT DPE ============ */
.result-grid { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
.dpe-badge-box { text-align: center; }
.dpe-badge {
  width: 160px; height: 160px; border-radius: 24px; margin: 0 auto 14px; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 96px; font-weight: 900;
  box-shadow: var(--shadow-lg);
}
.dpe-label { font-size: 15px; color: var(--gray); }
.metric-list { display: grid; gap: 14px; }
.metric { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--gray-light); border-radius: 10px; }
.metric .m-label { color: var(--gray); font-size: 14px; }
.metric .m-value { font-weight: 700; font-size: 18px; color: var(--blue); }

.energy-bar { height: 30px; border-radius: 8px; background: linear-gradient(to right, #1a9850, #66bd63, #a6d96a, #fee08b, #fdae61, #f46d43, #d73027); position: relative; margin: 16px 0 8px; }
.energy-marker { position: absolute; top: -6px; width: 4px; height: 42px; background: #000; border-radius: 2px; }
.energy-marker::after { content: attr(data-val); position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; white-space: nowrap; }

.recos { list-style: none; display: grid; gap: 12px; }
.recos li { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; background: var(--green-pale); border-left: 4px solid var(--green); border-radius: 8px; font-size: 15px; }
.recos li i { color: var(--green); margin-top: 3px; }

.comparison { padding: 18px; background: #eef6ff; border-radius: 10px; border-left: 4px solid var(--blue-light); }

/* ============ TABLE ============ */
.filters { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.filters select { padding: 9px 14px; border: 1.5px solid var(--gray-border); border-radius: 8px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--gray-border); font-size: 14px; }
th { background: var(--gray-light); font-weight: 700; color: var(--blue); }
tbody tr { cursor: pointer; transition: background .15s; }
tbody tr:hover { background: var(--green-pale); }
.dpe-pill { display: inline-block; min-width: 28px; padding: 3px 10px; border-radius: 6px; color: #fff; font-weight: 800; text-align: center; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--gray); }
.empty-state i { font-size: 48px; color: var(--gray-border); margin-bottom: 16px; }

/* ============ TOAST ============ */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 14px 20px; border-radius: 10px; color: #fff; box-shadow: var(--shadow-lg); font-weight: 600;
  display: flex; align-items: center; gap: 10px; min-width: 260px; animation: slideIn .3s; max-width: 360px;
}
.toast.success { background: var(--green); }
.toast.error { background: #d73027; }
.toast.info { background: var(--blue-light); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ MODAL ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal { background: #fff; border-radius: var(--radius); padding: 28px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 12px; color: var(--blue); }
.modal p { color: var(--gray); margin-bottom: 22px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

.loading { display: flex; justify-content: center; padding: 60px; color: var(--green); font-size: 28px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .result-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 18px; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .nav-links .btn span { display: none; }
}

/* Impression / Export PDF */
@media print {
  .sidebar, .topbar, .form-actions, .menu-toggle, #toast-container, .no-print { display: none !important; }
  .main { margin-left: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
