:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #10243f;
  --muted: #66758a;
  --line: #dce7f4;
  --primary: #064c99;
  --primary-dark: #04346d;
  --accent: #ff9f1c;
  --accent-soft: #fff3dc;
  --danger: #bd2f2f;
  --success: #1f7a4d;
  --shadow: 0 16px 36px rgba(7, 42, 86, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 282px 1fr;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef5ff 0, rgba(244, 247, 251, 0) 230px),
    var(--bg);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

body.is-locked {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 159, 28, 0.24), transparent 30%),
    linear-gradient(135deg, rgba(5, 47, 115, 0.98), rgba(7, 29, 66, 0.98));
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-card img {
  width: 220px;
  max-width: 100%;
  margin-bottom: 6px;
}

.login-card h1 {
  font-size: 1.7rem;
}

.login-card p {
  color: var(--muted);
}

#loginError {
  min-height: 20px;
  color: var(--danger);
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.sidebar {
  min-height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 159, 28, 0.22), transparent 28%),
    linear-gradient(180deg, #052f73 0%, #071d42 100%);
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  width: 64px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary);
  font-weight: 800;
  box-shadow: inset 0 -5px 0 var(--accent);
}

.logo-mark {
  padding: 6px;
  overflow: hidden;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #dbe8ff;
}

.nav {
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-item,
.ghost-button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #eff6ff;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
}

.nav-item.active,
.nav-item:hover,
.ghost-button:hover {
  background: rgba(255, 255, 255, 0.13);
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.user-card {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
}

.user-card strong,
.user-card small {
  display: block;
}

.user-card small {
  color: #dbe8ff;
}

.import-label {
  display: block;
}

.import-label input {
  display: none;
}

.app {
  min-width: 0;
  padding: 28px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
}

h2 {
  font-size: 1.05rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 11px;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

#searchInput {
  width: min(320px, 42vw);
}

#agencyFilter {
  min-width: 260px;
  border-color: #b8cdea;
  color: var(--primary-dark);
  font-weight: 800;
}

.primary-button,
.secondary-button,
.link-button,
.danger-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #241606;
}

.primary-button:hover {
  background: #ec8d06;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary-dark);
}

.link-button {
  background: transparent;
  color: var(--primary);
}

.danger-button {
  background: #fff1f1;
  color: var(--danger);
}

.doc-link {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 8px;
  padding: 7px 11px;
  background: #eaf2ff;
  color: var(--primary-dark);
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: none;
}

.doc-link:hover {
  background: var(--accent-soft);
  color: #8a570d;
}

.stat-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #0d6fd1 100%);
  color: #fff;
}

.stat-primary span {
  color: #dbe8ff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(6, 76, 153, 0.96), rgba(4, 52, 109, 0.96)),
    #064c99;
  color: #fff;
  box-shadow: var(--shadow);
}

.hero-panel h2 {
  max-width: 760px;
  margin-bottom: 8px;
  font-size: 1.45rem;
}

.hero-panel p {
  max-width: 780px;
  margin-bottom: 0;
  color: #dbe8ff;
}

