/*
 * ONEAD — Usine de Dessalement
 * Thème Eau / Supervision industrielle
 * Version design VF 2.0 — thème institutionnel eau et supervision
 */

:root {
  color-scheme: light;
  --onead: #087f9c;
  --onead-dark: #07546d;
  --onead-deep: #06384d;
  --ocean: #0369a1;
  --aqua: #20c9d8;
  --aqua-soft: #9cecf2;
  --sky: #eaf9fc;
  --success: #159570;
  --warning: #d38b18;
  --danger: #d74b5b;
  --info: #1e8fbd;

  --bg: #f2f8fa;
  --bg-elevated: #f8fcfd;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --panel-soft: #f5fbfc;
  --text: #143447;
  --heading: #082f45;
  --muted: #66808f;
  --line: #d9e8ed;
  --line-strong: #c3dce3;

  --sidebar-width: 270px;
  --topbar-height: 72px;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 5px 16px rgba(16, 77, 94, 0.06);
  --shadow: 0 14px 38px rgba(9, 74, 94, 0.09);
  --shadow-lg: 0 28px 70px rgba(5, 61, 82, 0.14);
  --focus: 0 0 0 0.22rem rgba(32, 201, 216, 0.2);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-bs-theme="dark"] {
  color-scheme: dark;
  --onead: #27bfd1;
  --onead-dark: #1594ad;
  --onead-deep: #062a3a;
  --ocean: #38a8dc;
  --aqua: #42d6df;
  --aqua-soft: #8de7eb;
  --sky: #0d2934;

  --bg: #06141d;
  --bg-elevated: #091c27;
  --panel: rgba(12, 34, 45, 0.94);
  --panel-solid: #0d2632;
  --panel-soft: #102e3a;
  --text: #e7f4f7;
  --heading: #f5fcfd;
  --muted: #92acb8;
  --line: #24434f;
  --line-strong: #315563;

  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.18);
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 30px 76px rgba(0, 0, 0, 0.34);
  --focus: 0 0 0 0.22rem rgba(66, 214, 223, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 92% 2%, rgba(32, 201, 216, 0.11), transparent 27rem),
    radial-gradient(circle at 30% 100%, rgba(3, 105, 161, 0.07), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0 0 auto var(--sidebar-width);
  height: 210px;
  background: linear-gradient(180deg, rgba(32, 201, 216, 0.035), transparent);
  pointer-events: none;
  content: "";
  z-index: -1;
}

::selection {
  background: rgba(32, 201, 216, 0.28);
  color: var(--heading);
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(102, 128, 143, 0.38);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

a,
button,
input,
select,
textarea,
.kpi,
.panel,
.quick-card {
  transition:
    color 180ms var(--ease),
    background-color 180ms var(--ease),
    border-color 180ms var(--ease),
    box-shadow 220ms var(--ease),
    transform 220ms var(--ease),
    opacity 180ms var(--ease);
}

a {
  color: var(--onead);
}

a:hover {
  color: var(--onead-dark);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--heading);
  letter-spacing: -0.02em;
}

.app-shell {
  min-height: 100vh;
}

/* Navigation latérale */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: 22px 14px 28px;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 10% 4%, rgba(77, 226, 235, 0.16), transparent 13rem),
    radial-gradient(circle at 100% 76%, rgba(1, 132, 169, 0.19), transparent 18rem),
    linear-gradient(165deg, #073f55 0%, #052f42 46%, #042737 100%);
  border-right: 1px solid rgba(143, 226, 235, 0.13);
  box-shadow: 14px 0 42px rgba(4, 43, 58, 0.11);
  color: #fff;
  z-index: 1040;
}

.sidebar::before,
.sidebar::after {
  position: absolute;
  border: 1px solid rgba(153, 236, 241, 0.1);
  border-radius: 50%;
  pointer-events: none;
  content: "";
}

.sidebar::before {
  width: 220px;
  height: 220px;
  top: -130px;
  right: -110px;
}

