/* Level ERP — Admin shell. Paleta gris+azul (Galican) + naranja (Level) + neutros. */
/* Inspirado en la maqueta v0.1 (mayo 2026). Look limpio tipo Linear/Notion. */

:root {
  /* Marcas */
  --gal: #1f6feb;
  --gal-soft: #eff6ff;
  --gal-dark: #1e3a8a;
  --lvl: #d97706;
  --lvl-soft: #fff7ed;
  --lvl-dark: #7c2d12;

  /* Neutros */
  --bg-page: #f3f4f6;
  --bg-surface: #ffffff;
  --bg-soft: #f7f7f5;
  --border: #e5e5e5;
  --border-strong: #d1d5db;

  /* Texto */
  --text-100: #1a1a1a;
  --text-200: #4b5563;
  --text-300: #6b7280;
  --text-400: #9ca3af;

  /* Semánticos */
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  /* Layout */
  --sidebar-w: 220px;
  --header-h: 52px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 28px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--text-100);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─────────── Layout shell ─────────── */
.lv-app { display: grid; grid-template-rows: var(--header-h) 1fr; min-height: 100vh; }
.lv-header {
  background: #1f2937; color: white;
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid #111827;
}
.lv-header .lv-logo { font-weight: 700; letter-spacing: 0.5px; font-size: 14px; }
.lv-header .lv-tag {
  background: rgba(255,255,255,0.1); padding: 2px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 500;
}
.lv-header .lv-search {
  flex: 1; max-width: 480px;
  background: #111827; border: 1px solid #374151;
  color: #cbd5e1; padding: 6px 10px; border-radius: 5px; font-size: 12px;
  outline: none;
}
.lv-header .lv-search:focus { border-color: #4b5563; color: white; }
.lv-header .lv-spacer { flex: 1; }
.lv-header .lv-empresa-switch {
  display: flex; background: #111827; border-radius: 5px; padding: 2px;
  font-size: 11px; font-weight: 600;
}
.lv-header .lv-empresa-switch span {
  padding: 3px 10px; border-radius: 3px; color: #9ca3af; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.lv-header .lv-empresa-switch span.active { background: white; color: #111827; }
.lv-header .lv-empresa-switch .dot { width: 6px; height: 6px; border-radius: 50%; }
.lv-header .lv-user {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
}
.lv-header .lv-user:hover { background: rgba(255,255,255,0.08); }
.lv-header .lv-user .lv-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--gal);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
}
.lv-header .lv-user-name { font-size: 12px; font-weight: 500; }

.lv-body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; overflow: hidden; }

/* ─────────── Sidebar ─────────── */
.lv-sidebar {
  background: #fafafa; border-right: 1px solid var(--border);
  padding: 14px 0; overflow-y: auto;
  height: calc(100vh - var(--header-h));
}
.lv-sidebar h4 {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-300); padding: 12px 16px 4px; font-weight: 700;
  margin: 0;
}
.lv-sidebar a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 16px; font-size: 13px; color: var(--text-200);
  text-decoration: none; border-left: 3px solid transparent;
  transition: background 0.08s ease;
}
.lv-sidebar a:hover { background: rgba(31,111,235,0.04); color: var(--gal-dark); }
.lv-sidebar a.active {
  background: var(--gal-soft); color: var(--gal-dark);
  border-left-color: var(--gal); font-weight: 600;
}
.lv-sidebar a .lv-icon { width: 18px; display: inline-flex; justify-content: center; font-size: 14px; }
.lv-sidebar a .lv-badge {
  margin-left: auto; background: var(--gal); color: white;
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 10px;
}
.lv-sidebar a .lv-badge.warn { background: var(--warn); }
.lv-sidebar a.disabled {
  opacity: 0.45; cursor: not-allowed; pointer-events: none;
}
.lv-sidebar a.disabled::after {
  content: 'Pronto'; margin-left: auto; font-size: 9px;
  background: var(--border); color: var(--text-300);
  padding: 1px 6px; border-radius: 8px; font-weight: 500;
}

/* ─────────── Main + Breadcrumb + Title ─────────── */
.lv-main {
  padding: 18px 24px 40px; overflow-y: auto;
  height: calc(100vh - var(--header-h));
}
.lv-bread {
  font-size: 11px; color: var(--text-300); margin-bottom: 6px;
}
.lv-bread a { color: var(--text-300); }
.lv-h1 {
  font-size: 20px; font-weight: 700; margin: 0 0 18px;
  display: flex; align-items: center; gap: 12px;
}
.lv-h1 .lv-h1-right { margin-left: auto; font-size: 12px; color: var(--text-300); font-weight: 400; }

