/* Lumen / Inspectora Sandra — shared design layer.
   Design language is the existing Material-3 pastel pink system; this file only
   centralises it and adds the mobile behaviour the old static mockups lacked. */

:root {
  color-scheme: light;

  --lm-primary: #a43073;
  --lm-primary-container: #f472b6;
  --lm-on-primary-container: #6d0047;
  --lm-primary-fixed: #ffd8e7;
  --lm-primary-fixed-dim: #ffafd3;

  --lm-secondary: #674bb5;
  --lm-secondary-container: #ab8ffe;
  --lm-secondary-fixed: #cebdff;
  --lm-on-secondary-container: #3f1e8c;

  --lm-tertiary: #00b580;
  --lm-tertiary-container: #00b580;
  --lm-tertiary-fixed: #68fcbf;
  --lm-on-tertiary-fixed: #002114;

  --lm-error: #ba1a1a;
  --lm-error-container: #ffdad6;
  --lm-on-error-container: #93000a;

  --lm-background: #fbf8fc;
  --lm-surface: #fbf8fc;
  --lm-surface-bright: #fbf8fc;
  --lm-surface-dim: #dcd9dd;
  --lm-surface-container-lowest: #ffffff;
  --lm-surface-container-low: #f5f3f6;
  --lm-surface-container: #f0edf1;
  --lm-surface-container-high: #eae7eb;
  --lm-surface-container-highest: #e4e1e5;
  --lm-surface-variant: #e4e1e5;
  --lm-surface-tint: #a43073;
  --lm-inverse-surface: #303033;
  --lm-inverse-on-surface: #f3f0f4;

  --lm-on-surface: #1b1b1e;
  --lm-on-surface-variant: #544249;
  --lm-on-background: #1b1b1e;
  --lm-on-secondary: #ffffff;
  --lm-on-primary: #ffffff;
  --lm-on-tertiary: #ffffff;
  --lm-on-error: #ffffff;

  --lm-outline: #87717a;
  --lm-outline-variant: #dac0c9;

  --lm-radius-sm: 0.25rem;
  --lm-radius: 0.5rem;
  --lm-radius-lg: 0.75rem;
  --lm-radius-full: 9999px;

  --lm-gap-xs: 0.25rem;
  --lm-gap-sm: 0.5rem;
  --lm-gap: 1rem;
  --lm-gap-lg: 1.5rem;
  --lm-margin: 2rem;

  --lm-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --lm-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --lm-shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.1);

  --lm-font-body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --lm-font-display: "Space Grotesk", var(--lm-font-body);
  --lm-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--lm-background);
  color: var(--lm-on-surface);
  font-family: var(--lm-font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Old mockups pinned the page; that broke scrolling on touch devices. */
html, body { overflow-x: hidden; min-height: 100%; }

/* ── Layout ──────────────────────────────────────────────────────────── */

.lm-shell { min-height: 100vh; display: flex; flex-direction: column; }

.lm-main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
}
@media (min-width: 768px)  { .lm-main { padding: 1.5rem; } }
@media (min-width: 1280px) { .lm-main { padding: 2rem; } }

.lm-stack   { display: flex; flex-direction: column; gap: var(--lm-gap); }
.lm-stack-sm{ display: flex; flex-direction: column; gap: var(--lm-gap-sm); }
.lm-row     { display: flex; flex-wrap: wrap; align-items: center; gap: var(--lm-gap-sm); }
.lm-row-tight { display: flex; flex-wrap: wrap; align-items: center; gap: var(--lm-gap-xs); }
.lm-spacer  { flex: 1 1 auto; }
.lm-grow    { flex: 1 1 0%; min-width: 0; }

.lm-grid { display: grid; gap: var(--lm-gap); grid-template-columns: 1fr; }
@media (min-width: 640px)  { .lm-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .lm-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .lm-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .lm-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ── Header ──────────────────────────────────────────────────────────── */

.lm-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--lm-surface-container-lowest) 88%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--lm-shadow-sm);
  border-bottom: 1px solid var(--lm-surface-container);
}