.sidebar::after {
  width: 300px;
  height: 300px;
  right: -210px;
  bottom: 4%;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 66px;
  margin: 0 3px 19px;
  padding: 10px 12px;
  gap: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(196, 244, 247, 0.12);
  border-radius: 18px;
  color: #fff;
  text-decoration: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand::after {
  position: absolute;
  width: 90px;
  height: 90px;
  top: -54px;
  right: -25px;
  background: rgba(50, 211, 222, 0.1);
  border-radius: 50%;
  content: "";
}

.brand:hover {
  border-color: rgba(196, 244, 247, 0.25);
  color: #fff;
  transform: translateY(-1px);
}

.brand > span {
  min-width: 0;
  position: relative;
  z-index: 1;
}

.brand strong,
.guest-brand strong {
  display: block;
  font-size: 1.27rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  line-height: 1.1;
}

.brand small,
.guest-brand small {
  display: block;
  margin-top: 4px;
  color: rgba(220, 247, 249, 0.72);
  font-size: 0.73rem;
  letter-spacing: 0.03em;
}

.brand-logo {
  position: relative;
  z-index: 1;
  width: 48px;
  height: 48px;
  max-width: 48px;
  max-height: 48px;
  padding: 4px;
  flex: 0 0 48px;
  object-fit: contain;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.water-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  background: linear-gradient(145deg, #45dbe3, #0386b0);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 52% 48% 55% 45% / 62% 58% 42% 38%;
  box-shadow: 0 8px 22px rgba(20, 205, 218, 0.28);
  color: #fff;
  font-weight: 900;
}

.sidebar nav {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 13px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #c9e5eb;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}

.sidebar nav a::before {
  width: 5px;
  height: 5px;
  margin-right: 11px;
  flex: 0 0 5px;
  background: rgba(151, 223, 230, 0.48);
  border-radius: 50%;
  content: "";
  transition: 180ms var(--ease);
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(210, 247, 249, 0.07);
  color: #fff;
  transform: translateX(2px);
}

.sidebar nav a.active {
  background: linear-gradient(90deg, rgba(41, 199, 211, 0.24), rgba(255, 255, 255, 0.08));
  border-color: rgba(135, 231, 236, 0.16);
  box-shadow:
    inset 3px 0 0 #44d5dd,
    0 8px 22px rgba(0, 0, 0, 0.08);
  color: #fff;
  font-weight: 650;
}

.sidebar nav a.active::before {
  width: 7px;
  height: 7px;
  flex-basis: 7px;
  background: #78e6eb;
  box-shadow: 0 0 0 4px rgba(84, 218, 226, 0.12);
}

.nav-label {
  margin-top: 11px;
  padding: 17px 13px 7px;
  color: #73adba;
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Zone principale */
.main-area {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(195, 220, 227, 0.82);
  box-shadow: 0 8px 24px rgba(10, 70, 89, 0.035);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

[data-bs-theme="dark"] .topbar {
  background: rgba(8, 25, 35, 0.84);
  border-bottom-color: rgba(41, 74, 87, 0.88);
}

.topbar .ms-auto {
  min-width: 0;
}

.user-pill {
  position: relative;
  display: flex;
  min-width: 148px;
  padding: 3px 0 3px 14px;
  flex-direction: column;
  border-left: 1px solid var(--line);
  color: var(--heading);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
}

.user-pill small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 550;
}

.theme-select {
  width: 94px;
}

.page {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 30px clamp(20px, 2.2vw, 38px) 52px;
}

.page-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  margin-bottom: 23px;
  padding-left: 17px;
}

.page-head::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--aqua), var(--ocean));
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(32, 201, 216, 0.24);
  content: "";
}

.page-head h1 {
  margin: 0;
  color: var(--heading);
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  font-weight: 800;
  line-height: 1.18;
}

.page-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Boutons et contrôles */
.btn {
  border-radius: 10px;
  font-weight: 650;
  letter-spacing: 0.005em;
  box-shadow: none;
}

.btn-sm {
  border-radius: 9px;
}

.btn-primary {
  --bs-btn-bg: #087f9c;
  --bs-btn-border-color: #087f9c;
  --bs-btn-hover-bg: #066b86;
  --bs-btn-hover-border-color: #066b86;
  --bs-btn-active-bg: #075b73;
  --bs-btn-active-border-color: #075b73;
  --bs-btn-disabled-bg: #70aebd;
  --bs-btn-disabled-border-color: #70aebd;
  box-shadow: 0 8px 18px rgba(8, 127, 156, 0.15);
}