/* ─────────── Toolbar / filtros ─────────── */
.lv-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.lv-filter, .lv-input {
  background: white; border: 1px solid var(--border-strong);
  padding: 6px 10px; border-radius: 5px; font-size: 12px;
  color: var(--text-200); font-family: inherit; outline: none;
}
.lv-input:focus { border-color: var(--gal); }
.lv-filter { cursor: pointer; }

/* ─────────── Buttons ─────────── */
.lv-btn {
  background: var(--gal); color: white; border: 0;
  padding: 7px 14px; border-radius: 5px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.1s ease;
  display: inline-flex; align-items: center; gap: 6px; font-family: inherit;
}
.lv-btn:hover:not(:disabled) { background: var(--gal-dark); }
.lv-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.lv-btn.ghost { background: white; color: var(--text-200); border: 1px solid var(--border-strong); }
.lv-btn.ghost:hover:not(:disabled) { background: var(--bg-soft); }
.lv-btn.ok { background: var(--success); }
.lv-btn.ok:hover:not(:disabled) { background: #15803d; }
.lv-btn.danger { background: var(--danger); }
.lv-btn.danger:hover:not(:disabled) { background: #b91c1c; }
.lv-btn.sm { padding: 4px 9px; font-size: 11px; }

/* ─────────── Cards / KPI / sections ─────────── */
.lv-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm);
}
.lv-section {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px;
}
.lv-section h4 {
  font-size: 11px; text-transform: uppercase; color: var(--text-300);
  letter-spacing: 0.05em; margin: 0 0 10px; font-weight: 700;
}

.lv-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.lv-kpi { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 7px; padding: 12px 14px; }
.lv-kpi.gal { border-left: 3px solid var(--gal); }
.lv-kpi.lvl { border-left: 3px solid var(--lvl); }
.lv-kpi.success { border-left: 3px solid var(--success); }
.lv-kpi .lbl { font-size: 10px; text-transform: uppercase; color: var(--text-300); margin-bottom: 4px; letter-spacing: 0.04em; }
.lv-kpi .num { font-size: 22px; font-weight: 700; }
.lv-kpi .chg { font-size: 11px; margin-top: 2px; color: var(--success); }
.lv-kpi .chg.warn { color: var(--warn); }
.lv-kpi .chg.muted { color: var(--text-300); }

