/* ==========================================================================
   layout.css  —  .l-* layout primitives (v1.0.0)
   Structure only: no colour, no decoration. Spacing is owned by layouts,
   never by components (key design decision — components carry no outer margin).
   ========================================================================== */

/* ---- l-app : the CRM shell (sidebar + main) ----------------------------- */
.l-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}
.l-app__sidebar { grid-column: 1; }
.l-app__main {
  grid-column: 2;
  min-width: 0;                 /* allow inner content to shrink/scroll       */
  display: flex;
  flex-direction: column;
}

/* Tablet & mobile: sidebar becomes an off-canvas drawer; main spans full. */
@media (max-width: 1024px) {
  .l-app { grid-template-columns: 1fr; }
  .l-app__main { grid-column: 1; }
}

/* ---- l-container : centred max-width wrapper ---------------------------- */
.l-container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.l-container--narrow { max-width: var(--container-narrow); }
@media (max-width: 768px) {
  .l-container { padding-inline: var(--space-4); }
}

/* ---- l-stack : vertical rhythm (gap-driven) ----------------------------- */
.l-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.l-stack--tight { gap: var(--space-2); }
.l-stack--loose { gap: var(--space-6); }

/* ---- l-cluster : horizontal group that wraps; aligns to baseline-ish ---- */
.l-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.l-cluster--between { justify-content: space-between; }
.l-cluster--end { justify-content: flex-end; }

/* ---- l-grid : responsive auto-fit grid for cards ------------------------ */
.l-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.l-grid--2 { grid-template-columns: repeat(2, 1fr); }
.l-grid--3 { grid-template-columns: repeat(3, 1fr); }
.l-grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) {
  .l-grid--2, .l-grid--3, .l-grid--4 { grid-template-columns: 1fr; }
}

/* ---- l-center : full-viewport centring (login screens) ------------------ */
.l-center {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-5);
}

/* ---- l-page : the scrolling content region inside main ------------------ */
.l-page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-5);
}
@media (max-width: 768px) { .l-page { padding: var(--space-4); } }

/* ---- l-spread : push first/last to edges, used in list rows ------------- */
.l-spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