.btn-primary:hover {
  box-shadow: 0 10px 22px rgba(8, 127, 156, 0.24);
  transform: translateY(-1px);
}

.btn-outline-primary {
  --bs-btn-color: var(--onead);
  --bs-btn-border-color: rgba(8, 127, 156, 0.38);
  --bs-btn-hover-bg: var(--onead);
  --bs-btn-hover-border-color: var(--onead);
}

.btn-outline-secondary {
  --bs-btn-color: var(--text);
  --bs-btn-border-color: var(--line-strong);
  --bs-btn-hover-bg: var(--panel-soft);
  --bs-btn-hover-border-color: var(--onead);
  --bs-btn-hover-color: var(--heading);
}

.btn-outline-danger {
  --bs-btn-color: var(--danger);
  --bs-btn-border-color: rgba(215, 75, 91, 0.42);
  --bs-btn-hover-bg: var(--danger);
  --bs-btn-hover-border-color: var(--danger);
}

.form-control,
.form-select {
  min-height: 42px;
  background-color: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
}

.form-control-sm,
.form-select-sm {
  min-height: 34px;
}

.form-control:hover,
.form-select:hover {
  border-color: rgba(8, 127, 156, 0.48);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  background-color: var(--panel-solid);
  border-color: var(--aqua);
  box-shadow: var(--focus);
  color: var(--text);
}

.form-control::placeholder {
  color: var(--muted);
  opacity: 0.72;
}

textarea.form-control {
  min-height: 110px;
}

label,
.form-label {
  color: var(--heading);
  font-size: 0.83rem;
  font-weight: 650;
}

.form-text {
  color: var(--muted);
}

.alert {
  border: 1px solid transparent;
  border-radius: 13px;
  box-shadow: var(--shadow-sm);
  font-size: 0.88rem;
}

.alert-success {
  background: rgba(21, 149, 112, 0.11);
  border-color: rgba(21, 149, 112, 0.22);
  color: var(--text);
}

.alert-warning {
  background: rgba(211, 139, 24, 0.12);
  border-color: rgba(211, 139, 24, 0.25);
  color: var(--text);
}

.alert-danger {
  background: rgba(215, 75, 91, 0.11);
  border-color: rgba(215, 75, 91, 0.23);
  color: var(--text);
}

/* Cartes KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 15px;
}

.kpi {
  position: relative;
  display: flex;
  min-height: 124px;
  padding: 19px 18px 17px;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), transparent 50%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  isolation: isolate;
}

.kpi::before {
  position: absolute;
  top: 0;
  right: 18px;
  left: 18px;
  height: 3px;
  background: linear-gradient(90deg, var(--aqua), rgba(32, 201, 216, 0));
  border-radius: 0 0 999px 999px;
  content: "";
  opacity: 0.7;
}

.kpi::after {
  position: absolute;
  width: 96px;
  height: 96px;
  right: -53px;
  bottom: -57px;
  background: rgba(32, 201, 216, 0.07);
  border: 1px solid rgba(32, 201, 216, 0.08);
  border-radius: 50%;
  content: "";
  z-index: -1;
}

.kpi:hover {
  border-color: rgba(32, 201, 216, 0.36);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.kpi span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.075em;
  line-height: 1.35;
  text-transform: uppercase;
}

.kpi strong {
  margin-top: 13px;
  color: var(--heading);
  font-size: clamp(1.23rem, 1.6vw, 1.62rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.kpi.primary {
  background:
    radial-gradient(circle at 92% 10%, rgba(130, 238, 241, 0.25), transparent 45%),
    linear-gradient(140deg, #087f9c 0%, #056d91 56%, #07536f 100%);
  border-color: rgba(95, 226, 233, 0.26);
  box-shadow: 0 16px 34px rgba(5, 108, 136, 0.23);
  color: #fff;
}

.kpi.primary::before {
  background: linear-gradient(90deg, #8df3f4, rgba(255, 255, 255, 0));
}

.kpi.primary::after {
  width: 120px;
  height: 120px;
  right: -60px;
  bottom: -71px;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.kpi.primary span {
  color: #c8f7f8;
}

.kpi.primary strong {
  color: #fff;
}

/* Panneaux et graphiques */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(290px, 0.8fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  position: relative;
  padding: 21px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.panel-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  margin-bottom: 17px;
  gap: 14px;
}