.hero-kicker {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-metrics {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.hero-metrics span {
  color: #dbe8ff;
  font-weight: 800;
}

.hero-metrics strong {
  color: #fff;
  font-size: 2.6rem;
}

.dashboard-showcase {
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-showcase img {
  display: block;
  width: 100%;
  max-height: min(56vh, 540px);
  object-fit: contain;
  object-position: center;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.85fr);
  gap: 18px;
  margin-bottom: 18px;
}

.chart-panel-wide {
  grid-row: span 2;
}

.chart-box {
  min-height: 240px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-legend i {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.line-chart {
  width: 100%;
  min-height: 260px;
}

.chart-grid-lines line {
  stroke: #e5edf7;
  stroke-width: 1;
}

.chart-grid-lines text,
.chart-axis text {
  fill: var(--muted);
  font-size: 0.78rem;
}

.chart-lines polyline {
  fill: none;
  stroke: var(--chart-color);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-lines circle {
  fill: var(--chart-color);
  stroke: #fff;
  stroke-width: 3;
}

.bar-chart {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.bar-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #eaf2ff;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat,
.panel,
.item-card,
.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
  border-top: 4px solid var(--accent);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 1.45rem;
}

.dashboard-grid,
.split {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.65fr);
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin-bottom: 0;
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  background: #eaf2ff;
  color: var(--primary-dark);
}

.form-panel {
  align-self: start;
  display: grid;
  gap: 12px;
}

.product-image {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef5ff;
  color: var(--muted);
  font-weight: 800;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--primary-dark);
  font-size: 0.8rem;
  text-transform: uppercase;
  background: #f5f9ff;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.item-card,
.task-card,
.agency-card {
  padding: 14px;
  box-shadow: none;
}

.item-card,
.agency-card {
  border-top: 4px solid var(--primary);
}

.agency-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.agency-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.agency-metrics span,
.agency-metrics strong {
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f5f9ff;
  color: var(--primary-dark);
  font-size: 0.84rem;
  font-weight: 800;
}

.agency-metrics strong {
  grid-column: 1 / -1;
  background: var(--accent-soft);
  color: #8a570d;
}

.item-card.stock-low {
  border-color: #ffd3d3;
  border-top-color: var(--danger);
  background: #fffafa;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.stock-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: #8a570d;
  font-size: 0.82rem;
  font-weight: 800;
}

.item-card h3,
.task-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

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

.stack,
.task-list {
  display: grid;
  gap: 10px;
}

.messaging-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.message-list {
  display: grid;
  gap: 10px;
  max-height: 62vh;
  overflow: auto;
  padding-right: 6px;
}

.message-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.message-card.own {
  border-color: #b8cdea;
  background: #f5f9ff;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.message-meta span,
.message-card small {
  color: var(--muted);
  font-size: 0.84rem;
}

.message-card p {
  margin-bottom: 8px;
}

.meeting-room {
  position: relative;
  min-height: calc(100vh - 128px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 159, 28, 0.18), transparent 24%),
    linear-gradient(135deg, #06162d, #0a2a5c);
  box-shadow: var(--shadow);
}

.meeting-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
}

.meeting-topbar span {
  display: block;
  color: #b8cdea;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meeting-topbar strong {
  display: block;
  font-size: 1.3rem;
}

.meeting-status {
  min-height: 34px;
  display: inline-flex !important;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff !important;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  grid-auto-rows: minmax(230px, 1fr);
  gap: 12px;
  min-height: 520px;
}

.video-tile {
  position: relative;
  overflow: hidden;
  min-height: 230px;
  border-radius: 8px;
  background: #071d42;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.video-tile video {
  width: 100%;
  height: 100%;
  min-height: 230px;
  object-fit: cover;
  display: block;
}

.video-placeholder-content {
  min-height: 230px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #dbe8ff;
  text-align: center;
  font-weight: 800;
}

.video-tile strong {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-size: 0.86rem;
}

.meeting-side {
  grid-row: 2 / 4;
  grid-column: 2;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
}

.meeting-side h2 {
  margin-bottom: 0;
}

.participant-list {
  display: grid;
  gap: 8px;
}

.participant-chip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #f5f9ff;
  color: var(--primary-dark);
  font-weight: 800;
}

.meeting-dock {
  grid-column: 1;
  justify-self: center;
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: 999px;
  background: rgba(4, 18, 38, 0.72);
  backdrop-filter: blur(10px);
}

.meeting-control {
  min-width: 86px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 900;
}

.meeting-control:hover {
  background: rgba(255, 255, 255, 0.2);
}

.meeting-control.join {
  background: var(--success);
}

.meeting-control.leave {
  background: var(--danger);
}

.row-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.right {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.status.payee,
.status.terminee {
  background: #e8f5ee;
  color: var(--success);
}

.status.impayee,
.status.haute {
  background: var(--accent-soft);
  color: #8a570d;
}

.status.sortie {
  background: #fff1f1;
  color: var(--danger);
}

.status.entree {
  background: #e8f5ee;
  color: var(--success);
}

.status.en-retard {
  background: #fff1f1;
  color: var(--danger);
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    gap: 16px;
  }

  .nav,
  .sidebar-footer {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .stats-grid,
  .analytics-grid,
  .dashboard-grid,
  .split {
    grid-template-columns: 1fr 1fr;
  }

  .chart-panel-wide {
    grid-column: 1 / -1;
    grid-row: auto;
  }

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

@media (max-width: 700px) {
  .app {
    padding: 18px;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  #searchInput,
  #agencyFilter {
    width: 100%;
    min-width: 0;
  }

  .stats-grid,
  .analytics-grid,
  .dashboard-grid,
  .split,
  .hero-panel,
  .dashboard-showcase,
  .messaging-layout,
  .meeting-room {
    grid-template-columns: 1fr;
  }

  .dashboard-showcase img {
    max-height: 42vh;
  }

  .meeting-side,
  .meeting-dock {
    grid-column: 1;
    grid-row: auto;
  }
}