/* ─────────── Pills ─────────── */
.lv-pill {
  display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 10px;
  font-weight: 600; line-height: 1.5;
}
.lv-pill.gal { background: var(--gal-soft); color: var(--gal-dark); }
.lv-pill.lvl { background: var(--lvl-soft); color: var(--lvl-dark); }
.lv-pill.mix { background: linear-gradient(90deg, var(--gal-soft), var(--lvl-soft)); color: #111827; border: 1px solid #cbd5e1; }
.lv-pill.ok { background: var(--success-soft); color: #14532d; }
.lv-pill.warn { background: var(--warn-soft); color: #78350f; }
.lv-pill.danger { background: var(--danger-soft); color: #991b1b; }
.lv-pill.muted { background: var(--bg-soft); color: var(--text-300); }

/* ─────────── Tables ─────────── */
.lv-table { width: 100%; border-collapse: collapse; font-size: 12px; background: var(--bg-surface); border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }
.lv-table th {
  background: var(--bg-soft); text-align: left; padding: 9px 12px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-300); font-weight: 700; border-bottom: 1px solid var(--border);
}
.lv-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.lv-table tr:last-child td { border-bottom: none; }
.lv-table tr.clickable { cursor: pointer; }
.lv-table tr.clickable:hover { background: var(--bg-soft); }
.lv-table .id-col { font-weight: 700; font-family: 'SF Mono', Menlo, monospace; font-size: 11px; }
.lv-table .num-col { text-align: right; font-variant-numeric: tabular-nums; }

/* ─────────── Stock bar ─────────── */
.lv-stock-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 80px; }
.lv-stock-bar > span { display: block; height: 100%; }
.lv-stock-bar .ok { background: var(--success); }
.lv-stock-bar .low { background: var(--warn); }
.lv-stock-bar .out { background: var(--danger); }

/* ─────────── Modal ─────────── */
.lv-modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.lv-modal-bg.show { opacity: 1; pointer-events: auto; }
.lv-modal {
  background: white; border-radius: var(--radius-lg);
  max-width: 720px; width: 100%; max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.lv-modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.lv-modal-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.lv-modal-head .close { margin-left: auto; cursor: pointer; color: var(--text-300); font-size: 20px; line-height: 1; }
.lv-modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.lv-modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--bg-soft); }

/* ─────────── Toast ─────────── */
.lv-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 12px 22px; border-radius: 24px; color: white; font-weight: 500;
  font-size: 13px; box-shadow: var(--shadow-lg);
  z-index: 1100; opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none; max-width: 90vw;
}
.lv-toast.show { opacity: 1; }
.lv-toast.ok { background: #15803d; }
.lv-toast.err { background: #b91c1c; }
.lv-toast.info { background: #1d4ed8; }
.lv-toast.warn { background: #b45309; }

/* ─────────── Login overlay ─────────── */
.lv-login-bg {
  position: fixed; inset: 0; background: linear-gradient(135deg, #e8eaf0 0%, #f5f7fa 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 2000;
}
.lv-login-box {
  background: white; border-radius: 18px; padding: 36px 32px;
  width: 100%; max-width: 380px; box-shadow: var(--shadow-lg);
}
.lv-login-box .lv-logo-big {
  text-align: center; margin-bottom: 28px;
}
.lv-login-box .lv-logo-big .brand {
  font-size: 30px; font-weight: 800; color: #1f2937; letter-spacing: -0.5px;
}
.lv-login-box .lv-logo-big .brand .accent { color: var(--lvl); }
.lv-login-box .lv-logo-big .tag {
  font-size: 12px; color: var(--text-300); margin-top: 6px;
}
.lv-login-box label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-200); margin-top: 16px; margin-bottom: 6px;
}
.lv-login-box input {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border-strong);
  border-radius: 8px; font-size: 14px; outline: none;
  transition: border 0.15s ease; font-family: inherit;
}
.lv-login-box input:focus { border-color: var(--gal); }
.lv-login-box button {
  width: 100%; margin-top: 22px; padding: 12px;
  background: var(--gal); color: white; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.lv-login-box button:hover:not(:disabled) { background: var(--gal-dark); }
.lv-login-box button:disabled { opacity: 0.6; cursor: not-allowed; }
.lv-login-box .lv-login-err {
  color: var(--danger); font-size: 12px; margin-top: 12px;
  text-align: center; min-height: 18px;
}

/* ─────────── Spinner ─────────── */
.lv-spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
  border-radius: 50%; animation: lv-spin-anim 0.7s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes lv-spin-anim { to { transform: rotate(360deg); } }

/* ─────────── Empty state ─────────── */
.lv-empty {
  text-align: center; padding: 40px 20px; color: var(--text-300);
  background: var(--bg-soft); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md); font-size: 13px;
}
.lv-empty .icon { font-size: 36px; opacity: 0.4; margin-bottom: 10px; }

/* ─────────── Detalle día fichaje (timeline) ─────────── */
.lv-timeline { padding: 4px 0; }
.lv-timeline .step {
  display: grid; grid-template-columns: 22px 80px 1fr auto;
  gap: 10px; align-items: start; padding: 10px 0;
  border-bottom: 1px dashed var(--border); font-size: 12px;
}
.lv-timeline .step:last-child { border-bottom: 0; }
.lv-timeline .dot {
  width: 12px; height: 12px; border-radius: 50%; margin-top: 4px;
  border: 2px solid white; box-shadow: 0 0 0 1px var(--border);
}
.lv-timeline .dot.entrada { background: var(--success); }
.lv-timeline .dot.inicio_pausa { background: var(--warn); }
.lv-timeline .dot.fin_pausa { background: var(--gal); }
.lv-timeline .dot.salida, .lv-timeline .dot.salida_justificada { background: var(--danger); }
.lv-timeline .hora { font-weight: 600; font-variant-numeric: tabular-nums; }
.lv-timeline .meta { color: var(--text-300); font-size: 11px; margin-top: 2px; }
.lv-timeline .anulado { opacity: 0.5; text-decoration: line-through; }

/* ─────────── Map container ─────────── */
.lv-map { width: 100%; height: 260px; border-radius: var(--radius-md); border: 1px solid var(--border); }

/* Hidden helper */
.lv-hidden { display: none !important; }

/* Responsive: pantallas pequeñas */
@media (max-width: 900px) {
  .lv-body { grid-template-columns: 1fr; }
  .lv-sidebar { display: none; }
  .lv-kpis { grid-template-columns: repeat(2, 1fr); }
}