.panel h2,
.panel-head h2 {
  margin: 0;
  color: var(--heading);
  font-size: 1rem;
  font-weight: 760;
  letter-spacing: -0.015em;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.77rem;
}

.chart-panel {
  min-height: 410px;
}

.chart-panel canvas,
.panel canvas {
  width: 100% !important;
  max-height: 330px;
}

.status-list {
  display: flex;
  flex-direction: column;
}

.status-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 55px;
  padding: 13px 3px;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.status-list > div:last-child {
  border-bottom: 0;
}

.status-list span {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-list strong {
  min-width: 38px;
  padding: 5px 9px;
  background: rgba(8, 127, 156, 0.08);
  border: 1px solid rgba(8, 127, 156, 0.09);
  border-radius: 9px;
  color: var(--heading);
  font-size: 0.88rem;
  text-align: center;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.comparison-grid > div {
  position: relative;
  display: flex;
  min-height: 112px;
  padding: 16px;
  overflow: hidden;
  flex-direction: column;
  background: linear-gradient(145deg, var(--panel-soft), var(--panel-solid));
  border: 1px solid var(--line);
  border-radius: 14px;
}

.comparison-grid > div::after {
  position: absolute;
  width: 52px;
  height: 52px;
  right: -28px;
  bottom: -28px;
  background: rgba(32, 201, 216, 0.09);
  border-radius: 50%;
  content: "";
}

.comparison-grid > div:hover {
  border-color: rgba(32, 201, 216, 0.38);
  transform: translateY(-2px);
}

.comparison-grid span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 730;
  letter-spacing: 0.05em;
  line-height: 1.35;
  text-transform: uppercase;
}

.comparison-grid strong {
  margin: 8px 0 4px;
  color: var(--heading);
  font-size: 1.22rem;
  font-weight: 780;
}

.comparison-grid small {
  color: var(--muted);
  font-size: 0.73rem;
}

/* Actions rapides */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 19px;
}

.quick-card {
  position: relative;
  display: flex;
  min-height: 110px;
  padding: 19px 19px 17px 73px;
  overflow: hidden;
  flex-direction: column;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-decoration: none;
}

.quick-card::before {
  position: absolute;
  left: 19px;
  width: 39px;
  height: 48px;
  background: linear-gradient(155deg, rgba(32, 201, 216, 0.22), rgba(3, 105, 161, 0.1));
  border: 1px solid rgba(32, 201, 216, 0.22);
  border-radius: 55% 45% 55% 45% / 65% 60% 40% 35%;
  content: "";
}

.quick-card::after {
  position: absolute;
  left: 34px;
  width: 9px;
  height: 9px;
  background: var(--aqua);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(32, 201, 216, 0.1);
  content: "";
}

.quick-card:hover {
  border-color: rgba(32, 201, 216, 0.42);
  box-shadow: var(--shadow);
  color: var(--heading);
  transform: translateY(-3px);
}

.quick-card strong {
  color: var(--heading);
  font-size: 0.95rem;
}

.quick-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.77rem;
}

/* Filtres, tableaux et données */
.filter-bar {
  display: flex;
  align-items: flex-end;
  padding: 15px;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
}

.filter-bar.compact {
  padding: 9px;
}

.filter-bar label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.table-responsive {
  border-radius: 13px;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  padding: 12px 13px;
  background: transparent;
  border-bottom-color: var(--line);
  color: var(--text);
  vertical-align: middle;
}

