:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e4e9f1;
  --text: #172033;
  --muted: #6a7588;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --accent: #f59e0b;
  --accent-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --sidebar-bg: #111827;
  --sidebar-text: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
img, video { max-width: 100%; display: block; }

.app { display: flex; height: 100vh; }

/* ---------------------- Sidebar ---------------------- */
.sidebar {
  width: 250px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0; height: 100vh;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px; border-bottom: 1px solid #1f2937; }
.brand-mark { font-size: 26px; }
.brand h1 { margin: 0; font-size: 17px; color: #fff; letter-spacing: -.2px; }
.brand p { margin: 0; font-size: 11px; color: #8b95a7; }
#nav { display: flex; flex-direction: column; padding: 10px; gap: 2px; flex: 1; overflow-y: auto; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px;
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--sidebar-text);
  transition: background .12s, color .12s;
}
#nav a:hover { background: #1f2937; color: #fff; }
#nav a.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.35); }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11px; color: #8b95a7; border-top: 1px solid #1f2937; }

/* ---------------------- Hamburger (mobile) ---------------------- */
.hamburger {
  display: none; background: transparent; border: none; cursor: pointer; padding: 8px;
  color: var(--text); font-size: 22px; line-height: 1;
}
.overlay { display: none; }
@media (max-width: 860px) {
  .hamburger { display: inline-flex; align-items: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .overlay { position: fixed; inset: 0; background: rgba(15,20,35,.45); z-index: 55; }
  .overlay.show { display: block; }
}

/* ---------------------- Content ---------------------- */
.content { flex: 1; overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 13px 20px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
#view-title { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.tenant-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.view { padding: 22px; max-width: 1120px; width: 100%; margin: 0 auto; }

/* ---------------------- Cards & KPI ---------------------- */
.grid { display: grid; gap: 14px; }
.cols-5 { grid-template-columns: repeat(5, 1fr); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.4px; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
h3.section { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 24px 0 10px; font-weight: 700; }

/* ---------------------- Tables ---------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; background: #fafbfd; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------- Chips / badges ---------------------- */
.chip { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--accent-soft); color: #b45309; }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--primary-soft); color: var(--primary); }

/* ---------------------- Forms ---------------------- */
.form-row { display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; align-items: flex-end; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px;
  background: #fff; color: var(--text); width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 70px; }
.field { flex: 1; min-width: 140px; }
button {
  background: var(--primary); color: #fff; border: none; padding: 9px 15px; border-radius: 9px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s, transform .05s;
}
button:hover { background: var(--primary-dark); }
button:active { transform: translateY(1px); }
button.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover { background: #f5f7fb; }
button.danger { background: var(--danger); }
button.small { padding: 6px 11px; font-size: 12px; }

.alert-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.alert-item:last-child { border-bottom: none; }
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 26px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; }

/* ---------------------- Bar chart ---------------------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.bar-label { width: 160px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; height: 14px; background: #eef1f5; border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 7px; background: var(--primary); }
.bar-value { width: 112px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ---------------------- Média / éditeur ---------------------- */
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 9px; background: #eef1f5; }
.media-preview { margin: 10px 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.media-preview img, .media-preview video { width: 100%; max-height: 280px; object-fit: contain; background: #0f172a; }
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center;
  color: var(--muted); cursor: pointer; transition: border-color .12s, background .12s; font-size: 13px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input { display: none; }
.pub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 6px; }
.pub-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.pub-media img, .pub-media video { width: 100%; height: 150px; object-fit: cover; background: #0f172a; display: block; }
.pub-body { padding: 12px 14px; }
.pub-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.pub-text { font-size: 12px; color: var(--muted); }

/* ---------------------- Landing / Auth ---------------------- */
.landing-body { background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #312e81 100%); }
.landing { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.landing-inner { display: flex; gap: 48px; max-width: 1020px; width: 100%; align-items: center; }
.landing-hero { flex: 1; color: #e3e9f3; }
.brand-light { display: flex; gap: 11px; align-items: center; }
.brand-light h1 { color: #fff; margin: 0; }
.brand-light p { color: #93a1b8; margin: 0; font-size: 12px; }
.landing-hero h2 { font-size: 34px; line-height: 1.2; color: #fff; margin: 26px 0 14px; letter-spacing: -.5px; }
.lede { color: #c3cddc; font-size: 15px; line-height: 1.6; max-width: 500px; }
.lede strong { color: #fff; }
.features { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 9px; }
.features li { color: #c3cddc; font-size: 14px; }
.landing-card {
  width: 400px; background: #fff; border-radius: 18px; padding: 28px;
  box-shadow: 0 30px 70px rgba(0,0,0,.45);
}
.auth-tabs { display: flex; gap: 6px; background: #eef1f5; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tabs button {
  flex: 1; background: transparent; color: var(--muted); border: none; padding: 9px;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.auth-tabs button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.auth-form .field { margin-bottom: 13px; min-width: 0; width: 100%; }
.btn-full { width: 100%; padding: 12px; margin-top: 6px; font-size: 14px; }
.form-error { color: var(--danger); font-size: 12px; min-height: 16px; margin: 2px 0 6px; }
.landing .hint { text-align: center; margin-top: 12px; display: block; }

/* ---------------------- Responsive ---------------------- */
@media (max-width: 1080px) {
  .cols-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .landing-inner { flex-direction: column; gap: 28px; }
  .landing-hero h2 { font-size: 27px; }
  .landing-card { width: 100%; }
  .cols-5, .cols-3 { grid-template-columns: 1fr 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
  .view { padding: 16px; }
  .tenant-name { display: none; }
}
@media (max-width: 480px) {
  .cols-5, .cols-3 { grid-template-columns: 1fr; }
  .bar-label { width: 110px; }
  .bar-value { width: 88px; }
}