.lm-header-bar {
  display: flex;
  align-items: center;
  gap: var(--lm-gap);
  padding: 0.75rem 1rem;
  max-width: 1280px;
  margin: 0 auto;
}
@media (min-width: 768px) { .lm-header-bar { padding: 1rem 1.5rem; } }

.lm-brand { display: flex; align-items: center; gap: var(--lm-gap-sm); min-width: 0; }
.lm-brand img { height: 2rem; width: auto; object-fit: contain; }
.lm-brand-text { display: flex; flex-direction: column; min-width: 0; }
.lm-brand-title {
  font-family: var(--lm-font-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lm-brand-sub {
  font-family: var(--lm-font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  color: var(--lm-primary);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav: horizontal scroller on small screens, inline on large. */
.lm-nav {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--lm-surface-container-low);
  border-radius: var(--lm-radius-full);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.lm-nav::-webkit-scrollbar { display: none; }

.lm-nav a {
  flex: 0 0 auto;
  padding: 0.5rem 0.9rem;
  border-radius: var(--lm-radius-full);
  color: var(--lm-on-surface-variant);
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
  /* 44px minimum touch target on coarse pointers */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.lm-nav a:hover { color: var(--lm-on-surface); }
.lm-nav a[aria-current="page"] {
  background: var(--lm-primary-container);
  color: var(--lm-on-primary-container);
  font-weight: 600;
}

.lm-header-actions { display: flex; align-items: center; gap: var(--lm-gap-sm); margin-left: auto; }

/* ── Surfaces ────────────────────────────────────────────────────────── */

.lm-card {
  background: var(--lm-surface-container-lowest);
  border-radius: var(--lm-radius-lg);
  padding: 1rem;
  box-shadow: var(--lm-shadow-sm);
}
@media (min-width: 768px) { .lm-card { padding: 1.25rem; } }
.lm-card + .lm-card { margin-top: var(--lm-gap); }

.lm-panel {
  background: var(--lm-surface-container-low);
  border-radius: var(--lm-radius);
  padding: 0.75rem;
}

.lm-divider { height: 1px; background: var(--lm-surface-container); border: 0; margin: var(--lm-gap) 0; }

/* ── Type ────────────────────────────────────────────────────────────── */

.lm-h1 { font-family: var(--lm-font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.25rem; }
.lm-h2 { font-family: var(--lm-font-display); font-size: 1.125rem; font-weight: 600; margin: 0 0 0.5rem; }
.lm-h3 { font-family: var(--lm-font-display); font-size: 0.95rem; font-weight: 600; margin: 0 0 0.375rem; }
.lm-muted { color: var(--lm-on-surface-variant); }
.lm-mono { font-family: var(--lm-font-mono); font-size: 0.75rem; }
.lm-tiny { font-family: var(--lm-font-mono); font-size: 0.6875rem; letter-spacing: 0.04em; }
.lm-error-text { color: var(--lm-error); }
.lm-ok-text { color: var(--lm-tertiary); }

/* ── Controls ────────────────────────────────────────────────────────── */

.lm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 40px;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: var(--lm-radius-full);
  background: var(--lm-surface-container);
  color: var(--lm-on-surface);
  font-family: var(--lm-font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 120ms ease, opacity 120ms ease;
}
.lm-btn:hover { filter: brightness(0.97); }
.lm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.lm-btn-primary { background: var(--lm-primary); color: var(--lm-on-primary); }
.lm-btn-container { background: var(--lm-primary-container); color: var(--lm-on-primary-container); }
.lm-btn-danger  { background: var(--lm-error-container); color: var(--lm-on-error-container); }
.lm-btn-sm { min-height: 32px; padding: 0.25rem 0.75rem; font-size: 0.8125rem; }

.lm-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.lm-label { font-size: 0.75rem; font-weight: 600; color: var(--lm-on-surface-variant); }
.lm-input, .lm-select, .lm-textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--lm-outline-variant);
  border-radius: var(--lm-radius);
  background: var(--lm-surface-container-lowest);
  color: var(--lm-on-surface);
  font-family: var(--lm-font-body);
  font-size: 0.875rem;
}
.lm-input:focus, .lm-select:focus, .lm-textarea:focus {
  outline: 2px solid var(--lm-primary-container);
  outline-offset: 1px;
  border-color: var(--lm-primary);
}
.lm-textarea { min-height: 96px; resize: vertical; }

/* Switch */
.lm-switch { position: relative; display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; }
.lm-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.lm-switch-track {
  width: 44px; height: 24px; border-radius: var(--lm-radius-full);
  background: var(--lm-surface-container-highest); transition: background 140ms ease; flex: 0 0 auto;
}
.lm-switch-track::after {
  content: ""; display: block; width: 18px; height: 18px; margin: 3px;
  border-radius: 50%; background: var(--lm-outline); transition: transform 140ms ease, background 140ms ease;
}
.lm-switch input:checked + .lm-switch-track { background: var(--lm-primary); }
.lm-switch input:checked + .lm-switch-track::after { transform: translateX(20px); background: var(--lm-on-primary); }
.lm-switch input:focus-visible + .lm-switch-track { outline: 2px solid var(--lm-primary-container); outline-offset: 2px; }
.lm-switch input:disabled + .lm-switch-track { opacity: 0.5; }

/* ── Badges ──────────────────────────────────────────────────────────── */

.lm-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.5rem; border-radius: var(--lm-radius-full);
  font-family: var(--lm-font-mono); font-size: 0.625rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
}
.lm-badge-ok    { background: color-mix(in srgb, var(--lm-tertiary) 16%, transparent); color: var(--lm-on-tertiary-fixed); }
.lm-badge-warn  { background: var(--lm-primary-fixed-dim); color: var(--lm-on-primary-container); }
.lm-badge-err   { background: var(--lm-error-container); color: var(--lm-on-error-container); }
.lm-badge-info  { background: var(--lm-secondary-fixed); color: var(--lm-on-secondary-container); }
.lm-badge-mute  { background: var(--lm-surface-container-high); color: var(--lm-on-surface-variant); }

.lm-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--lm-outline); flex: 0 0 auto; }
.lm-dot-ok { background: var(--lm-tertiary); }
.lm-dot-err { background: var(--lm-error); }
.lm-dot-warn { background: var(--lm-primary-fixed-dim); }

@keyframes lm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.lm-live { animation: lm-pulse 2s ease-in-out infinite; }

/* ── Stat tiles ──────────────────────────────────────────────────────── */

.lm-stat {
  background: var(--lm-surface-container-lowest);
  border-radius: var(--lm-radius-lg);
  padding: 0.875rem;
  box-shadow: var(--lm-shadow-sm);
  display: flex; flex-direction: column; gap: 0.125rem;
  min-width: 0;
}
.lm-stat-label {
  font-family: var(--lm-font-mono); font-size: 0.625rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--lm-on-surface-variant);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lm-stat-value {
  font-family: var(--lm-font-display); font-size: 1.5rem; font-weight: 700; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lm-stat-sub { font-family: var(--lm-font-mono); font-size: 0.6875rem; color: var(--lm-on-surface-variant); }

/* ── Meter ───────────────────────────────────────────────────────────── */

.lm-meter { height: 6px; border-radius: var(--lm-radius-full); background: var(--lm-surface-container-high); overflow: hidden; }
.lm-meter > i { display: block; height: 100%; border-radius: var(--lm-radius-full); background: var(--lm-primary-container); transition: width 260ms ease; }
.lm-meter > i.ok { background: var(--lm-tertiary); }
.lm-meter > i.warn { background: #ff8a5b; }
.lm-meter > i.err { background: var(--lm-error); }

/* ── Lists ───────────────────────────────────────────────────────────── */

.lm-list { list-style: none; margin: 0; padding: 0; }
.lm-list > li {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--lm-surface-container);
  min-width: 0;
}
.lm-list > li:last-child { border-bottom: 0; }
.lm-list-title { font-weight: 600; font-size: 0.875rem; overflow-wrap: anywhere; }
.lm-list-meta { font-family: var(--lm-font-mono); font-size: 0.6875rem; color: var(--lm-on-surface-variant); overflow-wrap: anywhere; }
.lm-list-actions { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }

/* Two-column list rows on wide screens, stacked on mobile. */
@media (min-width: 900px) {
  .lm-list > li.lm-row-item {
    flex-direction: row;
    align-items: center;
    gap: var(--lm-gap);
  }
  .lm-list > li.lm-row-item .lm-list-actions { margin-top: 0; margin-left: auto; }
}

/* ── Key/value ───────────────────────────────────────────────────────── */

.lm-kv { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
@media (min-width: 560px) { .lm-kv { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.lm-kv-item { display: flex; flex-direction: column; gap: 0.125rem; padding: 0.5rem; background: var(--lm-surface-container-low); border-radius: var(--lm-radius); min-width: 0; }
.lm-kv-key { font-family: var(--lm-font-mono); font-size: 0.625rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--lm-on-surface-variant); }
.lm-kv-val { font-family: var(--lm-font-mono); font-size: 0.8125rem; overflow-wrap: anywhere; }

/* ── Toast ───────────────────────────────────────────────────────────── */

.lm-toasts {
  position: fixed;
  left: 0.5rem; right: 0.5rem;
  bottom: 0.5rem;
  z-index: 100;
  display: flex; flex-direction: column; gap: 0.375rem;
  pointer-events: none;
}
@media (min-width: 768px) { .lm-toasts { left: auto; right: 1rem; bottom: 1rem; width: 24rem; } }
.lm-toast {
  pointer-events: auto;
  padding: 0.625rem 0.875rem;
  border-radius: var(--lm-radius);
  background: var(--lm-inverse-surface);
  color: var(--lm-inverse-on-surface);
  font-size: 0.8125rem;
  box-shadow: var(--lm-shadow-lg);
  overflow-wrap: anywhere;
}
.lm-toast-ok { background: var(--lm-on-tertiary-fixed); color: #fff; }
.lm-toast-err { background: var(--lm-error); color: #fff; }

/* ── Misc ────────────────────────────────────────────────────────────── */

.lm-code {
  font-family: var(--lm-font-mono);
  font-size: 0.75rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--lm-surface-container-low);
  border-radius: var(--lm-radius);
  padding: 0.75rem;
  margin: 0;
  max-height: 60vh;
  overflow: auto;
}

.lm-skeleton {
  height: 1rem; border-radius: var(--lm-radius-sm);
  background: linear-gradient(90deg, var(--lm-surface-container) 25%, var(--lm-surface-container-low) 37%, var(--lm-surface-container) 63%);
  background-size: 400% 100%;
  animation: lm-shimmer 1.4s ease infinite;
}
@keyframes lm-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.lm-empty { padding: 1.5rem 1rem; text-align: center; color: var(--lm-on-surface-variant); font-size: 0.875rem; }

.lm-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.lm-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.lm-foot {
  padding: 1.25rem 1rem 2rem;
  text-align: center;
  font-family: var(--lm-font-mono);
  font-size: 0.6875rem;
  color: var(--lm-on-surface-variant);
  border-top: 1px solid var(--lm-surface-container);
  margin-top: auto;
}

@media (prefers-reduced-motion: reduce) {
  .lm-live, .lm-skeleton { animation: none; }
  * { transition: none !important; }
}