.table thead th,
.data-table th {
  padding-top: 11px;
  padding-bottom: 11px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody tr:hover > * {
  background: rgba(32, 201, 216, 0.045);
}

.data-table td {
  min-width: 110px;
  max-width: 320px;
  font-size: 0.81rem;
}

.pagination {
  gap: 4px;
}

.page-link {
  background: var(--panel-solid);
  border-color: var(--line);
  border-radius: 9px !important;
  color: var(--onead);
}

.page-link:hover,
.page-link:focus {
  background: var(--panel-soft);
  border-color: var(--aqua);
  box-shadow: none;
  color: var(--onead-dark);
}

.empty-state {
  position: relative;
  padding: 70px 20px 48px;
  color: var(--muted);
  text-align: center;
}

.empty-state::before {
  position: absolute;
  top: 27px;
  left: 50%;
  width: 26px;
  height: 32px;
  background: linear-gradient(155deg, rgba(32, 201, 216, 0.3), rgba(3, 105, 161, 0.14));
  border: 1px solid rgba(32, 201, 216, 0.28);
  border-radius: 55% 45% 55% 45% / 65% 60% 40% 35%;
  content: "";
  transform: translateX(-50%);
}

.empty-state.compact {
  padding: 58px 20px 28px;
}

.empty-state.compact::before {
  top: 19px;
}

.error-code {
  color: var(--onead);
  font-size: 4rem;
  font-weight: 850;
}

.form-panel {
  max-width: 1400px;
}

pre {
  max-width: 100%;
  padding: 14px;
  overflow: auto;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font-size: 0.72rem;
  white-space: pre-wrap;
}

/* Statuts */
.status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  background: rgba(100, 116, 139, 0.12);
  border: 1px solid rgba(100, 116, 139, 0.12);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.67rem;
  font-weight: 750;
}

.status::before {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  background: currentColor;
  border-radius: 50%;
  content: "";
  opacity: 0.7;
}

.status-completed,
.status-insert,
.status-success,
.status-active,
.status-compliant {
  background: rgba(21, 149, 112, 0.11);
  border-color: rgba(21, 149, 112, 0.15);
  color: #13785c;
}

[data-bs-theme="dark"] .status-completed,
[data-bs-theme="dark"] .status-insert,
[data-bs-theme="dark"] .status-success,
[data-bs-theme="dark"] .status-active,
[data-bs-theme="dark"] .status-compliant {
  color: #64d5af;
}

.status-failed,
.status-reject,
.status-critical,
.status-out_of_range {
  background: rgba(215, 75, 91, 0.11);
  border-color: rgba(215, 75, 91, 0.15);
  color: #b73143;
}

[data-bs-theme="dark"] .status-failed,
[data-bs-theme="dark"] .status-reject,
[data-bs-theme="dark"] .status-critical,
[data-bs-theme="dark"] .status-out_of_range {
  color: #f18a97;
}

.status-preview,
.status-pending,
.status-monitor,
.status-planned {
  background: rgba(211, 139, 24, 0.12);
  border-color: rgba(211, 139, 24, 0.16);
  color: #a5680c;
}

[data-bs-theme="dark"] .status-preview,
[data-bs-theme="dark"] .status-pending,
[data-bs-theme="dark"] .status-monitor,
[data-bs-theme="dark"] .status-planned {
  color: #edb65b;
}

.status-disabled,
.status-skip,
.status-closed {
  background: rgba(100, 116, 139, 0.12);
  color: var(--muted);
}

/* Imports Excel */
.import-kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.upload-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}

.upload-zone {
  position: relative;
  display: grid;
  margin-top: 18px;
  padding: 34px 28px;
  gap: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(32, 201, 216, 0.08), transparent 14rem),
    var(--panel-soft);
  border: 2px dashed rgba(8, 127, 156, 0.3);
  border-radius: 17px;
}

.upload-zone:hover,
.upload-zone:focus-within {
  background-color: rgba(32, 201, 216, 0.04);
  border-color: var(--aqua);
}

.flow-steps {
  display: flex;
  margin-top: 19px;
  flex-wrap: wrap;
  gap: 8px;
}

.flow-steps span {
  padding: 7px 10px;
  background: rgba(8, 127, 156, 0.08);
  border: 1px solid rgba(8, 127, 156, 0.09);
  border-radius: 9px;
  color: var(--onead);
  font-size: 0.7rem;
  font-weight: 650;
}

.flow-steps span:not(:last-child)::after {
  margin-left: 5px;
  color: var(--muted);
  content: "›";
}

/* Assistant IA */
.ai-layout {
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  min-height: 660px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.ai-history {
  padding: 15px;
  overflow: auto;
  background: linear-gradient(180deg, var(--panel-soft), var(--panel));
  border-right: 1px solid var(--line);
}

.conversation-item {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 12px;
}

.conversation-item:hover {
  background: rgba(8, 127, 156, 0.055);
}

.conversation-item.active {
  background: rgba(8, 127, 156, 0.1);
  border-color: rgba(8, 127, 156, 0.1);
}

.conversation-item > a {
  min-width: 0;
  padding: 11px;
  flex: 1;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  text-overflow: ellipsis;
}

.conversation-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.62rem;
}

.conversation-item form button {
  padding: 5px 9px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.18rem;
}

.conversation-item form button:hover {
  color: var(--danger);
}

.ai-chat {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 16px 21px;
  gap: 14px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--line);
}

.ai-head div {
  display: flex;
  flex-direction: column;
}

.ai-head strong {
  color: var(--heading);
}

.ai-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.messages {
  min-height: 420px;
  max-height: 570px;
  padding: 23px;
  overflow: auto;
  flex: 1;
  background:
    radial-gradient(circle at 100% 0%, rgba(32, 201, 216, 0.04), transparent 18rem),
    var(--panel);
}

.message {
  max-width: min(80%, 760px);
  margin-bottom: 19px;
}

.message span {
  margin-left: 3px;
  color: var(--muted);
  font-size: 0.66rem;
}

.message p {
  margin: 5px 0 0;
  padding: 13px 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px 16px 16px;
  box-shadow: var(--shadow-sm);
  line-height: 1.6;
}

.message.user {
  margin-left: auto;
}

.message.user p {
  background: linear-gradient(135deg, #0b8ca7, #087593);
  border-color: transparent;
  border-radius: 16px 6px 16px 16px;
  box-shadow: 0 10px 24px rgba(8, 117, 147, 0.18);
  color: #fff;
}

.ai-input {
  display: flex;
  padding: 15px;
  gap: 10px;
  background: var(--panel-solid);
  border-top: 1px solid var(--line);
}

.ai-input textarea {
  min-height: 48px;
  max-height: 150px;
  padding: 12px 14px;
  resize: vertical;
  flex: 1;
  background: var(--panel-soft);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  color: var(--text);
}

.ai-input textarea:focus {
  border-color: var(--aqua);
  box-shadow: var(--focus);
  outline: 0;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.status-cards > div {
  display: flex;
  justify-content: space-between;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

/* Écrans de connexion et installation */
.guest-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 30px;
  background:
    radial-gradient(circle at 12% 8%, rgba(32, 201, 216, 0.24), transparent 28rem),
    radial-gradient(circle at 90% 88%, rgba(3, 105, 161, 0.15), transparent 32rem),
    linear-gradient(145deg, #e6f7fa, #f8fcfd 52%, #edf8fb);
}

.guest-shell {
  width: min(100%, 530px);
}

.guest-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 21px;
  gap: 12px;
}

.guest-brand strong {
  color: #07546d;
}

.guest-brand small {
  color: #5d7c8a;
}

.guest-brand img {
  width: 72px;
  height: 72px;
  padding: 5px;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgba(8, 127, 156, 0.14);
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(7, 89, 110, 0.14);
}

/* Stocks et consommations */
.stock-kpis {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.stock-overview-grid {
  grid-template-columns: minmax(0, 1.7fr) minmax(270px, 0.8fr);
  margin-top: 22px;
}

.stock-guide {
  display: grid;
  gap: 13px;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: stock-step;
}

.stock-guide li {
  position: relative;
  min-height: 56px;
  padding: 10px 10px 10px 54px;
  border-bottom: 1px solid var(--line);
  counter-increment: stock-step;
}

.stock-guide li:last-child {
  border-bottom: 0;
}

.stock-guide li::before {
  position: absolute;
  top: 9px;
  left: 2px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--onead), #24c4cf);
  border-radius: 11px;
  color: #fff;
  font-weight: 800;
  content: counter(stock-step);
  box-shadow: 0 8px 18px rgba(8, 127, 156, 0.18);
}

.stock-guide strong,
.stock-guide span {
  display: block;
}

.stock-guide span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.stock-balance-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.stock-balance-note span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stock-balance-note strong {
  color: var(--onead);
  font-size: 1.2rem;
}

.status-info {
  background: rgba(3, 105, 161, 0.11);
  border-color: rgba(3, 105, 161, 0.16);
  color: #0369a1;
}

[data-bs-theme="dark"] .status-info {
  color: #69c7ff;
}

.auth-card {
  position: relative;
  padding: 34px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(194, 224, 230, 0.9);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(7, 89, 110, 0.15);
  color: #183247;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.auth-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #087f9c, #37d4dd, #0369a1);
  content: "";
}

.auth-card h1 {
  margin: 7px 0;
  color: #082f45;
  font-size: 1.7rem;
  font-weight: 800;
}

.auth-card p {
  color: #64748b;
}

.eyebrow {
  color: #087f9c;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* Mode TV */
.tv-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% 0%, rgba(32, 201, 216, 0.12), transparent 28rem),
    #05131c;
  color: #e7f8fc;
}

.tv-head {
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 0 29px;
  gap: 25px;
  background: rgba(8, 30, 41, 0.8);
  border-bottom: 1px solid #254652;
  backdrop-filter: blur(16px);
}

.tv-head > strong {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.tv-brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  padding: 3px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
}

.tv-head [data-clock] {
  margin-left: auto;
  color: #b9e9ee;
  font-size: 1.18rem;
}

.tv-content {
  padding: 23px;
}

.tv-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
}

.tv-kpis article {
  position: relative;
  padding: 19px;
  overflow: hidden;
  background: linear-gradient(145deg, #0d2b38, #0a2230);
  border: 1px solid #24505f;
  border-radius: 17px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
}

.tv-kpis article::before {
  position: absolute;
  top: 0;
  right: 18px;
  left: 18px;
  height: 3px;
  background: linear-gradient(90deg, #43d4dd, transparent);
  content: "";
}

.tv-kpis span {
  display: block;
  color: #8ebbc6;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tv-kpis strong {
  display: block;
  margin-top: 8px;
  color: #fff;
  font-size: 1.75rem;
}

.tv-chart {
  height: 48vh;
  margin-top: 19px;
  padding: 19px;
  background: #0c2734;
  border: 1px solid #234b5a;
  border-radius: 17px;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.2);
}

.tv-chart canvas {
  max-height: 100%;
}

.audit-agent {
  max-width: 240px;
}

.text-secondary {
  color: var(--muted) !important;
}

.modal-content,
.dropdown-menu {
  background: var(--panel-solid);
  border-color: var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.dropdown-item {
  color: var(--text);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--panel-soft);
  color: var(--heading);
}

/* Responsive */
@media (max-width: 1450px) {
  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .import-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .comparison-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tv-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  body::before {
    left: 0;
  }

  .sidebar {
    width: min(86vw, 292px);
    transform: translateX(-105%);
    transition: transform 260ms var(--ease);
  }

  .sidebar.open {
    box-shadow: 30px 0 80px rgba(0, 0, 0, 0.3);
    transform: translateX(0);
  }

  .main-area {
    margin-left: 0;
  }

  .topbar {
    min-height: 64px;
    padding: 0 15px;
  }

  .topbar .btn-outline-primary,
  .user-pill {
    display: none;
  }

  .page {
    padding: 22px 17px 42px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .quick-card {
    min-height: 94px;
  }

  .ai-layout {
    grid-template-columns: 1fr;
  }

  .stock-overview-grid {
    grid-template-columns: 1fr;
  }

  .ai-history {
    max-height: 190px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 767.98px) {
  .kpi-grid,
  .status-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .import-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 17px;
    border-radius: 17px;
  }

  .chart-panel {
    min-height: 360px;
  }

  .upload-intro {
    flex-direction: column;
  }

  .message {
    max-width: 92%;
  }
}

@media (max-width: 575.98px) {
  body {
    font-size: 0.91rem;
  }

  .topbar {
    overflow-x: auto;
  }

  .topbar .ms-auto {
    gap: 6px !important;
  }

  .theme-select {
    display: none;
  }

  .page {
    padding: 17px 12px 35px;
  }

  .page-head {
    min-height: 58px;
    margin-bottom: 18px;
  }

  .page-head p {
    font-size: 0.78rem;
  }

  .kpi-grid,
  .status-cards,
  .tv-kpis {
    grid-template-columns: 1fr;
  }

  .kpi {
    min-height: 104px;
  }

  .import-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar > * {
    width: 100%;
  }

  .auth-card {
    padding: 25px 21px;
    border-radius: 20px;
  }

  .guest-body {
    padding: 21px 14px;
  }

  .ai-input {
    flex-direction: column;
  }

  .ai-input .btn {
    width: 100%;
  }

  .message {
    max-width: 96%;
  }

  .messages {
    padding: 17px 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
